/** * Converts the passed <code>value</code> into a {@link PackedInteger} and writes it to the * {@link DataOutput output} * * @param output The {@link DataOutput} to which the {@link PackedInteger} is written to * @param value The integer value which will be converted to a {@link PackedInteger} * @throws IOException * @throws IllegalArgumentException If the passed <code>value</code> is < 0. {@link PackedInteger} doesn't * allow signed integer * @throws IllegalArgumentException If the passed <code>output</code> is null */ public static void writePackedInteger(final DataOutput output, int value) throws IOException { if (value < 0) throw new IllegalArgumentException("Only unsigned integer can be packed"); if (value > 127) { output.writeByte(value & 0x7F | 0x80); writePackedInteger(output, value >> 7); } else { output.writeByte(value & 0xFF); } }
public void clusterRemoval(final List<String> clusterNames) { try (MessageOutputStream os = messageTracker.openMessageUninterruptibly()) { os.writeByte(Protocol.CLUSTER_TOPOLOGY_REMOVAL); PackedInteger.writePackedInteger(os, clusterNames.size()); for (String clusterName : clusterNames) { os.writeUTF(clusterName); } } 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); } }
public void clusterNodesRemoved(final List<ClusterRemovalInfo> clusterRemovalInfoList) { try (MessageOutputStream os = messageTracker.openMessageUninterruptibly()) { os.writeByte(Protocol.CLUSTER_TOPOLOGY_NODE_REMOVAL); PackedInteger.writePackedInteger(os, clusterRemovalInfoList.size()); for (ClusterRemovalInfo removalInfo : clusterRemovalInfoList) { os.writeUTF(removalInfo.getClusterName()); final List<String> nodeNamesList = removalInfo.getNodeNames(); PackedInteger.writePackedInteger(os, nodeNamesList.size()); for (String name : nodeNamesList) { os.writeUTF(name); } } } 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); } } }
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); } }
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); } }
private void writeTxnResponse(final int invId, final int flag) { try (MessageOutputStream os = messageTracker.openMessageUninterruptibly()) { os.writeByte(Protocol.TXN_RESPONSE); os.writeShort(invId); os.writeBoolean(true); PackedInteger.writePackedInteger(os, flag); } catch (IOException e) { // nothing to do at this point; the client doesn't want the response Logs.REMOTING.trace("EJB transaction response write failed", e); } }
int transactionTimeout = remoteTransaction.getEstimatedRemainingTime(); if(transactionTimeout == 0) throw Logs.TXN.outflowTransactionTimeoutElapsed(transaction); PackedInteger.writePackedInteger(dataOutput, transactionTimeout); return null; } else if (transaction instanceof LocalTransaction) { final Xid xid = outflowHandle.getXid(); dataOutput.writeByte(2); PackedInteger.writePackedInteger(dataOutput, xid.getFormatId()); final byte[] gtid = xid.getGlobalTransactionId(); dataOutput.writeByte(gtid.length); int transactionTimeout = outflowHandle.getRemainingTime(); if(transactionTimeout == 0) throw Logs.TXN.outflowTransactionTimeoutElapsed(transaction); PackedInteger.writePackedInteger(dataOutput, transactionTimeout); return outflowHandle; } else {
if (sessionId != null) { final byte[] bytes = sessionId.getEncodedForm(); PackedInteger.writePackedInteger(os, bytes.length); os.write(bytes); final String nodeName = weakAffinityUpdate.getNodeName(); final byte[] bytes = nodeName.getBytes(StandardCharsets.UTF_8); PackedInteger.writePackedInteger(os, bytes.length); os.write(bytes); final String clusterName = strongAffinityUpdate.getClusterName(); final byte[] bytes = clusterName.getBytes(StandardCharsets.UTF_8); PackedInteger.writePackedInteger(os, bytes.length); os.write(bytes);
private void doWrite(final boolean available, final List<EJBModuleIdentifier> modules) { try (MessageOutputStream os = messageTracker.openMessageUninterruptibly()) { os.writeByte(available ? Protocol.MODULE_AVAILABLE : Protocol.MODULE_UNAVAILABLE); PackedInteger.writePackedInteger(os, modules.size()); for (EJBModuleIdentifier module : modules) { final String appName = module.getAppName(); os.writeUTF(appName == null ? "" : appName); final String moduleName = module.getModuleName(); os.writeUTF(moduleName == null ? "" : moduleName); final String distinctName = module.getDistinctName(); os.writeUTF(distinctName == null ? "" : distinctName); } } catch (IOException e) { // nothing to do at this point; the client doesn't want the response Logs.REMOTING.trace("EJB availability message write failed", e); } } }
os.writeShort(invId); final byte[] encodedForm = sessionId.getEncodedForm(); PackedInteger.writePackedInteger(os, encodedForm.length); os.write(encodedForm); if (1 <= version && version <= 2) { final String nodeName = weakAffinityUpdate.getNodeName(); final byte[] bytes = nodeName.getBytes(StandardCharsets.UTF_8); PackedInteger.writePackedInteger(os, bytes.length); os.write(bytes); final String clusterName = strongAffinityUpdate.getClusterName(); final byte[] bytes = clusterName.getBytes(StandardCharsets.UTF_8); PackedInteger.writePackedInteger(os, bytes.length); os.write(bytes);
if (version >= 3) { PackedInteger.writePackedInteger(marshaller, totalContextData); PackedInteger.writePackedInteger(marshaller, totalContextData);
os.writeShort(invocation.getIndex()); final byte[] encoded = transactionID.getEncodedForm(); PackedInteger.writePackedInteger(os, encoded.length); os.write(encoded); if (withParam) {
os.writeShort(invocation.getIndex()); final byte[] encoded = transactionID.getEncodedForm(); PackedInteger.writePackedInteger(os, encoded.length); os.write(encoded); if (withParam) {
void handleTxnRecoverRequest(final int invId, final MessageInputStream message) throws IOException { final String parentName = message.readUTF(); final int flags = message.readInt(); final Xid[] xids; try { xids = transactionServer.getTransactionService().getTransactionContext().getRecoveryInterface().recover(flags, parentName); } catch (XAException e) { writeFailedResponse(invId, e); return; } try (MessageOutputStream os = messageTracker.openMessageUninterruptibly()) { os.writeByte(Protocol.TXN_RECOVERY_RESPONSE); os.writeShort(invId); PackedInteger.writePackedInteger(os, xids.length); final Marshaller marshaller = marshallerFactory.createMarshaller(configuration); marshaller.start(new NoFlushByteOutput(Marshalling.createByteOutput(os))); for (Xid xid : xids) { marshaller.writeObject(new XidTransactionID(xid)); } marshaller.finish(); } catch (IOException e) { // nothing to do at this point; the client doesn't want the response Logs.REMOTING.trace("EJB transaction response write failed", e); } }
public void clusterRemoval(final List<String> clusterNames) { try (MessageOutputStream os = messageTracker.openMessageUninterruptibly()) { os.writeByte(Protocol.CLUSTER_TOPOLOGY_REMOVAL); PackedInteger.writePackedInteger(os, clusterNames.size()); for (String clusterName : clusterNames) { os.writeUTF(clusterName); } } 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); } }
public void clusterRemoval(final List<String> clusterNames) { try (MessageOutputStream os = messageTracker.openMessageUninterruptibly()) { os.writeByte(Protocol.CLUSTER_TOPOLOGY_REMOVAL); PackedInteger.writePackedInteger(os, clusterNames.size()); for (String clusterName : clusterNames) { os.writeUTF(clusterName); } } 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); } }
public void clusterNodesRemoved(final List<ClusterRemovalInfo> clusterRemovalInfoList) { try (MessageOutputStream os = messageTracker.openMessageUninterruptibly()) { os.writeByte(Protocol.CLUSTER_TOPOLOGY_NODE_REMOVAL); PackedInteger.writePackedInteger(os, clusterRemovalInfoList.size()); for (ClusterRemovalInfo removalInfo : clusterRemovalInfoList) { os.writeUTF(removalInfo.getClusterName()); final List<String> nodeNamesList = removalInfo.getNodeNames(); PackedInteger.writePackedInteger(os, nodeNamesList.size()); for (String name : nodeNamesList) { os.writeUTF(name); } } } 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); } } }
private void writeTxnResponse(final int invId, final int flag) { try (MessageOutputStream os = messageTracker.openMessageUninterruptibly()) { os.writeByte(Protocol.TXN_RESPONSE); os.writeShort(invId); os.writeBoolean(true); PackedInteger.writePackedInteger(os, flag); } catch (IOException e) { // nothing to do at this point; the client doesn't want the response Logs.REMOTING.trace("EJB transaction response write failed", e); } }
private void writeTxnResponse(final int invId, final int flag) { try (MessageOutputStream os = messageTracker.openMessageUninterruptibly()) { os.writeByte(Protocol.TXN_RESPONSE); os.writeShort(invId); os.writeBoolean(true); PackedInteger.writePackedInteger(os, flag); } catch (IOException e) { // nothing to do at this point; the client doesn't want the response Logs.REMOTING.trace("EJB transaction response write failed", e); } }
private void doWrite(final boolean available, final List<EJBModuleIdentifier> modules) { try (MessageOutputStream os = messageTracker.openMessageUninterruptibly()) { os.writeByte(available ? Protocol.MODULE_AVAILABLE : Protocol.MODULE_UNAVAILABLE); PackedInteger.writePackedInteger(os, modules.size()); for (EJBModuleIdentifier module : modules) { final String appName = module.getAppName(); os.writeUTF(appName == null ? "" : appName); final String moduleName = module.getModuleName(); os.writeUTF(moduleName == null ? "" : moduleName); final String distinctName = module.getDistinctName(); os.writeUTF(distinctName == null ? "" : distinctName); } } catch (IOException e) { // nothing to do at this point; the client doesn't want the response Logs.REMOTING.trace("EJB availability message write failed", e); } } }