handler.receiveCloseRequest(); return; handler.receiveCloseRequest(); final RegisteredService registeredService = handler.getConnectionContext().getRegisteredService(serviceType); if (registeredService == null) { refuseService(channelId, "Unknown service name"); if (! handler.handleInboundChannelOpen()) { RemoteConnectionChannel existing = handler.addChannel(connectionChannel); if (existing != null) { log.tracef("Encountered open request for duplicate %s", existing); if (! ok1) handler.handleInboundChannelClosed(); log.trace("Received message data"); int channelId = buffer.getInt() ^ 0x80000000; RemoteConnectionChannel connectionChannel = handler.getChannel(channelId); if (connectionChannel == null) { log.trace("Received message window open"); int channelId = buffer.getInt() ^ 0x80000000; RemoteConnectionChannel connectionChannel = handler.getChannel(channelId); if (connectionChannel == null) { log.trace("Received message async close"); int channelId = buffer.getInt() ^ 0x80000000;
/** * The remote side requests a close of the whole channel. */ void receiveCloseRequest() { int oldState, newState; do { oldState = channelState; if ((oldState & RECEIVED_CLOSE_REQ) != 0) { // ignore duplicate, weird though it may be return; } newState = oldState | RECEIVED_CLOSE_REQ | SENT_CLOSE_REQ; } while (!casState(oldState, newState)); closePendingChannels(); log.tracef("Received remote close request on %s", this); if ((oldState & SENT_CLOSE_REQ) == 0) { sendCloseRequestBody(); closeAllChannels(); } if ((oldState & (INBOUND_CHANNELS_MASK | OUTBOUND_CHANNELS_MASK)) == 0) { remoteConnection.shutdownWrites(); } }
private void doGetConnectionState(final StringBuilder b) { b.append("Connection state for ").append(this).append(':').append('\n'); synchronized (handlers) { for (RemoteConnectionHandler handler : handlers) { handler.dumpState(b); } } }
void sendCloseRequest() { int oldState, newState; do { oldState = channelState; if ((oldState & SENT_CLOSE_REQ) != 0) { // idempotent close return; } newState = oldState | SENT_CLOSE_REQ; } while (!casState(oldState, newState)); log.tracef("Sending close request on %s", this); sendCloseRequestBody(); closeAllChannels(); if ((oldState & (INBOUND_CHANNELS_MASK | OUTBOUND_CHANNELS_MASK)) == 0) { remoteConnection.shutdownWrites(); } }
/** * A channel was closed, locally or remotely. * * @param channel the channel that was closed */ void handleChannelClosed(RemoteConnectionChannel channel) { int channelId = channel.getChannelId(); channels.remove(channel); boolean inbound = (channelId & 0x80000000) == 0; if (inbound) { handleInboundChannelClosed(); } else { handleOutboundChannelClosed(); } }
protected void closeAction() throws IOException { sendCloseRequest(); remoteConnection.shutdownWrites(); remoteConnection.getMessageReader().shutdownReads(); // now these guys can't send useless messages closePendingChannels(); closeAllChannels(); remoteConnection.getRemoteConnectionProvider().removeConnectionHandler(this); }
/** * The socket channel was closed with or without our consent. */ void handleConnectionClose() { remoteConnection.shutdownWrites(); closePendingChannels(); closeAllChannels(); }
boolean handleInboundChannelOpen() { int oldState, newState; do { oldState = channelState; int oldCount = oldState & INBOUND_CHANNELS_MASK; if (oldCount == maxInboundChannels) { log.tracef("Refused inbound channel request on %s because too many inbound channels are open", this); return false; } if ((oldState & SENT_CLOSE_REQ) != 0) { log.tracef("Refused inbound channel request on %s because close request was sent", this); return false; } newState = oldState + ONE_INBOUND_CHANNEL; } while (!casState(oldState, newState)); log.tracef("Opened inbound channel on %s", this); return true; }
final RemoteConnectionHandler connectionHandler = new RemoteConnectionHandler( connectionContext, connection, maxInboundChannels, maxOutboundChannels, AnonymousPrincipal.getInstance(), remoteEndpointName, behavior, authCap, offeredMechanisms, peerName, serverName); connection.getRemoteConnectionProvider().addConnectionHandler(connectionHandler);
private void unregister() { log.tracef("Unregistering %s", this); closeAsync(); connectionHandler.handleChannelClosed(this); }
RemoteConnectionChannel(final RemoteConnectionHandler connectionHandler, final RemoteConnection connection, final int channelId, final int outboundWindow, final int inboundWindow, final int maxOutboundMessages, final int maxInboundMessages, final long maxOutboundMessageSize, final long maxInboundMessageSize) { super(connectionHandler.getConnectionContext().getConnectionProviderContext().getExecutor(), true); this.maxOutboundMessageSize = maxOutboundMessageSize; this.maxInboundMessageSize = maxInboundMessageSize; connectionHandlerContext = connectionHandler.getConnectionContext(); this.connectionHandler = connectionHandler; this.connection = connection; this.channelId = channelId; this.outboundWindow = outboundWindow; this.inboundWindow = inboundWindow; this.maxOutboundMessages = maxOutboundMessages; this.maxInboundMessages = maxInboundMessages; }
protected void closeAction() throws IOException { sendCloseRequest(); remoteConnection.shutdownWrites(); remoteConnection.getMessageReader().shutdownReads(); // now these guys can't send useless messages closePendingChannels(); closeAllChannels(); remoteConnection.getRemoteConnectionProvider().removeConnectionHandler(this); }
void sendCloseRequest() { int oldState, newState; do { oldState = channelState; if ((oldState & SENT_CLOSE_REQ) != 0) { // idempotent close return; } newState = oldState | SENT_CLOSE_REQ; } while (!casState(oldState, newState)); log.tracef("Sending close request on %s", this); sendCloseRequestBody(); closeAllChannels(); if ((oldState & (INBOUND_CHANNELS_MASK | OUTBOUND_CHANNELS_MASK)) == 0) { remoteConnection.shutdownWrites(); } }
/** * A channel was closed, locally or remotely. * * @param channel the channel that was closed */ void handleChannelClosed(RemoteConnectionChannel channel) { int channelId = channel.getChannelId(); channels.remove(channel); boolean inbound = (channelId & 0x80000000) == 0; if (inbound) { handleInboundChannelClosed(); } else { handleOutboundChannelClosed(); } }
void handleOutboundChannelOpen() throws IOException { int oldState, newState; do { oldState = channelState; int oldCount = oldState & OUTBOUND_CHANNELS_MASK; if (oldCount == maxOutboundChannels) { log.tracef("Refused outbound channel open on %s because too many outbound channels are open", this); throw new ProtocolException("Too many channels open"); } if ((oldState & SENT_CLOSE_REQ) != 0) { log.tracef("Refused outbound channel open on %s because close request was sent", this); throw new NotOpenException("Cannot open new channel because close was initiated"); } newState = oldState + ONE_OUTBOUND_CHANNEL; } while (!casState(oldState, newState)); log.tracef("Opened outbound channel on %s", this); }
final RemoteConnectionHandler connectionHandler = new RemoteConnectionHandler(connectionContext, connection, maxInboundChannels, maxOutboundChannels, principalObj instanceof Principal ? (Principal) principalObj : AnonymousPrincipal.getInstance(), remoteEndpointName, behavior, authCap, offeredMechanisms, serverName, hostName); connection.setReadListener(new RemoteReadListener(connectionHandler, connection), false); connection.getRemoteConnectionProvider().addConnectionHandler(connectionHandler);
private void unregister() { log.tracef("Unregistering %s", this); closeAsync(); connectionHandler.handleChannelClosed(this); }
RemoteConnectionChannel(final RemoteConnectionHandler connectionHandler, final RemoteConnection connection, final int channelId, final int outboundWindow, final int inboundWindow, final int maxOutboundMessages, final int maxInboundMessages, final long maxOutboundMessageSize, final long maxInboundMessageSize) { super(connectionHandler.getConnectionContext().getConnectionProviderContext().getExecutor(), true); this.maxOutboundMessageSize = maxOutboundMessageSize; this.maxInboundMessageSize = maxInboundMessageSize; connectionHandlerContext = connectionHandler.getConnectionContext(); this.connectionHandler = connectionHandler; this.connection = connection; this.channelId = channelId; this.outboundWindow = outboundWindow; this.inboundWindow = inboundWindow; this.maxOutboundMessages = maxOutboundMessages; this.maxInboundMessages = maxInboundMessages; }
handler.receiveCloseRequest(); return; handler.receiveCloseRequest(); final RegisteredService registeredService = handler.getConnectionContext().getRegisteredService(serviceType); if (registeredService == null) { refuseService(channelId, "Unknown service name"); if (! handler.handleInboundChannelOpen()) { RemoteConnectionChannel existing = handler.addChannel(connectionChannel); if (existing != null) { log.tracef("Encountered open request for duplicate %s", existing); if (! ok1) handler.handleInboundChannelClosed(); log.trace("Received message data"); int channelId = buffer.getInt() ^ 0x80000000; RemoteConnectionChannel connectionChannel = handler.getChannel(channelId); if (connectionChannel == null) { log.trace("Received message window open"); int channelId = buffer.getInt() ^ 0x80000000; RemoteConnectionChannel connectionChannel = handler.getChannel(channelId); if (connectionChannel == null) { log.trace("Received message async close"); int channelId = buffer.getInt() ^ 0x80000000;
/** * The remote side requests a close of the whole channel. */ void receiveCloseRequest() { int oldState, newState; do { oldState = channelState; if ((oldState & RECEIVED_CLOSE_REQ) != 0) { // ignore duplicate, weird though it may be return; } newState = oldState | RECEIVED_CLOSE_REQ | SENT_CLOSE_REQ; } while (!casState(oldState, newState)); closePendingChannels(); log.tracef("Received remote close request on %s", this); if ((oldState & SENT_CLOSE_REQ) == 0) { sendCloseRequestBody(); closeAllChannels(); } if ((oldState & (INBOUND_CHANNELS_MASK | OUTBOUND_CHANNELS_MASK)) == 0) { remoteConnection.shutdownWrites(); } }