当前位置: 首页>>代码示例>>Java>>正文


Java Authorizations类代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.security.visibility.Authorizations的典型用法代码示例。如果您正苦于以下问题:Java Authorizations类的具体用法?Java Authorizations怎么用?Java Authorizations使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Authorizations类属于org.apache.hadoop.hbase.security.visibility包,在下文中一共展示了Authorizations类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doVerify

import org.apache.hadoop.hbase.security.visibility.Authorizations; //导入依赖的package包/类
private Job doVerify(Configuration conf, HTableDescriptor htd, String... auths)
    throws IOException, InterruptedException, ClassNotFoundException {
  Path outputDir = getTestDir(TEST_NAME, "verify-output");
  Job job = new Job(conf);
  job.setJarByClass(this.getClass());
  job.setJobName(TEST_NAME + " Verification for " + htd.getTableName());
  setJobScannerConf(job);
  Scan scan = new Scan();
  scan.setAuthorizations(new Authorizations(auths));
  TableMapReduceUtil.initTableMapperJob(htd.getTableName().getNameAsString(), scan,
      VerifyMapper.class, NullWritable.class, NullWritable.class, job);
  TableMapReduceUtil.addDependencyJars(job.getConfiguration(), AbstractHBaseTool.class);
  int scannerCaching = conf.getInt("verify.scannercaching", SCANNER_CACHING);
  TableMapReduceUtil.setScannerCaching(job, scannerCaching);
  job.setNumReduceTasks(0);
  FileOutputFormat.setOutputPath(job, outputDir);
  assertTrue(job.waitForCompletion(true));
  return job;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:20,代码来源:IntegrationTestWithCellVisibilityLoadAndVerify.java

示例2: testSetAuthorizations

import org.apache.hadoop.hbase.security.visibility.Authorizations; //导入依赖的package包/类
@Test
public void testSetAuthorizations() {
  Scan scan = new Scan();
  try {
    scan.setAuthorizations(new Authorizations("\u002b|\u0029"));
    scan.setAuthorizations(new Authorizations("A", "B", "0123", "A0", "1A1", "_a"));
    scan.setAuthorizations(new Authorizations("A|B"));
    scan.setAuthorizations(new Authorizations("A&B"));
    scan.setAuthorizations(new Authorizations("!B"));
    scan.setAuthorizations(new Authorizations("A", "(A)"));
    scan.setAuthorizations(new Authorizations("A", "{A"));
    scan.setAuthorizations(new Authorizations(" "));
    scan.setAuthorizations(new Authorizations(":B"));
    scan.setAuthorizations(new Authorizations("-B"));
    scan.setAuthorizations(new Authorizations(".B"));
    scan.setAuthorizations(new Authorizations("/B"));
  } catch (IllegalArgumentException e) {
    fail("should not throw exception");
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:21,代码来源:TestScan.java

示例3: doVerify

import org.apache.hadoop.hbase.security.visibility.Authorizations; //导入依赖的package包/类
private Job doVerify(Configuration conf, HTableDescriptor htd, String... auths)
    throws IOException, InterruptedException, ClassNotFoundException {
  Path outputDir = getTestDir(TEST_NAME, "verify-output");
  Job job = new Job(conf);
  job.setJarByClass(this.getClass());
  job.setJobName(TEST_NAME + " Verification for " + htd.getTableName());
  setJobScannerConf(job);
  Scan scan = new Scan();
  scan.setAuthorizations(new Authorizations(auths));
  TableMapReduceUtil.initTableMapperJob(htd.getTableName().getNameAsString(), scan,
      VerifyMapper.class, NullWritable.class, NullWritable.class, job);
  TableMapReduceUtil.addDependencyJarsForClasses(job.getConfiguration(), AbstractHBaseTool.class);
  int scannerCaching = conf.getInt("verify.scannercaching", SCANNER_CACHING);
  TableMapReduceUtil.setScannerCaching(job, scannerCaching);
  job.setNumReduceTasks(0);
  FileOutputFormat.setOutputPath(job, outputDir);
  assertTrue(job.waitForCompletion(true));
  return job;
}
 
开发者ID:apache,项目名称:hbase,代码行数:20,代码来源:IntegrationTestWithCellVisibilityLoadAndVerify.java

示例4: getScannedResults

import org.apache.hadoop.hbase.security.visibility.Authorizations; //导入依赖的package包/类
public ResultScanner getScannedResults(
		final Scan scanner,
		final String tableName,
		final String... authorizations )
		throws IOException {
	if (authorizations != null) {
		scanner.setAuthorizations(new Authorizations(
				authorizations));
	}

	final Table table = conn.getTable(getTableName(getQualifiedTableName(tableName)));

	final ResultScanner results = table.getScanner(scanner);

	table.close();

	return results;
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:19,代码来源:BasicHBaseOperations.java

示例5: testScanRowWithAuthorization

import org.apache.hadoop.hbase.security.visibility.Authorizations; //导入依赖的package包/类
@Test(expected=UnsupportedOperationException.class)
public void testScanRowWithAuthorization() throws IOException {
    clean();
    String row = rowPrefix + 0;
    putRow(row + 0, 1000);
    putRow(row + 3, 1000);

    Scan scan = new Scan();
    scan.setAuthorizations(new Authorizations());
    scan.setStartRow(Bytes.toBytes(row + 0));
    scan.setStopRow(Bytes.toBytes(row + 3));
    ResultScanner scanResult = table.getScanner(scan);

    scanResult.next();
}
 
开发者ID:aliyun,项目名称:aliyun-tablestore-hbase-client,代码行数:16,代码来源:TestScanRow.java

示例6: doVerify

import org.apache.hadoop.hbase.security.visibility.Authorizations; //导入依赖的package包/类
private int doVerify(Path outputDir, int numReducers) throws IOException, InterruptedException,
    ClassNotFoundException {
  job = new Job(getConf());

  job.setJobName("Link Verifier");
  job.setNumReduceTasks(numReducers);
  job.setJarByClass(getClass());

  setJobScannerConf(job);

  Scan scan = new Scan();
  scan.addColumn(FAMILY_NAME, COLUMN_PREV);
  scan.setCaching(10000);
  scan.setCacheBlocks(false);
  String[] split = labels.split(COMMA);

  scan.setAuthorizations(new Authorizations(split[this.labelIndex * 2],
      split[(this.labelIndex * 2) + 1]));

  TableMapReduceUtil.initTableMapperJob(tableName.getName(), scan, VerifyMapper.class,
      BytesWritable.class, BytesWritable.class, job);
  TableMapReduceUtil.addDependencyJars(job.getConfiguration(), AbstractHBaseTool.class);

  job.getConfiguration().setBoolean("mapreduce.map.speculative", false);

  job.setReducerClass(VerifyReducer.class);
  job.setOutputFormatClass(TextOutputFormat.class);
  TextOutputFormat.setOutputPath(job, outputDir);
  boolean success = job.waitForCompletion(true);

  return success ? 0 : 1;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:33,代码来源:IntegrationTestBigLinkedListWithVisibility.java

示例7: toAuthorizations

import org.apache.hadoop.hbase.security.visibility.Authorizations; //导入依赖的package包/类
/**
 * Convert a protocol buffer Authorizations bytes to a client Authorizations
 *
 * @param protoBytes
 * @return the converted client Authorizations
 * @throws DeserializationException
 */
public static Authorizations toAuthorizations(byte[] protoBytes) throws DeserializationException {
  if (protoBytes == null) return null;
  ClientProtos.Authorizations.Builder builder = ClientProtos.Authorizations.newBuilder();
  ClientProtos.Authorizations proto = null;
  try {
    ProtobufUtil.mergeFrom(builder, protoBytes);
    proto = builder.build();
  } catch (IOException e) {
    throw new DeserializationException(e);
  }
  return toAuthorizations(proto);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:20,代码来源:ProtobufUtil.java

示例8: deleteAllRows

import org.apache.hadoop.hbase.security.visibility.Authorizations; //导入依赖的package包/类
public static void deleteAllRows(final HBaseStore store, final String... auths) throws StoreException {
    final Connection connection = store.getConnection();
    try {
        if (connection.getAdmin().tableExists(store.getTableName())) {
            connection.getAdmin().flush(store.getTableName());
            final Table table = connection.getTable(store.getTableName());
            final Scan scan = new Scan();
            scan.setAuthorizations(new Authorizations(auths));
            try (ResultScanner scanner = table.getScanner(scan)) {
                final List<Delete> deletes = new ArrayList<>();
                for (final Result result : scanner) {
                    deletes.add(new Delete(result.getRow()));
                }
                table.delete(deletes);
                connection.getAdmin().flush(store.getTableName());
            }

            try (ResultScanner scanner = table.getScanner(scan)) {
                if (scanner.iterator().hasNext()) {
                    throw new StoreException("Some rows in table " + store.getTableName() + " failed to delete");
                }
            }
        }
    } catch (final IOException e) {
        throw new StoreException("Failed to delete all rows in table " + store.getTableName(), e);
    }
}
 
开发者ID:gchq,项目名称:Gaffer,代码行数:28,代码来源:TableUtils.java

示例9: HBaseRetriever

import org.apache.hadoop.hbase.security.visibility.Authorizations; //导入依赖的package包/类
public HBaseRetriever(final HBaseStore store,
                      final OP operation,
                      final User user,
                      final Iterable<? extends ElementId> ids,
                      final boolean includeMatchedVertex,
                      final Class<?>... extraProcessors) throws StoreException {
    this.serialisation = new ElementSerialisation(store.getSchema());
    this.rowRangeFactory = new RowRangeFactory(serialisation);
    this.validator = new ElementValidator(operation.getView());
    this.store = store;
    this.operation = operation;
    this.ids = ids;
    if (null != user && null != user.getDataAuths()) {
        this.authorisations = new Authorizations(
                user.getDataAuths().toArray(new String[user.getDataAuths().size()]));
    } else {
        this.authorisations = new Authorizations();
    }

    this.includeMatchedVertex = includeMatchedVertex;

    if (null != extraProcessors && extraProcessors.length > 0) {
        this.extraProcessors = StringUtil.toCsv(extraProcessors);
    } else {
        this.extraProcessors = null;
    }
}
 
开发者ID:gchq,项目名称:Gaffer,代码行数:28,代码来源:HBaseRetriever.java

示例10: toAuthorizations

import org.apache.hadoop.hbase.security.visibility.Authorizations; //导入依赖的package包/类
/**
 * Convert a protocol buffer Authorizations bytes to a client Authorizations
 *
 * @param protoBytes
 * @return the converted client Authorizations
 * @throws DeserializationException
 */
public static Authorizations toAuthorizations(byte[] protoBytes) throws DeserializationException {
  if (protoBytes == null) return null;
  ClientProtos.Authorizations.Builder builder = ClientProtos.Authorizations.newBuilder();
  ClientProtos.Authorizations proto = null;
  try {
    proto = builder.mergeFrom(protoBytes).build();
  } catch (InvalidProtocolBufferException e) {
    throw new DeserializationException(e);
  }
  return toAuthorizations(proto);
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:19,代码来源:ProtobufUtil.java

示例11: createLabels

import org.apache.hadoop.hbase.security.visibility.Authorizations; //导入依赖的package包/类
private void createLabels() throws IOException {
  // This scan should be done by user with global_admin previliges.. Ensure
  // that it works
  HTable visibilityLabelsTable = null;
  ResultScanner scanner = null;
  try {
    labels = new HashMap<String, Integer>();
    visibilityLabelsTable = new HTable(conf, LABELS_TABLE_NAME.getName());
    Scan scan = new Scan();
    scan.setAuthorizations(new Authorizations(VisibilityUtils.SYSTEM_LABEL));
    scan.addColumn(LABELS_TABLE_FAMILY, LABEL_QUALIFIER);
    scanner = visibilityLabelsTable.getScanner(scan);
    while (true) {
      Result next = scanner.next();
      if (next == null) {
        break;
      }
      byte[] row = next.getRow();
      byte[] value = next.getValue(LABELS_TABLE_FAMILY, LABEL_QUALIFIER);
      labels.put(Bytes.toString(value), Bytes.toInt(row));
    }
  } finally {
    try {
      if (scanner != null) {
        scanner.close();
      }
    } finally {
      if (visibilityLabelsTable != null) {
        visibilityLabelsTable.close();
      }
    }
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:34,代码来源:LabelExpander.java

示例12: runCopier

import org.apache.hadoop.hbase.security.visibility.Authorizations; //导入依赖的package包/类
public int runCopier(String outputDir) throws Exception {
  Job job = null;
  Scan scan = null;
  job = new Job(getConf());
  job.setJobName("Data copier");
  job.getConfiguration().setInt("INDEX", labelIndex);
  job.getConfiguration().set("LABELS", labels);
  job.setJarByClass(getClass());
  scan = new Scan();
  scan.setCacheBlocks(false);
  scan.setRaw(true);

  String[] split = labels.split(COMMA);
  scan.setAuthorizations(new Authorizations(split[this.labelIndex * 2],
      split[(this.labelIndex * 2) + 1]));
  if (delete) {
    LOG.info("Running deletes");
  } else {
    LOG.info("Running copiers");
  }
  if (delete) {
    TableMapReduceUtil.initTableMapperJob(tableName.getNameAsString(), scan,
        VisibilityDeleteImport.class, null, null, job);
  } else {
    TableMapReduceUtil.initTableMapperJob(tableName.getNameAsString(), scan,
        VisibilityImport.class, null, null, job);
  }
  job.getConfiguration().setBoolean("mapreduce.map.speculative", false);
  job.getConfiguration().setBoolean("mapreduce.reduce.speculative", false);
  TableMapReduceUtil.initTableReducerJob(COMMON_TABLE_NAME, null, job, null, null, null, null);
  TableMapReduceUtil.addDependencyJars(job);
  TableMapReduceUtil.addDependencyJars(job.getConfiguration(), AbstractHBaseTool.class);
  TableMapReduceUtil.initCredentials(job);
  job.setNumReduceTasks(0);
  boolean success = job.waitForCompletion(true);
  return success ? 0 : 1;
}
 
开发者ID:apache,项目名称:hbase,代码行数:38,代码来源:IntegrationTestBigLinkedListWithVisibility.java

示例13: TestGetRowFromGetCopyConstructor

import org.apache.hadoop.hbase.security.visibility.Authorizations; //导入依赖的package包/类
@Test
public void TestGetRowFromGetCopyConstructor() throws Exception {
  Get get = new Get(ROW);
  get.setFilter(null);
  get.setAuthorizations(new Authorizations("foo"));
  get.setACL("u", new Permission(Permission.Action.READ));
  get.setConsistency(Consistency.TIMELINE);
  get.setReplicaId(2);
  get.setIsolationLevel(IsolationLevel.READ_UNCOMMITTED);
  get.setCheckExistenceOnly(true);
  get.setTimeRange(3, 4);
  get.setMaxVersions(11);
  get.setMaxResultsPerColumnFamily(10);
  get.setRowOffsetPerColumnFamily(11);
  get.setCacheBlocks(true);

  Get copyGet = new Get(get);
  assertEquals(0, Bytes.compareTo(get.getRow(), copyGet.getRow()));

  // from OperationWithAttributes
  assertEquals(get.getId(), copyGet.getId());

  // from Query class
  assertEquals(get.getFilter(), copyGet.getFilter());
  assertTrue(get.getAuthorizations().toString().equals(copyGet.getAuthorizations().toString()));
  assertTrue(Bytes.equals(get.getACL(), copyGet.getACL()));
  assertEquals(get.getConsistency(), copyGet.getConsistency());
  assertEquals(get.getReplicaId(), copyGet.getReplicaId());
  assertEquals(get.getIsolationLevel(), copyGet.getIsolationLevel());

  // from Get class
  assertEquals(get.isCheckExistenceOnly(), copyGet.isCheckExistenceOnly());
  assertTrue(get.getTimeRange().equals(copyGet.getTimeRange()));
  assertEquals(get.getMaxVersions(), copyGet.getMaxVersions());
  assertEquals(get.getMaxResultsPerColumnFamily(), copyGet.getMaxResultsPerColumnFamily());
  assertEquals(get.getRowOffsetPerColumnFamily(), copyGet.getRowOffsetPerColumnFamily());
  assertEquals(get.getCacheBlocks(), copyGet.getCacheBlocks());
  assertEquals(get.getId(), copyGet.getId());
}
 
开发者ID:apache,项目名称:hbase,代码行数:40,代码来源:TestGet.java

示例14: getFromThrift

import org.apache.hadoop.hbase.security.visibility.Authorizations; //导入依赖的package包/类
/**
 * Creates a {@link Get} (HBase) from a {@link TGet} (Thrift).
 *
 * This ignores any timestamps set on {@link TColumn} objects.
 *
 * @param in the <code>TGet</code> to convert
 *
 * @return <code>Get</code> object
 *
 * @throws IOException if an invalid time range or max version parameter is given
 */
public static Get getFromThrift(TGet in) throws IOException {
  Get out = new Get(in.getRow());

  // Timestamp overwrites time range if both are set
  if (in.isSetTimestamp()) {
    out.setTimeStamp(in.getTimestamp());
  } else if (in.isSetTimeRange()) {
    out.setTimeRange(in.getTimeRange().getMinStamp(), in.getTimeRange().getMaxStamp());
  }

  if (in.isSetMaxVersions()) {
    out.setMaxVersions(in.getMaxVersions());
  }

  if (in.isSetFilterString()) {
    ParseFilter parseFilter = new ParseFilter();
    out.setFilter(parseFilter.parseFilterString(in.getFilterString()));
  }

  if (in.isSetAttributes()) {
    addAttributes(out,in.getAttributes());
  }

  if (in.isSetAuthorizations()) {
    out.setAuthorizations(new Authorizations(in.getAuthorizations().getLabels()));
  }
  
  if (!in.isSetColumns()) {
    return out;
  }

  for (TColumn column : in.getColumns()) {
    if (column.isSetQualifier()) {
      out.addColumn(column.getFamily(), column.getQualifier());
    } else {
      out.addFamily(column.getFamily());
    }
  }

  return out;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:53,代码来源:ThriftUtilities.java

示例15: scanFromThrift

import org.apache.hadoop.hbase.security.visibility.Authorizations; //导入依赖的package包/类
public static Scan scanFromThrift(TScan in) throws IOException {
  Scan out = new Scan();

  if (in.isSetStartRow())
    out.setStartRow(in.getStartRow());
  if (in.isSetStopRow())
    out.setStopRow(in.getStopRow());
  if (in.isSetCaching())
    out.setCaching(in.getCaching());
  if (in.isSetMaxVersions()) {
    out.setMaxVersions(in.getMaxVersions());
  }

  if (in.isSetColumns()) {
    for (TColumn column : in.getColumns()) {
      if (column.isSetQualifier()) {
        out.addColumn(column.getFamily(), column.getQualifier());
      } else {
        out.addFamily(column.getFamily());
      }
    }
  }

  TTimeRange timeRange = in.getTimeRange();
  if (timeRange != null &&
      timeRange.isSetMinStamp() && timeRange.isSetMaxStamp()) {
    out.setTimeRange(timeRange.getMinStamp(), timeRange.getMaxStamp());
  }

  if (in.isSetBatchSize()) {
    out.setBatch(in.getBatchSize());
  }

  if (in.isSetFilterString()) {
    ParseFilter parseFilter = new ParseFilter();
    out.setFilter(parseFilter.parseFilterString(in.getFilterString()));
  }

  if (in.isSetAttributes()) {
    addAttributes(out,in.getAttributes());
  }
  
  if (in.isSetAuthorizations()) {
    out.setAuthorizations(new Authorizations(in.getAuthorizations().getLabels()));
  }

  if (in.isSetReversed()) {
    out.setReversed(in.isReversed());
  }

  return out;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:53,代码来源:ThriftUtilities.java


注:本文中的org.apache.hadoop.hbase.security.visibility.Authorizations类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。