コード例 #1
0
 @Override
 public TableDescriptor getTableDescriptor(boolean useCache, String cluster, String table) {
   if (useCache) {
     TableDescriptor tableDescriptor = _tableDescriptorCache.get(table);
     if (tableDescriptor != null) {
       return tableDescriptor;
     }
   }
   LOG.debug("trace getTableDescriptor");
   TableDescriptor tableDescriptor = new TableDescriptor();
   try {
     if (_zk.exists(ZookeeperPathConstants.getTableEnabledPath(cluster, table), false) == null) {
       tableDescriptor.isEnabled = false;
     } else {
       tableDescriptor.isEnabled = true;
     }
     tableDescriptor.shardCount =
         Integer.parseInt(
             new String(getData(ZookeeperPathConstants.getTableShardCountPath(cluster, table))));
     tableDescriptor.tableUri =
         new String(getData(ZookeeperPathConstants.getTableUriPath(cluster, table)));
     tableDescriptor.compressionClass =
         new String(getData(ZookeeperPathConstants.getTableCompressionCodecPath(cluster, table)));
     tableDescriptor.compressionBlockSize =
         Integer.parseInt(
             new String(
                 getData(
                     ZookeeperPathConstants.getTableCompressionBlockSizePath(cluster, table))));
     tableDescriptor.analyzerDefinition =
         fromBytes(
             getData(ZookeeperPathConstants.getTablePath(cluster, table)),
             AnalyzerDefinition.class);
     tableDescriptor.blockCaching = isBlockCacheEnabled(cluster, table);
     tableDescriptor.blockCachingFileTypes = getBlockCacheFileTypes(cluster, table);
     tableDescriptor.name = table;
     tableDescriptor.columnPreCache =
         fromBytes(
             getData(ZookeeperPathConstants.getTableColumnsToPreCache(cluster, table)),
             ColumnPreCache.class);
     byte[] data = getData(ZookeeperPathConstants.getTableSimilarityPath(cluster, table));
     if (data != null) {
       tableDescriptor.similarityClass = new String(data);
     }
   } catch (KeeperException e) {
     throw new RuntimeException(e);
   } catch (InterruptedException e) {
     throw new RuntimeException(e);
   }
   tableDescriptor.cluster = cluster;
   _tableDescriptorCache.put(table, tableDescriptor);
   return tableDescriptor;
 }
コード例 #2
0
 @Override
 public int getShardCount(boolean useCache, String cluster, String table) {
   if (useCache) {
     TableDescriptor tableDescriptor = getTableDescriptor(true, cluster, table);
     return tableDescriptor.shardCount;
   }
   LOG.debug("trace getShardCount");
   try {
     return Integer.parseInt(
         new String(getData(ZookeeperPathConstants.getTableShardCountPath(cluster, table))));
   } catch (NumberFormatException e) {
     throw new RuntimeException(e);
   } catch (KeeperException e) {
     throw new RuntimeException(e);
   } catch (InterruptedException e) {
     throw new RuntimeException(e);
   }
 }