-
Notifications
You must be signed in to change notification settings - Fork 507
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
yifuzhou
committed
May 23, 2024
1 parent
4ba3726
commit 8b9e56c
Showing
32 changed files
with
624 additions
and
414 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
.../src/main/java/com/ctrip/xpipe/redis/console/keeper/Command/CheckKeeperActiveCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.ctrip.xpipe.redis.console.keeper.Command; | ||
|
||
import com.ctrip.xpipe.api.endpoint.Endpoint; | ||
import com.ctrip.xpipe.pool.XpipeNettyClientKeyedObjectPool; | ||
import com.ctrip.xpipe.redis.core.protocal.cmd.InfoCommand; | ||
import com.ctrip.xpipe.redis.core.protocal.cmd.InfoResultExtractor; | ||
import com.ctrip.xpipe.utils.VisibleForTesting; | ||
|
||
import java.util.concurrent.ScheduledExecutorService; | ||
|
||
public class CheckKeeperActiveCommand<T> extends AbstractKeeperCommand<T>{ | ||
|
||
private Endpoint keeper; | ||
|
||
private boolean expectedActive; | ||
|
||
public CheckKeeperActiveCommand(XpipeNettyClientKeyedObjectPool keyedObjectPool, ScheduledExecutorService scheduled, Endpoint keeper, boolean expectedActive) { | ||
super(keyedObjectPool, scheduled); | ||
this.keeper = keeper; | ||
this.expectedActive = expectedActive; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "CheckKeeperActiveCommand"; | ||
} | ||
|
||
@Override | ||
protected void doExecute() throws Throwable { | ||
InfoCommand infoCommand = generateInfoReplicationCommand(keeper); | ||
if (new InfoResultExtractor(infoCommand.execute().get()).isKeeperActive() == expectedActive) { | ||
this.future().setSuccess(); | ||
return; | ||
} | ||
this.future().setFailure(new Exception(String.format("keeper: %s is not %s", keeper, expectedActive))); | ||
} | ||
|
||
@Override | ||
protected void doReset() { | ||
|
||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...c/main/java/com/ctrip/xpipe/redis/console/keeper/Command/CheckKeeperConnectedCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.ctrip.xpipe.redis.console.keeper.Command; | ||
|
||
import com.ctrip.xpipe.api.endpoint.Endpoint; | ||
import com.ctrip.xpipe.pool.XpipeNettyClientKeyedObjectPool; | ||
import com.ctrip.xpipe.redis.core.protocal.cmd.RoleCommand; | ||
import com.ctrip.xpipe.redis.core.protocal.pojo.SlaveRole; | ||
|
||
import java.util.concurrent.ScheduledExecutorService; | ||
|
||
import static com.ctrip.xpipe.redis.core.protocal.MASTER_STATE.REDIS_REPL_CONNECTED; | ||
|
||
public class CheckKeeperConnectedCommand<T> extends AbstractKeeperCommand<T> { | ||
|
||
private Endpoint keeper; | ||
|
||
public CheckKeeperConnectedCommand(XpipeNettyClientKeyedObjectPool keyedObjectPool, ScheduledExecutorService scheduled, Endpoint keeper) { | ||
super(keyedObjectPool, scheduled); | ||
this.keeper = keeper; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "CheckKeeperConnectedCommand"; | ||
} | ||
|
||
@Override | ||
protected void doExecute() throws Throwable { | ||
SlaveRole role = (SlaveRole)new RoleCommand(keyedObjectPool.getKeyPool(keeper), scheduled).execute().get(); | ||
if (REDIS_REPL_CONNECTED == role.getMasterState()) { | ||
this.future().setSuccess(); | ||
return; | ||
} | ||
this.future().setFailure(new Exception(String.format("ping %s has no pong response", keeper))); | ||
} | ||
|
||
@Override | ||
protected void doReset() { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...ava/com/ctrip/xpipe/redis/console/keeper/Command/KeeperContainerReplOffsetGetCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.ctrip.xpipe.redis.console.keeper.Command; | ||
|
||
import com.ctrip.xpipe.api.endpoint.Endpoint; | ||
import com.ctrip.xpipe.pool.XpipeNettyClientKeyedObjectPool; | ||
import com.ctrip.xpipe.redis.core.protocal.cmd.InfoResultExtractor; | ||
|
||
import java.util.concurrent.ScheduledExecutorService; | ||
|
||
public class KeeperContainerReplOffsetGetCommand<V> extends AbstractKeeperCommand<Object>{ | ||
|
||
private Endpoint keeper; | ||
|
||
public KeeperContainerReplOffsetGetCommand(XpipeNettyClientKeyedObjectPool keyedObjectPool, ScheduledExecutorService scheduled, Endpoint keeper) { | ||
super(keyedObjectPool, scheduled); | ||
this.keeper = keeper; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "KeeperContainerReplOffsetGetCommand"; | ||
} | ||
|
||
@Override | ||
protected void doExecute() throws Throwable { | ||
this.future().setSuccess(new InfoResultExtractor(generateInfoReplicationCommand(keeper).execute().get()).getMasterReplOffset()); | ||
} | ||
|
||
@Override | ||
protected void doReset() { | ||
|
||
} | ||
} |
Oops, something went wrong.