String command = (String) msg.get("command"); shellMsg.setCommand(command); Object id = msg.get("id"); shellMsg.setId(id); String log = (String) msg.get("msg"); shellMsg.setMsg(log); String stream = (String) msg.get("stream"); if (stream == null) { stream = Utils.DEFAULT_STREAM_ID; Object taskObj = msg.get("task"); if (taskObj != null) { shellMsg.setTask((Long) taskObj); Object need_task_ids = msg.get("need_task_ids"); if (need_task_ids == null || ((Boolean) need_task_ids).booleanValue()) { shellMsg.setNeedTaskIds(true); shellMsg.setTuple((List) msg.get("tuple")); Object anchorObj = msg.get("anchors"); if (anchorObj != null) { if (anchorObj instanceof String) { Object nameObj = msg.get("name"); String metricName = null;
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; }
String command = (String) msg.get("command"); shellMsg.setCommand(command); Object id = msg.get("id"); shellMsg.setId(id); String log = (String) msg.get("msg"); shellMsg.setMsg(log); String stream = (String) msg.get("stream"); if (stream == null) stream = Utils.DEFAULT_STREAM_ID; shellMsg.setStream(stream); Object taskObj = msg.get("task"); if (taskObj != null) { shellMsg.setTask((Long) taskObj); Object need_task_ids = msg.get("need_task_ids"); if (need_task_ids == null || ((Boolean) need_task_ids).booleanValue()) { shellMsg.setNeedTaskIds(true); shellMsg.setTuple((List) msg.get("tuple")); Object anchorObj = msg.get("anchors"); if (anchorObj != null) { if (anchorObj instanceof String) { Object nameObj = msg.get("name");
public static Map<String, Double> parseResources(String input) { Map<String, Double> topology_resources = new HashMap<String, Double>(); JSONParser parser = new JSONParser(); LOG.debug("Input to parseResources {}", input); try { if (input != null) { Object obj = parser.parse(input); JSONObject jsonObject = (JSONObject) obj; if (jsonObject.containsKey(Config.TOPOLOGY_COMPONENT_RESOURCES_ONHEAP_MEMORY_MB)) { Double topoMemOnHeap = org.apache.storm.utils.Utils .getDouble(jsonObject.get(Config.TOPOLOGY_COMPONENT_RESOURCES_ONHEAP_MEMORY_MB), null); topology_resources.put(Config.TOPOLOGY_COMPONENT_RESOURCES_ONHEAP_MEMORY_MB, topoMemOnHeap); } if (jsonObject.containsKey(Config.TOPOLOGY_COMPONENT_RESOURCES_OFFHEAP_MEMORY_MB)) { Double topoMemOffHeap = org.apache.storm.utils.Utils .getDouble(jsonObject.get(Config.TOPOLOGY_COMPONENT_RESOURCES_OFFHEAP_MEMORY_MB), null); topology_resources.put(Config.TOPOLOGY_COMPONENT_RESOURCES_OFFHEAP_MEMORY_MB, topoMemOffHeap); } if (jsonObject.containsKey(Config.TOPOLOGY_COMPONENT_CPU_PCORE_PERCENT)) { Double topoCPU = org.apache.storm.utils.Utils.getDouble(jsonObject.get(Config.TOPOLOGY_COMPONENT_CPU_PCORE_PERCENT), null); topology_resources.put(Config.TOPOLOGY_COMPONENT_CPU_PCORE_PERCENT, topoCPU); } LOG.debug("Topology Resources {}", topology_resources); } } catch (ParseException e) { LOG.error("Failed to parse component resources is:" + e.toString(), e); return null; } return topology_resources; }
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; }