Package com.sun.sgs.protocol

Examples of com.sun.sgs.protocol.SessionProtocol


      this.message = message;
  }
 
  public void run(BigInteger sessionRefId, long timestamp) {

      SessionProtocol protocol =
    sessionService.getSessionProtocol(sessionRefId);
      if (protocol != null) {
    Map<BigInteger, LocalMemberInfo> channelMap =
        localPerSessionChannelMap.get(sessionRefId);
    if (channelMap == null) {
        // The session doesn't belong to any channels.
        return;
    }
                // There is a small window here where the channelMap may
                // have been removed from the localPerSessionChannelMap by a
                // disconnect handler after it has been retrieved from the map
                // by this task above.  Therefore, we need to check if
                // disconnection is in progress before synchronizing on the
                // channelMap
                LocalMemberInfo memberInfo = null;
                synchronized (localSessionDisconnectingSet) {
                    if (localSessionDisconnectingSet.contains(sessionRefId)) {
                        // The session is disconnecting so the channelMap
                        // has been removed
                        return;
                    }
                    memberInfo = channelMap.get(channelRefId);
                }
               
   
    if (memberInfo == null) {
        // The session is no longer a member.
        return;
    }
    if (memberInfo.msgTimestamp > timestamp) {
        // If session's message timestamp for this channel is
        // greater than the timestamp of the message to be
        // delivered, then this is an earlier message sent
        // before the session joined the channel.  Therefore
        // don't deliver the message.
        return;
    }
    memberInfo.msgTimestamp = timestamp;
    try {
        protocol.channelMessage(
      channelRefId, ByteBuffer.wrap(message), delivery);
    } catch (IOException e) {
        logger.logThrow(Level.WARNING, e,  "channelMessage " +
      "session:{0} channel:{0} throws",
      sessionRefId, channelRefId);
View Full Code Here


  ChannelCloseTask(BigInteger channelRefId) {
      super(channelRefId);
  }

  public void run(BigInteger sessionRefId, long timestamp) {
      SessionProtocol protocol =
    sessionService.getSessionProtocol(sessionRefId);
      if (protocol != null) {
    try {
        protocol.channelLeave(channelRefId);
    } catch (IOException e) {
        logger.logThrow(
      Level.WARNING, e, "channelLeave " +
      "session:{0} channel:{0} throws",
      sessionRefId, channelRefId);
View Full Code Here

      // channel request is being handled.  A client session
      // relocating from a node should not have any concurrent or
      // future channel requests processed for it.
      lockSession(sessionRefId);
     
      SessionProtocol protocol =
    sessionService.getSessionProtocol(sessionRefId);
      if (protocol == null) {
    if (!sessionService.isRelocatingToLocalNode(sessionRefId)) {
        // The session is not locally-connected and is not
        // known to be relocating to the local node.
View Full Code Here

    if (logger.isLoggable(Level.FINEST)) {
        logger.log(Level.FINEST, "sessionId:{0} message:{1}",
             HexDumper.toHexString(sessionId),
             HexDumper.toHexString(message));
    }
    SessionProtocol sessionProtocol =
        getSessionProtocol(new BigInteger(1, sessionId));
    if (sessionProtocol != null) {
        Delivery delivery = Delivery.values()[deliveryOrdinal];

        try {
      sessionProtocol.sessionMessage(
          ByteBuffer.wrap(message), delivery);
        } catch (IOException e) {
      // TBD: should we disconnect the session because
      // messages can't be delivered?
      if (logger.isLoggable(Level.FINE)) {
View Full Code Here

      // Update local channel membership set.
      addLocalChannelMember(
     channelRefId, delivery, sessionRefId, timestamp, false);

      // Send channel join protocol message.
      SessionProtocol protocol =
    sessionService.getSessionProtocol(sessionRefId);
      if (protocol != null) {
    try {
        protocol.channelJoin(name, channelRefId, delivery);
    } catch (IOException e) {
        logger.logThrow(Level.WARNING, e, "channelJoin throws");
    }
      }
  }
View Full Code Here

      // from local channel membership set.
      removeLocalPerSessionChannel(channelRefId, sessionRefId);
      removeLocalChannelMember(channelRefId, sessionRefId);
     
      // Send channel leave protocol message.
      SessionProtocol protocol =
    sessionService.getSessionProtocol(sessionRefId);
      if (protocol != null) {
    try {
        protocol.channelLeave(channelRefId);
    } catch (IOException e) {
        logger.logThrow(Level.WARNING, e,
            "channelLeave throws");
    }
      }
View Full Code Here

      this.message = message;
  }
 
  public void run(BigInteger sessionRefId, long timestamp) {

      SessionProtocol protocol =
    sessionService.getSessionProtocol(sessionRefId);
      if (protocol != null) {
    Map<BigInteger, LocalMemberInfo> channelMap =
        localPerSessionChannelMap.get(sessionRefId);
    if (channelMap == null) {
        // The session doesn't belong to any channels.
        return;
    }
    LocalMemberInfo memberInfo = channelMap.get(channelRefId);
    if (memberInfo == null) {
        // The session is no longer a member.
        return;
    }
    if (memberInfo.msgTimestamp > timestamp) {
        // If session's message timestamp for this channel is
        // greater than the timestamp of the message to be
        // delivered, then this is an earlier message sent
        // before the session joined the channel.  Therefore
        // don't deliver the message.
        return;
    }
    memberInfo.msgTimestamp = timestamp;
    try {
        protocol.channelMessage(
      channelRefId, ByteBuffer.wrap(message), delivery);
    } catch (IOException e) {
        logger.logThrow(Level.WARNING, e,  "channelMessage " +
      "session:{0} channel:{0} throws",
      HexDumper.toHexString(sessionRefId),
View Full Code Here

  ChannelCloseTask(BigInteger channelRefId) {
      super(channelRefId);
  }

  public void run(BigInteger sessionRefId, long timestamp) {
      SessionProtocol protocol =
    sessionService.getSessionProtocol(sessionRefId);
      if (protocol != null) {
    try {
        protocol.channelLeave(channelRefId);
    } catch (IOException e) {
        logger.logThrow(
      Level.WARNING, e, "channelLeave " +
      "session:{0} channel:{0} throws",
      HexDumper.toHexString(sessionRefId),
View Full Code Here

      // from local channel membership set.
      removeLocalPerSessionChannel(channelRefId, sessionRefId);
      removeLocalChannelMember(channelRefId, sessionRefId);
     
      // Send channel leave protocol message.
      SessionProtocol protocol =
    sessionService.getSessionProtocol(sessionRefId);
      if (protocol != null) {
    try {
        protocol.channelLeave(channelRefId);
    } catch (IOException e) {
        logger.logThrow(Level.WARNING, e,
            "channelLeave throws");
    }
      }
View Full Code Here

      this.message = message;
  }
 
  public void run(BigInteger sessionRefId, long timestamp) {

      SessionProtocol protocol =
    sessionService.getSessionProtocol(sessionRefId);
      if (protocol != null) {
    Map<BigInteger, LocalMemberInfo> channelMap =
        localPerSessionChannelMap.get(sessionRefId);
    if (channelMap == null) {
        // The session doesn't belong to any channels.
        return;
    }
                // There is a small window here where the channelMap may
                // have been removed from the localPerSessionChannelMap by a
                // disconnect handler after it has been retrieved from the map
                // by this task above.  Therefore, we need to check if
                // disconnection is in progress before synchronizing on the
                // channelMap
                LocalMemberInfo memberInfo = null;
                synchronized (localSessionDisconnectingSet) {
                    if (localSessionDisconnectingSet.contains(sessionRefId)) {
                        // The session is disconnecting so the channelMap
                        // has been removed
                        return;
                    }
                    memberInfo = channelMap.get(channelRefId);
                }
               
   
    if (memberInfo == null) {
        // The session is no longer a member.
        return;
    }
    if (memberInfo.msgTimestamp > timestamp) {
        // If session's message timestamp for this channel is
        // greater than the timestamp of the message to be
        // delivered, then this is an earlier message sent
        // before the session joined the channel.  Therefore
        // don't deliver the message.
        return;
    }
    memberInfo.msgTimestamp = timestamp;
    try {
        protocol.channelMessage(
      channelRefId, ByteBuffer.wrap(message), delivery);
    } catch (IOException e) {
        logger.logThrow(Level.WARNING, e,  "channelMessage " +
      "session:{0} channel:{0} throws",
      sessionRefId, channelRefId);
View Full Code Here

TOP

Related Classes of com.sun.sgs.protocol.SessionProtocol

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.