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


Java HRegionLocation类代码示例

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


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

示例1: regionLocationFromHBase

import org.apache.hadoop.hbase.HRegionLocation; //导入依赖的package包/类
public static THRegionLocation regionLocationFromHBase(HRegionLocation hrl) {
  HRegionInfo hri = hrl.getRegionInfo();
  ServerName serverName = hrl.getServerName();

  THRegionInfo thRegionInfo = new THRegionInfo();
  THRegionLocation thRegionLocation = new THRegionLocation();
  TServerName tServerName = new TServerName();

  tServerName.setHostName(serverName.getHostname());
  tServerName.setPort(serverName.getPort());
  tServerName.setStartCode(serverName.getStartcode());

  thRegionInfo.setTableName(hri.getTable().getName());
  thRegionInfo.setEndKey(hri.getEndKey());
  thRegionInfo.setStartKey(hri.getStartKey());
  thRegionInfo.setOffline(hri.isOffline());
  thRegionInfo.setSplit(hri.isSplit());
  thRegionInfo.setReplicaId(hri.getReplicaId());

  thRegionLocation.setRegionInfo(thRegionInfo);
  thRegionLocation.setServerName(tServerName);

  return thRegionLocation;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:25,代码来源:ThriftUtilities.java

示例2: getRegionServer

import org.apache.hadoop.hbase.HRegionLocation; //导入依赖的package包/类
/**
 * Returns the {@link ServerName} from catalog table {@link Result}
 * where the region is transitioning. It should be the same as
 * {@link HRegionInfo#getServerName(Result)} if the server is at OPEN state.
 * @param r Result to pull the transitioning server name from
 * @return A ServerName instance or {@link HRegionInfo#getServerName(Result)}
 * if necessary fields not found or empty.
 */
static ServerName getRegionServer(final Result r, int replicaId) {
  Cell cell = r.getColumnLatestCell(HConstants.CATALOG_FAMILY, getServerNameColumn(replicaId));
  if (cell == null || cell.getValueLength() == 0) {
    RegionLocations locations = MetaTableAccessor.getRegionLocations(r);
    if (locations != null) {
      HRegionLocation location = locations.getRegionLocation(replicaId);
      if (location != null) {
        return location.getServerName();
      }
    }
    return null;
  }
  return ServerName.parseServerName(Bytes.toString(cell.getValueArray(),
    cell.getValueOffset(), cell.getValueLength()));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:24,代码来源:RegionStateStore.java

示例3: testMove

import org.apache.hadoop.hbase.HRegionLocation; //导入依赖的package包/类
@Test (timeout=180000)
public void testMove() throws Exception {
  List<HRegionLocation> regions;
  try (RegionLocator locator = systemUserConnection.getRegionLocator(TEST_TABLE)) {
    regions = locator.getAllRegionLocations();
  }
  HRegionLocation location = regions.get(0);
  final HRegionInfo hri = location.getRegionInfo();
  final ServerName server = location.getServerName();
  AccessTestAction action = new AccessTestAction() {
    @Override
    public Object run() throws Exception {
      ACCESS_CONTROLLER.preMove(ObserverContext.createAndPrepare(CP_ENV, null),
          hri, server, server);
      return null;
    }
  };

  verifyAllowed(action, SUPERUSER, USER_ADMIN, USER_OWNER, USER_GROUP_ADMIN);
  verifyDenied(action, USER_CREATE, USER_RW, USER_RO, USER_NONE, USER_GROUP_READ,
    USER_GROUP_WRITE, USER_GROUP_CREATE);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:23,代码来源:TestAccessController.java

示例4: testAssign

import org.apache.hadoop.hbase.HRegionLocation; //导入依赖的package包/类
@Test (timeout=180000)
public void testAssign() throws Exception {
  List<HRegionLocation> regions;
  try (RegionLocator locator = systemUserConnection.getRegionLocator(TEST_TABLE)) {
    regions = locator.getAllRegionLocations();
  }
  HRegionLocation location = regions.get(0);
  final HRegionInfo hri = location.getRegionInfo();
  AccessTestAction action = new AccessTestAction() {
    @Override
    public Object run() throws Exception {
      ACCESS_CONTROLLER.preAssign(ObserverContext.createAndPrepare(CP_ENV, null), hri);
      return null;
    }
  };

  verifyAllowed(action, SUPERUSER, USER_ADMIN, USER_OWNER, USER_GROUP_ADMIN);
  verifyDenied(action, USER_CREATE, USER_RW, USER_RO, USER_NONE, USER_GROUP_READ,
    USER_GROUP_WRITE, USER_GROUP_CREATE);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:21,代码来源:TestAccessController.java

示例5: getQueue

import org.apache.hadoop.hbase.HRegionLocation; //导入依赖的package包/类
@VisibleForTesting
LinkedBlockingQueue<PutStatus> getQueue(HRegionLocation addr) {
  FlushWorker worker = serverToFlushWorkerMap.get(addr);
  if (worker == null) {
    synchronized (this.serverToFlushWorkerMap) {
      worker = serverToFlushWorkerMap.get(addr);
      if (worker == null) {
        // Create the flush worker
        worker = new FlushWorker(workerConf, this.conn, addr, this, perRegionServerBufferQueueSize,
                pool, executor);
        this.serverToFlushWorkerMap.put(addr, worker);
        executor.scheduleAtFixedRate(worker, flushPeriod, flushPeriod, TimeUnit.MILLISECONDS);
      }
    }
  }
  return worker.getQueue();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:HTableMultiplexer.java

示例6: testGetRegion

import org.apache.hadoop.hbase.HRegionLocation; //导入依赖的package包/类
@Test (timeout=300000)
public void testGetRegion() throws Exception {
  // We use actual HBaseAdmin instance instead of going via Admin interface in
  // here because makes use of an internal HBA method (TODO: Fix.).
  HBaseAdmin rawAdmin = new HBaseAdmin(TEST_UTIL.getConfiguration());

  final TableName tableName = TableName.valueOf("testGetRegion");
  LOG.info("Started " + tableName);
  HTable t = TEST_UTIL.createMultiRegionTable(tableName, HConstants.CATALOG_FAMILY);

  HRegionLocation regionLocation = t.getRegionLocation("mmm");
  HRegionInfo region = regionLocation.getRegionInfo();
  byte[] regionName = region.getRegionName();
  Pair<HRegionInfo, ServerName> pair = rawAdmin.getRegion(regionName);
  assertTrue(Bytes.equals(regionName, pair.getFirst().getRegionName()));
  pair = rawAdmin.getRegion(region.getEncodedNameAsBytes());
  assertTrue(Bytes.equals(regionName, pair.getFirst().getRegionName()));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:19,代码来源:TestAdmin2.java

示例7: clearCache

import org.apache.hadoop.hbase.HRegionLocation; //导入依赖的package包/类
/**
 * Delete a cached location, no matter what it is. Called when we were told to not use cache.
 * @param tableName tableName
 * @param row
 */
public void clearCache(final TableName tableName, final byte [] row, int replicaId) {
  ConcurrentMap<byte[], RegionLocations> tableLocations = getTableLocations(tableName);

  boolean removed = false;
  RegionLocations regionLocations = getCachedLocation(tableName, row);
  if (regionLocations != null) {
    HRegionLocation toBeRemoved = regionLocations.getRegionLocation(replicaId);
    RegionLocations updatedLocations = regionLocations.remove(replicaId);
    if (updatedLocations != regionLocations) {
      byte[] startKey = regionLocations.getRegionLocation().getRegionInfo().getStartKey();
      if (updatedLocations.isEmpty()) {
        removed = tableLocations.remove(startKey, regionLocations);
      } else {
        removed = tableLocations.replace(startKey, regionLocations, updatedLocations);
      }
    }

    if (removed && LOG.isTraceEnabled() && toBeRemoved != null) {
      LOG.trace("Removed " + toBeRemoved + " from cache");
    }
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:28,代码来源:MetaCache.java

示例8: getMockedConnection

import org.apache.hadoop.hbase.HRegionLocation; //导入依赖的package包/类
@SuppressWarnings("deprecation")
private HConnection getMockedConnection(final Configuration conf)
throws IOException, ServiceException {
  HConnection c = Mockito.mock(HConnection.class);
  Mockito.when(c.getConfiguration()).thenReturn(conf);
  Mockito.doNothing().when(c).close();
  // Make it so we return a particular location when asked.
  final HRegionLocation loc = new HRegionLocation(HRegionInfo.FIRST_META_REGIONINFO,
      ServerName.valueOf("example.org", 1234, 0));
  Mockito.when(c.getRegionLocation((TableName) Mockito.any(),
      (byte[]) Mockito.any(), Mockito.anyBoolean())).
    thenReturn(loc);
  Mockito.when(c.locateRegion((TableName) Mockito.any(), (byte[]) Mockito.any())).
    thenReturn(loc);
  ClientProtos.ClientService.BlockingInterface hri =
    Mockito.mock(ClientProtos.ClientService.BlockingInterface.class);
  Mockito.when(hri.bulkLoadHFile((RpcController)Mockito.any(), (BulkLoadHFileRequest)Mockito.any())).
    thenThrow(new ServiceException(new IOException("injecting bulk load error")));
  Mockito.when(c.getClient(Mockito.any(ServerName.class))).
    thenReturn(hri);
  return c;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:23,代码来源:TestLoadIncrementalHFilesSplitRecovery.java

示例9: printLocations

import org.apache.hadoop.hbase.HRegionLocation; //导入依赖的package包/类
private void printLocations(Result r) {
  RegionLocations rl = null;
  if (r == null) {
    LOG.info("FAILED FOR null Result");
    return;
  }
  LOG.info("FAILED FOR " + resultToString(r) + " Stale " + r.isStale());
  if (r.getRow() == null) {
    return;
  }
  try {
    rl = ((ClusterConnection)connection).locateRegion(tableName, r.getRow(), true, true);
  } catch (IOException e) {
    LOG.warn("Couldn't get locations for row " + Bytes.toString(r.getRow()));
  }
  HRegionLocation locations[] = rl.getRegionLocations();
  for (HRegionLocation h : locations) {
    LOG.info("LOCATION " + h);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:21,代码来源:MultiThreadedAction.java

示例10: verifyRegionResults

import org.apache.hadoop.hbase.HRegionLocation; //导入依赖的package包/类
private void verifyRegionResults(RegionLocator regionLocator,
    Map<byte[], String> results, String expected, byte[] row)
throws Exception {
  for (Map.Entry<byte [], String> e: results.entrySet()) {
    LOG.info("row=" + Bytes.toString(row) + ", expected=" + expected +
     ", result key=" + Bytes.toString(e.getKey()) +
     ", value=" + e.getValue());
  }
  HRegionLocation loc = regionLocator.getRegionLocation(row, true);
  byte[] region = loc.getRegionInfo().getRegionName();
  assertTrue("Results should contain region " +
    Bytes.toStringBinary(region) + " for row '" + Bytes.toStringBinary(row)+ "'",
    results.containsKey(region));
  assertEquals("Invalid result for row '"+Bytes.toStringBinary(row)+"'",
    expected, results.get(region));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:17,代码来源:TestServerCustomProtocol.java

示例11: addNewScanner

import org.apache.hadoop.hbase.HRegionLocation; //导入依赖的package包/类
private void addNewScanner(boolean isSync) {
  HRegionLocation regionLocation = null;
  synchronized (regionLocationQueue) {
    regionLocation = regionLocationQueue.poll();
  }
  if (regionLocation == null) return;
  runningGet.incrementAndGet();
  if (!isSync) {
    new Thread(new GetScannerRunnable(regionLocation)).start();
    return;
  }
  try {
    innerAddScanner(regionLocation);
  } catch (IOException e) {
    e.printStackTrace();
    abortException = e;
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:19,代码来源:IRScannerInParallel.java

示例12: innerAddScanner

import org.apache.hadoop.hbase.HRegionLocation; //导入依赖的package包/类
private void innerAddScanner(HRegionLocation regionLocation) throws IOException {
  if (INIT_REGION_SIZE != getRegionNumber()) {
    throw new IOException(
        "region number changed from " + INIT_REGION_SIZE + " to " + getRegionNumber());
  }
  Scan newScan = new Scan(rawScan);
  if (regionLocation.getRegionInfo().getStartKey() != null)
    newScan.setStartRow(regionLocation.getRegionInfo().getStartKey());
  if (regionLocation.getRegionInfo().getEndKey() != null)
    newScan.setStopRow(regionLocation.getRegionInfo().getEndKey());
  newScan.setAttribute(IndexConstants.SCAN_WITH_INDEX, Bytes.toBytes("Hi"));
  newScan.setFilter(rangeList.toFilterList());
  newScan.setAttribute(IndexConstants.MAX_SCAN_SCALE, Bytes.toBytes(1.0f));
  ResultScanner scanner = table.getScanner(newScan);
  synchronized (scannerList) {
    scannerList.add(scanner);
  }
  runningGet.decrementAndGet();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:20,代码来源:IRScannerInParallel.java

示例13: getNextScanner

import org.apache.hadoop.hbase.HRegionLocation; //导入依赖的package包/类
private ResultScanner getNextScanner() throws IOException {
  if (INIT_REGION_SIZE != getRegionNumber()) {
    throw new IOException(
        "region number changed from " + INIT_REGION_SIZE + " to " + getRegionNumber());
  }
  if (regionLocationQueue.isEmpty()) return null;
  HRegionLocation regionLocation = regionLocationQueue.poll();
  Scan newScan = new Scan(rawScan);
  if (regionLocation.getRegionInfo().getStartKey() != null)
    newScan.setStartRow(regionLocation.getRegionInfo().getStartKey());
  if (regionLocation.getRegionInfo().getEndKey() != null)
    newScan.setStopRow(regionLocation.getRegionInfo().getEndKey());
  newScan.setAttribute(IndexConstants.SCAN_WITH_INDEX, Bytes.toBytes("Hi"));
  newScan.setFilter(rangeList.toFilterList());
  newScan.setAttribute(IndexConstants.MAX_SCAN_SCALE, Bytes.toBytes(1.0f));
  newScan.setId(rawScan.getId());
  newScan.setCacheBlocks(rawScan.getCacheBlocks());
  newScan.setCaching(rawScan.getCaching());
  return table.getScanner(newScan);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:21,代码来源:IRScanner.java

示例14: addNewScanner

import org.apache.hadoop.hbase.HRegionLocation; //导入依赖的package包/类
private void addNewScanner(boolean isSync) {
  HRegionLocation regionLocation = null;
  synchronized (regionLocationQueue) {
    regionLocation = regionLocationQueue.poll();
  }
  if (regionLocation == null) return;
  if (!isSync) {
    new Thread(new GetScannerRunnable(regionLocation)).start();
    return;
  }
  try {
    innerAddScanner(regionLocation);
  } catch (IOException e) {
    e.printStackTrace();
    abortException = e;
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:LocalScannerInParallel.java

示例15: lookupRegionIndex

import org.apache.hadoop.hbase.HRegionLocation; //导入依赖的package包/类
protected static int lookupRegionIndex(List<HRegionLocation> list, byte[] key) {
  if (list.size() == 1 || Bytes.compareTo(key, list.get(0).getRegionInfo().getStartKey()) <= 0)
    return 0;
  if (Bytes.compareTo(key, list.get(list.size() - 1).getRegionInfo().getStartKey()) >= 0)
    return list.size() - 1;
  int l = 0, r = list.size() - 1;
  while (l < r) {
    int mid = (l + r) / 2;
    int cmp = Bytes.compareTo(key, list.get(mid).getRegionInfo().getStartKey());
    if (cmp == 0) {
      return mid;
    } else if (cmp > 0) {
      if (Bytes.compareTo(key, list.get(mid + 1).getRegionInfo().getStartKey()) < 0) return mid;
      l = mid + 1;
    } else {
      r = mid - 1;
    }
  }
  return l;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:21,代码来源:BaseIndexScanner.java


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