本文整理了Java中backtype.storm.utils.Utils.serialize()
方法的一些代码示例,展示了Utils.serialize()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.serialize()
方法的具体详情如下:
包路径:backtype.storm.utils.Utils
类名称:Utils
方法名:serialize
[英]Go thrift gzip serializer
[中]Go thrift gzip序列化程序
代码示例来源:origin: alibaba/jstorm
@Override
public byte[] serialize(T obj) {
if (obj != null)
return Utils.serialize(obj);
else
return null;
}
代码示例来源:origin: alibaba/jstorm
public static Object trySerialize(Object obj) {
if (obj == null) {
return null;
}
try {
return serialize(obj);
} catch (Exception e) {
LOG.info("Failed to serialize. cause={}", e.getCause());
return null;
}
}
代码示例来源:origin: alibaba/jstorm
@Override
public void update_nimbus_detail(String hostPort, Map map) throws Exception {
cluster_state.set_ephemeral_node(Cluster.NIMBUS_SLAVE_DETAIL_SUBTREE + Cluster.ZK_SEPERATOR + hostPort, Utils.serialize(map));
}
代码示例来源:origin: alibaba/jstorm
@Override
public byte[] commit(BatchId id) throws FailedException {
LOG.info("Receive BatchId " + id);
if (currentId == null) {
currentId = id;
} else if (currentId.getId() >= id.getId()) {
LOG.info("Current BatchId is " + currentId + ", receive:" + id);
throw new RuntimeException();
}
currentId = id;
AtomicLong counter = (AtomicLong) counters.remove(id);
if (counter == null) {
counter = new AtomicLong(0);
}
LOG.info("Flush " + id + "," + counter);
return Utils.serialize(id);
}
代码示例来源:origin: alibaba/jstorm
private void persist(Map<Object, Object> val, boolean cleanup) throws IOException {
byte[] toWrite = Utils.serialize(val);
String newPath = _vs.createVersion();
FileUtils.writeByteArrayToFile(new File(newPath), toWrite);
_vs.succeedVersion(newPath);
if (cleanup)
_vs.cleanup(4);
}
}
代码示例来源:origin: alibaba/jstorm
public void setTempObject(String path, Object obj) throws Exception {
if (obj instanceof byte[]) {
cluster_state.set_ephemeral_node(path, (byte[]) obj);
} else if (obj instanceof String) {
cluster_state.set_ephemeral_node(path, ((String) obj).getBytes());
} else {
cluster_state.set_ephemeral_node(path, Utils.serialize(obj));
}
}
代码示例来源:origin: alibaba/mdrill
@Override
public void task_heartbeat(String stormId, int taskId, TaskHeartbeat info) {
String taskPath = Cluster.taskbeat_path(stormId, taskId);
byte[] taskData = Utils.serialize(info);
cluster_state.set_data(taskPath, taskData);
}
代码示例来源:origin: alibaba/jstorm
public void setObject(String path, Object obj) throws Exception {
if (obj instanceof byte[]) {
cluster_state.set_data(path, (byte[]) obj);
} else if (obj instanceof String) {
cluster_state.set_data(path, ((String) obj).getBytes());
} else {
cluster_state.set_data(path, Utils.serialize(obj));
}
}
代码示例来源:origin: alibaba/mdrill
@Override
public void set_task(String stormId, int taskId, TaskInfo info) {
String taskPath = Cluster.task_path(stormId, taskId);
byte[] taskData = Utils.serialize(info);
cluster_state.set_data(taskPath, taskData);
}
代码示例来源:origin: alibaba/mdrill
private void persist(Map<Object, Object> val) throws IOException {
byte[] toWrite = Utils.serialize(val);
String newPath = _vs.createVersion();
FileUtils.writeByteArrayToFile(new File(newPath), toWrite);
_vs.succeedVersion(newPath);
_vs.cleanup(4);
}
}
代码示例来源:origin: alibaba/mdrill
@Override
public void activate_storm(String stormId, StormBase stormBase) {
String stormPath = Cluster.storm_path(stormId);
byte[] stormBaseData = Utils.serialize(stormBase);
cluster_state.set_data(stormPath, stormBaseData);
}
代码示例来源:origin: alibaba/mdrill
@Override
public void supervisor_heartbeat(String supervisorId, SupervisorInfo info) {
String supervisorPath = Cluster.supervisor_path(supervisorId);
byte[] infoData = Utils.serialize(info);
cluster_state.set_ephemeral_node(supervisorPath, infoData);
}
代码示例来源:origin: alibaba/mdrill
@Override
public void higo_heartbeat(String tablename,Integer task, SolrInfo info) {
String tablePath = Cluster.higo_path(tablename,task);
byte[] infoData = Utils.serialize(info);
cluster_state.set_ephemeral_node(tablePath, infoData);
}
代码示例来源:origin: alibaba/mdrill
@Override
public void set_assignment(String stormId, Assignment info) {
cluster_state.set_data(Cluster.assignment_path(stormId),
Utils.serialize(info));
}
代码示例来源:origin: alibaba/mdrill
@Override
public BoltDeclarer customGrouping(String componentId, String streamId, CustomStreamGrouping grouping) {
return grouping(componentId, streamId, Grouping.custom_serialized(Utils.serialize(grouping)));
}
代码示例来源:origin: alibaba/jstorm
public static Bolt mkBolt(Map<GlobalStreamId, Grouping> inputs, IBolt bolt,
HashMap<String, StreamInfo> output, Integer p) {
ComponentCommon common = mkComponentcommon(inputs, output, p);
byte[] boltSer = Utils.serialize(bolt);
ComponentObject component = ComponentObject.serialized_java(boltSer);
return new Bolt(component, common);
}
代码示例来源:origin: alibaba/mdrill
public static Bolt mkAckerBolt(Map<GlobalStreamId, Grouping> inputs,
IBolt bolt, HashMap<String, StreamInfo> output, Integer p) {
ComponentCommon common = mkAckerComponentcommon(inputs, output, p);
byte[] boltSer = Utils.serialize(bolt);
ComponentObject component = ComponentObject.serialized_java(boltSer);
return new Bolt(component, common);
}
代码示例来源:origin: alibaba/jstorm
/**
* create local topology files in blobstore and sync metadata to zk
*/
private void setupStormCode(String topologyId, String tmpJarLocation,
Map<Object, Object> stormConf, StormTopology topology, boolean update)
throws Exception {
String codeKey = StormConfig.master_stormcode_key(topologyId);
String confKey = StormConfig.master_stormconf_key(topologyId);
String codeKeyBak = StormConfig.master_stormcode_bak_key(topologyId);
// in local mode there is no jar
if (tmpJarLocation != null) {
setupJar(tmpJarLocation, topologyId, update);
}
if (update) {
backupBlob(codeKey, codeKeyBak, topologyId);
}
createOrUpdateBlob(confKey, Utils.serialize(stormConf), update, topologyId);
createOrUpdateBlob(codeKey, Utils.serialize(topology), update, topologyId);
}
代码示例来源:origin: alibaba/mdrill
@Override
public void update_storm(String stormId, StormStatus newElems) {
/**
* FIXME, not sure where the old exist error or not The raw code
* (set-data cluster-state (storm-path storm-id) (-> (storm-base this
* storm-id nil) (merge new-elems) Utils/serialize)))
*/
StormBase base = this.storm_base(stormId, null);
if (base != null) {
base.setStatus(newElems);
cluster_state.set_data(Cluster.storm_path(stormId),
Utils.serialize(base));
}
}
代码示例来源:origin: alibaba/jstorm
public static void write_nimbus_topology_conf(String topologyId, Map topoConf, NimbusData data)
throws Exception {
String confKey = master_stormconf_key(topologyId);
AtomicOutputStream out = data.getBlobStore().updateBlob(confKey);
out.write(Utils.serialize(topoConf));
out.close();
if (data.getBlobStore() instanceof LocalFsBlobStore) {
NimbusInfo nimbusInfo = data.getNimbusHostPortInfo();
int versionForKey = BlobStoreUtils.getVersionForKey(confKey, nimbusInfo, data.getConf());
data.getStormClusterState().setup_blobstore(confKey, nimbusInfo, versionForKey);
}
}
内容来源于网络,如有侵权,请联系作者删除!