public class BinaryStarReactorImpl extends Object implements BinaryStarReactor
BinaryStarReactor.Event, BinaryStarReactor.Mode, BinaryStarReactor.State
BSTAR_HEARTBEAT
Constructor and Description |
---|
BinaryStarReactorImpl(ManagedContext context,
BinaryStarReactor.Mode mode,
String local,
String remote)
This is the constructor for our
BinaryStarReactorImpl class. |
Modifier and Type | Method and Description |
---|---|
Reactor |
getReactor()
This method returns the underlying Reactor, so we can add
additional timers and readers.
|
void |
registerVoterSocket(Socket socket)
This method registers a client voter socket.
|
void |
setActiveHandler(LoopHandler handler)
Register handlers to be called each time there's a state change.
|
void |
setHeartbeatInterval(long heartbeatInterval)
Set the heartbeat interval used to detect peer outage.
|
void |
setPassiveHandler(LoopHandler handler)
Register handlers to be called each time there's a state change.
|
void |
setVoterHandler(LoopHandler handler)
Register handlers to be called each time there's a state change.
|
void |
start()
Start the configured reactor.
|
void |
stop()
Stop the reactor.
|
public BinaryStarReactorImpl(ManagedContext context, BinaryStarReactor.Mode mode, String local, String remote)
BinaryStarReactorImpl
class. We have to tell it
whether we're primary or backup server, as well as our local and
remote endpoints to bind and connect to.context
- The ManagedContextmode
- The connection mode, either primary or backuplocal
- The local socket endpoint for publishing eventsremote
- The remote socket endpoint for subscribing to eventspublic void start()
start
in interface BinaryStarReactor
public void stop()
stop
in interface BinaryStarReactor
public void registerVoterSocket(Socket socket)
BinaryStarReactorImpl
instance.registerVoterSocket
in interface BinaryStarReactor
socket
- The client socketpublic void setVoterHandler(LoopHandler handler)
setVoterHandler
in interface BinaryStarReactor
handler
- The handler for client eventspublic void setActiveHandler(LoopHandler handler)
setActiveHandler
in interface BinaryStarReactor
handler
- The handler for state change eventspublic void setPassiveHandler(LoopHandler handler)
setPassiveHandler
in interface BinaryStarReactor
handler
- The handler for state change eventspublic Reactor getReactor()
getReactor
in interface BinaryStarReactor
public void setHeartbeatInterval(long heartbeatInterval)
setHeartbeatInterval
in interface BinaryStarReactor
heartbeatInterval
- The heartbeat interval, in millisecondsCopyright © 2019. All rights reserved.