@Override public TxnId create() { return new TxnId(maxId.incrementAndGet()); }
@Override public void updateListenerJobParameters(JobParameterByteStore jobParameterByteStore) { String AsterixTransactionIdString = new String(jobParameterByteStore .getParameterValue(TRANSACTION_ID_PARAMETER_NAME, 0, TRANSACTION_ID_PARAMETER_NAME.length)); if (AsterixTransactionIdString.length() > 0) { this.txnId = new TxnId(Integer.parseInt(AsterixTransactionIdString)); } }
public TxnId getTxnJobId(JobId jobId) { return new TxnId(jobId.getId()); }
@Override public TxnId create() throws AlgebricksException { while (true) { try { return new TxnId(block.nextId()); } catch (BlockExhaustedException ex) { // retry LOGGER.info("block exhausted; obtaining new block from supplier"); TxnIdBlockRequest.Block newBlock; try { newBlock = TxnIdBlockRequest.send(appCtx); } catch (HyracksDataException e) { throw new AlgebricksException(e); } block = new Block(newBlock.getStartingId(), newBlock.getBlockSize()); } } }
public void init() throws IOException, ParseException, ACIDException, AlgebricksException { FileReader aql = new FileReader(schemaFile); IParser parser = parserFactory.createParser(aql); List<Statement> statements = parser.parse(); aql.close(); // TODO: Need to fix how to use transactions here. MetadataTransactionContext mdTxnCtx = new MetadataTransactionContext(new TxnId(-1)); ADGenDmlTranslator dmlt = new ADGenDmlTranslator(mdTxnCtx, statements); dmlt.translate(); typeMap = dmlt.getTypeMap(); typeAnnotMap = dmlt.getTypeDataGenMap(); dgCtx = new DataGeneratorContext(); }
@Override public IPushRuntime[] createPushRuntime(IHyracksTaskContext ctx) throws HyracksDataException { return new IPushRuntime[] { new CommitRuntime(ctx, new TxnId(ctx.getJobletContext().getJobId().getId()), getDatasetId(), primaryKeyFieldPermutation, true, ctx.getTaskAttemptId().getTaskId().getPartition(), true) }; } };
public IHyracksTaskContext createTestContext(JobId jobId, int partition, boolean withMessaging) throws HyracksDataException { IHyracksTaskContext ctx = TestUtils.create(KB32, ExecutionTestUtil.integrationUtil.ncs[0].getIoManager()); if (withMessaging) { TaskUtil.put(HyracksConstants.KEY_MESSAGE, new VSizeFrame(ctx), ctx); } IHyracksJobletContext jobletCtx = Mockito.mock(IHyracksJobletContext.class); JobEventListenerFactory factory = new JobEventListenerFactory(new TxnId(jobId.getId()), true); Mockito.when(jobletCtx.getJobletEventListenerFactory()).thenReturn(factory); Mockito.when(jobletCtx.getServiceContext()).thenReturn(ExecutionTestUtil.integrationUtil.ncs[0].getContext()); Mockito.when(jobletCtx.getJobId()).thenReturn(jobId); ctx = Mockito.spy(ctx); Mockito.when(ctx.getJobletContext()).thenReturn(jobletCtx); Mockito.when(ctx.getIoManager()).thenReturn(ExecutionTestUtil.integrationUtil.ncs[0].getIoManager()); TaskAttemptId taskId = new TaskAttemptId(new TaskId(new ActivityId(new OperatorDescriptorId(0), 0), partition), 0); Mockito.when(ctx.getTaskAttemptId()).thenReturn(taskId); return ctx; }
private static ITransactionContext beingTransaction(INcApplicationContext ncAppCtx, ILSMIndex index, long resourceId) { final TxnId txnId = new TxnId(1); final TransactionOptions options = new TransactionOptions(ITransactionManager.AtomicityLevel.ENTITY_LEVEL); final ITransactionManager transactionManager = ncAppCtx.getTransactionSubsystem().getTransactionManager(); final ITransactionContext txnCtx = transactionManager.beginTransaction(txnId, options); txnCtx.register(resourceId, 0, index, NoOpOperationCallback.INSTANCE, true); return txnCtx; }
@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()); }