2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.cluster.raft;
10 import scala.concurrent.duration.FiniteDuration;
12 import java.util.concurrent.TimeUnit;
15 * Default implementation of the ConfigParams
17 * If no implementation is provided for ConfigParams, then this will be used.
19 public class DefaultConfigParamsImpl implements ConfigParams {
21 private static final int SNAPSHOT_BATCH_COUNT = 100000;
24 * The maximum election time variance
26 private static final int ELECTION_TIME_MAX_VARIANCE = 100;
28 private final int SNAPSHOT_CHUNK_SIZE = 2048 * 1000; //2MB
32 * The interval at which a heart beat message will be sent to the remote
35 * Since this is set to 100 milliseconds the Election timeout should be
36 * at least 200 milliseconds
38 public static final FiniteDuration HEART_BEAT_INTERVAL =
39 new FiniteDuration(100, TimeUnit.MILLISECONDS);
43 public long getSnapshotBatchCount() {
44 return SNAPSHOT_BATCH_COUNT;
48 public FiniteDuration getHeartBeatInterval() {
49 return HEART_BEAT_INTERVAL;
54 public FiniteDuration getElectionTimeOutInterval() {
55 // returns 2 times the heart beat interval
56 return getHeartBeatInterval().$times(2);
60 public int getElectionTimeVariance() {
61 return ELECTION_TIME_MAX_VARIANCE;
65 public int getSnapshotChunkSize() {
66 return SNAPSHOT_CHUNK_SIZE;