final EJBClientChannel ejbClientChannel = new EJBClientChannel(channel, version, discoveredNodeRegistry, futureResult, retryExecutorWrapper); channel.receiveMessage(new Channel.Receiver() { public void handleError(final Channel channel, final IOException error) {
EJBSimpleTransactionControl(final EJBClientChannel channel) { this.channel = channel; final UserTransactionID transactionID = channel.allocateUserTransactionID(); this.transactionID = transactionID; simpleIdResolver = connection -> { if (channel.getChannel().getConnection() != connection) { throw Log.log.invalidTransactionConnection(); } return transactionID.getId(); }; }
MessageOutputStream out = handleCompression(invocationContext, underlying); try { out.write(Protocol.INVOCATION_REQUEST); out.writeShort(invocation.getIndex()); Marshaller marshaller = getMarshaller(); marshaller.start(new NoFlushByteOutput(Marshalling.createByteOutput(out))); invocation.setOutflowHandle(writeTransaction(invocationContext.getTransaction(), marshaller)); marshalledPrivateAttachments.put(AttachmentKeys.TRANSACTION_ID_KEY, calculateTransactionId(transaction)); receiverContext.requestFailed(new RequestSendFailedException(e.getMessage() + " @ " + peerIdentity.getConnection().getPeerURI(), e, true), getRetryExecutor()); } catch (RollbackException | SystemException | RuntimeException e) { receiverContext.requestFailed(new EJBException(e.getMessage(), e), getRetryExecutor()); return;
public Xid[] recover(final int flag, final String parentName, final ConnectionPeerIdentity peerIdentity) throws XAException { assert peerIdentity.getId() == 0; final InvocationTracker invocationTracker = channel.getInvocationTracker(); final PlainTransactionInvocation invocation = invocationTracker.addInvocation(PlainTransactionInvocation::new); try (MessageOutputStream os = invocationTracker.allocateMessage(invocation)) { final Xid[] xids = new Xid[count]; final Unmarshaller unmarshaller = channel.createUnmarshaller(); unmarshaller.start(Marshalling.createByteInput(inputStream)); for (int i = 0; i < count; i ++) {
void addAddress(EJBClientChannel clientChannel) { synchronized (this) { addressesByConnection.put(clientChannel, (InetSocketAddress) clientChannel.getChannel().getConnection().getPeerAddress()); serviceURLCache = null; } }
try (final Unmarshaller unmarshaller = createUnmarshaller()) { unmarshaller.start(response); result = unmarshaller.readObject();
try (final Unmarshaller unmarshaller = createUnmarshaller()) { unmarshaller.start(response); affinity = unmarshaller.readObject(Affinity.class); try (final Unmarshaller unmarshaller = createUnmarshaller()) { unmarshaller.start(response); e = unmarshaller.readObject(Exception.class); throw new NoSuchEJBException(message + " @ " + getChannel().getConnection().getPeerURI());
private void executeSimpleInvocation(int type, boolean withParam) throws SystemException { final EJBClientChannel channel = this.channel; final InvocationTracker invocationTracker = channel.getInvocationTracker(); final EJBTransactionOperations.PlainTransactionInvocation invocation = invocationTracker.addInvocation(EJBTransactionOperations.PlainTransactionInvocation::new); try (MessageOutputStream os = invocationTracker.allocateMessage(invocation)) {
protected boolean cancelInvocation(final EJBReceiverInvocationContext receiverContext, final boolean cancelIfRunning) { try { final EJBClientChannel channel = receiverContext.getClientInvocationContext().getAttachment(EJBCC_KEY); return channel != null && channel.cancelInvocation(receiverContext, cancelIfRunning); } catch (Exception e) { return false; } }
RemoteEJBReceiver(final RemoteTransportProvider remoteTransportProvider, final EJBReceiverContext receiverContext, final RemotingEJBDiscoveryProvider discoveredNodeRegistry) { this.remoteTransportProvider = remoteTransportProvider; this.receiverContext = receiverContext; this.discoveredNodeRegistry = discoveredNodeRegistry; serviceHandle = new ClientServiceHandle<>("jboss.ejb", channel -> EJBClientChannel.construct(channel, this.discoveredNodeRegistry, retryExecutorWrapper)); }
private Executor getRetryExecutor() { return retryExecutorWrapper.getExecutor(getChannel().getConnection().getEndpoint().getXnioWorker()); }
static SystemException readAppException(final EJBClientChannel channel, final BlockingInvocation.Response response) throws SystemException { Exception e; try (final Unmarshaller unmarshaller = channel.createUnmarshaller()) { try (MessageInputStream inputStream = response.getInputStream()) { unmarshaller.start(Marshalling.createByteInput(inputStream)); e = unmarshaller.readObject(Exception.class); unmarshaller.finish(); // The version is probably < 3 else we would not be here // drain off attachments so the server doesn't complain while (inputStream.read() != -1) { inputStream.skip(Long.MAX_VALUE); } } } catch (IOException | ClassNotFoundException e1) { throw new SystemException(); } if (e == null) { throw new SystemException(); } try { throw e; } catch (RuntimeException | SystemException e1) { throw e1; } catch (Exception e1) { final SystemException e2 = new SystemException(); e2.initCause(e1); return e2; } }
public Xid[] recover(final int flag, final String parentName, final ConnectionPeerIdentity peerIdentity) throws XAException { assert peerIdentity.getId() == 0; final InvocationTracker invocationTracker = channel.getInvocationTracker(); final PlainTransactionInvocation invocation = invocationTracker.addInvocation(PlainTransactionInvocation::new); try (MessageOutputStream os = invocationTracker.allocateMessage(invocation)) { final Xid[] xids = new Xid[count]; final Unmarshaller unmarshaller = channel.createUnmarshaller(); unmarshaller.start(Marshalling.createByteInput(inputStream)); for (int i = 0; i < count; i ++) {
try (final Unmarshaller unmarshaller = createUnmarshaller()) { unmarshaller.start(response); affinity = unmarshaller.readObject(Affinity.class); try (final Unmarshaller unmarshaller = createUnmarshaller()) { unmarshaller.start(response); e = unmarshaller.readObject(Exception.class); throw new NoSuchEJBException(message + " @ " + getChannel().getConnection().getPeerURI());
private int executeSimpleInvocation(final TransactionID transactionID, int type, boolean withAnswer, boolean withParam, boolean param) throws XAException { final InvocationTracker invocationTracker = channel.getInvocationTracker(); final PlainTransactionInvocation invocation = invocationTracker.addInvocation(PlainTransactionInvocation::new); try (MessageOutputStream os = invocationTracker.allocateMessage(invocation)) {
protected boolean cancelInvocation(final EJBReceiverInvocationContext receiverContext, final boolean cancelIfRunning) { try { final EJBClientChannel channel = receiverContext.getClientInvocationContext().getAttachment(EJBCC_KEY); return channel != null && channel.cancelInvocation(receiverContext, cancelIfRunning); } catch (Exception e) { return false; } }
RemoteEJBReceiver(final RemoteTransportProvider remoteTransportProvider, final EJBReceiverContext receiverContext, final RemotingEJBDiscoveryProvider discoveredNodeRegistry) { this.remoteTransportProvider = remoteTransportProvider; this.receiverContext = receiverContext; this.discoveredNodeRegistry = discoveredNodeRegistry; serviceHandle = new ClientServiceHandle<>("jboss.ejb", channel -> EJBClientChannel.construct(channel, this.discoveredNodeRegistry, retryExecutorWrapper)); }
MessageOutputStream out = handleCompression(invocationContext, underlying); try { out.write(Protocol.INVOCATION_REQUEST); out.writeShort(invocation.getIndex()); Marshaller marshaller = getMarshaller(); marshaller.start(new NoFlushByteOutput(Marshalling.createByteOutput(out))); invocation.setOutflowHandle(writeTransaction(invocationContext.getTransaction(), marshaller)); marshalledPrivateAttachments.put(AttachmentKeys.TRANSACTION_ID_KEY, calculateTransactionId(transaction)); receiverContext.requestFailed(new RequestSendFailedException(e.getMessage() + " @ " + peerIdentity.getConnection().getPeerURI(), e, true), getRetryExecutor()); } catch (RollbackException | SystemException | RuntimeException e) { receiverContext.requestFailed(new EJBException(e.getMessage(), e), getRetryExecutor()); return;
UserTransactionID allocateUserTransactionID() { final ThreadLocalRandom random = ThreadLocalRandom.current(); final String nodeName = getChannel().getConnection().getRemoteEndpointName(); final byte[] nameBytes; try {
EJBSimpleTransactionControl(final EJBClientChannel channel) { this.channel = channel; final UserTransactionID transactionID = channel.allocateUserTransactionID(); this.transactionID = transactionID; simpleIdResolver = connection -> { if (channel.getChannel().getConnection() != connection) { throw Log.log.invalidTransactionConnection(); } return transactionID.getId(); }; }