Rename refMap and its mutator methods

This commit is contained in:
Samuel H. Kenyon 2014-04-04 11:36:54 -04:00
parent 21e2747085
commit 587d9a7f6c

View File

@ -57,20 +57,20 @@ public class HashDbIngestModule extends IngestModuleAdapter implements FileInges
private List<HashDb> knownBadHashSets = new ArrayList<>(); private List<HashDb> knownBadHashSets = new ArrayList<>();
private List<HashDb> knownHashSets = new ArrayList<>(); private List<HashDb> knownHashSets = new ArrayList<>();
private long jobID; private long jobID;
static HashMap<Long, Long> refMap = new HashMap<>(); static HashMap<Long, Long> moduleRefCount = new HashMap<>();
static AtomicLong totalKnownBadCount = new AtomicLong(0); static AtomicLong totalKnownBadCount = new AtomicLong(0);
static AtomicLong totalCalctime = new AtomicLong(0); static AtomicLong totalCalctime = new AtomicLong(0);
static AtomicLong totalLookuptime = new AtomicLong(0); static AtomicLong totalLookuptime = new AtomicLong(0);
private static synchronized void refMapIncrement(long jobID) { private static synchronized void moduleRefCountIncrement(long jobID) {
long count = refMap.containsKey(jobID) ? refMap.get(jobID) : 0; long count = moduleRefCount.containsKey(jobID) ? moduleRefCount.get(jobID) : 0;
refMap.put(jobID, count + 1); moduleRefCount.put(jobID, count + 1);
} }
private static synchronized long refMapDecrementAndGet(long jobID) { private static synchronized long moduleRefCountDecrementAndGet(long jobID) {
if (refMap.containsKey(jobID)) { if (moduleRefCount.containsKey(jobID)) {
long count = refMap.get(jobID); long count = moduleRefCount.get(jobID);
refMap.put(jobID, --count); moduleRefCount.put(jobID, --count);
return count; return count;
} else { } else {
return 0; return 0;
@ -84,7 +84,7 @@ public class HashDbIngestModule extends IngestModuleAdapter implements FileInges
@Override @Override
public void startUp(org.sleuthkit.autopsy.ingest.IngestJobContext context) throws IngestModuleException { public void startUp(org.sleuthkit.autopsy.ingest.IngestJobContext context) throws IngestModuleException {
jobID = context.getJobId(); jobID = context.getJobId();
refMapIncrement(jobID); moduleRefCountIncrement(jobID);
getEnabledHashSets(hashDbManager.getKnownBadFileHashSets(), knownBadHashSets); getEnabledHashSets(hashDbManager.getKnownBadFileHashSets(), knownBadHashSets);
if (knownBadHashSets.isEmpty()) { if (knownBadHashSets.isEmpty()) {
services.postMessage(IngestMessage.createWarningMessage( services.postMessage(IngestMessage.createWarningMessage(
@ -316,7 +316,7 @@ public class HashDbIngestModule extends IngestModuleAdapter implements FileInges
@Override @Override
public void shutDown(boolean ingestJobCancelled) { public void shutDown(boolean ingestJobCancelled) {
if (refMapDecrementAndGet(jobID) == 0) { if (moduleRefCountDecrementAndGet(jobID) == 0) {
if ((!knownBadHashSets.isEmpty()) || (!knownHashSets.isEmpty())) { if ((!knownBadHashSets.isEmpty()) || (!knownHashSets.isEmpty())) {
StringBuilder detailsSb = new StringBuilder(); StringBuilder detailsSb = new StringBuilder();
//details //details