org.apache.ratis.conf.RaftProperties Java Examples

The following examples show how to use org.apache.ratis.conf.RaftProperties. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GrpcClientStreamer.java    From ratis with Apache License 2.0 6 votes vote down vote up
GrpcClientStreamer(RaftProperties prop, RaftGroup group,
    RaftPeerId leaderId, ClientId clientId, GrpcTlsConfig tlsConfig) {
  this.clientId = clientId;
  maxPendingNum = GrpcConfigKeys.OutputStream.outstandingAppendsMax(prop);
  maxMessageSize = GrpcConfigKeys.messageSizeMax(prop, LOG::debug);
  dataQueue = new ConcurrentLinkedDeque<>();
  ackQueue = new ConcurrentLinkedDeque<>();
  exceptionAndRetry = new ExceptionAndRetry(prop);

  this.groupId = group.getGroupId();
  this.peers = group.getPeers().stream().collect(
      Collectors.toMap(RaftPeer::getId, Function.identity()));
  proxyMap = new PeerProxyMap<>(clientId.toString(),
      raftPeer -> new GrpcClientProtocolProxy(clientId, raftPeer,
          ResponseHandler::new, prop, tlsConfig));
  proxyMap.addPeers(group.getPeers());
  refreshLeaderProxy(leaderId, null);

  senderThread = new Sender();
  senderThread.setName(this.toString() + "-sender");
  senderThread.start();
}
 
Example #2
Source File: WatchRequestTests.java    From incubator-ratis with Apache License 2.0 6 votes vote down vote up
@Test
public void testWatchRequestClientTimeout() throws Exception {
  final RaftProperties p = getProperties();
  RaftServerConfigKeys.Watch.setTimeout(p, TimeDuration.valueOf(100,
      TimeUnit.SECONDS));
  RaftClientConfigKeys.Rpc.setWatchRequestTimeout(p,
      TimeDuration.valueOf(15, TimeUnit.SECONDS));
  try {
    runWithNewCluster(NUM_SERVERS,
        cluster -> runSingleTest(WatchRequestTests::runTestWatchRequestClientTimeout, cluster, LOG));
  } finally {
    RaftServerConfigKeys.Watch.setTimeout(p, RaftServerConfigKeys.Watch.TIMEOUT_DEFAULT);
    RaftClientConfigKeys.Rpc.setWatchRequestTimeout(p,
        RaftClientConfigKeys.Rpc.WATCH_REQUEST_TIMEOUT_DEFAULT);
  }
}
 
Example #3
Source File: GrpcClientStreamer.java    From incubator-ratis with Apache License 2.0 6 votes vote down vote up
GrpcClientStreamer(RaftProperties prop, RaftGroup group,
    RaftPeerId leaderId, ClientId clientId, GrpcTlsConfig tlsConfig) {
  this.clientId = clientId;
  maxPendingNum = GrpcConfigKeys.OutputStream.outstandingAppendsMax(prop);
  maxMessageSize = GrpcConfigKeys.messageSizeMax(prop, LOG::debug);
  dataQueue = new ConcurrentLinkedDeque<>();
  ackQueue = new ConcurrentLinkedDeque<>();
  exceptionAndRetry = new ExceptionAndRetry(prop);

  this.groupId = group.getGroupId();
  this.peers = group.getPeers().stream().collect(
      Collectors.toMap(RaftPeer::getId, Function.identity()));
  proxyMap = new PeerProxyMap<>(clientId.toString(),
      raftPeer -> new GrpcClientProtocolProxy(clientId, raftPeer,
          ResponseHandler::new, prop, tlsConfig));
  proxyMap.addPeers(group.getPeers());
  refreshLeaderProxy(leaderId, null);

  senderThread = new Sender();
  senderThread.setName(this.toString() + "-sender");
  senderThread.start();
}
 
Example #4
Source File: TestRaftServerConfigKeys.java    From ratis with Apache License 2.0 6 votes vote down vote up
/**
 * Sets the value to <code>raft.server.storage.dir</code> via
 * RaftServerConfigKeys and also verifies the same via RaftServerConfigKeys.
 */
@Test
public void testStorageDirs() {
  final File testDir = new File(
      rootTestDir.get(), UUID.randomUUID().toString());
  final List<File> directories = new ArrayList<>();
  IntStream.range(0, 10).mapToObj((i) -> new File(testDir,
      Integer.toString(i))).forEach(directories::add);
  RaftProperties properties = new RaftProperties();
  RaftServerConfigKeys.setStorageDirs(properties, directories);

  final List<File> storageDirs = RaftServerConfigKeys.storageDirs(properties);
  final List<String> expectedDirs = directories.stream()
      .map(File::getAbsolutePath).collect(Collectors.toList());
  final List<String> actualDirs = storageDirs.stream()
      .map(File::getAbsolutePath).collect(Collectors.toList());
  actualDirs.removeAll(expectedDirs);
  Assert.assertEquals(directories.size(), storageDirs.size());
  Assert.assertEquals(0, actualDirs.size());
}
 
Example #5
Source File: RaftStateMachineExceptionTests.java    From ratis with Apache License 2.0 6 votes vote down vote up
@Test
public void testHandleStateMachineException() throws Exception {
  final RaftProperties prop = getProperties();
  prop.setClass(MiniRaftCluster.STATEMACHINE_CLASS_KEY,
      StateMachineWithException.class, StateMachine.class);
  final MiniRaftCluster cluster = newCluster(3);
  cluster.start();

  RaftPeerId leaderId = RaftTestUtil.waitForLeader(cluster).getId();

  try(final RaftClient client = cluster.createClient(leaderId)) {
    client.send(new RaftTestUtil.SimpleMessage("m"));
    fail("Exception expected");
  } catch (StateMachineException e) {
    e.printStackTrace();
    Assert.assertTrue(e.getCause().getMessage().contains("Fake Exception"));
  }
  cluster.shutdown();
}
 
Example #6
Source File: TestRaftServerJmx.java    From ratis with Apache License 2.0 6 votes vote down vote up
@Test(timeout = 30000)
public void testJmxBeans() throws Exception {
  final int NUM_SERVERS = 3;
  final MiniRaftClusterWithSimulatedRpc cluster
      = MiniRaftClusterWithSimulatedRpc.FACTORY.newCluster(3, new RaftProperties());
  cluster.start();
  waitForLeader(cluster);

  MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
  Set<ObjectInstance> objectInstances = platformMBeanServer.queryMBeans(new ObjectName("Ratis:*"), null);
  Assert.assertEquals(NUM_SERVERS, objectInstances.size());

  for (ObjectInstance instance : objectInstances) {
    Object groupId = platformMBeanServer.getAttribute(instance.getObjectName(), "GroupId");
    Assert.assertEquals(cluster.getGroupId().toString(), groupId);
  }
  cluster.shutdown();
}
 
Example #7
Source File: TestRatisHelper.java    From hadoop-ozone with Apache License 2.0 6 votes vote down vote up
@Test
public void testCreateRaftClientProperties() {

  OzoneConfiguration ozoneConfiguration = new OzoneConfiguration();
  ozoneConfiguration.set("hdds.ratis.raft.client.rpc.watch" +
      ".request.timeout", "30s");
  ozoneConfiguration.set("hdds.ratis.raft.client.rpc.request" +
      ".timeout", "30s");
  ozoneConfiguration.set(
      "hdds.ratis.raft.server.rpc.watch.request.timeout", "30s");

  RaftProperties raftProperties = new RaftProperties();
  RatisHelper.createRaftClientProperties(ozoneConfiguration, raftProperties);

  Assert.assertEquals("30s",
      raftProperties.get("raft.client.rpc.watch.request.timeout"));
  Assert.assertEquals("30s",
      raftProperties.get("raft.client.rpc.request.timeout"));
  Assert.assertNull(
      raftProperties.get("raft.server.rpc.watch.request.timeout"));

}
 
Example #8
Source File: MiniRaftClusterWithSimulatedRpc.java    From incubator-ratis with Apache License 2.0 6 votes vote down vote up
@Override
public MiniRaftClusterWithSimulatedRpc newCluster(
    String[] ids, RaftProperties prop) {
  RaftConfigKeys.Rpc.setType(prop, SimulatedRpc.INSTANCE);
  if (ThreadLocalRandom.current().nextBoolean()) {
    // turn off simulate latency half of the times.
    prop.setInt(SimulatedRequestReply.SIMULATE_LATENCY_KEY, 0);
  }
  final int simulateLatencyMs = ConfUtils.getInt(prop::getInt,
      SimulatedRequestReply.SIMULATE_LATENCY_KEY,
      SimulatedRequestReply.SIMULATE_LATENCY_DEFAULT, LOG::info, requireMin(0));
  final SimulatedRequestReply<RaftServerRequest, RaftServerReply> serverRequestReply
      = new SimulatedRequestReply<>(simulateLatencyMs);
  final SimulatedClientRpc client2serverRequestReply
      = new SimulatedClientRpc(simulateLatencyMs);
  return new MiniRaftClusterWithSimulatedRpc(ids, prop,
      serverRequestReply, client2serverRequestReply);
}
 
Example #9
Source File: SegmentedRaftLogWorker.java    From incubator-ratis with Apache License 2.0 5 votes vote down vote up
SegmentedRaftLogWorker(RaftGroupMemberId memberId, StateMachine stateMachine, Runnable submitUpdateCommitEvent,
                       RaftServerImpl server, RaftStorage storage, RaftProperties properties,
                       RaftLogMetrics metricRegistry) {
  this.name = memberId + "-" + getClass().getSimpleName();
  LOG.info("new {} for {}", name, storage);

  this.submitUpdateCommitEvent = submitUpdateCommitEvent;
  this.stateMachine = stateMachine;
  this.raftLogMetrics = metricRegistry;
  this.storage = storage;
  this.server = server;
  final SizeInBytes queueByteLimit = RaftServerConfigKeys.Log.queueByteLimit(properties);
  final int queueElementLimit = RaftServerConfigKeys.Log.queueElementLimit(properties);
  this.queue =
      new DataBlockingQueue<>(name, queueByteLimit, queueElementLimit, Task::getSerializedSize);

  this.segmentMaxSize = RaftServerConfigKeys.Log.segmentSizeMax(properties).getSize();
  this.preallocatedSize = RaftServerConfigKeys.Log.preallocatedSize(properties).getSize();
  this.bufferSize = RaftServerConfigKeys.Log.writeBufferSize(properties).getSizeInt();
  this.forceSyncNum = RaftServerConfigKeys.Log.forceSyncNum(properties);
  this.flushBatchSize = 0;

  this.stateMachineDataPolicy = new StateMachineDataPolicy(properties);

  this.workerThread = new Thread(this, name);

  // Server Id can be null in unit tests
  metricRegistry.addDataQueueSizeGauge(queue);
  metricRegistry.addLogWorkerQueueSizeGauge(writeTasks.q);
  metricRegistry.addFlushBatchSizeGauge(() -> (Gauge<Integer>) () -> flushBatchSize);
  this.logFlushTimer = metricRegistry.getFlushTimer();
  this.raftLogSyncTimer = metricRegistry.getRaftLogSyncTimer();
  this.raftLogQueueingTimer = metricRegistry.getRaftLogQueueTimer();
  this.raftLogEnqueueingDelayTimer = metricRegistry.getRaftLogEnqueueDelayTimer();

  this.writeBuffer = ByteBuffer.allocateDirect(bufferSize);
}
 
Example #10
Source File: SegmentedRaftLog.java    From incubator-ratis with Apache License 2.0 5 votes vote down vote up
SegmentedRaftLog(RaftGroupMemberId memberId, RaftServerImpl server,
    StateMachine stateMachine, Runnable submitUpdateCommitEvent,
    RaftStorage storage, long lastIndexInSnapshot, RaftProperties properties) {
  super(memberId, lastIndexInSnapshot, properties);
  this.server = newServerLogMethods(server);
  this.storage = storage;
  this.stateMachine = stateMachine;
  segmentMaxSize = RaftServerConfigKeys.Log.segmentSizeMax(properties).getSize();
  this.cache = new SegmentedRaftLogCache(memberId, storage, properties, getRaftLogMetrics());
  this.fileLogWorker = new SegmentedRaftLogWorker(memberId, stateMachine,
      submitUpdateCommitEvent, server, storage, properties, getRaftLogMetrics());
  stateMachineCachingEnabled = RaftServerConfigKeys.Log.StateMachineData.cachingEnabled(properties);
}
 
Example #11
Source File: XceiverServerRatis.java    From hadoop-ozone with Apache License 2.0 5 votes vote down vote up
private void setRaftSegmentAndWriteBufferSize(RaftProperties properties) {
  final int raftSegmentSize = (int)conf.getStorageSize(
      OzoneConfigKeys.DFS_CONTAINER_RATIS_SEGMENT_SIZE_KEY,
      OzoneConfigKeys.DFS_CONTAINER_RATIS_SEGMENT_SIZE_DEFAULT,
      StorageUnit.BYTES);
  RaftServerConfigKeys.Log.setSegmentSizeMax(properties,
      SizeInBytes.valueOf(raftSegmentSize));
  RaftServerConfigKeys.Log.setWriteBufferSize(properties,
          SizeInBytes.valueOf(raftSegmentSize));
}
 
Example #12
Source File: MiniRaftCluster.java    From ratis with Apache License 2.0 5 votes vote down vote up
private RaftServerProxy newRaftServer(RaftPeerId id, RaftGroup group, boolean format) {
  LOG.info("newRaftServer: {}, {}, format? {}", id, group, format);
  try {
    final File dir = getStorageDir(id);
    if (format) {
      FileUtils.deleteFully(dir);
      LOG.info("Formatted directory {}", dir);
    }
    final RaftProperties prop = new RaftProperties(properties);
    RaftServerConfigKeys.setStorageDirs(prop, Collections.singletonList(dir));
    return newRaftServer(id, getStateMachineRegistry(properties), group, prop);
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}
 
Example #13
Source File: CounterServer.java    From incubator-ratis with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws IOException, InterruptedException {
  if (args.length < 1) {
    System.err.println("Usage: java -cp *.jar org.apache.ratis.examples.counter.server.CounterServer {serverIndex}");
    System.err.println("{serverIndex} could be 1, 2 or 3");
    System.exit(1);
  }

  //find current peer object based on application parameter
  RaftPeer currentPeer =
      CounterCommon.PEERS.get(Integer.parseInt(args[0]) - 1);

  //create a property object
  RaftProperties properties = new RaftProperties();

  //set the storage directory (different for each peer) in RaftProperty object
  File raftStorageDir = new File("./" + currentPeer.getId().toString());
  RaftServerConfigKeys.setStorageDir(properties,
      Collections.singletonList(raftStorageDir));

  //set the port which server listen to in RaftProperty object
  final int port = NetUtils.createSocketAddr(currentPeer.getAddress()).getPort();
  GrpcConfigKeys.Server.setPort(properties, port);

  //create the counter state machine which hold the counter value
  CounterStateMachine counterStateMachine = new CounterStateMachine();

  //create and start the Raft server
  RaftServer server = RaftServer.newBuilder()
      .setGroup(CounterCommon.RAFT_GROUP)
      .setProperties(properties)
      .setServerId(currentPeer.getId())
      .setStateMachine(counterStateMachine)
      .build();
  server.start();

  //exit when any input entered
  Scanner scanner = new Scanner(System.in);
  scanner.nextLine();
  server.close();
}
 
Example #14
Source File: MiniRaftClusterWithNetty.java    From incubator-ratis with Apache License 2.0 5 votes vote down vote up
@Override
protected RaftServerProxy newRaftServer(
    RaftPeerId id, StateMachine.Registry stateMachineRegistry , RaftGroup group,
    RaftProperties properties) throws IOException {
  NettyConfigKeys.Server.setPort(properties, getPort(id, group));
  return ServerImplUtils.newRaftServer(id, group, stateMachineRegistry, properties, null);
}
 
Example #15
Source File: SegmentedRaftLogCache.java    From incubator-ratis with Apache License 2.0 5 votes vote down vote up
SegmentedRaftLogCache(Object name, RaftStorage storage, RaftProperties properties,
                              RaftLogMetrics raftLogMetrics) {
  this.name = name + "-" + getClass().getSimpleName();
  this.closedSegments = new LogSegmentList(name);
  this.storage = storage;
  this.raftLogMetrics = raftLogMetrics;
  this.raftLogMetrics.addClosedSegmentsNum(this);
  this.raftLogMetrics.addClosedSegmentsSizeInBytes(this);
  this.raftLogMetrics.addOpenSegmentSizeInBytes(this);
  this.maxCachedSegments = RaftServerConfigKeys.Log.segmentCacheNumMax(properties);
}
 
Example #16
Source File: MiniRaftClusterWithGrpc.java    From ratis with Apache License 2.0 5 votes vote down vote up
@Override
protected RaftServerProxy newRaftServer(
    RaftPeerId id, StateMachine.Registry stateMachineRegistry, RaftGroup group,
    RaftProperties properties) throws IOException {
  GrpcConfigKeys.Server.setPort(properties, getPort(id, group));
  return ServerImplUtils.newRaftServer(id, group, stateMachineRegistry, properties, null);
}
 
Example #17
Source File: MetadataServer.java    From ratis with Apache License 2.0 5 votes vote down vote up
public void start() throws IOException  {
    final ServerOpts opts = getServerOpts();
    if (opts.getHost() == null) {
        opts.setHost(LogServiceUtils.getHostName());
    }
    this.lifeCycle = new LifeCycle(this.id);
    RaftProperties properties = new RaftProperties();
    if(opts.getWorkingDir() != null) {
        RaftServerConfigKeys.setStorageDirs(properties, Collections.singletonList(new File(opts.getWorkingDir())));
    }
    GrpcConfigKeys.Server.setPort(properties, opts.getPort());
    NettyConfigKeys.Server.setPort(properties, opts.getPort());
    Set<RaftPeer> peers = getPeersFromQuorum(opts.getMetaQuorum());
    RaftGroupId raftMetaGroupId = RaftGroupId.valueOf(opts.getMetaGroupId());
    RaftGroup metaGroup = RaftGroup.valueOf(raftMetaGroupId, peers);
    metaStateMachine = new MetaStateMachine(raftMetaGroupId, RaftGroupId.valueOf(opts.getLogServerGroupId()));
    server = RaftServer.newBuilder()
            .setGroup(metaGroup)
            .setServerId(RaftPeerId.valueOf(id))
            .setStateMachineRegistry(raftGroupId -> {
                if(raftGroupId.equals(META_GROUP_ID)) {
                    return metaStateMachine;
                }
                return null;
            })
            .setProperties(properties).build();
    lifeCycle.startAndTransition(() -> {
        server.start();
    }, IOException.class);
}
 
Example #18
Source File: TestStateMachine.java    From incubator-ratis with Apache License 2.0 5 votes vote down vote up
void runTestTransactionContextIsPassedBack(boolean useMemory) throws Throwable {
  final RaftProperties properties = new RaftProperties();
  properties.setClass(MiniRaftCluster.STATEMACHINE_CLASS_KEY, SMTransactionContext.class, StateMachine.class);
  RaftServerConfigKeys.Log.setUseMemory(properties, useMemory);

  try(MiniRaftClusterWithSimulatedRpc cluster = getFactory().newCluster(NUM_SERVERS, properties)) {
    cluster.start();
    runTestTransactionContextIsPassedBack(cluster);
  }
}
 
Example #19
Source File: TestLogSegment.java    From incubator-ratis with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example #20
Source File: ParameterizedBaseTest.java    From ratis with Apache License 2.0 5 votes vote down vote up
public static Collection<Object[]> getMiniRaftClusters(
      RaftProperties prop, int clusterSize, Class<?>... clusterClasses)
      throws IOException {
    final List<Class<?>> classes = Arrays.asList(clusterClasses);
    final boolean isAll = classes.isEmpty(); //empty means all

    final Iterator<String[]> ids = new Iterator<String[]>() {
      private int i = 0;
      @Override
      public boolean hasNext() {
        return true;
      }
      @Override
      public String[] next() {
        return MiniRaftCluster.generateIds(clusterSize, i++*clusterSize);
      }
    };

    final List<Object[]> clusters = new ArrayList<>();

    if (isAll || classes.contains(MiniRaftClusterWithSimulatedRpc.class)) {
      add(clusters, MiniRaftClusterWithSimulatedRpc.FACTORY, ids.next(), prop);
    }
    if (isAll || classes.contains(MiniRaftClusterWithGrpc.class)) {
      add(clusters, MiniRaftClusterWithGrpc.FACTORY, ids.next(), prop);
    }
    if (isAll || classes.contains(MiniRaftClusterWithNetty.class)) {
      add(clusters, MiniRaftClusterWithNetty.FACTORY, ids.next(), prop);
    }
    if (isAll || classes.contains(MiniRaftClusterWithHadoopRpc.class)) {
//      add(clusters, MiniRaftClusterWithHadoopRpc.FACTORY, ids.next(), prop);
    }
    for(int i = 0; i < clusters.size(); i++) {
      LOG.info(i + ": " + clusters.get(i)[0].getClass().getSimpleName());
    }
    LOG.info("#clusters = " + clusters.size());
    return clusters;
  }
 
Example #21
Source File: GrpcOutputStream.java    From ratis with Apache License 2.0 5 votes vote down vote up
public GrpcOutputStream(RaftProperties prop, ClientId clientId,
    RaftGroup group, RaftPeerId leaderId, GrpcTlsConfig tlsConfig) {
  final int bufferSize = GrpcConfigKeys.OutputStream.bufferSize(prop).getSizeInt();
  buf = new byte[bufferSize];
  count = 0;
  this.clientId = clientId;
  streamer = new GrpcClientStreamer(prop, group, leaderId, clientId, tlsConfig);
}
 
Example #22
Source File: Client.java    From ratis with Apache License 2.0 5 votes vote down vote up
@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 * 1024));

  RaftServerConfigKeys.Log.setMaxCachedSegmentNum(raftProperties, 2);

  RaftClientConfigKeys.Rpc.setRequestTimeout(raftProperties,
      TimeDuration.valueOf(50000, TimeUnit.MILLISECONDS));
  RaftClientConfigKeys.Async.setSchedulerThreads(raftProperties, 10);
  RaftClientConfigKeys.Async.setMaxOutstandingRequests(raftProperties, 1000);


  final RaftGroup raftGroup = RaftGroup.valueOf(RaftGroupId.valueOf(ByteString.copyFromUtf8(raftGroupId)),
      parsePeers(peers));

  RaftClient.Builder builder =
      RaftClient.newBuilder().setProperties(raftProperties);
  builder.setRaftGroup(raftGroup);
  builder.setClientRpc(new GrpcFactory(new Parameters()).newRaftClientRpc(ClientId.randomId(), raftProperties));
  RaftClient client = builder.build();

  operation(client);
}
 
Example #23
Source File: RaftLogCache.java    From ratis with Apache License 2.0 4 votes vote down vote up
RaftLogCache(RaftPeerId selfId, RaftStorage storage, RaftProperties properties) {
  this.name = selfId + "-" + getClass().getSimpleName();
  this.closedSegments = new LogSegmentList(name);
  this.storage = storage;
  maxCachedSegments = RaftServerConfigKeys.Log.maxCachedSegmentNum(properties);
}
 
Example #24
Source File: RaftServerConfigKeys.java    From incubator-ratis with Apache License 2.0 4 votes vote down vote up
static void setTimeoutMax(RaftProperties properties, TimeDuration maxDuration) {
  setTimeDuration(properties::setTimeDuration, TIMEOUT_MAX_KEY, maxDuration);
}
 
Example #25
Source File: MiniRaftCluster.java    From ratis with Apache License 2.0 4 votes vote down vote up
public RpcBase(String[] ids, RaftProperties properties, Parameters parameters) {
  super(ids, properties, parameters);
}
 
Example #26
Source File: MiniRaftClusterWithHadoopRpc.java    From ratis with Apache License 2.0 4 votes vote down vote up
public MiniRaftClusterWithHadoopRpc newCluster(
    int numServers, RaftProperties properties, Configuration conf) {
  return newCluster(generateIds(numServers, 0), properties, conf);
}
 
Example #27
Source File: GrpcConfigKeys.java    From incubator-ratis with Apache License 2.0 4 votes vote down vote up
static void setFlowControlWindow(RaftProperties properties, SizeInBytes flowControlWindowSize) {
  setSizeInBytes(properties::set, FLOW_CONTROL_WINDOW_KEY, flowControlWindowSize);
}
 
Example #28
Source File: MiniRaftClusterWithNetty.java    From ratis with Apache License 2.0 4 votes vote down vote up
@Override
public MiniRaftClusterWithNetty newCluster(String[] ids, RaftProperties prop) {
  RaftConfigKeys.Rpc.setType(prop, SupportedRpcType.NETTY);
  return new MiniRaftClusterWithNetty(ids, prop);
}
 
Example #29
Source File: GrpcConfigKeys.java    From incubator-ratis with Apache License 2.0 4 votes vote down vote up
static void setLeaderOutstandingAppendsMax(RaftProperties properties, int maxAppend) {
  setInt(properties::setInt, LEADER_OUTSTANDING_APPENDS_MAX_KEY, maxAppend);
}
 
Example #30
Source File: RaftServerConfigKeys.java    From ratis with Apache License 2.0 4 votes vote down vote up
static SizeInBytes writeBufferSize(RaftProperties properties) {
  return getSizeInBytes(properties::getSizeInBytes,
      WRITE_BUFFER_SIZE_KEY, WRITE_BUFFER_SIZE_DEFAULT, getDefaultLog());
}