use of org.apache.thrift.TDeserializer 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.thrift.TDeserializer 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.thrift.TDeserializer in project storm by apache.
the class Utils method getDes.
private static TDeserializer getDes() {
TDeserializer des = threadDes.get();
if (des == null) {
des = new TDeserializer();
threadDes.set(des);
}
return des;
}
use of org.apache.thrift.TDeserializer in project buck by facebook.
the class ThriftUtil method deserialize.
public static void deserialize(ThriftProtocol protocol, byte[] source, TBase<?, ?> dest) throws ThriftException {
TDeserializer deserializer = new TDeserializer(getProtocolFactory(protocol));
dest.clear();
try {
deserializer.deserialize(dest, source);
} catch (TException e) {
throw new ThriftException(e);
}
}
use of org.apache.thrift.TDeserializer in project pinpoint by naver.
the class LegacyAgentStatMapper method readAgentStatThriftDto.
// FIXME (2014.08) Legacy support for TAgentStat Thrift DTO stored directly into hbase.
@Deprecated
private List<AgentStat> readAgentStatThriftDto(String agentId, long timestamp, byte[] tAgentStatByteArray) throws TException {
// CompactProtocol used
TDeserializer deserializer = new TDeserializer(factory);
TAgentStat tAgentStat = new TAgentStat();
deserializer.deserialize(tAgentStat, tAgentStatByteArray);
TJvmGc gc = tAgentStat.getGc();
if (gc == null) {
return Collections.emptyList();
}
AgentStatMemoryGcBo.Builder memoryGcBoBuilder = new AgentStatMemoryGcBo.Builder(tAgentStat.getAgentId(), tAgentStat.getStartTimestamp(), tAgentStat.getTimestamp());
memoryGcBoBuilder.gcType(gc.getType().name());
memoryGcBoBuilder.jvmMemoryHeapUsed(gc.getJvmMemoryHeapUsed());
memoryGcBoBuilder.jvmMemoryHeapMax(gc.getJvmMemoryHeapMax());
memoryGcBoBuilder.jvmMemoryNonHeapUsed(gc.getJvmMemoryNonHeapUsed());
memoryGcBoBuilder.jvmMemoryNonHeapMax(gc.getJvmMemoryNonHeapMax());
memoryGcBoBuilder.jvmGcOldCount(gc.getJvmGcOldCount());
memoryGcBoBuilder.jvmGcOldTime(gc.getJvmGcOldTime());
AgentStat agentStat = new AgentStat(agentId, timestamp);
AgentStatMemoryGcBo agentStatMemoryGcBo = memoryGcBoBuilder.build();
agentStat.setGcType(agentStatMemoryGcBo.getGcType());
agentStat.setGcOldCount(agentStatMemoryGcBo.getJvmGcOldCount());
agentStat.setGcOldTime(agentStatMemoryGcBo.getJvmGcOldTime());
agentStat.setHeapUsed(agentStatMemoryGcBo.getJvmMemoryHeapUsed());
agentStat.setHeapMax(agentStatMemoryGcBo.getJvmMemoryHeapMax());
agentStat.setNonHeapUsed(agentStatMemoryGcBo.getJvmMemoryNonHeapUsed());
agentStat.setNonHeapMax(agentStatMemoryGcBo.getJvmMemoryNonHeapMax());
List<AgentStat> result = new ArrayList<>(1);
result.add(agentStat);
return result;
}
Aggregations