Skip to content

Commit

Permalink
Merge pull request #928 from ctripcorp/bugfix/metaserver
Browse files Browse the repository at this point in the history
remove wild keeper
  • Loading branch information
LanternLee authored Jan 20, 2025
2 parents 2828a3f + dcb88bd commit e070256
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ public void addKeeper(KeeperTransMeta keeperTransMeta) {
@Override
public void removeKeeper(KeeperTransMeta keeperTransMeta) {
try {
long clusterDbId = null == keeperTransMeta.getClusterDbId() ? 1:keeperTransMeta.getClusterDbId();
long shardDbId = null == keeperTransMeta.getShardDbId() ? 1:keeperTransMeta.getShardDbId();
restTemplate.exchange("http://{ip}:{port}/keepers/clusters/{clusterId}/shards/{shardId}",
HttpMethod.DELETE, new HttpEntity<Object>(keeperTransMeta), Void.class,
keeperContainerMeta.getIp(), keeperContainerMeta.getPort(), keeperTransMeta.getClusterDbId(),
keeperTransMeta.getShardDbId());
keeperContainerMeta.getIp(), keeperContainerMeta.getPort(), clusterDbId, shardDbId);
} catch (HttpStatusCodeException ex) {
throw KeeperContainerErrorParser.parseErrorFromHttpException(ex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public class DefaultKeeperStateController extends AbstractLifecycle implements K

private Logger logger = LoggerFactory.getLogger(getClass());

private int addKeeperSuccessTimeoutMilli = 180000;
private int removeKeeperSuccessTimeoutMilli = 60000;
private int addKeeperSuccessTimeoutMilli = 10000;
private int removeKeeperSuccessTimeoutMilli = 10000;

@Autowired
private KeeperContainerServiceFactory keeperContainerServiceFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@ public void testRemoveKeeper() throws Exception {
Assert.assertEquals(meta, Codec.DEFAULT.decode(request.getBody().readByteArray(), KeeperTransMeta.class));
}

@Test
public void testRemoveWithReplId() throws Exception {
this.webServer.enqueue(new MockResponse());
KeeperTransMeta meta = new KeeperTransMeta(1L, new KeeperMeta());
this.service.removeKeeper(meta);
RecordedRequest request = this.webServer.takeRequest();
Assert.assertEquals(HttpMethod.DELETE.toString(), request.getMethod());
Assert.assertEquals("/keepers/clusters/1/shards/1", request.getPath());
Assert.assertEquals(meta, Codec.DEFAULT.decode(request.getBody().readByteArray(), KeeperTransMeta.class));
}

private KeeperTransMeta mockKeeperMeta() {
return new KeeperTransMeta(1L, 1L, new KeeperMeta());
}
Expand Down

0 comments on commit e070256

Please sign in to comment.