From 5cd8582470884e6b9589800a92956a2cbbc4bea6 Mon Sep 17 00:00:00 2001 From: yifuzhou Date: Thu, 21 Nov 2024 15:18:51 +0800 Subject: [PATCH] change KeeperContainerService bean name to KeeperContainerCheckerService --- ...ice.java => KeeperContainerCheckerService.java} | 2 +- ...a => DefaultKeeperContainerCheckerService.java} | 4 ++-- .../checker/impl/KeeperContainerInfoReporter.java | 10 +++++----- .../checker/impl/KeeperUsedInfoReporterTest.java | 12 ++++++------ .../controller/api/KeeperContainerController.java | 8 ++++---- .../KeeperContainerDiskIOLimitDispatcher.java | 6 +++--- .../console/keeper/command/KeeperResetCommand.java | 10 +++++----- ...erviceImpl.java => KeeperContainerService.java} | 12 ++---------- .../service/model/impl/ShardModelServiceImpl.java | 14 +++++++------- .../redis/console/spring/CheckerContextConfig.java | 6 +++--- .../redis/console/spring/ConsoleContextConfig.java | 8 ++++---- .../com/ctrip/xpipe/redis/console/AllTests.java | 2 +- .../redis/console/service/BasicServiceTest.java | 2 +- ...java => KeeperContainerCheckerServiceTest.java} | 6 +++--- .../console/service/impl/AzServiceImplTest.java | 2 +- ... => KeeperContainerCheckerServiceImplTest.java} | 13 ++----------- 16 files changed, 50 insertions(+), 67 deletions(-) rename redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/{KeeperContainerService.java => KeeperContainerCheckerService.java} (92%) rename redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/impl/{DefaultKeeperContainerService.java => DefaultKeeperContainerCheckerService.java} (94%) rename redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/service/impl/{KeeperContainerServiceImpl.java => KeeperContainerService.java} (97%) rename redis/redis-console/src/test/java/com/ctrip/xpipe/redis/console/service/{KeeperContainerServiceTest.java => KeeperContainerCheckerServiceTest.java} (90%) rename redis/redis-console/src/test/java/com/ctrip/xpipe/redis/console/service/impl/{KeeperContainerServiceImplTest.java => KeeperContainerCheckerServiceImplTest.java} (96%) diff --git a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/KeeperContainerService.java b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/KeeperContainerCheckerService.java similarity index 92% rename from redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/KeeperContainerService.java rename to redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/KeeperContainerCheckerService.java index b0553246f8..9c271782d4 100644 --- a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/KeeperContainerService.java +++ b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/KeeperContainerCheckerService.java @@ -6,7 +6,7 @@ import java.util.List; -public interface KeeperContainerService { +public interface KeeperContainerCheckerService { KeeperDiskInfo getKeeperDiskInfo(String keeperContainerIp) throws RestClientException; diff --git a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/impl/DefaultKeeperContainerService.java b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/impl/DefaultKeeperContainerCheckerService.java similarity index 94% rename from redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/impl/DefaultKeeperContainerService.java rename to redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/impl/DefaultKeeperContainerCheckerService.java index eca0948807..8e41fb8053 100644 --- a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/impl/DefaultKeeperContainerService.java +++ b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/impl/DefaultKeeperContainerCheckerService.java @@ -1,6 +1,6 @@ package com.ctrip.xpipe.redis.checker.impl; -import com.ctrip.xpipe.redis.checker.KeeperContainerService; +import com.ctrip.xpipe.redis.checker.KeeperContainerCheckerService; import com.ctrip.xpipe.redis.core.entity.KeeperDiskInfo; import com.ctrip.xpipe.redis.core.entity.KeeperInstanceMeta; import com.ctrip.xpipe.redis.core.entity.KeeperTransMeta; @@ -16,7 +16,7 @@ import java.util.List; @Service -public class DefaultKeeperContainerService extends AbstractService implements KeeperContainerService { +public class DefaultKeeperContainerCheckerService extends AbstractService implements KeeperContainerCheckerService { private static final String HTTP_PREFIX = "http://"; private static final String PATH_GET_KEEPER_DISK_INFO = "/keepers/disk"; diff --git a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/impl/KeeperContainerInfoReporter.java b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/impl/KeeperContainerInfoReporter.java index ffff72f395..1911f5d9e5 100644 --- a/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/impl/KeeperContainerInfoReporter.java +++ b/redis/redis-checker/src/main/java/com/ctrip/xpipe/redis/checker/impl/KeeperContainerInfoReporter.java @@ -2,7 +2,7 @@ import com.ctrip.xpipe.api.foundation.FoundationService; import com.ctrip.xpipe.redis.checker.CheckerConsoleService; -import com.ctrip.xpipe.redis.checker.KeeperContainerService; +import com.ctrip.xpipe.redis.checker.KeeperContainerCheckerService; import com.ctrip.xpipe.redis.checker.cluster.GroupCheckerLeaderAware; import com.ctrip.xpipe.redis.checker.config.CheckerConfig; import com.ctrip.xpipe.redis.checker.healthcheck.actions.keeper.info.RedisUsedMemoryCollector; @@ -42,7 +42,7 @@ public class KeeperContainerInfoReporter implements GroupCheckerLeaderAware { private CheckerConsoleService checkerConsoleService; - private KeeperContainerService keeperContainerService; + private KeeperContainerCheckerService keeperContainerCheckerService; private CheckerConfig config; @@ -54,12 +54,12 @@ public class KeeperContainerInfoReporter implements GroupCheckerLeaderAware { public KeeperContainerInfoReporter(RedisUsedMemoryCollector redisUsedMemoryCollector, CheckerConsoleService - checkerConsoleService, KeeperFlowCollector keeperFlowCollector, CheckerConfig config, KeeperContainerService keeperContainerService, MetaCache metaCache) { + checkerConsoleService, KeeperFlowCollector keeperFlowCollector, CheckerConfig config, KeeperContainerCheckerService keeperContainerCheckerService, MetaCache metaCache) { this.redisUsedMemoryCollector = redisUsedMemoryCollector; this.keeperFlowCollector = keeperFlowCollector; this.checkerConsoleService = checkerConsoleService; this.config = config; - this.keeperContainerService = keeperContainerService; + this.keeperContainerCheckerService = keeperContainerCheckerService; this.metaCache = metaCache; } @@ -151,7 +151,7 @@ public void reportKeeperContainerInfo() { } try { logger.debug("[get KeeperContainer disk Info] keeperIp: {}", keeperIp); - KeeperDiskInfo keeperDiskInfo = keeperContainerService.getKeeperDiskInfo(keeperIp); + KeeperDiskInfo keeperDiskInfo = keeperContainerCheckerService.getKeeperDiskInfo(keeperIp); logger.debug("[KeeperContainer disk Info] keeperIp: {} keeperDiskInfo: {}", keeperIp, keeperDiskInfo); if (keeperDiskInfo != null && keeperDiskInfo.available && keeperDiskInfo.spaceUsageInfo != null) { model.setDiskAvailable(true) diff --git a/redis/redis-checker/src/test/java/com/ctrip/xpipe/redis/checker/impl/KeeperUsedInfoReporterTest.java b/redis/redis-checker/src/test/java/com/ctrip/xpipe/redis/checker/impl/KeeperUsedInfoReporterTest.java index 45d2f019bf..45cbfac6b9 100644 --- a/redis/redis-checker/src/test/java/com/ctrip/xpipe/redis/checker/impl/KeeperUsedInfoReporterTest.java +++ b/redis/redis-checker/src/test/java/com/ctrip/xpipe/redis/checker/impl/KeeperUsedInfoReporterTest.java @@ -2,7 +2,7 @@ import com.ctrip.xpipe.api.foundation.FoundationService; import com.ctrip.xpipe.redis.checker.CheckerConsoleService; -import com.ctrip.xpipe.redis.checker.KeeperContainerService; +import com.ctrip.xpipe.redis.checker.KeeperContainerCheckerService; import com.ctrip.xpipe.redis.checker.config.CheckerConfig; import com.ctrip.xpipe.redis.checker.healthcheck.actions.keeper.info.RedisUsedMemoryCollector; import com.ctrip.xpipe.redis.checker.healthcheck.actions.keeper.infoStats.KeeperFlowCollector; @@ -50,7 +50,7 @@ public class KeeperUsedInfoReporterTest { CheckerConfig config; @Mock - KeeperContainerService keeperContainerService; + KeeperContainerCheckerService keeperContainerCheckerService; @Mock private MetaCache metaCache; @@ -121,7 +121,7 @@ public void befor() { diskInfo.spaceUsageInfo = new DiskSpaceUsageInfo(); diskInfo.spaceUsageInfo.size = 1024*1024*1024*1024L; diskInfo.spaceUsageInfo.use = 1024*1024*1024*100L; - Mockito.when(keeperContainerService.getKeeperDiskInfo(anyString())).thenReturn(diskInfo); + Mockito.when(keeperContainerCheckerService.getKeeperDiskInfo(anyString())).thenReturn(diskInfo); } @Test @@ -144,7 +144,7 @@ public void testReportKeeperContainerInfo() { @Test public void testKeeperContainerUnHealthInfo() { - Mockito.when(keeperContainerService.getKeeperDiskInfo(anyString())).thenReturn(null); + Mockito.when(keeperContainerCheckerService.getKeeperDiskInfo(anyString())).thenReturn(null); keeperContainerInfoReporter. reportKeeperContainerInfo(); Mockito.verify(checkerConsoleService, Mockito.times(1)) @@ -166,8 +166,8 @@ public void testKeeperContainerDiskSick() { KeeperDiskInfo diskInfo = new KeeperDiskInfo(); diskInfo.available = false; diskInfo.spaceUsageInfo = null; - Mockito.when(keeperContainerService.getKeeperDiskInfo(anyString())).thenReturn(diskInfo); - Mockito.when(keeperContainerService.getKeeperDiskInfo(anyString())).thenReturn(null); + Mockito.when(keeperContainerCheckerService.getKeeperDiskInfo(anyString())).thenReturn(diskInfo); + Mockito.when(keeperContainerCheckerService.getKeeperDiskInfo(anyString())).thenReturn(null); keeperContainerInfoReporter. reportKeeperContainerInfo(); Mockito.verify(checkerConsoleService, Mockito.times(1)) diff --git a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/controller/api/KeeperContainerController.java b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/controller/api/KeeperContainerController.java index 779cb016d5..31f3bddb77 100644 --- a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/controller/api/KeeperContainerController.java +++ b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/controller/api/KeeperContainerController.java @@ -10,7 +10,7 @@ import com.ctrip.xpipe.redis.console.model.KeeperRestElectionModel; import com.ctrip.xpipe.redis.console.model.MigrationKeeperContainerDetailModel; import com.ctrip.xpipe.redis.console.service.ConfigService; -import com.ctrip.xpipe.redis.checker.KeeperContainerService; +import com.ctrip.xpipe.redis.checker.KeeperContainerCheckerService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -32,7 +32,7 @@ public class KeeperContainerController extends AbstractConsoleController{ ConfigService configService; @Autowired - KeeperContainerService keeperContainerService; + KeeperContainerCheckerService keeperContainerCheckerService; @RequestMapping(value = "/keepercontainer/overload/info/all", method = RequestMethod.GET) public List getAllReadyToMigrateKeeperContainers() { @@ -97,7 +97,7 @@ public RetMessage getIORate() { @RequestMapping(value = "/keepers/election/reset", method = RequestMethod.POST) public RetMessage resetElection(@RequestBody KeeperRestElectionModel model){ try { - keeperContainerService.resetKeeper(model.getIp(), Long.parseLong(model.getShardId())); + keeperContainerCheckerService.resetKeeper(model.getIp(), Long.parseLong(model.getShardId())); return RetMessage.createSuccessMessage(); } catch (Exception e) { return RetMessage.createFailMessage(e.getMessage()); @@ -107,7 +107,7 @@ public RetMessage resetElection(@RequestBody KeeperRestElectionModel model){ @RequestMapping(value = "/keepers/release/rdb", method = RequestMethod.POST) public RetMessage releaseRdb(@RequestBody KeeperRestElectionModel model){ try { - keeperContainerService.releaseRdb(model.getIp(), Integer.parseInt(model.getPort()), Long.parseLong(model.getShardId())); + keeperContainerCheckerService.releaseRdb(model.getIp(), Integer.parseInt(model.getPort()), Long.parseLong(model.getShardId())); return RetMessage.createSuccessMessage(); } catch (Exception e) { return RetMessage.createFailMessage(e.getMessage()); diff --git a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/healthcheck/nonredis/keepercontainer/KeeperContainerDiskIOLimitDispatcher.java b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/healthcheck/nonredis/keepercontainer/KeeperContainerDiskIOLimitDispatcher.java index 06013f6647..157c1dd65e 100644 --- a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/healthcheck/nonredis/keepercontainer/KeeperContainerDiskIOLimitDispatcher.java +++ b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/healthcheck/nonredis/keepercontainer/KeeperContainerDiskIOLimitDispatcher.java @@ -2,7 +2,7 @@ import com.ctrip.xpipe.api.foundation.FoundationService; import com.ctrip.xpipe.api.monitor.EventMonitor; -import com.ctrip.xpipe.redis.checker.KeeperContainerService; +import com.ctrip.xpipe.redis.checker.KeeperContainerCheckerService; import com.ctrip.xpipe.redis.checker.alert.ALERT_TYPE; import com.ctrip.xpipe.redis.console.AbstractSiteLeaderIntervalAction; import com.ctrip.xpipe.redis.console.config.ConsoleConfig; @@ -34,7 +34,7 @@ public class KeeperContainerDiskIOLimitDispatcher extends AbstractSiteLeaderIntervalAction { @Autowired - private KeeperContainerService keeperContainerService; + private KeeperContainerCheckerService keeperContainerCheckerService; @Autowired private MetaCache metaCache; @@ -71,7 +71,7 @@ protected void run() { EventMonitor.DEFAULT.logEvent(ALERT_EVENT, "unknownLimit"); } else { try { - keeperContainerService.setKeeperContainerDiskIOLimit(keepercontainer.getIp(), keepercontainer.getPort(), megaByte2Byte(limit)); + keeperContainerCheckerService.setKeeperContainerDiskIOLimit(keepercontainer.getIp(), keepercontainer.getPort(), megaByte2Byte(limit)); EventMonitor.DEFAULT.logEvent(ALERT_EVENT, "success"); } catch (Throwable th) { logger.warn("[doAction][fail] {}", keepercontainer, th); diff --git a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/keeper/command/KeeperResetCommand.java b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/keeper/command/KeeperResetCommand.java index 85ae18a637..34be8ad12e 100644 --- a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/keeper/command/KeeperResetCommand.java +++ b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/keeper/command/KeeperResetCommand.java @@ -1,7 +1,7 @@ package com.ctrip.xpipe.redis.console.keeper.command; import com.ctrip.xpipe.command.AbstractCommand; -import com.ctrip.xpipe.redis.checker.KeeperContainerService; +import com.ctrip.xpipe.redis.checker.KeeperContainerCheckerService; public class KeeperResetCommand extends AbstractCommand { @@ -9,12 +9,12 @@ public class KeeperResetCommand extends AbstractCommand { private long shardId; - private KeeperContainerService keeperContainerService; + private KeeperContainerCheckerService keeperContainerCheckerService; - public KeeperResetCommand(String activeKeeperIp, long shardId, KeeperContainerService keeperContainerService) { + public KeeperResetCommand(String activeKeeperIp, long shardId, KeeperContainerCheckerService keeperContainerCheckerService) { this.activeKeeperIp = activeKeeperIp; this.shardId = shardId; - this.keeperContainerService = keeperContainerService; + this.keeperContainerCheckerService = keeperContainerCheckerService; } @Override @@ -24,7 +24,7 @@ public String getName() { @Override protected void doExecute() throws Throwable { - keeperContainerService.resetKeeper(activeKeeperIp, shardId); + keeperContainerCheckerService.resetKeeper(activeKeeperIp, shardId); this.future().setSuccess(); } diff --git a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/service/impl/KeeperContainerServiceImpl.java b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/service/impl/KeeperContainerService.java similarity index 97% rename from redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/service/impl/KeeperContainerServiceImpl.java rename to redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/service/impl/KeeperContainerService.java index 2d717acda3..de865559cd 100644 --- a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/service/impl/KeeperContainerServiceImpl.java +++ b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/service/impl/KeeperContainerService.java @@ -2,7 +2,6 @@ import com.ctrip.xpipe.endpoint.HostPort; import com.ctrip.xpipe.exception.XpipeRuntimeException; -import com.ctrip.xpipe.redis.checker.model.KeeperContainerUsedInfoModel; import com.ctrip.xpipe.redis.checker.spring.ConsoleDisableDbCondition; import com.ctrip.xpipe.redis.checker.spring.DisableDbMode; import com.ctrip.xpipe.redis.console.constant.XPipeConsoleConstant; @@ -12,8 +11,6 @@ import com.ctrip.xpipe.redis.console.model.*; import com.ctrip.xpipe.redis.console.query.DalQuery; import com.ctrip.xpipe.redis.console.service.*; -import com.ctrip.xpipe.redis.core.entity.KeeperInstanceMeta; -import com.ctrip.xpipe.redis.core.entity.KeeperTransMeta; import com.ctrip.xpipe.spring.RestTemplateFactory; import com.ctrip.xpipe.utils.StringUtil; import com.ctrip.xpipe.utils.VisibleForTesting; @@ -22,11 +19,6 @@ import com.google.common.collect.Maps; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Conditional; -import org.springframework.core.ParameterizedTypeReference; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.MediaType; import org.springframework.stereotype.Service; import org.springframework.web.client.RestClientException; import org.springframework.web.client.RestOperations; @@ -39,8 +31,8 @@ @Service @Conditional(ConsoleDisableDbCondition.class) @DisableDbMode(false) -public class KeeperContainerServiceImpl extends AbstractConsoleService - implements KeeperContainerService { +public class KeeperContainerService extends AbstractConsoleService + implements com.ctrip.xpipe.redis.console.service.KeeperContainerService { @Autowired private ClusterService clusterService; diff --git a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/service/model/impl/ShardModelServiceImpl.java b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/service/model/impl/ShardModelServiceImpl.java index 4080e10b5f..5565166519 100644 --- a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/service/model/impl/ShardModelServiceImpl.java +++ b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/service/model/impl/ShardModelServiceImpl.java @@ -16,7 +16,7 @@ import com.ctrip.xpipe.redis.console.model.*; import com.ctrip.xpipe.redis.console.repository.AzGroupClusterRepository; import com.ctrip.xpipe.redis.console.service.*; -import com.ctrip.xpipe.redis.console.service.impl.KeeperContainerServiceImpl; +import com.ctrip.xpipe.redis.console.service.KeeperContainerService; import com.ctrip.xpipe.redis.console.service.model.ShardModelService; import com.ctrip.xpipe.utils.ObjectUtils; import com.ctrip.xpipe.utils.VisibleForTesting; @@ -27,7 +27,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import com.ctrip.xpipe.redis.checker.KeeperContainerService; +import com.ctrip.xpipe.redis.checker.KeeperContainerCheckerService; import javax.annotation.PostConstruct; import javax.annotation.Resource; @@ -57,9 +57,9 @@ public class ShardModelServiceImpl implements ShardModelService{ @Autowired private ReplDirectionService replDirectionService; @Autowired - private KeeperContainerServiceImpl keeperContainerServiceImpl; + private KeeperContainerService keeperContainerService; @Autowired - private KeeperContainerService keeperContainerService; + private KeeperContainerCheckerService keeperContainerCheckerService; @Autowired private AzGroupClusterRepository azGroupClusterRepository; @Autowired @@ -128,7 +128,7 @@ public List getMultiShardModel(final String dcName, final String clu return shardModels; } - Map containerIdDcMap = keeperContainerServiceImpl.keeperContainerIdDcMap(); + Map containerIdDcMap = keeperContainerService.keeperContainerIdDcMap(); for (int i = 0; i < shards.size(); i++) { ShardTbl shardInfo = shards.get(i); Future dcClusterShardFuture = dcClusterShardFutures.get(i); @@ -284,7 +284,7 @@ public boolean switchActiveKeeper(String activeIp, String backupIp, ShardModel s keepers.get(0).getRedisIp(), keepers.get(0).getRedisPort(), keepers.get(1).getRedisIp(), keepers.get(1).getRedisPort()); return false; } - Command switchMasterCommand = retryCommandFactory.createRetryCommand(new KeeperResetCommand<>(activeKeeper.getHost(), shardModel.getShardTbl().getId(), keeperContainerService)); + Command switchMasterCommand = retryCommandFactory.createRetryCommand(new KeeperResetCommand<>(activeKeeper.getHost(), shardModel.getShardTbl().getId(), keeperContainerCheckerService)); Command checkKeeperRoleCommand = retryCommandFactory.createRetryCommand(new CheckKeeperActiveCommand<>(keyedObjectPool, scheduled, backUpKeeper, true)); SequenceCommandChain chain = new SequenceCommandChain(false, false); chain.add(switchMasterCommand); @@ -337,7 +337,7 @@ public boolean migrateActiveKeeper(String dcName, String clusterName, ShardModel return false; } Command fullSyncJudgeRetryCommand = retryCommandFactory.createRetryCommand(new FullSyncJudgeCommand<>(keyedObjectPool, scheduled, activeKeeper, backUpKeeper, activeMasterReplOffset)); - Command switchmasterCommand = retryCommandFactory.createRetryCommand(new KeeperResetCommand<>(activeKeeper.getHost(), shardModel.getShardTbl().getId(), keeperContainerService)); + Command switchmasterCommand = retryCommandFactory.createRetryCommand(new KeeperResetCommand<>(activeKeeper.getHost(), shardModel.getShardTbl().getId(), keeperContainerCheckerService)); Command checkKeeperRoleCommand = retryCommandFactory.createRetryCommand(new CheckKeeperActiveCommand<>(keyedObjectPool, scheduled, backUpKeeper, true)); chain = new SequenceCommandChain(false, false); chain.add(fullSyncJudgeRetryCommand); diff --git a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/spring/CheckerContextConfig.java b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/spring/CheckerContextConfig.java index 5033143482..a2f06b4430 100644 --- a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/spring/CheckerContextConfig.java +++ b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/spring/CheckerContextConfig.java @@ -2,7 +2,7 @@ import com.ctrip.xpipe.api.foundation.FoundationService; import com.ctrip.xpipe.redis.checker.*; -import com.ctrip.xpipe.redis.checker.KeeperContainerService; +import com.ctrip.xpipe.redis.checker.KeeperContainerCheckerService; import com.ctrip.xpipe.redis.checker.alert.AlertManager; import com.ctrip.xpipe.redis.checker.cluster.AllCheckerLeaderElector; import com.ctrip.xpipe.redis.checker.cluster.GroupCheckerLeaderElector; @@ -200,8 +200,8 @@ public HealthCheckReporter healthCheckReporter(CheckerConfig checkerConfig, Chec @Bean @Profile(AbstractProfile.PROFILE_NAME_PRODUCTION) public KeeperContainerInfoReporter keeperContainerInfoReporter(RedisUsedMemoryCollector redisUsedMemoryCollector, - CheckerConsoleService checkerConsoleService, KeeperFlowCollector keeperFlowCollector, CheckerConfig config, KeeperContainerService keeperContainerService, MetaCache metaCache) { - return new KeeperContainerInfoReporter(redisUsedMemoryCollector, checkerConsoleService, keeperFlowCollector, config, keeperContainerService, metaCache); + CheckerConsoleService checkerConsoleService, KeeperFlowCollector keeperFlowCollector, CheckerConfig config, KeeperContainerCheckerService keeperContainerCheckerService, MetaCache metaCache) { + return new KeeperContainerInfoReporter(redisUsedMemoryCollector, checkerConsoleService, keeperFlowCollector, config, keeperContainerCheckerService, metaCache); } @Bean(name = "ALLCHECKER") diff --git a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/spring/ConsoleContextConfig.java b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/spring/ConsoleContextConfig.java index f57b6dae29..af236e7244 100644 --- a/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/spring/ConsoleContextConfig.java +++ b/redis/redis-console/src/main/java/com/ctrip/xpipe/redis/console/spring/ConsoleContextConfig.java @@ -4,14 +4,14 @@ import com.ctrip.xpipe.api.sso.LogoutHandler; import com.ctrip.xpipe.api.sso.UserInfoHolder; import com.ctrip.xpipe.redis.checker.DcRelationsService; -import com.ctrip.xpipe.redis.checker.KeeperContainerService; +import com.ctrip.xpipe.redis.checker.KeeperContainerCheckerService; import com.ctrip.xpipe.redis.checker.PersistenceCache; import com.ctrip.xpipe.redis.checker.config.impl.CheckConfigBean; import com.ctrip.xpipe.redis.checker.config.impl.CommonConfigBean; import com.ctrip.xpipe.redis.checker.config.impl.ConsoleConfigBean; import com.ctrip.xpipe.redis.checker.config.impl.DataCenterConfigBean; import com.ctrip.xpipe.redis.checker.healthcheck.actions.ping.PingService; -import com.ctrip.xpipe.redis.checker.impl.DefaultKeeperContainerService; +import com.ctrip.xpipe.redis.checker.impl.DefaultKeeperContainerCheckerService; import com.ctrip.xpipe.redis.checker.impl.TestMetaCache; import com.ctrip.xpipe.redis.checker.resource.DefaultCheckerConsoleService; import com.ctrip.xpipe.redis.checker.spring.ConsoleServerMode; @@ -191,8 +191,8 @@ public FoundationService foundationService() { } @Bean - public KeeperContainerService keeperContainerService() { - return new DefaultKeeperContainerService(); + public KeeperContainerCheckerService keeperContainerService() { + return new DefaultKeeperContainerCheckerService(); } @Bean diff --git a/redis/redis-console/src/test/java/com/ctrip/xpipe/redis/console/AllTests.java b/redis/redis-console/src/test/java/com/ctrip/xpipe/redis/console/AllTests.java index 4ae5e92b32..cacabe6d88 100644 --- a/redis/redis-console/src/test/java/com/ctrip/xpipe/redis/console/AllTests.java +++ b/redis/redis-console/src/test/java/com/ctrip/xpipe/redis/console/AllTests.java @@ -100,7 +100,7 @@ ClusterServiceImplTest.class, ClusterServiceImplTest2.class, RedisServiceImplTest.class, - KeeperContainerServiceImplTest.class, + KeeperContainerCheckerServiceImplTest.class, ShardServiceImplTest.class, ShardServiceImplTest2.class, ShardServiceTest2.class, diff --git a/redis/redis-console/src/test/java/com/ctrip/xpipe/redis/console/service/BasicServiceTest.java b/redis/redis-console/src/test/java/com/ctrip/xpipe/redis/console/service/BasicServiceTest.java index 3fa2b4227a..3225e24cb0 100644 --- a/redis/redis-console/src/test/java/com/ctrip/xpipe/redis/console/service/BasicServiceTest.java +++ b/redis/redis-console/src/test/java/com/ctrip/xpipe/redis/console/service/BasicServiceTest.java @@ -12,7 +12,7 @@ DcServiceTest.class, ClusterServiceTest.class, ShardServiceTest.class, - KeeperContainerServiceTest.class, + KeeperContainerCheckerServiceTest.class, SentinelGroupServiceTest.class, SentinelGroupServiceMockTest.class, SentinelServiceImplTest.class diff --git a/redis/redis-console/src/test/java/com/ctrip/xpipe/redis/console/service/KeeperContainerServiceTest.java b/redis/redis-console/src/test/java/com/ctrip/xpipe/redis/console/service/KeeperContainerCheckerServiceTest.java similarity index 90% rename from redis/redis-console/src/test/java/com/ctrip/xpipe/redis/console/service/KeeperContainerServiceTest.java rename to redis/redis-console/src/test/java/com/ctrip/xpipe/redis/console/service/KeeperContainerCheckerServiceTest.java index 94fdd5dbe9..af5afa60e8 100644 --- a/redis/redis-console/src/test/java/com/ctrip/xpipe/redis/console/service/KeeperContainerServiceTest.java +++ b/redis/redis-console/src/test/java/com/ctrip/xpipe/redis/console/service/KeeperContainerCheckerServiceTest.java @@ -4,7 +4,7 @@ import com.ctrip.xpipe.redis.console.model.KeepercontainerTbl; import com.ctrip.xpipe.redis.console.model.KeepercontainerTblDao; import com.ctrip.xpipe.redis.console.model.KeepercontainerTblEntity; -import com.ctrip.xpipe.redis.console.service.impl.KeeperContainerServiceImpl; +import com.ctrip.xpipe.redis.console.service.impl.KeeperContainerService; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -23,11 +23,11 @@ * Sep 26, 2016 */ @RunWith(MockitoJUnitRunner.class) -public class KeeperContainerServiceTest extends AbstractConsoleTest { +public class KeeperContainerCheckerServiceTest extends AbstractConsoleTest { @Mock private KeepercontainerTblDao mockedKeepercontainerTblDao; @InjectMocks - private KeeperContainerServiceImpl keeperContainerService; + private KeeperContainerService keeperContainerService; @Test public void testMetasService() { diff --git a/redis/redis-console/src/test/java/com/ctrip/xpipe/redis/console/service/impl/AzServiceImplTest.java b/redis/redis-console/src/test/java/com/ctrip/xpipe/redis/console/service/impl/AzServiceImplTest.java index e341c98f5b..6f54cf9f4d 100644 --- a/redis/redis-console/src/test/java/com/ctrip/xpipe/redis/console/service/impl/AzServiceImplTest.java +++ b/redis/redis-console/src/test/java/com/ctrip/xpipe/redis/console/service/impl/AzServiceImplTest.java @@ -26,7 +26,7 @@ public class AzServiceImplTest extends AbstractServiceImplTest{ private DcServiceImpl dcService; @Autowired - private KeeperContainerServiceImpl keeperContainerService; + private KeeperContainerService keeperContainerService; @Autowired private KeeperServiceImpl keeperService; diff --git a/redis/redis-console/src/test/java/com/ctrip/xpipe/redis/console/service/impl/KeeperContainerServiceImplTest.java b/redis/redis-console/src/test/java/com/ctrip/xpipe/redis/console/service/impl/KeeperContainerCheckerServiceImplTest.java similarity index 96% rename from redis/redis-console/src/test/java/com/ctrip/xpipe/redis/console/service/impl/KeeperContainerServiceImplTest.java rename to redis/redis-console/src/test/java/com/ctrip/xpipe/redis/console/service/impl/KeeperContainerCheckerServiceImplTest.java index d44405b440..eee42418a0 100644 --- a/redis/redis-console/src/test/java/com/ctrip/xpipe/redis/console/service/impl/KeeperContainerServiceImplTest.java +++ b/redis/redis-console/src/test/java/com/ctrip/xpipe/redis/console/service/impl/KeeperContainerCheckerServiceImplTest.java @@ -8,27 +8,18 @@ import com.ctrip.xpipe.redis.console.model.ClusterTbl; import com.ctrip.xpipe.redis.console.model.KeeperContainerInfoModel; import com.ctrip.xpipe.redis.console.model.KeepercontainerTbl; -import com.ctrip.xpipe.redis.core.entity.KeeperInstanceMeta; -import com.ctrip.xpipe.redis.core.entity.KeeperMeta; -import com.ctrip.xpipe.redis.core.entity.KeeperTransMeta; import com.ctrip.xpipe.spring.RestTemplateFactory; import com.ctrip.xpipe.utils.StringUtil; import org.junit.Assert; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; -import org.mockito.Mockito; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.ParameterizedTypeReference; -import org.springframework.http.*; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.web.client.RestTemplate; import java.io.IOException; -import java.util.ArrayList; import java.util.List; -import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; @@ -37,11 +28,11 @@ *

* Apr 06, 2017 */ -public class KeeperContainerServiceImplTest extends AbstractServiceImplTest{ +public class KeeperContainerCheckerServiceImplTest extends AbstractServiceImplTest{ @Autowired - private KeeperContainerServiceImpl keeperContainerService; + private KeeperContainerService keeperContainerService; @Autowired private ClusterDao clusterDao;