移除无用的工程
This commit is contained in:
parent
fc07067215
commit
4dd00b97fa
|
|
@ -1,13 +0,0 @@
|
|||
<component name="libraryTable">
|
||||
<library name="Maven: com.alibaba:dubbox:2.8.4">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/alibaba/dubbox/2.8.4/dubbox-2.8.4.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/alibaba/dubbox/2.8.4/dubbox-2.8.4-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/alibaba/dubbox/2.8.4/dubbox-2.8.4-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
|
|
@ -1,128 +0,0 @@
|
|||
package com.ai.cloud.skywalking.reciever.storage;
|
||||
|
||||
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
|
||||
import com.ai.cloud.skywalking.reciever.conf.Config;
|
||||
import com.ai.cloud.skywalking.reciever.selfexamination.ServerHealthCollector;
|
||||
import com.ai.cloud.skywalking.reciever.selfexamination.ServerHeathReading;
|
||||
|
||||
/**
|
||||
* 告警的redis连接器,用于管理redis连接
|
||||
*
|
||||
* @author wusheng
|
||||
*
|
||||
*/
|
||||
public class AlarmRedisConnector {
|
||||
private static JedisPool jedisPool;
|
||||
|
||||
static {
|
||||
new RedisInspector().connect().start();
|
||||
}
|
||||
|
||||
public static Jedis getJedis() {
|
||||
if (Config.Alarm.ALARM_OFF_FLAG) {
|
||||
return null;
|
||||
} else {
|
||||
return jedisPool.getResource();
|
||||
}
|
||||
}
|
||||
|
||||
public static void reportJedisFailure() {
|
||||
RedisInspector.needConnectInit = true;
|
||||
}
|
||||
|
||||
private static class RedisInspector extends Thread {
|
||||
private static Logger logger = LogManager
|
||||
.getLogger(RedisInspector.class);
|
||||
|
||||
private static boolean needConnectInit = true;
|
||||
|
||||
private String[] config;
|
||||
|
||||
public RedisInspector() {
|
||||
super("RedisInspectorThread");
|
||||
String redisServerConfig = Config.Redis.REDIS_SERVER;
|
||||
if (redisServerConfig == null || redisServerConfig.length() <= 0) {
|
||||
logger.error("Redis server is not setting. Switch off alarm module. ");
|
||||
Config.Alarm.ALARM_OFF_FLAG = true;
|
||||
} else {
|
||||
config = redisServerConfig.split(":");
|
||||
if (config.length != 2) {
|
||||
logger.error("Redis server address is illegal setting, need to be 'ip:port'. Switch off alarm module. ");
|
||||
Config.Alarm.ALARM_OFF_FLAG = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private RedisInspector connect() {
|
||||
if (jedisPool != null && !jedisPool.isClosed()) {
|
||||
jedisPool.close();
|
||||
}
|
||||
|
||||
GenericObjectPoolConfig genericObjectPoolConfig = buildGenericObjectPoolConfig();
|
||||
jedisPool = new JedisPool(genericObjectPoolConfig, config[0],
|
||||
Integer.valueOf(config[1]));
|
||||
// Test connect redis.
|
||||
Jedis jedis = null;
|
||||
try {
|
||||
jedis = jedisPool.getResource();
|
||||
jedis.get("ok");
|
||||
needConnectInit = false;
|
||||
} catch (Exception e) {
|
||||
logger.error("can't connect to redis["
|
||||
+ Config.Redis.REDIS_SERVER + "]", e);
|
||||
} finally {
|
||||
if (jedis != null) {
|
||||
jedis.close();
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (Config.Alarm.ALARM_OFF_FLAG)
|
||||
return;
|
||||
|
||||
while (true) {
|
||||
try {
|
||||
if (needConnectInit) {
|
||||
connect();
|
||||
}
|
||||
|
||||
if (needConnectInit) {
|
||||
ServerHealthCollector.getCurrentHeathReading(null)
|
||||
.updateData(ServerHeathReading.ERROR,
|
||||
"alarm redis connect failue.");
|
||||
} else {
|
||||
ServerHealthCollector.getCurrentHeathReading(null)
|
||||
.updateData(ServerHeathReading.INFO,
|
||||
"alarm redis connectted.");
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
logger.error("redis init connect failue", t);
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(Config.Alarm.ALARM_REDIS_INSPECTOR_INTERVAL);
|
||||
} catch (InterruptedException e) {
|
||||
logger.error("Failure sleep.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private GenericObjectPoolConfig buildGenericObjectPoolConfig() {
|
||||
GenericObjectPoolConfig genericObjectPoolConfig = new GenericObjectPoolConfig();
|
||||
genericObjectPoolConfig.setTestOnBorrow(true);
|
||||
genericObjectPoolConfig.setMaxIdle(Config.Redis.REDIS_MAX_IDLE);
|
||||
genericObjectPoolConfig.setMinIdle(Config.Redis.REDIS_MIN_IDLE);
|
||||
genericObjectPoolConfig.setMaxTotal(Config.Redis.REDIS_MAX_TOTAL);
|
||||
return genericObjectPoolConfig;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.ai.cloud</groupId>
|
||||
<artifactId>skywalking</artifactId>
|
||||
<version>1.0-Final</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>skywalking-agent-test</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>skywalking-agent-test</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<version>2.4.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
<version>2.8.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
package com.ai.cloud.skywalking.agent.test;
|
||||
|
||||
import com.ai.cloud.skywalking.agent.test.utils.JedisUtils;
|
||||
|
||||
/**
|
||||
* Created by xin on 16-6-3.
|
||||
*/
|
||||
public class AgentTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Begin...");
|
||||
JedisUtils.setData("testKey1", "testKey2");
|
||||
|
||||
System.out.println("testKey1 = " + JedisUtils.getData("testKey1"));
|
||||
|
||||
JedisUtils.expire("testKey1");
|
||||
|
||||
System.out.println("End.....");
|
||||
}
|
||||
}
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
package com.ai.cloud.skywalking.agent.test.utils;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
public class JedisUtils {
|
||||
private static JedisPool jedisPool;
|
||||
private static Logger logger = LogManager.getLogger(JedisUtils.class);
|
||||
|
||||
static {
|
||||
InputStream redisConfigFileStream = JedisUtils.class.getResourceAsStream("/redis.conf");
|
||||
Properties jedisConfig = new Properties();
|
||||
try {
|
||||
jedisConfig.load(redisConfigFileStream);
|
||||
} catch (Exception e) {
|
||||
System.err.print("Failed to load redis.conf");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
jedisPool = new JedisPool(jedisConfig.getProperty("redis.ip", "127.0.0.1"),
|
||||
Integer.parseInt(jedisConfig.getProperty("redis.port", "6379")));
|
||||
}
|
||||
|
||||
public static void setData(String key, String value) {
|
||||
Jedis jedis = null;
|
||||
try {
|
||||
jedis = jedisPool.getResource();
|
||||
jedis.set(key, value);
|
||||
} catch (Exception e) {
|
||||
logger.error("Failed to set data", e);
|
||||
} finally {
|
||||
if (jedis != null) {
|
||||
jedis.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String getData(String key) {
|
||||
Jedis jedis = null;
|
||||
try {
|
||||
jedis = jedisPool.getResource();
|
||||
return jedis.get(key);
|
||||
} catch (Exception e) {
|
||||
logger.error("Failed to set data", e);
|
||||
} finally {
|
||||
if (jedis != null) {
|
||||
jedis.close();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void expire(String key) {
|
||||
Jedis jedis = null;
|
||||
try {
|
||||
jedis = jedisPool.getResource();
|
||||
jedis.expire(key, 0);
|
||||
} catch (Exception e) {
|
||||
logger.error("Failed to set data", e);
|
||||
} finally {
|
||||
if (jedis != null) {
|
||||
jedis.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue