public void clusterNewNodesAdded(final ClusterInfo clusterInfo) { try (MessageOutputStream os = messageTracker.openMessageUninterruptibly()) { os.writeByte(Protocol.CLUSTER_TOPOLOGY_ADDITION); PackedInteger.writePackedInteger(os, 1); os.writeUTF(clusterInfo.getClusterName()); final List<NodeInfo> nodeInfoList = clusterInfo.getNodeInfoList(); PackedInteger.writePackedInteger(os, nodeInfoList.size()); for (NodeInfo nodeInfo : nodeInfoList) { os.writeUTF(nodeInfo.getNodeName()); final List<MappingInfo> mappingInfoList = nodeInfo.getMappingInfoList(); PackedInteger.writePackedInteger(os, mappingInfoList.size()); for (MappingInfo mappingInfo : mappingInfoList) { boolean is6 = mappingInfo.getSourceAddress() instanceof Inet6Address; if (is6) { PackedInteger.writePackedInteger(os, mappingInfo.getNetmaskBits() << 1); } else { PackedInteger.writePackedInteger(os, mappingInfo.getNetmaskBits() << 1 | 1); } os.write(mappingInfo.getSourceAddress().getAddress()); os.writeUTF(mappingInfo.getDestinationAddress()); os.writeShort(mappingInfo.getDestinationPort()); } } } catch (IOException e) { // nothing to do at this point; the client doesn't want the response Logs.REMOTING.trace("EJB cluster message write failed", e); } }
boolean cancelInvocation(final EJBReceiverInvocationContext receiverContext, boolean cancelIfRunning) { if (version < 3 && ! cancelIfRunning) { // keep legacy behavior return false; } final MethodInvocation invocation = receiverContext.getClientInvocationContext().getAttachment(INV_KEY); if (invocation == null) { // lost it somehow return false; } if (invocation.alloc()) try { final int index = invocation.getIndex(); try (MessageOutputStream out = invocationTracker.allocateMessage()) { out.write(Protocol.CANCEL_REQUEST); out.writeShort(index); if (version >= 3) { out.writeBoolean(cancelIfRunning); } } catch (IOException ignored) {} } finally { invocation.free(); } // now await the result return invocation.receiverInvocationContext.getClientInvocationContext().awaitCancellationResult(); }
final byte[] encoded = transactionID.getEncodedForm(); PackedInteger.writePackedInteger(os, encoded.length); os.write(encoded); if (withParam) { os.writeBoolean(true);
final byte[] encodedForm = sessionId.getEncodedForm(); PackedInteger.writePackedInteger(os, encodedForm.length); os.write(encodedForm); if (1 <= version && version <= 2) { final Marshaller marshaller = marshallerFactory.createMarshaller(configuration); final byte[] bytes = nodeName.getBytes(StandardCharsets.UTF_8); PackedInteger.writePackedInteger(os, bytes.length); os.write(bytes); final byte[] bytes = clusterName.getBytes(StandardCharsets.UTF_8); PackedInteger.writePackedInteger(os, bytes.length); os.write(bytes);
public <T> StatefulEJBLocator<T> openSession(final StatelessEJBLocator<T> statelessLocator, final ConnectionPeerIdentity identity, EJBSessionCreationInvocationContext clientInvocationContext) throws Exception { SessionOpenInvocation<T> invocation = invocationTracker.addInvocation(id -> new SessionOpenInvocation<>(id, statelessLocator, clientInvocationContext)); try (MessageOutputStream out = invocationTracker.allocateMessage()) { out.write(Protocol.OPEN_SESSION_REQUEST); out.writeShort(invocation.getIndex()); writeRawIdentifier(statelessLocator, out); if (version >= 3) { out.writeInt(identity.getId()); invocation.setOutflowHandle(writeTransaction(clientInvocationContext.getTransaction(), out)); } } catch (IOException e) { CreateException createException = new CreateException(e.getMessage()); createException.initCause(e); throw createException; } // await the response return invocation.getResult(); }
out.write(version); out.writeUTF("river");
public void clusterTopology(final List<ClusterInfo> clusterInfoList) { try (MessageOutputStream os = messageTracker.openMessageUninterruptibly()) { os.writeByte(Protocol.CLUSTER_TOPOLOGY_COMPLETE); PackedInteger.writePackedInteger(os, clusterInfoList.size()); for (ClusterInfo clusterInfo : clusterInfoList) { os.writeUTF(clusterInfo.getClusterName()); final List<NodeInfo> nodeInfoList = clusterInfo.getNodeInfoList(); PackedInteger.writePackedInteger(os, nodeInfoList.size()); for (NodeInfo nodeInfo : nodeInfoList) { os.writeUTF(nodeInfo.getNodeName()); final List<MappingInfo> mappingInfoList = nodeInfo.getMappingInfoList(); PackedInteger.writePackedInteger(os, mappingInfoList.size()); for (MappingInfo mappingInfo : mappingInfoList) { boolean is6 = mappingInfo.getSourceAddress() instanceof Inet6Address; if (is6) { PackedInteger.writePackedInteger(os, mappingInfo.getNetmaskBits() << 1); } else { PackedInteger.writePackedInteger(os, mappingInfo.getNetmaskBits() << 1 | 1); } os.write(mappingInfo.getSourceAddress().getAddress()); os.writeUTF(mappingInfo.getDestinationAddress()); os.writeShort(mappingInfo.getDestinationPort()); } } } } catch (IOException e) { // nothing to do at this point; the client doesn't want the response Logs.REMOTING.trace("EJB cluster message write failed", e); } }
final byte[] encoded = transactionID.getEncodedForm(); PackedInteger.writePackedInteger(os, encoded.length); os.write(encoded); if (withParam) { os.writeBoolean(param);
/** {@inheritDoc} */ public void writeByte(final int v) throws IOException { write(v); }
public void write(final byte[] b, final int off, final int len) throws IOException { delegate.write(b, off, len); } }
public void write(final byte[] b) throws IOException { delegate.write(b); }
/** {@inheritDoc} */ public void writeBoolean(final boolean v) throws IOException { write(v ? 1 : 0); }
public void write(final int b) throws IOException { delegate.write(b); }
/** {@inheritDoc} */ public void writeBytes(final String s) throws IOException { int len = s.length(); for (int i = 0 ; i < len ; i++) { write(s.charAt(i)); } }
write(bytes, 0, bytes.length);
messageOutputStream.write(Protocol.COMPRESSED_INVOCATION_MESSAGE);