public class BasicAuctionClusteredService extends Object implements ClusteredService
| Modifier and Type | Field and Description |
|---|---|
static int |
BID_MESSAGE_LENGTH |
static int |
BID_SUCCEEDED_OFFSET |
static int |
CORRELATION_ID_OFFSET |
static int |
CUSTOMER_ID_OFFSET |
static int |
EGRESS_MESSAGE_LENGTH |
static int |
PRICE_OFFSET |
static int |
SNAPSHOT_CUSTOMER_ID_OFFSET |
static int |
SNAPSHOT_MESSAGE_LENGTH |
static int |
SNAPSHOT_PRICE_OFFSET |
| Constructor and Description |
|---|
BasicAuctionClusteredService() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object o) |
int |
hashCode() |
void |
onRoleChange(Cluster.Role newRole)
Notify that the cluster node has changed role.
|
void |
onSessionClose(ClientSession session,
long timestamp,
CloseReason closeReason)
A session has been closed for a client to the cluster.
|
void |
onSessionMessage(ClientSession session,
long timestamp,
DirectBuffer buffer,
int offset,
int length,
Header header)
A message has been received to be processed by a clustered service.
|
void |
onSessionOpen(ClientSession session,
long timestamp)
A session has been opened for a client to the cluster.
|
void |
onStart(Cluster cluster,
Image snapshotImage)
Start event for the service where the service can perform any initialisation required and load snapshot state.
|
void |
onTakeSnapshot(ExclusivePublication snapshotPublication)
The service should take a snapshot and store its state to the provided archive
Publication. |
void |
onTerminate(Cluster cluster)
Called when the container is going to terminate.
|
void |
onTimerEvent(long correlationId,
long timestamp)
A scheduled timer has expired.
|
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitonNewLeadershipTermEventpublic static final int CORRELATION_ID_OFFSET
public static final int CUSTOMER_ID_OFFSET
public static final int PRICE_OFFSET
public static final int BID_MESSAGE_LENGTH
public static final int BID_SUCCEEDED_OFFSET
public static final int EGRESS_MESSAGE_LENGTH
public static final int SNAPSHOT_CUSTOMER_ID_OFFSET
public static final int SNAPSHOT_PRICE_OFFSET
public static final int SNAPSHOT_MESSAGE_LENGTH
public void onStart(Cluster cluster, Image snapshotImage)
ClusteredService
Note: As this is a potentially long running operation the implementation should use
Cluster.idleStrategy() and then occasionally call IdleStrategy.idle() or
IdleStrategy.idle(int), especially when polling the Image returns 0.
onStart in interface ClusteredServicecluster - with which the service can interact.snapshotImage - from which the service can load its archived state which can be null when no snapshot.public void onSessionMessage(ClientSession session, long timestamp, DirectBuffer buffer, int offset, int length, Header header)
ClusteredServiceonSessionMessage in interface ClusteredServicesession - for the client which sent the message. This can be null if the client was a service.timestamp - for when the message was received.buffer - containing the message.offset - in the buffer at which the message is encoded.length - of the encoded message.header - aeron header for the incoming message.public void onTakeSnapshot(ExclusivePublication snapshotPublication)
ClusteredServicePublication.
Note: As this is a potentially long running operation the implementation should use
Cluster.idleStrategy() and then occasionally call IdleStrategy.idle() or
IdleStrategy.idle(int),
especially when the snapshot ExclusivePublication returns Publication.BACK_PRESSURED.
onTakeSnapshot in interface ClusteredServicesnapshotPublication - to which the state should be recorded.public void onRoleChange(Cluster.Role newRole)
ClusteredServiceonRoleChange in interface ClusteredServicenewRole - that the node has assumed.public void onTerminate(Cluster cluster)
ClusteredServiceonTerminate in interface ClusteredServicecluster - with which the service can interact.public void onSessionOpen(ClientSession session, long timestamp)
ClusteredServiceonSessionOpen in interface ClusteredServicesession - for the client which have been opened.timestamp - at which the session was opened.public void onSessionClose(ClientSession session, long timestamp, CloseReason closeReason)
ClusteredServiceonSessionClose in interface ClusteredServicesession - that has been closed.timestamp - at which the session was closed.closeReason - the session was closed.public void onTimerEvent(long correlationId,
long timestamp)
ClusteredServiceonTimerEvent in interface ClusteredServicecorrelationId - for the expired timer.timestamp - at which the timer expired.Copyright © 2014-2020 Real Logic Limited. All Rights Reserved.