public void close() throws IOException { connection.close(); } }
public void handleFinished(final Connection connection) throws IOException { final ProcessControllerClient client = (ProcessControllerClient) connection.getAttachment(); messageHandler.handleConnectionFinished(client); } });
public MessageHandler handleConnected(final Connection connection) throws IOException { SERVER_LOGGER.tracef("Received connection from %s", connection.getPeerAddress()); return new InitMessageHandler(processController); }
public void requestProcessInventory() throws IOException { final OutputStream os = connection.writeMessage(); try { os.write(Protocol.REQUEST_PROCESS_INVENTORY); os.close(); } finally { safeClose(os); } }
public void handleMessage(final Connection connection, final InputStream dataStream) throws IOException { final int cmd = readUnsignedByte(dataStream); if (cmd != Protocol.AUTH) { ProcessLogger.SERVER_LOGGER.receivedUnknownGreetingCode(Integer.valueOf(cmd), connection.getPeerAddress()); connection.close(); return; } final int version = StreamUtils.readUnsignedByte(dataStream); if (version < 1) { ProcessLogger.SERVER_LOGGER.receivedInvalidVersion(connection.getPeerAddress()); connection.close(); return; } final byte[] authCode = new byte[ProcessController.AUTH_BYTES_ENCODED_LENGTH]; StreamUtils.readFully(dataStream, authCode); final ManagedProcess process = processController.getServerByAuthCode(authCode); if (process == null) { ProcessLogger.SERVER_LOGGER.receivedUnknownCredentials(connection.getPeerAddress()); StreamUtils.safeClose(connection); return; } ProcessLogger.SERVER_LOGGER.tracef("Received authentic connection from %s", connection.getPeerAddress()); connection.setMessageHandler(new ConnectedMessageHandler(processController, process.isPrivileged())); processController.addManagedConnection(connection); dataStream.close(); // Reset the respawn count for the connecting process process.resetRespawnCount(); }
boolean ok = false; try { final OutputStream os = connection.writeMessage(); try { os.write(Protocol.AUTH); os.write(authCode.getBytes(Charset.forName("US-ASCII"))); final ProcessControllerClient processControllerClient = new ProcessControllerClient(connection); connection.attach(processControllerClient); ProcessLogger.CLIENT_LOGGER.trace("Sent initial greeting message"); os.close();
public void handleShutdown(final Connection connection) throws IOException { SERVER_LOGGER.tracef("Received end-of-stream for connection"); processController.removeManagedConnection(connection); connection.shutdownWrites(); }
public void requestProcessInventory() throws IOException { final OutputStream os = connection.writeMessage(); try { os.write(Protocol.REQUEST_PROCESS_INVENTORY); os.close(); } finally { safeClose(os); } }
public void handleMessage(final Connection connection, final InputStream dataStream) throws IOException { final int cmd = readUnsignedByte(dataStream); if (cmd != Protocol.AUTH) { SERVER_LOGGER.receivedUnknownGreetingCode(Integer.valueOf(cmd), connection.getPeerAddress()); connection.close(); return; } final int version = StreamUtils.readUnsignedByte(dataStream); if (version < 1) { SERVER_LOGGER.receivedInvalidVersion(connection.getPeerAddress()); connection.close(); return; } final byte[] authCode = new byte[16]; StreamUtils.readFully(dataStream, authCode); final ManagedProcess process = processController.getServerByAuthCode(authCode); if (process == null) { SERVER_LOGGER.receivedUnknownCredentials(connection.getPeerAddress()); StreamUtils.safeClose(connection); return; } SERVER_LOGGER.tracef("Received authentic connection from %s", connection.getPeerAddress()); connection.setMessageHandler(new ConnectedMessageHandler(processController, process.isPrivileged())); processController.addManagedConnection(connection); dataStream.close(); // Reset the respawn count for the connecting process process.resetRespawnCount(); }
boolean ok = false; try { final OutputStream os = connection.writeMessage(); try { os.write(Protocol.AUTH); os.write(authCode.getBytes(Charset.forName("US-ASCII"))); final ProcessControllerClient processControllerClient = new ProcessControllerClient(connection); connection.attach(processControllerClient); ProcessLogger.CLIENT_LOGGER.trace("Sent initial greeting message"); os.close();
public void handleShutdown(final Connection connection) throws IOException { ProcessLogger.SERVER_LOGGER.tracef("Received end-of-stream for connection"); processController.removeManagedConnection(connection); connection.shutdownWrites(); }
public void requestProcessInventory() throws IOException { final OutputStream os = connection.writeMessage(); try { os.write(Protocol.REQUEST_PROCESS_INVENTORY); os.close(); } finally { safeClose(os); } }
public void handleMessage(final Connection connection, final InputStream dataStream) throws IOException { final int cmd = readUnsignedByte(dataStream); if (cmd != Protocol.AUTH) { ProcessLogger.SERVER_LOGGER.receivedUnknownGreetingCode(Integer.valueOf(cmd), connection.getPeerAddress()); connection.close(); return; } final int version = StreamUtils.readUnsignedByte(dataStream); if (version < 1) { ProcessLogger.SERVER_LOGGER.receivedInvalidVersion(connection.getPeerAddress()); connection.close(); return; } final byte[] authCode = new byte[ProcessController.AUTH_BYTES_ENCODED_LENGTH]; StreamUtils.readFully(dataStream, authCode); final ManagedProcess process = processController.getServerByAuthCode(authCode); if (process == null) { ProcessLogger.SERVER_LOGGER.receivedUnknownCredentials(connection.getPeerAddress()); StreamUtils.safeClose(connection); return; } ProcessLogger.SERVER_LOGGER.tracef("Received authentic connection from %s", connection.getPeerAddress()); connection.setMessageHandler(new ConnectedMessageHandler(processController, process.isPrivileged())); processController.addManagedConnection(connection); dataStream.close(); // Reset the respawn count for the connecting process process.resetRespawnCount(); }
public void close() throws IOException { connection.close(); } }
public void handleFinished(final Connection connection) throws IOException { final ProcessControllerClient client = (ProcessControllerClient) connection.getAttachment(); messageHandler.handleConnectionFinished(client); } });
boolean ok = false; try { final OutputStream os = connection.writeMessage(); try { os.write(Protocol.AUTH); os.write(authCode); final ProcessControllerClient processControllerClient = new ProcessControllerClient(connection); connection.attach(processControllerClient); CLIENT_LOGGER.trace("Sent initial greeting message"); os.close();
public void handleShutdown(final Connection connection) throws IOException { SERVER_LOGGER.tracef("Received end-of-stream for connection"); processController.removeManagedConnection(connection); connection.shutdownWrites(); }
public MessageHandler handleConnected(final Connection connection) throws IOException { ProcessLogger.SERVER_LOGGER.tracef("Received connection from %s", connection.getPeerAddress()); return new InitMessageHandler(processController); }
public void shutdown(int exitCode) throws IOException { final OutputStream os = connection.writeMessage(); try { os.write(Protocol.SHUTDOWN); writeInt(os, exitCode); os.close(); } finally { safeClose(os); } }
public void close() throws IOException { connection.close(); } }