use of org.apache.ratis.conf.RaftProperties in project incubator-ratis by apache.
the class TestExceptionDependentRetry method testExceptionRetryAttempts.
@Test
public void testExceptionRetryAttempts() throws Exception {
final RaftProperties prop = getProperties();
RaftClientConfigKeys.Rpc.setRequestTimeout(prop, TimeDuration.valueOf(100, TimeUnit.MILLISECONDS));
prop.setClass(MiniRaftCluster.STATEMACHINE_CLASS_KEY, SimpleStateMachine4Testing.class, StateMachine.class);
RaftServerConfigKeys.Write.setElementLimit(prop, 1);
runWithNewCluster(1, this::runTestExceptionRetryAttempts);
}
use of org.apache.ratis.conf.RaftProperties in project incubator-ratis by apache.
the class ServerRestartTests method testRestartWithCorruptedLogEntryWithException.
@Test
public void testRestartWithCorruptedLogEntryWithException() throws Exception {
final RaftProperties p = getProperties();
final Log.CorruptionPolicy policy = Log.corruptionPolicy(p);
Log.setCorruptionPolicy(p, Log.CorruptionPolicy.EXCEPTION);
testFailureCase("restart-fail-ChecksumException", () -> runWithNewCluster(1, this::runTestRestartWithCorruptedLogEntry), CompletionException.class, ChecksumException.class);
Log.setCorruptionPolicy(p, policy);
}
use of org.apache.ratis.conf.RaftProperties in project incubator-ratis by apache.
the class MemoryRaftLogTest method testEntryPerformTruncation.
@Test
public void testEntryPerformTruncation() throws Exception {
final RaftProperties prop = new RaftProperties();
prop.setClass(MiniRaftCluster.STATEMACHINE_CLASS_KEY, SimpleStateMachine4Testing.class, StateMachine.class);
final RaftPeerId peerId = RaftPeerId.valueOf("s0");
final RaftGroupId groupId = RaftGroupId.randomId();
final RaftGroupMemberId memberId = RaftGroupMemberId.valueOf(peerId, groupId);
MemoryRaftLog raftLog = new MemoryRaftLog(memberId, () -> -1, prop);
raftLog.open(RaftLog.INVALID_LOG_INDEX, null);
LogEntryProto[] entries1 = new LogEntryProto[2];
entries1[0] = LogEntryProto.newBuilder().setIndex(0).setTerm(0).build();
entries1[1] = LogEntryProto.newBuilder().setIndex(1).setTerm(0).build();
raftLog.append(entries1).forEach(CompletableFuture::join);
LogEntryProto[] entries2 = new LogEntryProto[1];
entries2[0] = LogEntryProto.newBuilder().setIndex(0).setTerm(2).build();
raftLog.append(entries2).forEach(CompletableFuture::join);
final LogEntryHeader[] termIndices = raftLog.getEntries(0, 10);
assertEquals(1, termIndices.length);
assertEquals(entries2[0].getIndex(), termIndices[0].getIndex());
assertEquals(entries2[0].getTerm(), termIndices[0].getTerm());
}
use of org.apache.ratis.conf.RaftProperties in project incubator-ratis by apache.
the class TestRaftServerConfigKeys method testStorageDirProperty.
/**
* Sets the value to <code>raft.server.storage.dir</code> via
* RaftServerConfigKeys and verifies it by reading directly from property.
*/
@Test
public void testStorageDirProperty() {
final File testDir = new File(rootTestDir.get(), UUID.randomUUID().toString());
final List<File> directories = new ArrayList<>();
final RaftProperties properties = new RaftProperties();
IntStream.range(0, 10).mapToObj((i) -> new File(testDir, Integer.toString(i))).forEach(directories::add);
RaftServerConfigKeys.setStorageDir(properties, directories);
final String expected = directories.stream().map(File::getAbsolutePath).collect(Collectors.joining(","));
final String actual = properties.get(RaftServerConfigKeys.STORAGE_DIR_KEY);
Assert.assertEquals(expected, actual);
}
use of org.apache.ratis.conf.RaftProperties in project incubator-ratis by apache.
the class TestRaftServerConfigKeys method testPendingRequestSize.
/**
* Sets the value to <code>raft.server.write.byte-limit</code> via
* RaftServerConfigKeys and also verifies the same via RaftServerConfigKeys.
*/
@Test
public void testPendingRequestSize() {
RaftProperties properties = new RaftProperties();
// setting to 4GB
setSizeInBytes(properties::set, BYTE_LIMIT_KEY, SizeInBytes.valueOf("4gb"), requireMin(1L));
int pendingRequestMegabyteLimit = Math.toIntExact(RaftServerConfigKeys.Write.byteLimit(properties).getSize() / SizeInBytes.ONE_MB.getSize());
Assert.assertEquals(4096, pendingRequestMegabyteLimit);
}
Aggregations