Added a new variable in the distributed-datastore-provider.yang. This
will be used to configure the snapshot chunk size. Added various
setters/getters to the DatastoreContext. The support for this variable
was added to JMX as well, so that the value can be seen via JConsole.
Moreover, added tests in DatastoreContextTest.
Also fixed a recurring typo in sal-akka-raft. Snapshot was spelled as
snaphot (missing s in shot).
This code was unit tested with different entries in datastore.cfg. Also
tested the case where no special value was provided in datastore.cfg,
and the default value was shown in jconsole.
Change-Id: Ie754075cc25f9eadf01cc65aee726735144c1794
Signed-off-by: Shaleen Saxena <[email protected]>
// in-memory journal can use before it needs to snapshot
private int snapshotDataThresholdPercentage = 12;
- private int snaphotChunkSize = SNAPSHOT_CHUNK_SIZE;
+ private int snapshotChunkSize = SNAPSHOT_CHUNK_SIZE;
private long electionTimeoutFactor = 2;
private String customRaftPolicyImplementationClass;
this.snapshotDataThresholdPercentage = snapshotDataThresholdPercentage;
}
- public void setSnaphotChunkSize(int snaphotChunkSize) {
- this.snaphotChunkSize = snaphotChunkSize;
+ public void setSnapshotChunkSize(int snapshotChunkSize) {
+ this.snapshotChunkSize = snapshotChunkSize;
}
public void setJournalRecoveryLogBatchSize(int journalRecoveryLogBatchSize) {
@Override
public int getSnapshotChunkSize() {
- return snaphotChunkSize;
+ return snapshotChunkSize;
}
@Override
MockRaftActorContext leaderActorContext = createActorContextWithFollower();
((DefaultConfigParamsImpl)leaderActorContext.getConfigParams()).setHeartBeatInterval(
new FiniteDuration(1000, TimeUnit.SECONDS));
- ((DefaultConfigParamsImpl)leaderActorContext.getConfigParams()).setSnaphotChunkSize(2);
+ ((DefaultConfigParamsImpl)leaderActorContext.getConfigParams()).setSnapshotChunkSize(2);
leaderActorContext.setReplicatedLog(
new MockRaftActorContext.MockReplicatedLogBuilder().createEntries(0, 4, 1).build());
# cannot be found then the default raft policy will be applied
#custom-raft-policy-implementation=
+# The maximum size (in bytes) for snapshot chunks to be sent during sync
+#shard-snapshot-chunk-size=20480000
public static final String UNKNOWN_DATA_STORE_TYPE = "unknown";
public static final int DEFAULT_SHARD_BATCHED_MODIFICATION_COUNT = 1000;
public static final long DEFAULT_SHARD_COMMIT_QUEUE_EXPIRY_TIMEOUT_IN_MS = TimeUnit.MILLISECONDS.convert(2, TimeUnit.MINUTES);
+ public static final int DEFAULT_SHARD_SNAPSHOT_CHUNK_SIZE = 2048000;
private static Set<String> globalDatastoreTypes = Sets.newConcurrentHashSet();
setIsolatedLeaderCheckInterval(DEFAULT_ISOLATED_LEADER_CHECK_INTERVAL_IN_MILLIS);
setSnapshotDataThresholdPercentage(DEFAULT_SHARD_SNAPSHOT_DATA_THRESHOLD_PERCENTAGE);
setElectionTimeoutFactor(DEFAULT_SHARD_ELECTION_TIMEOUT_FACTOR);
+ setShardSnapshotChunkSize(DEFAULT_SHARD_SNAPSHOT_CHUNK_SIZE);
}
private DatastoreContext(DatastoreContext other) {
setSnapshotDataThresholdPercentage(other.raftConfig.getSnapshotDataThresholdPercentage());
setElectionTimeoutFactor(other.raftConfig.getElectionTimeoutFactor());
setCustomRaftPolicyImplementation(other.customRaftPolicyImplementation);
+ setShardSnapshotChunkSize(other.raftConfig.getSnapshotChunkSize());
}
return transactionDebugContextEnabled;
}
+ public int getShardSnapshotChunkSize() {
+ return raftConfig.getSnapshotChunkSize();
+ }
+
+ public void setShardSnapshotChunkSize(int shardSnapshotChunkSize) {
+ raftConfig.setSnapshotChunkSize(shardSnapshotChunkSize);
+ }
+
public static class Builder {
private final DatastoreContext datastoreContext;
private int maxShardDataChangeExecutorPoolSize =
datastoreContext.setCustomRaftPolicyImplementation(customRaftPolicyImplementation);
return this;
}
+
+ public Builder shardSnapshotChunkSize(int shardSnapshotChunkSize) {
+ datastoreContext.setShardSnapshotChunkSize(shardSnapshotChunkSize);
+ return this;
+ }
}
}
int getMaxShardDataChangeListenerQueueSize();
int getMaxShardDataStoreExecutorQueueSize();
+
+ int getShardSnapshotChunkSize();
}
public int getMaxShardDataStoreExecutorQueueSize() {
return context.getDataStoreProperties().getMaxDataStoreExecutorQueueSize();
}
+
+ @Override
+ public int getShardSnapshotChunkSize() {
+ return context.getShardSnapshotChunkSize();
+ }
+
}
props.getShardCommitQueueExpiryTimeoutInSeconds().getValue().intValue())
.transactionDebugContextEnabled(props.getTransactionDebugContextEnabled())
.customRaftPolicyImplementation(props.getCustomRaftPolicyImplementation())
+ .shardSnapshotChunkSize(props.getShardSnapshotChunkSize().getValue().intValue())
.build();
return DistributedDataStoreFactory.createInstance(getConfigSchemaServiceDependency(),
props.getShardCommitQueueExpiryTimeoutInSeconds().getValue().intValue())
.transactionDebugContextEnabled(props.getTransactionDebugContextEnabled())
.customRaftPolicyImplementation(props.getCustomRaftPolicyImplementation())
+ .shardSnapshotChunkSize(props.getShardSnapshotChunkSize().getValue().intValue())
.build();
return DistributedDataStoreFactory.createInstance(getOperationalSchemaServiceDependency(),
present in the distributed data store module itself. If this property is set to a class which
cannot be found then the default raft behavior will be applied";
}
+
+ leaf shard-snapshot-chunk-size {
+ default 2048000;
+ type non-zero-uint32-type;
+ description "When sending a snapshot to a follower, this is the maximum size in bytes for
+ a chunk of data.";
+ }
}
// Augments the 'configuration' choice node under modules/module.
import static org.opendaylight.controller.cluster.datastore.DatastoreContext.DEFAULT_SHARD_TX_COMMIT_TIMEOUT_IN_SECONDS;
import static org.opendaylight.controller.cluster.datastore.DatastoreContext.DEFAULT_SNAPSHOT_BATCH_COUNT;
import static org.opendaylight.controller.cluster.datastore.DatastoreContext.DEFAULT_TX_CREATION_INITIAL_RATE_LIMIT;
+import static org.opendaylight.controller.cluster.datastore.DatastoreContext.DEFAULT_SHARD_SNAPSHOT_CHUNK_SIZE;
import java.util.concurrent.TimeUnit;
import org.junit.Assert;
import org.junit.Test;
context.getDataStoreProperties().getMaxDataChangeListenerQueueSize());
assertEquals(InMemoryDOMDataStoreConfigProperties.DEFAULT_MAX_DATA_STORE_EXECUTOR_QUEUE_SIZE,
context.getDataStoreProperties().getMaxDataStoreExecutorQueueSize());
+ assertEquals(DEFAULT_SHARD_SNAPSHOT_CHUNK_SIZE, context.getShardSnapshotChunkSize());
}
@Test
InMemoryDOMDataStoreConfigProperties.DEFAULT_MAX_DATA_CHANGE_LISTENER_QUEUE_SIZE + 1);
builder.maxShardDataStoreExecutorQueueSize(
InMemoryDOMDataStoreConfigProperties.DEFAULT_MAX_DATA_STORE_EXECUTOR_QUEUE_SIZE + 1);
+ builder.shardSnapshotChunkSize(DEFAULT_SHARD_SNAPSHOT_CHUNK_SIZE+1);
DatastoreContext context = builder.build();
context.getDataStoreProperties().getMaxDataChangeListenerQueueSize());
assertEquals(InMemoryDOMDataStoreConfigProperties.DEFAULT_MAX_DATA_STORE_EXECUTOR_QUEUE_SIZE + 1,
context.getDataStoreProperties().getMaxDataStoreExecutorQueueSize());
+ assertEquals(DEFAULT_SHARD_SNAPSHOT_CHUNK_SIZE + 1, context.getShardSnapshotChunkSize());
}
}