Ejemplo n.º 1
0
  private void init() {
    String className = getClass().getSimpleName();
    currentQueryPath = new Path(queryBasePath, className);
    currentResultPath = new Path(resultBasePath, className);
    currentDatasetPath = new Path(datasetBasePath, className);

    try {
      // if the current database is "default", we don't need create it because it is already
      // prepated at startup time.
      if (!currentDatabase.equals(TajoConstants.DEFAULT_DATABASE_NAME)) {
        client.updateQuery("CREATE DATABASE IF NOT EXISTS " + currentDatabase);
      }
      client.selectDatabase(currentDatabase);
    } catch (ServiceException e) {
      e.printStackTrace();
    }
  }
Ejemplo n.º 2
0
  private Response forwardToBlockingService(Request rpcRequest, BlockingService blockingService)
      throws RpcException {
    // Get matching method
    MethodDescriptor method = getMethod(rpcRequest, blockingService.getDescriptorForType());

    // Create request for method
    Message request = getRequestProto(rpcRequest, blockingService.getRequestPrototype(method));

    // Call method
    SocketRpcController socketController = new SocketRpcController();
    try {
      Message response = blockingService.callBlockingMethod(method, socketController, request);
      return createRpcResponse(response, true, socketController);
    } catch (ServiceException e) {
      throw new RpcException(ErrorReason.RPC_FAILED, e.getMessage(), e);
    } catch (RuntimeException e) {
      throw new RpcException(
          ErrorReason.RPC_ERROR, "Error running method " + method.getFullName(), e);
    }
  }
Ejemplo n.º 3
0
  /**
   * Tests an on-the-fly RPC that was scheduled for the earlier RS on the same port for openRegion.
   * The region server should reject this RPC. (HBASE-9721)
   */
  @Test
  public void testOpenCloseRegionRPCIntendedForPreviousServer() throws Exception {
    Assert.assertTrue(getRS().getRegion(regionName).isAvailable());

    ServerName sn = getRS().getServerName();
    ServerName earlierServerName = ServerName.valueOf(sn.getHostname(), sn.getPort(), 1);

    try {
      CloseRegionRequest request =
          RequestConverter.buildCloseRegionRequest(earlierServerName, regionName);
      getRS().getRSRpcServices().closeRegion(null, request);
      Assert.fail("The closeRegion should have been rejected");
    } catch (ServiceException se) {
      Assert.assertTrue(se.getCause() instanceof IOException);
      Assert.assertTrue(
          se.getCause().getMessage().contains("This RPC was intended for a different server"));
    }

    // actual close
    closeRegionNoZK();
    try {
      AdminProtos.OpenRegionRequest orr =
          RequestConverter.buildOpenRegionRequest(earlierServerName, hri, null, null);
      getRS().getRSRpcServices().openRegion(null, orr);
      Assert.fail("The openRegion should have been rejected");
    } catch (ServiceException se) {
      Assert.assertTrue(se.getCause() instanceof IOException);
      Assert.assertTrue(
          se.getCause().getMessage().contains("This RPC was intended for a different server"));
    } finally {
      openRegion(HTU, getRS(), hri);
    }
  }