public Number connect(Map<String, Object> conf, TopologyContext context) throws IOException, NoOutputException { JSONObject setupInfo = new JSONObject(); setupInfo.put("pidDir", context.getPIDDir()); setupInfo.put("conf", conf); setupInfo.put("context", context); writeMessage(setupInfo); Number pid = (Number) ((JSONObject) readMessage()).get("pid"); return pid; }
private Object readMessage() throws IOException, NoOutputException { try { return JSONValue.parseWithException(readString()); } catch (ParseException e) { throw new IOException(e); } }
private void writeMessage(Object msg) throws IOException { writeString(JSONValue.toJSONString(msg)); }
public void writeTaskIds(List<Integer> taskIds) throws IOException { writeMessage(taskIds); }
public ShellMsg readShellMsg() throws IOException, NoOutputException { JSONObject msg = (JSONObject) readMessage(); ShellMsg shellMsg = new ShellMsg();
public void writeSpoutMsg(SpoutMsg msg) throws IOException { JSONObject obj = new JSONObject(); obj.put("command", msg.getCommand()); obj.put("id", msg.getId()); writeMessage(obj); }
public ShellMsg readShellMsg() throws IOException, NoOutputException { JSONObject msg = (JSONObject) readMessage(); ShellMsg shellMsg = new ShellMsg();
public Number connect(Map conf, TopologyContext context) throws IOException, NoOutputException { JSONObject setupInfo = new JSONObject(); setupInfo.put("pidDir", context.getPIDDir()); setupInfo.put("conf", conf); setupInfo.put("context", context); writeMessage(setupInfo); Number pid = (Number) ((JSONObject) readMessage()).get("pid"); return pid; }
public void writeBoltMsg(BoltMsg boltMsg) throws IOException { JSONObject obj = new JSONObject(); obj.put("id", boltMsg.getId()); obj.put("comp", boltMsg.getComp()); obj.put("stream", boltMsg.getStream()); obj.put("task", boltMsg.getTask()); obj.put("tuple", boltMsg.getTuple()); writeMessage(obj); }
private Object readMessage() throws IOException, NoOutputException { try { return JSONValue.parseWithException(readString()); } catch (ParseException e) { throw new IOException(e); } }
private void writeMessage(Object msg) throws IOException { writeString(JSONValue.toJSONString(msg)); }
public void writeTaskIds(List<Integer> taskIds) throws IOException { writeMessage(taskIds); }
public void writeSpoutMsg(SpoutMsg msg) throws IOException { JSONObject obj = new JSONObject(); obj.put("command", msg.getCommand()); obj.put("id", msg.getId()); writeMessage(obj); }
public void writeBoltMsg(BoltMsg boltMsg) throws IOException { JSONObject obj = new JSONObject(); obj.put("id", boltMsg.getId()); obj.put("comp", boltMsg.getComp()); obj.put("stream", boltMsg.getStream()); obj.put("task", boltMsg.getTask()); obj.put("tuple", boltMsg.getTuple()); writeMessage(obj); }