当前位置: 首页>>代码示例>>Java>>正文


Java HTableDescriptor.removeFamily方法代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.HTableDescriptor.removeFamily方法的典型用法代码示例。如果您正苦于以下问题:Java HTableDescriptor.removeFamily方法的具体用法?Java HTableDescriptor.removeFamily怎么用?Java HTableDescriptor.removeFamily使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.hbase.HTableDescriptor的用法示例。


在下文中一共展示了HTableDescriptor.removeFamily方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateTableDescriptor

import org.apache.hadoop.hbase.HTableDescriptor; //导入方法依赖的package包/类
/**
 * Remove the column family from the file system and update the table descriptor
 */
private void updateTableDescriptor(final MasterProcedureEnv env) throws IOException {
  // Update table descriptor
  LOG.info("DeleteColumn. Table = " + tableName + " family = " + getColumnFamilyName());

  HTableDescriptor htd = env.getMasterServices().getTableDescriptors().get(tableName);

  if (!htd.hasFamily(familyName)) {
    // It is possible to reach this situation, as we could already delete the column family
    // from table descriptor, but the master failover happens before we complete this state.
    // We should be able to handle running this function multiple times without causing problem.
    return;
  }

  htd.removeFamily(familyName);
  env.getMasterServices().getTableDescriptors().add(htd);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:20,代码来源:DeleteColumnFamilyProcedure.java

示例2: perform

import org.apache.hadoop.hbase.HTableDescriptor; //导入方法依赖的package包/类
@Override
public void perform() throws Exception {
  HTableDescriptor tableDescriptor = admin.getTableDescriptor(tableName);
  HColumnDescriptor[] columnDescriptors = tableDescriptor.getColumnFamilies();

  if (columnDescriptors.length <= (protectedColumns == null ? 1 : protectedColumns.size())) {
    return;
  }

  int index = random.nextInt(columnDescriptors.length);
  while(protectedColumns != null &&
        protectedColumns.contains(columnDescriptors[index].getNameAsString())) {
    index = random.nextInt(columnDescriptors.length);
  }
  byte[] colDescName = columnDescriptors[index].getName();
  LOG.debug("Performing action: Removing " + Bytes.toString(colDescName)+ " from "
      + tableName.getNameAsString());
  tableDescriptor.removeFamily(colDescName);

  // Don't try the modify if we're stopping
  if (context.isStopping()) {
    return;
  }
  admin.modifyTable(tableName, tableDescriptor);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:26,代码来源:RemoveColumnAction.java

示例3: deleteColumn

import org.apache.hadoop.hbase.HTableDescriptor; //导入方法依赖的package包/类
/**
 * Delete column of a table
 * @param tableName
 * @param familyName
 * @return Modified HTableDescriptor with requested column deleted.
 * @throws IOException
 */
public HTableDescriptor deleteColumn(TableName tableName, byte[] familyName)
    throws IOException {
  LOG.info("DeleteColumn. Table = " + tableName
      + " family = " + Bytes.toString(familyName));
  HTableDescriptor htd = this.services.getTableDescriptors().get(tableName);
  htd.removeFamily(familyName);
  this.services.getTableDescriptors().add(htd);
  return htd;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:17,代码来源:MasterFileSystem.java

示例4: testModifyTableDeleteCF

import org.apache.hadoop.hbase.HTableDescriptor; //导入方法依赖的package包/类
@Test(timeout = 60000)
public void testModifyTableDeleteCF() throws Exception {
  final TableName tableName = TableName.valueOf("testModifyTableAddCF");
  final String cf2 = "cf2";
  final String cf3 = "cf3";
  final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();

  MasterProcedureTestingUtility.createTable(procExec, tableName, null, "cf1", cf2, cf3);
  HTableDescriptor currentHtd = UTIL.getHBaseAdmin().getTableDescriptor(tableName);
  assertEquals(3, currentHtd.getFamiliesKeys().size());

  // Test 1: Modify the table descriptor
  HTableDescriptor htd = new HTableDescriptor(UTIL.getHBaseAdmin().getTableDescriptor(tableName));
  htd.removeFamily(cf2.getBytes());

  long procId = ProcedureTestingUtility.submitAndWait(
      procExec, new ModifyTableProcedure(procExec.getEnvironment(), htd));
  ProcedureTestingUtility.assertProcNotFailed(procExec.getResult(procId));

  currentHtd = UTIL.getHBaseAdmin().getTableDescriptor(tableName);
  assertEquals(2, currentHtd.getFamiliesKeys().size());
  assertFalse(currentHtd.hasFamily(cf2.getBytes()));

  // Test 2: Modify the table descriptor offline
  UTIL.getHBaseAdmin().disableTable(tableName);
  ProcedureTestingUtility.waitNoProcedureRunning(procExec);

  HTableDescriptor htd2 =
      new HTableDescriptor(UTIL.getHBaseAdmin().getTableDescriptor(tableName));
  htd2.removeFamily(cf3.getBytes());

  long procId2 =
      ProcedureTestingUtility.submitAndWait(procExec,
        new ModifyTableProcedure(procExec.getEnvironment(), htd2));
  ProcedureTestingUtility.assertProcNotFailed(procExec.getResult(procId2));

  currentHtd = UTIL.getHBaseAdmin().getTableDescriptor(tableName);
  assertEquals(1, currentHtd.getFamiliesKeys().size());
  assertFalse(currentHtd.hasFamily(cf3.getBytes()));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:41,代码来源:TestModifyTableProcedure.java

示例5: testRecoveryAndDoubleExecutionOnline

import org.apache.hadoop.hbase.HTableDescriptor; //导入方法依赖的package包/类
@Test(timeout = 60000)
public void testRecoveryAndDoubleExecutionOnline() throws Exception {
  final TableName tableName = TableName.valueOf("testRecoveryAndDoubleExecutionOnline");
  final String cf2 = "cf2";
  final String cf3 = "cf3";
  final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();

  // create the table
  HRegionInfo[] regions = MasterProcedureTestingUtility.createTable(
    procExec, tableName, null, "cf1", cf3);

  ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, true);

  // Modify multiple properties of the table.
  HTableDescriptor htd = new HTableDescriptor(UTIL.getHBaseAdmin().getTableDescriptor(tableName));
  boolean newCompactionEnableOption = htd.isCompactionEnabled() ? false : true;
  htd.setCompactionEnabled(newCompactionEnableOption);
  htd.addFamily(new HColumnDescriptor(cf2));
  htd.removeFamily(cf3.getBytes());

  // Start the Modify procedure && kill the executor
  long procId = procExec.submitProcedure(
    new ModifyTableProcedure(procExec.getEnvironment(), htd), nonceGroup, nonce);

  // Restart the executor and execute the step twice
  int numberOfSteps = ModifyTableState.values().length;
  MasterProcedureTestingUtility.testRecoveryAndDoubleExecution(procExec, procId, numberOfSteps,
    ModifyTableState.values());

  // Validate descriptor
  HTableDescriptor currentHtd = UTIL.getHBaseAdmin().getTableDescriptor(tableName);
  assertEquals(newCompactionEnableOption, currentHtd.isCompactionEnabled());
  assertEquals(2, currentHtd.getFamiliesKeys().size());
  assertTrue(currentHtd.hasFamily(cf2.getBytes()));
  assertFalse(currentHtd.hasFamily(cf3.getBytes()));

  // cf2 should be added cf3 should be removed
  MasterProcedureTestingUtility.validateTableCreation(UTIL.getHBaseCluster().getMaster(),
    tableName, regions, "cf1", cf2);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:41,代码来源:TestModifyTableProcedure.java

示例6: testRollbackAndDoubleExecutionAfterPONR

import org.apache.hadoop.hbase.HTableDescriptor; //导入方法依赖的package包/类
@Test(timeout = 60000)
public void testRollbackAndDoubleExecutionAfterPONR() throws Exception {
  final TableName tableName = TableName.valueOf("testRollbackAndDoubleExecutionAfterPONR");
  final String familyToAddName = "cf2";
  final String familyToRemove = "cf1";
  final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();

  // create the table
  HRegionInfo[] regions = MasterProcedureTestingUtility.createTable(
    procExec, tableName, null, familyToRemove);
  UTIL.getHBaseAdmin().disableTable(tableName);

  ProcedureTestingUtility.waitNoProcedureRunning(procExec);
  ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, true);

  HTableDescriptor htd = new HTableDescriptor(UTIL.getHBaseAdmin().getTableDescriptor(tableName));
  htd.setCompactionEnabled(!htd.isCompactionEnabled());
  htd.addFamily(new HColumnDescriptor(familyToAddName));
  htd.removeFamily(familyToRemove.getBytes());
  htd.setRegionReplication(3);

  // Start the Modify procedure && kill the executor
  long procId = procExec.submitProcedure(
    new ModifyTableProcedure(procExec.getEnvironment(), htd), nonceGroup, nonce);

  // Failing after MODIFY_TABLE_DELETE_FS_LAYOUT we should not trigger the rollback.
  // NOTE: the 5 (number of MODIFY_TABLE_DELETE_FS_LAYOUT + 1 step) is hardcoded,
  //       so you have to look at this test at least once when you add a new step.
  int numberOfSteps = 5;
  MasterProcedureTestingUtility.testRollbackAndDoubleExecutionAfterPONR(
    procExec,
    procId,
    numberOfSteps,
    ModifyTableState.values());

  // "cf2" should be added and "cf1" should be removed
  MasterProcedureTestingUtility.validateTableCreation(UTIL.getHBaseCluster().getMaster(),
    tableName, regions, false, familyToAddName);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:40,代码来源:TestModifyTableProcedure.java

示例7: testRecoveryAndDoubleExecutionOffline

import org.apache.hadoop.hbase.HTableDescriptor; //导入方法依赖的package包/类
@Test(timeout=60000)
public void testRecoveryAndDoubleExecutionOffline() throws Exception {
  final TableName tableName = TableName.valueOf("testRecoveryAndDoubleExecutionOffline");
  final String cf2 = "cf2";
  final String cf3 = "cf3";
  final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();

  // create the table
  HRegionInfo[] regions = MasterProcedureTestingUtility.createTable(
    procExec, tableName, null, "cf1", cf3);
  UTIL.getHBaseAdmin().disableTable(tableName);

  ProcedureTestingUtility.waitNoProcedureRunning(procExec);
  ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, true);

  // Modify multiple properties of the table.
  HTableDescriptor htd = new HTableDescriptor(UTIL.getHBaseAdmin().getTableDescriptor(tableName));
  boolean newCompactionEnableOption = htd.isCompactionEnabled() ? false : true;
  htd.setCompactionEnabled(newCompactionEnableOption);
  htd.addFamily(new HColumnDescriptor(cf2));
  htd.removeFamily(cf3.getBytes());
  htd.setRegionReplication(3);

  // Start the Modify procedure && kill the executor
  long procId = procExec.submitProcedure(
    new ModifyTableProcedure(procExec.getEnvironment(), htd), nonceGroup, nonce);

  // Restart the executor and execute the step twice
  int numberOfSteps = ModifyTableState.values().length;
  MasterProcedureTestingUtility.testRecoveryAndDoubleExecution(
    procExec,
    procId,
    numberOfSteps,
    ModifyTableState.values());

  // Validate descriptor
  HTableDescriptor currentHtd = UTIL.getHBaseAdmin().getTableDescriptor(tableName);
  assertEquals(newCompactionEnableOption, currentHtd.isCompactionEnabled());
  assertEquals(2, currentHtd.getFamiliesKeys().size());

  // cf2 should be added cf3 should be removed
  MasterProcedureTestingUtility.validateTableCreation(UTIL.getHBaseCluster().getMaster(),
    tableName, regions, false, "cf1", cf2);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:45,代码来源:TestModifyTableProcedure.java


注:本文中的org.apache.hadoop.hbase.HTableDescriptor.removeFamily方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。