use of io.pravega.controller.store.stream.VersionedTransactionData in project pravega by pravega.
the class ControllerEventProcessorTest method testAbortEventProcessor.
@Test(timeout = 10000)
public void testAbortEventProcessor() {
UUID txnId = streamStore.generateTransactionId(SCOPE, STREAM, null, executor).join();
VersionedTransactionData txnData = streamStore.createTransaction(SCOPE, STREAM, txnId, 10000, 10000, null, executor).join();
Assert.assertNotNull(txnData);
checkTransactionState(SCOPE, STREAM, txnId, TxnStatus.OPEN);
streamStore.sealTransaction(SCOPE, STREAM, txnData.getId(), false, Optional.empty(), "", Long.MIN_VALUE, null, executor).join();
checkTransactionState(SCOPE, STREAM, txnData.getId(), TxnStatus.ABORTING);
AbortRequestHandler abortRequestHandler = new AbortRequestHandler(streamStore, streamMetadataTasks, executor);
abortRequestHandler.processEvent(new AbortEvent(SCOPE, STREAM, txnData.getEpoch(), txnData.getId(), 11L)).join();
checkTransactionState(SCOPE, STREAM, txnData.getId(), TxnStatus.ABORTED);
}
use of io.pravega.controller.store.stream.VersionedTransactionData in project pravega by pravega.
the class ControllerEventProcessorTest method testMarkOnCommit.
@Test(timeout = 10000)
public void testMarkOnCommit() {
UUID txnId = streamStore.generateTransactionId(SCOPE, STREAM, null, executor).join();
VersionedTransactionData txnData = streamStore.createTransaction(SCOPE, STREAM, txnId, 10000, 10000, null, executor).join();
Assert.assertNotNull(txnData);
checkTransactionState(SCOPE, STREAM, txnId, TxnStatus.OPEN);
String writer1 = "writer1";
long timestamp = 1L;
streamStore.sealTransaction(SCOPE, STREAM, txnData.getId(), true, Optional.empty(), writer1, timestamp, null, executor).join();
checkTransactionState(SCOPE, STREAM, txnData.getId(), TxnStatus.COMMITTING);
CommitRequestHandler commitEventProcessor = new CommitRequestHandler(streamStore, streamMetadataTasks, streamTransactionMetadataTasks, bucketStore, executor);
commitEventProcessor.processEvent(new CommitEvent(SCOPE, STREAM, txnData.getEpoch())).join();
checkTransactionState(SCOPE, STREAM, txnData.getId(), TxnStatus.COMMITTED);
WriterMark mark = streamStore.getWriterMark(SCOPE, STREAM, writer1, null, executor).join();
assertEquals(mark.getTimestamp(), timestamp);
}
use of io.pravega.controller.store.stream.VersionedTransactionData in project pravega by pravega.
the class ControllerEventProcessorTest method testCommitAndStreamProcessorFairness.
@Test(timeout = 30000)
public void testCommitAndStreamProcessorFairness() {
List<VersionedTransactionData> txnDataList1 = createAndCommitTransactions(3);
int epoch = txnDataList1.get(0).getEpoch();
streamStore.startCommitTransactions(SCOPE, STREAM, 100, null, executor).join();
EventStreamWriterMock<ControllerEvent> requestEventWriter = new EventStreamWriterMock<>();
streamMetadataTasks.setRequestEventWriter(requestEventWriter);
CommitRequestHandler commitEventProcessor = new CommitRequestHandler(streamStore, streamMetadataTasks, streamTransactionMetadataTasks, bucketStore, executor);
StreamRequestHandler streamRequestHandler = new StreamRequestHandler(new AutoScaleTask(streamMetadataTasks, streamStore, executor), new ScaleOperationTask(streamMetadataTasks, streamStore, executor), null, null, null, null, null, null, null, streamStore, null, executor);
// set some processor name so that the processing gets postponed
streamStore.createWaitingRequestIfAbsent(SCOPE, STREAM, "test", null, executor).join();
AssertExtensions.assertFutureThrows("Operation should be disallowed", commitEventProcessor.processEvent(new CommitEvent(SCOPE, STREAM, epoch)), e -> Exceptions.unwrap(e) instanceof StoreException.OperationNotAllowedException);
streamStore.deleteWaitingRequestConditionally(SCOPE, STREAM, "test1", null, executor).join();
assertEquals("test", streamStore.getWaitingRequestProcessor(SCOPE, STREAM, null, executor).join());
// now remove the barrier but change the state so that processing can not happen.
streamStore.deleteWaitingRequestConditionally(SCOPE, STREAM, "test", null, executor).join();
assertNull(streamStore.getWaitingRequestProcessor(SCOPE, STREAM, null, executor).join());
streamStore.setState(SCOPE, STREAM, State.SCALING, null, executor).join();
AssertExtensions.assertFutureThrows("Operation should be disallowed", commitEventProcessor.processEvent(new CommitEvent(SCOPE, STREAM, epoch)), e -> Exceptions.unwrap(e) instanceof StoreException.OperationNotAllowedException);
assertEquals(commitEventProcessor.getProcessorName(), streamStore.getWaitingRequestProcessor(SCOPE, STREAM, null, executor).join());
streamStore.setState(SCOPE, STREAM, State.ACTIVE, null, executor).join();
// verify that we are able to process if the waiting processor name is same as ours.
commitEventProcessor.processEvent(new CommitEvent(SCOPE, STREAM, epoch)).join();
// verify that waiting processor is cleaned up.
assertNull(streamStore.getWaitingRequestProcessor(SCOPE, STREAM, null, executor).join());
// now set the state to COMMITTING_TXN and try the same with scaling
streamStore.setState(SCOPE, STREAM, State.COMMITTING_TXN, null, executor).join();
// verify that event that does not try to use `processor.withCompletion` runs without contention
assertTrue(Futures.await(streamRequestHandler.processEvent(new AutoScaleEvent(SCOPE, STREAM, 0L, AutoScaleEvent.UP, 0L, 2, true, 0L))));
// now same event's processing in face of a barrier should get postponed
streamStore.createWaitingRequestIfAbsent(SCOPE, STREAM, commitEventProcessor.getProcessorName(), null, executor).join();
assertTrue(Futures.await(streamRequestHandler.processEvent(new AutoScaleEvent(SCOPE, STREAM, 0L, AutoScaleEvent.UP, 0L, 2, true, 0L))));
AssertExtensions.assertFutureThrows("Operation should be disallowed", streamRequestHandler.processEvent(new ScaleOpEvent(SCOPE, STREAM, Collections.emptyList(), Collections.emptyList(), false, 0L, 0L)), e -> Exceptions.unwrap(e) instanceof StoreException.OperationNotAllowedException);
assertEquals(commitEventProcessor.getProcessorName(), streamStore.getWaitingRequestProcessor(SCOPE, STREAM, null, executor).join());
}
use of io.pravega.controller.store.stream.VersionedTransactionData in project pravega by pravega.
the class TimeoutServiceTest method testPingLeaseTooLarge.
@Test(timeout = 10000)
public void testPingLeaseTooLarge() {
UUID txnId = streamStore.generateTransactionId(SCOPE, STREAM, null, executor).join();
VersionedTransactionData txData = streamStore.createTransaction(SCOPE, STREAM, txnId, LEASE, 10 * LEASE, null, executor).join();
timeoutService.addTxn(SCOPE, STREAM, txData.getId(), txData.getVersion(), LEASE, txData.getMaxExecutionExpiryTime());
Version version = txData.getVersion();
PingTxnStatus pingStatus = timeoutService.pingTxn(SCOPE, STREAM, txData.getId(), version, Config.MAX_LEASE_VALUE + 1);
Assert.assertEquals(PingTxnStatus.Status.LEASE_TOO_LARGE, pingStatus.getStatus());
pingStatus = timeoutService.pingTxn(SCOPE, STREAM, txData.getId(), version, 10 * LEASE + 1);
Assert.assertEquals(PingTxnStatus.Status.MAX_EXECUTION_TIME_EXCEEDED, pingStatus.getStatus());
}
use of io.pravega.controller.store.stream.VersionedTransactionData in project pravega by pravega.
the class TimeoutServiceTest method testCloseUnknownTxn.
@Test(timeout = 5000)
public void testCloseUnknownTxn() {
UUID txId = streamStore.generateTransactionId(SCOPE, STREAM, null, executor).join();
VersionedTransactionData txData = streamStore.createTransaction(SCOPE, STREAM, txId, LEASE, 10 * LEASE, null, executor).join();
UUID txnId = txData.getId();
Controller.TxnState state = controllerService.checkTransactionStatus(SCOPE, STREAM, txnId, 0L).join();
Assert.assertEquals(TxnState.State.OPEN, state.getState());
Controller.TxnStatus.Status status = controllerService.abortTransaction(SCOPE, STREAM, txnId, 0L).join().getStatus();
Assert.assertEquals(Controller.TxnStatus.Status.SUCCESS, status);
}
Aggregations