Commit b2caea5d authored by Florian Fittkau's avatar Florian Fittkau

WiP

parent 893b2312
......@@ -5,7 +5,6 @@ import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
......@@ -15,23 +14,31 @@ import explorviz.live_trace_processing.debug.DebugFileByteBufferWriter;
import explorviz.live_trace_processing.record.misc.StringRegistryRecord;
public class MonitoringStringRegistry {
private static final Map<String, Integer> stringReg = new ConcurrentHashMap<String, Integer>();
private static final AtomicInteger stringRegIndex = new AtomicInteger(0);
private static final ConcurrentHashMap<String, Integer> stringReg = new ConcurrentHashMap<String, Integer>();
private static final AtomicInteger stringRegIndex = new AtomicInteger(1);
public static final Integer getIdForString(final String value) {
Integer result = stringReg.get(value);
if (result == null) {
result = stringRegIndex.getAndIncrement();
stringReg.put(value, result);
final Integer wasAbsent = stringReg.putIfAbsent(value, result);
final ByteBuffer stringRegistryRecord = buildStringRegistryRecord(value, result);
if (wasAbsent == null) {
final ByteBuffer stringRegistryRecord = buildStringRegistryRecord(value, result);
MonitoringController.sendOutBuffer(stringRegistryRecord);
MonitoringController.sendOutBuffer(stringRegistryRecord);
}
}
return result;
}
/**
* only accessed single threaded by TCPWriter
*
* @param value
* @return
*/
public static final Integer getIdForStringWithoutSending(final String value) {
Integer result = stringReg.get(value);
if (result == null) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment