本文整理匯總了Java中org.apache.hadoop.hbase.client.Get.setAuthorizations方法的典型用法代碼示例。如果您正苦於以下問題:Java Get.setAuthorizations方法的具體用法?Java Get.setAuthorizations怎麽用?Java Get.setAuthorizations使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.hadoop.hbase.client.Get
的用法示例。
在下文中一共展示了Get.setAuthorizations方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testGetForSuperUserWithFewerLabelAuths
import org.apache.hadoop.hbase.client.Get; //導入方法依賴的package包/類
@Test
public void testGetForSuperUserWithFewerLabelAuths() throws Throwable {
String[] auths = { SECRET };
String user = "admin";
VisibilityClient.setAuths(TEST_UTIL.getConnection(), auths, user);
TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
final Table table = createTableAndWriteDataWithLabels(tableName, SECRET + "&" + CONFIDENTIAL
+ "&!" + PRIVATE, SECRET + "&!" + PRIVATE);
PrivilegedExceptionAction<Void> scanAction = new PrivilegedExceptionAction<Void>() {
public Void run() throws Exception {
Get g = new Get(row1);
g.setAuthorizations(new Authorizations(SECRET, CONFIDENTIAL));
try (Connection connection = ConnectionFactory.createConnection(conf);
Table t = connection.getTable(table.getName())) {
Result result = t.get(g);
assertTrue(!result.isEmpty());
}
return null;
}
};
SUPERUSER.runAs(scanAction);
}
示例2: testVisibilityLabelsForUserWithNoAuths
import org.apache.hadoop.hbase.client.Get; //導入方法依賴的package包/類
@Test
public void testVisibilityLabelsForUserWithNoAuths() throws Throwable {
String user = "admin";
String[] auths = { SECRET };
try (Connection conn = ConnectionFactory.createConnection(conf)) {
VisibilityClient.clearAuths(conn, auths, user); // Removing all auths if any.
VisibilityClient.setAuths(conn, auths, "user1");
}
TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
final Table table = createTableAndWriteDataWithLabels(tableName, SECRET);
SecureTestUtil.grantOnTable(TEST_UTIL, NORMAL_USER1.getShortName(), tableName,
null, null, Permission.Action.READ);
SecureTestUtil.grantOnTable(TEST_UTIL, NORMAL_USER2.getShortName(), tableName,
null, null, Permission.Action.READ);
PrivilegedExceptionAction<Void> getAction = new PrivilegedExceptionAction<Void>() {
public Void run() throws Exception {
Get g = new Get(row1);
g.setAuthorizations(new Authorizations(SECRET, CONFIDENTIAL));
try (Connection connection = ConnectionFactory.createConnection(conf);
Table t = connection.getTable(table.getName())) {
Result result = t.get(g);
assertTrue(result.isEmpty());
}
return null;
}
};
NORMAL_USER2.runAs(getAction);
}
示例3: testVisibilityLabelsWithGet
import org.apache.hadoop.hbase.client.Get; //導入方法依賴的package包/類
@Test
public void testVisibilityLabelsWithGet() throws Exception {
TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
try (Table table = createTableAndWriteDataWithLabels(tableName, SECRET + "&" + CONFIDENTIAL
+ "&!" + PRIVATE, SECRET + "&" + CONFIDENTIAL + "&" + PRIVATE)) {
Get get = new Get(row1);
get.setAuthorizations(new Authorizations(SECRET, CONFIDENTIAL));
Result result = table.get(get);
assertTrue(!result.isEmpty());
Cell cell = result.getColumnLatestCell(fam, qual);
assertTrue(Bytes.equals(value, 0, value.length, cell.getValueArray(), cell.getValueOffset(),
cell.getValueLength()));
}
}
示例4: testVisibilityLabelsInGetThatDoesNotMatchAnyDefinedLabels
import org.apache.hadoop.hbase.client.Get; //導入方法依賴的package包/類
@Test
public void testVisibilityLabelsInGetThatDoesNotMatchAnyDefinedLabels() throws Exception {
TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
try (Table table = createTableAndWriteDataWithLabels(tableName, "(" + SECRET + "|" + CONFIDENTIAL
+ ")", PRIVATE)) {
Get get = new Get(row1);
get.setAuthorizations(new Authorizations("SAMPLE"));
Result result = table.get(get);
assertTrue(result.isEmpty());
}
}
示例5: testLabelsWithIncrement
import org.apache.hadoop.hbase.client.Get; //導入方法依賴的package包/類
@Test
public void testLabelsWithIncrement() throws Throwable {
TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
try (Table table = TEST_UTIL.createTable(tableName, fam)) {
byte[] row1 = Bytes.toBytes("row1");
byte[] val = Bytes.toBytes(1L);
Put put = new Put(row1);
put.add(fam, qual, HConstants.LATEST_TIMESTAMP, val);
put.setCellVisibility(new CellVisibility(SECRET + " & " + CONFIDENTIAL));
table.put(put);
Get get = new Get(row1);
get.setAuthorizations(new Authorizations(SECRET));
Result result = table.get(get);
assertTrue(result.isEmpty());
table.incrementColumnValue(row1, fam, qual, 2L);
result = table.get(get);
assertTrue(result.isEmpty());
Increment increment = new Increment(row1);
increment.addColumn(fam, qual, 2L);
increment.setCellVisibility(new CellVisibility(SECRET));
table.increment(increment);
result = table.get(get);
assertTrue(!result.isEmpty());
}
}
示例6: testMutateRow
import org.apache.hadoop.hbase.client.Get; //導入方法依賴的package包/類
@Test
public void testMutateRow() throws Exception {
final byte[] qual2 = Bytes.toBytes("qual2");
TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
HTableDescriptor desc = new HTableDescriptor(tableName);
HColumnDescriptor col = new HColumnDescriptor(fam);
desc.addFamily(col);
TEST_UTIL.getHBaseAdmin().createTable(desc);
try (Table table = TEST_UTIL.getConnection().getTable(tableName)){
Put p1 = new Put(row1);
p1.add(fam, qual, value);
p1.setCellVisibility(new CellVisibility(CONFIDENTIAL));
Put p2 = new Put(row1);
p2.add(fam, qual2, value);
p2.setCellVisibility(new CellVisibility(SECRET));
RowMutations rm = new RowMutations(row1);
rm.add(p1);
rm.add(p2);
table.mutateRow(rm);
Get get = new Get(row1);
get.setAuthorizations(new Authorizations(CONFIDENTIAL));
Result result = table.get(get);
assertTrue(result.containsColumn(fam, qual));
assertFalse(result.containsColumn(fam, qual2));
get.setAuthorizations(new Authorizations(SECRET));
result = table.get(get);
assertFalse(result.containsColumn(fam, qual));
assertTrue(result.containsColumn(fam, qual2));
}
}
示例7: verifyGet
import org.apache.hadoop.hbase.client.Get; //導入方法依賴的package包/類
@Override
protected void verifyGet(final byte[] row, final String visString, final int expected,
final boolean nullExpected, final String... auths) throws IOException,
InterruptedException {
PrivilegedExceptionAction<Void> scanAction = new PrivilegedExceptionAction<Void>() {
public Void run() throws Exception {
try (Connection connection = ConnectionFactory.createConnection(conf1);
Table table2 = connection.getTable(TableName.valueOf(TABLE_NAME))) {
CellScanner cellScanner;
Cell current;
Get get = new Get(row);
get.setAuthorizations(new Authorizations(auths));
Result result = table2.get(get);
cellScanner = result.cellScanner();
boolean advance = cellScanner.advance();
if (nullExpected) {
assertTrue(!advance);
return null;
}
current = cellScanner.current();
assertArrayEquals(CellUtil.cloneRow(current), row);
assertEquals(expected, TestCoprocessorForTagsAtSink.tags.size());
boolean foundNonVisTag = false;
for(Tag t : TestCoprocessorForTagsAtSink.tags) {
if(t.getType() == NON_VIS_TAG_TYPE) {
assertEquals(TEMP, Bytes.toString(t.getValue()));
foundNonVisTag = true;
break;
}
}
doAssert(row, visString);
assertTrue(foundNonVisTag);
return null;
}
}
};
USER1.runAs(scanAction);
}
示例8: getFromThrift
import org.apache.hadoop.hbase.client.Get; //導入方法依賴的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;
}
示例9: beforeGet
import org.apache.hadoop.hbase.client.Get; //導入方法依賴的package包/類
@Override
public Get beforeGet(long rowkeyBase, Get get) {
get.setAuthorizations(new Authorizations(
authorizations[(int) (rowkeyBase % authorizations.length)]));
return get;
}