Search in sources :

Example 1 with InMemoryMetadataStoreFactory

use of org.apache.samza.metadatastore.InMemoryMetadataStoreFactory in project samza by apache.

the class TestLocalApplicationRunner method testCreateCoordinatorStreamWithoutCoordinatorFactory.

/**
 * Underlying coordinator stream should not be created if not using CoordinatorStreamMetadataStoreFactory
 */
@Test
public void testCreateCoordinatorStreamWithoutCoordinatorFactory() throws Exception {
    SystemAdmins systemAdmins = mock(SystemAdmins.class);
    PowerMockito.whenNew(SystemAdmins.class).withAnyArguments().thenReturn(systemAdmins);
    LocalApplicationRunner localApplicationRunner = spy(new LocalApplicationRunner(mockApp, config, new InMemoryMetadataStoreFactory()));
    doReturn(false).when(localApplicationRunner).createUnderlyingCoordinatorStream(eq(config));
    MetadataStore coordinatorStreamStore = localApplicationRunner.createCoordinatorStreamStore(config);
    assertTrue(coordinatorStreamStore instanceof InMemoryMetadataStore);
    // creating underlying coordinator stream should not be called for other coordinator stream metadata store types.
    verify(localApplicationRunner, never()).createUnderlyingCoordinatorStream(eq(config));
}
Also used : InMemoryMetadataStore(org.apache.samza.metadatastore.InMemoryMetadataStore) MetadataStore(org.apache.samza.metadatastore.MetadataStore) ZkMetadataStore(org.apache.samza.zk.ZkMetadataStore) InMemoryMetadataStore(org.apache.samza.metadatastore.InMemoryMetadataStore) InMemoryMetadataStoreFactory(org.apache.samza.metadatastore.InMemoryMetadataStoreFactory) SystemAdmins(org.apache.samza.system.SystemAdmins) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 2 with InMemoryMetadataStoreFactory

use of org.apache.samza.metadatastore.InMemoryMetadataStoreFactory in project samza by apache.

the class TestRunner method run.

/**
 * Run the application with the specified timeout
 *
 * @param timeout time to wait for the application to finish. This timeout does not include
 *                input stream initialization time or the assertion time over output streams. This timeout just accounts
 *                for time that samza job takes run. Timeout must be greater than 0.
 * @throws SamzaException if Samza job fails with exception and returns UnsuccessfulFinish as the statuscode
 */
public void run(Duration timeout) {
    Preconditions.checkNotNull(app);
    Preconditions.checkState(!timeout.isZero() || !timeout.isNegative(), "Timeouts should be positive");
    // Cleaning store directories to ensure current run does not pick up state from previous run
    deleteStoreDirectories();
    Config config = new MapConfig(JobPlanner.generateSingleJobConfig(configs));
    final LocalApplicationRunner runner = new LocalApplicationRunner(app, config, new InMemoryMetadataStoreFactory());
    runner.run(externalContext);
    if (!runner.waitForFinish(timeout)) {
        throw new SamzaException("Timed out waiting for application to finish");
    }
    ApplicationStatus status = runner.status();
    deleteStoreDirectories();
    if (status.getStatusCode() == ApplicationStatus.StatusCode.UnsuccessfulFinish) {
        throw new SamzaException("Application could not finish successfully", status.getThrowable());
    }
}
Also used : MapConfig(org.apache.samza.config.MapConfig) InMemorySystemConfig(org.apache.samza.config.InMemorySystemConfig) JobCoordinatorConfig(org.apache.samza.config.JobCoordinatorConfig) Config(org.apache.samza.config.Config) JobConfig(org.apache.samza.config.JobConfig) ClusterManagerConfig(org.apache.samza.config.ClusterManagerConfig) StreamConfig(org.apache.samza.config.StreamConfig) ApplicationConfig(org.apache.samza.config.ApplicationConfig) TaskConfig(org.apache.samza.config.TaskConfig) ApplicationStatus(org.apache.samza.job.ApplicationStatus) InMemoryMetadataStoreFactory(org.apache.samza.metadatastore.InMemoryMetadataStoreFactory) MapConfig(org.apache.samza.config.MapConfig) SamzaException(org.apache.samza.SamzaException) LocalApplicationRunner(org.apache.samza.runtime.LocalApplicationRunner)

Aggregations

InMemoryMetadataStoreFactory (org.apache.samza.metadatastore.InMemoryMetadataStoreFactory)2 SamzaException (org.apache.samza.SamzaException)1 ApplicationConfig (org.apache.samza.config.ApplicationConfig)1 ClusterManagerConfig (org.apache.samza.config.ClusterManagerConfig)1 Config (org.apache.samza.config.Config)1 InMemorySystemConfig (org.apache.samza.config.InMemorySystemConfig)1 JobConfig (org.apache.samza.config.JobConfig)1 JobCoordinatorConfig (org.apache.samza.config.JobCoordinatorConfig)1 MapConfig (org.apache.samza.config.MapConfig)1 StreamConfig (org.apache.samza.config.StreamConfig)1 TaskConfig (org.apache.samza.config.TaskConfig)1 ApplicationStatus (org.apache.samza.job.ApplicationStatus)1 InMemoryMetadataStore (org.apache.samza.metadatastore.InMemoryMetadataStore)1 MetadataStore (org.apache.samza.metadatastore.MetadataStore)1 LocalApplicationRunner (org.apache.samza.runtime.LocalApplicationRunner)1 SystemAdmins (org.apache.samza.system.SystemAdmins)1 ZkMetadataStore (org.apache.samza.zk.ZkMetadataStore)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1