Search in sources :

Example 6 with TDeserializer

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);
    }
}
Also used : TDeserializer(org.apache.thrift.TDeserializer) LocalStateData(org.apache.storm.generated.LocalStateData) HashMap(java.util.HashMap) ThriftSerializedObject(org.apache.storm.generated.ThriftSerializedObject) File(java.io.File) IOException(java.io.IOException)

Example 7 with TDeserializer

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;
}
Also used : TDeserializer(org.apache.thrift.TDeserializer) TBase(org.apache.thrift.TBase) ThriftSerializedObject(org.apache.storm.generated.ThriftSerializedObject)

Example 8 with TDeserializer

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;
}
Also used : TDeserializer(org.apache.thrift.TDeserializer)

Example 9 with TDeserializer

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);
    }
}
Also used : TException(org.apache.thrift.TException) TDeserializer(org.apache.thrift.TDeserializer)

Example 10 with TDeserializer

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;
}
Also used : TDeserializer(org.apache.thrift.TDeserializer) TAgentStat(com.navercorp.pinpoint.thrift.dto.TAgentStat) AgentStat(com.navercorp.pinpoint.web.vo.AgentStat) TAgentStat(com.navercorp.pinpoint.thrift.dto.TAgentStat) TJvmGc(com.navercorp.pinpoint.thrift.dto.TJvmGc) ArrayList(java.util.ArrayList) AgentStatMemoryGcBo(com.navercorp.pinpoint.common.server.bo.AgentStatMemoryGcBo)

Aggregations

TDeserializer (org.apache.thrift.TDeserializer)30 TException (org.apache.thrift.TException)19 IOException (java.io.IOException)8 TBase (org.apache.thrift.TBase)6 Table (org.apache.hadoop.hive.metastore.api.Table)4 TBinaryProtocol (org.apache.cassandra.thrift.TBinaryProtocol)3 HCatException (org.apache.hive.hcatalog.common.HCatException)3 ThriftSerializedObject (org.apache.storm.generated.ThriftSerializedObject)3 TJSONProtocol (org.apache.thrift.protocol.TJSONProtocol)3 LoggerFactory (org.slf4j.LoggerFactory)3 RT (clojure.lang.RT)2 FileNotFoundException (java.io.FileNotFoundException)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 SlicePredicate (org.apache.cassandra.thrift.SlicePredicate)2 ExecuteException (org.apache.commons.exec.ExecuteException)2 Partition (org.apache.hadoop.hive.metastore.api.Partition)2 ParseException (org.json.simple.parser.ParseException)2 Example (com.airbnb.aerosolve.core.Example)1 AgentStatMemoryGcBo (com.navercorp.pinpoint.common.server.bo.AgentStatMemoryGcBo)1