nacos加入到项目当中
This commit is contained in:
parent
cc813549f3
commit
05a4c87022
@ -1,29 +0,0 @@
|
|||||||
package com.qc.soft.framework.basic.http;
|
|
||||||
|
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
|
||||||
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
|
|
||||||
import org.springframework.data.redis.serializer.RedisSerializer;
|
|
||||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
public class RedisConfiguration {
|
|
||||||
|
|
||||||
|
|
||||||
@Bean(name = "stringRedisTemplate")
|
|
||||||
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
|
|
||||||
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
|
|
||||||
redisTemplate.setConnectionFactory(factory);
|
|
||||||
RedisSerializer<String> stringSerializer = new StringRedisSerializer();
|
|
||||||
GenericJackson2JsonRedisSerializer serializer = new GenericJackson2JsonRedisSerializer();
|
|
||||||
redisTemplate.setKeySerializer(stringSerializer);
|
|
||||||
redisTemplate.setValueSerializer(serializer);
|
|
||||||
redisTemplate.setHashKeySerializer(stringSerializer);
|
|
||||||
redisTemplate.setHashValueSerializer(serializer);
|
|
||||||
return redisTemplate;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -49,11 +49,11 @@ public class JenkinsDataCacheSynchronizer {
|
|||||||
@EventListener(ApplicationReadyEvent.class)
|
@EventListener(ApplicationReadyEvent.class)
|
||||||
public void firstSyncCheck() {
|
public void firstSyncCheck() {
|
||||||
log.info("The adapter checks if the item is initialized");
|
log.info("The adapter checks if the item is initialized");
|
||||||
ThirdPartyJenkinsResponse redisValue = (ThirdPartyJenkinsResponse) redisTemplate.opsForValue().get(REDIS_JENKINS_ORIGINAL_VIEW);
|
// ThirdPartyJenkinsResponse redisValue = (ThirdPartyJenkinsResponse) redisTemplate.opsForValue().get(REDIS_JENKINS_ORIGINAL_VIEW);
|
||||||
if (redisValue != null) {
|
// if (redisValue != null) {
|
||||||
log.info("Instead of initializing the project, the jenkins information will be incrementally synchronized");
|
// log.info("Instead of initializing the project, the jenkins information will be incrementally synchronized");
|
||||||
return;
|
//// return;
|
||||||
}
|
// }
|
||||||
CompletableFuture<Void> future = CompletableFuture.runAsync(this::views, executorService)
|
CompletableFuture<Void> future = CompletableFuture.runAsync(this::views, executorService)
|
||||||
.thenRun(this::viewDetail)
|
.thenRun(this::viewDetail)
|
||||||
.thenRun(this::job)
|
.thenRun(this::job)
|
||||||
@ -103,6 +103,9 @@ public class JenkinsDataCacheSynchronizer {
|
|||||||
@Scheduled(cron = "15 * * * * ?")
|
@Scheduled(cron = "15 * * * * ?")
|
||||||
public void job() {
|
public void job() {
|
||||||
List<ThirdPartyJenkinsViewDetailResponse> cacheViewsDetail = getCacheViewsDetail();
|
List<ThirdPartyJenkinsViewDetailResponse> cacheViewsDetail = getCacheViewsDetail();
|
||||||
|
if (CollectionUtils.isEmpty(cacheViewsDetail)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
ExecutorService viewPool = Executors.newFixedThreadPool(cacheViewsDetail.size(), r -> {
|
ExecutorService viewPool = Executors.newFixedThreadPool(cacheViewsDetail.size(), r -> {
|
||||||
Thread thread = new Thread(r);
|
Thread thread = new Thread(r);
|
||||||
thread.setName("jenkins-sync-view-thread-" + System.currentTimeMillis());
|
thread.setName("jenkins-sync-view-thread-" + System.currentTimeMillis());
|
||||||
|
|||||||
@ -65,10 +65,10 @@ public class JenkinsController {
|
|||||||
// return Flux.interval(Duration.ofSeconds(2)).map(index -> jenkinsService.aggregate());
|
// return Flux.interval(Duration.ofSeconds(2)).map(index -> jenkinsService.aggregate());
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// @GetMapping(value = "jenkins/aggregate")
|
@GetMapping(value = "jenkins/aggregate")
|
||||||
// public JenkinsAggregateResponse aggregate() {
|
public JenkinsAggregateResponse aggregate() {
|
||||||
// return jenkinsService.aggregate();
|
return jenkinsService.aggregate();
|
||||||
// }
|
}
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// @GetMapping(value = "/events", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
|
// @GetMapping(value = "/events", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
|
||||||
|
|||||||
@ -100,7 +100,7 @@ public class JenkinsServiceImpl implements IJenkinsService {
|
|||||||
}
|
}
|
||||||
aggregate.setViews(viewsAggregate);
|
aggregate.setViews(viewsAggregate);
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
log.info("Elapsed time in seconds:{}", stopWatch.getTotalTimeSeconds());
|
log.info("Jenkins aggregate elapsed time in seconds:{}", stopWatch.getTotalTimeSeconds());
|
||||||
return aggregate;
|
return aggregate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user