Skip to content

Commit

Permalink
change KeeperContainerService bean name to KeeperContainerCheckerService
Browse files Browse the repository at this point in the history
  • Loading branch information
yifuzhou committed Nov 21, 2024
1 parent 3a7a7a3 commit 5cd8582
Show file tree
Hide file tree
Showing 16 changed files with 50 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import java.util.List;

public interface KeeperContainerService {
public interface KeeperContainerCheckerService {

KeeperDiskInfo getKeeperDiskInfo(String keeperContainerIp) throws RestClientException;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -42,7 +42,7 @@ public class KeeperContainerInfoReporter implements GroupCheckerLeaderAware {

private CheckerConsoleService checkerConsoleService;

private KeeperContainerService keeperContainerService;
private KeeperContainerCheckerService keeperContainerCheckerService;

private CheckerConfig config;

Expand All @@ -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;
}

Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -50,7 +50,7 @@ public class KeeperUsedInfoReporterTest {
CheckerConfig config;

@Mock
KeeperContainerService keeperContainerService;
KeeperContainerCheckerService keeperContainerCheckerService;

@Mock
private MetaCache metaCache;
Expand Down Expand Up @@ -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
Expand All @@ -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))
Expand All @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;

Expand All @@ -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<MigrationKeeperContainerDetailModel> getAllReadyToMigrateKeeperContainers() {
Expand Down Expand Up @@ -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());
Expand All @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -34,7 +34,7 @@
public class KeeperContainerDiskIOLimitDispatcher extends AbstractSiteLeaderIntervalAction {

@Autowired
private KeeperContainerService keeperContainerService;
private KeeperContainerCheckerService keeperContainerCheckerService;

@Autowired
private MetaCache metaCache;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
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<T> extends AbstractCommand<T> {

private String activeKeeperIp;

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
Expand All @@ -24,7 +24,7 @@ public String getName() {

@Override
protected void doExecute() throws Throwable {
keeperContainerService.resetKeeper(activeKeeperIp, shardId);
keeperContainerCheckerService.resetKeeper(activeKeeperIp, shardId);
this.future().setSuccess();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -39,8 +31,8 @@
@Service
@Conditional(ConsoleDisableDbCondition.class)
@DisableDbMode(false)
public class KeeperContainerServiceImpl extends AbstractConsoleService<KeepercontainerTblDao>
implements KeeperContainerService {
public class KeeperContainerService extends AbstractConsoleService<KeepercontainerTblDao>
implements com.ctrip.xpipe.redis.console.service.KeeperContainerService {

@Autowired
private ClusterService clusterService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -128,7 +128,7 @@ public List<ShardModel> getMultiShardModel(final String dcName, final String clu
return shardModels;
}

Map<Long, Long> containerIdDcMap = keeperContainerServiceImpl.keeperContainerIdDcMap();
Map<Long, Long> containerIdDcMap = keeperContainerService.keeperContainerIdDcMap();
for (int i = 0; i < shards.size(); i++) {
ShardTbl shardInfo = shards.get(i);
Future<DcClusterShardTbl> dcClusterShardFuture = dcClusterShardFutures.get(i);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -191,8 +191,8 @@ public FoundationService foundationService() {
}

@Bean
public KeeperContainerService keeperContainerService() {
return new DefaultKeeperContainerService();
public KeeperContainerCheckerService keeperContainerService() {
return new DefaultKeeperContainerCheckerService();
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
ClusterServiceImplTest.class,
ClusterServiceImplTest2.class,
RedisServiceImplTest.class,
KeeperContainerServiceImplTest.class,
KeeperContainerCheckerServiceImplTest.class,
ShardServiceImplTest.class,
ShardServiceImplTest2.class,
ShardServiceTest2.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
DcServiceTest.class,
ClusterServiceTest.class,
ShardServiceTest.class,
KeeperContainerServiceTest.class,
KeeperContainerCheckerServiceTest.class,
SentinelGroupServiceTest.class,
SentinelGroupServiceMockTest.class,
SentinelServiceImplTest.class
Expand Down
Loading

0 comments on commit 5cd8582

Please sign in to comment.