use of org.apache.drill.exec.exception.StoreException in project drill by apache.
the class RemoteFunctionRegistry method prepareStores.
/**
* Connects to three stores: REGISTRY, UNREGISTRATION, JARS.
* Puts in REGISTRY store with default instance of remote function registry if store is initiated for the first time.
* Registers unregistration listener in UNREGISTRATION store.
*/
private void prepareStores(PersistentStoreProvider storeProvider, ClusterCoordinator coordinator) {
try {
PersistentStoreConfig<Registry> registrationConfig = PersistentStoreConfig.newProtoBuilder(SchemaUserBitShared.Registry.WRITE, SchemaUserBitShared.Registry.MERGE).name("udf").persist().build();
registry = storeProvider.getOrCreateStore(registrationConfig);
registry.putIfAbsent(registry_path, Registry.getDefaultInstance());
} catch (StoreException e) {
throw new DrillRuntimeException("Failure while loading remote registry.", e);
}
TransientStoreConfig<String> unregistrationConfig = TransientStoreConfig.newJacksonBuilder(mapper, String.class).name("udf/unregister").build();
unregistration = coordinator.getOrCreateTransientStore(unregistrationConfig);
unregistration.addListener(unregistrationListener);
TransientStoreConfig<String> jarsConfig = TransientStoreConfig.newJacksonBuilder(mapper, String.class).name("udf/jars").build();
jars = coordinator.getOrCreateTransientStore(jarsConfig);
}
use of org.apache.drill.exec.exception.StoreException in project drill by apache.
the class CachingPersistentStoreProvider method getOrCreateStore.
@Override
@SuppressWarnings("unchecked")
public <V> PersistentStore<V> getOrCreateStore(final PersistentStoreConfig<V> config) throws StoreException {
final PersistentStore<?> store = storeCache.get(config);
if (store == null) {
final PersistentStore<?> newStore = provider.getOrCreateStore(config);
final PersistentStore<?> finalStore = storeCache.putIfAbsent(config, newStore);
if (finalStore == null) {
return (PersistentStore<V>) newStore;
}
try {
newStore.close();
} catch (Exception ex) {
throw new StoreException(ex);
}
}
return (PersistentStore<V>) store;
}
Aggregations