Search in sources :

Example 6 with TxnState

use of io.pravega.controller.stream.api.grpc.v1.Controller.TxnState in project pravega by pravega.

the class TimeoutServiceTest method testControllerPingFailureDisconnected.

@Test(timeout = 10000)
public void testControllerPingFailureDisconnected() throws InterruptedException {
    TxnId txnId = controllerService.createTransaction(SCOPE, STREAM, LEASE, SCALE_GRACE_PERIOD).thenApply(x -> ModelHelper.decode(x.getKey())).join();
    Optional<Throwable> result = timeoutService.getTaskCompletionQueue().poll((long) (0.75 * LEASE), TimeUnit.MILLISECONDS);
    Assert.assertNull(result);
    TxnState status = controllerService.checkTransactionStatus(SCOPE, STREAM, txnId).join();
    Assert.assertEquals(TxnState.State.OPEN, status.getState());
    // Stop timeoutService, and then try pinging the transaction.
    timeoutService.stopAsync();
    PingTxnStatus pingStatus = controllerService.pingTransaction(SCOPE, STREAM, txnId, LEASE).join();
    Assert.assertEquals(PingTxnStatus.Status.DISCONNECTED, pingStatus.getStatus());
    result = timeoutService.getTaskCompletionQueue().poll((long) (0.5 * LEASE), TimeUnit.MILLISECONDS);
    Assert.assertNull(result);
    // Check that the transaction status is still open, since timeoutService has been stopped.
    status = controllerService.checkTransactionStatus(SCOPE, STREAM, txnId).join();
    Assert.assertEquals(TxnState.State.OPEN, status.getState());
}
Also used : CuratorFrameworkFactory(org.apache.curator.framework.CuratorFrameworkFactory) StreamStoreFactory(io.pravega.controller.store.stream.StreamStoreFactory) SegmentHelper(io.pravega.controller.server.SegmentHelper) AssertExtensions(io.pravega.test.common.AssertExtensions) Cleanup(lombok.Cleanup) TxnState(io.pravega.controller.stream.api.grpc.v1.Controller.TxnState) CompletableFuture(java.util.concurrent.CompletableFuture) StreamConfiguration(io.pravega.client.stream.StreamConfiguration) StoreClient(io.pravega.controller.store.client.StoreClient) RetryOneTime(org.apache.curator.retry.RetryOneTime) StoreException(io.pravega.controller.store.stream.StoreException) TaskMetadataStore(io.pravega.controller.store.task.TaskMetadataStore) TestingServerStarter(io.pravega.test.common.TestingServerStarter) After(org.junit.After) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) TestingServer(org.apache.curator.test.TestingServer) StreamMetadataTasks(io.pravega.controller.task.Stream.StreamMetadataTasks) Controller(io.pravega.controller.stream.api.grpc.v1.Controller) HostMonitorConfigImpl(io.pravega.controller.store.host.impl.HostMonitorConfigImpl) ModelHelper(io.pravega.client.stream.impl.ModelHelper) ControllerService(io.pravega.controller.server.ControllerService) SegmentHelperMock(io.pravega.controller.mocks.SegmentHelperMock) StoreClientFactory(io.pravega.controller.store.client.StoreClientFactory) Test(org.junit.Test) UUID(java.util.UUID) State(io.pravega.controller.store.stream.tables.State) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) HostStoreFactory(io.pravega.controller.store.host.HostStoreFactory) TimeUnit(java.util.concurrent.TimeUnit) TxnId(io.pravega.controller.stream.api.grpc.v1.Controller.TxnId) Slf4j(lombok.extern.slf4j.Slf4j) TaskStoreFactory(io.pravega.controller.store.task.TaskStoreFactory) CuratorFramework(org.apache.curator.framework.CuratorFramework) Config(io.pravega.controller.util.Config) ConnectionFactoryImpl(io.pravega.client.netty.impl.ConnectionFactoryImpl) HostControllerStore(io.pravega.controller.store.host.HostControllerStore) StreamTransactionMetadataTasks(io.pravega.controller.task.Stream.StreamTransactionMetadataTasks) TxnStatus(io.pravega.controller.store.stream.TxnStatus) VersionedTransactionData(io.pravega.controller.store.stream.VersionedTransactionData) Optional(java.util.Optional) ExecutorServiceHelpers(io.pravega.common.concurrent.ExecutorServiceHelpers) StreamMetadataStore(io.pravega.controller.store.stream.StreamMetadataStore) Assert(org.junit.Assert) EventStreamWriterMock(io.pravega.controller.mocks.EventStreamWriterMock) PingTxnStatus(io.pravega.controller.stream.api.grpc.v1.Controller.PingTxnStatus) ScalingPolicy(io.pravega.client.stream.ScalingPolicy) ClientConfig(io.pravega.client.ClientConfig) TxnId(io.pravega.controller.stream.api.grpc.v1.Controller.TxnId) PingTxnStatus(io.pravega.controller.stream.api.grpc.v1.Controller.PingTxnStatus) TxnState(io.pravega.controller.stream.api.grpc.v1.Controller.TxnState) Test(org.junit.Test)

Aggregations

Controller (io.pravega.controller.stream.api.grpc.v1.Controller)6 PingTxnStatus (io.pravega.controller.stream.api.grpc.v1.Controller.PingTxnStatus)6 TxnState (io.pravega.controller.stream.api.grpc.v1.Controller.TxnState)6 ClientConfig (io.pravega.client.ClientConfig)5 ConnectionFactoryImpl (io.pravega.client.netty.impl.ConnectionFactoryImpl)5 ScalingPolicy (io.pravega.client.stream.ScalingPolicy)5 StreamConfiguration (io.pravega.client.stream.StreamConfiguration)5 ModelHelper (io.pravega.client.stream.impl.ModelHelper)5 ExecutorServiceHelpers (io.pravega.common.concurrent.ExecutorServiceHelpers)5 EventStreamWriterMock (io.pravega.controller.mocks.EventStreamWriterMock)5 SegmentHelperMock (io.pravega.controller.mocks.SegmentHelperMock)5 ControllerService (io.pravega.controller.server.ControllerService)5 SegmentHelper (io.pravega.controller.server.SegmentHelper)5 StoreClient (io.pravega.controller.store.client.StoreClient)5 StoreClientFactory (io.pravega.controller.store.client.StoreClientFactory)5 HostControllerStore (io.pravega.controller.store.host.HostControllerStore)5 HostStoreFactory (io.pravega.controller.store.host.HostStoreFactory)5 HostMonitorConfigImpl (io.pravega.controller.store.host.impl.HostMonitorConfigImpl)5 StoreException (io.pravega.controller.store.stream.StoreException)5 StreamMetadataStore (io.pravega.controller.store.stream.StreamMetadataStore)5