public SimpleXid withoutBranch() { if (branchId.length == 0) { return this; } else { return new SimpleXid(formatId, globalId, NO_BYTES, false); } }
public int compareTo(final SimpleXid o) { int res = signum(formatId - o.formatId); if (res == 0) res = compareByteArrays(globalId, o.globalId); if (res == 0) res = compareByteArrays(branchId, o.branchId); assert (res == 0) == equals(o); return res; }
public int compareTo(final XidKey o) { final int res = signum(expiration - o.expiration); return res == 0 ? gtid.compareTo(o.gtid) : res; }
/** * Creates a XA recovery registry for a transaction. This method assumes that there is no file already * existing for this transaction, and, furthermore, it is not thread safe (the creation of this object is * already thread protected at the caller). * * @param xid the transaction xid * @throws SystemException if the there was a problem when creating the recovery file in file system */ XAResourceRegistryFile(Xid xid) throws SystemException { xaRecoveryPath.toFile().mkdir(); // create dir if non existent final String xidString = SimpleXid.of(xid).toHexString('_'); this.filePath = xaRecoveryPath.resolve(xidString); openFilePaths.add(xidString); try { fileChannel = FileChannel.open(filePath, StandardOpenOption.APPEND, StandardOpenOption.CREATE_NEW); fileChannel.lock(); Log.log.xaResourceRecoveryFileCreated(filePath); } catch (IOException e) { throw Log.log.createXAResourceRecoveryFileFailed(filePath, e); } }
public void forget(final Xid xid) throws XAException { try { Entry entry = known.get(SimpleXid.of(xid).withoutBranch()); if (entry != null) { entry.forget(); } else { throw new XAException(XAException.XAER_NOTA); } } catch (XAException e) { throw e; } catch (Throwable t) { throw Log.log.resourceManagerErrorXa(XAException.XAER_RMFAIL, t); } }
public String toHexString() { return toHexString(':'); }
public boolean equals(final Object obj) { return obj instanceof SimpleXid && equals((SimpleXid) obj); }
public void commit(final Xid xid, final boolean onePhase) throws XAException { try { Entry entry = known.get(SimpleXid.of(xid).withoutBranch()); if (entry != null) { entry.commit(onePhase); } else { throw new XAException(XAException.XAER_NOTA); } } catch (XAException e) { throw e; } catch (Throwable t) { throw Log.log.resourceManagerErrorXa(XAException.XAER_RMFAIL, t); } }
/** * Creates a XA recovery registry for a transaction. This method assumes that there is no file already * existing for this transaction, and, furthermore, it is not thread safe (the creation of this object is * already thread protected at the caller). * * @param xid the transaction xid * @throws SystemException if the there was a problem when creating the recovery file in file system */ XAResourceRegistryFile(Xid xid) throws SystemException { xaRecoveryPath.toFile().mkdir(); // create dir if non existent final String xidString = SimpleXid.of(xid).toHexString('_'); this.filePath = xaRecoveryPath.resolve(xidString); openFilePaths.add(xidString); try { fileChannel = FileChannel.open(filePath, StandardOpenOption.APPEND, StandardOpenOption.CREATE_NEW); fileChannel.lock(); Log.log.xaResourceRecoveryFileCreated(filePath); } catch (IOException e) { throw Log.log.createXAResourceRecoveryFileFailed(filePath, e); } }
public String toHexString(char separator) { StringBuilder b = new StringBuilder(); toHexString(b, separator); return b.toString(); }
public boolean equals(final Object obj) { return obj instanceof SimpleXid && equals((SimpleXid) obj); }
public void dropLocal(@NotNull final Transaction transaction) { final Xid xid = getXid(transaction); final SimpleXid gtid = SimpleXid.of(xid).withoutBranch(); final Entry entry = known.remove(gtid); if (entry != null) { timeoutSet.remove(entry.getXidKey()); } }
public static SimpleXid of(final Xid xid) { return xid instanceof SimpleXid ? (SimpleXid) xid : new SimpleXid(xid.getFormatId(), xid.getGlobalTransactionId(), xid.getBranchQualifier()); }
public int compareTo(final SimpleXid o) { int res = signum(formatId - o.formatId); if (res == 0) res = compareByteArrays(globalId, o.globalId); if (res == 0) res = compareByteArrays(branchId, o.branchId); assert (res == 0) == equals(o); return res; }
/** * Creates a XA recovery registry for a transaction. This method assumes that there is no file already * existing for this transaction, and, furthermore, it is not thread safe (the creation of this object is * already thread protected at the caller). * * @param xid the transaction xid * @throws SystemException if the there was a problem when creating the recovery file in file system */ XAResourceRegistryFile(Xid xid) throws SystemException { xaRecoveryPath.toFile().mkdir(); // create dir if non existent final String xidString = SimpleXid.of(xid).toHexString('_'); this.filePath = xaRecoveryPath.resolve(xidString); openFilePaths.add(xidString); try { fileChannel = FileChannel.open(filePath, StandardOpenOption.APPEND, StandardOpenOption.CREATE_NEW); fileChannel.lock(); Log.log.xaResourceRecoveryFileCreated(filePath); } catch (IOException e) { throw Log.log.createXAResourceRecoveryFileFailed(filePath, e); } }
public String toString() { StringBuilder b = new StringBuilder(); b.append("XID ["); toHexString(b, ':'); b.append(']'); return b.toString(); } }
public int compareTo(final XidKey o) { final int res = signum(expiration - o.expiration); return res == 0 ? gtid.compareTo(o.gtid) : res; }
public boolean equals(final Object obj) { return obj instanceof SimpleXid && equals((SimpleXid) obj); }
public void rollbackLocal(@NotNull final Transaction transaction) throws IllegalStateException, SystemException { getEntryFor(transaction, SimpleXid.of(getXid(transaction)).withoutBranch()).rollbackLocal(); }
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); } }