Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.DelayQueue;
import java.util.concurrent.TimeUnit;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Expand Down Expand Up @@ -121,6 +122,7 @@ public enum CommandType {
private int numThreads;
private long highestTimestamp;
private List<AuditReplayThread> threads;
private DelayQueue<AuditReplayCommand> commandQueue;
private Function<Long, Long> relativeToAbsoluteTimestamp;
private AuditCommandParser commandParser;

Expand Down Expand Up @@ -172,8 +174,9 @@ public Long apply(Long input) {
LOG.info("Starting " + numThreads + " threads");

threads = new ArrayList<>();
commandQueue = new DelayQueue<>();
for (int i = 0; i < numThreads; i++) {
AuditReplayThread thread = new AuditReplayThread(context);
AuditReplayThread thread = new AuditReplayThread(context, commandQueue);
threads.add(thread);
thread.start();
}
Expand All @@ -188,11 +191,7 @@ public void map(LongWritable lineNum, Text inputLine, Mapper.Context context)
if (delay > MAX_READAHEAD_MS) {
Thread.sleep(delay - (MAX_READAHEAD_MS / 2));
}
int idx = cmd.getSrc().hashCode() % numThreads;
if (idx < 0) {
idx += numThreads;
}
threads.get(idx).addToQueue(cmd);
commandQueue.put(cmd);
highestTimestamp = cmd.getAbsoluteTimestamp();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ public class AuditReplayThread extends Thread {
private Map<REPLAYCOUNTERS, Counter> replayCountersMap = new HashMap<>();
private Map<String, Counter> individualCommandsMap = new HashMap<>();

AuditReplayThread(Mapper.Context mapperContext) throws IOException {
commandQueue = new DelayQueue<>();
AuditReplayThread(Mapper.Context mapperContext, DelayQueue<AuditReplayCommand> queue)
throws IOException {
commandQueue = queue;
Configuration mapperConf = mapperContext.getConfiguration();
String namenodeURI = mapperConf.get(WorkloadDriver.NN_URI);
startTimestampMs = mapperConf.getLong(WorkloadDriver.START_TIMESTAMP_MS, -1);
Expand Down