Java 类org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.VisibilityLabelsResponse 实例源码

项目:ditb    文件:TestVisibilityLabelsWithDeletes.java   
private void setAuths() throws IOException, InterruptedException {
  PrivilegedExceptionAction<VisibilityLabelsResponse> action =
      new PrivilegedExceptionAction<VisibilityLabelsResponse>() {
    @Override
    public VisibilityLabelsResponse run() throws Exception {
      try (Connection conn = ConnectionFactory.createConnection(conf)) {
        return VisibilityClient.setAuths(conn, new String[] { CONFIDENTIAL,
          PRIVATE, SECRET,
            TOPSECRET }, SUPERUSER.getShortName());
      } catch (Throwable e) {
      }
      return null;
    }
  };
  SUPERUSER.runAs(action);
}
项目:ditb    文件:TestVisibilityLabelsWithDeletes.java   
public static void addLabels() throws Exception {
  PrivilegedExceptionAction<VisibilityLabelsResponse> action =
      new PrivilegedExceptionAction<VisibilityLabelsResponse>() {
    @Override
    public VisibilityLabelsResponse run() throws Exception {
      String[] labels = { SECRET, TOPSECRET, CONFIDENTIAL, PUBLIC, PRIVATE };
      try (Connection conn = ConnectionFactory.createConnection(conf)) {
        VisibilityClient.addLabels(conn, labels);
      } catch (Throwable t) {
        throw new IOException(t);
      }
      return null;
    }
  };
  SUPERUSER.runAs(action);
}
项目:ditb    文件:TestVisibilityLabels.java   
public static void addLabels() throws Exception {
  PrivilegedExceptionAction<VisibilityLabelsResponse> action =
      new PrivilegedExceptionAction<VisibilityLabelsResponse>() {
    public VisibilityLabelsResponse run() throws Exception {
      String[] labels = { SECRET, TOPSECRET, CONFIDENTIAL, PUBLIC, PRIVATE, COPYRIGHT, ACCENT,
          UNICODE_VIS_TAG, UC1, UC2 };
      try (Connection conn = ConnectionFactory.createConnection(conf)) {
        VisibilityClient.addLabels(conn, labels);
      } catch (Throwable t) {
        throw new IOException(t);
      }
      return null;
    }
  };
  SUPERUSER.runAs(action);
}
项目:ditb    文件:TestVisibilityWithCheckAuths.java   
public static void addLabels() throws Exception {
  PrivilegedExceptionAction<VisibilityLabelsResponse> action =
      new PrivilegedExceptionAction<VisibilityLabelsResponse>() {
    @Override
    public VisibilityLabelsResponse run() throws Exception {
      String[] labels = { TOPSECRET };
      try (Connection conn = ConnectionFactory.createConnection(conf)) {
        VisibilityClient.addLabels(conn, labels);
      } catch (Throwable t) {
        throw new IOException(t);
      }
      return null;
    }
  };
  SUPERUSER.runAs(action);
}
项目:ditb    文件:TestImportTSVWithVisibilityLabels.java   
private static void createLabels() throws IOException, InterruptedException {
  PrivilegedExceptionAction<VisibilityLabelsResponse> action =
      new PrivilegedExceptionAction<VisibilityLabelsResponse>() {
    @Override
    public VisibilityLabelsResponse run() throws Exception {
      String[] labels = { SECRET, TOPSECRET, CONFIDENTIAL, PUBLIC, PRIVATE };
      try (Connection conn = ConnectionFactory.createConnection(conf)) {
        VisibilityClient.addLabels(conn, labels);
        LOG.info("Added labels ");
      } catch (Throwable t) {
        LOG.error("Error in adding labels" , t);
        throw new IOException(t);
      }
      return null;
    }
  };
  SUPERUSER.runAs(action);
}
项目:pbase    文件:TestVisibilityLabelsWithDeletes.java   
public static void addLabels() throws Exception {
  PrivilegedExceptionAction<VisibilityLabelsResponse> action =
      new PrivilegedExceptionAction<VisibilityLabelsResponse>() {
    @Override
    public VisibilityLabelsResponse run() throws Exception {
      String[] labels = { SECRET, TOPSECRET, CONFIDENTIAL, PUBLIC, PRIVATE };
      try {
        VisibilityClient.addLabels(conf, labels);
      } catch (Throwable t) {
        throw new IOException(t);
      }
      return null;
    }
  };
  SUPERUSER.runAs(action);
}
项目:pbase    文件:TestVisibilityLabels.java   
public static void addLabels() throws Exception {
  PrivilegedExceptionAction<VisibilityLabelsResponse> action =
      new PrivilegedExceptionAction<VisibilityLabelsResponse>() {
    public VisibilityLabelsResponse run() throws Exception {
      String[] labels = { SECRET, TOPSECRET, CONFIDENTIAL, PUBLIC, PRIVATE, COPYRIGHT, ACCENT,
          UNICODE_VIS_TAG, UC1, UC2 };
      try {
        VisibilityClient.addLabels(conf, labels);
      } catch (Throwable t) {
        throw new IOException(t);
      }
      return null;
    }
  };
  SUPERUSER.runAs(action);
}
项目:pbase    文件:TestVisibilityWithCheckAuths.java   
public static void addLabels() throws Exception {
  PrivilegedExceptionAction<VisibilityLabelsResponse> action =
      new PrivilegedExceptionAction<VisibilityLabelsResponse>() {
    @Override
    public VisibilityLabelsResponse run() throws Exception {
      String[] labels = { TOPSECRET };
      try {
        VisibilityClient.addLabels(conf, labels);
      } catch (Throwable t) {
        throw new IOException(t);
      }
      return null;
    }
  };
  SUPERUSER.runAs(action);
}
项目:pbase    文件:TestImportTSVWithVisibilityLabels.java   
private static void createLabels() throws IOException, InterruptedException {
  PrivilegedExceptionAction<VisibilityLabelsResponse> action =
      new PrivilegedExceptionAction<VisibilityLabelsResponse>() {
    @Override
    public VisibilityLabelsResponse run() throws Exception {
      String[] labels = { SECRET, TOPSECRET, CONFIDENTIAL, PUBLIC, PRIVATE };
      try {
        VisibilityClient.addLabels(conf, labels);
        LOG.info("Added labels ");
      } catch (Throwable t) {
        LOG.error("Error in adding labels" , t);
        throw new IOException(t);
      }
      return null;
    }
  };
  SUPERUSER.runAs(action);
}
项目:HIndex    文件:TestVisibilityLabels.java   
@Test
public void testAddLabels() throws Throwable {
  PrivilegedExceptionAction<VisibilityLabelsResponse> action = 
      new PrivilegedExceptionAction<VisibilityLabelsResponse>() {
    public VisibilityLabelsResponse run() throws Exception {
      String[] labels = { "L1", SECRET, "L2", "invalid~", "L3" };
      VisibilityLabelsResponse response = null;
      try {
        response = VisibilityClient.addLabels(conf, labels);
      } catch (Throwable e) {
        fail("Should not have thrown exception");
      }
      List<RegionActionResult> resultList = response.getResultList();
      assertEquals(5, resultList.size());
      assertTrue(resultList.get(0).getException().getValue().isEmpty());
      assertEquals("org.apache.hadoop.hbase.security.visibility.LabelAlreadyExistsException",
          resultList.get(1).getException().getName());
      assertTrue(resultList.get(2).getException().getValue().isEmpty());
      assertEquals("org.apache.hadoop.hbase.security.visibility.InvalidLabelException",
          resultList.get(3).getException().getName());
      assertTrue(resultList.get(4).getException().getValue().isEmpty());
      return null;
    }
  };
  SUPERUSER.runAs(action);
}
项目:HIndex    文件:TestImportTSVWithVisibilityLabels.java   
private static void createLabels() throws IOException, InterruptedException {
  PrivilegedExceptionAction<VisibilityLabelsResponse> action =
      new PrivilegedExceptionAction<VisibilityLabelsResponse>() {
    @Override
    public VisibilityLabelsResponse run() throws Exception {
      String[] labels = { SECRET, TOPSECRET, CONFIDENTIAL, PUBLIC, PRIVATE };
      try {
        VisibilityClient.addLabels(conf, labels);
        LOG.info("Added labels ");
      } catch (Throwable t) {
        LOG.error("Error in adding labels" , t);
        throw new IOException(t);
      }
      return null;
    }
  };
  SUPERUSER.runAs(action);
}
项目:hbase    文件:TestThriftHBaseServiceHandlerWithLabels.java   
private static void createLabels() throws IOException, InterruptedException {
  PrivilegedExceptionAction<VisibilityLabelsResponse> action =
      new PrivilegedExceptionAction<VisibilityLabelsResponse>() {
    @Override
    public VisibilityLabelsResponse run() throws Exception {
      String[] labels = { SECRET, CONFIDENTIAL, PRIVATE, PUBLIC, TOPSECRET };
      try (Connection conn = ConnectionFactory.createConnection(conf)) {
        VisibilityClient.addLabels(conn, labels);
      } catch (Throwable t) {
        throw new IOException(t);
      }
      return null;
    }
  };
  SUPERUSER.runAs(action);
}
项目:hbase    文件:TestVisibilityLabelsReplication.java   
public static void addLabels() throws Exception {
  PrivilegedExceptionAction<VisibilityLabelsResponse> action =
      new PrivilegedExceptionAction<VisibilityLabelsResponse>() {
    @Override
    public VisibilityLabelsResponse run() throws Exception {
      String[] labels = { SECRET, TOPSECRET, CONFIDENTIAL, PUBLIC, PRIVATE, UNICODE_VIS_TAG };
      try (Connection conn = ConnectionFactory.createConnection(conf)) {
        VisibilityClient.addLabels(conn, labels);
      } catch (Throwable t) {
        throw new IOException(t);
      }
      return null;
    }
  };
  SUPERUSER.runAs(action);
}
项目:hbase    文件:TestVisibilityLabels.java   
public static void addLabels() throws Exception {
  PrivilegedExceptionAction<VisibilityLabelsResponse> action =
      new PrivilegedExceptionAction<VisibilityLabelsResponse>() {
    @Override
    public VisibilityLabelsResponse run() throws Exception {
      String[] labels = { SECRET, TOPSECRET, CONFIDENTIAL, PUBLIC, PRIVATE, COPYRIGHT, ACCENT,
          UNICODE_VIS_TAG, UC1, UC2 };
      try (Connection conn = ConnectionFactory.createConnection(conf)) {
        VisibilityClient.addLabels(conn, labels);
      } catch (Throwable t) {
        throw new IOException(t);
      }
      return null;
    }
  };
  SUPERUSER.runAs(action);
}
项目:hbase    文件:VisibilityLabelsWithDeletesTestBase.java   
public static void addLabels() throws Exception {
  PrivilegedExceptionAction<VisibilityLabelsResponse> action =
    new PrivilegedExceptionAction<VisibilityLabelsResponse>() {
      @Override
      public VisibilityLabelsResponse run() throws Exception {
        String[] labels = { SECRET, TOPSECRET, CONFIDENTIAL, PUBLIC, PRIVATE };
        try (Connection conn = ConnectionFactory.createConnection(conf)) {
          VisibilityClient.addLabels(conn, labels);
        } catch (Throwable t) {
          throw new IOException(t);
        }
        return null;
      }
    };
  SUPERUSER.runAs(action);
}
项目:hbase    文件:TestVisibilityLabelsOpWithDifferentUsersNoACL.java   
private static void addLabels() throws Exception {
  PrivilegedExceptionAction<VisibilityLabelsResponse> action =
      new PrivilegedExceptionAction<VisibilityLabelsResponse>() {
    @Override
    public VisibilityLabelsResponse run() throws Exception {
      String[] labels = { SECRET, CONFIDENTIAL, PRIVATE };
      try (Connection conn = ConnectionFactory.createConnection(conf)) {
        VisibilityClient.addLabels(conn, labels);
      } catch (Throwable t) {
        throw new IOException(t);
      }
      return null;
    }
  };
  SUPERUSER.runAs(action);
}
项目:hbase    文件:TestVisibilityLabelsWithSLGStack.java   
private static void addLabels() throws Exception {
  PrivilegedExceptionAction<VisibilityLabelsResponse> action =
      new PrivilegedExceptionAction<VisibilityLabelsResponse>() {
    @Override
    public VisibilityLabelsResponse run() throws Exception {
      String[] labels = { SECRET, CONFIDENTIAL };
      try (Connection conn = ConnectionFactory.createConnection(conf)) {
        VisibilityClient.addLabels(conn, labels);
      } catch (Throwable t) {
        throw new IOException(t);
      }
      return null;
    }
  };
  SUPERUSER.runAs(action);
}
项目:hbase    文件:TestVisibilityWithCheckAuths.java   
public static void addLabels() throws Exception {
  PrivilegedExceptionAction<VisibilityLabelsResponse> action =
      new PrivilegedExceptionAction<VisibilityLabelsResponse>() {
    @Override
    public VisibilityLabelsResponse run() throws Exception {
      String[] labels = { TOPSECRET };
      try (Connection conn = ConnectionFactory.createConnection(conf)) {
        VisibilityClient.addLabels(conn, labels);
      } catch (Throwable t) {
        throw new IOException(t);
      }
      return null;
    }
  };
  SUPERUSER.runAs(action);
}
项目:hbase    文件:TestImportTSVWithVisibilityLabels.java   
private static void createLabels() throws IOException, InterruptedException {
  PrivilegedExceptionAction<VisibilityLabelsResponse> action =
      new PrivilegedExceptionAction<VisibilityLabelsResponse>() {
    @Override
    public VisibilityLabelsResponse run() throws Exception {
      String[] labels = { SECRET, TOPSECRET, CONFIDENTIAL, PUBLIC, PRIVATE };
      try (Connection conn = ConnectionFactory.createConnection(conf)) {
        VisibilityClient.addLabels(conn, labels);
        LOG.info("Added labels ");
      } catch (Throwable t) {
        LOG.error("Error in adding labels" , t);
        throw new IOException(t);
      }
      return null;
    }
  };
  SUPERUSER.runAs(action);
}
项目:PyroDB    文件:TestVisibilityLabels.java   
@Test
public void testAddLabels() throws Throwable {
  PrivilegedExceptionAction<VisibilityLabelsResponse> action = 
      new PrivilegedExceptionAction<VisibilityLabelsResponse>() {
    public VisibilityLabelsResponse run() throws Exception {
      String[] labels = { "L1", SECRET, "L2", "invalid~", "L3" };
      VisibilityLabelsResponse response = null;
      try {
        response = VisibilityClient.addLabels(conf, labels);
      } catch (Throwable e) {
        fail("Should not have thrown exception");
      }
      List<RegionActionResult> resultList = response.getResultList();
      assertEquals(5, resultList.size());
      assertTrue(resultList.get(0).getException().getValue().isEmpty());
      assertEquals("org.apache.hadoop.hbase.security.visibility.LabelAlreadyExistsException",
          resultList.get(1).getException().getName());
      assertTrue(resultList.get(2).getException().getValue().isEmpty());
      assertEquals("org.apache.hadoop.hbase.security.visibility.InvalidLabelException",
          resultList.get(3).getException().getName());
      assertTrue(resultList.get(4).getException().getValue().isEmpty());
      return null;
    }
  };
  SUPERUSER.runAs(action);
}
项目:PyroDB    文件:TestImportTSVWithVisibilityLabels.java   
private static void createLabels() throws IOException, InterruptedException {
  PrivilegedExceptionAction<VisibilityLabelsResponse> action =
      new PrivilegedExceptionAction<VisibilityLabelsResponse>() {
    @Override
    public VisibilityLabelsResponse run() throws Exception {
      String[] labels = { SECRET, TOPSECRET, CONFIDENTIAL, PUBLIC, PRIVATE };
      try {
        VisibilityClient.addLabels(conf, labels);
        LOG.info("Added labels ");
      } catch (Throwable t) {
        LOG.error("Error in adding labels" , t);
        throw new IOException(t);
      }
      return null;
    }
  };
  SUPERUSER.runAs(action);
}
项目:ditb    文件:TestThriftHBaseServiceHandlerWithLabels.java   
private static void createLabels() throws IOException, InterruptedException {
  PrivilegedExceptionAction<VisibilityLabelsResponse> action = new PrivilegedExceptionAction<VisibilityLabelsResponse>() {
    public VisibilityLabelsResponse run() throws Exception {
      String[] labels = { SECRET, CONFIDENTIAL, PRIVATE, PUBLIC, TOPSECRET };
      try (Connection conn = ConnectionFactory.createConnection(conf)) {
        VisibilityClient.addLabels(conn, labels);
      } catch (Throwable t) {
        throw new IOException(t);
      }
      return null;
    }
  };
  SUPERUSER.runAs(action);
}
项目:ditb    文件:VisibilityController.java   
private void setExceptionResults(int size, IOException e,
    VisibilityLabelsResponse.Builder response) {
  RegionActionResult.Builder failureResultBuilder = RegionActionResult.newBuilder();
  failureResultBuilder.setException(ResponseConverter.buildException(e));
  RegionActionResult failureResult = failureResultBuilder.build();
  for (int i = 0; i < size; i++) {
    response.addResult(i, failureResult);
  }
}
项目:ditb    文件:TestVisibilityLabelsReplication.java   
public static void addLabels() throws Exception {
  PrivilegedExceptionAction<VisibilityLabelsResponse> action =
      new PrivilegedExceptionAction<VisibilityLabelsResponse>() {
    public VisibilityLabelsResponse run() throws Exception {
      String[] labels = { SECRET, TOPSECRET, CONFIDENTIAL, PUBLIC, PRIVATE, UNICODE_VIS_TAG };
      try (Connection conn = ConnectionFactory.createConnection(conf)) {
        VisibilityClient.addLabels(conn, labels);
      } catch (Throwable t) {
        throw new IOException(t);
      }
      return null;
    }
  };
  SUPERUSER.runAs(action);
}
项目:ditb    文件:TestVisibilityLabelsReplication.java   
public static void setAuths(final Configuration conf) throws Exception {
  PrivilegedExceptionAction<VisibilityLabelsResponse> action =
      new PrivilegedExceptionAction<VisibilityLabelsResponse>() {
    public VisibilityLabelsResponse run() throws Exception {
      try (Connection conn = ConnectionFactory.createConnection(conf)) {
        return VisibilityClient.setAuths(conn, new String[] { SECRET,
          CONFIDENTIAL, PRIVATE, TOPSECRET, UNICODE_VIS_TAG }, "user1");
      } catch (Throwable e) {
        throw new Exception(e);
      }
    }
  };
  VisibilityLabelsResponse response = SUPERUSER.runAs(action);
}
项目:ditb    文件:TestVisibilityLabelsOpWithDifferentUsersNoACL.java   
private static void addLabels() throws Exception {
  PrivilegedExceptionAction<VisibilityLabelsResponse> action = 
      new PrivilegedExceptionAction<VisibilityLabelsResponse>() {
    public VisibilityLabelsResponse run() throws Exception {
      String[] labels = { SECRET, CONFIDENTIAL, PRIVATE };
      try (Connection conn = ConnectionFactory.createConnection(conf)) {
        VisibilityClient.addLabels(conn, labels);
      } catch (Throwable t) {
        throw new IOException(t);
      }
      return null;
    }
  };
  SUPERUSER.runAs(action);
}
项目:ditb    文件:TestVisibilityLabelsWithSLGStack.java   
private static void addLabels() throws Exception {
  PrivilegedExceptionAction<VisibilityLabelsResponse> action = 
      new PrivilegedExceptionAction<VisibilityLabelsResponse>() {
    public VisibilityLabelsResponse run() throws Exception {
      String[] labels = { SECRET, CONFIDENTIAL };
      try (Connection conn = ConnectionFactory.createConnection(conf)) {
        VisibilityClient.addLabels(conn, labels);
      } catch (Throwable t) {
        throw new IOException(t);
      }
      return null;
    }
  };
  SUPERUSER.runAs(action);
}
项目:ditb    文件:TestVisibilityLabelsWithDefaultVisLabelService.java   
@Test
public void testAddLabels() throws Throwable {
  PrivilegedExceptionAction<VisibilityLabelsResponse> action =
      new PrivilegedExceptionAction<VisibilityLabelsResponse>() {
    public VisibilityLabelsResponse run() throws Exception {
      String[] labels = { "L1", SECRET, "L2", "invalid~", "L3" };
      VisibilityLabelsResponse response = null;
      try (Connection conn = ConnectionFactory.createConnection(conf)) {
        response = VisibilityClient.addLabels(conn, labels);
      } catch (Throwable e) {
        fail("Should not have thrown exception");
      }
      List<RegionActionResult> resultList = response.getResultList();
      assertEquals(5, resultList.size());
      assertTrue(resultList.get(0).getException().getValue().isEmpty());
      assertEquals("org.apache.hadoop.hbase.DoNotRetryIOException", resultList.get(1)
          .getException().getName());
      assertTrue(Bytes.toString(resultList.get(1).getException().getValue().toByteArray())
          .contains(
              "org.apache.hadoop.hbase.security.visibility.LabelAlreadyExistsException: "
                  + "Label 'secret' already exists"));
      assertTrue(resultList.get(2).getException().getValue().isEmpty());
      assertTrue(resultList.get(3).getException().getValue().isEmpty());
      assertTrue(resultList.get(4).getException().getValue().isEmpty());
      return null;
    }
  };
  SUPERUSER.runAs(action);
}
项目:ditb    文件:VisibilityClient.java   
private static VisibilityLabelsResponse setOrClearAuths(Connection connection,
    final String[] auths, final String user, final boolean setOrClear)
        throws IOException, ServiceException, Throwable {

    try (Table table = connection.getTable(LABELS_TABLE_NAME)) {
      Batch.Call<VisibilityLabelsService, VisibilityLabelsResponse> callable =
          new Batch.Call<VisibilityLabelsService, VisibilityLabelsResponse>() {
        ServerRpcController controller = new ServerRpcController();
        BlockingRpcCallback<VisibilityLabelsResponse> rpcCallback =
            new BlockingRpcCallback<VisibilityLabelsResponse>();

        public VisibilityLabelsResponse call(VisibilityLabelsService service) throws IOException {
          SetAuthsRequest.Builder setAuthReqBuilder = SetAuthsRequest.newBuilder();
          setAuthReqBuilder.setUser(ByteStringer.wrap(Bytes.toBytes(user)));
          for (String auth : auths) {
            if (auth.length() > 0) {
              setAuthReqBuilder.addAuth(ByteStringer.wrap(Bytes.toBytes(auth)));
            }
          }
          if (setOrClear) {
            service.setAuths(controller, setAuthReqBuilder.build(), rpcCallback);
          } else {
            service.clearAuths(controller, setAuthReqBuilder.build(), rpcCallback);
          }
          VisibilityLabelsResponse response = rpcCallback.get();
          if (controller.failedOnException()) {
            throw controller.getFailedOn();
          }
          return response;
        }
      };
      Map<byte[], VisibilityLabelsResponse> result = table.coprocessorService(
          VisibilityLabelsService.class, HConstants.EMPTY_BYTE_ARRAY, HConstants.EMPTY_BYTE_ARRAY,
          callable);
      return result.values().iterator().next(); // There will be exactly one region for labels
      // table and so one entry in result Map.
    }
}
项目:ditb    文件:TestScannersWithLabels.java   
private static void createLabels() throws IOException, InterruptedException {
  PrivilegedExceptionAction<VisibilityLabelsResponse> action = new PrivilegedExceptionAction<VisibilityLabelsResponse>() {
    public VisibilityLabelsResponse run() throws Exception {
      String[] labels = { SECRET, CONFIDENTIAL, PRIVATE, PUBLIC, TOPSECRET };
      try (Connection conn = ConnectionFactory.createConnection(conf)) {
        VisibilityClient.addLabels(conn, labels);
      } catch (Throwable t) {
        throw new IOException(t);
      }
      return null;
    }
  };
  SUPERUSER.runAs(action);
}
项目:pbase    文件:VisibilityController.java   
private void setExceptionResults(int size, IOException e,
    VisibilityLabelsResponse.Builder response) {
  RegionActionResult.Builder failureResultBuilder = RegionActionResult.newBuilder();
  failureResultBuilder.setException(ResponseConverter.buildException(e));
  RegionActionResult failureResult = failureResultBuilder.build();
  for (int i = 0; i < size; i++) {
    response.addResult(i, failureResult);
  }
}
项目:pbase    文件:TestVisibilityLabelsWithDeletes.java   
private void setAuths() throws IOException, InterruptedException {
  PrivilegedExceptionAction<VisibilityLabelsResponse> action =
      new PrivilegedExceptionAction<VisibilityLabelsResponse>() {
    @Override
    public VisibilityLabelsResponse run() throws Exception {
      try {
        return VisibilityClient.setAuths(conf, new String[] { CONFIDENTIAL, PRIVATE, SECRET,
            TOPSECRET }, SUPERUSER.getShortName());
      } catch (Throwable e) {
      }
      return null;
    }
  };
  SUPERUSER.runAs(action);
}
项目:pbase    文件:TestVisibilityLabelsReplication.java   
public static void addLabels() throws Exception {
  PrivilegedExceptionAction<VisibilityLabelsResponse> action =
      new PrivilegedExceptionAction<VisibilityLabelsResponse>() {
    public VisibilityLabelsResponse run() throws Exception {
      String[] labels = { SECRET, TOPSECRET, CONFIDENTIAL, PUBLIC, PRIVATE, UNICODE_VIS_TAG };
      try {
        VisibilityClient.addLabels(conf, labels);
      } catch (Throwable t) {
        throw new IOException(t);
      }
      return null;
    }
  };
  SUPERUSER.runAs(action);
}
项目:pbase    文件:TestVisibilityLabelsReplication.java   
public static void setAuths(final Configuration conf) throws Exception {
  PrivilegedExceptionAction<VisibilityLabelsResponse> action =
      new PrivilegedExceptionAction<VisibilityLabelsResponse>() {
    public VisibilityLabelsResponse run() throws Exception {
      try {
        return VisibilityClient.setAuths(conf, new String[] { SECRET, CONFIDENTIAL, PRIVATE,
            TOPSECRET, UNICODE_VIS_TAG }, "user1");
      } catch (Throwable e) {
        throw new Exception(e);
      }
    }
  };
  VisibilityLabelsResponse response = SUPERUSER.runAs(action);
}
项目:pbase    文件:TestVisibilityLabelsOpWithDifferentUsersNoACL.java   
private static void addLabels() throws Exception {
  PrivilegedExceptionAction<VisibilityLabelsResponse> action = 
      new PrivilegedExceptionAction<VisibilityLabelsResponse>() {
    public VisibilityLabelsResponse run() throws Exception {
      String[] labels = { SECRET, CONFIDENTIAL, PRIVATE };
      try {
        VisibilityClient.addLabels(conf, labels);
      } catch (Throwable t) {
        throw new IOException(t);
      }
      return null;
    }
  };
  SUPERUSER.runAs(action);
}
项目:pbase    文件:TestVisibilityLabelsWithSLGStack.java   
private static void addLabels() throws Exception {
  PrivilegedExceptionAction<VisibilityLabelsResponse> action = 
      new PrivilegedExceptionAction<VisibilityLabelsResponse>() {
    public VisibilityLabelsResponse run() throws Exception {
      String[] labels = { SECRET, CONFIDENTIAL };
      try {
        VisibilityClient.addLabels(conf, labels);
      } catch (Throwable t) {
        throw new IOException(t);
      }
      return null;
    }
  };
  SUPERUSER.runAs(action);
}
项目:pbase    文件:TestVisibilityLabelsWithDefaultVisLabelService.java   
@Test
public void testAddLabels() throws Throwable {
  PrivilegedExceptionAction<VisibilityLabelsResponse> action =
      new PrivilegedExceptionAction<VisibilityLabelsResponse>() {
    public VisibilityLabelsResponse run() throws Exception {
      String[] labels = { "L1", SECRET, "L2", "invalid~", "L3" };
      VisibilityLabelsResponse response = null;
      try {
        response = VisibilityClient.addLabels(conf, labels);
      } catch (Throwable e) {
        fail("Should not have thrown exception");
      }
      List<RegionActionResult> resultList = response.getResultList();
      assertEquals(5, resultList.size());
      assertTrue(resultList.get(0).getException().getValue().isEmpty());
      assertEquals("org.apache.hadoop.hbase.DoNotRetryIOException", resultList.get(1)
          .getException().getName());
      assertTrue(Bytes.toString(resultList.get(1).getException().getValue().toByteArray())
          .contains(
              "org.apache.hadoop.hbase.security.visibility.LabelAlreadyExistsException: "
                  + "Label 'secret' already exists"));
      assertTrue(resultList.get(2).getException().getValue().isEmpty());
      assertTrue(resultList.get(3).getException().getValue().isEmpty());
      assertTrue(resultList.get(4).getException().getValue().isEmpty());
      return null;
    }
  };
  SUPERUSER.runAs(action);
}
项目:pbase    文件:VisibilityClient.java   
private static VisibilityLabelsResponse setOrClearAuths(Configuration conf, final String[] auths,
    final String user, final boolean setOrClear) throws IOException, ServiceException, Throwable {
  // TODO: Make it so caller passes in a Connection rather than have us do this expensive
  // setup each time.  This class only used in test and shell at moment though.
  try (Connection connection = ConnectionFactory.createConnection(conf)) {
    try (Table table = connection.getTable(LABELS_TABLE_NAME)) {
      Batch.Call<VisibilityLabelsService, VisibilityLabelsResponse> callable =
          new Batch.Call<VisibilityLabelsService, VisibilityLabelsResponse>() {
        ServerRpcController controller = new ServerRpcController();
        BlockingRpcCallback<VisibilityLabelsResponse> rpcCallback =
            new BlockingRpcCallback<VisibilityLabelsResponse>();

        public VisibilityLabelsResponse call(VisibilityLabelsService service) throws IOException {
          SetAuthsRequest.Builder setAuthReqBuilder = SetAuthsRequest.newBuilder();
          setAuthReqBuilder.setUser(ByteStringer.wrap(Bytes.toBytes(user)));
          for (String auth : auths) {
            if (auth.length() > 0) {
              setAuthReqBuilder.addAuth(ByteStringer.wrap(Bytes.toBytes(auth)));
            }
          }
          if (setOrClear) {
            service.setAuths(controller, setAuthReqBuilder.build(), rpcCallback);
          } else {
            service.clearAuths(controller, setAuthReqBuilder.build(), rpcCallback);
          }
          VisibilityLabelsResponse response = rpcCallback.get();
          if (controller.failedOnException()) {
            throw controller.getFailedOn();
          }
          return response;
        }
      };
      Map<byte[], VisibilityLabelsResponse> result = table.coprocessorService(
          VisibilityLabelsService.class, HConstants.EMPTY_BYTE_ARRAY, HConstants.EMPTY_BYTE_ARRAY,
          callable);
      return result.values().iterator().next(); // There will be exactly one region for labels
      // table and so one entry in result Map.
    }
  }
}
项目:HIndex    文件:TestThriftHBaseServiceHandlerWithLabels.java   
private static void createLabels() throws IOException, InterruptedException {
  PrivilegedExceptionAction<VisibilityLabelsResponse> action = new PrivilegedExceptionAction<VisibilityLabelsResponse>() {
    public VisibilityLabelsResponse run() throws Exception {
      String[] labels = { SECRET, CONFIDENTIAL, PRIVATE, PUBLIC, TOPSECRET };
      try {
        VisibilityClient.addLabels(conf, labels);
      } catch (Throwable t) {
        throw new IOException(t);
      }
      return null;
    }
  };
  SUPERUSER.runAs(action);
}
项目:HIndex    文件:VisibilityController.java   
private void setExceptionResults(int size, IOException e,
    VisibilityLabelsResponse.Builder response) {
  RegionActionResult.Builder failureResultBuilder = RegionActionResult.newBuilder();
  failureResultBuilder.setException(ResponseConverter.buildException(e));
  RegionActionResult failureResult = failureResultBuilder.build();
  for (int i = 0; i < size; i++) {
    response.addResult(i, failureResult);
  }
}