Search in sources :

Example 1 with StoreException

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);
}
Also used : Registry(org.apache.drill.exec.proto.UserBitShared.Registry) DrillRuntimeException(org.apache.drill.common.exceptions.DrillRuntimeException) StoreException(org.apache.drill.exec.exception.StoreException)

Example 2 with StoreException

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;
}
Also used : PersistentStore(org.apache.drill.exec.store.sys.PersistentStore) StoreException(org.apache.drill.exec.exception.StoreException) StoreException(org.apache.drill.exec.exception.StoreException)

Aggregations

StoreException (org.apache.drill.exec.exception.StoreException)2 DrillRuntimeException (org.apache.drill.common.exceptions.DrillRuntimeException)1 Registry (org.apache.drill.exec.proto.UserBitShared.Registry)1 PersistentStore (org.apache.drill.exec.store.sys.PersistentStore)1