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


Java MetaEditor.addRegionToMeta方法代码示例

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


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

示例1: updateMeta

import org.apache.hadoop.hbase.catalog.MetaEditor; //导入方法依赖的package包/类
@Override
protected void updateMeta(final byte [] oldRegion1,
    final byte [] oldRegion2,
  HRegion newRegion)
throws IOException {
  byte[][] regionsToDelete = {oldRegion1, oldRegion2};
  for (int r = 0; r < regionsToDelete.length; r++) {
    if(Bytes.equals(regionsToDelete[r], latestRegion.getRegionName())) {
      latestRegion = null;
    }
    Delete delete = new Delete(regionsToDelete[r]);
    table.delete(delete);
    if(LOG.isDebugEnabled()) {
      LOG.debug("updated columns in row: " + Bytes.toStringBinary(regionsToDelete[r]));
    }
  }
  newRegion.getRegionInfo().setOffline(true);

  MetaEditor.addRegionToMeta(table, newRegion.getRegionInfo());

  if(LOG.isDebugEnabled()) {
    LOG.debug("updated columns in row: "
        + Bytes.toStringBinary(newRegion.getRegionName()));
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:26,代码来源:HMerge.java

示例2: createMultiRegionsInMeta

import org.apache.hadoop.hbase.catalog.MetaEditor; //导入方法依赖的package包/类
/**
 * Create rows in hbase:meta for regions of the specified table with the specified
 * start keys.  The first startKey should be a 0 length byte array if you
 * want to form a proper range of regions.
 * @param conf
 * @param htd
 * @param startKeys
 * @return list of region info for regions added to meta
 * @throws IOException
 */
public List<HRegionInfo> createMultiRegionsInMeta(final Configuration conf,
    final HTableDescriptor htd, byte [][] startKeys)
throws IOException {
  HTable meta = new HTable(conf, TableName.META_TABLE_NAME);
  Arrays.sort(startKeys, Bytes.BYTES_COMPARATOR);
  List<HRegionInfo> newRegions = new ArrayList<HRegionInfo>(startKeys.length);
  // add custom ones
  for (int i = 0; i < startKeys.length; i++) {
    int j = (i + 1) % startKeys.length;
    HRegionInfo hri = new HRegionInfo(htd.getTableName(), startKeys[i],
        startKeys[j]);
    MetaEditor.addRegionToMeta(meta, hri);
    newRegions.add(hri);
  }

  meta.close();
  return newRegions;
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:29,代码来源:HBaseTestingUtility.java

示例3: createRegion

import org.apache.hadoop.hbase.catalog.MetaEditor; //导入方法依赖的package包/类
protected HRegionInfo createRegion(Configuration conf, final HTable htbl,
    byte[] startKey, byte[] endKey) throws IOException {
  HTable meta = new HTable(conf, TableName.META_TABLE_NAME);
  HTableDescriptor htd = htbl.getTableDescriptor();
  HRegionInfo hri = new HRegionInfo(htbl.getName(), startKey, endKey);

  LOG.info("manually adding regioninfo and hdfs data: " + hri.toString());
  Path rootDir = FSUtils.getRootDir(conf);
  FileSystem fs = rootDir.getFileSystem(conf);
  Path p = new Path(FSUtils.getTableDir(rootDir, htbl.getName()),
      hri.getEncodedName());
  fs.mkdirs(p);
  Path riPath = new Path(p, HRegionFileSystem.REGION_INFO_FILE);
  FSDataOutputStream out = fs.create(riPath);
  out.write(hri.toDelimitedByteArray());
  out.close();

  // add to meta.
  MetaEditor.addRegionToMeta(meta, hri);
  meta.close();
  return hri;
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:23,代码来源:OfflineMetaRebuildTestCore.java

示例4: createMultiRegionsInMeta

import org.apache.hadoop.hbase.catalog.MetaEditor; //导入方法依赖的package包/类
/**
 * Create rows in META for regions of the specified table with the specified
 * start keys.  The first startKey should be a 0 length byte array if you
 * want to form a proper range of regions.
 * @param conf
 * @param htd
 * @param startKeys
 * @return list of region info for regions added to meta
 * @throws IOException
 */
public List<HRegionInfo> createMultiRegionsInMeta(final Configuration conf,
    final HTableDescriptor htd, byte [][] startKeys)
throws IOException {
  HTable meta = new HTable(conf, HConstants.META_TABLE_NAME);
  Arrays.sort(startKeys, Bytes.BYTES_COMPARATOR);
  List<HRegionInfo> newRegions = new ArrayList<HRegionInfo>(startKeys.length);
  // add custom ones
  for (int i = 0; i < startKeys.length; i++) {
    int j = (i + 1) % startKeys.length;
    HRegionInfo hri = new HRegionInfo(htd.getName(), startKeys[i],
        startKeys[j]);
    MetaEditor.addRegionToMeta(meta, hri);
    newRegions.add(hri);
  }

  meta.close();
  return newRegions;
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:29,代码来源:HBaseTestingUtility.java

示例5: testAssignRegion

import org.apache.hadoop.hbase.catalog.MetaEditor; //导入方法依赖的package包/类
/**
 * This tests region assignment
 */
@Test
public void testAssignRegion() throws Exception {
  String table = "testAssignRegion";
  try {
    HTableDescriptor desc = new HTableDescriptor(table);
    desc.addFamily(new HColumnDescriptor(FAMILY));
    admin.createTable(desc);

    HTable meta = new HTable(conf, HConstants.META_TABLE_NAME);
    HRegionInfo hri = new HRegionInfo(
      desc.getName(), Bytes.toBytes("A"), Bytes.toBytes("Z"));
    MetaEditor.addRegionToMeta(meta, hri);

    HMaster master = TEST_UTIL.getHBaseCluster().getMaster();
    master.assignRegion(hri);
    master.getAssignmentManager().waitForAssignment(hri);

    ServerName serverName = master.getAssignmentManager().
      getRegionStates().getRegionServerOfRegion(hri);
    TEST_UTIL.assertRegionOnServer(hri, serverName, 200);
  } finally {
    TEST_UTIL.deleteTable(Bytes.toBytes(table));
  }
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:28,代码来源:TestAssignmentManagerOnCluster.java

示例6: createRegion

import org.apache.hadoop.hbase.catalog.MetaEditor; //导入方法依赖的package包/类
protected HRegionInfo createRegion(Configuration conf, final HTable htbl,
    byte[] startKey, byte[] endKey) throws IOException {
  HTable meta = new HTable(conf, HConstants.META_TABLE_NAME);
  HTableDescriptor htd = htbl.getTableDescriptor();
  HRegionInfo hri = new HRegionInfo(htbl.getTableName(), startKey, endKey);

  LOG.info("manually adding regioninfo and hdfs data: " + hri.toString());
  Path rootDir = new Path(conf.get(HConstants.HBASE_DIR));
  FileSystem fs = rootDir.getFileSystem(conf);
  Path p = new Path(rootDir + "/" + htd.getNameAsString(),
      hri.getEncodedName());
  fs.mkdirs(p);
  Path riPath = new Path(p, HRegion.REGIONINFO_FILE);
  FSDataOutputStream out = fs.create(riPath);
  out.write(hri.toDelimitedByteArray());
  out.close();

  // add to meta.
  MetaEditor.addRegionToMeta(meta, hri);
  meta.close();
  return hri;
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:23,代码来源:OfflineMetaRebuildTestCore.java

示例7: fixMetaHoleOnline

import org.apache.hadoop.hbase.catalog.MetaEditor; //导入方法依赖的package包/类
/**
 * Puts the specified HRegionInfo into META.
 */
public static void fixMetaHoleOnline(Configuration conf,
    HRegionInfo hri) throws IOException {
  HTable meta = new HTable(conf, TableName.META_TABLE_NAME);
  MetaEditor.addRegionToMeta(meta, hri);
  meta.close();
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:10,代码来源:HBaseFsckRepair.java

示例8: testAssignRegion

import org.apache.hadoop.hbase.catalog.MetaEditor; //导入方法依赖的package包/类
/**
 * This tests region assignment
 */
@Test (timeout=60000)
public void testAssignRegion() throws Exception {
  String table = "testAssignRegion";
  try {
    HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(table));
    desc.addFamily(new HColumnDescriptor(FAMILY));
    admin.createTable(desc);

    HTable meta = new HTable(conf, TableName.META_TABLE_NAME);
    HRegionInfo hri = new HRegionInfo(
      desc.getTableName(), Bytes.toBytes("A"), Bytes.toBytes("Z"));
    MetaEditor.addRegionToMeta(meta, hri);

    HMaster master = TEST_UTIL.getHBaseCluster().getMaster();
    master.assignRegion(hri);
    AssignmentManager am = master.getAssignmentManager();
    am.waitForAssignment(hri);

    RegionStates regionStates = am.getRegionStates();
    ServerName serverName = regionStates.getRegionServerOfRegion(hri);
    TEST_UTIL.assertRegionOnServer(hri, serverName, 200);

    // Region is assigned now. Let's assign it again.
    // Master should not abort, and region should be assigned.
    RegionState oldState = regionStates.getRegionState(hri);
    TEST_UTIL.getHBaseAdmin().assign(hri.getRegionName());
    master.getAssignmentManager().waitForAssignment(hri);
    RegionState newState = regionStates.getRegionState(hri);
    assertTrue(newState.isOpened()
      && newState.getStamp() != oldState.getStamp());
  } finally {
    TEST_UTIL.deleteTable(Bytes.toBytes(table));
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:38,代码来源:TestAssignmentManagerOnCluster.java

示例9: testOpenFailed

import org.apache.hadoop.hbase.catalog.MetaEditor; //导入方法依赖的package包/类
/**
 * This tests region open failed
 */
@Test (timeout=60000)
public void testOpenFailed() throws Exception {
  String table = "testOpenFailed";
  try {
    HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(table));
    desc.addFamily(new HColumnDescriptor(FAMILY));
    admin.createTable(desc);

    HTable meta = new HTable(conf, TableName.META_TABLE_NAME);
    HRegionInfo hri = new HRegionInfo(
      desc.getTableName(), Bytes.toBytes("A"), Bytes.toBytes("Z"));
    MetaEditor.addRegionToMeta(meta, hri);

    MyLoadBalancer.controledRegion = hri.getEncodedName();

    HMaster master = TEST_UTIL.getHBaseCluster().getMaster();
    master.assignRegion(hri);
    AssignmentManager am = master.getAssignmentManager();
    assertFalse(am.waitForAssignment(hri));

    RegionState state = am.getRegionStates().getRegionState(hri);
    assertEquals(RegionState.State.FAILED_OPEN, state.getState());
    // Failed to open since no plan, so it's on no server
    assertNull(state.getServerName());

    MyLoadBalancer.controledRegion = null;
    master.assignRegion(hri);
    assertTrue(am.waitForAssignment(hri));

    ServerName serverName = master.getAssignmentManager().
      getRegionStates().getRegionServerOfRegion(hri);
    TEST_UTIL.assertRegionOnServer(hri, serverName, 200);
  } finally {
    MyLoadBalancer.controledRegion = null;
    TEST_UTIL.deleteTable(Bytes.toBytes(table));
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:41,代码来源:TestAssignmentManagerOnCluster.java

示例10: testAssignDisabledRegion

import org.apache.hadoop.hbase.catalog.MetaEditor; //导入方法依赖的package包/类
/**
 * Test force unassign/assign a region of a disabled table
 */
@Test (timeout=60000)
public void testAssignDisabledRegion() throws Exception {
  String table = "testAssignDisabledRegion";
  MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
  MyMaster master = null;
  try {
    HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(table));
    desc.addFamily(new HColumnDescriptor(FAMILY));
    admin.createTable(desc);

    HTable meta = new HTable(conf, TableName.META_TABLE_NAME);
    HRegionInfo hri = new HRegionInfo(
      desc.getTableName(), Bytes.toBytes("A"), Bytes.toBytes("Z"));
    MetaEditor.addRegionToMeta(meta, hri);

    // Assign the region
    master = (MyMaster)cluster.getMaster();
    master.assignRegion(hri);
    AssignmentManager am = master.getAssignmentManager();
    RegionStates regionStates = am.getRegionStates();
    assertTrue(am.waitForAssignment(hri));

    // Disable the table
    admin.disableTable(table);
    assertTrue(regionStates.isRegionOffline(hri));

    // You can't assign a disabled region
    am.assign(hri, true, true);
    assertTrue(regionStates.isRegionOffline(hri));

    // You can't unassign a disabled region either
    am.unassign(hri, true);
    assertTrue(regionStates.isRegionOffline(hri));
  } finally {
    TEST_UTIL.deleteTable(Bytes.toBytes(table));
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:41,代码来源:TestAssignmentManagerOnCluster.java

示例11: createRegion

import org.apache.hadoop.hbase.catalog.MetaEditor; //导入方法依赖的package包/类
/**
 * Create a new region in META.
 */
private HRegionInfo createRegion(Configuration conf, final HTableDescriptor
    htd, byte[] startKey, byte[] endKey)
    throws IOException {
  HTable meta = new HTable(conf, TableName.META_TABLE_NAME, executorService);
  HRegionInfo hri = new HRegionInfo(htd.getTableName(), startKey, endKey);
  MetaEditor.addRegionToMeta(meta, hri);
  meta.close();
  return hri;
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:13,代码来源:TestHBaseFsck.java

示例12: changeOnlineStatus

import org.apache.hadoop.hbase.catalog.MetaEditor; //导入方法依赖的package包/类
/**
 * Set a single region on/offline.
 * This is a tool to repair tables that have offlined tables in their midst.
 * Can happen on occasion.  Use at your own risk.  Call from a bit of java
 * or jython script.  This method is 'expensive' in that it creates a
 * {@link HTable} instance per invocation to go against <code>.META.</code>
 * @param c A configuration that has its <code>hbase.master</code>
 * properly set.
 * @param row Row in the catalog .META. table whose HRegionInfo's offline
 * status we want to change.
 * @param onlineOffline Pass <code>true</code> to OFFLINE the region.
 * @throws IOException e
 */
public static void changeOnlineStatus (final Configuration c,
    final byte [] row, final boolean onlineOffline)
throws IOException {
  HTable t = new HTable(c, HConstants.META_TABLE_NAME);
  Get get = new Get(row);
  get.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER);
  Result res = t.get(get);
  KeyValue [] kvs = res.raw();
  if(kvs.length <= 0) {
    throw new IOException("no information for row " + Bytes.toString(row));
  }
  HRegionInfo info = HRegionInfo.getHRegionInfo(res);
  if (info == null) {
    throw new IOException("no information for row " + Bytes.toString(row));
  }

  info.setOffline(onlineOffline);
  MetaEditor.addRegionToMeta(t, info);

  Delete delete = new Delete(row);
  delete.deleteColumns(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER);
  delete.deleteColumns(HConstants.CATALOG_FAMILY,
      HConstants.STARTCODE_QUALIFIER);

  t.delete(delete);
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:40,代码来源:MetaUtils.java

示例13: fixMetaHoleOnline

import org.apache.hadoop.hbase.catalog.MetaEditor; //导入方法依赖的package包/类
/**
 * Puts the specified HRegionInfo into META.
 */
public static void fixMetaHoleOnline(Configuration conf,
    HRegionInfo hri) throws IOException {
  HTable meta = new HTable(conf, HConstants.META_TABLE_NAME);
  MetaEditor.addRegionToMeta(meta, hri);
  meta.close();
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:10,代码来源:HBaseFsckRepair.java

示例14: createRegion

import org.apache.hadoop.hbase.catalog.MetaEditor; //导入方法依赖的package包/类
/**
 * Create a new region in META.
 */
private HRegionInfo createRegion(Configuration conf, final HTableDescriptor
    htd, byte[] startKey, byte[] endKey)
    throws IOException {
  HTable meta = new HTable(conf, HConstants.META_TABLE_NAME);
  HRegionInfo hri = new HRegionInfo(htd.getName(), startKey, endKey);
  MetaEditor.addRegionToMeta(meta, hri);
  meta.close();
  return hri;
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:13,代码来源:TestHBaseFsck.java

示例15: testAssignRegionOnRestartedServer

import org.apache.hadoop.hbase.catalog.MetaEditor; //导入方法依赖的package包/类
/**
 * This tests region assignment on a simulated restarted server
 */
@Test (timeout=120000)
public void testAssignRegionOnRestartedServer() throws Exception {
  String table = "testAssignRegionOnRestartedServer";
  TEST_UTIL.getMiniHBaseCluster().getConf().setInt("hbase.assignment.maximum.attempts", 20);
  TEST_UTIL.getMiniHBaseCluster().stopMaster(0);
  TEST_UTIL.getMiniHBaseCluster().startMaster(); //restart the master so that conf take into affect

  ServerName deadServer = null;
  HMaster master = null;
  try {
    HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(table));
    desc.addFamily(new HColumnDescriptor(FAMILY));
    admin.createTable(desc);

    HTable meta = new HTable(conf, TableName.META_TABLE_NAME);
    final HRegionInfo hri = new HRegionInfo(
      desc.getTableName(), Bytes.toBytes("A"), Bytes.toBytes("Z"));
    MetaEditor.addRegionToMeta(meta, hri);

    master = TEST_UTIL.getHBaseCluster().getMaster();
    Set<ServerName> onlineServers = master.serverManager.getOnlineServers().keySet();
    assertFalse("There should be some servers online", onlineServers.isEmpty());

    // Use the first server as the destination server
    ServerName destServer = onlineServers.iterator().next();

    // Created faked dead server
    deadServer = ServerName.valueOf(destServer.getHostname(),
        destServer.getPort(), destServer.getStartcode() - 100L);
    master.serverManager.recordNewServerWithLock(deadServer, ServerLoad.EMPTY_SERVERLOAD);

    final AssignmentManager am = master.getAssignmentManager();
    RegionPlan plan = new RegionPlan(hri, null, deadServer);
    am.addPlan(hri.getEncodedName(), plan);
    master.assignRegion(hri);

    int version = ZKAssign.transitionNode(master.getZooKeeper(), hri,
      destServer, EventType.M_ZK_REGION_OFFLINE,
      EventType.RS_ZK_REGION_OPENING, 0);
    assertEquals("TansitionNode should fail", -1, version);

    TEST_UTIL.waitFor(60000, new Waiter.Predicate<Exception>() {
      @Override
      public boolean evaluate() throws Exception {
        return ! am.getRegionStates().isRegionInTransition(hri);
      }
    });

  assertFalse("Region should be assigned", am.getRegionStates().isRegionInTransition(hri));
  } finally {
    if (deadServer != null) {
      master.serverManager.expireServer(deadServer);
    }

    TEST_UTIL.deleteTable(Bytes.toBytes(table));
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:61,代码来源:TestAssignmentManagerOnCluster.java


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