public static void formJobTerminateLogRecord(ITransactionContext txnCtx, LogRecord logRecord, boolean isCommit) { logRecord.setTxnCtx(txnCtx); TransactionUtil.formJobTerminateLogRecord(logRecord, txnCtx.getTxnId().getId(), isCommit); }
public static void formMarkerLogRecord(LogRecord logRecord, ITransactionContext txnCtx, int datasetId, int resourcePartition, ByteBuffer marker) { logRecord.setTxnCtx(txnCtx); logRecord.setLogSource(LogSource.LOCAL); logRecord.setLogType(LogType.MARKER); logRecord.setTxnId(txnCtx.getTxnId().getId()); logRecord.setDatasetId(datasetId); logRecord.setResourcePartition(resourcePartition); marker.get(); // read the first byte since it is not part of the marker object logRecord.setMarker(marker); logRecord.computeAndSetLogSize(); } }
public static void formEntityCommitLogRecord(LogRecord logRecord, ITransactionContext txnCtx, int datasetId, int PKHashValue, ITupleReference PKValue, int[] PKFields, int resourcePartition, byte entityCommitType) { logRecord.setTxnCtx(txnCtx); logRecord.setLogType(entityCommitType); logRecord.setTxnId(txnCtx.getTxnId().getId()); logRecord.setDatasetId(datasetId); logRecord.setPKHashValue(PKHashValue); logRecord.setPKFieldCnt(PKFields.length); logRecord.setPKValue(PKValue); logRecord.setPKFields(PKFields); logRecord.setResourcePartition(resourcePartition); logRecord.computeAndSetPKValueSize(); logRecord.computeAndSetLogSize(); }
@Test public void waitLogTest() throws Exception { final INcApplicationContext ncAppCtx = (INcApplicationContext) integrationUtil.ncs[0].getApplicationContext(); LogRecord logRecord = new LogRecord(); final long txnId = 1; logRecord.setTxnCtx(TransactionContextFactory.create(new TxnId(txnId), new TransactionOptions(ITransactionManager.AtomicityLevel.ENTITY_LEVEL))); logRecord.setLogSource(LogSource.LOCAL); logRecord.setLogType(LogType.WAIT); logRecord.setTxnId(txnId); logRecord.isFlushed(false); logRecord.computeAndSetLogSize(); Thread transactor = new Thread(() -> { final LogManager logManager = (LogManager) ncAppCtx.getTransactionSubsystem().getLogManager(); logManager.log(logRecord); }); transactor.start(); transactor.join(TimeUnit.SECONDS.toMillis(30)); Assert.assertTrue(logRecord.isFlushed()); }