@Test public void testReport() { for (int i = 0; i < 100; i++) { MData mData = new MData(); mData.setTimestamp(Long.valueOf(i)); report(mData); } }
private void report(MData mData) { int size = queue.size(); if (size >= MAX_RETRY_RETAIN) { int needRemoveSize = size - (MAX_RETRY_RETAIN - 1); for (int i = 0; i < needRemoveSize; i++) { queue.poll(); } } queue.add(mData); final List<Node> monitorNodes = appContext.getSubscribedNodeManager().getNodeList(NodeType.MONITOR); if (CollectionUtils.isEmpty(monitorNodes)) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Please Start LTS-Monitor"); } return; } while (queue.size() > 0) { List<MData> list = new ArrayList<MData>(); queue.drainTo(list, BATCH_REPORT_SIZE); boolean success = false; try { HttpCmd cmd = new DefaultHttpCmd(); cmd.setCommand(HttpCmdNames.HTTP_CMD_ADD_M_DATA); cmd.addParam(HttpCmdParamNames.M_NODE, JSON.toJSONString(buildMNode())); cmd.addParam(HttpCmdParamNames.M_DATA, JSON.toJSONString(list)); if (sendReq(monitorNodes, cmd)) { success = true; } } catch (Throwable t) { LOGGER.warn("Report monitor data Error : " + t.getMessage(), t); } finally { if (!success) { queue.addAll(list); } } if (!success) { break; } } }
MStatReportWorker implements Runnable { private void report(MData mData) { int size = queue.size(); if (size >= MAX_RETRY_RETAIN) { int needRemoveSize = size - (MAX_RETRY_RETAIN - 1); for (int i = 0; i < needRemoveSize; i++) { queue.poll(); } } queue.add(mData); final List<Node> monitorNodes = appContext.getSubscribedNodeManager().getNodeList(NodeType.MONITOR); if (CollectionUtils.isEmpty(monitorNodes)) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Please Start LTS-Monitor"); } return; } while (queue.size() > 0) { List<MData> list = new ArrayList<MData>(); queue.drainTo(list, BATCH_REPORT_SIZE); boolean success = false; try { HttpCmd cmd = new DefaultHttpCmd(); cmd.setCommand(HttpCmdNames.HTTP_CMD_ADD_M_DATA); cmd.addParam(HttpCmdParamNames.M_NODE, JSON.toJSONString(buildMNode())); cmd.addParam(HttpCmdParamNames.M_DATA, JSON.toJSONString(list)); if (sendReq(monitorNodes, cmd)) { success = true; } } catch (Throwable t) { LOGGER.warn("Report monitor data Error : " + t.getMessage(), t); } finally { if (!success) { queue.addAll(list); } } if (!success) { break; } } } }
MStatReportWorker implements Runnable { private void report(MData mData) { int size = queue.size(); if (size >= MAX_RETRY_RETAIN) { int needRemoveSize = size - (MAX_RETRY_RETAIN - 1); for (int i = 0; i < needRemoveSize; i++) { queue.poll(); } } queue.add(mData); final List<Node> monitorNodes = appContext.getSubscribedNodeManager().getNodeList(NodeType.MONITOR); if (CollectionUtils.isEmpty(monitorNodes)) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Please Start LTS-Monitor"); } return; } while (queue.size() > 0) { List<MData> list = new ArrayList<MData>(); queue.drainTo(list, BATCH_REPORT_SIZE); boolean success = false; try { HttpCmd cmd = new DefaultHttpCmd(); cmd.setCommand(HttpCmdNames.HTTP_CMD_ADD_M_DATA); cmd.addParam(HttpCmdParamNames.M_NODE, JSON.toJSONString(buildMNode())); cmd.addParam(HttpCmdParamNames.M_DATA, JSON.toJSONString(list)); if (sendReq(monitorNodes, cmd)) { success = true; } } catch (Throwable t) { LOGGER.warn("Report monitor data Error : " + t.getMessage(), t); } finally { if (!success) { queue.addAll(list); } } if (!success) { break; } } } MStatReportWorker(AppContext appContext, AbstractMStatReporter reporter); }
MStatReportWorker implements Runnable { private void report(MData mData) { int size = queue.size(); if (size >= MAX_RETRY_RETAIN) { int needRemoveSize = size - (MAX_RETRY_RETAIN - 1); for (int i = 0; i < needRemoveSize; i++) { queue.poll(); } } queue.add(mData); final List<Node> monitorNodes = appContext.getSubscribedNodeManager().getNodeList(NodeType.MONITOR); if (CollectionUtils.isEmpty(monitorNodes)) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Please Start LTS-Monitor"); } return; } while (queue.size() > 0) { List<MData> list = new ArrayList<MData>(); queue.drainTo(list, BATCH_REPORT_SIZE); boolean success = false; try { HttpCmd cmd = new DefaultHttpCmd(); cmd.setCommand(HttpCmdNames.HTTP_CMD_ADD_M_DATA); cmd.addParam(HttpCmdParamNames.M_NODE, JSON.toJSONString(buildMNode())); cmd.addParam(HttpCmdParamNames.M_DATA, JSON.toJSONString(list)); if (sendReq(monitorNodes, cmd)) { success = true; } } catch (Throwable t) { LOGGER.warn("Report monitor data Error : " + t.getMessage(), t); } finally { if (!success) { queue.addAll(list); } } if (!success) { break; } } } MStatReportWorker(AppContext appContext, AbstractMStatReporter reporter); @Override void run(); }
MStatReportWorker implements Runnable { private void report(MData mData) { int size = queue.size(); if (size >= MAX_RETRY_RETAIN) { int needRemoveSize = size - (MAX_RETRY_RETAIN - 1); for (int i = 0; i < needRemoveSize; i++) { queue.poll(); } } queue.add(mData); final List<Node> monitorNodes = appContext.getSubscribedNodeManager().getNodeList(NodeType.MONITOR); if (CollectionUtils.isEmpty(monitorNodes)) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Please Start LTS-Monitor"); } return; } while (queue.size() > 0) { List<MData> list = new ArrayList<MData>(); queue.drainTo(list, BATCH_REPORT_SIZE); boolean success = false; try { HttpCmd cmd = new DefaultHttpCmd(); cmd.setCommand(HttpCmdNames.HTTP_CMD_ADD_M_DATA); cmd.addParam(HttpCmdParamNames.M_NODE, JSON.toJSONString(buildMNode())); cmd.addParam(HttpCmdParamNames.M_DATA, JSON.toJSONString(list)); if (sendReq(monitorNodes, cmd)) { success = true; } } catch (Throwable t) { LOGGER.warn("Report monitor data Error : " + t.getMessage(), t); } finally { if (!success) { queue.addAll(list); } } if (!success) { break; } } } MStatReportWorker(AppContext appContext, AbstractMStatReporter reporter); @Override void run();  }