Java Code Examples for backtype.storm.utils.Utils#javaDeserialize()

The following examples show how to use backtype.storm.utils.Utils#javaDeserialize() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RocksTTLDBCache.java    From jstorm with Apache License 2.0 6 votes vote down vote up
@Override
public Object get(String key) {
    for (Entry<Integer, ColumnFamilyHandle> entry : windowHandlers.entrySet()) {
        try {
            byte[] data = ttlDB.get(entry.getValue(), key.getBytes());
            if (data != null) {
                try {
                    return Utils.javaDeserialize(data);
                } catch (Exception e) {
                    LOG.error("Failed to deserialize obj of " + key);
                    ttlDB.remove(entry.getValue(), key.getBytes());
                    return null;
                }
            }
        } catch (Exception ignored) {
        }
    }

    return null;
}
 
Example 2
Source File: StormConfig.java    From jstorm with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public static Object readLocalObject(String topologyId, String readFile) throws IOException {
    String errMsg = "Failed to get topology configuration of " + topologyId + " file:" + readFile;

    byte[] bconf = FileUtils.readFileToByteArray(new File(readFile));
    if (bconf == null) {
        errMsg += ", failed to read";
        LOG.error(errMsg);
        throw new IOException(errMsg);
    }

    Object ret;
    try {
        ret = Utils.javaDeserialize(bconf);
    } catch (Exception e) {
        errMsg += ", failed to serialize the data";
        LOG.error(errMsg);
        throw new IOException(errMsg);
    }

    return ret;
}
 
Example 3
Source File: SimpleBolt.java    From jstorm with Apache License 2.0 5 votes vote down vote up
@Override
public void revert(BatchId id, byte[] commitResult) {
    LOG.info("Receive BatchId " + id);

    BatchId failedId = (BatchId) Utils.javaDeserialize(commitResult);

    if (!failedId.equals(id)) {
        LOG.info("Deserialized error  " + id);
    }
}
 
Example 4
Source File: JavaSerializer.java    From jstorm with Apache License 2.0 5 votes vote down vote up
@Override
public T deserialize(byte[] b) {
    if (b != null)
        return (T) Utils.javaDeserialize(b);
    else
        return null;
}
 
Example 5
Source File: TridentTopology.java    From jstorm with Apache License 2.0 5 votes vote down vote up
private static boolean isIdentityPartition(PartitionNode n) {
    Grouping g = n.thriftGrouping;
    if(g.is_set_custom_serialized()) {
        CustomStreamGrouping csg = (CustomStreamGrouping) Utils.javaDeserialize(g.get_custom_serialized(), Serializable.class);
        return csg instanceof IdentityGrouping;
    }
    return false;
}
 
Example 6
Source File: RocksDBCache.java    From jstorm with Apache License 2.0 4 votes vote down vote up
protected Object deserialize(byte[] data) {
    return Utils.javaDeserialize(data);
}
 
Example 7
Source File: StormConfig.java    From jstorm with Apache License 2.0 4 votes vote down vote up
public static Map read_nimbus_topology_conf(String topologyId, BlobStore blobStore)
        throws IOException, KeyNotFoundException {
    return Utils.javaDeserialize(blobStore.readBlob(master_stormconf_key(topologyId)), Map.class);
}
 
Example 8
Source File: StormConfig.java    From jstorm with Apache License 2.0 4 votes vote down vote up
public static StormTopology read_nimbus_topology_code(String topologyId, BlobStore blobStore)
        throws IOException, KeyNotFoundException {
    return Utils.javaDeserialize(blobStore.readBlob(master_stormcode_key(topologyId)), StormTopology.class);
}
 
Example 9
Source File: BatchBoltExecutor.java    From jstorm with Apache License 2.0 4 votes vote down vote up
private IBatchBolt newTransactionalBolt() {
    return Utils.javaDeserialize(_boltSer, IBatchBolt.class);
}