Search in sources :

Example 6 with RaftProperties

use of org.apache.ratis.conf.RaftProperties in project incubator-ratis by apache.

the class TestRaftLogReadWrite method setup.

@Before
public void setup() throws Exception {
    storageDir = getTestDir();
    RaftProperties properties = new RaftProperties();
    RaftServerConfigKeys.setStorageDir(properties, storageDir);
    this.segmentMaxSize = RaftServerConfigKeys.Log.segmentSizeMax(properties).getSize();
    this.preallocatedSize = RaftServerConfigKeys.Log.preallocatedSize(properties).getSize();
    this.bufferSize = RaftServerConfigKeys.Log.writeBufferSize(properties).getSizeInt();
}
Also used : RaftProperties(org.apache.ratis.conf.RaftProperties) Before(org.junit.Before)

Example 7 with RaftProperties

use of org.apache.ratis.conf.RaftProperties in project incubator-ratis by apache.

the class Client method run.

@Override
public void run() throws Exception {
    int raftSegmentPreallocatedSize = 1024 * 1024 * 1024;
    RaftProperties raftProperties = new RaftProperties();
    RaftConfigKeys.Rpc.setType(raftProperties, SupportedRpcType.GRPC);
    GrpcConfigKeys.setMessageSizeMax(raftProperties, SizeInBytes.valueOf(raftSegmentPreallocatedSize));
    RaftServerConfigKeys.Log.Appender.setBufferByteLimit(raftProperties, SizeInBytes.valueOf(raftSegmentPreallocatedSize));
    RaftServerConfigKeys.Log.setWriteBufferSize(raftProperties, SizeInBytes.valueOf(raftSegmentPreallocatedSize));
    RaftServerConfigKeys.Log.setPreallocatedSize(raftProperties, SizeInBytes.valueOf(raftSegmentPreallocatedSize));
    RaftServerConfigKeys.Log.setSegmentSizeMax(raftProperties, SizeInBytes.valueOf(1 * 1024 * 1024 * 1024L));
    RaftConfigKeys.DataStream.setType(raftProperties, SupportedDataStreamType.NETTY);
    RaftServerConfigKeys.Log.setSegmentCacheNumMax(raftProperties, 2);
    RaftClientConfigKeys.Rpc.setRequestTimeout(raftProperties, TimeDuration.valueOf(50000, TimeUnit.MILLISECONDS));
    RaftClientConfigKeys.Async.setOutstandingRequestsMax(raftProperties, 1000);
    for (File dir : storageDir) {
        FileUtils.createDirectories(dir);
    }
    operation(getClients(raftProperties));
}
Also used : RaftProperties(org.apache.ratis.conf.RaftProperties) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File)

Example 8 with RaftProperties

use of org.apache.ratis.conf.RaftProperties in project incubator-ratis by apache.

the class TestRaftServerWithGrpc method setup.

@Before
public void setup() {
    final RaftProperties p = getProperties();
    p.setClass(MiniRaftCluster.STATEMACHINE_CLASS_KEY, SimpleStateMachine4Testing.class, StateMachine.class);
    RaftClientConfigKeys.Rpc.setRequestTimeout(p, TimeDuration.valueOf(1, TimeUnit.SECONDS));
}
Also used : RaftProperties(org.apache.ratis.conf.RaftProperties) Before(org.junit.Before)

Example 9 with RaftProperties

use of org.apache.ratis.conf.RaftProperties in project incubator-ratis by apache.

the class TestDataStreamDisabled method testDataStreamDisabled.

@Test
public void testDataStreamDisabled() {
    final RaftProperties properties = new RaftProperties();
    Assert.assertEquals(SupportedDataStreamType.DISABLED, RaftConfigKeys.DataStream.type(properties, LOG::info));
    final RaftPeer server = RaftPeer.newBuilder().setId("s0").build();
    final RaftClient client = RaftClient.newBuilder().setRaftGroup(RaftGroup.valueOf(RaftGroupId.randomId(), server)).setProperties(properties).build();
    exception.expect(UnsupportedOperationException.class);
    exception.expectMessage(DisabledDataStreamClientFactory.class.getName() + "$1 does not support streamAsync");
    // stream() will create a header request, thus it will hit UnsupportedOperationException due to
    // DisabledDataStreamFactory.
    client.getDataStreamApi().stream();
}
Also used : RaftProperties(org.apache.ratis.conf.RaftProperties) RaftPeer(org.apache.ratis.protocol.RaftPeer) RaftClient(org.apache.ratis.client.RaftClient) Test(org.junit.Test) BaseTest(org.apache.ratis.BaseTest)

Example 10 with RaftProperties

use of org.apache.ratis.conf.RaftProperties in project incubator-ratis by apache.

the class TestLogSegment method setup.

@Before
public void setup() {
    RaftProperties properties = new RaftProperties();
    storageDir = getTestDir();
    RaftServerConfigKeys.setStorageDir(properties, Collections.singletonList(storageDir));
    this.segmentMaxSize = RaftServerConfigKeys.Log.segmentSizeMax(properties).getSize();
    this.preallocatedSize = RaftServerConfigKeys.Log.preallocatedSize(properties).getSize();
    this.bufferSize = RaftServerConfigKeys.Log.writeBufferSize(properties).getSizeInt();
}
Also used : RaftProperties(org.apache.ratis.conf.RaftProperties) Before(org.junit.Before)

Aggregations

RaftProperties (org.apache.ratis.conf.RaftProperties)54 Test (org.junit.Test)22 BaseTest (org.apache.ratis.BaseTest)14 Before (org.junit.Before)12 RaftPeerId (org.apache.ratis.protocol.RaftPeerId)9 RaftServer (org.apache.ratis.server.RaftServer)8 File (java.io.File)7 CompletableFuture (java.util.concurrent.CompletableFuture)7 RaftClient (org.apache.ratis.client.RaftClient)7 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)5 Parameters (org.apache.ratis.conf.Parameters)4 LogEntryProto (org.apache.ratis.proto.RaftProtos.LogEntryProto)4 RaftGroupId (org.apache.ratis.protocol.RaftGroupId)4 RaftGroupMemberId (org.apache.ratis.protocol.RaftGroupMemberId)4 RaftGroup (org.apache.ratis.protocol.RaftGroup)3 StateMachine (org.apache.ratis.statemachine.StateMachine)3 TimeDuration (org.apache.ratis.util.TimeDuration)3 List (java.util.List)2 UUID (java.util.UUID)2