本文整理了Java中org.apache.hadoop.hbase.client.Get.setAuthorizations()
方法的一些代码示例,展示了Get.setAuthorizations()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Get.setAuthorizations()
方法的具体详情如下:
包路径:org.apache.hadoop.hbase.client.Get
类名称:Get
方法名:setAuthorizations
暂无
代码示例来源:origin: apache/hbase
@Override
public Get beforeGet(long rowkeyBase, Get get) {
get.setAuthorizations(new Authorizations(
authorizations[(int) (rowkeyBase % authorizations.length)]));
return get;
}
}
代码示例来源:origin: apache/hbase
@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());
}
}
代码示例来源:origin: apache/hbase
@Override
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;
}
};
代码示例来源:origin: apache/hbase
@Override
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;
}
};
代码示例来源:origin: apache/hbase
@Test
public void testDeleteWithNoVisibilitiesForPutsAndDeletes() throws Exception {
TableName tableName = createTable(5);
Put p = new Put(Bytes.toBytes("row1"));
p.addColumn(fam, qual, value);
Table table = TEST_UTIL.getConnection().getTable(tableName);
table.put(p);
p = new Put(Bytes.toBytes("row1"));
p.addColumn(fam, qual1, value);
table.put(p);
p = new Put(Bytes.toBytes("row2"));
p.addColumn(fam, qual, value);
table.put(p);
p = new Put(Bytes.toBytes("row2"));
p.addColumn(fam, qual1, value);
table.put(p);
Delete d = new Delete(Bytes.toBytes("row1"));
table.delete(d);
Get g = new Get(Bytes.toBytes("row1"));
g.readAllVersions();
g.setAuthorizations(new Authorizations(SECRET, PRIVATE));
Result result = table.get(g);
assertEquals(0, result.rawCells().length);
p = new Put(Bytes.toBytes("row1"));
p.addColumn(fam, qual, value);
table.put(p);
result = table.get(g);
assertEquals(1, result.rawCells().length);
}
代码示例来源:origin: apache/hbase
@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()));
}
}
代码示例来源:origin: apache/hbase
@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.getAdmin().createTable(desc);
try (Table table = TEST_UTIL.getConnection().getTable(tableName)){
Put p1 = new Put(row1);
p1.addColumn(fam, qual, value);
p1.setCellVisibility(new CellVisibility(CONFIDENTIAL));
Put p2 = new Put(row1);
p2.addColumn(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));
}
}
代码示例来源:origin: apache/hbase
Result r = table.get(new Get(row1));
assertEquals(0, r.size());
r = table.get(new Get(row1).setAuthorizations(new Authorizations(PRIVATE)));
assertEquals(1, r.size());
assertEquals(Bytes.toString(value1), Bytes.toString(CellUtil.cloneValue(r.rawCells()[0])));
r = table.get(new Get(row1).setAuthorizations(new Authorizations(PRIVATE)));
assertEquals(1, r.size());
assertEquals(Bytes.toString(value1), Bytes.toString(CellUtil.cloneValue(r.rawCells()[0])));
r = table.get(new Get(row1).setAuthorizations(new Authorizations(PRIVATE)));
assertEquals(0, r.size());
代码示例来源:origin: apache/hbase
assertEquals(1, r.size());
assertEquals(Bytes.toString(value1), Bytes.toString(CellUtil.cloneValue(r.rawCells()[0])));
r = table.get(new Get(row1).setAuthorizations(new Authorizations(PRIVATE)));
assertEquals(1, r.size());
assertEquals(Bytes.toString(value1), Bytes.toString(CellUtil.cloneValue(r.rawCells()[0])));
r = table.get(new Get(row1).setAuthorizations(new Authorizations(PRIVATE)));
assertEquals(0, r.size());
r = table.get(new Get(row1).setAuthorizations(new Authorizations(PRIVATE)));
assertEquals(0, r.size());
代码示例来源:origin: apache/hbase
@Test
public void testLabelsWithAppend() 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("a");
Put put = new Put(row1);
put.addColumn(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());
Append append = new Append(row1);
append.addColumn(fam, qual, Bytes.toBytes("b"));
table.append(append);
result = table.get(get);
assertTrue(result.isEmpty());
append = new Append(row1);
append.addColumn(fam, qual, Bytes.toBytes("c"));
append.setCellVisibility(new CellVisibility(SECRET));
table.append(append);
result = table.get(get);
assertTrue(!result.isEmpty());
}
}
代码示例来源:origin: apache/hbase
@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.addColumn(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());
}
}
代码示例来源:origin: apache/hbase
Cell current;
Get get = new Get(row);
get.setAuthorizations(new Authorizations(auths));
Result result = table2.get(get);
cellScanner = result.cellScanner();
代码示例来源:origin: apache/hbase
Cell current;
Get get = new Get(row);
get.setAuthorizations(new Authorizations(auths));
Result result = table2.get(get);
cellScanner = result.cellScanner();
代码示例来源:origin: apache/hbase
g.setAuthorizations(new Authorizations(SECRET, PRIVATE));
Result result = table.get(g);
assertEquals(0, result.rawCells().length);
g.setAuthorizations(new Authorizations(SECRET, PRIVATE));
result = table.get(g);
assertEquals(0, result.rawCells().length);
代码示例来源:origin: apache/hbase
@Override
public Void run() throws Exception {
try (Connection connection = ConnectionFactory.createConnection(conf);
Table table = connection.getTable(tableName)) {
// Test that we enforce the defined set
Get get = new Get(ROW_1);
get.setAuthorizations(new Authorizations(new String[] { SECRET, CONFIDENTIAL }));
Result result = table.get(get);
assertFalse("Inappropriate authorization", result.containsColumn(CF, Q1));
assertTrue("Missing authorization", result.containsColumn(CF, Q2));
assertTrue("Inappropriate filtering", result.containsColumn(CF, Q3));
// Test that we also enforce the defined set for the user if no auths are provided
get = new Get(ROW_1);
result = table.get(get);
assertFalse("Inappropriate authorization", result.containsColumn(CF, Q1));
assertTrue("Missing authorization", result.containsColumn(CF, Q2));
assertTrue("Inappropriate filtering", result.containsColumn(CF, Q3));
return null;
}
}
});
代码示例来源:origin: apache/hbase
.setReplicaId(3)
.setACL("test_user", new Permission(Permission.Action.READ))
.setAuthorizations(new Authorizations("test_label"))
.setPriority(3);
代码示例来源:origin: apache/hbase
out.setAuthorizations(new Authorizations(in.getAuthorizations().getLabels()));
代码示例来源:origin: apache/hbase
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);
代码示例来源:origin: org.apache.hbase/hbase-client
.setReplicaId(3)
.setACL("test_user", new Permission(Permission.Action.READ))
.setAuthorizations(new Authorizations("test_label"))
.setPriority(3);
代码示例来源:origin: org.apache.hbase/hbase-client
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);
内容来源于网络,如有侵权,请联系作者删除!