Authored by jack.xue

update

... ... @@ -34,6 +34,21 @@
<groupId>org.influxdb</groupId>
<artifactId>influxdb-java</artifactId>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<exclusions>
<exclusion>
<artifactId>log4j</artifactId>
<groupId>log4j</groupId>
</exclusion>
<exclusion>
<artifactId>slf4j-log4j12</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
\ No newline at end of file
... ...
... ... @@ -16,8 +16,7 @@ import javax.annotation.PostConstruct;
/**
* Created by yoho on 2016/6/21.
*/
@Component
public class InfluxComp {
public class InfluxComp implements Runnable {
public static final Logger DEBUG = LoggerFactory.getLogger(InfluxComp.class);
... ... @@ -37,7 +36,6 @@ public class InfluxComp {
}
@PostConstruct
public void doService() {
while (true) {
... ... @@ -69,4 +67,9 @@ public class InfluxComp {
return influxDBClient.query(query);
}
@Override
public void run() {
}
}
... ...
... ... @@ -21,7 +21,6 @@ import org.springframework.web.bind.annotation.RestController;
public class RabbitmqService {
public static final Logger DEBUG = LoggerFactory.getLogger(RabbitmqService.class);
@Autowired
InfluxComp influxComp;
@RequestMapping(value = "/overview")
... ...
... ... @@ -6,14 +6,18 @@ import com.monitor.cmdb.service.IMObjectInfoService;
import com.monitor.cmdb.service.ITypeInfoService;
import com.monitor.middleware.rabbitmq.constant.InterVar;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* Created by yoho on 2016/6/21.
*/
public class MoScanTask implements Runnable{
public class MoScanTask {
@Autowired
IMObjectInfoService moService;
... ... @@ -21,8 +25,14 @@ public class MoScanTask implements Runnable{
@Autowired
ITypeInfoService typeService;
MoScanTask()
{
int i=0;
i++;
System.out.println("123");
}
//自动发现rabbit监控对象
@Scheduled(cron = "0/1 0 0 * * ? *")
@Scheduled(cron = "0/1 * * * * ? *")
public void doTask() {
List<MObjectInfo> mObjectInfoList = moService.queryMObjectsInfo();
... ... @@ -38,8 +48,4 @@ public class MoScanTask implements Runnable{
}
}
@Override
public void run() {
doTask();
}
}
... ...
... ... @@ -6,7 +6,10 @@ import com.monitor.middleware.rabbitmq.task.job.ClusterViewJob;
import com.monitor.middleware.rabbitmq.task.job.OneJob;
import com.monitor.middleware.rabbitmq.task.job.OverViewJob;
import com.monitor.middleware.rabbitmq.task.job.QueueViewJob;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.Map;
... ... @@ -21,7 +24,7 @@ import static com.monitor.middleware.rabbitmq.constant.InterVar.EXECUTOR_SERVICE
*/
public class MonitTask {
@Scheduled(cron = "0/1 0 0 * * ? *")
@Scheduled(cron = "0/1 * * * * ? *")
public void doTask() {
for (Map.Entry<Integer, MObjectInfo> entry : InterVar.moMaps.entrySet()) {
EXECUTOR_SERVICE.submit(new OneJob(new ClusterViewJob(entry.getKey())));
... ...
... ... @@ -8,6 +8,7 @@ import org.apache.zookeeper.ZooKeeper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.stereotype.Service;
import java.io.IOException;
... ... @@ -17,6 +18,7 @@ import java.util.List;
/**
* Created by yoho on 2016/6/21.
*/
@EnableScheduling
@Service
public class ZkMonitorServiceImpl implements IZkMonitorService {
... ...
... ... @@ -4,12 +4,14 @@ import com.monitor.middleware.zookeeper.service.IZkMonitorService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
/**
* Created by yoho on 2016/6/21.
*/
@EnableScheduling
@Component
public class ZookeeperMonitorTask {
... ... @@ -18,7 +20,7 @@ public class ZookeeperMonitorTask {
@Autowired
IZkMonitorService zkMonitorService;
@Scheduled(fixedRate=5000)
@Scheduled(fixedRate = 5000)
public void zookeeperMonitor() {
zkMonitorService.zookeeperMonitor();
}
... ...
... ... @@ -2,11 +2,18 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd">
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<task:scheduler id="taskScheduler" pool-size="5"></task:scheduler>
<!-- <task:scheduler id="taskScheduler" pool-size="5"></task:scheduler>
<task:annotation-driven scheduler="taskScheduler"/>-->
<!-- <bean id="task" class="com.monitor.middleware.rabbitmq.task.MonitTask"></bean>
<task:scheduled-tasks>
<task:scheduled ref="task" method="doTask" fixed-rate="1000"/>
</task:scheduled-tasks>-->
<bean id="httpClientFactory" class="org.springframework.http.client.SimpleClientHttpRequestFactory">
<property name="connectTimeout" value="2000"/>
... ...
... ... @@ -24,7 +24,7 @@
<!-- Enables the Spring Task @Scheduled programming model -->
<task:executor id="executor" pool-size="50"/>
<task:scheduler id="scheduler" pool-size="50"/>
<task:annotation-driven executor="executor" scheduler="scheduler"/>
<task:annotation-driven executor="executor" scheduler="scheduler"/>
<mvc:annotation-driven>
<mvc:message-converters>
... ...