@Override void perform() throws IOException { HTableDescriptor selected = selectTable(disabledTables); if (selected == null) { return; } Admin admin = connection.getAdmin(); try { HColumnDescriptor cfd = createFamilyDesc(); if (selected.hasFamily(cfd.getName())) { LOG.info( new String(cfd.getName()) + " already exists in table " + selected.getTableName()); return; } TableName tableName = selected.getTableName(); LOG.info("Adding column family: " + cfd + " to table: " + tableName); admin.addColumn(tableName, cfd); // assertion HTableDescriptor freshTableDesc = admin.getTableDescriptor(tableName); Assert.assertTrue( "Column family: " + cfd + " was not added", freshTableDesc.hasFamily(cfd.getName())); LOG.info("Added column family: " + cfd + " to table: " + tableName); disabledTables.put(tableName, freshTableDesc); } catch (Exception e) { LOG.warn("Caught exception in action: " + this.getClass()); throw e; } finally { admin.close(); } verifyTables(); }
@Override void perform() throws IOException { HTableDescriptor selected = selectTable(disabledTables); HColumnDescriptor cfd = selectFamily(selected); if (selected == null || cfd == null) { return; } Admin admin = connection.getAdmin(); try { if (selected.getColumnFamilies().length < 2) { LOG.info("No enough column families to delete in table " + selected.getTableName()); return; } TableName tableName = selected.getTableName(); LOG.info("Deleting column family: " + cfd + " from table: " + tableName); admin.deleteColumnFamily(tableName, cfd.getName()); // assertion HTableDescriptor freshTableDesc = admin.getTableDescriptor(tableName); Assert.assertFalse( "Column family: " + cfd + " was not added", freshTableDesc.hasFamily(cfd.getName())); LOG.info("Deleted column family: " + cfd + " from table: " + tableName); disabledTables.put(tableName, freshTableDesc); } catch (Exception e) { LOG.warn("Caught exception in action: " + this.getClass()); throw e; } finally { admin.close(); } verifyTables(); }