Search in sources :

Example 1 with MetadataStoreFactory

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

the class TestLocalApplicationRunner method testGetCoordinatorStreamStoreFactoryWithDefaultSystem.

/**
 * Default metadata store factory should not be null if default system defined and the default
 * ZkJobCoordinator is used.
 */
@Test
public void testGetCoordinatorStreamStoreFactoryWithDefaultSystem() {
    Optional<MetadataStoreFactory> metadataStoreFactory = LocalApplicationRunner.getDefaultCoordinatorStreamStoreFactory(new MapConfig(ImmutableMap.of(JobConfig.JOB_DEFAULT_SYSTEM, "test-system")));
    assertTrue(metadataStoreFactory.isPresent());
}
Also used : MapConfig(org.apache.samza.config.MapConfig) InMemoryMetadataStoreFactory(org.apache.samza.metadatastore.InMemoryMetadataStoreFactory) CoordinatorStreamMetadataStoreFactory(org.apache.samza.coordinator.metadatastore.CoordinatorStreamMetadataStoreFactory) MetadataStoreFactory(org.apache.samza.metadatastore.MetadataStoreFactory) ZkMetadataStoreFactory(org.apache.samza.zk.ZkMetadataStoreFactory) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 2 with MetadataStoreFactory

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

the class TestLocalApplicationRunner method testGetCoordinatorStreamStoreFactoryWithNonZkJobCoordinator.

/**
 * Default metadata store factory be null if job coordinator system or default system defined and a non ZkJobCoordinator
 * job coordinator is used.
 */
@Test
public void testGetCoordinatorStreamStoreFactoryWithNonZkJobCoordinator() {
    MapConfig mapConfig = new MapConfig(ImmutableMap.of(JobConfig.JOB_DEFAULT_SYSTEM, "test-system", JobCoordinatorConfig.JOB_COORDINATOR_FACTORY, PassthroughJobCoordinatorFactory.class.getName()));
    Optional<MetadataStoreFactory> metadataStoreFactory = LocalApplicationRunner.getDefaultCoordinatorStreamStoreFactory(mapConfig);
    assertFalse(metadataStoreFactory.isPresent());
}
Also used : MapConfig(org.apache.samza.config.MapConfig) InMemoryMetadataStoreFactory(org.apache.samza.metadatastore.InMemoryMetadataStoreFactory) CoordinatorStreamMetadataStoreFactory(org.apache.samza.coordinator.metadatastore.CoordinatorStreamMetadataStoreFactory) MetadataStoreFactory(org.apache.samza.metadatastore.MetadataStoreFactory) ZkMetadataStoreFactory(org.apache.samza.zk.ZkMetadataStoreFactory) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 3 with MetadataStoreFactory

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

the class TestLocalApplicationRunner method testGetCoordinatorStreamStoreFactoryWithoutJobCoordinatorSystem.

/**
 * Default metadata store factory should be null if no job coordinator system defined and the default
 * ZkJobCoordinator is used.
 */
@Test
public void testGetCoordinatorStreamStoreFactoryWithoutJobCoordinatorSystem() {
    Optional<MetadataStoreFactory> metadataStoreFactory = LocalApplicationRunner.getDefaultCoordinatorStreamStoreFactory(new MapConfig());
    assertFalse(metadataStoreFactory.isPresent());
}
Also used : MapConfig(org.apache.samza.config.MapConfig) InMemoryMetadataStoreFactory(org.apache.samza.metadatastore.InMemoryMetadataStoreFactory) CoordinatorStreamMetadataStoreFactory(org.apache.samza.coordinator.metadatastore.CoordinatorStreamMetadataStoreFactory) MetadataStoreFactory(org.apache.samza.metadatastore.MetadataStoreFactory) ZkMetadataStoreFactory(org.apache.samza.zk.ZkMetadataStoreFactory) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 4 with MetadataStoreFactory

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

the class LocalApplicationRunner method getMetadataStoreForRunID.

/**
 * This is not to be confused with the metadata store created from the member {@link #metadataStoreFactory}.
 * The reason for the two Metadata store types (ZK and coordinator stream) is that the job model needs to be stored in
 * ZK because of the versioning requirements. Configs and startpoints are stored in the coordinator stream. This
 * disparity will be resolved with the next gen metadata store abstraction.
 */
private MetadataStore getMetadataStoreForRunID() {
    String metadataStoreFactoryClass = appDesc.getConfig().getOrDefault(METADATA_STORE_FACTORY_CONFIG, DEFAULT_METADATA_STORE_FACTORY);
    MetadataStoreFactory metadataStoreFactory = ReflectionUtil.getObj(metadataStoreFactoryClass, MetadataStoreFactory.class);
    return metadataStoreFactory.getMetadataStore(RUN_ID_METADATA_STORE, appDesc.getConfig(), new MetricsRegistryMap());
}
Also used : MetricsRegistryMap(org.apache.samza.metrics.MetricsRegistryMap) CoordinatorStreamMetadataStoreFactory(org.apache.samza.coordinator.metadatastore.CoordinatorStreamMetadataStoreFactory) MetadataStoreFactory(org.apache.samza.metadatastore.MetadataStoreFactory) ZkMetadataStoreFactory(org.apache.samza.zk.ZkMetadataStoreFactory)

Example 5 with MetadataStoreFactory

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

the class TestZkLocalApplicationRunner method getConfigFromCoordinatorStream.

private MapConfig getConfigFromCoordinatorStream(Config config) {
    MetadataStoreFactory metadataStoreFactory = ReflectionUtil.getObj(new JobConfig(config).getMetadataStoreFactory(), MetadataStoreFactory.class);
    MetadataStore metadataStore = metadataStoreFactory.getMetadataStore("set-config", config, new MetricsRegistryMap());
    metadataStore.init();
    Map<String, String> configMap = new HashMap<>();
    CoordinatorStreamValueSerde jsonSerde = new CoordinatorStreamValueSerde("set-config");
    metadataStore.all().forEach((key, value) -> {
        CoordinatorStreamStore.CoordinatorMessageKey coordinatorMessageKey = CoordinatorStreamStore.deserializeCoordinatorMessageKeyFromJson(key);
        String deserializedValue = jsonSerde.fromBytes(value);
        configMap.put(coordinatorMessageKey.getKey(), deserializedValue);
    });
    return new MapConfig(configMap);
}
Also used : MetadataStore(org.apache.samza.metadatastore.MetadataStore) ZkMetadataStore(org.apache.samza.zk.ZkMetadataStore) CoordinatorStreamStore(org.apache.samza.coordinator.metadatastore.CoordinatorStreamStore) HashMap(java.util.HashMap) MapConfig(org.apache.samza.config.MapConfig) MetricsRegistryMap(org.apache.samza.metrics.MetricsRegistryMap) MetadataStoreFactory(org.apache.samza.metadatastore.MetadataStoreFactory) CoordinatorStreamValueSerde(org.apache.samza.coordinator.stream.CoordinatorStreamValueSerde) JobConfig(org.apache.samza.config.JobConfig)

Aggregations

MetadataStoreFactory (org.apache.samza.metadatastore.MetadataStoreFactory)7 ZkMetadataStoreFactory (org.apache.samza.zk.ZkMetadataStoreFactory)6 MapConfig (org.apache.samza.config.MapConfig)5 CoordinatorStreamMetadataStoreFactory (org.apache.samza.coordinator.metadatastore.CoordinatorStreamMetadataStoreFactory)5 InMemoryMetadataStoreFactory (org.apache.samza.metadatastore.InMemoryMetadataStoreFactory)4 Test (org.junit.Test)4 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4 MetricsRegistryMap (org.apache.samza.metrics.MetricsRegistryMap)3 HashMap (java.util.HashMap)1 JobConfig (org.apache.samza.config.JobConfig)1 CoordinatorStreamStore (org.apache.samza.coordinator.metadatastore.CoordinatorStreamStore)1 CoordinatorStreamValueSerde (org.apache.samza.coordinator.stream.CoordinatorStreamValueSerde)1 MetadataStore (org.apache.samza.metadatastore.MetadataStore)1 ZkMetadataStore (org.apache.samza.zk.ZkMetadataStore)1