this.actor = requireNonNull(actor);
}
+ @Override
+ protected String memberId() {
+ return actor.memberId();
+ }
+
@Override
public <T> void persist(final T entry, final Consumer<T> callback) {
actor.persist(entry, callback::accept);
}
PersistenceControl(final RaftActor raftActor) {
- this(new DisabledRaftStorage(raftActor, raftActor.self()), new PekkoRaftStorage(raftActor));
+ this(new DisabledRaftStorage(raftActor.memberId(), raftActor, raftActor.self()),
+ new PekkoRaftStorage(raftActor));
}
@Override
}
}
+ private final String memberId;
private final ExecuteInSelfActor actor;
private final ActorRef actorRef;
- public DisabledRaftStorage(final ExecuteInSelfActor actor, final ActorRef actorRef) {
+ public DisabledRaftStorage(final String memberId, final ExecuteInSelfActor actor, final ActorRef actorRef) {
+ this.memberId = requireNonNull(memberId);
this.actor = requireNonNull(actor);
this.actorRef = requireNonNull(actorRef);
}
+ @Override
+ protected String memberId() {
+ return memberId;
+ }
+
/**
* {@inheritDoc}
*
*/
package org.opendaylight.controller.cluster.raft.spi;
+import com.google.common.base.MoreObjects;
+import com.google.common.base.MoreObjects.ToStringHelper;
import org.eclipse.jdt.annotation.NonNullByDefault;
/**
@NonNullByDefault
public abstract sealed class RaftStorage implements DataPersistenceProvider
permits DisabledRaftStorage, EnabledRaftStorage {
- // Nothing else for now, but there is lot more to come.
// FIXME: we should bave the concept of being 'open', when we have a thread pool to perform the asynchronous part
// of RaftActorSnapshotCohort.createSnapshot(), using virtual-thread-per-task
// - for small snapshots just use memory and throw them away as sson as unreferenced
// - for large snapshots keep them on disk even after they become unreferenced -- for some time, or journal
// activity.
+
+ /**
+ * Returns the member name associated with this storage.
+ *
+ * @return the member name associated with this storage
+ */
+ protected abstract String memberId();
+
+ @Override
+ public final String toString() {
+ return addToStringAtrributes(MoreObjects.toStringHelper(this)).toString();
+ }
+
+ protected ToStringHelper addToStringAtrributes(final ToStringHelper helper) {
+ return helper.add("memberId", memberId());
+ }
}