コード例 #1
0
 @Override
 public String getCluster(boolean useCache, String table) {
   if (useCache) {
     Map<String, String> map = _tableToClusterCache.get();
     String cluster = map.get(table);
     if (cluster == null) {
       return null;
     } else {
       return cluster;
     }
   }
   LOG.debug("trace getCluster");
   List<String> clusterList = getClusterList();
   for (String cluster : clusterList) {
     try {
       Stat stat = _zk.exists(ZookeeperPathConstants.getTablePath(cluster, table), false);
       if (stat != null) {
         return cluster;
       }
     } catch (KeeperException e) {
       throw new RuntimeException(e);
     } catch (InterruptedException e) {
       throw new RuntimeException(e);
     }
   }
   return null;
 }
コード例 #2
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;
 }
コード例 #3
0
 @Override
 public boolean exists(boolean useCache, String cluster, String table) {
   if (useCache) {
     Map<String, String> map = _tableToClusterCache.get();
     if (map.containsKey(table)) {
       return true;
     } else {
       return false;
     }
   }
   LOG.debug("trace exists");
   try {
     if (_zk.exists(ZookeeperPathConstants.getTablePath(cluster, table), false) == null) {
       return false;
     }
     return true;
   } catch (KeeperException e) {
     throw new RuntimeException(e);
   } catch (InterruptedException e) {
     throw new RuntimeException(e);
   }
 }