use of io.dingodb.store.row.StateListener in project dingo by dingodb.
the class KVStoreStateMachine method onLeaderStop.
@Override
public void onLeaderStop(final Status status) {
super.onLeaderStop(status);
final long oldTerm = this.leaderTerm.get();
this.leaderTerm.set(-1L);
// Because of the raft state machine must be a sequential commit, in order to prevent the user
// doing something (needs to go through the raft state machine) in the listeners, we asynchronously
// triggers the listeners.
final List<StateListener> listeners = //
this.storeEngine.getStateListenerContainer().getStateListenerGroup(getRegionId());
if (listeners.isEmpty()) {
return;
}
this.storeEngine.getRaftStateTrigger().execute(() -> {
for (final StateListener listener : listeners) {
// iterator the snapshot
listener.onLeaderStop(oldTerm);
}
});
}
use of io.dingodb.store.row.StateListener in project dingo by dingodb.
the class KVStoreStateMachine method onStartFollowing.
@Override
public void onStartFollowing(final LeaderChangeContext ctx) {
super.onStartFollowing(ctx);
// Because of the raft state machine must be a sequential commit, in order to prevent the user
// doing something (needs to go through the raft state machine) in the listeners, we need
// asynchronously triggers the listeners.
final List<StateListener> listeners = //
this.storeEngine.getStateListenerContainer().getStateListenerGroup(getRegionId());
if (listeners.isEmpty()) {
return;
}
this.storeEngine.getRaftStateTrigger().execute(() -> {
for (final StateListener listener : listeners) {
// iterator the snapshot
listener.onStartFollowing(ctx.getLeaderId(), ctx.getTerm());
}
});
}
use of io.dingodb.store.row.StateListener in project dingo by dingodb.
the class KVStoreStateMachine method onStopFollowing.
@Override
public void onStopFollowing(final LeaderChangeContext ctx) {
super.onStopFollowing(ctx);
// Because of the raft state machine must be a sequential commit, in order to prevent the user
// doing something (needs to go through the raft state machine) in the listeners, we need
// asynchronously triggers the listeners.
final List<StateListener> listeners = //
this.storeEngine.getStateListenerContainer().getStateListenerGroup(getRegionId());
if (listeners.isEmpty()) {
return;
}
this.storeEngine.getRaftStateTrigger().execute(() -> {
for (final StateListener listener : listeners) {
// iterator the snapshot
listener.onStopFollowing(ctx.getLeaderId(), ctx.getTerm());
}
});
}
use of io.dingodb.store.row.StateListener in project dingo by dingodb.
the class KVStoreStateMachine method onLeaderStart.
@Override
public void onLeaderStart(final long term) {
super.onLeaderStart(term);
this.leaderTerm.set(term);
// Because of the raft state machine must be a sequential commit, in order to prevent the user
// doing something (needs to go through the raft state machine) in the listeners, we need
// asynchronously triggers the listeners.
final List<StateListener> listeners = //
this.storeEngine.getStateListenerContainer().getStateListenerGroup(getRegionId());
if (listeners.isEmpty()) {
return;
}
this.storeEngine.getRaftStateTrigger().execute(() -> {
for (final StateListener listener : listeners) {
// iterator the snapshot
listener.onLeaderStart(term);
}
});
}
Aggregations