Github user mjwall commented on a diff in the pull request:

    https://github.com/apache/accumulo/pull/107#discussion_r65575725
  
    --- Diff: 
server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectWriteAheadLogs.java
 ---
    @@ -170,76 +175,117 @@ boolean holdsLock(HostAndPort addr) {
         }
       }
     
    -  private int removeFiles(Map<String,Path> nameToFileMap, 
Map<String,ArrayList<Path>> serverToFileMap, Map<String,Path> sortedWALogs, 
final GCStatus status) {
    -    AccumuloConfiguration conf = 
ServerConfiguration.getSystemConfiguration(instance);
    +  private AccumuloConfiguration getConfig() {
    +    return ServerConfiguration.getSystemConfiguration(instance);
    +  }
    +
    +  @VisibleForTesting
    +  int removeFiles(Map<String,Path> nameToFileMap, 
Map<String,ArrayList<Path>> serverToFileMap, Map<String,Path> sortedWALogs, 
final GCStatus status) {
    +    // TODO: remove nameToFileMap from method signature, not used here I 
don't think
    +    AccumuloConfiguration conf = getConfig();
         for (Entry<String,ArrayList<Path>> entry : serverToFileMap.entrySet()) 
{
           if (entry.getKey().isEmpty()) {
    -        // old-style log entry, just remove it
    -        for (Path path : entry.getValue()) {
    -          log.debug("Removing old-style WAL " + path);
    -          try {
    -            if (!useTrash || !fs.moveToTrash(path))
    -              fs.deleteRecursively(path);
    -            status.currentLog.deleted++;
    -          } catch (FileNotFoundException ex) {
    -            // ignored
    -          } catch (IOException ex) {
    -            log.error("Unable to delete wal " + path + ": " + ex);
    -          }
    -        }
    +        removeOldStyleWAL(entry, status);
           } else {
    -        HostAndPort address = AddressUtil.parseAddress(entry.getKey(), 
false);
    -        if (!holdsLock(address)) {
    -          for (Path path : entry.getValue()) {
    -            log.debug("Removing WAL for offline server " + path);
    -            try {
    -              if (!useTrash || !fs.moveToTrash(path))
    -                fs.deleteRecursively(path);
    -              status.currentLog.deleted++;
    -            } catch (FileNotFoundException ex) {
    -              // ignored
    -            } catch (IOException ex) {
    -              log.error("Unable to delete wal " + path + ": " + ex);
    -            }
    -          }
    -          continue;
    -        } else {
    -          Client tserver = null;
    -          try {
    -            tserver = ThriftUtil.getClient(new 
TabletClientService.Client.Factory(), address, conf);
    -            tserver.removeLogs(Tracer.traceInfo(), 
SystemCredentials.get().toThrift(instance), paths2strings(entry.getValue()));
    -            log.debug("deleted " + entry.getValue() + " from " + 
entry.getKey());
    -            status.currentLog.deleted += entry.getValue().size();
    -          } catch (TException e) {
    -            log.warn("Error talking to " + address + ": " + e);
    -          } finally {
    -            if (tserver != null)
    -              ThriftUtil.returnClient(tserver);
    -          }
    -        }
    +        removeWALFile(entry, conf, status);
           }
         }
    -
         for (Path swalog : sortedWALogs.values()) {
    -      log.debug("Removing sorted WAL " + swalog);
    +      removeSortedWAL(swalog);
    +    }
    +    return 0;
    +  }
    +
    +  @VisibleForTesting
    +  void removeSortedWAL(Path swalog) {
    +    log.debug("Removing sorted WAL " + swalog);
    +    try {
    +      if (!useTrash || !fs.moveToTrash(swalog)) {
    --- End diff --
    
    I'll add a note to the follow on ticket to really cleanup this class if 
that is ok?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to