use of io.aeron.cluster.client.ClusterException in project Aeron by real-logic.
the class LogReplication method isDone.
boolean isDone(final long nowNs) {
if (position == stopPosition && isStopped) {
return true;
}
if (position > stopPosition) {
throw new ClusterException("log replication has progressed past stopPosition: " + this);
}
if (nowNs >= progressCheckDeadlineNs) {
progressCheckDeadlineNs = nowNs + progressCheckIntervalNs;
if (NULL_COUNTER_ID != recordingPositionCounterId) {
final CountersReader counters = archive.context().aeron().countersReader();
final long recordingPosition = counters.getCounterValue(recordingPositionCounterId);
if (RecordingPos.isActive(counters, recordingPositionCounterId, recordingId) && recordingPosition > position) {
position = recordingPosition;
progressDeadlineNs = nowNs + progressCheckTimeoutNs;
}
}
}
if (nowNs >= progressDeadlineNs) {
if (position < stopPosition) {
throw new ClusterException("log replication has not progressed: " + this, AeronException.Category.WARN);
} else {
throw new ClusterException("log replication failed to stop: " + this);
}
}
return false;
}
use of io.aeron.cluster.client.ClusterException in project Aeron by real-logic.
the class ConsensusModuleContextTest method unknownTimerServiceSupplier.
@Test
void unknownTimerServiceSupplier() {
final String supplierName = "unknown timer service supplier";
System.setProperty(TIMER_SERVICE_SUPPLIER_PROP_NAME, supplierName);
try {
final ClusterException exception = assertThrows(ClusterException.class, context::conclude);
assertEquals("ERROR - invalid TimerServiceSupplier: " + supplierName, exception.getMessage());
} finally {
System.clearProperty(TIMER_SERVICE_SUPPLIER_PROP_NAME);
}
}
use of io.aeron.cluster.client.ClusterException in project Aeron by real-logic.
the class RecordingLogTest method shouldNotAllowInvalidateOfSnapshotWithoutParentTerm.
@Test
void shouldNotAllowInvalidateOfSnapshotWithoutParentTerm() {
try (RecordingLog recordingLog = new RecordingLog(tempDir, true)) {
recordingLog.appendSnapshot(-10, 1L, 0, 777L, 0, 0);
recordingLog.appendSnapshot(-11, 1L, 0, 777L, 0, SERVICE_ID);
final ClusterException ex = assertThrows(ClusterException.class, recordingLog::invalidateLatestSnapshot);
assertEquals("ERROR - no matching term for snapshot: leadershipTermId=1", ex.getMessage());
}
}
use of io.aeron.cluster.client.ClusterException in project Aeron by real-logic.
the class RecordingLogTest method appendTermShouldRejectNullValueAsRecordingId.
@Test
void appendTermShouldRejectNullValueAsRecordingId() {
try (RecordingLog recordingLog = new RecordingLog(tempDir, true)) {
final ClusterException exception = assertThrows(ClusterException.class, () -> recordingLog.appendTerm(NULL_VALUE, 0, 0, 0));
assertEquals("ERROR - invalid recordingId=-1", exception.getMessage());
assertEquals(0, recordingLog.entries().size());
}
}
use of io.aeron.cluster.client.ClusterException in project Aeron by real-logic.
the class RecordingLogTest method appendTermShouldNotAcceptDifferentRecordingIds.
@Test
void appendTermShouldNotAcceptDifferentRecordingIds() {
try (RecordingLog recordingLog = new RecordingLog(tempDir, true)) {
recordingLog.appendTerm(42, 0, 0, 0);
final ClusterException exception = assertThrows(ClusterException.class, () -> recordingLog.appendTerm(21, 1, 0, 0));
assertEquals("ERROR - invalid TERM recordingId=21, expected recordingId=42", exception.getMessage());
assertEquals(1, recordingLog.entries().size());
}
try (RecordingLog recordingLog = new RecordingLog(tempDir, true)) {
final ClusterException exception = assertThrows(ClusterException.class, () -> recordingLog.appendTerm(-5, -5, -5, -5));
assertEquals("ERROR - invalid TERM recordingId=-5, expected recordingId=42", exception.getMessage());
assertEquals(1, recordingLog.entries().size());
}
}
Aggregations