/** * Creates an instance of this class for cloning using the {@link ServerTransaction#createCopy()} * method. */ protected ServerTransaction createInstance() { return new ServerTransaction(); }
public ServerTransaction create() throws RemoteException { return ServerTransaction.create(this, _idGenerator.getAndIncrement(), Lease.FOREVER); }
/** * {@inheritDoc} * The assumption here is two transactions are still equal if they have the same transaction manager * and the same transaction id, regardless of whether one is or is not nested. */ public boolean equals(final Object other) { return super.equals(other); } }
public boolean joinIfNeededAndEmbedded(TransactionParticipant participant, int partitionId, String clusterName, Object proxy) throws UnknownTransactionException, CannotJoinException, CrashCountException, RemoteException { if (isEmbeddedMgrProxySideInstance() && needParticipantsJoin()) { if (partitionId < 0) join(participant, ServerTransaction.EMBEDDED_CRASH_COUNT /* crashcount */); else join(participant, ServerTransaction.EMBEDDED_CRASH_COUNT /* crashcount */, partitionId, clusterName, proxy); return true; } return false; }
public static ServerTransaction create(TransactionManager mgr, long id, long lease) throws RemoteException { ServerTransaction txn = new ServerTransaction(mgr, id, lease); txn.initEmbedded(); return txn; }
protected void initEmbedded() throws RemoteException { if (mgr.needParticipantsJoin()) { //check for embedded manager if (((TxnMgrProxy) mgr).isEmbeddedMgr()) { setEmbeddedMgrInProxy(true); setEmbeddedMgrProxySideInstance(true); } } else//local mng { setEmbeddedMgrInProxy(true); setEmbeddedMgrProxySideInstance(true); } }
@Override public boolean beforeOperationExecution(boolean isEmbedded) { if (!super.beforeOperationExecution(isEmbedded)) return false; // Optimization: the following code is intended for remote execution only. if (isEmbedded) return true; if (_txn != null) { final ServerTransaction transaction = (ServerTransaction) _txn; try { // Required on embedded transaction manager so the transaction won't be joined in the server if (transaction.isEmbeddedMgrProxySideInstance() && transaction.needParticipantsJoin()) { _txn = transaction.createCopy(); ((ServerTransaction) _txn).setEmbeddedMgrProxySideInstance(false); } } catch (RemoteException e) { setRemoteOperationExecutionError(new IllegalStateException("Caught remote exception on embedded transaction manager", e)); return false; } } return true; }
if (xtnEntry != null && xtnEntry.getStatus() != XtnStatus.UNINITIALIZED && xtnEntry.getStatus() != XtnStatus.UNINITIALIZED_FAILED && (txn.isEmbeddedMgrInProxy() || !xtnEntry.isOnlyEmbeddedJoins())) { if (txn.isEmbeddedMgrInProxy() && !xtnEntry.isOperatedUpon() && isTransactionWithLease(txn)) renewTransactionLease(txn, txn.getLease()); return xtnEntry; /* already joined this transaction */ if (txn.isEmbeddedMgrInProxy() || !xtnEntry.isOnlyEmbeddedJoins()) return xtnEntry; /* already joined this transaction */ continue; if (!fromReplication && !txn.isEmbeddedMgrInProxy() && xtnEntry.setOnlyEmbeddedJoins(false)) { final PlatformLogicalVersion targetSpaceVersion = LRMIUtilities.getServicePlatformLogicalVersion(((TxnMgrProxy) txn.mgr).getProxy()); if (_engine.getClusterPolicy() != null) txn.join(_engine.getSpaceImpl().getSpaceStub(), SystemTime.timeMillis()/* crashcount */, _engine.getPartitionIdZeroBased(), _engine.getClusterPolicy().m_ClusterName); else txn.join(_engine.getSpaceImpl().getSpaceStub(), SystemTime.timeMillis()/* crashcount */);
@Deprecated public void join(long id, TransactionParticipant part, long crashCount, ServerTransaction userXtnObject) throws UnknownTransactionException, CannotJoinException, CrashCountException, RemoteException { if (!userXtnObject.isEmbeddedMgrProxySideInstance()) throw new UnsupportedOperationException(" supported only with embedded mahalo"); getProxy().join(id, part, crashCount, userXtnObject); }
/** * Sets the transaction the connection will use. Only relevant when auto commit is set to * false. * * @param transaction The transaction the connection will use. */ public void setTransaction(Transaction transaction) throws SQLException { if (getAutoCommit()) throw new IllegalArgumentException("Setting a transaction is not allowed when autoCommit = true."); try { if (transaction instanceof ServerTransaction) { ServerTransaction serverTransaction = (ServerTransaction) transaction; serverTransaction = serverTransaction.createCopy(); serverTransaction.setEmbeddedMgrProxySideInstance(false); RequestPacket packet = new SetTransaction(serverTransaction); writeRequestPacket(packet); } qp.setTransaction(transaction); } catch (RemoteException e) { throw new SQLException(e.getMessage()); } }
private void setNonEmbeddedJoinIfNeed(XtnEntry xtnEntry, ServerTransaction txn, boolean fromReplication) throws TransactionException, RemoteException { if ((txn.isEmbeddedMgrInProxy() && xtnEntry.m_Transaction.isEmbeddedMgrInProxy()) || !xtnEntry.isOnlyEmbeddedJoins()) return; if (xtnEntry.m_Transaction.mgr instanceof LocalTransactionManager) return; //backward comp' //this participant had only embedded joins, need to perform a remote join // in order to report to embedded mahalo that there is a remote proxy involved as well //so mahalo will not drop the participant if reported as failed in case of inactive remote space if (_engine.isCleanUnusedEmbeddedGlobalXtns() && xtnEntry.getStatus() == XtnStatus.BEGUN) { if (!fromReplication) { synchronized (xtnEntry.getJoinLock()) { if (xtnEntry.getStatus() == XtnStatus.BEGUN && xtnEntry.setOnlyEmbeddedJoins(false)) { ServerTransaction xtnToUse = !txn.isEmbeddedMgrInProxy() ? txn : xtnEntry.m_Transaction; final PlatformLogicalVersion targetSpaceVersion = LRMIUtilities.getServicePlatformLogicalVersion(((TxnMgrProxy) xtnToUse.mgr).getProxy()); if (_engine.getClusterPolicy() != null) xtnToUse.join(_engine.getSpaceImpl().getSpaceStub(), SystemTime.timeMillis()/* crashcount */, _engine.getPartitionIdZeroBased(), _engine.getClusterPolicy().m_ClusterName); else xtnToUse.join(_engine.getSpaceImpl().getSpaceStub(), SystemTime.timeMillis()/* crashcount */); } } } } }
|| entryHolder.isTransient() || entryHolder.getWriteLockTransaction() == null || !entryHolder.getWriteLockTransaction().equals(xtn)) continue; xtn.getMetaData(), _spaceName));
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { super.readExternal(in); _id = in.readObject(); }
@Override public void writeExternal(ObjectOutput out) throws IOException { super.writeExternal(out); out.writeObject(_id); }
private void serialize(ObjectOutput out) throws IOException { boolean lightMgr = _embeddedMgrProxySideInstance && needParticipantsJoin() && mgr instanceof TxnMgrProxy; if (lightMgr) { TxnMgrProxy cur = (TxnMgrProxy) mgr; out.writeObject(cur.createLightProxy()); } else out.writeObject(mgr); out.writeLong(id); out.writeLong(lease); //note: written _embeddedMgrProxySideInstance will be read into _embeddedMgr out.writeBoolean(_embeddedMgrProxySideInstance); }
@Deprecated public void joinIfNeededAndEmbedded(TransactionParticipant participant) throws UnknownTransactionException, CannotJoinException, CrashCountException, RemoteException { if (isEmbeddedMgrProxySideInstance() && needParticipantsJoin()) join(participant, ServerTransaction.EMBEDDED_CRASH_COUNT /* crashcount */); }
@Deprecated public void join(Object id, TransactionParticipant part, long crashCount, ServerTransaction userXtnObject) throws UnknownTransactionException, CannotJoinException, CrashCountException, RemoteException { if (!userXtnObject.isEmbeddedMgrProxySideInstance()) throw new UnsupportedOperationException(" supported only with embedded mahalo"); getProxy().join(id, part, crashCount, userXtnObject); }
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { super.readExternal(in); if (in.readBoolean()) { parent = (NestableServerTransaction) in.readObject(); } } }
public void writeExternal(ObjectOutput out) throws IOException { super.writeExternal(out); if (parent == null) { out.writeBoolean(false); } else { out.writeBoolean(true); out.writeObject(parent); } }
@SuppressWarnings("SimplifiableIfStatement") @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; AbstractTransactionReplicationPacketData that = (AbstractTransactionReplicationPacketData) o; if (_weight != that._weight) return false; if (_flags != that._flags) return false; if (_metaData != null ? !_metaData.equals(that._metaData) : that._metaData != null) return false; return _transaction != null ? _transaction.equals(that._transaction) : that._transaction == null; } }