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


Java HBaseException类代码示例

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


HBaseException类属于org.apache.hadoop.hbase.exceptions包,在下文中一共展示了HBaseException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: assignRegions

import org.apache.hadoop.hbase.exceptions.HBaseException; //导入依赖的package包/类
protected static void assignRegions(final MasterProcedureEnv env,
    final TableName tableName, final List<HRegionInfo> regions)
    throws HBaseException, IOException {
  ProcedureSyncWait.waitRegionServers(env);

  final AssignmentManager assignmentManager = env.getMasterServices().getAssignmentManager();

  // Mark the table as Enabling
  assignmentManager.getTableStateManager().setTableState(tableName,
      ZooKeeperProtos.Table.State.ENABLING);

  // Trigger immediate assignment of the regions in round-robin fashion
  ModifyRegionUtils.assignRegions(assignmentManager, regions);

  // Enable table
  assignmentManager.getTableStateManager()
    .setTableState(tableName, ZooKeeperProtos.Table.State.ENABLED);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:19,代码来源:CreateTableProcedure.java

示例2: testGetNamespacePermission

import org.apache.hadoop.hbase.exceptions.HBaseException; //导入依赖的package包/类
@Test (timeout=180000)
public void testGetNamespacePermission() throws Exception {
  String namespace = "testGetNamespacePermission";
  NamespaceDescriptor desc = NamespaceDescriptor.create(namespace).build();
  createNamespace(TEST_UTIL, desc);
  grantOnNamespace(TEST_UTIL, USER_NONE.getShortName(), namespace, Permission.Action.READ);
  try {
    List<UserPermission> namespacePermissions = AccessControlClient.getUserPermissions(
        systemUserConnection, AccessControlLists.toNamespaceEntry(namespace));
    assertTrue(namespacePermissions != null);
    assertTrue(namespacePermissions.size() == 1);
  } catch (Throwable thw) {
    throw new HBaseException(thw);
  }
  deleteNamespace(TEST_UTIL, namespace);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:17,代码来源:TestAccessController.java

示例3: testGetNamespacePermission

import org.apache.hadoop.hbase.exceptions.HBaseException; //导入依赖的package包/类
@Test
public void testGetNamespacePermission() throws Exception {
  String namespace = "testNamespace";
  NamespaceDescriptor desc = NamespaceDescriptor.create(namespace).build();
  TEST_UTIL.getMiniHBaseCluster().getMaster().createNamespace(desc);
  grantOnNamespace(TEST_UTIL, USER_NONE.getShortName(), namespace, Permission.Action.READ);
  try {
    List<UserPermission> namespacePermissions = AccessControlClient.getUserPermissions(conf,
    AccessControlLists.toNamespaceEntry(namespace));
    assertTrue(namespacePermissions != null);
    assertTrue(namespacePermissions.size() == 1);
  } catch (Throwable thw) {
    throw new HBaseException(thw);
  }
  TEST_UTIL.getMiniHBaseCluster().getMaster().deleteNamespace(namespace);
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:17,代码来源:TestAccessController.java

示例4: getNamespacePermissionsAndVerify

import org.apache.hadoop.hbase.exceptions.HBaseException; //导入依赖的package包/类
/**
 * List all user permissions match the given regular expression for namespace
 * and verify each of them.
 * @param namespaceRegexWithoutPrefix the regualar expression for namespace, without NAMESPACE_PREFIX
 * @param expectedAmount the expected amount of user permissions returned
 * @param expectedNamespace the expected namespace of each user permission returned
 * @throws HBaseException in the case of any HBase exception when accessing hbase:acl table
 */
private void getNamespacePermissionsAndVerify(String namespaceRegexWithoutPrefix,
    int expectedAmount, String expectedNamespace) throws HBaseException {
  try {
    List<UserPermission> namespacePermissions = AccessControlClient.getUserPermissions(
      systemUserConnection, AccessControlLists.toNamespaceEntry(namespaceRegexWithoutPrefix));
    assertTrue(namespacePermissions != null);
    assertEquals(expectedAmount, namespacePermissions.size());
    for (UserPermission namespacePermission : namespacePermissions) {
      assertFalse(namespacePermission.isGlobal());  // Verify it is not a global user permission
      assertEquals(expectedNamespace, namespacePermission.getNamespace());  // Verify namespace is set
    }
  } catch (Throwable thw) {
    throw new HBaseException(thw);
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:24,代码来源:TestAccessController.java

示例5: prepareDisable

import org.apache.hadoop.hbase.exceptions.HBaseException; //导入依赖的package包/类
/**
 * Action before any real action of disabling table. Set the exception in the procedure instead
 * of throwing it.  This approach is to deal with backward compatible with 1.0.
 * @param env MasterProcedureEnv
 * @throws HBaseException
 * @throws IOException
 */
private boolean prepareDisable(final MasterProcedureEnv env) throws HBaseException, IOException {
  boolean canTableBeDisabled = true;
  if (tableName.equals(TableName.META_TABLE_NAME)) {
    setFailure("master-disable-table", new ConstraintException("Cannot disable catalog table"));
    canTableBeDisabled = false;
  } else if (!MetaTableAccessor.tableExists(env.getMasterServices().getConnection(), tableName)) {
    setFailure("master-disable-table", new TableNotFoundException(tableName));
    canTableBeDisabled = false;
  } else if (!skipTableStateCheck) {
    // There could be multiple client requests trying to disable or enable
    // the table at the same time. Ensure only the first request is honored
    // After that, no other requests can be accepted until the table reaches
    // DISABLED or ENABLED.
    //
    // Note: A quick state check should be enough for us to move forward. However, instead of
    // calling TableStateManager.isTableState() to just check the state, we called
    // TableStateManager.setTableStateIfInStates() to set the state to DISABLING from ENABLED.
    // This is because we treat empty state as enabled from 0.92-clusters. See
    // ZKTableStateManager.setTableStateIfInStates() that has a hack solution to work around
    // this issue.
    TableStateManager tsm =
      env.getMasterServices().getAssignmentManager().getTableStateManager();
    if (!tsm.setTableStateIfInStates(tableName, ZooKeeperProtos.Table.State.DISABLING,
          ZooKeeperProtos.Table.State.DISABLING, ZooKeeperProtos.Table.State.ENABLED)) {
      LOG.info("Table " + tableName + " isn't enabled; skipping disable");
      setFailure("master-disable-table", new TableNotEnabledException(tableName));
      canTableBeDisabled = false;
    }
  }

  // We are done the check. Future actions in this procedure could be done asynchronously.
  ProcedurePrepareLatch.releaseLatch(syncLatch, this);

  return canTableBeDisabled;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:43,代码来源:DisableTableProcedure.java

示例6: setTableStateToDisabling

import org.apache.hadoop.hbase.exceptions.HBaseException; //导入依赖的package包/类
/**
 * Mark table state to Disabling
 * @param env MasterProcedureEnv
 * @throws IOException
 */
protected static void setTableStateToDisabling(
    final MasterProcedureEnv env,
    final TableName tableName) throws HBaseException, IOException {
  // Set table disabling flag up in zk.
  env.getMasterServices().getAssignmentManager().getTableStateManager().setTableState(
    tableName,
    ZooKeeperProtos.Table.State.DISABLING);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:14,代码来源:DisableTableProcedure.java

示例7: setTableStateToDisabled

import org.apache.hadoop.hbase.exceptions.HBaseException; //导入依赖的package包/类
/**
 * Mark table state to Disabled
 * @param env MasterProcedureEnv
 * @throws IOException
 */
protected static void setTableStateToDisabled(
    final MasterProcedureEnv env,
    final TableName tableName) throws HBaseException, IOException {
  // Flip the table to disabled
  env.getMasterServices().getAssignmentManager().getTableStateManager().setTableState(
    tableName,
    ZooKeeperProtos.Table.State.DISABLED);
  LOG.info("Disabled table, " + tableName + ", is completed.");
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:15,代码来源:DisableTableProcedure.java

示例8: setTableStateToEnabling

import org.apache.hadoop.hbase.exceptions.HBaseException; //导入依赖的package包/类
/**
 * Mark table state to Enabling
 * @param env MasterProcedureEnv
 * @param tableName the target table
 * @throws IOException
 */
protected static void setTableStateToEnabling(
    final MasterProcedureEnv env,
    final TableName tableName) throws HBaseException, IOException {
  // Set table disabling flag up in zk.
  LOG.info("Attempting to enable the table " + tableName);
  env.getMasterServices().getAssignmentManager().getTableStateManager().setTableState(
    tableName,
    ZooKeeperProtos.Table.State.ENABLING);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:16,代码来源:EnableTableProcedure.java

示例9: setTableStateToEnabled

import org.apache.hadoop.hbase.exceptions.HBaseException; //导入依赖的package包/类
/**
 * Mark table state to Enabled
 * @param env MasterProcedureEnv
 * @throws IOException
 */
protected static void setTableStateToEnabled(
    final MasterProcedureEnv env,
    final TableName tableName) throws HBaseException, IOException {
  // Flip the table to Enabled
  env.getMasterServices().getAssignmentManager().getTableStateManager().setTableState(
    tableName,
    ZooKeeperProtos.Table.State.ENABLED);
  LOG.info("Table '" + tableName + "' was successfully enabled.");
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:15,代码来源:EnableTableProcedure.java

示例10: deleteAssignmentState

import org.apache.hadoop.hbase.exceptions.HBaseException; //导入依赖的package包/类
protected static void deleteAssignmentState(final MasterProcedureEnv env,
    final TableName tableName) throws HBaseException, IOException {
  AssignmentManager am = env.getMasterServices().getAssignmentManager();

  // Clean up regions of the table in RegionStates.
  LOG.debug("Removing '" + tableName + "' from region states.");
  am.getRegionStates().tableDeleted(tableName);

  // If entry for this table states, remove it.
  LOG.debug("Marking '" + tableName + "' as deleted.");
  am.getTableStateManager().setDeletedTable(tableName);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:13,代码来源:DeleteTableProcedure.java

示例11: testSetTimeToLive

import org.apache.hadoop.hbase.exceptions.HBaseException; //导入依赖的package包/类
@Test
public void testSetTimeToLive() throws HBaseException {
  String ttl;
  ColumnFamilyDescriptorBuilder builder
    = ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes("foo"));

  ttl = "50000";
  builder.setTimeToLive(ttl);
  Assert.assertEquals(50000, builder.build().getTimeToLive());

  ttl = "50000 seconds";
  builder.setTimeToLive(ttl);
  Assert.assertEquals(50000, builder.build().getTimeToLive());

  ttl = "";
  builder.setTimeToLive(ttl);
  Assert.assertEquals(0, builder.build().getTimeToLive());

  ttl = "FOREVER";
  builder.setTimeToLive(ttl);
  Assert.assertEquals(HConstants.FOREVER, builder.build().getTimeToLive());

  ttl = "1 HOUR 10 minutes 1 second";
  builder.setTimeToLive(ttl);
  Assert.assertEquals(4201, builder.build().getTimeToLive());

  ttl = "500 Days 23 HOURS";
  builder.setTimeToLive(ttl);
  Assert.assertEquals(43282800, builder.build().getTimeToLive());

  ttl = "43282800 SECONDS (500 Days 23 hours)";
  builder.setTimeToLive(ttl);
  Assert.assertEquals(43282800, builder.build().getTimeToLive());
}
 
开发者ID:apache,项目名称:hbase,代码行数:35,代码来源:TestColumnFamilyDescriptorBuilder.java

示例12: testSetTimeToLive

import org.apache.hadoop.hbase.exceptions.HBaseException; //导入依赖的package包/类
@Test
public void testSetTimeToLive() throws HBaseException {
  String ttl;
  HColumnDescriptor desc = new HColumnDescriptor("foo");

  ttl = "50000";
  desc.setTimeToLive(ttl);
  Assert.assertEquals(50000, desc.getTimeToLive());

  ttl = "50000 seconds";
  desc.setTimeToLive(ttl);
  Assert.assertEquals(50000, desc.getTimeToLive());

  ttl = "";
  desc.setTimeToLive(ttl);
  Assert.assertEquals(0, desc.getTimeToLive());

  ttl = "FOREVER";
  desc.setTimeToLive(ttl);
  Assert.assertEquals(HConstants.FOREVER, desc.getTimeToLive());

  ttl = "1 HOUR 10 minutes 1 second";
  desc.setTimeToLive(ttl);
  Assert.assertEquals(4201, desc.getTimeToLive());

  ttl = "500 Days 23 HOURS";
  desc.setTimeToLive(ttl);
  Assert.assertEquals(43282800, desc.getTimeToLive());

  ttl = "43282800 SECONDS (500 Days 23 hours)";
  desc.setTimeToLive(ttl);
  Assert.assertEquals(43282800, desc.getTimeToLive());
}
 
开发者ID:apache,项目名称:hbase,代码行数:34,代码来源:TestHColumnDescriptor.java

示例13: valueOf

import org.apache.hadoop.hbase.exceptions.HBaseException; //导入依赖的package包/类
/**
 * Convert a human readable string to its value.
 * @see org.apache.hadoop.hbase.util.PrettyPrinter#format(String, Unit)
 * @param pretty
 * @param unit
 * @return the value corresponding to the human readable string
 */
public static String valueOf(final String pretty, final Unit unit) throws HBaseException {
  StringBuilder value = new StringBuilder();
  switch (unit) {
    case TIME_INTERVAL:
      value.append(humanReadableIntervalToSec(pretty));
      break;
    default:
      value.append(pretty);
  }
  return value.toString();
}
 
开发者ID:apache,项目名称:hbase,代码行数:19,代码来源:PrettyPrinter.java

示例14: humanReadableIntervalToSec

import org.apache.hadoop.hbase.exceptions.HBaseException; //导入依赖的package包/类
/**
 * Convert a human readable time interval to seconds. Examples of the human readable
 * time intervals are: 50 DAYS 1 HOUR 30 MINUTES , 25000 SECONDS etc.
 * The units of time specified can be in uppercase as well as lowercase. Also, if a
 * single number is specified without any time unit, it is assumed to be in seconds.
 * @param humanReadableInterval
 * @return value in seconds
 */
private static long humanReadableIntervalToSec(final String humanReadableInterval)
        throws HBaseException {
  if (humanReadableInterval == null || humanReadableInterval.equalsIgnoreCase("FOREVER")) {
    return HConstants.FOREVER;
  }

  try {
    return Long.parseLong(humanReadableInterval);
  } catch(NumberFormatException ex) {
    LOG.debug("Given interval value is not a number, parsing for human readable format");
  }

  String days = null;
  String hours = null;
  String minutes = null;
  String seconds = null;
  String expectedTtl = null;
  long ttl;

  Matcher matcher = PrettyPrinter.INTERVAL_PATTERN.matcher(humanReadableInterval);
  if (matcher.matches()) {
    expectedTtl = matcher.group(2);
    days = matcher.group(4);
    hours = matcher.group(6);
    minutes = matcher.group(8);
    seconds = matcher.group(10);
  }
  ttl = 0;
  ttl += days != null ? Long.parseLong(days)*HConstants.DAY_IN_SECONDS:0;
  ttl += hours != null ? Long.parseLong(hours)*HConstants.HOUR_IN_SECONDS:0;
  ttl += minutes != null ? Long.parseLong(minutes)*HConstants.MINUTE_IN_SECONDS:0;
  ttl += seconds != null ? Long.parseLong(seconds):0;

  if (expectedTtl != null && Long.parseLong(expectedTtl) != ttl) {
    throw new HBaseException("Malformed TTL string: TTL values in seconds and human readable" +
            "format do not match");
  }
  return ttl;
}
 
开发者ID:apache,项目名称:hbase,代码行数:48,代码来源:PrettyPrinter.java

示例15: setTimeToLive

import org.apache.hadoop.hbase.exceptions.HBaseException; //导入依赖的package包/类
public ColumnFamilyDescriptorBuilder setTimeToLive(final String value) throws HBaseException {
  desc.setTimeToLive(value);
  return this;
}
 
开发者ID:apache,项目名称:hbase,代码行数:5,代码来源:ColumnFamilyDescriptorBuilder.java


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