public static List<MonitorStat> retrieveFromRedis(String traceId, RedisType redisType) throws Exception { return redisServiceMonitorRetriever.retrieve(traceId, redisType); } }
@Override public void execute(MonitorStat monitorStat) throws Exception { executeJson(monitorStat); }
public static List<MonitorStat> retrieveFromLog(String traceId, String filePath) throws Exception { return logServiceMonitorRetriever.retrieve(traceId, filePath); }
public List<MonitorStat> retrieve(String traceId, RedisType redisType) throws Exception { if (StringUtils.isEmpty(traceId)) { throw new MonitorException("Trace ID is null"); } if (redisType == null) { throw new MonitorException("Redis type is null"); } Map<String, String> monitorStatMap = null; switch (redisType) { case REDIS_SENTINEL: monitorStatMap = retrieveFromSentinel(traceId); break; case REDIS_CLUSTER: monitorStatMap = retrieveFromCluster(traceId); break; } if (MapUtils.isEmpty(monitorStatMap)) { return null; } List<MonitorStat> monitorStatList = retrieve(monitorStatMap); sort(monitorStatList); return monitorStatList; }
public void actionPerformed(ActionEvent e) { Map<String, String> splunkValue = new HashMap<String, String>(); splunkValue.put(ThunderConstant.SPLUNK_HOST_ATTRIBUTE_NAME, hostComboBox.getSelectedItem().toString()); splunkValue.put(ThunderConstant.SPLUNK_PORT_ATTRIBUTE_NAME, portTextField.getText().trim()); splunkValue.put(ThunderConstant.SPLUNK_USER_NAME_ATTRIBUTE_NAME, userNameTextField.getText().trim()); splunkValue.put(ThunderConstant.SPLUNK_PASSWORD_ATTRIBUTE_NAME, passwordField.getPasswordText().trim()); PropertiesContext.addPropertiesMap(splunkValue); try { MonitorController.getSplunkLogServiceMonitorRetriever().dispose(); MonitorController.getSplunkLogServiceMonitorRetriever().initialize(PropertiesContext.getProperties()); } catch (Exception ex) { } if (MonitorController.getSplunkLogServiceMonitorRetriever().enabled()) { JBasicOptionPane.showMessageDialog(HandleManager.getFrame(TraceTopology.this), ConsoleLocale.getString("start_success"), SwingLocale.getString("information"), JBasicOptionPane.INFORMATION_MESSAGE); } else { JBasicOptionPane.showMessageDialog(HandleManager.getFrame(TraceTopology.this), ConsoleLocale.getString("start_failure"), SwingLocale.getString("error"), JBasicOptionPane.ERROR_MESSAGE); } } });
public List<MonitorStat> retrieve(String traceId, Map<String, Object> conditions) throws Exception { return retrieve(traceId, conditions, ThunderConstant.ENCODING_UTF_8); }
public List<MonitorStat> retrieve(String traceId, String filePath, String encoding) throws Exception { if (StringUtils.isEmpty(traceId)) { throw new MonitorException("Trace ID is null"); throw new MonitorException("File path is null"); line = line.substring(line.indexOf("{")); try { MonitorStat monitorStat = create(line); monitorStatList.add(monitorStat); } catch (Exception e) { sort(monitorStatList);
public List<MonitorStat> retrieve(String traceId, Map<String, Object> conditions, String encoding) throws Exception { if (StringUtils.isEmpty(traceId)) { throw new MonitorException("Trace ID is null"); throw new MonitorException("Splunk service is null"); throw new MonitorException("Input stream is null"); line = "{" + line + "}"; try { MonitorStat monitorStat = create(line); String exception = monitorStat.getException(); if (StringUtils.isNotEmpty(exception)) { sort(monitorStatList);
@Override public void execute(final MonitorStat monitorStat) throws Exception { final String traceId = monitorStat.getTraceId(); if (StringUtils.isEmpty(traceId)) { LOG.error("Trace ID is null, monitor stat can't be put into redis"); return; } if (RedisSentinelPoolFactory.enabled()) { executeToSentinel(traceId, monitorStat); } else if (RedisClusterFactory.enabled()) { executeToCluster(traceId, monitorStat); } }
@Override public void handleMonitor(ProtocolMessage message) { MonitorStat monitorStat = null; List<MonitorExecutor> monitorExecutors = getExecutorContainer().getMonitorExecutors(); if (CollectionUtils.isNotEmpty(monitorExecutors)) { for (MonitorExecutor monitorExecutor : monitorExecutors) { if (monitorStat == null) { monitorStat = monitorExecutor.createMonitorStat(message); } try { monitorExecutor.execute(monitorStat); } catch (Exception e) { LOG.error("Execute monitor failed, executor={}", monitorExecutor.getClass().getName()); } } } }
@Override public void execute(MonitorStat monitorStat) throws Exception { MonitorEntity monitorEntity = cacheContainer.getMonitorEntity(); List<String> addresses = monitorEntity.getAddresses(); if (CollectionUtils.isEmpty(addresses)) { LOG.error("Webservice monitor addresses are null"); return; } for (String address : addresses) { if (!address.startsWith("http://")) { address = "http://" + address; } String value = SerializerExecutor.toJson(monitorStat); HttpEntity entity = new StringEntity(value, ThunderConstant.ENCODING_UTF_8); HttpPost httpPost = new HttpPost(address); httpPost.addHeader("content-type", "application/json;charset=" + ThunderConstant.ENCODING_UTF_8); httpPost.setEntity(entity); HttpAsyncCallback httpAsyncCallback = new HttpAsyncCallback(); httpAsyncCallback.setHttpPost(httpPost); httpAsyncClient.execute(httpPost, httpAsyncCallback); } }
public void initialize(ThunderProperties properties) throws Exception { this.properties = properties; if (service == null) { try { ServiceArgs loginArgs = new ServiceArgs(); loginArgs.setHost(properties.getString(ThunderConstant.SPLUNK_HOST_ATTRIBUTE_NAME)); loginArgs.setPort(properties.getInteger(ThunderConstant.SPLUNK_PORT_ATTRIBUTE_NAME)); loginArgs.setUsername(properties.getString(ThunderConstant.SPLUNK_USER_NAME_ATTRIBUTE_NAME)); loginArgs.setPassword(properties.getString(ThunderConstant.SPLUNK_PASSWORD_ATTRIBUTE_NAME)); loginArgs.setSSLSecurityProtocol(SSLSecurityProtocol.TLSv1_2); service = Service.connect(loginArgs); } catch (Exception e) { LOG.error("Initialize Splunk connection failed", e); dispose(); } } }
public List<MonitorStat> retrieve(String[] monitorStatArray) { List<MonitorStat> monitorStatList = new ArrayList<MonitorStat>(); for (String monitorStatJson : monitorStatArray) { MonitorStat monitorStat = create(monitorStatJson); monitorStatList.add(monitorStat); } return monitorStatList; } }
public Map<String, String> retrieveFromCluster(String traceId) throws Exception { JedisCluster cluster = RedisClusterFactory.getCluster(); if (cluster == null) { throw new MonitorException("No redis cluster found, retrieve failed"); } Map<String, String> monitorStatMap = cluster.hgetAll(traceId); if (MapUtils.isEmpty(monitorStatMap)) { return null; } return monitorStatMap; }
@Override public void setProperties(ThunderProperties properties) { super.setProperties(properties); try { ApacheAsyncClientExecutor clientExecutor = new ApacheAsyncClientExecutor(); clientExecutor.initialize(properties); httpAsyncClient = clientExecutor.getClient(); } catch (Exception e) { LOG.error("Get htty async client failed", e); } }
public static List<MonitorStat> retrieveFromSplunk(String traceId, Map<String, Object> conditions) throws Exception { return splunkLogServiceMonitorRetriever.retrieve(traceId, conditions); }
public List<MonitorStat> retrieve(String traceId, String filePath) throws Exception { return retrieve(traceId, filePath, ThunderConstant.ENCODING_UTF_8); }
public List<MonitorStat> retrieve(Map<String, String> monitorStatMap) { List<MonitorStat> monitorStatList = new ArrayList<MonitorStat>(); for (Map.Entry<String, String> entry : monitorStatMap.entrySet()) { MonitorStat monitorStat = create(entry.getValue()); monitorStatList.add(monitorStat); } return monitorStatList; }
public Map<String, String> retrieveFromSentinel(String traceId) throws Exception { Jedis jedis = RedisSentinelPoolFactory.getResource(); if (jedis == null) { throw new MonitorException("No redis sentinel resource found, retrieve failed"); } Map<String, String> monitorStatMap = jedis.hgetAll(traceId); if (MapUtils.isEmpty(monitorStatMap)) { return null; } return monitorStatMap; }
public List<MonitorStat> retrieve(String traceId) throws Exception { return retrieve(traceId, null); }