Java 类org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.NameStringPair 实例源码

项目:ditb    文件:SnapshotManager.java   
private SnapshotDescription toSnapshotDescription(ProcedureDescription desc)
    throws IOException {
  SnapshotDescription.Builder builder = SnapshotDescription.newBuilder();
  if (!desc.hasInstance()) {
    throw new IOException("Snapshot name is not defined: " + desc.toString());
  }
  String snapshotName = desc.getInstance();
  List<NameStringPair> props = desc.getConfigurationList();
  String table = null;
  for (NameStringPair prop : props) {
    if ("table".equalsIgnoreCase(prop.getName())) {
      table = prop.getValue();
    }
  }
  if (table == null) {
    throw new IOException("Snapshot table is not defined: " + desc.toString());
  }
  TableName tableName = TableName.valueOf(table);
  builder.setTable(tableName.getNameAsString());
  builder.setName(snapshotName);
  builder.setType(SnapshotDescription.Type.FLUSH);
  return builder.build();
}
项目:ditb    文件:MasterRpcServices.java   
@Override
public RegionServerStartupResponse regionServerStartup(
    RpcController controller, RegionServerStartupRequest request) throws ServiceException {
  // Register with server manager
  try {
    master.checkServiceStarted();
    InetAddress ia = master.getRemoteInetAddress(
      request.getPort(), request.getServerStartCode());
    // if regionserver passed hostname to use,
    // then use it instead of doing a reverse DNS lookup
    ServerName rs = master.serverManager.regionServerStartup(request, ia);

    // Send back some config info
    RegionServerStartupResponse.Builder resp = createConfigurationSubset();
    NameStringPair.Builder entry = NameStringPair.newBuilder()
      .setName(HConstants.KEY_FOR_HOSTNAME_SEEN_BY_MASTER)
      .setValue(rs.getHostname());
    resp.addMapEntries(entry.build());

    return resp.build();
  } catch (IOException ioe) {
    throw new ServiceException(ioe);
  }
}
项目:ditb    文件:TestRSKilledWhenInitializing.java   
@Override
protected void handleReportForDutyResponse(RegionServerStartupResponse c) throws IOException {
  if (firstRS.getAndSet(false)) {
    InetSocketAddress address = super.getRpcServer().getListenerAddress();
    if (address == null) {
      throw new IOException("Listener channel is closed");
    }
    for (NameStringPair e : c.getMapEntriesList()) {
      String key = e.getName();
      // The hostname the master sees us as.
      if (key.equals(HConstants.KEY_FOR_HOSTNAME_SEEN_BY_MASTER)) {
        String hostnameFromMasterPOV = e.getValue();
        assertEquals(address.getHostName(), hostnameFromMasterPOV);
      }
    }
    while (!masterActive) {
      Threads.sleep(100);
    }
    super.kill();
  } else {
    super.handleReportForDutyResponse(c);
  }
}
项目:ditb    文件:HBaseAdmin.java   
/**
 * Check the current state of the specified procedure.
 * <p>
 * There are three possible states:
 * <ol>
 * <li>running - returns <tt>false</tt></li>
 * <li>finished - returns <tt>true</tt></li>
 * <li>finished with error - throws the exception that caused the procedure to fail</li>
 * </ol>
 * <p>
 *
 * @param signature The signature that uniquely identifies a procedure
 * @param instance The instance name of the procedure
 * @param props Property/Value pairs of properties passing to the procedure
 * @return true if the specified procedure is finished successfully, false if it is still running
 * @throws IOException if the specified procedure finished with error
 */
@Override
public boolean isProcedureFinished(String signature, String instance, Map<String, String> props)
    throws IOException {
  final ProcedureDescription.Builder builder = ProcedureDescription.newBuilder();
  builder.setSignature(signature).setInstance(instance);
  for (Entry<String, String> entry : props.entrySet()) {
    NameStringPair pair = NameStringPair.newBuilder().setName(entry.getKey())
        .setValue(entry.getValue()).build();
    builder.addConfiguration(pair);
  }
  final ProcedureDescription desc = builder.build();
  return executeCallable(
      new MasterCallable<IsProcedureDoneResponse>(getConnection()) {
        @Override
        public IsProcedureDoneResponse call(int callTimeout) throws ServiceException {
          PayloadCarryingRpcController controller = rpcControllerFactory.newController();
          controller.setCallTimeout(callTimeout);
          return master.isProcedureDone(controller, IsProcedureDoneRequest
              .newBuilder().setProcedure(desc).build());
        }
      }).getDone();
}
项目:pbase    文件:SnapshotManager.java   
private SnapshotDescription toSnapshotDescription(ProcedureDescription desc)
    throws IOException {
  SnapshotDescription.Builder builder = SnapshotDescription.newBuilder();
  if (!desc.hasInstance()) {
    throw new IOException("Snapshot name is not defined: " + desc.toString());
  }
  String snapshotName = desc.getInstance();
  List<NameStringPair> props = desc.getConfigurationList();
  String table = null;
  for (NameStringPair prop : props) {
    if ("table".equalsIgnoreCase(prop.getName())) {
      table = prop.getValue();
    }
  }
  if (table == null) {
    throw new IOException("Snapshot table is not defined: " + desc.toString());
  }
  TableName tableName = TableName.valueOf(table);
  builder.setTable(tableName.getNameAsString());
  builder.setName(snapshotName);
  builder.setType(SnapshotDescription.Type.FLUSH);
  return builder.build();
}
项目:pbase    文件:MasterRpcServices.java   
@Override
public RegionServerStartupResponse regionServerStartup(
    RpcController controller, RegionServerStartupRequest request) throws ServiceException {
  // Register with server manager
  try {
    master.checkServiceStarted();
    InetAddress ia = master.getRemoteInetAddress(
      request.getPort(), request.getServerStartCode());
    ServerName rs = master.serverManager.regionServerStartup(ia, request.getPort(),
      request.getServerStartCode(), request.getServerCurrentTime());

    // Send back some config info
    RegionServerStartupResponse.Builder resp = createConfigurationSubset();
    NameStringPair.Builder entry = NameStringPair.newBuilder()
      .setName(HConstants.KEY_FOR_HOSTNAME_SEEN_BY_MASTER)
      .setValue(rs.getHostname());
    resp.addMapEntries(entry.build());

    return resp.build();
  } catch (IOException ioe) {
    throw new ServiceException(ioe);
  }
}
项目:pbase    文件:TestRSKilledWhenInitializing.java   
@Override
protected void handleReportForDutyResponse(RegionServerStartupResponse c) throws IOException {
  if (firstRS.getAndSet(false)) {
    for (NameStringPair e : c.getMapEntriesList()) {
      String key = e.getName();
      // The hostname the master sees us as.
      if (key.equals(HConstants.KEY_FOR_HOSTNAME_SEEN_BY_MASTER)) {
        String hostnameFromMasterPOV = e.getValue();
        assertEquals(super.getRpcServer().getListenerAddress().getHostName(),
          hostnameFromMasterPOV);
      }
    }
    while (!masterActive) {
      Threads.sleep(100);
    }
    super.kill();
  } else {
    super.handleReportForDutyResponse(c);
  }
}
项目:pbase    文件:HBaseAdmin.java   
/**
 * Execute a distributed procedure on a cluster synchronously with return data
 *
 * @param signature A distributed procedure is uniquely identified
 * by its signature (default the root ZK node name of the procedure).
 * @param instance The instance name of the procedure. For some procedures, this parameter is
 * optional.
 * @param props Property/Value pairs of properties passing to the procedure
 * @return data returned after procedure execution. null if no return data.
 * @throws IOException
 */
@Override
public byte[] execProcedureWithRet(String signature, String instance,
    Map<String, String> props) throws IOException {
  ProcedureDescription.Builder builder = ProcedureDescription.newBuilder();
  builder.setSignature(signature).setInstance(instance);
  for (Entry<String, String> entry : props.entrySet()) {
    NameStringPair pair = NameStringPair.newBuilder().setName(entry.getKey())
        .setValue(entry.getValue()).build();
    builder.addConfiguration(pair);
  }

  final ExecProcedureRequest request = ExecProcedureRequest.newBuilder()
      .setProcedure(builder.build()).build();
  // run the procedure on the master
  ExecProcedureResponse response = executeCallable(new MasterCallable<ExecProcedureResponse>(
      getConnection()) {
    @Override
    public ExecProcedureResponse call(int callTimeout) throws ServiceException {
      return master.execProcedureWithRet(null, request);
    }
  });

  return response.hasReturnData() ? response.getReturnData().toByteArray() : null;
}
项目:pbase    文件:HBaseAdmin.java   
/**
 * Check the current state of the specified procedure.
 * <p>
 * There are three possible states:
 * <ol>
 * <li>running - returns <tt>false</tt></li>
 * <li>finished - returns <tt>true</tt></li>
 * <li>finished with error - throws the exception that caused the procedure to fail</li>
 * </ol>
 * <p>
 *
 * @param signature The signature that uniquely identifies a procedure
 * @param instance The instance name of the procedure
 * @param props Property/Value pairs of properties passing to the procedure
 * @return true if the specified procedure is finished successfully, false if it is still running
 * @throws IOException if the specified procedure finished with error
 */
@Override
public boolean isProcedureFinished(String signature, String instance, Map<String, String> props)
    throws IOException {
  final ProcedureDescription.Builder builder = ProcedureDescription.newBuilder();
  builder.setSignature(signature).setInstance(instance);
  for (Entry<String, String> entry : props.entrySet()) {
    NameStringPair pair = NameStringPair.newBuilder().setName(entry.getKey())
        .setValue(entry.getValue()).build();
    builder.addConfiguration(pair);
  }
  final ProcedureDescription desc = builder.build();
  return executeCallable(
      new MasterCallable<IsProcedureDoneResponse>(getConnection()) {
        @Override
        public IsProcedureDoneResponse call(int callTimeout) throws ServiceException {
          return master.isProcedureDone(null, IsProcedureDoneRequest
              .newBuilder().setProcedure(desc).build());
        }
      }).getDone();
}
项目:HIndex    文件:HMaster.java   
@Override
public RegionServerStartupResponse regionServerStartup(
    RpcController controller, RegionServerStartupRequest request) throws ServiceException {
  // Register with server manager
  try {
    InetAddress ia = getRemoteInetAddress(request.getPort(), request.getServerStartCode());
    ServerName rs = this.serverManager.regionServerStartup(ia, request.getPort(),
      request.getServerStartCode(), request.getServerCurrentTime());

    // Send back some config info
    RegionServerStartupResponse.Builder resp = createConfigurationSubset();
    NameStringPair.Builder entry = NameStringPair.newBuilder()
      .setName(HConstants.KEY_FOR_HOSTNAME_SEEN_BY_MASTER)
      .setValue(rs.getHostname());
    resp.addMapEntries(entry.build());

    return resp.build();
  } catch (IOException ioe) {
    throw new ServiceException(ioe);
  }
}
项目:HIndex    文件:SnapshotManager.java   
private SnapshotDescription toSnapshotDescription(ProcedureDescription desc)
    throws IOException {
  SnapshotDescription.Builder builder = SnapshotDescription.newBuilder();
  if (!desc.hasInstance()) {
    throw new IOException("Snapshot name is not defined: " + desc.toString());
  }
  String snapshotName = desc.getInstance();
  List<NameStringPair> props = desc.getConfigurationList();
  String table = null;
  for (NameStringPair prop : props) {
    if ("table".equalsIgnoreCase(prop.getName())) {
      table = prop.getValue();
    }
  }
  if (table == null) {
    throw new IOException("Snapshot table is not defined: " + desc.toString());
  }
  TableName tableName = TableName.valueOf(table);
  builder.setTable(tableName.getNameAsString());
  builder.setName(snapshotName);
  builder.setType(SnapshotDescription.Type.FLUSH);
  return builder.build();
}
项目:HIndex    文件:HBaseAdmin.java   
/**
 * Check the current state of the specified procedure.
 * <p>
 * There are three possible states:
 * <ol>
 * <li>running - returns <tt>false</tt></li>
 * <li>finished - returns <tt>true</tt></li>
 * <li>finished with error - throws the exception that caused the procedure to fail</li>
 * </ol>
 * <p>
 *
 * @param signature The signature that uniquely identifies a procedure
 * @param instance The instance name of the procedure
 * @param props Property/Value pairs of properties passing to the procedure
 * @return true if the specified procedure is finished successfully, false if it is still running
 * @throws IOException if the specified procedure finished with error
 */
public boolean isProcedureFinished(String signature, String instance, Map<String, String> props)
    throws IOException {
  final ProcedureDescription.Builder builder = ProcedureDescription.newBuilder();
  builder.setSignature(signature).setInstance(instance);
  for (String key : props.keySet()) {
    NameStringPair pair = NameStringPair.newBuilder().setName(key)
        .setValue(props.get(key)).build();
    builder.addConfiguration(pair);
  }
  final ProcedureDescription desc = builder.build();
  return executeCallable(
      new MasterCallable<IsProcedureDoneResponse>(getConnection()) {
        @Override
        public IsProcedureDoneResponse call() throws ServiceException {
          return master.isProcedureDone(null, IsProcedureDoneRequest
              .newBuilder().setProcedure(desc).build());
        }
      }).getDone();
}
项目:PyroDB    文件:SnapshotManager.java   
private SnapshotDescription toSnapshotDescription(ProcedureDescription desc)
    throws IOException {
  SnapshotDescription.Builder builder = SnapshotDescription.newBuilder();
  if (!desc.hasInstance()) {
    throw new IOException("Snapshot name is not defined: " + desc.toString());
  }
  String snapshotName = desc.getInstance();
  List<NameStringPair> props = desc.getConfigurationList();
  String table = null;
  for (NameStringPair prop : props) {
    if ("table".equalsIgnoreCase(prop.getName())) {
      table = prop.getValue();
    }
  }
  if (table == null) {
    throw new IOException("Snapshot table is not defined: " + desc.toString());
  }
  TableName tableName = TableName.valueOf(table);
  builder.setTable(tableName.getNameAsString());
  builder.setName(snapshotName);
  builder.setType(SnapshotDescription.Type.FLUSH);
  return builder.build();
}
项目:PyroDB    文件:MasterRpcServices.java   
@Override
public RegionServerStartupResponse regionServerStartup(
    RpcController controller, RegionServerStartupRequest request) throws ServiceException {
  // Register with server manager
  try {
    master.checkServiceStarted();
    InetAddress ia = master.getRemoteInetAddress(
      request.getPort(), request.getServerStartCode());
    ServerName rs = master.serverManager.regionServerStartup(ia, request.getPort(),
      request.getServerStartCode(), request.getServerCurrentTime());

    // Send back some config info
    RegionServerStartupResponse.Builder resp = createConfigurationSubset();
    NameStringPair.Builder entry = NameStringPair.newBuilder()
      .setName(HConstants.KEY_FOR_HOSTNAME_SEEN_BY_MASTER)
      .setValue(rs.getHostname());
    resp.addMapEntries(entry.build());

    return resp.build();
  } catch (IOException ioe) {
    throw new ServiceException(ioe);
  }
}
项目:PyroDB    文件:TestRSKilledWhenInitializing.java   
@Override
protected void handleReportForDutyResponse(RegionServerStartupResponse c) throws IOException {
  if (firstRS.getAndSet(false)) {
    for (NameStringPair e : c.getMapEntriesList()) {
      String key = e.getName();
      // The hostname the master sees us as.
      if (key.equals(HConstants.KEY_FOR_HOSTNAME_SEEN_BY_MASTER)) {
        String hostnameFromMasterPOV = e.getValue();
        assertEquals(super.getRpcServer().getListenerAddress().getHostName(),
          hostnameFromMasterPOV);
      }
    }
    while (!masterActive) {
      Threads.sleep(100);
    }
    super.kill();
  } else {
    super.handleReportForDutyResponse(c);
  }
}
项目:PyroDB    文件:HBaseAdmin.java   
/**
 * Check the current state of the specified procedure.
 * <p>
 * There are three possible states:
 * <ol>
 * <li>running - returns <tt>false</tt></li>
 * <li>finished - returns <tt>true</tt></li>
 * <li>finished with error - throws the exception that caused the procedure to fail</li>
 * </ol>
 * <p>
 *
 * @param signature The signature that uniquely identifies a procedure
 * @param instance The instance name of the procedure
 * @param props Property/Value pairs of properties passing to the procedure
 * @return true if the specified procedure is finished successfully, false if it is still running
 * @throws IOException if the specified procedure finished with error
 */
public boolean isProcedureFinished(String signature, String instance, Map<String, String> props)
    throws IOException {
  final ProcedureDescription.Builder builder = ProcedureDescription.newBuilder();
  builder.setSignature(signature).setInstance(instance);
  for (Entry<String, String> entry : props.entrySet()) {
    NameStringPair pair = NameStringPair.newBuilder().setName(entry.getKey())
        .setValue(entry.getValue()).build();
    builder.addConfiguration(pair);
  }
  final ProcedureDescription desc = builder.build();
  return executeCallable(
      new MasterCallable<IsProcedureDoneResponse>(getConnection()) {
        @Override
        public IsProcedureDoneResponse call(int callTimeout) throws ServiceException {
          return master.isProcedureDone(null, IsProcedureDoneRequest
              .newBuilder().setProcedure(desc).build());
        }
      }).getDone();
}
项目:c5    文件:HMaster.java   
@Override
public RegionServerStartupResponse regionServerStartup(
    RpcController controller, RegionServerStartupRequest request) throws ServiceException {
  // Register with server manager
  try {
    InetAddress ia = getRemoteInetAddress(request.getPort(), request.getServerStartCode());
    ServerName rs = this.serverManager.regionServerStartup(ia, request.getPort(),
      request.getServerStartCode(), request.getServerCurrentTime());

    // Send back some config info
    RegionServerStartupResponse.Builder resp = createConfigurationSubset();
    NameStringPair.Builder entry = NameStringPair.newBuilder()
      .setName(HConstants.KEY_FOR_HOSTNAME_SEEN_BY_MASTER)
      .setValue(rs.getHostname());
    resp.addMapEntries(entry.build());

    return resp.build();
  } catch (IOException ioe) {
    throw new ServiceException(ioe);
  }
}
项目:c5    文件:TestRSKilledWhenInitializing.java   
@Override
protected void handleReportForDutyResponse(RegionServerStartupResponse c) throws IOException {
  for (NameStringPair e : c.getMapEntriesList()) {
    String key = e.getName();
    // The hostname the master sees us as.
    if (key.equals(HConstants.KEY_FOR_HOSTNAME_SEEN_BY_MASTER)) {
      String hostnameFromMasterPOV = e.getValue();
      assertEquals(super.getRpcServer().getListenerAddress().getHostName(),
        hostnameFromMasterPOV);
    }
  }
  while (!masterActive) {
    Threads.sleep(100);
  }
  super.kill();
}
项目:DominoHBase    文件:HMaster.java   
@Override
public RegionServerStartupResponse regionServerStartup(
    RpcController controller, RegionServerStartupRequest request) throws ServiceException {
  // Register with server manager
  try {
    InetAddress ia = getRemoteInetAddress(request.getPort(), request.getServerStartCode());
    ServerName rs = this.serverManager.regionServerStartup(ia, request.getPort(),
      request.getServerStartCode(), request.getServerCurrentTime());

    // Send back some config info
    RegionServerStartupResponse.Builder resp = createConfigurationSubset();
    NameStringPair.Builder entry = NameStringPair.newBuilder()
      .setName(HConstants.KEY_FOR_HOSTNAME_SEEN_BY_MASTER)
      .setValue(rs.getHostname());
    resp.addMapEntries(entry.build());

    return resp.build();
  } catch (IOException ioe) {
    throw new ServiceException(ioe);
  }
}
项目:ditb    文件:MasterRpcServices.java   
private RegionServerStartupResponse.Builder addConfig(
    final RegionServerStartupResponse.Builder resp, final String key) {
  NameStringPair.Builder entry = NameStringPair.newBuilder()
    .setName(key)
    .setValue(master.getConfiguration().get(key));
  resp.addMapEntries(entry.build());
  return resp;
}
项目:ditb    文件:HBaseAdmin.java   
/**
 * Execute a distributed procedure on a cluster synchronously with return data
 *
 * @param signature A distributed procedure is uniquely identified
 * by its signature (default the root ZK node name of the procedure).
 * @param instance The instance name of the procedure. For some procedures, this parameter is
 * optional.
 * @param props Property/Value pairs of properties passing to the procedure
 * @return data returned after procedure execution. null if no return data.
 * @throws IOException
 */
@Override
public byte[] execProcedureWithRet(String signature, String instance,
    Map<String, String> props) throws IOException {
  ProcedureDescription.Builder builder = ProcedureDescription.newBuilder();
  builder.setSignature(signature).setInstance(instance);
  for (Entry<String, String> entry : props.entrySet()) {
    NameStringPair pair = NameStringPair.newBuilder().setName(entry.getKey())
        .setValue(entry.getValue()).build();
    builder.addConfiguration(pair);
  }

  final ExecProcedureRequest request = ExecProcedureRequest.newBuilder()
      .setProcedure(builder.build()).build();
  // run the procedure on the master
  ExecProcedureResponse response = executeCallable(new MasterCallable<ExecProcedureResponse>(
      getConnection()) {
    @Override
    public ExecProcedureResponse call(int callTimeout) throws ServiceException {
      PayloadCarryingRpcController controller = rpcControllerFactory.newController();
      controller.setCallTimeout(callTimeout);
      return master.execProcedureWithRet(controller, request);
    }
  });

  return response.hasReturnData() ? response.getReturnData().toByteArray() : null;
}
项目:pbase    文件:MasterRpcServices.java   
private RegionServerStartupResponse.Builder addConfig(
    final RegionServerStartupResponse.Builder resp, final String key) {
  NameStringPair.Builder entry = NameStringPair.newBuilder()
    .setName(key)
    .setValue(master.getConfiguration().get(key));
  resp.addMapEntries(entry.build());
  return resp;
}
项目:HIndex    文件:HMaster.java   
private RegionServerStartupResponse.Builder addConfig(
    final RegionServerStartupResponse.Builder resp, final String key) {
  NameStringPair.Builder entry = NameStringPair.newBuilder()
    .setName(key)
    .setValue(this.conf.get(key));
  resp.addMapEntries(entry.build());
  return resp;
}
项目:PyroDB    文件:MasterRpcServices.java   
private RegionServerStartupResponse.Builder addConfig(
    final RegionServerStartupResponse.Builder resp, final String key) {
  NameStringPair.Builder entry = NameStringPair.newBuilder()
    .setName(key)
    .setValue(master.getConfiguration().get(key));
  resp.addMapEntries(entry.build());
  return resp;
}
项目:c5    文件:HMaster.java   
private RegionServerStartupResponse.Builder addConfig(
    final RegionServerStartupResponse.Builder resp, final String key) {
  NameStringPair.Builder entry = NameStringPair.newBuilder()
    .setName(key)
    .setValue(this.conf.get(key));
  resp.addMapEntries(entry.build());
  return resp;
}
项目:DominoHBase    文件:HMaster.java   
private RegionServerStartupResponse.Builder addConfig(
    final RegionServerStartupResponse.Builder resp, final String key) {
  NameStringPair.Builder entry = NameStringPair.newBuilder()
    .setName(key)
    .setValue(this.conf.get(key));
  resp.addMapEntries(entry.build());
  return resp;
}
项目:ditb    文件:HBaseAdmin.java   
/**
 * Execute a distributed procedure on a cluster.
 *
 * @param signature A distributed procedure is uniquely identified
 * by its signature (default the root ZK node name of the procedure).
 * @param instance The instance name of the procedure. For some procedures, this parameter is
 * optional.
 * @param props Property/Value pairs of properties passing to the procedure
 * @throws IOException
 */
@Override
public void execProcedure(String signature, String instance,
    Map<String, String> props) throws IOException {
  ProcedureDescription.Builder builder = ProcedureDescription.newBuilder();
  builder.setSignature(signature).setInstance(instance);
  for (Entry<String, String> entry : props.entrySet()) {
    NameStringPair pair = NameStringPair.newBuilder().setName(entry.getKey())
        .setValue(entry.getValue()).build();
    builder.addConfiguration(pair);
  }

  final ExecProcedureRequest request = ExecProcedureRequest.newBuilder()
      .setProcedure(builder.build()).build();
  // run the procedure on the master
  ExecProcedureResponse response = executeCallable(new MasterCallable<ExecProcedureResponse>(
      getConnection()) {
    @Override
    public ExecProcedureResponse call(int callTimeout) throws ServiceException {
      PayloadCarryingRpcController controller = rpcControllerFactory.newController();
      controller.setCallTimeout(callTimeout);
      return master.execProcedure(controller, request);
    }
  });

  long start = EnvironmentEdgeManager.currentTime();
  long max = response.getExpectedTimeout();
  long maxPauseTime = max / this.numRetries;
  int tries = 0;
  LOG.debug("Waiting a max of " + max + " ms for procedure '" +
      signature + " : " + instance + "'' to complete. (max " + maxPauseTime + " ms per retry)");
  boolean done = false;
  while (tries == 0
      || ((EnvironmentEdgeManager.currentTime() - start) < max && !done)) {
    try {
      // sleep a backoff <= pauseTime amount
      long sleep = getPauseTime(tries++);
      sleep = sleep > maxPauseTime ? maxPauseTime : sleep;
      LOG.debug("(#" + tries + ") Sleeping: " + sleep +
        "ms while waiting for procedure completion.");
      Thread.sleep(sleep);
    } catch (InterruptedException e) {
      throw (InterruptedIOException)new InterruptedIOException("Interrupted").initCause(e);
    }
    LOG.debug("Getting current status of procedure from master...");
    done = isProcedureFinished(signature, instance, props);
  }
  if (!done) {
    throw new IOException("Procedure '" + signature + " : " + instance
        + "' wasn't completed in expectedTime:" + max + " ms");
  }
}
项目:pbase    文件:HBaseAdmin.java   
/**
 * Execute a distributed procedure on a cluster.
 *
 * @param signature A distributed procedure is uniquely identified
 * by its signature (default the root ZK node name of the procedure).
 * @param instance The instance name of the procedure. For some procedures, this parameter is
 * optional.
 * @param props Property/Value pairs of properties passing to the procedure
 * @throws IOException
 */
@Override
public void execProcedure(String signature, String instance,
    Map<String, String> props) throws IOException {
  ProcedureDescription.Builder builder = ProcedureDescription.newBuilder();
  builder.setSignature(signature).setInstance(instance);
  for (Entry<String, String> entry : props.entrySet()) {
    NameStringPair pair = NameStringPair.newBuilder().setName(entry.getKey())
        .setValue(entry.getValue()).build();
    builder.addConfiguration(pair);
  }

  final ExecProcedureRequest request = ExecProcedureRequest.newBuilder()
      .setProcedure(builder.build()).build();
  // run the procedure on the master
  ExecProcedureResponse response = executeCallable(new MasterCallable<ExecProcedureResponse>(
      getConnection()) {
    @Override
    public ExecProcedureResponse call(int callTimeout) throws ServiceException {
      return master.execProcedure(null, request);
    }
  });

  long start = EnvironmentEdgeManager.currentTime();
  long max = response.getExpectedTimeout();
  long maxPauseTime = max / this.numRetries;
  int tries = 0;
  LOG.debug("Waiting a max of " + max + " ms for procedure '" +
      signature + " : " + instance + "'' to complete. (max " + maxPauseTime + " ms per retry)");
  boolean done = false;
  while (tries == 0
      || ((EnvironmentEdgeManager.currentTime() - start) < max && !done)) {
    try {
      // sleep a backoff <= pauseTime amount
      long sleep = getPauseTime(tries++);
      sleep = sleep > maxPauseTime ? maxPauseTime : sleep;
      LOG.debug("(#" + tries + ") Sleeping: " + sleep +
        "ms while waiting for procedure completion.");
      Thread.sleep(sleep);
    } catch (InterruptedException e) {
      throw (InterruptedIOException)new InterruptedIOException("Interrupted").initCause(e);
    }
    LOG.debug("Getting current status of procedure from master...");
    done = isProcedureFinished(signature, instance, props);
  }
  if (!done) {
    throw new IOException("Procedure '" + signature + " : " + instance
        + "' wasn't completed in expectedTime:" + max + " ms");
  }
}
项目:HIndex    文件:HBaseAdmin.java   
/**
 * Execute a distributed procedure on a cluster.
 *
 * @param signature A distributed procedure is uniquely identified
 * by its signature (default the root ZK node name of the procedure).
 * @param instance The instance name of the procedure. For some procedures, this parameter is
 * optional.
 * @param props Property/Value pairs of properties passing to the procedure
 */
public void execProcedure(String signature, String instance,
    Map<String, String> props) throws IOException {
  ProcedureDescription.Builder builder = ProcedureDescription.newBuilder();
  builder.setSignature(signature).setInstance(instance);
  for (String key : props.keySet()) {
    NameStringPair pair = NameStringPair.newBuilder().setName(key)
        .setValue(props.get(key)).build();
    builder.addConfiguration(pair);
  }

  final ExecProcedureRequest request = ExecProcedureRequest.newBuilder()
      .setProcedure(builder.build()).build();
  // run the procedure on the master
  ExecProcedureResponse response = executeCallable(new MasterCallable<ExecProcedureResponse>(
      getConnection()) {
    @Override
    public ExecProcedureResponse call() throws ServiceException {
      return master.execProcedure(null, request);
    }
  });

  long start = EnvironmentEdgeManager.currentTimeMillis();
  long max = response.getExpectedTimeout();
  long maxPauseTime = max / this.numRetries;
  int tries = 0;
  LOG.debug("Waiting a max of " + max + " ms for procedure '" +
      signature + " : " + instance + "'' to complete. (max " + maxPauseTime + " ms per retry)");
  boolean done = false;
  while (tries == 0
      || ((EnvironmentEdgeManager.currentTimeMillis() - start) < max && !done)) {
    try {
      // sleep a backoff <= pauseTime amount
      long sleep = getPauseTime(tries++);
      sleep = sleep > maxPauseTime ? maxPauseTime : sleep;
      LOG.debug("(#" + tries + ") Sleeping: " + sleep +
        "ms while waiting for procedure completion.");
      Thread.sleep(sleep);

    } catch (InterruptedException e) {
      LOG.debug("Interrupted while waiting for procedure " + signature + " to complete");
      Thread.currentThread().interrupt();
    }
    LOG.debug("Getting current status of procedure from master...");
    done = isProcedureFinished(signature, instance, props);
  }
  if (!done) {
    throw new IOException("Procedure '" + signature + " : " + instance
        + "' wasn't completed in expectedTime:" + max + " ms");
  }
}
项目:PyroDB    文件:HBaseAdmin.java   
/**
 * Execute a distributed procedure on a cluster.
 *
 * @param signature A distributed procedure is uniquely identified
 * by its signature (default the root ZK node name of the procedure).
 * @param instance The instance name of the procedure. For some procedures, this parameter is
 * optional.
 * @param props Property/Value pairs of properties passing to the procedure
 */
public void execProcedure(String signature, String instance,
    Map<String, String> props) throws IOException {
  ProcedureDescription.Builder builder = ProcedureDescription.newBuilder();
  builder.setSignature(signature).setInstance(instance);
  for (Entry<String, String> entry : props.entrySet()) {
    NameStringPair pair = NameStringPair.newBuilder().setName(entry.getKey())
        .setValue(entry.getValue()).build();
    builder.addConfiguration(pair);
  }

  final ExecProcedureRequest request = ExecProcedureRequest.newBuilder()
      .setProcedure(builder.build()).build();
  // run the procedure on the master
  ExecProcedureResponse response = executeCallable(new MasterCallable<ExecProcedureResponse>(
      getConnection()) {
    @Override
    public ExecProcedureResponse call(int callTimeout) throws ServiceException {
      return master.execProcedure(null, request);
    }
  });

  long start = EnvironmentEdgeManager.currentTimeMillis();
  long max = response.getExpectedTimeout();
  long maxPauseTime = max / this.numRetries;
  int tries = 0;
  LOG.debug("Waiting a max of " + max + " ms for procedure '" +
      signature + " : " + instance + "'' to complete. (max " + maxPauseTime + " ms per retry)");
  boolean done = false;
  while (tries == 0
      || ((EnvironmentEdgeManager.currentTimeMillis() - start) < max && !done)) {
    try {
      // sleep a backoff <= pauseTime amount
      long sleep = getPauseTime(tries++);
      sleep = sleep > maxPauseTime ? maxPauseTime : sleep;
      LOG.debug("(#" + tries + ") Sleeping: " + sleep +
        "ms while waiting for procedure completion.");
      Thread.sleep(sleep);
    } catch (InterruptedException e) {
      throw (InterruptedIOException)new InterruptedIOException("Interrupted").initCause(e);
    }
    LOG.debug("Getting current status of procedure from master...");
    done = isProcedureFinished(signature, instance, props);
  }
  if (!done) {
    throw new IOException("Procedure '" + signature + " : " + instance
        + "' wasn't completed in expectedTime:" + max + " ms");
  }
}