protected void writeAttachments(final ObjectOutput output, final Map<String, Object> attachments) throws IOException { if (attachments == null) { output.writeByte(0); return; } // write the attachment count PackedInteger.writePackedInteger(output, attachments.size()); for (Map.Entry<String, Object> entry : attachments.entrySet()) { output.writeObject(entry.getKey()); output.writeObject(entry.getValue()); } }
final int transactionIDBytesLength = PackedInteger.readPackedInteger(input);
void writeNodesRemoved(final DataOutput output, final String clusterName, final Set<String> removedNodes) throws IOException { if (output == null) { throw EjbMessages.MESSAGES.cannotWriteToNullDataOutput(); } if (removedNodes == null || removedNodes.isEmpty()) { return; } // write the header output.write(HEADER_NODES_REMOVED); // write the cluster count PackedInteger.writePackedInteger(output, 1); // write the cluster name output.writeUTF(clusterName); // write the removed nodes count final int removedNodesCount = removedNodes.size(); PackedInteger.writePackedInteger(output, removedNodesCount); // write out the member info for each removed member for (final String node : removedNodes) { // write the node name output.writeUTF(node); } }
void writeNewNodesAdded(final DataOutput output, final String clusterName, final Map<String, List<ClientMapping>> clientMappings) throws IOException { if (output == null) { throw EjbMessages.MESSAGES.cannotWriteToNullDataOutput(); } if (clientMappings.isEmpty()) { return; } // write the header output.write(HEADER_NEW_NODES_ADDED); // write the cluster count PackedInteger.writePackedInteger(output, 1); // write the cluster name output.writeUTF(clusterName); // write out the cluster node(s) information this.writeClusterNodes(output, clusterName, clientMappings); }
/** * Writes out a EJB remoting protocol message containing the names of the <code>clusters</code> which have been removed * from the server. * * @param output The {@link DataOutput} to which the message will be written * @param registries * @throws IOException */ void writeClusterRemoved(final DataOutput output, final Collection<Registry<String, List<ClientMapping>>> registries) throws IOException { if (output == null) { throw EjbMessages.MESSAGES.cannotWriteToNullDataOutput(); } if (registries == null || registries.isEmpty()) { return; } // write the header output.write(HEADER_CLUSTER_REMOVED); // write the cluster count PackedInteger.writePackedInteger(output, registries.size()); // write out the cluster name for each of the removed cluster for (final Registry<String, List<ClientMapping>> registry : registries) { output.writeUTF(registry.getName()); } }
protected void writeTxPrepareResponseMessage(final ChannelAssociation channelAssociation, final short invocationId, final int xaResourceStatusCode) throws IOException { final DataOutputStream dataOutputStream; final MessageOutputStream messageOutputStream; try { messageOutputStream = channelAssociation.acquireChannelMessageOutputStream(); } catch (Exception e) { throw EjbMessages.MESSAGES.failedToOpenMessageOutputStream(e); } dataOutputStream = new DataOutputStream(messageOutputStream); try { // write header dataOutputStream.writeByte(HEADER_TX_INVOCATION_RESPONSE); // write invocation id dataOutputStream.writeShort(invocationId); // write a "bit" to indicate that this message contains the XAResource status for a "prepare" // invocation dataOutputStream.writeBoolean(true); // write the XAResource status PackedInteger.writePackedInteger(dataOutputStream, xaResourceStatusCode); } finally { channelAssociation.releaseChannelMessageOutputStream(messageOutputStream); dataOutputStream.close(); } }
private void sendVersionMessage(final ChannelAssociation channelAssociation) throws IOException { final DataOutputStream outputStream; final MessageOutputStream messageOutputStream; try { messageOutputStream = channelAssociation.acquireChannelMessageOutputStream(); } catch (Exception e) { throw EjbMessages.MESSAGES.failedToOpenMessageOutputStream(e); } outputStream = new DataOutputStream(messageOutputStream); try { // write the version outputStream.write(this.serverProtocolVersion); // write the marshaller type count PackedInteger.writePackedInteger(outputStream, this.supportedMarshallingStrategies.length); // write the marshaller types for (int i = 0; i < this.supportedMarshallingStrategies.length; i++) { outputStream.writeUTF(this.supportedMarshallingStrategies[i]); } } finally { channelAssociation.releaseChannelMessageOutputStream(messageOutputStream); outputStream.close(); } }
private void writeClusterNodes(final DataOutput output, final String clusterName, final Map<String, List<ClientMapping>> clientMappings) throws IOException { PackedInteger.writePackedInteger(output, memberCount); throw EjbMessages.MESSAGES.clientMappingMissing(nodeName, clusterName); PackedInteger.writePackedInteger(output, clientMappingsForNode.size()); PackedInteger.writePackedInteger(output, netMaskAndIPFamilyDifferentiator);
private void writeModuleReport(final DataOutput output, final DeploymentModuleIdentifier[] modules) throws IOException { // write the count PackedInteger.writePackedInteger(output, modules.length); // write the module identifiers for (int i = 0; i < modules.length; i++) { // write the app name final String appName = modules[i].getApplicationName(); if (appName == null) { // write out a empty string output.writeUTF(""); } else { output.writeUTF(appName); } // write the module name output.writeUTF(modules[i].getModuleName()); // write the distinct name final String distinctName = modules[i].getDistinctName(); if (distinctName == null) { // write out an empty string output.writeUTF(""); } else { output.writeUTF(distinctName); } } } }
/** * Writes out a EJB remoting protocol message containing the cluster topology information for the passed <code>clusters</code> * * @param output The {@link DataOutput} into which the message will be written * @param clientMappingsRegistries * @throws IOException */ void writeCompleteClusterTopology(final DataOutput output, final Collection<Registry<String, List<ClientMapping>>> clientMappingsRegistries) throws IOException { if (output == null) { throw EjbMessages.MESSAGES.cannotWriteToNullDataOutput(); } if (clientMappingsRegistries == null || clientMappingsRegistries.isEmpty()) { return; } // write the header output.write(HEADER_COMPLETE_CLUSTER_TOPOLOGY); // write the cluster count PackedInteger.writePackedInteger(output, clientMappingsRegistries.size()); // write out each of the cluster's topology for (final Registry<String, List<ClientMapping>> registry : clientMappingsRegistries) { // write the cluster name output.writeUTF(registry.getName()); // write out the information of each cluster node this.writeClusterNodes(output, registry.getName(), registry.getEntries()); } }
private void writeSessionId(final ChannelAssociation channelAssociation, final short invocationId, final SessionID sessionID, final Affinity hardAffinity) throws IOException { final byte[] sessionIdBytes = sessionID.getEncodedForm(); final DataOutputStream dataOutputStream; final MessageOutputStream messageOutputStream; try { messageOutputStream = channelAssociation.acquireChannelMessageOutputStream(); } catch (Exception e) { throw EjbMessages.MESSAGES.failedToOpenMessageOutputStream(e); } dataOutputStream = new DataOutputStream(messageOutputStream); try { // write out header dataOutputStream.writeByte(HEADER_SESSION_OPEN_RESPONSE); // write out invocation id dataOutputStream.writeShort(invocationId); // session id byte length PackedInteger.writePackedInteger(dataOutputStream, sessionIdBytes.length); // write out the session id bytes dataOutputStream.write(sessionIdBytes); // now marshal the hard affinity associated with this session final Marshaller marshaller = this.prepareForMarshalling(this.marshallerFactory, dataOutputStream); marshaller.writeObject(hardAffinity); // finish marshalling marshaller.finish(); } finally { channelAssociation.releaseChannelMessageOutputStream(messageOutputStream); dataOutputStream.close(); } }