accumulo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Josh Elser <josh.el...@gmail.com>
Subject Re: Setting authorizations in code
Date Mon, 23 Sep 2013 16:22:36 GMT
I imagine that it might be useful to add a "wait" option to more (if
not all) of the client API where applicable (securityOperations being
one of them). We already have the resources with fate to handle these
transactions, so it would be nice to present that capability to users.

Benjamin, want to add a sleep for a second or two to your code to
verify that this is what you're seeing?



On Mon, Sep 23, 2013 at 12:06 PM, Eric Newton <eric.newton@gmail.com> wrote:
> Authorizations, like all settings, take a moment to propagate to all
> servers.
>
> -Eric
>
>
>
> On Mon, Sep 23, 2013 at 9:24 AM, Benjamin Parrish
> <benjamin.d.parrish@gmail.com> wrote:
>>
>> I am trying to set authorizations in code, but the scanner is always
>> returning the previous fetch of data using the previous authorizations.  I
>> am setting the Authorizations on the Connector, and then I get a new Scanner
>> after setting the Authorizations.
>>
>>
>> public Authorizations setAuthorizations(SecurityGroup[] authorizations) {
>> List<byte[]> authorizationList = new ArrayList<byte[]>();
>>
>>
>> for (SecurityGroup auth : authorizations) {
>> String groupString = Security.getName(auth);
>>
>>
>> byte[] groupBytes = groupString.getBytes();
>>
>>
>> authorizationList.add(groupBytes);
>> }
>>
>>
>> Authorizations auths = new Authorizations(authorizationList);
>>
>>
>> try {
>> connector.securityOperations().changeUserAuthorizations(_loggedInUser,
>> auths);
>>
>>
>> return auths;
>> } catch (AccumuloException e) {
>> // TODO Auto-generated catch block
>> e.printStackTrace();
>> } catch (AccumuloSecurityException e) {
>> // TODO Auto-generated catch block
>> e.printStackTrace();
>> }
>>
>>
>> return null;
>> }
>>
>>
>> public Scanner getScanner() {
>>         try {
>>         Authorizations auths = this.getAuthorizations();
>>
>>
>>
>> return connector.createScanner(TABLE, auths);
>> } catch (TableNotFoundException e) {
>> // TODO Auto-generated catch block
>> e.printStackTrace();
>> }
>>
>>
>>
>>         return null;
>> }
>>
>>
>> @Override
>> public Collection<Plate> filter(SecurityGroup[] authorizations, String
>> regEx) {
>> _db.setAuthorizations(authorizations);
>>
>>
>> Scanner scanner = _db.getScanner();
>>
>> String valueRegex = (regEx.equals("")) ? ".*" : regEx + ".*";
>>
>>
>>
>> scanner.fetchColumn(Plate.COLUMN_FAMILY, new Text(Plate.PLATE_QUALIFIER));
>>
>>
>>
>> IteratorSetting iter = new IteratorSetting(1, "regexfilter",
>> RegExFilter.class);
>>
>>
>>
>>         iter.addOption(RegExFilter.VALUE_REGEX, valueRegex);
>>
>>
>>
>>         scanner.addScanIterator(iter);
>>
>>
>> Iterator<Entry<Key, Value>> it = scanner.iterator();
>>
>>
>> Map<Text, Plate> map = new HashMap<Text, Plate>();
>>
>>
>>
>>     while (it.hasNext()) {
>>     Entry<Key,Value> entry = it.next();
>>
>>
>>
>>     Text rowId = entry.getKey().getRow();
>>
>>
>>
>>     if (map.containsKey(rowId)) {
>>     continue;
>>     }
>>
>>
>>
>>     Plate plate = new Plate(Plate.getMap(rowId, scanner));
>>
>>
>>
>>     map.put(rowId, plate);
>>     }
>>
>>
>> return map.values();
>> }
>
>

Mime
View raw message