Thank your reply this question.
1、 public void deleteUser(String licenseKey, String userId) throws
AccumuloException {
Connector conn = AccumuloClientSingleton.INSTANCE.getConnector();
BatchDeleter bd = null;
try {
conn.securityOperations().changeUserAuthorizations(AccumuloConstants.USER_NAME,
new Authorizations(licenseKey));
bd = conn.createBatchDeleter(AccumuloConstants.XT_USER, new
Authorizations(licenseKey), 10,
new BatchWriterConfig());
Set<Range> ranges = new HashSet<Range>();
ranges.add(new Range(userId));
bd.setRanges(ranges);
bd.delete();
} catch (Exception e) {
throw new AccumuloException("删除用户信息时异常", e);
} finally {
if (bd != null)
bd.close();
}
}
2、 public XtUser getUser(String licenseKey, String userAccount) throws
AccumuloException {
Connector conn = AccumuloClientSingleton.INSTANCE.getConnector();
Map<String, XtUser> map = new HashMap<String, XtUser>();
try {
conn.securityOperations().changeUserAuthorizations(AccumuloConstants.USER_NAME,
new Authorizations(licenseKey));
Scanner scanner =
conn.createScanner(AccumuloConstants.USER_NAME, new
Authorizations(licenseKey));
// 行迭代器
IteratorSetting it = new IteratorSetting(1, "WholeRowIterator",
WholeRowIterator.class);
scanner.addScanIterator(it);
for (Entry<Key, Value> entry : scanner) {
XtUser xtUser = new XtUser();
for (Entry<Key, Value> actualEntry :
WholeRowIterator.decodeRow(entry.getKey(), entry.getValue())
.entrySet()) {
String qualifier =
actualEntry.getKey().getColumnFamily().toString();
String value = actualEntry.getValue().toString();
if (qualifier.equals("role_id")) {
xtUser.setRoleId(value);
} else if (qualifier.equals("role_name")) {
xtUser.setRoleName("role_name");
} else if (qualifier.equals("user_account")) {
xtUser.setUserAccount(value);
}
map.put(xtUser.getUserAccount(), xtUser);
}
}
} catch (Exception e) {
throw new AccumuloException("获取用户消息异常", e);
}
return map.get(userAccount);
}
Method 1, method 2 will modify the user's permission, if concurrent case, is
also the method 1, method 2 and is called, should be how to deal with?
--
View this message in context:
http://apache-accumulo.1065345.n5.nabble.com/accumulo-query-delete-tp12965p12969.html
Sent from the Developers mailing list archive at Nabble.com.