@Override public boolean equals(Object obj) { if (!(obj instanceof StateSnapshotMetadata)) { return false; } final StateSnapshotMetadata other = (StateSnapshotMetadata) obj; return getLastSuccessfulProcessedEventPosition() == other.getLastSuccessfulProcessedEventPosition() && getLastWrittenEventPosition() == other.getLastWrittenEventPosition() && getLastWrittenEventTerm() == other.getLastWrittenEventTerm(); }
public List<StateSnapshotMetadata> listRecoverable(long lastSuccessfulProcessedEventPosition) { return list(s -> s.getLastWrittenEventPosition() <= lastSuccessfulProcessedEventPosition); }
/** * @param term the current term * @return a snapshot metadata based on nothing but the term */ public static StateSnapshotMetadata createInitial(int term) { return new StateSnapshotMetadata( INITIAL_LAST_PROCESSED_EVENT_POSITION, INITIAL_LAST_WRITTEN_EVENT_POSITION, term, false); }
@Override public String toString() { return "StateSnapshotMetadata{" + "lastSuccessfulProcessedEventPosition=" + getLastSuccessfulProcessedEventPosition() + ", lastWrittenEventPosition=" + getLastWrittenEventPosition() + ", lastWrittenEventTerm=" + getLastWrittenEventTerm() + ", exists=" + exists() + '}'; }
public boolean isInitial() { return getLastSuccessfulProcessedEventPosition() == INITIAL_LAST_PROCESSED_EVENT_POSITION && getLastWrittenEventPosition() == INITIAL_LAST_WRITTEN_EVENT_POSITION; }
@Override public void takeSnapshot(final StateSnapshotMetadata metadata) { if (db == null) { throw new IllegalStateException("Cannot create snapshot of not open database."); } if (exists(metadata)) { return; } final File snapshotDir = storage.getSnapshotDirectoryFor(metadata); db.createSnapshot(snapshotDir); }
public List<StateSnapshotMetadata> list() { return list(s -> true); }
/** * Purges old and invalid snapshots. Should be done once we are sure we can discard other * snapshots, e.g. during recovery. * * @param metadata last taken/recovered snapshot metadata */ default void purgeAllExcept(StateSnapshotMetadata metadata) throws Exception { purgeAll(s -> !s.equals(metadata)); } }
@Override public ZeebeDb openDb() { db = zeebeDbFactory.createDb(storage.getRuntimeDirectory()); return db; }
@Override public String toString() { return "StateSnapshotMetadata{" + "lastSuccessfulProcessedEventPosition=" + getLastSuccessfulProcessedEventPosition() + ", lastWrittenEventPosition=" + getLastWrittenEventPosition() + ", lastWrittenEventTerm=" + getLastWrittenEventTerm() + ", exists=" + exists() + '}'; }
@Override public boolean equals(Object obj) { if (!(obj instanceof StateSnapshotMetadata)) { return false; } final StateSnapshotMetadata other = (StateSnapshotMetadata) obj; return getLastSuccessfulProcessedEventPosition() == other.getLastSuccessfulProcessedEventPosition() && getLastWrittenEventPosition() == other.getLastWrittenEventPosition() && getLastWrittenEventTerm() == other.getLastWrittenEventTerm(); }
public List<StateSnapshotMetadata> listRecoverable(long lastSuccessfulProcessedEventPosition) { return list(s -> s.getLastWrittenEventPosition() <= lastSuccessfulProcessedEventPosition); }
public boolean isInitial() { return getLastSuccessfulProcessedEventPosition() == INITIAL_LAST_PROCESSED_EVENT_POSITION && getLastWrittenEventPosition() == INITIAL_LAST_WRITTEN_EVENT_POSITION; }
@Override public void takeSnapshot(final StateSnapshotMetadata metadata) { if (db == null) { throw new IllegalStateException("Cannot create snapshot of not open database."); } if (exists(metadata)) { return; } final File snapshotDir = storage.getSnapshotDirectoryFor(metadata); db.createSnapshot(snapshotDir); }
/** * @param term the current term * @return a snapshot metadata based on nothing but the term */ public static StateSnapshotMetadata createInitial(int term) { return new StateSnapshotMetadata( INITIAL_LAST_PROCESSED_EVENT_POSITION, INITIAL_LAST_WRITTEN_EVENT_POSITION, term, false); }
public List<StateSnapshotMetadata> list() { return list(s -> true); }
/** * Purges old and invalid snapshots. Should be done once we are sure we can discard other * snapshots, e.g. during recovery. * * @param metadata last taken/recovered snapshot metadata */ default void purgeAllExcept(StateSnapshotMetadata metadata) throws Exception { purgeAll(s -> !s.equals(metadata)); } }
@Override public ZeebeDb openDb() { db = zeebeDbFactory.createDb(storage.getRuntimeDirectory()); return db; }
@Override public int hashCode() { return Objects.hash( getLastSuccessfulProcessedEventPosition(), getLastWrittenEventPosition(), getLastWrittenEventTerm(), exists()); }
@Override public int hashCode() { return Objects.hash( getLastSuccessfulProcessedEventPosition(), getLastWrittenEventPosition(), getLastWrittenEventTerm(), exists()); }