当前位置: 首页>>代码示例>>Java>>正文


Java Utils.deserialize方法代码示例

本文整理汇总了Java中backtype.storm.utils.Utils.deserialize方法的典型用法代码示例。如果您正苦于以下问题:Java Utils.deserialize方法的具体用法?Java Utils.deserialize怎么用?Java Utils.deserialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在backtype.storm.utils.Utils的用法示例。


在下文中一共展示了Utils.deserialize方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readLocalObject

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
/**
 * stormconf has mergered into clusterconf
 * 
 * @param conf
 * @param topologyId
 * @return Map
 * @throws IOException
 */
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 += ", due to failed to read";
		LOG.error(errMsg);
		throw new IOException(errMsg);
	}

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

	return ret;
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:33,代码来源:StormConfig.java

示例2: readLocalObject

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
/**
 * stormconf has mergered into clusterconf
 * 
 * @param conf
 * @param topologyId
 * @return Map
 * @throws IOException
 */
@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 += ", due to failed to read";
		LOG.error(errMsg);
		throw new IOException(errMsg);
	}

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

	return ret;
}
 
开发者ID:songtk,项目名称:learn_jstorm,代码行数:34,代码来源:StormConfig.java

示例3: load

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
/**
 * Loads an instance of <code>class</code> from <code>path</code> if possible. Does not check whether
 * <code>path</code> exists.
 * 
 * @param <T> the type of object to load
 * @param path the path to save to
 * @param cls the type of the object to load
 * @return the instance or <b>null</b>
 * @throws SignalException in case of I/O problems or if the object in <code>path</code> is not of type 
 *   <code>cls</code>
 */
private <T> T load(String path, Class<T> cls) throws SignalException {
    try {
        T result;
        byte[] data = client.getData().forPath(path);
        if (null != data) {
            Object obj = Utils.deserialize(data);
            if (null != obj && !(cls.isInstance(obj))) {
                throw new SignalException("path " + path + " contains " + obj + " as data rather than a " 
                    + cls.getName());
            }
            result = cls.cast(obj);
        } else {
            result = null;
        }
        return result;
    } catch (Exception e) {
        throw new SignalException(e);
    }
}
 
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:31,代码来源:PortManager.java

示例4: isIdentityPartition

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
private static boolean isIdentityPartition(PartitionNode n) {
    Grouping g = n.thriftGrouping;
    if(g.is_set_custom_serialized()) {
        CustomStreamGrouping csg = (CustomStreamGrouping) Utils.deserialize(g.get_custom_serialized());
        return csg instanceof IdentityGrouping;
    }
    return false;
}
 
开发者ID:greeenSY,项目名称:Tstream,代码行数:9,代码来源:TridentTopology.java

示例5: revert

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
@Override
public void revert(BatchId id, byte[] commitResult) {
	LOG.info("Receive BatchId " + id);
	
	BatchId failedId = (BatchId)Utils.deserialize(commitResult);
	
	if (failedId.equals(id) == false) {
		LOG.info("Deserialized error  " + id);
	}
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:11,代码来源:SimpleBolt.java

示例6: revert

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
@Override
public void revert(BatchId id, byte[] commitResult) {
	CommitedValue commitedValue = (CommitedValue) Utils
			.deserialize(commitResult);
	if (commitedValue == null) {
		LOG.warn("Failed to deserialize commited value");
		return;
	}

	revertQueue.offer(commitedValue);
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:12,代码来源:DBBolt.java

示例7: getData

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
public static String getData(DistributedClusterState zkClusterState,
		String path) throws Exception {
	byte[] data = zkClusterState.get_data(path, false);
	if (data == null || data.length == 0) {
		return null;
	}

	Object obj = Utils.deserialize(data, null);

	return obj.toString();
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:12,代码来源:ZkTool.java

示例8: getData

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
public static String getData(DistributedClusterState zkClusterState,
                             String path) throws Exception {
    byte[] data = zkClusterState.get_data(path, false);
    if (data == null || data.length == 0) {
        return null;
    }

    Object obj = Utils.deserialize(data, null);

    return obj.toString();
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:12,代码来源:ZkTool.java

示例9: getAssignment

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
/**
 * Returns the assignment for the given <code>topology</code> from the zookeeper connection 
 * <code>framework</code>.
 * 
 * @param framework the Curator framework connection to the Zookeeper
 * @param topology the topology to set the assignment for
 * @return the assignment for <code>topology</code>
 * @throws IOException in case of writing problems
 */
public static Assignment getAssignment(CuratorFramework framework, TopologyInfo topology) throws IOException {
    Assignment result = null;
    try {
        byte[] data = framework.getData().forPath(ASSIGNMENTS_PREFIX + topology.get_id());
        Object o = Utils.deserialize(data);
        if (o instanceof Assignment) {
            result = (Assignment) o;
        }
    } catch (Exception e) {
        throw new IOException(e.getMessage());
    }
    return result;
}
 
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:23,代码来源:ZkUtils.java

示例10: getWorkerBeats

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
/**
 * Returns the actual worker beats for the given <code>topology</code>. For handling the worker ids, please refer to
 * {@link HostPort#WORKERBEATS_HOSTPORT_PARSER}.
 * 
 * @param framework the Curator framework connection to the Zookeeper
 * @param topology the topology to set the assignment for
 * @return the alive workers in format node-port with associated alive time stamp (may be <b>null</b> if 
 *     there are no workers)
 * @throws IOException in case of errors accessing the heartbeats
 */
public static Map<String, Long> getWorkerBeats(CuratorFramework framework, TopologyInfo topology) 
    throws IOException {
    //  format: (str (workerbeat-storm-root storm-id) "/" node "-" port))
    Map<String, Long> result = null;
    try {
        String wpPath = WORKERBEATS_PREFIX + topology.get_id();
        List<String> children = framework.getChildren().forPath(wpPath);
        for (String child : children) {
            byte[] data = framework.getData().forPath(wpPath + "/" + child);
            Object o = Utils.deserialize(data);
            if (o instanceof WorkerHeartbeat) {
                WorkerHeartbeat beat = (WorkerHeartbeat) o;
                if (null == result) {
                    result = new HashMap<String, Long>();
                }
                if (beat.time_secs instanceof Long)  {
                    result.put(child, (Long) beat.time_secs);
                } else if (beat.time_secs instanceof Number)  {
                    result.put(child, ((Number) beat.time_secs).longValue());
                } else {
                    result.put(child, UNKNOWN_TIME);
                }
            }
        }
    } catch (Exception e) {
        throw new IOException(e.getMessage());
    }
    return result;
}
 
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:40,代码来源:ZkUtils.java

示例11: newTransactionalBolt

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
private IBatchBolt newTransactionalBolt() {
	return (IBatchBolt) Utils.deserialize(_boltSer);
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:4,代码来源:BatchBoltExecutor.java

示例12: maybe_deserialize

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
public static Object maybe_deserialize(byte[] data) {
	if (data == null) {
		return null;
	}
	return Utils.deserialize(data);
}
 
开发者ID:greeenSY,项目名称:Tstream,代码行数:7,代码来源:Cluster.java


注:本文中的backtype.storm.utils.Utils.deserialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。