use of org.apache.storm.generated.ThriftSerializedObject in project storm by apache.
the class LocalState method partialDeserializeLatestVersion.
private Map<String, ThriftSerializedObject> partialDeserializeLatestVersion(TDeserializer td) {
try {
String latestPath = _vs.mostRecentVersionPath();
Map<String, ThriftSerializedObject> result = new HashMap<>();
if (latestPath != null) {
byte[] serialized = FileUtils.readFileToByteArray(new File(latestPath));
if (serialized.length == 0) {
LOG.warn("LocalState file '{}' contained no data, resetting state", latestPath);
} else {
if (td == null) {
td = new TDeserializer();
}
LocalStateData data = new LocalStateData();
td.deserialize(data, serialized);
result = data.get_serialized_parts();
}
}
return result;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of org.apache.storm.generated.ThriftSerializedObject in project storm by apache.
the class LocalState method get.
public TBase get(String key) {
TDeserializer td = new TDeserializer();
Map<String, ThriftSerializedObject> partial = partialSnapshot(td);
ThriftSerializedObject tso = partial.get(key);
TBase ret = null;
if (tso != null) {
ret = deserialize(tso, td);
}
return ret;
}
use of org.apache.storm.generated.ThriftSerializedObject in project storm by apache.
the class LocalState method deserializeLatestVersion.
private Map<String, TBase> deserializeLatestVersion() throws IOException {
Map<String, TBase> result = new HashMap<>();
TDeserializer td = new TDeserializer();
for (Map.Entry<String, ThriftSerializedObject> ent : partialDeserializeLatestVersion(td).entrySet()) {
result.put(ent.getKey(), deserialize(ent.getValue(), td));
}
return result;
}
use of org.apache.storm.generated.ThriftSerializedObject in project storm by apache.
the class LocalState method put.
public synchronized void put(String key, TBase val, boolean cleanup) {
Map<String, ThriftSerializedObject> curr = partialSnapshot(null);
TSerializer ser = new TSerializer();
curr.put(key, serialize(val, ser));
persistInternal(curr, ser, cleanup);
}
Aggregations