Search in sources :

Example 1 with AdapterType

use of com.nearinfinity.honeycomb.config.AdapterType in project honeycomb by altamiracorp.

the class StoreFactoryTest method createFactory.

private StoreFactory createFactory() {
    HoneycombConfiguration configurationHolder = new HoneycombConfiguration(adapterConfigs, "hbase");
    Map<AdapterType, Provider<Store>> map = Maps.newHashMap();
    map.put(AdapterType.HBASE, storeProvider);
    when(storeProvider.get()).thenReturn(store);
    return new StoreFactory(map, configurationHolder);
}
Also used : HoneycombConfiguration(com.nearinfinity.honeycomb.config.HoneycombConfiguration) AdapterType(com.nearinfinity.honeycomb.config.AdapterType) Provider(com.google.inject.Provider)

Example 2 with AdapterType

use of com.nearinfinity.honeycomb.config.AdapterType in project honeycomb by altamiracorp.

the class Bootstrap method configure.

@Override
protected void configure() {
    bind(HoneycombConfiguration.class).toInstance(configuration);
    for (AdapterType adapter : AdapterType.values()) {
        if (configuration.isAdapterConfigured(adapter)) {
            try {
                Class<?> moduleClass = Class.forName(adapter.getModuleClass());
                Constructor<?> moduleCtor = moduleClass.getConstructor(Map.class);
                Object module = moduleCtor.newInstance(configuration.getAdapterOptions(adapter));
                install((Module) module);
            } catch (ClassNotFoundException e) {
                logger.error("The " + adapter.getName() + " adapter is" + " configured, but could not be found on the classpath.");
                throw new StorageBackendCreationException(adapter.getName(), e);
            } catch (Exception e) {
                logger.error("Exception while attempting to reflect on the " + adapter.getName() + " adapter.", e);
                throw new StorageBackendCreationException(adapter.getName(), e);
            }
        }
    }
}
Also used : HoneycombConfiguration(com.nearinfinity.honeycomb.config.HoneycombConfiguration) StorageBackendCreationException(com.nearinfinity.honeycomb.exceptions.StorageBackendCreationException) AdapterType(com.nearinfinity.honeycomb.config.AdapterType) StorageBackendCreationException(com.nearinfinity.honeycomb.exceptions.StorageBackendCreationException) IOException(java.io.IOException)

Example 3 with AdapterType

use of com.nearinfinity.honeycomb.config.AdapterType in project honeycomb by altamiracorp.

the class HBaseModule method configure.

@Override
protected void configure() {
    final MapBinder<AdapterType, Store> storeMapBinder = MapBinder.newMapBinder(binder(), AdapterType.class, Store.class);
    storeMapBinder.addBinding(AdapterType.HBASE).to(HBaseStore.class);
    install(new FactoryModuleBuilder().implement(Table.class, HBaseTable.class).build(HBaseTableFactory.class));
    bind(HTableProvider.class).toInstance(hTableProvider);
    bind(HTableInterface.class).toProvider(hTableProvider);
    bind(Long.class).annotatedWith(Names.named(ConfigConstants.WRITE_BUFFER)).toInstance(configuration.getLong(ConfigConstants.WRITE_BUFFER, ConfigConstants.DEFAULT_WRITE_BUFFER));
    bind(String.class).annotatedWith(Names.named(ConfigConstants.COLUMN_FAMILY)).toInstance(configuration.get(ConfigConstants.COLUMN_FAMILY));
}
Also used : FactoryModuleBuilder(com.google.inject.assistedinject.FactoryModuleBuilder) AdapterType(com.nearinfinity.honeycomb.config.AdapterType) Store(com.nearinfinity.honeycomb.Store) HTableInterface(org.apache.hadoop.hbase.client.HTableInterface)

Aggregations

AdapterType (com.nearinfinity.honeycomb.config.AdapterType)3 HoneycombConfiguration (com.nearinfinity.honeycomb.config.HoneycombConfiguration)2 Provider (com.google.inject.Provider)1 FactoryModuleBuilder (com.google.inject.assistedinject.FactoryModuleBuilder)1 Store (com.nearinfinity.honeycomb.Store)1 StorageBackendCreationException (com.nearinfinity.honeycomb.exceptions.StorageBackendCreationException)1 IOException (java.io.IOException)1 HTableInterface (org.apache.hadoop.hbase.client.HTableInterface)1