void setComms(ServerConnection sc, Socket socket, ByteBuffer bb, MessageStats msgStats) throws IOException { this.serverConnection = sc; setComms(socket, bb, msgStats); }
void setComms(Socket socket, ByteBuffer bb, MessageStats msgStats) throws IOException { this.socketChannel = socket.getChannel(); if (this.socketChannel == null) { setComms(socket, socket.getInputStream(), socket.getOutputStream(), bb, msgStats); } else { setComms(socket, null, null, bb, msgStats); } }
/** * Creates a cached {@link Message}object whose state is filled in with a message received from * the server. */ private Message initializeMessage() { Message message = new Message(2, Version.CURRENT); message.setComms(this.socket, this.in, this.out, this.commBuffer, this.stats); return message; }
void initStreams(Socket s, int socketBufferSize, MessageStats messageStats) { try { if (getAcceptor().isSelector()) { // set it on the message to null. This causes Message // to fetch it from a thread local. That way we only need // one per thread in our selector thread pool instead of // one per connection. commBuffer = null; } else { commBuffer = allocateCommBuffer(socketBufferSize, s); } requestMessage.setComms(this, theSocket, commBuffer, messageStats); replyMessage.setComms(this, theSocket, commBuffer, messageStats); responseMessage.setComms(this, theSocket, commBuffer, messageStats); errorMessage.setComms(this, theSocket, commBuffer, messageStats); chunkedResponseMessage.setComms(this, theSocket, commBuffer, messageStats); queryResponseMessage.setComms(this, theSocket, commBuffer, messageStats); executeFunctionResponseMessage.setComms(this, theSocket, commBuffer, messageStats); registerInterestResponseMessage.setComms(this, theSocket, commBuffer, messageStats); keySetResponseMessage.setComms(this, theSocket, commBuffer, messageStats); } catch (RuntimeException re) { throw re; } catch (Exception e) { logger.fatal(e.getMessage(), e); } }
private void sendMessage(Message message) throws IOException { if (message == null) { return; } this.socketWriteLock.lock(); try { message.setComms(getSocket(), getCommBuffer(), getStatistics()); message.send(); getProxy().resetPingCounter(); } finally { this.socketWriteLock.unlock(); } if (logger.isTraceEnabled()) { logger.trace("{}: Sent {}", this, message); } }
@Before public void setUp() throws Exception { Socket mockSocket = mock(Socket.class); this.message = new Message(2, Version.CURRENT); assertEquals(2, this.message.getNumberOfParts()); MessageStats mockStats = mock(MessageStats.class); ByteBuffer msgBuffer = ByteBuffer.allocate(1000); ServerConnection mockServerConnection = mock(ServerConnection.class); this.message.setComms(mockServerConnection, mockSocket, msgBuffer, mockStats); }
MessageStats messageStats = mock(MessageStats.class); message.setComms(socket, ByteBuffer.allocate(100), messageStats); message.receiveWithHeaderReadTimeout(500);
/** * Attempts to send this operation's message out on the given connection * * @param cnx the connection to use when sending * @throws Exception if the send fails */ protected void attemptSend(Connection cnx) throws Exception { setMsgTransactionId(); if (logger.isTraceEnabled(LogMarker.DISTRIBUTION_BRIDGE_SERVER_VERBOSE)) { logger.trace(LogMarker.DISTRIBUTION_BRIDGE_SERVER_VERBOSE, "Sending op={} using {}", getShortClassName(), cnx); } getMessage().setComms(cnx.getSocket(), cnx.getInputStream(), cnx.getOutputStream(), cnx.getCommBuffer(), cnx.getStats()); try { sendMessage(cnx); } finally { getMessage().unsetComms(); } }
@Override protected Object attemptReadResponse(Connection cnx) throws Exception { Message msg = createResponseMessage(); if (msg != null) { msg.setComms(cnx.getSocket(), cnx.getInputStream(), cnx.getOutputStream(), cnx.getCommBuffer(), cnx.getStats()); if (msg instanceof ChunkedMessage) { try { return processResponse(cnx, msg); } finally { msg.unsetComms(); processSecureBytes(cnx, msg); } } else { try { msg.receive(); } finally { msg.unsetComms(); processSecureBytes(cnx, msg); } return processResponse(cnx, msg); } } else { return null; } }
Message msg = createResponseMessage(); if (msg != null) { msg.setComms(cnx.getSocket(), cnx.getInputStream(), cnx.getOutputStream(), ((ConnectionImpl) cnx).getCommBufferForAsyncRead(), cnx.getStats()); if (msg instanceof ChunkedMessage) {
Message msg = createResponseMessage(); if (msg != null) { msg.setComms(cnx.getSocket(), cnx.getInputStream(), cnx.getOutputStream(), cnx.getCommBuffer(), cnx.getStats()); if (msg instanceof ChunkedMessage) {
Message msg = createResponseMessage(); if (msg != null) { msg.setComms(cnx.getSocket(), cnx.getInputStream(), cnx.getOutputStream(), cnx.getCommBuffer(), cnx.getStats()); if (msg instanceof ChunkedMessage) {