Java 类org.apache.hadoop.hbase.protobuf.generated.MasterProtos.UnassignRegionRequest 实例源码

项目:ditb    文件:HBaseAdmin.java   
/**
 * Unassign a region from current hosting regionserver.  Region will then be
 * assigned to a regionserver chosen at random.  Region could be reassigned
 * back to the same server.  Use {@link #move(byte[], byte[])} if you want
 * to control the region movement.
 * @param regionName Region to unassign. Will clear any existing RegionPlan
 * if one found.
 * @param force If true, force unassign (Will remove region from
 * regions-in-transition too if present. If results in double assignment
 * use hbck -fix to resolve. To be used by experts).
 * @throws MasterNotRunningException
 * @throws ZooKeeperConnectionException
 * @throws IOException
 */
@Override
public void unassign(final byte [] regionName, final boolean force)
throws MasterNotRunningException, ZooKeeperConnectionException, IOException {
  final byte[] toBeUnassigned = getRegionName(regionName);
  executeCallable(new MasterCallable<Void>(getConnection()) {
    @Override
    public Void call(int callTimeout) throws ServiceException {
      PayloadCarryingRpcController controller = rpcControllerFactory.newController();
      controller.setCallTimeout(callTimeout);
      // Hard to know the table name, at least check if meta
      if (isMetaRegion(regionName)) {
        controller.setPriority(TableName.META_TABLE_NAME);
      }
      UnassignRegionRequest request =
        RequestConverter.buildUnassignRegionRequest(toBeUnassigned, force);
      master.unassignRegion(controller, request);
      return null;
    }
  });
}
项目:ditb    文件:MasterRpcServices.java   
@Override
public UnassignRegionResponse unassignRegion(RpcController controller,
    UnassignRegionRequest req) throws ServiceException {
  try {
    final byte [] regionName = req.getRegion().getValue().toByteArray();
    RegionSpecifierType type = req.getRegion().getType();
    final boolean force = req.getForce();
    UnassignRegionResponse urr = UnassignRegionResponse.newBuilder().build();

    master.checkInitialized();
    if (type != RegionSpecifierType.REGION_NAME) {
      LOG.warn("unassignRegion specifier type: expected: " + RegionSpecifierType.REGION_NAME
        + " actual: " + type);
    }
    Pair<HRegionInfo, ServerName> pair =
      MetaTableAccessor.getRegion(master.getConnection(), regionName);
    if (pair == null) throw new UnknownRegionException(Bytes.toString(regionName));
    HRegionInfo hri = pair.getFirst();
    if (master.cpHost != null) {
      if (master.cpHost.preUnassign(hri, force)) {
        return urr;
      }
    }
    LOG.debug(master.getClientIdAuditPrefix() + " unassign " + hri.getRegionNameAsString()
        + " in current location if it is online and reassign.force=" + force);
    master.assignmentManager.unassign(hri, force);
    if (master.assignmentManager.getRegionStates().isRegionOffline(hri)) {
      LOG.debug("Region " + hri.getRegionNameAsString()
          + " is not online on any region server, reassigning it.");
      master.assignRegion(hri);
    }
    if (master.cpHost != null) {
      master.cpHost.postUnassign(hri, force);
    }

    return urr;
  } catch (IOException ioe) {
    throw new ServiceException(ioe);
  }
}
项目:ditb    文件:RequestConverter.java   
/**
 * Creates a protocol buffer UnassignRegionRequest
 *
 * @param regionName
 * @param force
 * @return an UnassignRegionRequest
 */
public static UnassignRegionRequest buildUnassignRegionRequest(
    final byte [] regionName, final boolean force) {
  UnassignRegionRequest.Builder builder = UnassignRegionRequest.newBuilder();
  builder.setRegion(buildRegionSpecifier(RegionSpecifierType.REGION_NAME,regionName));
  builder.setForce(force);
  return builder.build();
}
项目:pbase    文件:MasterRpcServices.java   
@Override
public UnassignRegionResponse unassignRegion(RpcController controller,
    UnassignRegionRequest req) throws ServiceException {
  try {
    final byte [] regionName = req.getRegion().getValue().toByteArray();
    RegionSpecifierType type = req.getRegion().getType();
    final boolean force = req.getForce();
    UnassignRegionResponse urr = UnassignRegionResponse.newBuilder().build();

    master.checkInitialized();
    if (type != RegionSpecifierType.REGION_NAME) {
      LOG.warn("unassignRegion specifier type: expected: " + RegionSpecifierType.REGION_NAME
        + " actual: " + type);
    }
    Pair<HRegionInfo, ServerName> pair =
      MetaTableAccessor.getRegion(master.getConnection(), regionName);
    if (pair == null) throw new UnknownRegionException(Bytes.toString(regionName));
    HRegionInfo hri = pair.getFirst();
    if (master.cpHost != null) {
      if (master.cpHost.preUnassign(hri, force)) {
        return urr;
      }
    }
    LOG.debug(master.getClientIdAuditPrefix() + " unassign " + hri.getRegionNameAsString()
        + " in current location if it is online and reassign.force=" + force);
    master.assignmentManager.unassign(hri, force);
    if (master.assignmentManager.getRegionStates().isRegionOffline(hri)) {
      LOG.debug("Region " + hri.getRegionNameAsString()
          + " is not online on any region server, reassigning it.");
      master.assignRegion(hri);
    }
    if (master.cpHost != null) {
      master.cpHost.postUnassign(hri, force);
    }

    return urr;
  } catch (IOException ioe) {
    throw new ServiceException(ioe);
  }
}
项目:pbase    文件:RequestConverter.java   
/**
 * Creates a protocol buffer UnassignRegionRequest
 *
 * @param regionName
 * @param force
 * @return an UnassignRegionRequest
 */
public static UnassignRegionRequest buildUnassignRegionRequest(
    final byte [] regionName, final boolean force) {
  UnassignRegionRequest.Builder builder = UnassignRegionRequest.newBuilder();
  builder.setRegion(buildRegionSpecifier(RegionSpecifierType.REGION_NAME,regionName));
  builder.setForce(force);
  return builder.build();
}
项目:pbase    文件:HBaseAdmin.java   
/**
 * Unassign a region from current hosting regionserver.  Region will then be
 * assigned to a regionserver chosen at random.  Region could be reassigned
 * back to the same server.  Use {@link #move(byte[], byte[])} if you want
 * to control the region movement.
 * @param regionName Region to unassign. Will clear any existing RegionPlan
 * if one found.
 * @param force If true, force unassign (Will remove region from
 * regions-in-transition too if present. If results in double assignment
 * use hbck -fix to resolve. To be used by experts).
 * @throws MasterNotRunningException
 * @throws ZooKeeperConnectionException
 * @throws IOException
 */
@Override
public void unassign(final byte [] regionName, final boolean force)
throws MasterNotRunningException, ZooKeeperConnectionException, IOException {
  final byte[] toBeUnassigned = getRegionName(regionName);
  executeCallable(new MasterCallable<Void>(getConnection()) {
    @Override
    public Void call(int callTimeout) throws ServiceException {
      UnassignRegionRequest request =
        RequestConverter.buildUnassignRegionRequest(toBeUnassigned, force);
      master.unassignRegion(null, request);
      return null;
    }
  });
}
项目:HIndex    文件:HMaster.java   
@Override
public UnassignRegionResponse unassignRegion(RpcController controller, UnassignRegionRequest req)
throws ServiceException {
  try {
    final byte [] regionName = req.getRegion().getValue().toByteArray();
    RegionSpecifierType type = req.getRegion().getType();
    final boolean force = req.getForce();
    UnassignRegionResponse urr = UnassignRegionResponse.newBuilder().build();

    checkInitialized();
    if (type != RegionSpecifierType.REGION_NAME) {
      LOG.warn("unassignRegion specifier type: expected: " + RegionSpecifierType.REGION_NAME
        + " actual: " + type);
    }
    Pair<HRegionInfo, ServerName> pair =
      MetaReader.getRegion(this.catalogTracker, regionName);
    if (pair == null) throw new UnknownRegionException(Bytes.toString(regionName));
    HRegionInfo hri = pair.getFirst();
    if (cpHost != null) {
      if (cpHost.preUnassign(hri, force)) {
        return urr;
      }
    }
    LOG.debug(getClientIdAuditPrefix() + " unassign " + hri.getRegionNameAsString()
        + " in current location if it is online and reassign.force=" + force);
    this.assignmentManager.unassign(hri, force);
    if (this.assignmentManager.getRegionStates().isRegionOffline(hri)) {
      LOG.debug("Region " + hri.getRegionNameAsString()
          + " is not online on any region server, reassigning it.");
      assignRegion(hri);
    }
    if (cpHost != null) {
      cpHost.postUnassign(hri, force);
    }

    return urr;
  } catch (IOException ioe) {
    throw new ServiceException(ioe);
  }
}
项目:HIndex    文件:RequestConverter.java   
/**
 * Creates a protocol buffer UnassignRegionRequest
 *
 * @param regionName
 * @param force
 * @return an UnassignRegionRequest
 */
public static UnassignRegionRequest buildUnassignRegionRequest(
    final byte [] regionName, final boolean force) {
  UnassignRegionRequest.Builder builder = UnassignRegionRequest.newBuilder();
  builder.setRegion(buildRegionSpecifier(RegionSpecifierType.REGION_NAME,regionName));
  builder.setForce(force);
  return builder.build();
}
项目:PyroDB    文件:MasterRpcServices.java   
@Override
public UnassignRegionResponse unassignRegion(RpcController controller,
    UnassignRegionRequest req) throws ServiceException {
  try {
    final byte [] regionName = req.getRegion().getValue().toByteArray();
    RegionSpecifierType type = req.getRegion().getType();
    final boolean force = req.getForce();
    UnassignRegionResponse urr = UnassignRegionResponse.newBuilder().build();

    master.checkInitialized();
    if (type != RegionSpecifierType.REGION_NAME) {
      LOG.warn("unassignRegion specifier type: expected: " + RegionSpecifierType.REGION_NAME
        + " actual: " + type);
    }
    Pair<HRegionInfo, ServerName> pair =
      MetaReader.getRegion(master.getCatalogTracker(), regionName);
    if (pair == null) throw new UnknownRegionException(Bytes.toString(regionName));
    HRegionInfo hri = pair.getFirst();
    if (master.cpHost != null) {
      if (master.cpHost.preUnassign(hri, force)) {
        return urr;
      }
    }
    LOG.debug(master.getClientIdAuditPrefix() + " unassign " + hri.getRegionNameAsString()
        + " in current location if it is online and reassign.force=" + force);
    master.assignmentManager.unassign(hri, force);
    if (master.assignmentManager.getRegionStates().isRegionOffline(hri)) {
      LOG.debug("Region " + hri.getRegionNameAsString()
          + " is not online on any region server, reassigning it.");
      master.assignRegion(hri);
    }
    if (master.cpHost != null) {
      master.cpHost.postUnassign(hri, force);
    }

    return urr;
  } catch (IOException ioe) {
    throw new ServiceException(ioe);
  }
}
项目:PyroDB    文件:RequestConverter.java   
/**
 * Creates a protocol buffer UnassignRegionRequest
 *
 * @param regionName
 * @param force
 * @return an UnassignRegionRequest
 */
public static UnassignRegionRequest buildUnassignRegionRequest(
    final byte [] regionName, final boolean force) {
  UnassignRegionRequest.Builder builder = UnassignRegionRequest.newBuilder();
  builder.setRegion(buildRegionSpecifier(RegionSpecifierType.REGION_NAME,regionName));
  builder.setForce(force);
  return builder.build();
}
项目:c5    文件:HMaster.java   
@Override
public UnassignRegionResponse unassignRegion(RpcController controller, UnassignRegionRequest req)
throws ServiceException {
  try {
    final byte [] regionName = req.getRegion().getValue().toByteArray();
    RegionSpecifierType type = req.getRegion().getType();
    final boolean force = req.getForce();
    UnassignRegionResponse urr = UnassignRegionResponse.newBuilder().build();

    checkInitialized();
    if (type != RegionSpecifierType.REGION_NAME) {
      LOG.warn("unassignRegion specifier type: expected: " + RegionSpecifierType.REGION_NAME
        + " actual: " + type);
    }
    Pair<HRegionInfo, ServerName> pair =
      MetaReader.getRegion(this.catalogTracker, regionName);
    if (pair == null) throw new UnknownRegionException(Bytes.toString(regionName));
    HRegionInfo hri = pair.getFirst();
    if (cpHost != null) {
      if (cpHost.preUnassign(hri, force)) {
        return urr;
      }
    }
    LOG.debug(getClientIdAuditPrefix() + " unassign " + hri.getRegionNameAsString()
        + " in current location if it is online and reassign.force=" + force);
    this.assignmentManager.unassign(hri, force);
    if (this.assignmentManager.getRegionStates().isRegionOffline(hri)) {
      LOG.debug("Region " + hri.getRegionNameAsString()
          + " is not online on any region server, reassigning it.");
      assignRegion(hri);
    }
    if (cpHost != null) {
      cpHost.postUnassign(hri, force);
    }

    return urr;
  } catch (IOException ioe) {
    throw new ServiceException(ioe);
  }
}
项目:c5    文件:RequestConverter.java   
/**
 * Creates a protocol buffer UnassignRegionRequest
 *
 * @param regionName
 * @param force
 * @return an UnassignRegionRequest
 */
public static UnassignRegionRequest buildUnassignRegionRequest(
    final byte [] regionName, final boolean force) {
  UnassignRegionRequest.Builder builder = UnassignRegionRequest.newBuilder();
  builder.setRegion(buildRegionSpecifier(RegionSpecifierType.REGION_NAME,regionName));
  builder.setForce(force);
  return builder.build();
}
项目:HIndex    文件:HBaseAdmin.java   
/**
 * Unassign a region from current hosting regionserver.  Region will then be
 * assigned to a regionserver chosen at random.  Region could be reassigned
 * back to the same server.  Use {@link #move(byte[], byte[])} if you want
 * to control the region movement.
 * @param regionName Region to unassign. Will clear any existing RegionPlan
 * if one found.
 * @param force If true, force unassign (Will remove region from
 * regions-in-transition too if present. If results in double assignment
 * use hbck -fix to resolve. To be used by experts).
 * @throws MasterNotRunningException
 * @throws ZooKeeperConnectionException
 * @throws IOException
 */
public void unassign(final byte [] regionName, final boolean force)
throws MasterNotRunningException, ZooKeeperConnectionException, IOException {
  final byte[] toBeUnassigned = getRegionName(regionName);
  executeCallable(new MasterCallable<Void>(getConnection()) {
    @Override
    public Void call() throws ServiceException {
      UnassignRegionRequest request =
        RequestConverter.buildUnassignRegionRequest(toBeUnassigned, force);
      master.unassignRegion(null,request);
      return null;
    }
  });
}
项目:PyroDB    文件:HBaseAdmin.java   
/**
 * Unassign a region from current hosting regionserver.  Region will then be
 * assigned to a regionserver chosen at random.  Region could be reassigned
 * back to the same server.  Use {@link #move(byte[], byte[])} if you want
 * to control the region movement.
 * @param regionName Region to unassign. Will clear any existing RegionPlan
 * if one found.
 * @param force If true, force unassign (Will remove region from
 * regions-in-transition too if present. If results in double assignment
 * use hbck -fix to resolve. To be used by experts).
 * @throws MasterNotRunningException
 * @throws ZooKeeperConnectionException
 * @throws IOException
 */
public void unassign(final byte [] regionName, final boolean force)
throws MasterNotRunningException, ZooKeeperConnectionException, IOException {
  final byte[] toBeUnassigned = getRegionName(regionName);
  executeCallable(new MasterCallable<Void>(getConnection()) {
    @Override
    public Void call(int callTimeout) throws ServiceException {
      UnassignRegionRequest request =
        RequestConverter.buildUnassignRegionRequest(toBeUnassigned, force);
      master.unassignRegion(null,request);
      return null;
    }
  });
}
项目:c5    文件:HBaseAdmin.java   
/**
 * Unassign a region from current hosting regionserver.  Region will then be
 * assigned to a regionserver chosen at random.  Region could be reassigned
 * back to the same server.  Use {@link #move(byte[], byte[])} if you want
 * to control the region movement.
 * @param regionName Region to unassign. Will clear any existing RegionPlan
 * if one found.
 * @param force If true, force unassign (Will remove region from
 * regions-in-transition too if present. If results in double assignment
 * use hbck -fix to resolve. To be used by experts).
 * @throws MasterNotRunningException
 * @throws ZooKeeperConnectionException
 * @throws IOException
 */
public void unassign(final byte [] regionName, final boolean force)
throws MasterNotRunningException, ZooKeeperConnectionException, IOException {
  final byte[] toBeUnassigned = getRegionName(regionName);
  executeCallable(new MasterCallable<Void>(getConnection()) {
    @Override
    public Void call() throws ServiceException {
      UnassignRegionRequest request =
        RequestConverter.buildUnassignRegionRequest(toBeUnassigned, force);
      master.unassignRegion(null,request);
      return null;
    }
  });
}