</parent>
<artifactId>features-controller</artifactId>
<packaging>pom</packaging>
- <prerequisites>
- <maven>3.0</maven>
- </prerequisites>
+
<modules>
<module>config</module>
<module>config-persister</module>
</parent>
<artifactId>itests-controller</artifactId>
<packaging>pom</packaging>
- <prerequisites>
- <maven>3.0</maven>
- </prerequisites>
+
<modules>
<module>base-features-it</module>
</modules>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0 .0.xsd">
<modelVersion>4.0.0</modelVersion>
- <prerequisites>
- <maven>3.0</maven>
- </prerequisites>
<parent>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<artifactId>commons.opendaylight</artifactId>
<version>1.5.0-SNAPSHOT</version>
<packaging>pom</packaging>
- <prerequisites>
- <maven>3.0</maven>
- </prerequisites>
<properties>
<version>${enforcer.version}</version>
<executions>
<execution>
- <id>enforce-java</id>
+ <id>enforce-requirements</id>
<goals>
<goal>enforce</goal>
</goals>
<requireJavaVersion>
<version>1.7.0</version>
</requireJavaVersion>
+ <requireMavenVersion>
+ <version>3.1.1</version>
+ </requireMavenVersion>
</rules>
</configuration>
</execution>
<artifactId>commons.parent</artifactId>
<version>1.1.0-SNAPSHOT</version>
<packaging>pom</packaging>
- <prerequisites>
- <maven>3.0</maven>
- </prerequisites>
<properties>
<nexus.repository.release>opendaylight.release</nexus.repository.release>
<packaging>bundle</packaging>
<name>${project.artifactId}</name>
<description>Common protocol framework</description>
- <prerequisites>
- <maven>3.0.4</maven>
- </prerequisites>
<dependencies>
<dependency>
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
+import java.io.DataInput;
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import org.opendaylight.controller.cluster.datastore.node.utils.QNameFactory;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.Node;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeContainerBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.DataInput;
-import java.io.DataInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
/**
* NormalizedNodeInputStreamReader reads the byte stream and constructs the normalized node including its children nodes.
private NormalizedNodeAttrBuilder<NodeWithValue, Object,
LeafSetEntryNode<Object>> leafSetEntryBuilder;
+ private final StringBuilder reusableStringBuilder = new StringBuilder(50);
+
public NormalizedNodeInputStreamReader(InputStream stream) throws IOException {
Preconditions.checkNotNull(stream);
input = new DataInputStream(stream);
case NodeTypes.ANY_XML_NODE :
LOG.debug("Read xml node");
- Node<?> value = (Node<?>) readObject();
return Builders.anyXmlBuilder().withValue((Node<?>) readObject()).build();
case NodeTypes.MAP_NODE :
String namespace = readCodedString();
String revision = readCodedString();
- // Not using stringbuilder as compiler optimizes string concatenation of +
String qName;
if(!Strings.isNullOrEmpty(revision)) {
- qName = "(" + namespace + REVISION_ARG + revision + ")" +localName;
+ qName = reusableStringBuilder.append('(').append(namespace).append(REVISION_ARG).
+ append(revision).append(')').append(localName).toString();
} else {
- qName = "(" + namespace + ")" + localName;
+ qName = reusableStringBuilder.append('(').append(namespace).append(')').
+ append(localName).toString();
}
+ reusableStringBuilder.delete(0, reusableStringBuilder.length());
return QNameFactory.create(qName);
}
if(valueType == NormalizedNodeOutputStreamWriter.IS_CODE_VALUE) {
return codedStringMap.get(input.readInt());
} else if(valueType == NormalizedNodeOutputStreamWriter.IS_STRING_VALUE) {
- String value = input.readUTF();
+ String value = input.readUTF().intern();
codedStringMap.put(Integer.valueOf(codedStringMap.size()), value);
return value;
}
return readObjSet();
case ValueTypes.BOOL_TYPE :
- return input.readBoolean();
+ return Boolean.valueOf(input.readBoolean());
case ValueTypes.BYTE_TYPE :
- return input.readByte();
+ return Byte.valueOf(input.readByte());
case ValueTypes.INT_TYPE :
- return input.readInt();
+ return Integer.valueOf(input.readInt());
case ValueTypes.LONG_TYPE :
- return input.readLong();
+ return Long.valueOf(input.readLong());
case ValueTypes.QNAME_TYPE :
return readQName();
case ValueTypes.SHORT_TYPE :
- return input.readShort();
+ return Short.valueOf(input.readShort());
case ValueTypes.STRING_TYPE :
return input.readUTF();
case ValueTypes.BIG_INTEGER_TYPE :
return new BigInteger(input.readUTF());
+ case ValueTypes.BINARY_TYPE :
+ byte[] bytes = new byte[input.readInt()];
+ input.readFully(bytes);
+ return bytes;
+
case ValueTypes.YANG_IDENTIFIER_TYPE :
return readYangInstanceIdentifier();
return new YangInstanceIdentifier.AugmentationIdentifier(readQNameSet());
case PathArgumentTypes.NODE_IDENTIFIER :
- return new NodeIdentifier(readQName());
+ return new NodeIdentifier(readQName());
case PathArgumentTypes.NODE_IDENTIFIER_WITH_PREDICATES :
- return new NodeIdentifierWithPredicates(readQName(), readKeyValueMap());
+ return new NodeIdentifierWithPredicates(readQName(), readKeyValueMap());
case PathArgumentTypes.NODE_IDENTIFIER_WITH_VALUE :
- return new NodeWithValue(readQName(), readObject());
+ return new NodeWithValue(readQName(), readObject());
default :
return null;
import com.google.common.base.Preconditions;
import com.google.common.collect.Iterables;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import java.io.DataOutput;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* NormalizedNodeOutputStreamWriter will be used by distributed datastore to send normalized node in
}
}
- @SuppressWarnings("rawtypes")
private void writeObject(Object value) throws IOException {
byte type = ValueTypes.getSerializableType(value);
case ValueTypes.BITS_TYPE:
writeObjSet((Set<?>) value);
break;
+ case ValueTypes.BINARY_TYPE:
+ byte[] bytes = (byte[]) value;
+ output.writeInt(bytes.length);
+ output.write(bytes);
+ break;
case ValueTypes.YANG_IDENTIFIER_TYPE:
writeYangInstanceIdentifier((YangInstanceIdentifier) value);
break;
package org.opendaylight.controller.cluster.datastore.node.utils.stream;
import com.google.common.base.Preconditions;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
public class ValueTypes {
public static final byte SHORT_TYPE = 1;
public static final byte STRING_TYPE = 9;
public static final byte BIG_INTEGER_TYPE = 10;
public static final byte BIG_DECIMAL_TYPE = 11;
+ public static final byte BINARY_TYPE = 12;
private static Map<Class<?>, Byte> types = new HashMap<>();
types.put(Short.class, Byte.valueOf(SHORT_TYPE));
types.put(BigInteger.class, Byte.valueOf(BIG_INTEGER_TYPE));
types.put(BigDecimal.class, Byte.valueOf(BIG_DECIMAL_TYPE));
+ types.put(byte[].class, Byte.valueOf(BINARY_TYPE));
}
public static final byte getSerializableType(Object node){
}
ContainerNode node1 = TestModel.createBaseTestContainerBuilder()
- .withChild(ImmutableNodes.leafNode(TestModel.SOME_BINARY_DATE_QNAME, binaryData))
+ .withChild(ImmutableNodes.leafNode(TestModel.SOME_BINARY_DATA_QNAME, binaryData))
.build();
NormalizedNodeMessages.Node serializedNode1 = NormalizedNodeSerializer
// FIXME: This will not work due to BUG 2326. Once that is fixed we can uncomment this assertion
// assertEquals(node1, node2);
- Optional<DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?>> child = node2.getChild(new YangInstanceIdentifier.NodeIdentifier(TestModel.SOME_BINARY_DATE_QNAME));
+ Optional<DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?>> child = node2.getChild(new YangInstanceIdentifier.NodeIdentifier(TestModel.SOME_BINARY_DATA_QNAME));
Object value = child.get().getValue();
import org.junit.Test;
import org.opendaylight.controller.cluster.datastore.util.TestModel;
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
+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.stream.NormalizedNodeStreamWriter;
import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter;
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.ImmutableLeafSetEntryNodeBuilder;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
public class NormalizedNodeStreamReaderWriterTest {
@Test
public void testNormalizedNodeStreamReaderWriter() throws IOException {
- testNormalizedNodeStreamReaderWriter(TestModel.createTestContainer());
+ testNormalizedNodeStreamReaderWriter(createTestContainer());
QName toaster = QName.create("http://netconfcentral.org/ns/toaster","2009-11-20","toaster");
QName darknessFactor = QName.create("http://netconfcentral.org/ns/toaster","2009-11-20","darknessFactor");
withChild(toasterNode).build());
}
+ private NormalizedNode<?, ?> createTestContainer() {
+ byte[] bytes1 = {1,2,3};
+ LeafSetEntryNode<Object> entry1 = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(
+ new YangInstanceIdentifier.NodeWithValue(TestModel.BINARY_LEAF_LIST_QNAME, bytes1)).
+ withValue(bytes1).build();
+
+ byte[] bytes2 = {};
+ LeafSetEntryNode<Object> entry2 = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(
+ new YangInstanceIdentifier.NodeWithValue(TestModel.BINARY_LEAF_LIST_QNAME, bytes2)).
+ withValue(bytes2).build();
+
+ return TestModel.createBaseTestContainerBuilder().
+ withChild(ImmutableLeafSetNodeBuilder.create().withNodeIdentifier(
+ new YangInstanceIdentifier.NodeIdentifier(TestModel.BINARY_LEAF_LIST_QNAME)).
+ withChild(entry1).withChild(entry2).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)).
+ withChild(ImmutableNodes.mapEntry(TestModel.ORDERED_LIST_ENTRY_QNAME,
+ TestModel.ID_QNAME, 11)).build()).
+ build();
+ }
+
private void testNormalizedNodeStreamReaderWriter(NormalizedNode<?, ?> input) throws IOException {
byte[] byteData = null;
package org.opendaylight.controller.cluster.datastore.util;
+import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntry;
+import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntryBuilder;
+import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapNodeBuilder;
import com.google.common.collect.ImmutableSet;
+import java.io.InputStream;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntry;
-import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntryBuilder;
-import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapNodeBuilder;
-
public class TestModel {
public static final QName TEST_QNAME = QName.create(
public static final QName DESC_QNAME = QName.create(TEST_QNAME, "desc");
public static final QName POINTER_QNAME = QName.create(TEST_QNAME, "pointer");
- public static final QName SOME_BINARY_DATE_QNAME = QName.create(TEST_QNAME, "some-binary-data");
+ public static final QName SOME_BINARY_DATA_QNAME = QName.create(TEST_QNAME, "some-binary-data");
+ public static final QName BINARY_LEAF_LIST_QNAME = QName.create(TEST_QNAME, "binary_leaf_list");
public static final QName SOME_REF_QNAME = QName.create(TEST_QNAME,
"some-ref");
public static final QName MYIDENTITY_QNAME = QName.create(TEST_QNAME,
public static final QName SWITCH_FEATURES_QNAME = QName.create(TEST_QNAME,
"switch-features");
- public static final QName AUGMENTED_LIST_QNAME = QName.create(TEST_QNAME,
- "augmented-list");
+ public static final QName AUGMENTED_LIST_QNAME = QName.create(TEST_QNAME, "augmented-list");
+ public static final QName AUGMENTED_LIST_ENTRY_QNAME = QName.create(TEST_QNAME, "augmented-list-entry");
public static final QName OUTER_LIST_QNAME = QName.create(TEST_QNAME,
"outer-list");
public static final QName ID_QNAME = QName.create(TEST_QNAME, "id");
public static final QName NAME_QNAME = QName.create(TEST_QNAME, "name");
public static final QName VALUE_QNAME = QName.create(TEST_QNAME, "value");
+ public static final QName BOOLEAN_LEAF_QNAME = QName.create(TEST_QNAME, "boolean-leaf");
+ public static final QName SHORT_LEAF_QNAME = QName.create(TEST_QNAME, "short-leaf");
+ public static final QName BYTE_LEAF_QNAME = QName.create(TEST_QNAME, "byte-leaf");
+ public static final QName BIGINTEGER_LEAF_QNAME = QName.create(TEST_QNAME, "biginteger-leaf");
+ public static final QName BIGDECIMAL_LEAF_QNAME = QName.create(TEST_QNAME, "bigdecimal-leaf");
+ public static final QName ORDERED_LIST_QNAME = QName.create(TEST_QNAME, "ordered-list");
+ public static final QName ORDERED_LIST_ENTRY_QNAME = QName.create(TEST_QNAME, "ordered-list-entry");
+ public static final QName UNKEYED_LIST_QNAME = QName.create(TEST_QNAME, "unkeyed-list");
+ public static final QName UNKEYED_LIST_ENTRY_QNAME = QName.create(TEST_QNAME, "unkeyed-list-entry");
+ public static final QName CHOICE_QNAME = QName.create(TEST_QNAME, "choice");
private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang";
private static final String DATASTORE_AUG_YANG =
"/odl-datastore-augmentation.yang";
private static final String TWO_TWO_NAME = "two";
private static final String DESC = "Hello there";
private static final Long LONG_ID = 1L;
- private static final Boolean ENABLED = false;
+ private static final Boolean ENABLED = true;
private static final Short SHORT_ID = 1;
private static final Byte BYTE_ID = 1;
// Family specific constants
private static final String SECOND_GRAND_CHILD_NAME = "second grand child";
- // first child
- private static final YangInstanceIdentifier CHILDREN_1_PATH =
- YangInstanceIdentifier.builder(CHILDREN_PATH)
- .nodeWithKey(CHILDREN_QNAME, CHILD_NUMBER_QNAME, FIRST_CHILD_ID) //
- .build();
- private static final YangInstanceIdentifier CHILDREN_1_NAME_PATH =
- YangInstanceIdentifier.builder(CHILDREN_PATH)
- .nodeWithKey(CHILDREN_QNAME, CHILD_NAME_QNAME, FIRST_CHILD_NAME) //
- .build();
-
- private static final YangInstanceIdentifier CHILDREN_2_PATH =
- YangInstanceIdentifier.builder(CHILDREN_PATH)
- .nodeWithKey(CHILDREN_QNAME, CHILD_NUMBER_QNAME, SECOND_CHILD_ID) //
- .build();
- private static final YangInstanceIdentifier CHILDREN_2_NAME_PATH =
- YangInstanceIdentifier.builder(CHILDREN_PATH)
- .nodeWithKey(CHILDREN_QNAME, CHILD_NAME_QNAME, SECOND_CHILD_NAME) //
- .build();
-
-
- private static final YangInstanceIdentifier GRAND_CHILD_1_PATH =
- YangInstanceIdentifier
- .builder(CHILDREN_1_PATH)
- .node(GRAND_CHILDREN_QNAME)
- //
- .nodeWithKey(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME,
- FIRST_GRAND_CHILD_ID) //
- .build();
-
- private static final YangInstanceIdentifier GRAND_CHILD_1_NAME_PATH =
- YangInstanceIdentifier
- .builder(CHILDREN_1_PATH)
- .node(GRAND_CHILDREN_QNAME)
- //
- .nodeWithKey(GRAND_CHILDREN_QNAME, GRAND_CHILD_NAME_QNAME,
- FIRST_GRAND_CHILD_NAME) //
- .build();
-
- private static final YangInstanceIdentifier GRAND_CHILD_2_PATH =
- YangInstanceIdentifier
- .builder(CHILDREN_2_PATH)
- .node(GRAND_CHILDREN_QNAME)
- //
- .nodeWithKey(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME,
- SECOND_GRAND_CHILD_ID) //
- .build();
-
- private static final YangInstanceIdentifier GRAND_CHILD_2_NAME_PATH =
- YangInstanceIdentifier
- .builder(CHILDREN_2_PATH)
- .node(GRAND_CHILDREN_QNAME)
- //
- .nodeWithKey(GRAND_CHILDREN_QNAME, GRAND_CHILD_NAME_QNAME,
- SECOND_GRAND_CHILD_NAME) //
- .build();
-
- private static final YangInstanceIdentifier DESC_PATH_ID =
- YangInstanceIdentifier.builder(DESC_PATH).build();
- private static final YangInstanceIdentifier OUTER_LIST_1_PATH =
- YangInstanceIdentifier.builder(OUTER_LIST_PATH)
- .nodeWithKey(OUTER_LIST_QNAME, ID_QNAME, ONE_ID) //
- .build();
-
- private static final YangInstanceIdentifier OUTER_LIST_2_PATH =
- YangInstanceIdentifier.builder(OUTER_LIST_PATH)
- .nodeWithKey(OUTER_LIST_QNAME, ID_QNAME, TWO_ID) //
- .build();
-
- private static final YangInstanceIdentifier TWO_TWO_PATH =
- YangInstanceIdentifier.builder(OUTER_LIST_2_PATH).node(INNER_LIST_QNAME) //
- .nodeWithKey(INNER_LIST_QNAME, NAME_QNAME, TWO_TWO_NAME) //
- .build();
-
- private static final YangInstanceIdentifier TWO_TWO_VALUE_PATH =
- YangInstanceIdentifier.builder(TWO_TWO_PATH).node(VALUE_QNAME) //
- .build();
-
private static final MapEntryNode BAR_NODE = mapEntryBuilder(
OUTER_LIST_QNAME, ID_QNAME, TWO_ID) //
.withChild(mapNodeBuilder(INNER_LIST_QNAME) //
// Create augmentations
- MapEntryNode mapEntry = createAugmentedListEntry(1, "First Test");
+ MapEntryNode augMapEntry = createAugmentedListEntry(1, "First Test");
// Create a bits leaf
NormalizedNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, Object, LeafNode<Object>>
QName.create(TEST_QNAME, "my-bits"))).withValue(
ImmutableSet.of("foo", "bar"));
- // Create unkey list entry
- UnkeyedListEntryNode binaryDataKey =
- Builders.unkeyedListEntryBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME)).
- withChild(ImmutableNodes.leafNode(SOME_BINARY_DATE_QNAME, DESC)).build();
+ // Create unkeyed list entry
+ UnkeyedListEntryNode unkeyedListEntry =
+ Builders.unkeyedListEntryBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(UNKEYED_LIST_ENTRY_QNAME)).
+ withChild(ImmutableNodes.leafNode(NAME_QNAME, "unkeyed-entry-name")).build();
+
+ // Create YangInstanceIdentifier with all path arg types.
+ YangInstanceIdentifier instanceID = YangInstanceIdentifier.create(
+ new YangInstanceIdentifier.NodeIdentifier(QName.create(TEST_QNAME, "qname")),
+ new YangInstanceIdentifier.NodeIdentifierWithPredicates(QName.create(TEST_QNAME, "list-entry"),
+ QName.create(TEST_QNAME, "key"), 10),
+ new YangInstanceIdentifier.AugmentationIdentifier(ImmutableSet.of(
+ QName.create(TEST_QNAME, "aug1"), QName.create(TEST_QNAME, "aug2"))),
+ new YangInstanceIdentifier.NodeWithValue(QName.create(TEST_QNAME, "leaf-list-entry"), "foo"));
Map<QName, Object> keyValues = new HashMap<>();
keyValues.put(CHILDREN_QNAME, FIRST_CHILD_NAME);
// Create the document
return ImmutableContainerNodeBuilder
.create()
- .withNodeIdentifier(
- new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME))
+ .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME))
.withChild(myBits.build())
.withChild(ImmutableNodes.leafNode(DESC_QNAME, DESC))
- .withChild(ImmutableNodes.leafNode(POINTER_QNAME, ENABLED))
- .withChild(ImmutableNodes.leafNode(POINTER_QNAME, SHORT_ID))
- .withChild(ImmutableNodes.leafNode(POINTER_QNAME, BYTE_ID))
- .withChild(
- ImmutableNodes.leafNode(SOME_REF_QNAME, GRAND_CHILD_1_PATH))
+ .withChild(ImmutableNodes.leafNode(BOOLEAN_LEAF_QNAME, ENABLED))
+ .withChild(ImmutableNodes.leafNode(SHORT_LEAF_QNAME, SHORT_ID))
+ .withChild(ImmutableNodes.leafNode(BYTE_LEAF_QNAME, BYTE_ID))
+ .withChild(ImmutableNodes.leafNode(TestModel.BIGINTEGER_LEAF_QNAME, BigInteger.valueOf(100)))
+ .withChild(ImmutableNodes.leafNode(TestModel.BIGDECIMAL_LEAF_QNAME, BigDecimal.valueOf(1.2)))
+ .withChild(ImmutableNodes.leafNode(SOME_REF_QNAME, instanceID))
.withChild(ImmutableNodes.leafNode(MYIDENTITY_QNAME, DESC_QNAME))
- .withChild(Builders.unkeyedListBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(OUTER_LIST_QNAME))
- .withChild(binaryDataKey).build())
- .withChild(Builders.orderedMapBuilder()
- .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME)).withChild(mapEntry).build())
- .withChild(Builders.choiceBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME))
+ .withChild(Builders.unkeyedListBuilder()
+ .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(UNKEYED_LIST_QNAME))
+ .withChild(unkeyedListEntry).build())
+ .withChild(Builders.choiceBuilder()
+ .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(CHOICE_QNAME))
.withChild(ImmutableNodes.leafNode(DESC_QNAME, LONG_ID)).build())
// .withChild(augmentationNode)
.withChild(shoes)
.withChild(numbers)
.withChild(switchFeatures)
- .withChild(
- mapNodeBuilder(AUGMENTED_LIST_QNAME).withChild(mapEntry).build())
- .withChild(
- mapNodeBuilder(OUTER_LIST_QNAME)
- .withChild(mapEntry(OUTER_LIST_QNAME, ID_QNAME, ONE_ID))
- .withChild(BAR_NODE).build()
+ .withChild(mapNodeBuilder(AUGMENTED_LIST_QNAME).withChild(augMapEntry).build())
+ .withChild(mapNodeBuilder(OUTER_LIST_QNAME)
+ .withChild(mapEntry(OUTER_LIST_QNAME, ID_QNAME, ONE_ID))
+ .withChild(BAR_NODE).build()
);
}
.create()
.withNodeIdentifier(
new YangInstanceIdentifier.NodeIdentifierWithPredicates(
- AUGMENTED_LIST_QNAME, ID_QNAME, id))
+ AUGMENTED_LIST_ENTRY_QNAME, ID_QNAME, id))
.withChild(ImmutableNodes.leafNode(ID_QNAME, id))
.withChild(augmentationNode).build();
}
type uint8;
}
+ leaf-list binary_leaf_list {
+ type binary;
+ }
+
leaf pointer {
type leafref {
path "/network-topology/topology/node/termination-point/tp-id";
</configuration>
<required-capabilities>
<capability>urn:opendaylight:params:xml:ns:yang:controller:config:concurrent-data-broker?module=odl-concurrent-data-broker-cfg&revision=2014-11-24</capability>
- <capability>urn:opendaylight:params:xml:ns:yang:controller:config:distributed-datastore-provider?module=distributed-datastore-privider&revision=2014-06-12</capability>
+ <capability>urn:opendaylight:params:xml:ns:yang:controller:config:distributed-datastore-provider?module=distributed-datastore-provider&revision=2014-06-12</capability>
<capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:config-dom-store?module=opendaylight-config-dom-datastore&revision=2014-06-17</capability>
<capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:operational-dom-store?module=opendaylight-operational-dom-datastore&revision=2014-06-17</capability>
<capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom?module=opendaylight-md-sal-dom&revision=2013-10-28</capability>
"member-3 here would be the name of the member"
);
- currentMemberName = (String) cluster.getSelfRoles().toArray()[0];
+ currentMemberName = cluster.getSelfRoles().iterator().next();
selfAddress = cluster.selfAddress();
-
}
public void subscribeToMemberEvents(ActorRef actorRef){
* 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 akka.actor.ActorSystem;
import org.opendaylight.controller.sal.core.api.model.SchemaService;
import org.osgi.framework.BundleContext;
-import java.util.concurrent.atomic.AtomicReference;
-
public class DistributedDataStoreFactory {
+ private static final String ACTOR_SYSTEM_NAME = "opendaylight-cluster-data";
+ private static final String CONFIGURATION_NAME = "odl-cluster-data";
- public static final String ACTOR_SYSTEM_NAME = "opendaylight-cluster-data";
-
- public static final String CONFIGURATION_NAME = "odl-cluster-data";
-
- private static AtomicReference<ActorSystem> persistentActorSystem = new AtomicReference<>();
+ private static volatile ActorSystem persistentActorSystem = null;
public static DistributedDataStore createInstance(String name, SchemaService schemaService,
DatastoreContext datastoreContext, BundleContext bundleContext) {
return dataStore;
}
- synchronized private static final ActorSystem getOrCreateInstance(final BundleContext bundleContext, ConfigurationReader configurationReader) {
-
- AtomicReference<ActorSystem> actorSystemReference = persistentActorSystem;
- String configurationName = CONFIGURATION_NAME;
- String actorSystemName = ACTOR_SYSTEM_NAME;
-
- if (actorSystemReference.get() != null){
- return actorSystemReference.get();
+ private static final ActorSystem getOrCreateInstance(final BundleContext bundleContext, ConfigurationReader configurationReader) {
+ ActorSystem ret = persistentActorSystem;
+ if (ret == null) {
+ synchronized (DistributedDataStoreFactory.class) {
+ ret = persistentActorSystem;
+ if (ret == null) {
+ // Create an OSGi bundle classloader for actor system
+ BundleDelegatingClassLoader classLoader = new BundleDelegatingClassLoader(bundleContext.getBundle(),
+ Thread.currentThread().getContextClassLoader());
+
+ ret = ActorSystem.create(ACTOR_SYSTEM_NAME,
+ ConfigFactory.load(configurationReader.read()).getConfig(CONFIGURATION_NAME), classLoader);
+ ret.actorOf(Props.create(TerminationMonitor.class), "termination-monitor");
+
+ persistentActorSystem = ret;
+ }
+ }
}
- // Create an OSGi bundle classloader for actor system
- BundleDelegatingClassLoader classLoader = new BundleDelegatingClassLoader(bundleContext.getBundle(),
- Thread.currentThread().getContextClassLoader());
-
- ActorSystem system = ActorSystem.create(actorSystemName,
- ConfigFactory.load(configurationReader.read()).getConfig(configurationName), classLoader);
- system.actorOf(Props.create(TerminationMonitor.class), "termination-monitor");
-
- actorSystemReference.set(system);
- return system;
+ return ret;
}
-
}
private static final Object TX_COMMIT_TIMEOUT_CHECK_MESSAGE = "txCommitTimeoutCheck";
- public static final String DEFAULT_NAME = "default";
+ @VisibleForTesting
+ static final String DEFAULT_NAME = "default";
// The state of this Shard
private final InMemoryDOMDataStore store;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.google.common.base.Supplier;
+import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import org.opendaylight.controller.cluster.DataPersistenceProvider;
import org.opendaylight.controller.cluster.common.actor.AbstractUntypedPersistentActorWithMetering;
import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import scala.concurrent.duration.Duration;
-
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
private final DatastoreContext datastoreContext;
- private final Collection<String> knownModules = new HashSet<>(128);
+ private Collection<String> knownModules = Collections.emptySet();
private final DataPersistenceProvider dataPersistenceProvider;
if(dataPersistenceProvider.isRecoveryApplicable()) {
if (message instanceof SchemaContextModules) {
SchemaContextModules msg = (SchemaContextModules) message;
- knownModules.clear();
- knownModules.addAll(msg.getModules());
+ knownModules = ImmutableSet.copyOf(msg.getModules());
} else if (message instanceof RecoveryFailure) {
RecoveryFailure failure = (RecoveryFailure) message;
LOG.error(failure.cause(), "Recovery failed");
LOG.info("New SchemaContext has a super set of current knownModules - persisting info");
- knownModules.clear();
- knownModules.addAll(newModules);
+ knownModules = ImmutableSet.copyOf(newModules);
dataPersistenceProvider.persist(new SchemaContextModules(newModules), new Procedure<SchemaContextModules>() {
Preconditions.checkArgument(actor != null, "actor must not be null");
Preconditions.checkArgument(message != null, "message must not be null");
- LOG.debug("Sending message {} to {}", message.getClass().toString(), actor.toString());
+ LOG.debug("Sending message {} to {}", message.getClass(), actor);
return ask(actor, message, timeout);
}
Preconditions.checkArgument(actor != null, "actor must not be null");
Preconditions.checkArgument(message != null, "message must not be null");
- LOG.debug("Sending message {} to {}", message.getClass().toString(), actor.toString());
+ LOG.debug("Sending message {} to {}", message.getClass(), actor);
return ask(actor, message, timeout);
}
Preconditions.checkArgument(actor != null, "actor must not be null");
Preconditions.checkArgument(message != null, "message must not be null");
- LOG.debug("Sending message {} to {}", message.getClass().toString(), actor.toString());
+ LOG.debug("Sending message {} to {}", message.getClass(), actor);
actor.tell(message, ActorRef.noSender());
}
return false;
}
- int pathAtIndex = path.indexOf("@");
+ int pathAtIndex = path.indexOf('@');
if (pathAtIndex == -1) {
//if the path is of local format, then its local and is co-located
return true;
} else if (selfAddressHostPort != null) {
// self-address and tx actor path, both are of remote path format
- int slashIndex = path.indexOf("/", pathAtIndex);
+ int slashIndex = path.indexOf('/', pathAtIndex);
if (slashIndex == -1) {
return false;