static SubstrateServerMessage receive(DataInputStream is) throws IOException { try { ServerCommand command = ServerCommand.values()[is.readInt()]; int length = is.readInt(); byte[] payload = new byte[length]; is.readFully(payload); return new SubstrateServerMessage(command, payload); } catch (EOFException ex) { return null; } }
private static void sendExitStatus(DataOutputStream output, int exitStatus) { try { SubstrateServerMessage.send(new SubstrateServerMessage(ServerCommand.SEND_STATUS, ByteBuffer.allocate(4).putInt(exitStatus).array()), output); } catch (IOException e) { throw VMError.shouldNotReachHere(e); } }
private static void sendError(DataOutputStream output, String message) { try { SubstrateServerMessage.send(new SubstrateServerMessage(ServerCommand.WRITE_ERR, message.getBytes()), output); } catch (IOException e) { throw VMError.shouldNotReachHere(e); } }
@Override public void write(byte[] b, int off, int len) throws IOException { if (interrupted) { throw new ClosedByInterruptException(); } writing = true; try { SubstrateServerMessage message = new SubstrateServerMessage(command, b, off, len); SubstrateServerMessage.send(message, original); } finally { writing = false; } }
DataInputStream is = new DataInputStream(svmClient.getInputStream())) { SubstrateServerMessage.send(new SubstrateServerMessage(command, payload), os); if (ServerCommand.GET_VERSION.equals(command)) { SubstrateServerMessage response = SubstrateServerMessage.receive(is);
case GET_VERSION: log("Received 'version' request. Responding with " + System.getProperty(GRAALVM_VERSION_PROPERTY) + ".\n"); SubstrateServerMessage.send(new SubstrateServerMessage(serverCommand.command, System.getProperty(GRAALVM_VERSION_PROPERTY).getBytes()), output); return Instant.now().isBefore(lastKeepAliveAction.plus(Duration.ofMinutes(TIMEOUT_MINUTES))); case BUILD_IMAGE: