public class ClusterImpl extends Object implements ClusterApi
| Constructor and Description |
|---|
ClusterImpl(ClusterConfig config) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addJoinMember(Node joinMember)
后加入进来的节点
|
void |
broadcast(byte[] data)
在集群中广播消息
|
Node |
getLocalMember()
获取本地成员
|
Collection<Node> |
getRemoteMembers()
获取集群中的成员,不包含当前成员
|
Collection<Node> |
getSeedMembers()
获取种子成员
|
boolean |
isLateJoinMember()
是后加入的成员
|
TimerTask |
schedule(Runnable command,
long delay)
添加定时任务,注意:如果抛出异常,会终止后续任务,请自行处理异常
|
TimerTask |
schedule(Runnable command,
long delay,
Executor executor)
添加定时任务,注意:如果抛出异常,会终止后续任务,请自行处理异常
|
TimerTask |
scheduleOnce(Runnable command,
long delay)
添加定时任务
|
TimerTask |
scheduleOnce(Runnable command,
long delay,
Executor executor)
添加定时任务
|
boolean |
send(Node address,
byte[] data)
发送消息
|
ClusterSyncAckMessage |
sendSync(Node address,
byte[] message)
同步发送消息
|
void |
start()
启动
|
void |
stop()
停止
|
public ClusterImpl(ClusterConfig config)
public void start()
throws Exception
ClusterApistart in interface ClusterApiExceptionpublic void stop()
ClusterApistop in interface ClusterApipublic boolean send(Node address, byte[] data)
ClusterApisend in interface ClusterApiaddress - memberdata - 集群消息public ClusterSyncAckMessage sendSync(Node address, byte[] message)
ClusterApisendSync in interface ClusterApiaddress - Nodemessage - 集群消息public void broadcast(byte[] data)
ClusterApibroadcast in interface ClusterApidata - 集群消息public TimerTask schedule(Runnable command, long delay)
ClusterApischedule in interface ClusterApicommand - runnabledelay - delaypublic TimerTask schedule(Runnable command, long delay, Executor executor)
ClusterApischedule in interface ClusterApicommand - runnabledelay - delayexecutor - 用于自定义线程池,处理耗时业务public TimerTask scheduleOnce(Runnable command, long delay)
ClusterApischeduleOnce in interface ClusterApicommand - runnabledelay - delaypublic TimerTask scheduleOnce(Runnable command, long delay, Executor executor)
ClusterApischeduleOnce in interface ClusterApicommand - runnabledelay - delayexecutor - 用于自定义线程池,处理耗时业务public boolean isLateJoinMember()
ClusterApiisLateJoinMember in interface ClusterApipublic Collection<Node> getSeedMembers()
ClusterApigetSeedMembers in interface ClusterApipublic Collection<Node> getRemoteMembers()
ClusterApigetRemoteMembers in interface ClusterApipublic Node getLocalMember()
ClusterApigetLocalMember in interface ClusterApiprotected void addJoinMember(Node joinMember)
joinMember - joinMemberCopyright © 2025. All rights reserved.