Remove DataTreeCandidatePayload 76/55076/2
authorRobert Varga <robert.varga@pantheon.tech>
Sat, 15 Apr 2017 01:07:37 +0000 (03:07 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Sat, 15 Apr 2017 01:34:21 +0000 (03:34 +0200)
Deprecated since Boron, this payload will cause a snapshot in Carbon,
hence we can remove it in Nitrogen.

Change-Id: Ic2b5f54837ab130b56f9121c560e2616ae66dbda
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeCandidatePayload.java [deleted file]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTree.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeCandidatePayloadTest.java [deleted file]
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardRecoveryCoordinatorTest.java

diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeCandidatePayload.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeCandidatePayload.java
deleted file mode 100644 (file)
index d11ce38..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.cluster.datastore;
-
-import com.google.common.base.Preconditions;
-import com.google.common.io.ByteArrayDataOutput;
-import com.google.common.io.ByteStreams;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import org.opendaylight.controller.cluster.datastore.persisted.DataTreeCandidateInputOutput;
-import org.opendaylight.controller.cluster.raft.persisted.MigratedSerializable;
-import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
-
-/**
- * Payload wrapper for a DataTreeCandidatePayload.
- *
- * @deprecated Deprecated in Boron in favor of CommitTransactionPayload
- */
-@Deprecated
-final class DataTreeCandidatePayload extends Payload implements Externalizable, MigratedSerializable {
-    private static final long serialVersionUID = 1L;
-
-    private transient byte[] serialized;
-
-    // checkstyle flags the public modifier as redundant which really doesn't make sense since it clearly isn't
-    // redundant. It is explicitly needed for Java serialization to be able to create instances via reflection.
-    @SuppressWarnings("checkstyle:RedundantModifier")
-    public DataTreeCandidatePayload() {
-        // Required by Externalizable
-    }
-
-    private DataTreeCandidatePayload(final byte[] serialized) {
-        this.serialized = Preconditions.checkNotNull(serialized);
-    }
-
-    /**
-     * Creates a DataTreeCandidatePayload.
-     *
-     * @deprecated Use CommitTransactionPayload instead
-     */
-    @Deprecated
-    static DataTreeCandidatePayload create(final DataTreeCandidate candidate) {
-        final ByteArrayDataOutput out = ByteStreams.newDataOutput();
-        try {
-            DataTreeCandidateInputOutput.writeDataTreeCandidate(out, candidate);
-        } catch (IOException e) {
-            throw new IllegalArgumentException(String.format("Failed to serialize candidate %s", candidate), e);
-        }
-
-        return new DataTreeCandidatePayload(out.toByteArray());
-    }
-
-    public DataTreeCandidate getCandidate() throws IOException {
-        return DataTreeCandidateInputOutput.readDataTreeCandidate(ByteStreams.newDataInput(serialized));
-    }
-
-    @Override
-    public int size() {
-        return serialized.length;
-    }
-
-    @Override
-    public void writeExternal(final ObjectOutput out) throws IOException {
-        out.writeByte((byte)serialVersionUID);
-        out.writeInt(serialized.length);
-        out.write(serialized);
-    }
-
-    @Override
-    public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
-        final long version = in.readByte();
-        Preconditions.checkArgument(version == serialVersionUID, "Unsupported serialization version %s", version);
-
-        final int length = in.readInt();
-        serialized = new byte[length];
-        in.readFully(serialized);
-    }
-
-    @Override
-    public boolean isMigrated() {
-        return true;
-    }
-
-    @Deprecated
-    @Override
-    public Object writeReplace() {
-        // this is fine
-        return this;
-    }
-}
index dffb69c36d3969c1bca35f9f6c5146c50ca1cf7f..36a6a70f38717b755fbf44a39795de3eca46fb21 100644 (file)
@@ -336,8 +336,6 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
             allMetadataClosedLocalHistory(((CloseLocalHistoryPayload) payload).getIdentifier());
         } else if (payload instanceof PurgeLocalHistoryPayload) {
             allMetadataPurgedLocalHistory(((PurgeLocalHistoryPayload) payload).getIdentifier());
-        } else if (payload instanceof DataTreeCandidatePayload) {
-            applyRecoveryCandidate(((DataTreeCandidatePayload) payload).getCandidate());
         } else {
             LOG.debug("{}: ignoring unhandled payload {}", logContext, payload);
         }
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeCandidatePayloadTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeCandidatePayloadTest.java
deleted file mode 100644 (file)
index c7e20bb..0000000
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.cluster.datastore;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
-
-import java.io.IOException;
-import java.util.Collection;
-import org.apache.commons.lang3.SerializationUtils;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
-import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
-import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
-
-@Deprecated
-public class DataTreeCandidatePayloadTest {
-    static final QName LEAF_SET = QName.create(TestModel.TEST_QNAME, "leaf-set");
-
-    private DataTreeCandidate candidate;
-
-    private static DataTreeCandidateNode findNode(final Collection<DataTreeCandidateNode> nodes,
-            final PathArgument arg) {
-        for (DataTreeCandidateNode node : nodes) {
-            if (arg.equals(node.getIdentifier())) {
-                return node;
-            }
-        }
-        return null;
-    }
-
-    private static void assertChildrenEquals(final Collection<DataTreeCandidateNode> expected,
-            final Collection<DataTreeCandidateNode> actual) {
-        // Make sure all expected nodes are there
-        for (DataTreeCandidateNode exp : expected) {
-            final DataTreeCandidateNode act = findNode(actual, exp.getIdentifier());
-            assertNotNull("missing expected child", act);
-            assertCandidateNodeEquals(exp, act);
-        }
-        // Make sure no nodes are present which are not in the expected set
-        for (DataTreeCandidateNode act : actual) {
-            final DataTreeCandidateNode exp = findNode(expected, act.getIdentifier());
-            assertNull("unexpected child", exp);
-        }
-    }
-
-    private static void assertCandidateEquals(final DataTreeCandidate expected, final DataTreeCandidate actual) {
-        assertEquals("root path", expected.getRootPath(), actual.getRootPath());
-
-        final DataTreeCandidateNode expRoot = expected.getRootNode();
-        final DataTreeCandidateNode actRoot = expected.getRootNode();
-        assertEquals("root type", expRoot.getModificationType(), actRoot.getModificationType());
-
-        switch (actRoot.getModificationType()) {
-            case DELETE:
-            case WRITE:
-                assertEquals("root data", expRoot.getDataAfter(), actRoot.getDataAfter());
-                break;
-            case SUBTREE_MODIFIED:
-                assertChildrenEquals(expRoot.getChildNodes(), actRoot.getChildNodes());
-                break;
-            default:
-                fail("Unexpect root type " + actRoot.getModificationType());
-                break;
-        }
-
-        assertCandidateNodeEquals(expected.getRootNode(), actual.getRootNode());
-    }
-
-    private static void assertCandidateNodeEquals(final DataTreeCandidateNode expected,
-            final DataTreeCandidateNode actual) {
-        assertEquals("child type", expected.getModificationType(), actual.getModificationType());
-        assertEquals("child identifier", expected.getIdentifier(), actual.getIdentifier());
-
-        switch (actual.getModificationType()) {
-            case DELETE:
-            case WRITE:
-                assertEquals("child data", expected.getDataAfter(), actual.getDataAfter());
-                break;
-            case SUBTREE_MODIFIED:
-                assertChildrenEquals(expected.getChildNodes(), actual.getChildNodes());
-                break;
-            default:
-                fail("Unexpect root type " + actual.getModificationType());
-                break;
-        }
-    }
-
-    @Before
-    public void setUp() {
-        final YangInstanceIdentifier writePath = TestModel.TEST_PATH;
-        final NormalizedNode<?, ?> writeData = ImmutableContainerNodeBuilder.create().withNodeIdentifier(
-                new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME))
-                    .withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")).build();
-        candidate = DataTreeCandidates.fromNormalizedNode(writePath, writeData);
-    }
-
-    @Test
-    public void testCandidateSerialization() throws IOException {
-        final DataTreeCandidatePayload payload = DataTreeCandidatePayload.create(candidate);
-        assertEquals("payload size", 141, payload.size());
-    }
-
-    @Test
-    public void testCandidateSerDes() throws IOException {
-        final DataTreeCandidatePayload payload = DataTreeCandidatePayload.create(candidate);
-        assertCandidateEquals(candidate, payload.getCandidate());
-    }
-
-    @Test
-    public void testPayloadSerDes() throws IOException {
-        final DataTreeCandidatePayload payload = DataTreeCandidatePayload.create(candidate);
-        assertCandidateEquals(candidate, SerializationUtils.clone(payload).getCandidate());
-    }
-
-    @SuppressWarnings({ "rawtypes", "unchecked" })
-    @Test
-    public void testLeafSetEntryNodeCandidate() throws Exception {
-        YangInstanceIdentifier.NodeWithValue entryPathArg = new YangInstanceIdentifier.NodeWithValue(LEAF_SET, "one");
-        YangInstanceIdentifier leafSetEntryPath = YangInstanceIdentifier.builder(TestModel.TEST_PATH).node(LEAF_SET)
-                .node(entryPathArg).build();
-
-        NormalizedNode<?, ?> leafSetEntryNode = Builders.leafSetEntryBuilder()
-                .withNodeIdentifier(entryPathArg).withValue("one").build();
-
-        candidate = DataTreeCandidates.fromNormalizedNode(leafSetEntryPath, leafSetEntryNode);
-        DataTreeCandidatePayload payload = DataTreeCandidatePayload.create(candidate);
-        assertCandidateEquals(candidate, payload.getCandidate());
-    }
-
-    @SuppressWarnings({ "rawtypes", "unchecked" })
-    @Test
-    public void testLeafSetNodeCandidate() throws Exception {
-        YangInstanceIdentifier.NodeWithValue entryPathArg = new YangInstanceIdentifier.NodeWithValue(LEAF_SET, "one");
-        YangInstanceIdentifier leafSetPath = YangInstanceIdentifier.builder(TestModel.TEST_PATH).node(LEAF_SET).build();
-
-        LeafSetEntryNode leafSetEntryNode = Builders.leafSetEntryBuilder()
-                .withNodeIdentifier(entryPathArg).withValue("one").build();
-        NormalizedNode<?, ?> leafSetNode = Builders.leafSetBuilder().withNodeIdentifier(
-                new YangInstanceIdentifier.NodeIdentifier(LEAF_SET)).withChild(leafSetEntryNode).build();
-
-        DataTreeCandidate candidate = DataTreeCandidates.fromNormalizedNode(leafSetPath, leafSetNode);
-        DataTreeCandidatePayload payload = DataTreeCandidatePayload.create(candidate);
-        assertCandidateEquals(candidate, payload.getCandidate());
-    }
-
-    @SuppressWarnings({ "rawtypes", "unchecked" })
-    @Test
-    public void testOrderedLeafSetNodeCandidate() throws Exception {
-        YangInstanceIdentifier.NodeWithValue entryPathArg = new YangInstanceIdentifier.NodeWithValue(LEAF_SET, "one");
-        YangInstanceIdentifier leafSetPath = YangInstanceIdentifier.builder(TestModel.TEST_PATH).node(LEAF_SET).build();
-
-        LeafSetEntryNode leafSetEntryNode = Builders.leafSetEntryBuilder()
-                .withNodeIdentifier(entryPathArg).withValue("one").build();
-        NormalizedNode<?, ?> leafSetNode = Builders.orderedLeafSetBuilder().withNodeIdentifier(
-                new YangInstanceIdentifier.NodeIdentifier(LEAF_SET)).withChild(leafSetEntryNode).build();
-
-        candidate = DataTreeCandidates.fromNormalizedNode(leafSetPath, leafSetNode);
-        DataTreeCandidatePayload payload = DataTreeCandidatePayload.create(candidate);
-        assertCandidateEquals(candidate, payload.getCandidate());
-    }
-
-    @Test
-    public void testLeafNodeCandidate() throws Exception {
-        YangInstanceIdentifier leafPath = YangInstanceIdentifier.builder(TestModel.TEST_PATH)
-                .node(TestModel.DESC_QNAME).build();
-        LeafNode<Object> leafNode = Builders.leafBuilder().withNodeIdentifier(
-                new YangInstanceIdentifier.NodeIdentifier(TestModel.DESC_QNAME)).withValue("test").build();
-
-        candidate = DataTreeCandidates.fromNormalizedNode(leafPath, leafNode);
-        DataTreeCandidatePayload payload = DataTreeCandidatePayload.create(candidate);
-        assertCandidateEquals(candidate, payload.getCandidate());
-    }
-}
index 736e29170364bf0af6a6f3ecdffcdcd69125311d..fc257b8cbbdf3fa8fd67295b4924dfa7b5c11ac9 100644 (file)
@@ -50,21 +50,6 @@ public class ShardRecoveryCoordinatorTest extends AbstractTest {
         peopleDataTree = new ShardDataTree(mockShard, peopleSchemaContext, TreeType.OPERATIONAL);
     }
 
-    @Deprecated
-    @Test
-    public void testAppendRecoveredLogEntryDataTreeCandidatePayload() {
-        final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree,
-                null, "foobar", LoggerFactory.getLogger("foo"));
-        coordinator.startLogRecoveryBatch(10);
-        try {
-            coordinator.appendRecoveredLogEntry(DataTreeCandidatePayload.create(createCar()));
-        } catch (final SchemaValidationFailedException e) {
-            fail("SchemaValidationFailedException should not happen if pruning is done");
-        }
-
-        coordinator.applyCurrentLogRecoveryBatch();
-    }
-
     @Test
     public void testAppendRecoveredLogEntryCommitTransactionPayload() throws IOException {
         final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree,