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


Java RegionLocations.getRegionLocation方法代码示例

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


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

示例1: getRegionServer

import org.apache.hadoop.hbase.RegionLocations; //导入方法依赖的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

示例2: replicateUsingCallable

import org.apache.hadoop.hbase.RegionLocations; //导入方法依赖的package包/类
private void replicateUsingCallable(ClusterConnection connection, Queue<Entry> entries)
    throws IOException, RuntimeException {
  Entry entry;
  while ((entry = entries.poll()) != null) {
    byte[] row = entry.getEdit().getCells().get(0).getRow();
    RegionLocations locations = connection.locateRegion(tableName, row, true, true);
    RegionReplicaReplayCallable callable = new RegionReplicaReplayCallable(connection,
      RpcControllerFactory.instantiate(connection.getConfiguration()),
      table.getName(), locations.getRegionLocation(1),
      locations.getRegionLocation(1).getRegionInfo(), row, Lists.newArrayList(entry),
      new AtomicLong());

    RpcRetryingCallerFactory factory = RpcRetryingCallerFactory.instantiate(
      connection.getConfiguration());
    factory.<ReplicateWALEntryResponse> newCaller().callWithRetries(callable, 10000);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:TestRegionReplicaReplicationEndpointNoMaster.java

示例3: testShutdownOfReplicaHolder

import org.apache.hadoop.hbase.RegionLocations; //导入方法依赖的package包/类
@Test
public void testShutdownOfReplicaHolder() throws Exception {
  // checks that the when the server holding meta replica is shut down, the meta replica
  // can be recovered
  RegionLocations rl = ConnectionManager.getConnectionInternal(TEST_UTIL.getConfiguration()).
      locateRegion(TableName.META_TABLE_NAME, Bytes.toBytes(""), false, true);
  HRegionLocation hrl = rl.getRegionLocation(1);
  ServerName oldServer = hrl.getServerName();
  TEST_UTIL.getHBaseClusterInterface().killRegionServer(oldServer);
  int i = 0;
  do {
    LOG.debug("Waiting for the replica " + hrl.getRegionInfo() + " to come up");
    Thread.sleep(30000); //wait for the detection/recovery
    rl = ConnectionManager.getConnectionInternal(TEST_UTIL.getConfiguration()).
        locateRegion(TableName.META_TABLE_NAME, Bytes.toBytes(""), false, true);
    hrl = rl.getRegionLocation(1);
    i++;
  } while ((hrl == null || hrl.getServerName().equals(oldServer)) && i < 3);
  assertTrue(i != 3);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:21,代码来源:TestMetaWithReplicas.java

示例4: prepare

import org.apache.hadoop.hbase.RegionLocations; //导入方法依赖的package包/类
/**
 * Two responsibilities
 * - if the call is already completed (by another replica) stops the retries.
 * - set the location to the right region, depending on the replica.
 */
@Override
public void prepare(final boolean reload) throws IOException {
  if (controller.isCanceled()) return;

  if (Thread.interrupted()) {
    throw new InterruptedIOException();
  }

  if (reload || location == null) {
    RegionLocations rl = getRegionLocations(false, id, cConnection, tableName, get.getRow());
    location = id < rl.size() ? rl.getRegionLocation(id) : null;
  }

  if (location == null || location.getServerName() == null) {
    // With this exception, there will be a retry. The location can be null for a replica
    //  when the table is created or after a split.
    throw new HBaseIOException("There is no location for replica id #" + id);
  }

  ServerName dest = location.getServerName();

  setStub(cConnection.getClient(dest));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:29,代码来源:RpcRetryingCallerWithReadReplicas.java

示例5: clearCache

import org.apache.hadoop.hbase.RegionLocations; //导入方法依赖的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

示例6: getReplicaLocationOrFail

import org.apache.hadoop.hbase.RegionLocations; //导入方法依赖的package包/类
private HRegionLocation getReplicaLocationOrFail(Action<Row> action) {
  // We are going to try get location once again. For each action, we'll do it once
  // from cache, because the previous calls in the loop might populate it.
  int replicaId = action.getReplicaId();
  RegionLocations locs = findAllLocationsOrFail(action, true);
  if (locs == null) return null; // manageError already called
  HRegionLocation loc = locs.getRegionLocation(replicaId);
  if (loc == null || loc.getServerName() == null) {
    locs = findAllLocationsOrFail(action, false);
    if (locs == null) return null; // manageError already called
    loc = locs.getRegionLocation(replicaId);
  }
  if (loc == null || loc.getServerName() == null) {
    manageLocationError(action, null);
    return null;
  }
  return loc;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:19,代码来源:AsyncProcess.java

示例7: getRegionServer

import org.apache.hadoop.hbase.RegionLocations; //导入方法依赖的package包/类
/**
 * Returns the {@link ServerName} from catalog table {@link Result}
 * where the region is transitioning. It should be the same as
 * {@link MetaTableAccessor#getServerName(Result,int)} if the server is at OPEN state.
 * @param r Result to pull the transitioning server name from
 * @return A ServerName instance or {@link MetaTableAccessor#getServerName(Result,int)}
 * if necessary fields not found or empty.
 */
static ServerName getRegionServer(final Result r, int replicaId) {
  final 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:apache,项目名称:hbase,代码行数:25,代码来源:RegionStateStore.java

示例8: replicateUsingCallable

import org.apache.hadoop.hbase.RegionLocations; //导入方法依赖的package包/类
private void replicateUsingCallable(ClusterConnection connection, Queue<Entry> entries)
    throws IOException, RuntimeException {
  Entry entry;
  while ((entry = entries.poll()) != null) {
    byte[] row = CellUtil.cloneRow(entry.getEdit().getCells().get(0));
    RegionLocations locations = connection.locateRegion(tableName, row, true, true);
    RegionReplicaReplayCallable callable = new RegionReplicaReplayCallable(connection,
      RpcControllerFactory.instantiate(connection.getConfiguration()),
      table.getName(), locations.getRegionLocation(1),
      locations.getRegionLocation(1).getRegionInfo(), row, Lists.newArrayList(entry),
      new AtomicLong());

    RpcRetryingCallerFactory factory = RpcRetryingCallerFactory.instantiate(
      connection.getConfiguration());
    factory.<ReplicateWALEntryResponse> newCaller().callWithRetries(callable, 10000);
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:18,代码来源:TestRegionReplicaReplicationEndpointNoMaster.java

示例9: testShutdownOfReplicaHolder

import org.apache.hadoop.hbase.RegionLocations; //导入方法依赖的package包/类
@Test
public void testShutdownOfReplicaHolder() throws Exception {
  // checks that the when the server holding meta replica is shut down, the meta replica
  // can be recovered
  try (ClusterConnection conn = (ClusterConnection)
      ConnectionFactory.createConnection(TEST_UTIL.getConfiguration())) {
    RegionLocations rl = conn.
        locateRegion(TableName.META_TABLE_NAME, Bytes.toBytes(""), false, true);
    HRegionLocation hrl = rl.getRegionLocation(1);
    ServerName oldServer = hrl.getServerName();
    TEST_UTIL.getHBaseClusterInterface().killRegionServer(oldServer);
    int i = 0;
    do {
      LOG.debug("Waiting for the replica " + hrl.getRegionInfo() + " to come up");
      Thread.sleep(10000); //wait for the detection/recovery
      rl = conn.locateRegion(TableName.META_TABLE_NAME, Bytes.toBytes(""), false, true);
      hrl = rl.getRegionLocation(1);
      i++;
    } while ((hrl == null || hrl.getServerName().equals(oldServer)) && i < 3);
    assertTrue(i != 3);
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:23,代码来源:TestMetaWithReplicas.java

示例10: prepare

import org.apache.hadoop.hbase.RegionLocations; //导入方法依赖的package包/类
/**
 * Two responsibilities
 * - if the call is already completed (by another replica) stops the retries.
 * - set the location to the right region, depending on the replica.
 */
@Override
// TODO: Very like the super class implemenation. Can we shrink this down?
public void prepare(final boolean reload) throws IOException {
  if (getRpcController().isCanceled()) return;
  if (Thread.interrupted()) {
    throw new InterruptedIOException();
  }
  if (reload || location == null) {
    RegionLocations rl = getRegionLocations(false, id, cConnection, tableName, get.getRow());
    location = id < rl.size() ? rl.getRegionLocation(id) : null;
  }

  if (location == null || location.getServerName() == null) {
    // With this exception, there will be a retry. The location can be null for a replica
    //  when the table is created or after a split.
    throw new HBaseIOException("There is no location for replica id #" + id);
  }

  setStubByServiceName(this.location.getServerName());
}
 
开发者ID:apache,项目名称:hbase,代码行数:26,代码来源:RpcRetryingCallerWithReadReplicas.java

示例11: clearCache

import org.apache.hadoop.hbase.RegionLocations; //导入方法依赖的package包/类
/**
 * Deletes the cached location of the region if necessary, based on some error from source.
 * @param hri The region in question.
 */
public void clearCache(RegionInfo hri) {
  ConcurrentMap<byte[], RegionLocations> tableLocations = getTableLocations(hri.getTable());
  RegionLocations regionLocations = tableLocations.get(hri.getStartKey());
  if (regionLocations != null) {
    HRegionLocation oldLocation = regionLocations.getRegionLocation(hri.getReplicaId());
    if (oldLocation == null) return;
    RegionLocations updatedLocations = regionLocations.remove(oldLocation);
    boolean removed;
    if (updatedLocations != regionLocations) {
      if (updatedLocations.isEmpty()) {
        removed = tableLocations.remove(hri.getStartKey(), regionLocations);
      } else {
        removed = tableLocations.replace(hri.getStartKey(), regionLocations, updatedLocations);
      }
      if (removed) {
        if (metrics != null) {
          metrics.incrMetaCacheNumClearRegion();
        }
        if (LOG.isTraceEnabled()) {
          LOG.trace("Removed " + oldLocation + " from cache");
        }
      }
    }
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:30,代码来源:MetaCache.java

示例12: prepare

import org.apache.hadoop.hbase.RegionLocations; //导入方法依赖的package包/类
/**
 * @param reload force reload of server location
 * @throws IOException
 */
@Override
public void prepare(boolean reload) throws IOException {
  if (Thread.interrupted()) {
    throw new InterruptedIOException();
  }
  RegionLocations rl = RpcRetryingCallerWithReadReplicas.getRegionLocations(!reload,
      id, getConnection(), getTableName(), getRow());
  location = id < rl.size() ? rl.getRegionLocation(id) : null;
  if (location == null || location.getServerName() == null) {
    // With this exception, there will be a retry. The location can be null for a replica
    //  when the table is created or after a split.
    throw new HBaseIOException("There is no location for replica id #" + id);
  }
  ServerName dest = location.getServerName();
  setStub(super.getConnection().getClient(dest));
  if (!instantiated || reload) {
    checkIfRegionServerIsRemote();
    instantiated = true;
  }
  cursor = null;
  // check how often we retry.
  if (reload) {
    incRPCRetriesMetrics(scanMetrics, isRegionServerRemote);
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:30,代码来源:ScannerCallable.java

示例13: getReplicaLocationOrFail

import org.apache.hadoop.hbase.RegionLocations; //导入方法依赖的package包/类
private HRegionLocation getReplicaLocationOrFail(Action action) {
  // We are going to try get location once again. For each action, we'll do it once
  // from cache, because the previous calls in the loop might populate it.
  int replicaId = action.getReplicaId();
  RegionLocations locs = findAllLocationsOrFail(action, true);
  if (locs == null) return null; // manageError already called
  HRegionLocation loc = locs.getRegionLocation(replicaId);
  if (loc == null || loc.getServerName() == null) {
    locs = findAllLocationsOrFail(action, false);
    if (locs == null) return null; // manageError already called
    loc = locs.getRegionLocation(replicaId);
  }
  if (loc == null || loc.getServerName() == null) {
    manageLocationError(action, null);
    return null;
  }
  return loc;
}
 
开发者ID:apache,项目名称:hbase,代码行数:19,代码来源:AsyncRequestFutureImpl.java

示例14: countMetaRegions

import org.apache.hadoop.hbase.RegionLocations; //导入方法依赖的package包/类
private static int countMetaRegions(final HMaster master, final TableName tableName)
    throws IOException {
  final AtomicInteger actualRegCount = new AtomicInteger(0);
  final MetaScannerVisitor visitor = new MetaScannerVisitorBase() {
    @Override
    public boolean processRow(Result rowResult) throws IOException {
      RegionLocations list = MetaTableAccessor.getRegionLocations(rowResult);
      if (list == null) {
        LOG.warn("No serialized HRegionInfo in " + rowResult);
        return true;
      }
      HRegionLocation l = list.getRegionLocation();
      if (l == null) {
        return true;
      }
      if (!l.getRegionInfo().getTable().equals(tableName)) {
        return false;
      }
      if (l.getRegionInfo().isOffline() || l.getRegionInfo().isSplit()) return true;
      HRegionLocation[] locations = list.getRegionLocations();
      for (HRegionLocation location : locations) {
        if (location == null) continue;
        ServerName serverName = location.getServerName();
        // Make sure that regions are assigned to server
        if (serverName != null && serverName.getHostAndPort() != null) {
          actualRegCount.incrementAndGet();
        }
      }
      return true;
    }
  };
  MetaScanner.metaScan(master.getConnection(), visitor, tableName);
  return actualRegCount.get();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:35,代码来源:MasterProcedureTestingUtility.java

示例15: addCallsForReplica

import org.apache.hadoop.hbase.RegionLocations; //导入方法依赖的package包/类
/**
 * Creates the calls and submit them
 *
 * @param cs  - the completion service to use for submitting
 * @param rl  - the region locations
 * @param min - the id of the first replica, inclusive
 * @param max - the id of the last replica, inclusive.
 */
private void addCallsForReplica(ResultBoundedCompletionService<Result> cs,
                               RegionLocations rl, int min, int max) {
  for (int id = min; id <= max; id++) {
    HRegionLocation hrl = rl.getRegionLocation(id);
    ReplicaRegionServerCallable callOnReplica = new ReplicaRegionServerCallable(id, hrl);
    cs.submit(callOnReplica, callTimeout, id);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:17,代码来源:RpcRetryingCallerWithReadReplicas.java


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