/** * Constructor to set maximum versions and use the specified configuration, * table factory and pool type. The HTablePool supports the * {@link PoolType#Reusable} and {@link PoolType#ThreadLocal}. If the pool * type is null or not one of those two values, then it will default to * {@link PoolType#Reusable}. * * @param config configuration * @param maxSize maximum number of references to keep for each table * @param tableFactory table factory * @param poolType pool type which is one of {@link PoolType#Reusable} or * {@link PoolType#ThreadLocal} */ public HaeinsaTablePool(final Configuration config, final int maxSize, final HaeinsaTableIfaceFactory tableFactory, PoolType poolType) { // Make a new configuration instance so I can safely cleanup when // done with the pool. this.config = config == null ? new Configuration() : config; this.maxSize = maxSize; this.tableFactory = tableFactory == null ? new DefaultHaeinsaTableIfaceFactory(new HTableFactory()) : tableFactory; if (poolType == null) { this.poolType = PoolType.Reusable; } else { switch (poolType) { case Reusable: case ThreadLocal: { this.poolType = poolType; break; } default: { this.poolType = PoolType.Reusable; break; } } } this.tables = new PoolMap<String, HaeinsaTableIfaceInternal>(this.poolType, this.maxSize); }
private HBaseCubes(DataCube<O> cube, Deserializer<O> deserializer, byte[] cubeTable, byte[] lookupTable, byte[] counterTable, byte[] cf, Configuration conf, int writeBatchSize, CommitType commitType, SyncLevel syncLevel, HTableFactory factory, int numFlushThreads, int numIoeRetries, int numCasRetries) throws IOException { this.cubeTable = cubeTable; this.syncLevel = syncLevel; pool = new HTablePool(conf, 10, factory); IdService idService = new HBaseIdService(conf, lookupTable, counterTable, cf, EMPTY_BYTE_ARRAY); DbHarness<O> hbaseDbHarness = new HBaseDbHarness<O>(pool, EMPTY_BYTE_ARRAY, cubeTable, cf, deserializer, idService, commitType, numFlushThreads, numIoeRetries, numCasRetries, null); // these are the defaults // Note: batches are flushed after 1 minute dataCubeIo = new DataCubeIo<O>(cube, hbaseDbHarness, writeBatchSize, TimeUnit.MINUTES.toMillis(1), syncLevel); }
private static HTableFactory newNonFlushingHTableFactory() { return new HTableFactory() { @Override public HTableInterface createHTableInterface(Configuration config, byte[] tableName) { try { HTable table = new HTable(config, tableName); table.setAutoFlush(false); return table; } catch (IOException ioe) { throw new RuntimeException(ioe); } } }; }
private HBaseCubes(DataCube<O> cube, Deserializer<O> deserializer, byte[] cubeTable, byte[] lookupTable, byte[] counterTable, byte[] cf, Configuration conf, int writeBatchSize, CommitType commitType, SyncLevel syncLevel, HTableFactory factory) throws IOException { this(cube, deserializer, cubeTable, lookupTable, counterTable, cf, conf, writeBatchSize, commitType, syncLevel, factory, DEFAULT_FLUSH_THREADS, DEFAULT_IOE_RETRIES, DEFAULT_CAS_RETRIES); }
/** * The "no counter / lookup" version. */ private HBaseCubes(DataCube<O> cube, Deserializer<O> deserializer, byte[] cubeTable, byte[] cf, Configuration conf, int writeBatchSize, CommitType commitType, SyncLevel syncLevel, HTableFactory factory) throws IOException { this(cube, deserializer, cubeTable, null, null, cf, conf, writeBatchSize, commitType, syncLevel, factory); }