Exemple #1
0
 /**
  * Get the descriptive name as {@link RegionState} does it but with hidden startkey optionally
  *
  * @param state
  * @param conf
  * @return descriptive string
  */
 public static String getDescriptiveNameFromRegionStateForDisplay(
     RegionState state, Configuration conf) {
   if (conf.getBoolean(DISPLAY_KEYS_KEY, true)) return state.toDescriptiveString();
   String descriptiveStringFromState = state.toDescriptiveString();
   int idx = descriptiveStringFromState.lastIndexOf(" state=");
   String regionName = getRegionNameAsStringForDisplay(state.getRegion(), conf);
   return regionName + descriptiveStringFromState.substring(idx);
 }
 /**
  * Gets the meta region location, if available. Does not block.
  *
  * @param zkw
  * @param replicaId
  * @return server name
  */
 public ServerName getMetaRegionLocation(final ZooKeeperWatcher zkw, int replicaId) {
   try {
     RegionState state = getMetaRegionState(zkw, replicaId);
     return state.isOpened() ? state.getServerName() : null;
   } catch (KeeperException ke) {
     return null;
   }
 }
 /**
  * Convert a protobuf ClusterStatus to a ClusterStatus
  *
  * @param proto the protobuf ClusterStatus
  * @return the converted ClusterStatus
  */
 public static ClusterStatus convert(ClusterStatusProtos.ClusterStatus proto) {
   Map<ServerName, ServerLoad> servers = new HashMap<ServerName, ServerLoad>();
   for (LiveServerInfo lsi : proto.getLiveServersList()) {
     servers.put(ProtobufUtil.toServerName(lsi.getServer()), new ServerLoad(lsi.getServerLoad()));
   }
   Collection<ServerName> deadServers = new LinkedList<ServerName>();
   for (HBaseProtos.ServerName sn : proto.getDeadServersList()) {
     deadServers.add(ProtobufUtil.toServerName(sn));
   }
   Collection<ServerName> backupMasters = new LinkedList<ServerName>();
   for (HBaseProtos.ServerName sn : proto.getBackupMastersList()) {
     backupMasters.add(ProtobufUtil.toServerName(sn));
   }
   final Map<String, RegionState> rit = new HashMap<String, RegionState>();
   for (RegionInTransition region : proto.getRegionsInTransitionList()) {
     String key = new String(region.getSpec().getValue().toByteArray());
     RegionState value = RegionState.convert(region.getRegionState());
     rit.put(key, value);
   }
   final int numMasterCoprocessors = proto.getMasterCoprocessorsCount();
   final String[] masterCoprocessors = new String[numMasterCoprocessors];
   for (int i = 0; i < numMasterCoprocessors; i++) {
     masterCoprocessors[i] = proto.getMasterCoprocessors(i).getName();
   }
   return new ClusterStatus(
       proto.getHbaseVersion().getVersion(),
       ClusterId.convert(proto.getClusterId()).toString(),
       servers,
       deadServers,
       ProtobufUtil.toServerName(proto.getMaster()),
       backupMasters,
       rit,
       masterCoprocessors,
       proto.getBalancerOn());
 }
 @Override
 public ReportRegionStateTransitionResponse reportRegionStateTransition(
     RpcController c, ReportRegionStateTransitionRequest req) throws ServiceException {
   ReportRegionStateTransitionResponse resp = super.reportRegionStateTransition(c, req);
   if (enabled.get()
       && req.getTransition(0).getTransitionCode() == TransitionCode.READY_TO_MERGE
       && !resp.hasErrorMessage()) {
     RegionStates regionStates = myMaster.getAssignmentManager().getRegionStates();
     for (RegionState regionState : regionStates.getRegionsInTransition().values()) {
       // Find the merging_new region and remove it
       if (regionState.isMergingNew()) {
         regionStates.deleteRegion(regionState.getRegion());
       }
     }
   }
   return resp;
 }