private String getHBaseTableName(String tableName) { return RepoAndTableUtil.getHBaseTableName(repositoryName, tableName); }
public synchronized EventPublisher getEventPublisher(String repositoryName, String tableName) throws IOException, InterruptedException { String hbaseTableName = RepoAndTableUtil.getHBaseTableName(repositoryName, tableName); if (!eventPublishers.containsKey(hbaseTableName)) { eventPublishers.put(hbaseTableName, createEventPublisher(repositoryName, tableName)); } return eventPublishers.get(hbaseTableName); }
@VisibleForTesting static HTableDescriptor createRecordTableDescriptor(String repositoryName, String tableName) { // We have checks on table name in TableManagerImpl -- probably this can go if (tableName.contains(".") || tableName.contains(":")) { throw new IllegalArgumentException("Repository table name cannot contain periods or colons"); } String hbaseTableName = RepoAndTableUtil.getHBaseTableName(repositoryName, tableName); HTableDescriptor recordTableDescriptor = new HTableDescriptor(hbaseTableName); recordTableDescriptor.addFamily(DATA_CF); recordTableDescriptor.setValue(TABLE_TYPE_PROPERTY, TABLE_TYPE_RECORD); RepoAndTableUtil.setRepositoryOwnership(recordTableDescriptor, repositoryName); return recordTableDescriptor; }
@Override public void dropTable(String tableName) throws InterruptedException, IOException { if (Table.RECORD.name.equals(tableName)) { throw new IllegalArgumentException("Can't delete the default record table"); } HBaseAdmin hbaseAdmin = new HBaseAdmin(configuration); String hbaseTableName = RepoAndTableUtil.getHBaseTableName(repositoryName, tableName); try { if (hbaseAdmin.tableExists(hbaseTableName) && LilyHBaseSchema.isRecordTableDescriptor(hbaseAdmin.getTableDescriptor(Bytes.toBytes(hbaseTableName)))) { hbaseAdmin.disableTable(hbaseTableName); hbaseAdmin.deleteTable(hbaseTableName); } else { throw new IllegalArgumentException( String.format("Table '%s' is not a valid record table (HBase table name: '%s')", tableName, hbaseTableName)); } } finally { hbaseAdmin.close(); } }