Esempio n. 1
0
 public static void removeUnusedWALEntries(
     KeyExtent extent, List<LogEntry> logEntries, ZooLock zooLock) {
   if (extent.isRootTablet()) {
     for (LogEntry entry : logEntries) {
       String root = getZookeeperLogLocation();
       while (true) {
         try {
           IZooReaderWriter zoo = ZooReaderWriter.getInstance();
           if (zoo.isLockHeld(zooLock.getLockID()))
             zoo.recursiveDelete(root + "/" + entry.filename, NodeMissingPolicy.SKIP);
           break;
         } catch (Exception e) {
           log.error(e, e);
         }
         UtilWaitThread.sleep(1000);
       }
     }
   } else {
     Mutation m = new Mutation(extent.getMetadataEntry());
     for (LogEntry entry : logEntries) {
       m.putDelete(LogColumnFamily.NAME, new Text(entry.toString()));
     }
     update(SystemCredentials.get(), zooLock, m, extent);
   }
 }
Esempio n. 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);
   }
 }