@Override public byte[] serialize(T obj) { if (obj != null) return Utils.serialize(obj); else return null; }
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; } }
@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)); }
@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); }
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); } }
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)); } }
@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); }
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)); } }
@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); }
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); } }
@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); }
@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); }
@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); }
@Override public void set_assignment(String stormId, Assignment info) { cluster_state.set_data(Cluster.assignment_path(stormId), Utils.serialize(info)); }
@Override public BoltDeclarer customGrouping(String componentId, String streamId, CustomStreamGrouping grouping) { return grouping(componentId, streamId, Grouping.custom_serialized(Utils.serialize(grouping))); }
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); }
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); }
/** * 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); }
@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)); } }
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); } }