public SimpleXid withoutBranch() { if (branchId.length == 0) { return this; } else { return new SimpleXid(formatId, globalId, NO_BYTES, false); } }
public static SimpleXid of(final Xid xid) { return xid instanceof SimpleXid ? (SimpleXid) xid : new SimpleXid(xid.getFormatId(), xid.getGlobalTransactionId(), xid.getBranchQualifier()); }
public static SimpleXid readXid(InputStream is, int len) throws IOException { final int formatId = readInt32BE(is); len -= 4; int gtidLen = readInt8(is); len --; if (len < gtidLen) { throw new EOFException(); } final byte[] gtid = gtidLen == 0 ? SimpleXid.NO_BYTES : new byte[gtidLen]; readFully(is, gtid); len -= gtidLen; final byte[] bq = len == 0 ? SimpleXid.NO_BYTES : new byte[len]; readFully(is, bq); return new SimpleXid(formatId, gtid, bq); } }
ExceptionSupplier<ImportResult<?>, SystemException> readTransaction(final DataInput input) throws IOException { final int type = input.readUnsignedByte(); if (type == 0) { return null; } else if (type == 1) { // remote user transaction final int id = input.readInt(); final int timeout = PackedInteger.readPackedInteger(input); return () -> new ImportResult<Transaction>(transactionServer.getOrBeginTransaction(id, timeout), SubordinateTransactionControl.EMPTY, false); } else if (type == 2) { final int fmt = PackedInteger.readPackedInteger(input); final byte[] gtid = new byte[input.readUnsignedByte()]; input.readFully(gtid); final byte[] bq = new byte[input.readUnsignedByte()]; input.readFully(bq); final int timeout = PackedInteger.readPackedInteger(input); return () -> { try { return transactionServer.getTransactionService().getTransactionContext().findOrImportTransaction(new SimpleXid(fmt, gtid, bq), timeout); } catch (XAException e) { throw new SystemException(e.getMessage()); } }; } else { throw Logs.REMOTING.invalidTransactionType(type); } }
byte[] branchId = new byte[len]; unmarshaller.readFully(branchId); ret[i] = new SimpleXid(formatId, globalId, branchId);
byte[] branchId = new byte[len]; unmarshaller.readFully(branchId); SimpleXid simpleXid = new SimpleXid(formatId, globalId, branchId); beginXid.complete(simpleXid); unmarshaller.finish();
protected ReceivedTransaction readTransaction(Unmarshaller unmarshaller) throws IOException { int type = unmarshaller.readByte(); if (type == 0) { return null; } else if (type == 1 || type == 2) { int formatId = unmarshaller.readInt(); int len = unmarshaller.readInt(); byte[] globalId = new byte[len]; unmarshaller.readFully(globalId); len = unmarshaller.readInt(); byte[] branchId = new byte[len]; unmarshaller.readFully(branchId); SimpleXid simpleXid = new SimpleXid(formatId, globalId, branchId); if (type == 2) { return new ReceivedTransaction(simpleXid, unmarshaller.readInt(), true); } return new ReceivedTransaction(simpleXid, 0, false); } else { throw EjbHttpClientMessages.MESSAGES.invalidTransactionType(type); } }
@Override public final void handleRequest(HttpServerExchange exchange) throws Exception { ContentType contentType = ContentType.parse(exchange.getRequestHeaders().getFirst(Headers.CONTENT_TYPE)); if (contentType == null || contentType.getVersion() != 1 || !contentType.getType().equals(TransactionConstants.XID)) { exchange.setStatusCode(StatusCodes.BAD_REQUEST); HttpRemoteTransactionMessages.MESSAGES.debugf("Exchange %s has incorrect or missing content type", exchange); return; } try { Unmarshaller unmarshaller = MARSHALLER_FACTORY.createUnmarshaller(createMarshallingConf()); unmarshaller.start(new InputStreamByteInput(exchange.getInputStream())); int formatId = unmarshaller.readInt(); int len = unmarshaller.readInt(); byte[] globalId = new byte[len]; unmarshaller.readFully(globalId); len = unmarshaller.readInt(); byte[] branchId = new byte[len]; unmarshaller.readFully(branchId); SimpleXid simpleXid = new SimpleXid(formatId, globalId, branchId); unmarshaller.finish(); ImportResult<LocalTransaction> transaction = transactionContext.findOrImportTransaction(simpleXid, 0); transaction.getTransaction().performFunction((ExceptionBiFunction<ImportResult<LocalTransaction>, HttpServerExchange, Void, Exception>) (o, exchange2) -> { handleImpl(exchange2, o); return null; }, transaction, exchange); } catch (Exception e) { sendException(exchange, StatusCodes.INTERNAL_SERVER_ERROR, e); } }
public SimpleXid withoutBranch() { if (branchId.length == 0) { return this; } else { return new SimpleXid(formatId, globalId, NO_BYTES, false); } }
public SimpleXid withoutBranch() { if (branchId.length == 0) { return this; } else { return new SimpleXid(formatId, globalId, NO_BYTES, false); } }
public static SimpleXid of(final Xid xid) { return xid instanceof SimpleXid ? (SimpleXid) xid : new SimpleXid(xid.getFormatId(), xid.getGlobalTransactionId(), xid.getBranchQualifier()); }
public static SimpleXid of(final Xid xid) { return xid instanceof SimpleXid ? (SimpleXid) xid : new SimpleXid(xid.getFormatId(), xid.getGlobalTransactionId(), xid.getBranchQualifier()); }
public static SimpleXid readXid(InputStream is, int len) throws IOException { final int formatId = readInt32BE(is); len -= 4; int gtidLen = readInt8(is); len --; if (len < gtidLen) { throw new EOFException(); } final byte[] gtid = gtidLen == 0 ? SimpleXid.NO_BYTES : new byte[gtidLen]; readFully(is, gtid); len -= gtidLen; final byte[] bq = len == 0 ? SimpleXid.NO_BYTES : new byte[len]; readFully(is, bq); return new SimpleXid(formatId, gtid, bq); } }
public static SimpleXid readXid(InputStream is, int len) throws IOException { final int formatId = readInt32BE(is); len -= 4; int gtidLen = readInt8(is); len --; if (len < gtidLen) { throw new EOFException(); } final byte[] gtid = gtidLen == 0 ? SimpleXid.NO_BYTES : new byte[gtidLen]; readFully(is, gtid); len -= gtidLen; final byte[] bq = len == 0 ? SimpleXid.NO_BYTES : new byte[len]; readFully(is, bq); return new SimpleXid(formatId, gtid, bq); } }
ExceptionSupplier<ImportResult<?>, SystemException> readTransaction(final DataInput input) throws IOException { final int type = input.readUnsignedByte(); if (type == 0) { return null; } else if (type == 1) { // remote user transaction final int id = input.readInt(); final int timeout = PackedInteger.readPackedInteger(input); return () -> new ImportResult<Transaction>(transactionServer.getOrBeginTransaction(id, timeout), SubordinateTransactionControl.EMPTY, false); } else if (type == 2) { final int fmt = PackedInteger.readPackedInteger(input); final byte[] gtid = new byte[input.readUnsignedByte()]; input.readFully(gtid); final byte[] bq = new byte[input.readUnsignedByte()]; input.readFully(bq); final int timeout = PackedInteger.readPackedInteger(input); return () -> { try { return transactionServer.getTransactionService().getTransactionContext().findOrImportTransaction(new SimpleXid(fmt, gtid, bq), timeout); } catch (XAException e) { throw new SystemException(e.getMessage()); } }; } else { throw Logs.REMOTING.invalidTransactionType(type); } }
ExceptionSupplier<ImportResult<?>, SystemException> readTransaction(final DataInput input) throws IOException { final int type = input.readUnsignedByte(); if (type == 0) { return null; } else if (type == 1) { // remote user transaction final int id = input.readInt(); final int timeout = PackedInteger.readPackedInteger(input); return () -> new ImportResult<Transaction>(transactionServer.getOrBeginTransaction(id, timeout), SubordinateTransactionControl.EMPTY, false); } else if (type == 2) { final int fmt = PackedInteger.readPackedInteger(input); final byte[] gtid = new byte[input.readUnsignedByte()]; input.readFully(gtid); final byte[] bq = new byte[input.readUnsignedByte()]; input.readFully(bq); final int timeout = PackedInteger.readPackedInteger(input); return () -> { try { return transactionServer.getTransactionService().getTransactionContext().findOrImportTransaction(new SimpleXid(fmt, gtid, bq), timeout); } catch (XAException e) { throw new SystemException(e.getMessage()); } }; } else { throw Logs.REMOTING.invalidTransactionType(type); } }
byte[] branchId = new byte[len]; unmarshaller.readFully(branchId); SimpleXid simpleXid = new SimpleXid(formatId, globalId, branchId); beginXid.complete(simpleXid); unmarshaller.finish();
protected ReceivedTransaction readTransaction(Unmarshaller unmarshaller) throws IOException { int type = unmarshaller.readByte(); if (type == 0) { return null; } else if (type == 1 || type == 2) { int formatId = unmarshaller.readInt(); int len = unmarshaller.readInt(); byte[] globalId = new byte[len]; unmarshaller.readFully(globalId); len = unmarshaller.readInt(); byte[] branchId = new byte[len]; unmarshaller.readFully(branchId); SimpleXid simpleXid = new SimpleXid(formatId, globalId, branchId); if (type == 2) { return new ReceivedTransaction(simpleXid, unmarshaller.readInt(), true); } return new ReceivedTransaction(simpleXid, 0, false); } else { throw EjbHttpClientMessages.MESSAGES.invalidTransactionType(type); } }
protected ReceivedTransaction readTransaction(Unmarshaller unmarshaller) throws IOException { int type = unmarshaller.readByte(); if (type == 0) { return null; } else if (type == 1 || type == 2) { int formatId = unmarshaller.readInt(); int len = unmarshaller.readInt(); byte[] globalId = new byte[len]; unmarshaller.readFully(globalId); len = unmarshaller.readInt(); byte[] branchId = new byte[len]; unmarshaller.readFully(branchId); SimpleXid simpleXid = new SimpleXid(formatId, globalId, branchId); if (type == 2) { return new ReceivedTransaction(simpleXid, unmarshaller.readInt(), true); } return new ReceivedTransaction(simpleXid, 0, false); } else { throw EjbHttpClientMessages.MESSAGES.invalidTransactionType(type); } }
@Override public final void handleRequest(HttpServerExchange exchange) throws Exception { ContentType contentType = ContentType.parse(exchange.getRequestHeaders().getFirst(Headers.CONTENT_TYPE)); if (contentType == null || contentType.getVersion() != 1 || !contentType.getType().equals(TransactionConstants.XID)) { exchange.setStatusCode(StatusCodes.BAD_REQUEST); HttpRemoteTransactionMessages.MESSAGES.debugf("Exchange %s has incorrect or missing content type", exchange); return; } try { Unmarshaller unmarshaller = MARSHALLER_FACTORY.createUnmarshaller(createMarshallingConf()); unmarshaller.start(new InputStreamByteInput(exchange.getInputStream())); int formatId = unmarshaller.readInt(); int len = unmarshaller.readInt(); byte[] globalId = new byte[len]; unmarshaller.readFully(globalId); len = unmarshaller.readInt(); byte[] branchId = new byte[len]; unmarshaller.readFully(branchId); SimpleXid simpleXid = new SimpleXid(formatId, globalId, branchId); unmarshaller.finish(); ImportResult<LocalTransaction> transaction = transactionContext.findOrImportTransaction(simpleXid, 0); transaction.getTransaction().performFunction((ExceptionBiFunction<ImportResult<LocalTransaction>, HttpServerExchange, Void, Exception>) (o, exchange2) -> { handleImpl(exchange2, o); return null; }, transaction, exchange); } catch (Exception e) { sendException(exchange, StatusCodes.INTERNAL_SERVER_ERROR, e); } }