Refine search
public void close() throws IOException { delegate.close(); }
public MessageOutputStream cancel() { delegate.cancel(); return this; }
public static void writeId(final MessageOutputStream stream, final int version, final int id) throws IOException { if (version == 1) { stream.writeInt(id); } else { stream.writeShort(id); } }
private void writeTxnResponse(final int invId) { try (MessageOutputStream os = messageTracker.openMessageUninterruptibly()) { os.writeByte(Protocol.TXN_RESPONSE); os.writeShort(invId); os.writeBoolean(false); } 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); } }
void writeParamError(final int invId) { try (final MessageOutputStream outputStream = messageTracker.openMessageUninterruptibly()) { outputStream.writeShort(invId); outputStream.writeByte(M_RESP_PARAM_ERROR); } catch (IOException e) { log.outboundException(e); } } }
protected void writeFailure(Exception reason) { try (MessageOutputStream os = messageTracker.openMessageUninterruptibly()) { os.writeByte(Protocol.APPLICATION_EXCEPTION); os.writeShort(invId); if (version >= 3) os.writeByte(getEnlistmentStatus()); final Marshaller marshaller = marshallerFactory.createMarshaller(configuration); marshaller.start(new NoFlushByteOutput(Marshalling.createByteOutput(os))); marshaller.writeObject(reason); marshaller.writeByte(0); marshaller.finish(); } catch (IOException e) { // nothing to do at this point; the client doesn't want the response Logs.REMOTING.trace("EJB response write failed", e); } finally { invocations.removeKey(invId); } }
MessageOutputStream out = handleCompression(invocationContext, underlying); try { out.write(Protocol.INVOCATION_REQUEST); out.writeShort(invocation.getIndex()); marshaller.start(new NoFlushByteOutput(Marshalling.createByteOutput(out))); out.writeUTF(invokedMethod.getName()); out.writeUTF(invocationContext.getMethodSignatureString()); marshaller.writeObject(locator.getAppName()); marshaller.writeObject(locator.getModuleName()); marshaller.writeObject(locator.getDistinctName()); marshaller.writeObject(locator.getBeanName()); marshaller.finish(); } catch (IOException e) { underlying.cancel(); throw e; } finally { out.close();
mos.writeByte(messageId); writeId(mos, version, id); mos.writeByte(Protocol.SUCCESS); if (version == 1) { mos.writeByte(Protocol.P_LIST); mos.writeInt(resultList.size()); try (Marshaller marshaller = createMarshaller(mos, configuration)) { for (NameClassPair nameClassPair : resultList) { marshaller.writeObject(nameClassPair); mos.writeInt(resultList.size()); for (NameClassPair nameClassPair : resultList) { mos.writeUTF(nameClassPair.getName()); mos.writeUTF(nameClassPair.getClassName());
try (MessageOutputStream underlying = messageTracker.openMessageUninterruptibly()) { if(finalResponseCompressLevel != 0) { underlying.writeByte(Protocol.COMPRESSED_INVOCATION_MESSAGE); os = new WrapperMessageOutputStream(underlying, new DeflaterOutputStream(underlying, new Deflater(finalResponseCompressLevel))); } else { os = underlying; os.writeByte(Protocol.INVOCATION_RESPONSE); os.writeShort(invId); if (version >= 3) { os.writeByte(txnCmd); int updateBits = 0; if (sessionId != null) { os.writeByte(updateBits); if (sessionId != null) { final byte[] bytes = sessionId.getEncodedForm(); PackedInteger.writePackedInteger(os, bytes.length); os.write(bytes); 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); os.close();
mos.writeByte(messageId); writeId(mos, version, id); mos.writeByte(Protocol.SUCCESS); if (version == 1) { mos.writeByte(Protocol.P_LIST); mos.writeInt(resultList.size()); try (Marshaller marshaller = createMarshaller(mos, configuration)) { for (Binding binding : resultList) { if (binding.getObject() instanceof Context) { marshaller.writeByte(Protocol.P_CONTEXT); marshaller.writeUTF(binding.getName()); } else { marshaller.writeByte(Protocol.P_BINDING); marshaller.writeObject(binding);
private void writeSuccessResponse(final int messageId, final int id, final Object result) throws IOException { try (MessageOutputStream mos = messageTracker.openMessageUninterruptibly()) { mos.writeByte(messageId); writeId(mos, version, id); mos.writeByte(Protocol.SUCCESS); if (result instanceof Context) { mos.writeByte(Protocol.P_CONTEXT); } else { mos.writeByte(Protocol.P_OBJECT); try (Marshaller marshaller = createMarshaller(mos, configuration)) { marshaller.writeObject(result); } } } }
final EJBTransactionOperations.PlainTransactionInvocation invocation = invocationTracker.addInvocation(EJBTransactionOperations.PlainTransactionInvocation::new); try (MessageOutputStream os = invocationTracker.allocateMessage(invocation)) { os.writeByte(type); os.writeShort(invocation.getIndex()); final byte[] encoded = transactionID.getEncodedForm(); PackedInteger.writePackedInteger(os, encoded.length); os.write(encoded); if (withParam) { os.writeBoolean(true);
protected static void writeResponse(final Channel channel, final ManagementRequestHeader header, final byte param) throws IOException { final ManagementResponseHeader response = ManagementResponseHeader.create(header); final MessageOutputStream output = channel.writeMessage(); try { writeHeader(response, output); output.write(param); output.write(ManagementProtocol.RESPONSE_END); output.close(); } finally { StreamUtils.safeClose(output); } }
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); } }
public void writeNoSuchMethod() { final String message = Logs.REMOTING.remoteMessageNoSuchMethod(methodLocator, identifier); try (MessageOutputStream os = messageTracker.openMessageUninterruptibly()) { os.writeByte(Protocol.NO_SUCH_METHOD); os.writeShort(invId); os.writeUTF(message); } catch (IOException e) { // nothing to do at this point; the client doesn't want the response Logs.REMOTING.trace("EJB response write failed", e); } finally { invocations.removeKey(invId); } }
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 PlainTransactionInvocation invocation = invocationTracker.addInvocation(PlainTransactionInvocation::new); try (MessageOutputStream os = invocationTracker.allocateMessage(invocation)) { os.writeByte(Protocol.TXN_RECOVERY_REQUEST); os.writeShort(invocation.getIndex()); os.writeUTF(parentName); os.writeInt(flag); } catch (IOException e) { throw new XAException(XAException.XAER_RMERR);
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(); }
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); } }