use of io.prestosql.spi.statestore.StateMap in project hetu-core by openlookeng.
the class TestHazelcastStateStoreFactory method testTcpipCreateWithStaticSeeds.
/**
* Test state store creation with tcp-ip with static seeds configured
*/
@Test
public void testTcpipCreateWithStaticSeeds() {
HazelcastStateStoreFactory factory = new HazelcastStateStoreFactory();
assertEquals(factory.getName(), HAZELCAST);
SeedStoreFactory seedStoreFactory = new FileBasedSeedStoreFactory();
assertEquals(seedStoreFactory.getName(), "filebased");
// bootstrap state store with static seeds
Map<String, String> config = new HashMap<>(0);
config.put(DISCOVERY_MODE_CONFIG_NAME, DISCOVERY_MODE_TCPIP);
config.put(STATE_STORE_CLUSTER_CONFIG_NAME, "static-seed-cluster");
config.put(DISCOVERY_PORT_CONFIG_NAME, PORT2);
config.put(DISCOVERY_TCPIP_SEEDS, MEMBER_ADDRESS2);
StateStoreBootstrapper bootstrapper = new HazelcastStateStoreBootstrapper();
bootstrapper.bootstrap(ImmutableSet.of(MEMBER_ADDRESS2), config);
// create state store client
String stateStoreName = "static-seed-state-store";
StateStore stateStore = factory.create(stateStoreName, null, config);
assertEquals(stateStore.getName(), stateStoreName);
StateCollection collection = stateStore.createStateCollection("test", StateCollection.Type.MAP);
((StateMap<String, String>) collection).put(TEST_KEY, TEST_VALUE);
assertEquals(collection.size(), 1);
assertEquals(((StateMap<String, String>) collection).get(TEST_KEY), TEST_VALUE);
((HazelcastStateStore) stateStore).shutdown();
}
use of io.prestosql.spi.statestore.StateMap in project hetu-core by openlookeng.
the class PagePublisherQueryManager method saveDynamicFilter.
public synchronized void saveDynamicFilter(String globalQueryId, Map<String, byte[]> bloomFilters) {
PagePublisherQueryRunner queryRunner = this.queryRunners.get(globalQueryId);
StateStore stateStore = this.stateStoreProvider.getStateStore();
if (queryRunner != null && stateStore != null) {
if (this.stateStoreProvider.getStateStore() == null) {
return;
}
String collectionName = queryRunner.getQueryId().getId() + CROSS_REGION_DYNAMIC_FILTER_COLLECTION;
synchronized (queryRunner) {
if (queryRunner.isDone() || queryRunner.isExpired()) {
return;
}
StateMap map = (StateMap<String, Map<String, byte[]>>) stateStore.getOrCreateStateCollection(CROSS_REGION_DYNAMIC_FILTERS, StateCollection.Type.MAP);
map.put(collectionName, bloomFilters);
}
}
}
Aggregations