예제 #1
0
  @Override
  public void initializeSecurity(TCredentials credentials, String principal, byte[] token)
      throws AccumuloSecurityException {
    try {
      // remove old settings from zookeeper first, if any
      IZooReaderWriter zoo = ZooReaderWriter.getInstance();
      synchronized (zooCache) {
        zooCache.clear();
        if (zoo.exists(ZKUserPath)) {
          zoo.recursiveDelete(ZKUserPath, NodeMissingPolicy.SKIP);
          log.info("Removed " + ZKUserPath + "/" + " from zookeeper");
        }

        // prep parent node of users with root username
        zoo.putPersistentData(ZKUserPath, principal.getBytes(UTF_8), NodeExistsPolicy.FAIL);

        constructUser(principal, ZKSecurityTool.createPass(token));
      }
    } catch (KeeperException e) {
      log.error("{}", e.getMessage(), e);
      throw new RuntimeException(e);
    } catch (InterruptedException e) {
      log.error("{}", e.getMessage(), e);
      throw new RuntimeException(e);
    } catch (AccumuloException e) {
      log.error("{}", e.getMessage(), e);
      throw new RuntimeException(e);
    }
  }
예제 #2
0
 public static void addLogEntry(Credentials credentials, LogEntry entry, ZooLock zooLock) {
   if (entry.extent.isRootTablet()) {
     String root = getZookeeperLogLocation();
     while (true) {
       try {
         IZooReaderWriter zoo = ZooReaderWriter.getInstance();
         if (zoo.isLockHeld(zooLock.getLockID())) {
           String[] parts = entry.filename.split("/");
           String uniqueId = parts[parts.length - 1];
           zoo.putPersistentData(
               root + "/" + uniqueId, entry.toBytes(), NodeExistsPolicy.OVERWRITE);
         }
         break;
       } catch (KeeperException e) {
         log.error(e, e);
       } catch (InterruptedException e) {
         log.error(e, e);
       } catch (IOException e) {
         log.error(e, e);
       }
       UtilWaitThread.sleep(1000);
     }
   } else {
     Mutation m = new Mutation(entry.getRow());
     m.put(entry.getColumnFamily(), entry.getColumnQualifier(), entry.getValue());
     update(credentials, zooLock, m, entry.extent);
   }
 }