Java 类org.apache.hadoop.hbase.monitoring.MonitoredRPCHandler 实例源码

项目:ditb    文件:RpcServer.java   
static MonitoredRPCHandler getStatus() {
  // It is ugly the way we park status up in RpcServer.  Let it be for now.  TODO.
  MonitoredRPCHandler status = RpcServer.MONITORED_RPC.get();
  if (status != null) {
    return status;
  }
  status = TaskMonitor.get().createRPCStatus(Thread.currentThread().getName());
  status.pause("Waiting for a call");
  RpcServer.MONITORED_RPC.set(status);
  return status;
}
项目:LCIndex-HBase-0.94.16    文件:TestHRegion.java   
/**
 * Testcase to check state of region initialization task set to ABORTED or not if any exceptions
 * during initialization
 * 
 * @throws Exception
 */
@Test
public void testStatusSettingToAbortIfAnyExceptionDuringRegionInitilization() throws Exception {
  HRegionInfo info = null;
  try {
    FileSystem fs = Mockito.mock(FileSystem.class);
    Mockito.when(fs.exists((Path) Mockito.anyObject())).thenThrow(new IOException());
    HTableDescriptor htd = new HTableDescriptor(tableName);
    htd.addFamily(new HColumnDescriptor("cf"));
    info = new HRegionInfo(htd.getName(), HConstants.EMPTY_BYTE_ARRAY,
        HConstants.EMPTY_BYTE_ARRAY, false);
    Path path = new Path(DIR + "testStatusSettingToAbortIfAnyExceptionDuringRegionInitilization");
    // no where we are instantiating HStore in this test case so useTableNameGlobally is null. To
    // avoid NullPointerException we are setting useTableNameGlobally to false.
    SchemaMetrics.setUseTableNameInTest(false);
    region = HRegion.newHRegion(path, null, fs, conf, info, htd, null);
    // region initialization throws IOException and set task state to ABORTED.
    region.initialize();
    fail("Region initialization should fail due to IOException");
  } catch (IOException io) {
    List<MonitoredTask> tasks = TaskMonitor.get().getTasks();
    for (MonitoredTask monitoredTask : tasks) {
      if (!(monitoredTask instanceof MonitoredRPCHandler)
          && monitoredTask.getDescription().contains(region.toString())) {
        assertTrue("Region state should be ABORTED.",
            monitoredTask.getState().equals(MonitoredTask.State.ABORTED));
        break;
      }
    }
  } finally {
    HRegion.closeHRegion(region);
  }
}
项目:pbase    文件:CallRunner.java   
MonitoredRPCHandler getStatus() {
  // It is ugly the way we park status up in RpcServer.  Let it be for now.  TODO.
  MonitoredRPCHandler status = RpcServer.MONITORED_RPC.get();
  if (status != null) {
    return status;
  }
  status = TaskMonitor.get().createRPCStatus(Thread.currentThread().getName());
  status.pause("Waiting for a call");
  RpcServer.MONITORED_RPC.set(status);
  return status;
}
项目:pbase    文件:TestHRegion.java   
/**
 * Testcase to check state of region initialization task set to ABORTED or not
 * if any exceptions during initialization
 *
 * @throws Exception
 */
@Test
public void testStatusSettingToAbortIfAnyExceptionDuringRegionInitilization() throws Exception {
  TableName tableName = TableName.valueOf(name.getMethodName());
  HRegionInfo info = null;
  try {
    FileSystem fs = Mockito.mock(FileSystem.class);
    Mockito.when(fs.exists((Path) Mockito.anyObject())).thenThrow(new IOException());
    HTableDescriptor htd = new HTableDescriptor(tableName);
    htd.addFamily(new HColumnDescriptor("cf"));
    info = new HRegionInfo(htd.getTableName(), HConstants.EMPTY_BYTE_ARRAY,
        HConstants.EMPTY_BYTE_ARRAY, false);
    Path path = new Path(dir + "testStatusSettingToAbortIfAnyExceptionDuringRegionInitilization");
    region = HRegion.newHRegion(path, null, fs, CONF, info, htd, null);
    // region initialization throws IOException and set task state to ABORTED.
    region.initialize();
    fail("Region initialization should fail due to IOException");
  } catch (IOException io) {
    List<MonitoredTask> tasks = TaskMonitor.get().getTasks();
    for (MonitoredTask monitoredTask : tasks) {
      if (!(monitoredTask instanceof MonitoredRPCHandler)
          && monitoredTask.getDescription().contains(region.toString())) {
        assertTrue("Region state should be ABORTED.",
            monitoredTask.getState().equals(MonitoredTask.State.ABORTED));
        break;
      }
    }
  } finally {
    HRegion.closeHRegion(region);
  }
}
项目:HIndex    文件:CoprocessorHConnection.java   
public org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ClientService.BlockingInterface
    getClient(ServerName serverName) throws IOException {
  // client is trying to reach off-server, so we can't do anything special
  if (!this.serverName.equals(serverName)) {
    return delegate.getClient(serverName);
  }
  // the client is attempting to write to the same regionserver, we can short-circuit to our
  // local regionserver
  final BlockingService blocking = ClientService.newReflectiveBlockingService(this.server);
  final RpcServerInterface rpc = this.server.getRpcServer();

  final MonitoredRPCHandler status =
      TaskMonitor.get().createRPCStatus(Thread.currentThread().getName());
  status.pause("Setting up server-local call");

  final long timestamp = EnvironmentEdgeManager.currentTimeMillis();
  BlockingRpcChannel channel = new BlockingRpcChannel() {

    @Override
    public Message callBlockingMethod(MethodDescriptor method, RpcController controller,
        Message request, Message responsePrototype) throws ServiceException {
      try {
        // we never need a cell-scanner - everything is already fully formed
        return rpc.call(blocking, method, request, null, timestamp, status).getFirst();
      } catch (IOException e) {
        throw new ServiceException(e);
      }
    }
  };
  return ClientService.newBlockingStub(channel);
}
项目:HIndex    文件:CallRunner.java   
MonitoredRPCHandler getStatus() {
  // It is ugly the way we park status up in RpcServer.  Let it be for now.  TODO.
  MonitoredRPCHandler status = RpcServer.MONITORED_RPC.get();
  if (status != null) {
    return status;
  }
  status = TaskMonitor.get().createRPCStatus(Thread.currentThread().getName());
  status.pause("Waiting for a call");
  RpcServer.MONITORED_RPC.set(status);
  return status;
}
项目:HIndex    文件:TestHRegion.java   
/**
 * Testcase to check state of region initialization task set to ABORTED or not
 * if any exceptions during initialization
 * 
 * @throws Exception
 */
@Test
public void testStatusSettingToAbortIfAnyExceptionDuringRegionInitilization() throws Exception {
  TableName tableName = TableName.valueOf(name.getMethodName());
  HRegionInfo info = null;
  try {
    FileSystem fs = Mockito.mock(FileSystem.class);
    Mockito.when(fs.exists((Path) Mockito.anyObject())).thenThrow(new IOException());
    HTableDescriptor htd = new HTableDescriptor(tableName);
    htd.addFamily(new HColumnDescriptor("cf"));
    info = new HRegionInfo(htd.getTableName(), HConstants.EMPTY_BYTE_ARRAY,
        HConstants.EMPTY_BYTE_ARRAY, false);
    Path path = new Path(dir + "testStatusSettingToAbortIfAnyExceptionDuringRegionInitilization");
    region = HRegion.newHRegion(path, null, fs, CONF, info, htd, null);
    // region initialization throws IOException and set task state to ABORTED.
    region.initialize();
    fail("Region initialization should fail due to IOException");
  } catch (IOException io) {
    List<MonitoredTask> tasks = TaskMonitor.get().getTasks();
    for (MonitoredTask monitoredTask : tasks) {
      if (!(monitoredTask instanceof MonitoredRPCHandler)
          && monitoredTask.getDescription().contains(region.toString())) {
        assertTrue("Region state should be ABORTED.",
            monitoredTask.getState().equals(MonitoredTask.State.ABORTED));
        break;
      }
    }
  } finally {
    HRegion.closeHRegion(region);
  }
}
项目:IRIndex    文件:TestHRegion.java   
/**
 * Testcase to check state of region initialization task set to ABORTED or not if any exceptions
 * during initialization
 * 
 * @throws Exception
 */
@Test
public void testStatusSettingToAbortIfAnyExceptionDuringRegionInitilization() throws Exception {
  HRegionInfo info = null;
  try {
    FileSystem fs = Mockito.mock(FileSystem.class);
    Mockito.when(fs.exists((Path) Mockito.anyObject())).thenThrow(new IOException());
    HTableDescriptor htd = new HTableDescriptor(tableName);
    htd.addFamily(new HColumnDescriptor("cf"));
    info = new HRegionInfo(htd.getName(), HConstants.EMPTY_BYTE_ARRAY,
        HConstants.EMPTY_BYTE_ARRAY, false);
    Path path = new Path(DIR + "testStatusSettingToAbortIfAnyExceptionDuringRegionInitilization");
    // no where we are instantiating HStore in this test case so useTableNameGlobally is null. To
    // avoid NullPointerException we are setting useTableNameGlobally to false.
    SchemaMetrics.setUseTableNameInTest(false);
    region = HRegion.newHRegion(path, null, fs, conf, info, htd, null);
    // region initialization throws IOException and set task state to ABORTED.
    region.initialize();
    fail("Region initialization should fail due to IOException");
  } catch (IOException io) {
    List<MonitoredTask> tasks = TaskMonitor.get().getTasks();
    for (MonitoredTask monitoredTask : tasks) {
      if (!(monitoredTask instanceof MonitoredRPCHandler)
          && monitoredTask.getDescription().contains(region.toString())) {
        assertTrue("Region state should be ABORTED.",
            monitoredTask.getState().equals(MonitoredTask.State.ABORTED));
        break;
      }
    }
  } finally {
    HRegion.closeHRegion(region);
  }
}
项目:hbase    文件:RpcExecutor.java   
private void run(CallRunner cr) {
  MonitoredRPCHandler status = RpcServer.getStatus();
  cr.setStatus(status);
  try {
    this.activeHandlerCount.incrementAndGet();
    cr.run();
  } catch (Throwable e) {
    if (e instanceof Error) {
      int failedCount = failedHandlerCount.incrementAndGet();
      if (this.handlerFailureThreshhold >= 0
          && failedCount > handlerCount * this.handlerFailureThreshhold) {
        String message = "Number of failed RpcServer handler runs exceeded threshhold "
            + this.handlerFailureThreshhold + "; reason: " + StringUtils.stringifyException(e);
        if (abortable != null) {
          abortable.abort(message, e);
        } else {
          LOG.error("Error but can't abort because abortable is null: "
              + StringUtils.stringifyException(e));
          throw e;
        }
      } else {
        LOG.warn("Handler errors " + StringUtils.stringifyException(e));
      }
    } else {
      LOG.warn("Handler  exception " + StringUtils.stringifyException(e));
    }
  } finally {
    this.activeHandlerCount.decrementAndGet();
  }
}
项目:hbase    文件:RpcServer.java   
protected static MonitoredRPCHandler getStatus() {
  // It is ugly the way we park status up in RpcServer.  Let it be for now.  TODO.
  MonitoredRPCHandler status = RpcServer.MONITORED_RPC.get();
  if (status != null) {
    return status;
  }
  status = TaskMonitor.get().createRPCStatus(Thread.currentThread().getName());
  status.pause("Waiting for a call");
  RpcServer.MONITORED_RPC.set(status);
  return status;
}
项目:hbase    文件:NettyRpcServer.java   
@Override
public Pair<Message, CellScanner> call(BlockingService service,
    MethodDescriptor md, Message param, CellScanner cellScanner,
    long receiveTime, MonitoredRPCHandler status) throws IOException {
  return call(service, md, param, cellScanner, receiveTime, status,
      System.currentTimeMillis(), 0);
}
项目:hbase    文件:NettyRpcServer.java   
@Override
public Pair<Message, CellScanner> call(BlockingService service, MethodDescriptor md,
    Message param, CellScanner cellScanner, long receiveTime, MonitoredRPCHandler status,
    long startTime, int timeout) throws IOException {
  NettyServerCall fakeCall = new NettyServerCall(-1, service, md, null, param, cellScanner, null,
      -1, null, receiveTime, timeout, reservoir, cellBlockBuilder, null);
  return call(fakeCall, status);
}
项目:hbase    文件:SimpleRpcServer.java   
@Override
public Pair<Message, CellScanner> call(BlockingService service, MethodDescriptor md,
    Message param, CellScanner cellScanner, long receiveTime, MonitoredRPCHandler status)
    throws IOException {
  return call(service, md, param, cellScanner, receiveTime, status, System.currentTimeMillis(),
    0);
}
项目:hbase    文件:SimpleRpcServer.java   
@Override
public Pair<Message, CellScanner> call(BlockingService service, MethodDescriptor md,
    Message param, CellScanner cellScanner, long receiveTime, MonitoredRPCHandler status,
    long startTime, int timeout) throws IOException {
  SimpleServerCall fakeCall = new SimpleServerCall(-1, service, md, null, param, cellScanner,
      null, -1, null, receiveTime, timeout, reservoir, cellBlockBuilder, null, null);
  return call(fakeCall, status);
}
项目:hbase    文件:TestHRegion.java   
/**
 * Testcase to check state of region initialization task set to ABORTED or not
 * if any exceptions during initialization
 *
 * @throws Exception
 */
@Test
public void testStatusSettingToAbortIfAnyExceptionDuringRegionInitilization() throws Exception {
  HRegionInfo info;
  try {
    FileSystem fs = Mockito.mock(FileSystem.class);
    Mockito.when(fs.exists((Path) Mockito.anyObject())).thenThrow(new IOException());
    HTableDescriptor htd = new HTableDescriptor(tableName);
    htd.addFamily(new HColumnDescriptor("cf"));
    info = new HRegionInfo(htd.getTableName(), HConstants.EMPTY_BYTE_ARRAY,
        HConstants.EMPTY_BYTE_ARRAY, false);
    Path path = new Path(dir + "testStatusSettingToAbortIfAnyExceptionDuringRegionInitilization");
    region = HRegion.newHRegion(path, null, fs, CONF, info, htd, null);
    // region initialization throws IOException and set task state to ABORTED.
    region.initialize();
    fail("Region initialization should fail due to IOException");
  } catch (IOException io) {
    List<MonitoredTask> tasks = TaskMonitor.get().getTasks();
    for (MonitoredTask monitoredTask : tasks) {
      if (!(monitoredTask instanceof MonitoredRPCHandler)
          && monitoredTask.getDescription().contains(region.toString())) {
        assertTrue("Region state should be ABORTED.",
            monitoredTask.getState().equals(MonitoredTask.State.ABORTED));
        break;
      }
    }
  } finally {
    HBaseTestingUtility.closeRegionAndWAL(region);
  }
}
项目:PyroDB    文件:CallRunner.java   
MonitoredRPCHandler getStatus() {
  // It is ugly the way we park status up in RpcServer.  Let it be for now.  TODO.
  MonitoredRPCHandler status = RpcServer.MONITORED_RPC.get();
  if (status != null) {
    return status;
  }
  status = TaskMonitor.get().createRPCStatus(Thread.currentThread().getName());
  status.pause("Waiting for a call");
  RpcServer.MONITORED_RPC.set(status);
  return status;
}
项目:PyroDB    文件:TestHRegion.java   
/**
 * Testcase to check state of region initialization task set to ABORTED or not
 * if any exceptions during initialization
 * 
 * @throws Exception
 */
@Test
public void testStatusSettingToAbortIfAnyExceptionDuringRegionInitilization() throws Exception {
  TableName tableName = TableName.valueOf(name.getMethodName());
  HRegionInfo info = null;
  try {
    FileSystem fs = Mockito.mock(FileSystem.class);
    Mockito.when(fs.exists((Path) Mockito.anyObject())).thenThrow(new IOException());
    HTableDescriptor htd = new HTableDescriptor(tableName);
    htd.addFamily(new HColumnDescriptor("cf"));
    info = new HRegionInfo(htd.getTableName(), HConstants.EMPTY_BYTE_ARRAY,
        HConstants.EMPTY_BYTE_ARRAY, false);
    Path path = new Path(dir + "testStatusSettingToAbortIfAnyExceptionDuringRegionInitilization");
    region = HRegion.newHRegion(path, null, fs, CONF, info, htd, null);
    // region initialization throws IOException and set task state to ABORTED.
    region.initialize();
    fail("Region initialization should fail due to IOException");
  } catch (IOException io) {
    List<MonitoredTask> tasks = TaskMonitor.get().getTasks();
    for (MonitoredTask monitoredTask : tasks) {
      if (!(monitoredTask instanceof MonitoredRPCHandler)
          && monitoredTask.getDescription().contains(region.toString())) {
        assertTrue("Region state should be ABORTED.",
            monitoredTask.getState().equals(MonitoredTask.State.ABORTED));
        break;
      }
    }
  } finally {
    HRegion.closeHRegion(region);
  }
}
项目:c5    文件:CoprocessorHConnection.java   
public org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ClientService.BlockingInterface
    getClient(ServerName serverName) throws IOException {
  // client is trying to reach off-server, so we can't do anything special
  if (!this.serverName.equals(serverName)) {
    return delegate.getClient(serverName);
  }
  // the client is attempting to write to the same regionserver, we can short-circuit to our
  // local regionserver
  final BlockingService blocking = ClientService.newReflectiveBlockingService(this.server);
  final RpcServerInterface rpc = this.server.getRpcServer();

  final MonitoredRPCHandler status =
      TaskMonitor.get().createRPCStatus(Thread.currentThread().getName());
  status.pause("Setting up server-local call");

  final long timestamp = EnvironmentEdgeManager.currentTimeMillis();
  BlockingRpcChannel channel = new BlockingRpcChannel() {

    @Override
    public Message callBlockingMethod(MethodDescriptor method, RpcController controller,
        Message request, Message responsePrototype) throws ServiceException {
      try {
        // we never need a cell-scanner - everything is already fully formed
        return rpc.call(blocking, method, request, null, timestamp, status).getFirst();
      } catch (IOException e) {
        throw new ServiceException(e);
      }
    }
  };
  return ClientService.newBlockingStub(channel);
}
项目:c5    文件:TestHRegion.java   
/**
 * Testcase to check state of region initialization task set to ABORTED or not
 * if any exceptions during initialization
 * 
 * @throws Exception
 */
@Test
public void testStatusSettingToAbortIfAnyExceptionDuringRegionInitilization() throws Exception {
  TableName tableName = TableName.valueOf(name.getMethodName());
  HRegionInfo info = null;
  try {
    FileSystem fs = Mockito.mock(FileSystem.class);
    Mockito.when(fs.exists((Path) Mockito.anyObject())).thenThrow(new IOException());
    HTableDescriptor htd = new HTableDescriptor(tableName);
    htd.addFamily(new HColumnDescriptor("cf"));
    info = new HRegionInfo(htd.getTableName(), HConstants.EMPTY_BYTE_ARRAY,
        HConstants.EMPTY_BYTE_ARRAY, false);
    Path path = new Path(DIR + "testStatusSettingToAbortIfAnyExceptionDuringRegionInitilization");
    region = HRegion.newHRegion(path, null, fs, conf, info, htd, null);
    // region initialization throws IOException and set task state to ABORTED.
    region.initialize();
    fail("Region initialization should fail due to IOException");
  } catch (IOException io) {
    List<MonitoredTask> tasks = TaskMonitor.get().getTasks();
    for (MonitoredTask monitoredTask : tasks) {
      if (!(monitoredTask instanceof MonitoredRPCHandler)
          && monitoredTask.getDescription().contains(region.toString())) {
        assertTrue("Region state should be ABORTED.",
            monitoredTask.getState().equals(MonitoredTask.State.ABORTED));
        break;
      }
    }
  } finally {
    HRegion.closeHRegion(region);
  }
}
项目:HBase-Research    文件:TestHRegion.java   
/**
 * Testcase to check state of region initialization task set to ABORTED or not if any exceptions
 * during initialization
 * 
 * @throws Exception
 */
@Test
public void testStatusSettingToAbortIfAnyExceptionDuringRegionInitilization() throws Exception {
  HRegionInfo info = null;
  try {
    FileSystem fs = Mockito.mock(FileSystem.class);
    Mockito.when(fs.exists((Path) Mockito.anyObject())).thenThrow(new IOException());
    HTableDescriptor htd = new HTableDescriptor(tableName);
    htd.addFamily(new HColumnDescriptor("cf"));
    info = new HRegionInfo(htd.getName(), HConstants.EMPTY_BYTE_ARRAY,
        HConstants.EMPTY_BYTE_ARRAY, false);
    Path path = new Path(DIR + "testStatusSettingToAbortIfAnyExceptionDuringRegionInitilization");
    // no where we are instantiating HStore in this test case so useTableNameGlobally is null. To
    // avoid NullPointerException we are setting useTableNameGlobally to false.
    SchemaMetrics.setUseTableNameInTest(false);
    region = HRegion.newHRegion(path, null, fs, conf, info, htd, null);
    // region initialization throws IOException and set task state to ABORTED.
    region.initialize();
    fail("Region initialization should fail due to IOException");
  } catch (IOException io) {
    List<MonitoredTask> tasks = TaskMonitor.get().getTasks();
    for (MonitoredTask monitoredTask : tasks) {
      if (!(monitoredTask instanceof MonitoredRPCHandler)
          && monitoredTask.getDescription().contains(region.toString())) {
        assertTrue("Region state should be ABORTED.",
            monitoredTask.getState().equals(MonitoredTask.State.ABORTED));
        break;
      }
    }
  } finally {
    HRegion.closeHRegion(region);
  }
}
项目:hbase-0.94.8-qod    文件:TestHRegion.java   
/**
 * Testcase to check state of region initialization task set to ABORTED or not if any exceptions
 * during initialization
 * 
 * @throws Exception
 */
@Test
public void testStatusSettingToAbortIfAnyExceptionDuringRegionInitilization() throws Exception {
  HRegionInfo info = null;
  try {
    FileSystem fs = Mockito.mock(FileSystem.class);
    Mockito.when(fs.exists((Path) Mockito.anyObject())).thenThrow(new IOException());
    HTableDescriptor htd = new HTableDescriptor(tableName);
    htd.addFamily(new HColumnDescriptor("cf"));
    info = new HRegionInfo(htd.getName(), HConstants.EMPTY_BYTE_ARRAY,
        HConstants.EMPTY_BYTE_ARRAY, false);
    Path path = new Path(DIR + "testStatusSettingToAbortIfAnyExceptionDuringRegionInitilization");
    // no where we are instantiating HStore in this test case so useTableNameGlobally is null. To
    // avoid NullPointerException we are setting useTableNameGlobally to false.
    SchemaMetrics.setUseTableNameInTest(false);
    region = HRegion.newHRegion(path, null, fs, conf, info, htd, null);
    // region initialization throws IOException and set task state to ABORTED.
    region.initialize();
    fail("Region initialization should fail due to IOException");
  } catch (IOException io) {
    List<MonitoredTask> tasks = TaskMonitor.get().getTasks();
    for (MonitoredTask monitoredTask : tasks) {
      if (!(monitoredTask instanceof MonitoredRPCHandler)
          && monitoredTask.getDescription().contains(region.toString())) {
        assertTrue("Region state should be ABORTED.",
            monitoredTask.getState().equals(MonitoredTask.State.ABORTED));
        break;
      }
    }
  } finally {
    HRegion.closeHRegion(region);
  }
}
项目:hbase-0.94.8-qod    文件:TestHRegion.java   
/**
 * Testcase to check state of region initialization task set to ABORTED or not if any exceptions
 * during initialization
 * 
 * @throws Exception
 */
@Test
public void testStatusSettingToAbortIfAnyExceptionDuringRegionInitilization() throws Exception {
  HRegionInfo info = null;
  try {
    FileSystem fs = Mockito.mock(FileSystem.class);
    Mockito.when(fs.exists((Path) Mockito.anyObject())).thenThrow(new IOException());
    HTableDescriptor htd = new HTableDescriptor(tableName);
    htd.addFamily(new HColumnDescriptor("cf"));
    info = new HRegionInfo(htd.getName(), HConstants.EMPTY_BYTE_ARRAY,
        HConstants.EMPTY_BYTE_ARRAY, false);
    Path path = new Path(DIR + "testStatusSettingToAbortIfAnyExceptionDuringRegionInitilization");
    // no where we are instantiating HStore in this test case so useTableNameGlobally is null. To
    // avoid NullPointerException we are setting useTableNameGlobally to false.
    SchemaMetrics.setUseTableNameInTest(false);
    region = HRegion.newHRegion(path, null, fs, conf, info, htd, null);
    // region initialization throws IOException and set task state to ABORTED.
    region.initialize();
    fail("Region initialization should fail due to IOException");
  } catch (IOException io) {
    List<MonitoredTask> tasks = TaskMonitor.get().getTasks();
    for (MonitoredTask monitoredTask : tasks) {
      if (!(monitoredTask instanceof MonitoredRPCHandler)
          && monitoredTask.getDescription().contains(region.toString())) {
        assertTrue("Region state should be ABORTED.",
            monitoredTask.getState().equals(MonitoredTask.State.ABORTED));
        break;
      }
    }
  } finally {
    HRegion.closeHRegion(region);
  }
}
项目:DominoHBase    文件:TestHRegion.java   
/**
 * Testcase to check state of region initialization task set to ABORTED or not if any exceptions
 * during initialization
 * 
 * @throws Exception
 */
@Test
public void testStatusSettingToAbortIfAnyExceptionDuringRegionInitilization() throws Exception {
  HRegionInfo info = null;
  try {
    FileSystem fs = Mockito.mock(FileSystem.class);
    Mockito.when(fs.exists((Path) Mockito.anyObject())).thenThrow(new IOException());
    HTableDescriptor htd = new HTableDescriptor(tableName);
    htd.addFamily(new HColumnDescriptor("cf"));
    info = new HRegionInfo(htd.getName(), HConstants.EMPTY_BYTE_ARRAY,
        HConstants.EMPTY_BYTE_ARRAY, false);
    Path path = new Path(DIR + "testStatusSettingToAbortIfAnyExceptionDuringRegionInitilization");
    region = HRegion.newHRegion(path, null, fs, conf, info, htd, null);
    // region initialization throws IOException and set task state to ABORTED.
    region.initialize();
    fail("Region initialization should fail due to IOException");
  } catch (IOException io) {
    List<MonitoredTask> tasks = TaskMonitor.get().getTasks();
    for (MonitoredTask monitoredTask : tasks) {
      if (!(monitoredTask instanceof MonitoredRPCHandler)
          && monitoredTask.getDescription().contains(region.toString())) {
        assertTrue("Region state should be ABORTED.",
            monitoredTask.getState().equals(MonitoredTask.State.ABORTED));
        break;
      }
    }
  } finally {
    HRegion.closeHRegion(region);
  }
}
项目:hindex    文件:TestHRegion.java   
/**
 * Testcase to check state of region initialization task set to ABORTED or not if any exceptions
 * during initialization
 * 
 * @throws Exception
 */
@Test
public void testStatusSettingToAbortIfAnyExceptionDuringRegionInitilization() throws Exception {
  HRegionInfo info = null;
  try {
    FileSystem fs = Mockito.mock(FileSystem.class);
    Mockito.when(fs.exists((Path) Mockito.anyObject())).thenThrow(new IOException());
    HTableDescriptor htd = new HTableDescriptor(tableName);
    htd.addFamily(new HColumnDescriptor("cf"));
    info = new HRegionInfo(htd.getName(), HConstants.EMPTY_BYTE_ARRAY,
        HConstants.EMPTY_BYTE_ARRAY, false);
    Path path = new Path(DIR + "testStatusSettingToAbortIfAnyExceptionDuringRegionInitilization");
    // no where we are instantiating HStore in this test case so useTableNameGlobally is null. To
    // avoid NullPointerException we are setting useTableNameGlobally to false.
    SchemaMetrics.setUseTableNameInTest(false);
    region = HRegion.newHRegion(path, null, fs, conf, info, htd, null);
    // region initialization throws IOException and set task state to ABORTED.
    region.initialize();
    fail("Region initialization should fail due to IOException");
  } catch (IOException io) {
    List<MonitoredTask> tasks = TaskMonitor.get().getTasks();
    for (MonitoredTask monitoredTask : tasks) {
      if (!(monitoredTask instanceof MonitoredRPCHandler)
          && monitoredTask.getDescription().contains(region.toString())) {
        assertTrue("Region state should be ABORTED.",
            monitoredTask.getState().equals(MonitoredTask.State.ABORTED));
        break;
      }
    }
  } finally {
    HRegion.closeHRegion(region);
  }
}
项目:ditb    文件:RpcServerInterface.java   
Pair<Message, CellScanner> call(BlockingService service, MethodDescriptor md,
  Message param, CellScanner cellScanner, long receiveTime, MonitoredRPCHandler status)
throws IOException, ServiceException;
项目:ditb    文件:RpcServer.java   
/**
 * This is a server side method, which is invoked over RPC. On success
 * the return response has protobuf response payload. On failure, the
 * exception name and the stack trace are returned in the protobuf response.
 */
@Override
public Pair<Message, CellScanner> call(BlockingService service, MethodDescriptor md,
    Message param, CellScanner cellScanner, long receiveTime, MonitoredRPCHandler status)
throws IOException {
  try {
    status.setRPC(md.getName(), new Object[]{param}, receiveTime);
    // TODO: Review after we add in encoded data blocks.
    status.setRPCPacket(param);
    status.resume("Servicing call");
    //get an instance of the method arg type
    long startTime = System.currentTimeMillis();
    PayloadCarryingRpcController controller = new PayloadCarryingRpcController(cellScanner);
    Message result = service.callBlockingMethod(md, controller, param);
    long endTime = System.currentTimeMillis();
    int processingTime = (int) (endTime - startTime);
    int qTime = (int) (startTime - receiveTime);
    int totalTime = (int) (endTime - receiveTime);
    if (LOG.isTraceEnabled()) {
      LOG.trace(CurCall.get().toString() +
          ", response " + TextFormat.shortDebugString(result) +
          " queueTime: " + qTime +
          " processingTime: " + processingTime +
          " totalTime: " + totalTime);
    }
    long requestSize = param.getSerializedSize();
    long responseSize = result.getSerializedSize();
    metrics.dequeuedCall(qTime);
    metrics.processedCall(processingTime);
    metrics.totalCall(totalTime);
    metrics.receivedRequest(requestSize);
    metrics.sentResponse(responseSize);
    // log any RPC responses that are slower than the configured warn
    // response time or larger than configured warning size
    boolean tooSlow = (processingTime > warnResponseTime && warnResponseTime > -1);
    boolean tooLarge = (responseSize > warnResponseSize && warnResponseSize > -1);
    if (tooSlow || tooLarge) {
      // when tagging, we let TooLarge trump TooSmall to keep output simple
      // note that large responses will often also be slow.
      logResponse(new Object[]{param},
          md.getName(), md.getName() + "(" + param.getClass().getName() + ")",
          (tooLarge ? "TooLarge" : "TooSlow"),
          status.getClient(), startTime, processingTime, qTime,
          responseSize);
    }
    return new Pair<Message, CellScanner>(result, controller.cellScanner());
  } catch (Throwable e) {
    // The above callBlockingMethod will always return a SE.  Strip the SE wrapper before
    // putting it on the wire.  Its needed to adhere to the pb Service Interface but we don't
    // need to pass it over the wire.
    if (e instanceof ServiceException) e = e.getCause();

    // increment the number of requests that were exceptions.
    metrics.exception(e);

    if (e instanceof LinkageError) throw new DoNotRetryIOException(e);
    if (e instanceof IOException) throw (IOException)e;
    LOG.error("Unexpected throwable object ", e);
    throw new IOException(e.getMessage(), e);
  }
}
项目:ditb    文件:CallRunner.java   
public void setStatus(MonitoredRPCHandler status) {
  this.status = status;
}
项目:ditb    文件:TestRpcHandlerException.java   
@Override
public Pair<Message, CellScanner> call(BlockingService service, MethodDescriptor md,
  Message param, CellScanner cellScanner, long receiveTime, MonitoredRPCHandler status)
      throws IOException {
  return super.call(service, md, param, cellScanner, receiveTime, status);
}
项目:ditb    文件:AbstractTestIPC.java   
@Override
public Pair<Message, CellScanner> call(BlockingService service, MethodDescriptor md,
    Message param, CellScanner cellScanner, long receiveTime, MonitoredRPCHandler status)
    throws IOException {
  return super.call(service, md, param, cellScanner, receiveTime, status);
}
项目:ditb    文件:IntegrationTestRpcClient.java   
@Override
public Pair<Message, CellScanner> call(BlockingService service, MethodDescriptor md,
    Message param, CellScanner cellScanner, long receiveTime, MonitoredRPCHandler status)
    throws IOException {
  return super.call(service, md, param, cellScanner, receiveTime, status);
}
项目:pbase    文件:RpcServerInterface.java   
Pair<Message, CellScanner> call(BlockingService service, MethodDescriptor md,
  Message param, CellScanner cellScanner, long receiveTime, MonitoredRPCHandler status)
throws IOException, ServiceException;
项目:pbase    文件:RpcServer.java   
/**
 * This is a server side method, which is invoked over RPC. On success
 * the return response has protobuf response payload. On failure, the
 * exception name and the stack trace are returned in the protobuf response.
 */
@Override
public Pair<Message, CellScanner> call(BlockingService service, MethodDescriptor md,
    Message param, CellScanner cellScanner, long receiveTime, MonitoredRPCHandler status)
throws IOException {
  try {
    status.setRPC(md.getName(), new Object[]{param}, receiveTime);
    // TODO: Review after we add in encoded data blocks.
    status.setRPCPacket(param);
    status.resume("Servicing call");
    //get an instance of the method arg type
    long startTime = System.currentTimeMillis();
    PayloadCarryingRpcController controller = new PayloadCarryingRpcController(cellScanner);
    Message result = service.callBlockingMethod(md, controller, param);
    int processingTime = (int) (System.currentTimeMillis() - startTime);
    int qTime = (int) (startTime - receiveTime);
    if (LOG.isTraceEnabled()) {
      LOG.trace(CurCall.get().toString() +
          ", response " + TextFormat.shortDebugString(result) +
          " queueTime: " + qTime +
          " processingTime: " + processingTime);
    }
    metrics.dequeuedCall(qTime);
    metrics.processedCall(processingTime);
    long responseSize = result.getSerializedSize();
    // log any RPC responses that are slower than the configured warn
    // response time or larger than configured warning size
    boolean tooSlow = (processingTime > warnResponseTime && warnResponseTime > -1);
    boolean tooLarge = (responseSize > warnResponseSize && warnResponseSize > -1);
    if (tooSlow || tooLarge) {
      // when tagging, we let TooLarge trump TooSmall to keep output simple
      // note that large responses will often also be slow.
      logResponse(new Object[]{param},
          md.getName(), md.getName() + "(" + param.getClass().getName() + ")",
          (tooLarge ? "TooLarge" : "TooSlow"),
          status.getClient(), startTime, processingTime, qTime,
          responseSize);
    }
    return new Pair<Message, CellScanner>(result, controller.cellScanner());
  } catch (Throwable e) {
    // The above callBlockingMethod will always return a SE.  Strip the SE wrapper before
    // putting it on the wire.  Its needed to adhere to the pb Service Interface but we don't
    // need to pass it over the wire.
    if (e instanceof ServiceException) e = e.getCause();
    if (e instanceof LinkageError) throw new DoNotRetryIOException(e);
    if (e instanceof IOException) throw (IOException)e;
    LOG.error("Unexpected throwable object ", e);
    throw new IOException(e.getMessage(), e);
  }
}
项目:pbase    文件:TestRpcHandlerException.java   
@Override
public Pair<Message, CellScanner> call(BlockingService service, MethodDescriptor md,
  Message param, CellScanner cellScanner, long receiveTime, MonitoredRPCHandler status)
      throws IOException {
  return super.call(service, md, param, cellScanner, receiveTime, status);
}
项目:pbase    文件:TestIPC.java   
@Override
public Pair<Message, CellScanner> call(BlockingService service,
    MethodDescriptor md, Message param, CellScanner cellScanner,
    long receiveTime, MonitoredRPCHandler status) throws IOException {
  return super.call(service, md, param, cellScanner, receiveTime, status);
}
项目:HIndex    文件:RpcServerInterface.java   
Pair<Message, CellScanner> call(BlockingService service, MethodDescriptor md,
  Message param, CellScanner cellScanner, long receiveTime, MonitoredRPCHandler status)
throws IOException, ServiceException;
项目:HIndex    文件:RpcServer.java   
/**
 * This is a server side method, which is invoked over RPC. On success
 * the return response has protobuf response payload. On failure, the
 * exception name and the stack trace are returned in the protobuf response.
 */
public Pair<Message, CellScanner> call(BlockingService service, MethodDescriptor md,
    Message param, CellScanner cellScanner, long receiveTime, MonitoredRPCHandler status)
throws IOException {
  try {
    status.setRPC(md.getName(), new Object[]{param}, receiveTime);
    // TODO: Review after we add in encoded data blocks.
    status.setRPCPacket(param);
    status.resume("Servicing call");
    //get an instance of the method arg type
    long startTime = System.currentTimeMillis();
    PayloadCarryingRpcController controller = new PayloadCarryingRpcController(cellScanner);
    Message result = service.callBlockingMethod(md, controller, param);
    int processingTime = (int) (System.currentTimeMillis() - startTime);
    int qTime = (int) (startTime - receiveTime);
    if (LOG.isTraceEnabled()) {
      LOG.trace(CurCall.get().toString() +
          ", response " + TextFormat.shortDebugString(result) +
          " queueTime: " + qTime +
          " processingTime: " + processingTime);
    }
    metrics.dequeuedCall(qTime);
    metrics.processedCall(processingTime);
    long responseSize = result.getSerializedSize();
    // log any RPC responses that are slower than the configured warn
    // response time or larger than configured warning size
    boolean tooSlow = (processingTime > warnResponseTime && warnResponseTime > -1);
    boolean tooLarge = (responseSize > warnResponseSize && warnResponseSize > -1);
    if (tooSlow || tooLarge) {
      // when tagging, we let TooLarge trump TooSmall to keep output simple
      // note that large responses will often also be slow.
      StringBuilder buffer = new StringBuilder(256);
      buffer.append(md.getName());
      buffer.append("(");
      buffer.append(param.getClass().getName());
      buffer.append(")");
      logResponse(new Object[]{param},
          md.getName(), buffer.toString(), (tooLarge ? "TooLarge" : "TooSlow"),
          status.getClient(), startTime, processingTime, qTime,
          responseSize);
    }
    return new Pair<Message, CellScanner>(result,
      controller != null? controller.cellScanner(): null);
  } catch (Throwable e) {
    // The above callBlockingMethod will always return a SE.  Strip the SE wrapper before
    // putting it on the wire.  Its needed to adhere to the pb Service Interface but we don't
    // need to pass it over the wire.
    if (e instanceof ServiceException) e = e.getCause();
    if (e instanceof LinkageError) throw new DoNotRetryIOException(e);
    if (e instanceof IOException) throw (IOException)e;
    LOG.error("Unexpected throwable object ", e);
    throw new IOException(e.getMessage(), e);
  }
}
项目:HIndex    文件:TestIPC.java   
@Override
public Pair<Message, CellScanner> call(BlockingService service,
    MethodDescriptor md, Message param, CellScanner cellScanner,
    long receiveTime, MonitoredRPCHandler status) throws IOException {
  return super.call(service, md, param, cellScanner, receiveTime, status);
}
项目:hbase    文件:RpcServerInterface.java   
/**
 * @deprecated As of release 1.3, this will be removed in HBase 3.0
 */
@Deprecated
Pair<Message, CellScanner> call(BlockingService service, MethodDescriptor md,
  Message param, CellScanner cellScanner, long receiveTime, MonitoredRPCHandler status)
throws IOException;
项目:hbase    文件:RpcServerInterface.java   
/**
 * @deprecated As of release 2.0, this will be removed in HBase 3.0
 */
@Deprecated
Pair<Message, CellScanner> call(BlockingService service, MethodDescriptor md, Message param,
    CellScanner cellScanner, long receiveTime, MonitoredRPCHandler status, long startTime,
    int timeout) throws IOException;
项目:hbase    文件:CallRunner.java   
public void setStatus(MonitoredRPCHandler status) {
  this.status = status;
}