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());
}
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());
}
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());
}
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());
}
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);
}
Aggregations