NormalizedNode<?, ?> legacyConfigRoot2 = toRootNode(PeopleModel.BASE_PATH, PeopleModel.emptyContainer());
+ ShardManagerSnapshot legacyShardManagerSnapshot = newLegacyShardManagerSnapshot("config-one", "config-two");
DatastoreSnapshot legacyConfigSnapshot = new DatastoreSnapshot("config",
- SerializationUtils.serialize(newLegacyShardManagerSnapshot("config-one", "config-two")),
+ SerializationUtils.serialize(legacyShardManagerSnapshot),
Arrays.asList(newLegacyShardSnapshot("config-one", newLegacySnapshot(legacyConfigRoot1)),
newLegacyShardSnapshot("config-two", newLegacySnapshot(legacyConfigRoot2))));
SerializationUtils.clone(legacy);
assertEquals("DatastoreSnapshotList size", 2, cloned.size());
- assertDatastoreSnapshotEquals(legacyConfigSnapshot, cloned.get(0), Optional.of(legacyConfigRoot1),
- Optional.of(legacyConfigRoot2));
- assertDatastoreSnapshotEquals(legacyOperSnapshot, cloned.get(1), Optional.empty());
+ assertDatastoreSnapshotEquals(legacyConfigSnapshot, cloned.get(0),
+ new org.opendaylight.controller.cluster.datastore.persisted.ShardManagerSnapshot(
+ legacyShardManagerSnapshot.getShardList(), Collections.emptyMap()),
+ Optional.of(legacyConfigRoot1), Optional.of(legacyConfigRoot2));
+ assertDatastoreSnapshotEquals(legacyOperSnapshot, cloned.get(1),
+ (org.opendaylight.controller.cluster.datastore.persisted.ShardManagerSnapshot)null,
+ Optional.empty());
}
- private void assertDatastoreSnapshotEquals(DatastoreSnapshot legacy,
- org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot actual,
- Optional<NormalizedNode<?, ?>>... shardRoots) throws IOException {
+ @SuppressWarnings("unchecked")
+ private static void assertDatastoreSnapshotEquals(final DatastoreSnapshot legacy,
+ final org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot actual,
+ final org.opendaylight.controller.cluster.datastore.persisted.ShardManagerSnapshot expShardMgrSnapshot,
+ final Optional<NormalizedNode<?, ?>>... shardRoots) throws IOException {
assertEquals("Type", legacy.getType(), actual.getType());
if (legacy.getShardManagerSnapshot() == null) {
assertNull("Expected null ShardManagerSnapshot", actual.getShardManagerSnapshot());
} else {
- ShardManagerSnapshot legacyShardManagerSnapshot =
- (ShardManagerSnapshot) SerializationUtils.deserialize(legacy.getShardManagerSnapshot());
- ShardManagerSnapshot actualShardManagerSnapshot =
- (ShardManagerSnapshot) SerializationUtils.deserialize(actual.getShardManagerSnapshot());
- assertEquals("ShardManagerSnapshot", legacyShardManagerSnapshot.getShardList(),
+ org.opendaylight.controller.cluster.datastore.persisted.ShardManagerSnapshot actualShardManagerSnapshot =
+ (org.opendaylight.controller.cluster.datastore.persisted.ShardManagerSnapshot)
+ SerializationUtils.deserialize(legacy.getShardManagerSnapshot());
+ assertEquals("ShardManagerSnapshot", expShardMgrSnapshot.getShardList(),
actualShardManagerSnapshot.getShardList());
}
}
}
- private static void assertSnapshotEquals(Snapshot expected, Optional<NormalizedNode<?, ?>> expRoot,
- org.opendaylight.controller.cluster.raft.persisted.Snapshot actual) throws IOException {
+ private static void assertSnapshotEquals(final Snapshot expected, final Optional<NormalizedNode<?, ?>> expRoot,
+ final org.opendaylight.controller.cluster.raft.persisted.Snapshot actual) throws IOException {
assertEquals("lastIndex", expected.getLastIndex(), actual.getLastIndex());
assertEquals("lastTerm", expected.getLastTerm(), actual.getLastTerm());
assertEquals("lastAppliedIndex", expected.getLastAppliedIndex(), actual.getLastAppliedIndex());
}
}
- private static ShardManagerSnapshot newLegacyShardManagerSnapshot(String... shards) {
+ private static ShardManagerSnapshot newLegacyShardManagerSnapshot(final String... shards) {
return ShardManagerSnapshot.forShardList(Arrays.asList(shards));
}
- private static DatastoreSnapshot.ShardSnapshot newLegacyShardSnapshot(String name,
- org.opendaylight.controller.cluster.raft.Snapshot snapshot) {
+ private static DatastoreSnapshot.ShardSnapshot newLegacyShardSnapshot(final String name,
+ final org.opendaylight.controller.cluster.raft.Snapshot snapshot) {
return new DatastoreSnapshot.ShardSnapshot(name, SerializationUtils.serialize(snapshot));
}
- private static Snapshot newLegacySnapshot(NormalizedNode<?, ?> root)
+ private static Snapshot newLegacySnapshot(final NormalizedNode<?, ?> root)
throws Exception {
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
if (root != null) {
MetadataShardDataTreeSnapshot snapshot = new MetadataShardDataTreeSnapshot(root);
- try (final DataOutputStream dos = new DataOutputStream(bos)) {
+ try (DataOutputStream dos = new DataOutputStream(bos)) {
PayloadVersion.BORON.writeTo(dos);
try (ObjectOutputStream oos = new ObjectOutputStream(dos)) {
oos.writeObject(snapshot);
"member-1", null);
}
- private static NormalizedNode<?, ?> toRootNode(YangInstanceIdentifier path, NormalizedNode<?, ?> node)
+ private static NormalizedNode<?, ?> toRootNode(final YangInstanceIdentifier path, final NormalizedNode<?, ?> node)
throws DataValidationFailedException {
DataTree dataTree = InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL);
dataTree.setSchemaContext(SchemaContextHelper.full());