forked from john1688/TITAN
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
gao_xianglong@sina.com
authored and
gao_xianglong@sina.com
committed
Jan 5, 2018
1 parent
7959a63
commit 609de91
Showing
374 changed files
with
25,680 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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> | ||
<groupId>com.yunji</groupId> | ||
<artifactId>titan</artifactId> | ||
<version>2.0.0-SNAPSHOT</version> | ||
<packaging>pom</packaging> | ||
<modules> | ||
<module>titan-utils</module> | ||
<module>titan-manager</module> | ||
<module>titan-task</module> | ||
<module>titan-agent</module> | ||
<module>titan-datacollect</module> | ||
<module>titan-monitor</module> | ||
</modules> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?xml version="1.0"?> | ||
<project | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" | ||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>com.yunji</groupId> | ||
<artifactId>titan</artifactId> | ||
<version>2.0.0-SNAPSHOT</version> | ||
</parent> | ||
<groupId>com.yunji</groupId> | ||
<artifactId>titan-agent</artifactId> | ||
<version>2.0.0-SNAPSHOT</version> | ||
<name>titan-agent</name> | ||
<url>http://maven.apache.org</url> | ||
<properties> | ||
<java-version>1.8</java-version> | ||
<titan-utils-version>2.0.0-SNAPSHOT</titan-utils-version> | ||
<junit-version>4.8.2</junit-version> | ||
<dubbo-version>2.5.3</dubbo-version> | ||
<httpclient-version>4.5.2</httpclient-version> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.0</version> | ||
<configuration> | ||
<encoding>UTF-8</encoding> | ||
<source>${java-version}</source> | ||
<target>${java-version}</target> | ||
<compilerArguments> | ||
<verbose /> | ||
<bootclasspath>${env.JAVA_HOME}/jre/lib/rt.jar</bootclasspath> | ||
<extdirs>${project.basedir}/lib</extdirs> | ||
</compilerArguments> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.httpcomponents</groupId> | ||
<artifactId>httpclient</artifactId> | ||
<version>${httpclient-version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>${junit-version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.alibaba</groupId> | ||
<artifactId>dubbo</artifactId> | ||
<version>${dubbo-version}</version> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.yunji</groupId> | ||
<artifactId>titan-utils</artifactId> | ||
<version>${titan-utils-version}</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
51 changes: 51 additions & 0 deletions
51
titan-agent/src/main/java/com/yunji/titan/agent/IdleConnectionEvictor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright (C) 2015-2020 yunjiweidian | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/> | ||
*/ | ||
package com.yunji.titan.agent; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
import javax.annotation.PostConstruct; | ||
import javax.annotation.Resource; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.scheduling.annotation.Scheduled; | ||
import org.springframework.stereotype.Service; | ||
import com.yunji.titan.agent.config.HttpConnectionManager; | ||
|
||
/** | ||
* 定时清理空闲和过期的http连接 | ||
* | ||
* @author gaoxianglong | ||
*/ | ||
@Service | ||
public class IdleConnectionEvictor { | ||
@Resource | ||
private HttpConnectionManager httpConnectionManager; | ||
private Logger log = LoggerFactory.getLogger(IdleConnectionEvictor.class); | ||
|
||
@PostConstruct | ||
public void init() { | ||
/* 定时清理所有空闲的http连接 */ | ||
httpConnectionManager.getPoolConnManager().closeIdleConnections(5, TimeUnit.SECONDS); | ||
log.info("定时清理空闲和过期的http连接任务启动..."); | ||
} | ||
|
||
@Scheduled(cron = "0/5 * * * * ?") | ||
public void connectionEvictor() { | ||
/* 定时关闭所有过期的http连接 */ | ||
httpConnectionManager.getPoolConnManager().closeExpiredConnections(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright (C) 2015-2020 yunjiweidian | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/> | ||
*/ | ||
package com.yunji.titan.agent; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.context.support.ClassPathXmlApplicationContext; | ||
|
||
/** | ||
* 压测引擎启动函数 | ||
* | ||
* @author gaoxianglong | ||
*/ | ||
public class Main { | ||
private Logger log = LoggerFactory.getLogger(Main.class); | ||
|
||
public static void main(String[] args) { | ||
new Main(); | ||
} | ||
|
||
Main() { | ||
init(); | ||
} | ||
|
||
@SuppressWarnings("resource") | ||
private void init() { | ||
new ClassPathXmlApplicationContext("classpath:*-context.xml"); | ||
log.info("titan-agent启动成功..."); | ||
try { | ||
synchronized (this) { | ||
this.wait(); | ||
} | ||
} catch (Exception e) { | ||
log.error("error", e); | ||
} | ||
} | ||
} |
Oops, something went wrong.