public void createAllowedDuringPassiveStateBackupLog(String callerUuid, String txnId) { createBackupLog(callerUuid, txnId, true); }
private void finalizeTransactionsOf(String callerUuid) { final Iterator<Map.Entry<String, TxBackupLog>> it = txBackupLogs.entrySet().iterator(); while (it.hasNext()) { final Map.Entry<String, TxBackupLog> entry = it.next(); final String txnId = entry.getKey(); final TxBackupLog log = entry.getValue(); if (finalize(callerUuid, txnId, log)) { it.remove(); } } }
@Override public void clientDisconnected(String clientUuid) { logger.info("Committing/rolling-back live transactions of client, UUID: " + clientUuid); finalizeTransactionsOf(clientUuid); }
@Override public void run() throws Exception { TransactionManagerServiceImpl txManagerService = getService(); txManagerService.createAllowedDuringPassiveStateBackupLog(getCallerUuid(), getTxnId()); }
@Override protected Object innerCall() throws Exception { TransactionOptions options = new TransactionOptions(); options.setDurability(parameters.durability); options.setTimeout(parameters.timeout, TimeUnit.MILLISECONDS); options.setTransactionType(TransactionOptions.TransactionType.getByValue(parameters.transactionType)); TransactionManagerServiceImpl transactionManager = (TransactionManagerServiceImpl) clientEngine.getTransactionManagerService(); TransactionContext context = transactionManager.newClientTransactionContext(options, endpoint.getUuid()); context.beginTransaction(); endpoint.setTransactionContext(context); return context.getTxnId(); }
@Override public void run() throws Exception { TransactionManagerServiceImpl txManagerService = getService(); txManagerService.purgeBackupLog(txnId); }
@Override public void begin() throws IllegalStateException { if (state == ACTIVE) { throw new IllegalStateException("Transaction is already active"); } if (TRANSACTION_EXISTS.get() != null) { throw new IllegalStateException("Nested transactions are not allowed!"); } startTime = currentTimeMillis(); backupAddresses = transactionManagerService.pickBackupLogAddresses(durability); //init caller thread if (threadId == null) { threadId = Thread.currentThread().getId(); setThreadFlag(TRUE); } state = ACTIVE; transactionManagerService.startCount.inc(); }
@Override public <T> T executeTransaction(TransactionOptions options, TransactionalTask<T> task) throws TransactionException { checkNotNull(task, "TransactionalTask is required!"); TransactionContext context = newTransactionContext(options); context.beginTransaction(); try { T value = task.execute(context); context.commitTransaction(); return value; } catch (Throwable e) { context.rollbackTransaction(); if (e instanceof TransactionException) { throw (TransactionException) e; } if (e.getCause() instanceof TransactionException) { throw (TransactionException) e.getCause(); } if (e instanceof RuntimeException) { throw (RuntimeException) e; } throw new TransactionException(e); } }
((UserCodeDeploymentClassLoader) configClassLoader).setUserCodeDeploymentService(userCodeDeploymentService); this.transactionManagerService = new TransactionManagerServiceImpl(this); this.wanReplicationService = node.getNodeExtension().createService(WanReplicationService.class); this.packetDispatcher = new PacketDispatcher(
TransactionManagerServiceImpl txManagerService = (TransactionManagerServiceImpl) nodeEngine.getTransactionManagerService(); Transaction tx = txManagerService.newAllowedDuringPassiveStateTransaction(options); notifyBeforeStateChange(oldState, requestedState, isTransient); tx.begin();
@Override public void run() throws Exception { TransactionManagerServiceImpl txManagerService = getService(); txManagerService.createAllowedDuringPassiveStateBackupLog(getCallerUuid(), getTxnId()); }
@Override protected Object innerCall() throws Exception { TransactionOptions options = new TransactionOptions(); options.setDurability(parameters.durability); options.setTimeout(parameters.timeout, TimeUnit.MILLISECONDS); options.setTransactionType(TransactionOptions.TransactionType.getByValue(parameters.transactionType)); TransactionManagerServiceImpl transactionManager = (TransactionManagerServiceImpl) clientEngine.getTransactionManagerService(); TransactionContext context = transactionManager.newClientTransactionContext(options, endpoint.getUuid()); context.beginTransaction(); endpoint.setTransactionContext(context); return context.getTxnId(); }
@Override public void run() throws Exception { TransactionManagerServiceImpl txManagerService = getService(); txManagerService.purgeBackupLog(txnId); }
@Override public void begin() throws IllegalStateException { if (state == ACTIVE) { throw new IllegalStateException("Transaction is already active"); } if (TRANSACTION_EXISTS.get() != null) { throw new IllegalStateException("Nested transactions are not allowed!"); } startTime = currentTimeMillis(); backupAddresses = transactionManagerService.pickBackupLogAddresses(durability); //init caller thread if (threadId == null) { threadId = Thread.currentThread().getId(); setThreadFlag(TRUE); } state = ACTIVE; transactionManagerService.startCount.inc(); }
@Override public <T> T executeTransaction(TransactionOptions options, TransactionalTask<T> task) throws TransactionException { checkNotNull(task, "TransactionalTask is required!"); TransactionContext context = newTransactionContext(options); context.beginTransaction(); try { T value = task.execute(context); context.commitTransaction(); return value; } catch (Throwable e) { context.rollbackTransaction(); if (e instanceof TransactionException) { throw (TransactionException) e; } if (e.getCause() instanceof TransactionException) { throw (TransactionException) e.getCause(); } if (e instanceof RuntimeException) { throw (RuntimeException) e; } throw new TransactionException(e); } }
((UserCodeDeploymentClassLoader) configClassLoader).setUserCodeDeploymentService(userCodeDeploymentService); this.transactionManagerService = new TransactionManagerServiceImpl(this); this.wanReplicationService = node.getNodeExtension().createService(WanReplicationService.class); this.packetDispatcher = new PacketDispatcher(
TransactionManagerServiceImpl txManagerService = (TransactionManagerServiceImpl) nodeEngine.getTransactionManagerService(); Transaction tx = txManagerService.newAllowedDuringPassiveStateTransaction(options); notifyBeforeStateChange(oldState, requestedState, isTransient); tx.begin();
public void createBackupLog(String callerUuid, String txnId) { createBackupLog(callerUuid, txnId, false); }
private void finalizeTransactionsOf(String callerUuid) { final Iterator<Map.Entry<String, TxBackupLog>> it = txBackupLogs.entrySet().iterator(); while (it.hasNext()) { final Map.Entry<String, TxBackupLog> entry = it.next(); final String txnId = entry.getKey(); final TxBackupLog log = entry.getValue(); if (finalize(callerUuid, txnId, log)) { it.remove(); } } }
@Override public void clientDisconnected(String clientUuid) { logger.info("Committing/rolling-back live transactions of client, UUID: " + clientUuid); finalizeTransactionsOf(clientUuid); }