From: Tony Tkacik Date: Thu, 5 Feb 2015 09:57:50 +0000 (+0000) Subject: Merge "BUG-2288: remove DOMNotificationListenerRegistration" X-Git-Tag: release/lithium~632 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=c37b95d3a9347913a4854b2f448e216cd17cae87;hp=49de64c7659a854950ee4f5970e8b18aa92ecc0b Merge "BUG-2288: remove DOMNotificationListenerRegistration" --- diff --git a/features/neutron/pom.xml b/features/neutron/pom.xml index 642ce98351..cd7dce53d4 100644 --- a/features/neutron/pom.xml +++ b/features/neutron/pom.xml @@ -16,6 +16,17 @@ + + org.opendaylight.aaa + features-aaa + ${aaa.version} + features + xml + + + org.opendaylight.controller + networkconfig.neutron + org.osgi org.osgi.core diff --git a/features/neutron/src/main/resources/features.xml b/features/neutron/src/main/resources/features.xml index 263f907cee..b244d4d2a9 100644 --- a/features/neutron/src/main/resources/features.xml +++ b/features/neutron/src/main/resources/features.xml @@ -3,15 +3,19 @@ + mvn:org.opendaylight.aaa/features-aaa/${aaa.version}/xml/features odl-neutron-api odl-neutron-northbound odl-neutron-implementation + odl-aaa-authn + war odl-neutron-api mvn:org.eclipse.persistence/org.eclipse.persistence.moxy/${eclipse.persistence.version} mvn:org.eclipse.persistence/org.eclipse.persistence.core/${eclipse.persistence.version} + mvn:org.eclipse.persistence/org.eclipse.persistence.antlr/${eclipse.persistence.version} mvn:org.opendaylight.controller/networkconfig.neutron.northbound/${networkconfig.neutron.northbound.version} mvn:com.sun.jersey/jersey-core/${jersey.version} mvn:com.sun.jersey/jersey-server/${jersey.version} @@ -26,7 +30,8 @@ odl-neutron-api + war mvn:org.opendaylight.controller/networkconfig.neutron.implementation/${networkconfig.neutron.implementation.version} mvn:org.osgi/org.osgi.core/${osgi.core.version} - \ No newline at end of file + diff --git a/karaf/opendaylight-karaf-resources/src/main/resources/configuration/tomcat-server.xml b/karaf/opendaylight-karaf-resources/src/main/resources/configuration/tomcat-server.xml index fbcd0a4c77..5092a5eee1 100644 --- a/karaf/opendaylight-karaf-resources/src/main/resources/configuration/tomcat-server.xml +++ b/karaf/opendaylight-karaf-resources/src/main/resources/configuration/tomcat-server.xml @@ -26,9 +26,9 @@ - + redirectPort="8663" /> + + + + + + + + + + + + + + + + + + + + + 300000 + 2 + false + 8543 + 20000 + 5000 + + + + + + + + + + + + + 300000 + 2 + false + 8443 + 20000 + 5000 + + + + + + + + + + + + + + + karaf + karaf + + + org.apache.karaf.jaas.boot.principal.RolePrincipal + + + + + + + + + + default + karaf + + + org.apache.karaf.jaas.boot.principal.RolePrincipal + + + + + + + + diff --git a/karaf/opendaylight-karaf/pom.xml b/karaf/opendaylight-karaf/pom.xml index e0ea4c0edf..9bf2309b6f 100644 --- a/karaf/opendaylight-karaf/pom.xml +++ b/karaf/opendaylight-karaf/pom.xml @@ -121,6 +121,14 @@ xml + + org.opendaylight.controller + features-neutron + features + xml + runtime + + diff --git a/opendaylight/commons/opendaylight/pom.xml b/opendaylight/commons/opendaylight/pom.xml index 32aa9a3efc..ba5d69ac46 100644 --- a/opendaylight/commons/opendaylight/pom.xml +++ b/opendaylight/commons/opendaylight/pom.xml @@ -1342,6 +1342,15 @@ runtime + + org.opendaylight.controller + features-neutron + features + xml + runtime + ${networkconfig.neutron.version} + + org.openjdk.jmh diff --git a/opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/attribute/JavaAttribute.java b/opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/attribute/JavaAttribute.java index f6ce92d506..6a90439bb2 100644 --- a/opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/attribute/JavaAttribute.java +++ b/opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/attribute/JavaAttribute.java @@ -201,7 +201,7 @@ public class JavaAttribute extends AbstractAttribute implements TypedAttribute { itemTypes[i++] = innerCompositeType; } - String[] descriptions = Arrays.copyOf(itemNames, itemNames.length); + String[] descriptions = itemNames.clone(); descriptions[0] = DESCRIPTION_OF_VALUE_ATTRIBUTE_FOR_UNION; try { diff --git a/opendaylight/md-sal/pom.xml b/opendaylight/md-sal/pom.xml index 9f342b88e8..1743b62180 100644 --- a/opendaylight/md-sal/pom.xml +++ b/opendaylight/md-sal/pom.xml @@ -78,6 +78,7 @@ sal-distributed-datastore + sal-dummy-distributed-datastore sal-dom-xsql diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/ValueSerializer.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/ValueSerializer.java index 71946b0a7a..9e3230a623 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/ValueSerializer.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/ValueSerializer.java @@ -16,6 +16,8 @@ import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessa import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; public class ValueSerializer { + private static final String NULL_VALUE = ""; + public static void serialize(NormalizedNodeMessages.Node.Builder builder, QNameSerializationContext context, Object value) { builder.setIntValueType(ValueType.getSerializableType(value).ordinal()); @@ -35,8 +37,10 @@ public class ValueSerializer { } } } - } else if(value instanceof byte[]){ + } else if(value instanceof byte[]) { builder.setBytesValue(ByteString.copyFrom((byte[]) value)); + } else if(value == null){ + builder.setValue(NULL_VALUE); } else { builder.setValue(value.toString()); } @@ -64,6 +68,8 @@ public class ValueSerializer { } } else if(value instanceof byte[]){ builder.setBytesValue(ByteString.copyFrom((byte[]) value)); + } else if(value == null){ + builder.setValue(NULL_VALUE); } else { builder.setValue(value.toString()); } diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/ValueType.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/ValueType.java index b9e46a3a57..9eec8a300a 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/ValueType.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/ValueType.java @@ -8,7 +8,6 @@ package org.opendaylight.controller.cluster.datastore.node.utils.serialization; -import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap.Builder; import java.math.BigDecimal; @@ -91,6 +90,12 @@ public enum ValueType { Object deserialize(final String str) { throw new UnsupportedOperationException("Should have been caught by caller"); } + }, + NULL_TYPE { + @Override + Object deserialize(final String str) { + return null; + } }; private static final Map, ValueType> TYPES; @@ -116,7 +121,9 @@ public enum ValueType { abstract Object deserialize(String str); public static final ValueType getSerializableType(Object node) { - Preconditions.checkNotNull(node, "node should not be null"); + if(node == null){ + return NULL_TYPE; + } final ValueType type = TYPES.get(node.getClass()); if (type != null) { diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeInputStreamReader.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeInputStreamReader.java index 2aa0027e55..cde338179b 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeInputStreamReader.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeInputStreamReader.java @@ -284,7 +284,7 @@ public class NormalizedNodeInputStreamReader implements NormalizedNodeStreamRead return bytes; case ValueTypes.YANG_IDENTIFIER_TYPE : - return readYangInstanceIdentifier(); + return readYangInstanceIdentifier(); default : return null; diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeOutputStreamWriter.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeOutputStreamWriter.java index 2c8e259711..088f4dfbe9 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeOutputStreamWriter.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeOutputStreamWriter.java @@ -365,6 +365,8 @@ public class NormalizedNodeOutputStreamWriter implements NormalizedNodeStreamWri case ValueTypes.YANG_IDENTIFIER_TYPE: writeYangInstanceIdentifier((YangInstanceIdentifier) value); break; + case ValueTypes.NULL_TYPE : + break; default: output.writeUTF(value.toString()); break; diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/ValueTypes.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/ValueTypes.java index 3a2d2b49b3..83099f8a5b 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/ValueTypes.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/ValueTypes.java @@ -8,7 +8,6 @@ package org.opendaylight.controller.cluster.datastore.node.utils.stream; -import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap.Builder; import java.math.BigDecimal; @@ -31,6 +30,7 @@ final class ValueTypes { public static final byte BIG_INTEGER_TYPE = 10; public static final byte BIG_DECIMAL_TYPE = 11; public static final byte BINARY_TYPE = 12; + public static final byte NULL_TYPE = 13; private static final Map, Byte> TYPES; @@ -57,7 +57,9 @@ final class ValueTypes { } public static final byte getSerializableType(Object node) { - Preconditions.checkNotNull(node, "node should not be null"); + if(node == null){ + return NULL_TYPE; + } final Byte type = TYPES.get(node.getClass()); if (type != null) { diff --git a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/ValueSerializerTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/ValueSerializerTest.java index d9b7a18fda..f5eecf33d9 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/ValueSerializerTest.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/ValueSerializerTest.java @@ -291,6 +291,24 @@ public class ValueSerializerTest{ } + @Test + public void testSerializeNull(){ + NormalizedNodeMessages.Node.Builder builder = NormalizedNodeMessages.Node.newBuilder(); + Object none = null; + ValueSerializer.serialize(builder, mock(QNameSerializationContext.class),none); + + assertEquals(ValueType.NULL_TYPE.ordinal(), builder.getIntValueType()); + assertEquals("", builder.getValue()); + + NormalizedNodeMessages.PathArgumentAttribute.Builder builder1 = NormalizedNodeMessages.PathArgumentAttribute.newBuilder(); + + ValueSerializer.serialize(builder1, mock(QNameSerializationContext.class),none); + + assertEquals(ValueType.NULL_TYPE.ordinal(), builder1.getType()); + assertEquals("", builder.getValue()); + + } + @Test public void testDeSerializeShort(){ @@ -519,5 +537,31 @@ public class ValueSerializerTest{ } + @Test + public void testDeSerializeNullType(){ + NormalizedNodeMessages.Node.Builder nodeBuilder = NormalizedNodeMessages.Node.newBuilder(); + nodeBuilder.setIntValueType(ValueType.NULL_TYPE.ordinal()); + nodeBuilder.setValue(""); + + Object o = ValueSerializer + .deSerialize(mock(QNameDeSerializationContext.class), + nodeBuilder.build()); + + assertEquals(null, o); + + NormalizedNodeMessages.PathArgumentAttribute.Builder argumentBuilder + = NormalizedNodeMessages.PathArgumentAttribute.newBuilder(); + + argumentBuilder.setType(ValueType.NULL_TYPE.ordinal()); + argumentBuilder.setValue(""); + + o = ValueSerializer + .deSerialize(mock(QNameDeSerializationContext.class), + argumentBuilder.build()); + + assertEquals(null, o); + + } + } diff --git a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/ValueTypeTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/ValueTypeTest.java index 8fe0633b6e..1280559c00 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/ValueTypeTest.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/ValueTypeTest.java @@ -1,8 +1,7 @@ package org.opendaylight.controller.cluster.datastore.node.utils.serialization; -import org.junit.Test; - import static org.junit.Assert.assertEquals; +import org.junit.Test; public class ValueTypeTest { @@ -15,4 +14,12 @@ public class ValueTypeTest { ValueType serializableType = ValueType.getSerializableType(b); assertEquals(ValueType.BINARY_TYPE, serializableType); } + + @Test + public void testNullType(){ + ValueType serializableType = ValueType.getSerializableType(null); + assertEquals(ValueType.NULL_TYPE, serializableType); + + assertEquals(null, ValueType.NULL_TYPE.deserialize("")); + } } \ No newline at end of file diff --git a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeStreamReaderWriterTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeStreamReaderWriterTest.java index a67e887a15..6528f2e4d2 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeStreamReaderWriterTest.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeStreamReaderWriterTest.java @@ -59,10 +59,15 @@ public class NormalizedNodeStreamReaderWriterTest { new YangInstanceIdentifier.NodeWithValue(TestModel.BINARY_LEAF_LIST_QNAME, bytes2)). withValue(bytes2).build(); + LeafSetEntryNode entry3 = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier( + new YangInstanceIdentifier.NodeWithValue(TestModel.BINARY_LEAF_LIST_QNAME, null)). + withValue(null).build(); + + return TestModel.createBaseTestContainerBuilder(). withChild(ImmutableLeafSetNodeBuilder.create().withNodeIdentifier( new YangInstanceIdentifier.NodeIdentifier(TestModel.BINARY_LEAF_LIST_QNAME)). - withChild(entry1).withChild(entry2).build()). + withChild(entry1).withChild(entry2).withChild(entry3).build()). withChild(ImmutableNodes.leafNode(TestModel.SOME_BINARY_DATA_QNAME, new byte[]{1,2,3,4})). withChild(Builders.orderedMapBuilder(). withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.ORDERED_LIST_QNAME)). diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedWriteTransaction.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedWriteTransaction.java index 45e18ff219..bc11f122e6 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedWriteTransaction.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedWriteTransaction.java @@ -108,6 +108,7 @@ class DOMForwardedWriteTransaction extends if (impl != null) { LOG.trace("Transaction {} cancelled before submit", getIdentifier()); FUTURE_UPDATER.lazySet(this, CANCELLED_FUTURE); + closeSubtransactions(); return true; } diff --git a/opendaylight/md-sal/sal-dummy-distributed-datastore/README b/opendaylight/md-sal/sal-dummy-distributed-datastore/README new file mode 100644 index 0000000000..19a17eacce --- /dev/null +++ b/opendaylight/md-sal/sal-dummy-distributed-datastore/README @@ -0,0 +1,16 @@ +To use this run a real instance of the controller on your laptop. +Modify the module-shards.conf to replicate modules to member-2 or +member-2 and member-3 as neccessary. + +Then run the dummy datastore. + +For example, + + java -jar ./target/sal-dummy-distributed-datastore-1.2.0-SNAPSHOT-allinone.jar -member-name member-2 -cause-trouble -drop-replies -max-delay-millis 500 + +Runs the dummy datastore as member-2. Will cause failures including dropped replies and when it does reply may cause a random delay of upto +500 millis + +This will start of the dummy datastore which will then spawn dummy shard actors which will listen to the RequestVote +and AppendEntries messages. For RequestVote messages it will always respond with a positive vote and for AppendEntries +it will put a sleep for a randomized interval upto the max delay. \ No newline at end of file diff --git a/opendaylight/md-sal/sal-dummy-distributed-datastore/pom.xml b/opendaylight/md-sal/sal-dummy-distributed-datastore/pom.xml new file mode 100644 index 0000000000..d8d1a76a70 --- /dev/null +++ b/opendaylight/md-sal/sal-dummy-distributed-datastore/pom.xml @@ -0,0 +1,214 @@ + + + 4.0.0 + + org.opendaylight.controller + sal-parent + 1.2.0-SNAPSHOT + + sal-dummy-distributed-datastore + bundle + + + + com.google.guava + guava + + + + com.typesafe.akka + akka-actor_${scala.version} + + + + com.typesafe.akka + akka-cluster_${scala.version} + + + + com.typesafe.akka + akka-persistence-experimental_${scala.version} + + + + com.typesafe.akka + akka-remote_${scala.version} + + + + com.typesafe.akka + akka-testkit_${scala.version} + + + + com.typesafe.akka + akka-slf4j_${scala.version} + + + + com.typesafe.akka + akka-osgi_${scala.version} + + + + org.opendaylight.controller + sal-clustering-commons + + + + org.opendaylight.controller + sal-akka-raft + 1.2.0-SNAPSHOT + + + + + + junit + junit + test + + + org.mockito + mockito-all + test + + + + org.slf4j + slf4j-simple + ${slf4j.version} + test + + + + args4j + args4j + 2.0.29 + + + + org.slf4j + slf4j-simple + 1.7.7 + + + + + + + + + org.apache.felix + maven-bundle-plugin + true + + + ${project.groupId}.${project.artifactId} + + + !*snappy;!org.jboss.*;!com.jcraft.*;!*jetty*;!sun.security.*;* + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + test-jar + + + + + + org.jacoco + jacoco-maven-plugin + + + org.opendaylight.controller.* + + + + org.opendaylight.controller.config.yang.config.* + + false + + + + pre-test + + prepare-agent + + + + post-test + + report + + test + + + + + org.apache.maven.plugins + maven-shade-plugin + 1.5 + + + package + + shade + + + true + allinone + + + *:* + + + + + reference.conf + + + + org.opendaylight.controller.dummy.datastore.Main + + + + + + + + + + + scm:git:ssh://git.opendaylight.org:29418/controller.git + scm:git:ssh://git.opendaylight.org:29418/controller.git + HEAD + https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL:Architecture:Clustering + + diff --git a/opendaylight/md-sal/sal-dummy-distributed-datastore/src/main/java/org/opendaylight/controller/dummy/datastore/Configuration.java b/opendaylight/md-sal/sal-dummy-distributed-datastore/src/main/java/org/opendaylight/controller/dummy/datastore/Configuration.java new file mode 100644 index 0000000000..bbf40824a6 --- /dev/null +++ b/opendaylight/md-sal/sal-dummy-distributed-datastore/src/main/java/org/opendaylight/controller/dummy/datastore/Configuration.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2014 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.dummy.datastore; + +public class Configuration { + private final int maxDelayInMillis; + private final boolean dropReplies; + private final boolean causeTrouble; + + public Configuration(int maxDelayInMillis, boolean dropReplies, boolean causeTrouble) { + this.maxDelayInMillis = maxDelayInMillis; + this.dropReplies = dropReplies; + this.causeTrouble = causeTrouble; + } + + public int getMaxDelayInMillis() { + return maxDelayInMillis; + } + + public boolean shouldDropReplies() { + return dropReplies; + } + + public boolean shouldCauseTrouble() { + return causeTrouble; + } +} diff --git a/opendaylight/md-sal/sal-dummy-distributed-datastore/src/main/java/org/opendaylight/controller/dummy/datastore/DummyShard.java b/opendaylight/md-sal/sal-dummy-distributed-datastore/src/main/java/org/opendaylight/controller/dummy/datastore/DummyShard.java new file mode 100644 index 0000000000..34b41ccfca --- /dev/null +++ b/opendaylight/md-sal/sal-dummy-distributed-datastore/src/main/java/org/opendaylight/controller/dummy/datastore/DummyShard.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2014 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.dummy.datastore; + +import akka.actor.Props; +import akka.actor.UntypedActor; +import akka.japi.Creator; +import org.opendaylight.controller.cluster.raft.messages.AppendEntries; +import org.opendaylight.controller.cluster.raft.messages.AppendEntriesReply; +import org.opendaylight.controller.cluster.raft.messages.InstallSnapshot; +import org.opendaylight.controller.cluster.raft.messages.InstallSnapshotReply; +import org.opendaylight.controller.cluster.raft.messages.RequestVote; +import org.opendaylight.controller.cluster.raft.messages.RequestVoteReply; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class DummyShard extends UntypedActor{ + private final Configuration configuration; + private final String followerId; + private final Logger LOG = LoggerFactory.getLogger(DummyShard.class); + + public DummyShard(Configuration configuration, String followerId) { + this.configuration = configuration; + this.followerId = followerId; + LOG.info("Creating : {}", followerId); + } + + @Override + public void onReceive(Object o) throws Exception { + if(o instanceof RequestVote){ + RequestVote req = (RequestVote) o; + sender().tell(new RequestVoteReply(req.getTerm(), true), self()); + } else if(AppendEntries.LEGACY_SERIALIZABLE_CLASS.equals(o.getClass()) || o instanceof AppendEntries) { + AppendEntries req = AppendEntries.fromSerializable(o); + handleAppendEntries(req); + } else if(InstallSnapshot.SERIALIZABLE_CLASS.equals(o.getClass())) { + InstallSnapshot req = InstallSnapshot.fromSerializable(o); + handleInstallSnapshot(req); + } else if(o instanceof InstallSnapshot){ + handleInstallSnapshot((InstallSnapshot) o); + } else { + LOG.error("Unknown message : {}", o.getClass()); + } + } + + private void handleInstallSnapshot(InstallSnapshot req) { + sender().tell(new InstallSnapshotReply(req.getTerm(), followerId, req.getChunkIndex(), true), self()); + } + + protected void handleAppendEntries(AppendEntries req) throws InterruptedException { + LOG.info("{} - Received AppendEntries message : leader term, index, size = {}, {}, {}", followerId, req.getTerm(),req.getLeaderCommit(), req.getEntries().size()); + long lastIndex = req.getLeaderCommit(); + if (req.getEntries().size() > 0) + lastIndex = req.getEntries().get(0).getIndex(); + + if (configuration.shouldCauseTrouble()) { + boolean ignore = false; + + if (configuration.shouldDropReplies()) { + ignore = Math.random() > 0.5; + } + + long delay = (long) (Math.random() * configuration.getMaxDelayInMillis()); + + if (!ignore) { + LOG.info("{} - Randomizing delay : {}", followerId, delay); + Thread.sleep(delay); + sender().tell(new AppendEntriesReply(followerId, req.getTerm(), true, lastIndex, req.getTerm()), self()); + } + } else { + sender().tell(new AppendEntriesReply(followerId, req.getTerm(), true, lastIndex, req.getTerm()), self()); + } + } + + public static Props props(Configuration configuration, final String followerId) { + + return Props.create(new DummyShardCreator(configuration, followerId)); + } + + private static class DummyShardCreator implements Creator { + + private static final long serialVersionUID = 1L; + private final Configuration configuration; + private final String followerId; + + DummyShardCreator(Configuration configuration, String followerId) { + this.configuration = configuration; + this.followerId = followerId; + } + + @Override + public DummyShard create() throws Exception { + return new DummyShard(configuration, followerId); + } + } + +} diff --git a/opendaylight/md-sal/sal-dummy-distributed-datastore/src/main/java/org/opendaylight/controller/dummy/datastore/DummyShardManager.java b/opendaylight/md-sal/sal-dummy-distributed-datastore/src/main/java/org/opendaylight/controller/dummy/datastore/DummyShardManager.java new file mode 100644 index 0000000000..339f37e0bb --- /dev/null +++ b/opendaylight/md-sal/sal-dummy-distributed-datastore/src/main/java/org/opendaylight/controller/dummy/datastore/DummyShardManager.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2014 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.dummy.datastore; + +import akka.actor.ActorContext; +import akka.actor.Props; +import akka.actor.UntypedActor; +import akka.japi.Creator; + +public class DummyShardManager extends UntypedActor { + public DummyShardManager(Configuration configuration, String memberName, String[] shardNames, String type) throws Exception { + new DummyShardsCreator(configuration, context(), memberName, shardNames, type).create(); + } + + @Override + public void onReceive(Object o) throws Exception { + + } + + public static Props props(Configuration configuration, String memberName, String[] shardNames, String type){ + return Props.create(new DummyShardManagerCreator(configuration, memberName, shardNames, type)); + } + + private static class DummyShardManagerCreator implements Creator { + + private final Configuration configuration; + private final String memberName; + private final String[] shardNames; + private final String type; + + public DummyShardManagerCreator(Configuration configuration, String memberName, String[] shardNames, String type) { + this.configuration = configuration; + this.memberName = memberName; + this.shardNames = shardNames; + this.type = type; + } + + @Override + public DummyShardManager create() throws Exception { + return new DummyShardManager(configuration, memberName, shardNames, type ); + } + } + + private static class DummyShardsCreator { + private final Configuration configuration; + private final ActorContext actorSystem; + private final String memberName; + private final String[] shardNames; + private final String type; + + DummyShardsCreator(Configuration configuration, ActorContext actorSystem, String memberName, String[] shardNames, String type){ + this.configuration = configuration; + this.actorSystem = actorSystem; + this.memberName = memberName; + this.shardNames = shardNames; + this.type = type; + } + + void create(){ + for(String shardName : shardNames){ + String shardId = memberName + "-shard-" + shardName + "-" + type; + actorSystem.actorOf(DummyShard.props(configuration, shardId), shardId); + } + } + } +} diff --git a/opendaylight/md-sal/sal-dummy-distributed-datastore/src/main/java/org/opendaylight/controller/dummy/datastore/Main.java b/opendaylight/md-sal/sal-dummy-distributed-datastore/src/main/java/org/opendaylight/controller/dummy/datastore/Main.java new file mode 100644 index 0000000000..81da1f89a6 --- /dev/null +++ b/opendaylight/md-sal/sal-dummy-distributed-datastore/src/main/java/org/opendaylight/controller/dummy/datastore/Main.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2014 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.dummy.datastore; + +import akka.actor.ActorSystem; +import com.typesafe.config.ConfigFactory; +import org.kohsuke.args4j.CmdLineParser; +import org.kohsuke.args4j.Option; + +public class Main { + @Option(name="-member-name", usage="Sets the member name", required = true) + public String memberName; + + @Option(name="-max-delay-millis", usage = "Sets the maximum delay that should be applied for any append entry. Only applies when cause-trouble is present.") + public int maxDelayInMillis = 500; + + @Option(name="-cause-trouble", usage="If present turns on artificial failures") + public boolean causeTrouble = false; + + @Option(name="-drop-replies", usage = "If present drops replies. Only applies when cause-trouble is present.") + public boolean dropReplies = false; + + public void run(){ + ActorSystem actorSystem = ActorSystem.create("opendaylight-cluster-data", ConfigFactory.load(memberName).getConfig("odl-cluster-data")); + + Configuration configuration = new Configuration(maxDelayInMillis, dropReplies, causeTrouble); + + actorSystem.actorOf(DummyShardManager.props(configuration, memberName, new String[] {"inventory", "default", "toaster", "topology"}, "operational"), "shardmanager-operational"); + actorSystem.actorOf(DummyShardManager.props(configuration, memberName, new String[] {"inventory", "default", "toaster", "topology"}, "config"), "shardmanager-config"); + } + + @Override + public String toString() { + return "Main{" + + "memberName='" + memberName + '\'' + + ", maxDelayInMillis=" + maxDelayInMillis + + ", causeTrouble=" + causeTrouble + + ", dropReplies=" + dropReplies + + '}'; + } + + public static void main(String[] args){ + Main bean = new Main(); + CmdLineParser parser = new CmdLineParser(bean); + + try { + parser.parseArgument(args); + System.out.println(bean.toString()); + bean.run(); + } catch(Exception e){ + System.err.println(e.getMessage()); + parser.printUsage(System.err); + } + } + +} diff --git a/opendaylight/md-sal/sal-dummy-distributed-datastore/src/main/resources/member-2.conf b/opendaylight/md-sal/sal-dummy-distributed-datastore/src/main/resources/member-2.conf new file mode 100644 index 0000000000..38aa4c5174 --- /dev/null +++ b/opendaylight/md-sal/sal-dummy-distributed-datastore/src/main/resources/member-2.conf @@ -0,0 +1,49 @@ +odl-cluster-data { + bounded-mailbox { + mailbox-type = "org.opendaylight.controller.cluster.common.actor.MeteredBoundedMailbox" + mailbox-capacity = 1000 + mailbox-push-timeout-time = 100ms + } + + metric-capture-enabled = true + + akka { + loglevel = "INFO" + loggers = ["akka.event.slf4j.Slf4jLogger"] + + actor { + + provider = "akka.cluster.ClusterActorRefProvider" + serializers { + java = "akka.serialization.JavaSerializer" + proto = "akka.remote.serialization.ProtobufSerializer" + } + + serialization-bindings { + "com.google.protobuf.Message" = proto + + } + } + remote { + log-remote-lifecycle-events = off + netty.tcp { + hostname = "127.0.0.1" + port = 2553 + maximum-frame-size = 419430400 + send-buffer-size = 52428800 + receive-buffer-size = 52428800 + } + } + + cluster { + seed-nodes = ["akka.tcp://opendaylight-cluster-data@127.0.0.1:2550", "akka.tcp://opendaylight-cluster-data@127.0.0.1:2553"] + + auto-down-unreachable-after = 10s + + roles = [ + "member-2" + ] + + } + } +} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-dummy-distributed-datastore/src/main/resources/member-3.conf b/opendaylight/md-sal/sal-dummy-distributed-datastore/src/main/resources/member-3.conf new file mode 100644 index 0000000000..7b2da6a1db --- /dev/null +++ b/opendaylight/md-sal/sal-dummy-distributed-datastore/src/main/resources/member-3.conf @@ -0,0 +1,49 @@ +odl-cluster-data { + bounded-mailbox { + mailbox-type = "org.opendaylight.controller.cluster.common.actor.MeteredBoundedMailbox" + mailbox-capacity = 1000 + mailbox-push-timeout-time = 100ms + } + + metric-capture-enabled = true + + akka { + loglevel = "INFO" + loggers = ["akka.event.slf4j.Slf4jLogger"] + + actor { + + provider = "akka.cluster.ClusterActorRefProvider" + serializers { + java = "akka.serialization.JavaSerializer" + proto = "akka.remote.serialization.ProtobufSerializer" + } + + serialization-bindings { + "com.google.protobuf.Message" = proto + + } + } + remote { + log-remote-lifecycle-events = off + netty.tcp { + hostname = "127.0.0.1" + port = 2554 + maximum-frame-size = 419430400 + send-buffer-size = 52428800 + receive-buffer-size = 52428800 + } + } + + cluster { + seed-nodes = ["akka.tcp://opendaylight-cluster-data@127.0.0.1:2550", "akka.tcp://opendaylight-cluster-data@127.0.0.1:2554"] + + auto-down-unreachable-after = 10s + + roles = [ + "member-3" + ] + + } + } +} \ No newline at end of file diff --git a/opendaylight/networkconfiguration/neutron/northbound/src/main/resources/WEB-INF/web.xml b/opendaylight/networkconfiguration/neutron/northbound/src/main/resources/WEB-INF/web.xml index dccd1332c9..08a314a42e 100644 --- a/opendaylight/networkconfiguration/neutron/northbound/src/main/resources/WEB-INF/web.xml +++ b/opendaylight/networkconfiguration/neutron/northbound/src/main/resources/WEB-INF/web.xml @@ -9,6 +9,11 @@ javax.ws.rs.Application org.opendaylight.controller.networkconfig.neutron.northbound.NeutronNorthboundRSApplication + + + com.sun.jersey.spi.container.ContainerRequestFilters + org.opendaylight.aaa.sts.TokenAuthFilter + 1 @@ -16,34 +21,37 @@ JAXRSNeutron /* - - - NB api - /* - - - System-Admin - Network-Admin - Network-Operator - Container-User - - - - - System-Admin - - - Network-Admin - - - Network-Operator - - - Container-User - - - BASIC - opendaylight - + + cross-origin-restconf + org.eclipse.jetty.servlets.CrossOriginFilter + + allowedOrigins + * + + + allowedMethods + GET,POST,OPTIONS,DELETE,PUT,HEAD + + + allowedHeaders + origin, content-type, accept, authorization + + + + cross-origin-restconf + /* + + + + NB api + /* + POST + GET + PUT + PATCH + DELETE + HEAD + +