</execution>
</executions>
</plugin>
+
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.9-RC1</version>
+ <scope>compile</scope>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<groupId>org.eclipse.xtend</groupId>
<artifactId>org.eclipse.xtend.lib</artifactId>
</dependency>
- <dependency>
- <groupId>org.eclipse.xtend</groupId>
- <artifactId>org.eclipse.xtend.standalone</artifactId>
- <version>2.4.3</version>
- <scope>runtime</scope>
- </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-binding-config</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller.model</groupId>
- <artifactId>model-flow-service</artifactId>
- <version>1.0-SNAPSHOT</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller.model</groupId>
- <artifactId>model-flow-management</artifactId>
- <version>1.0-SNAPSHOT</version>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-data-impl</artifactId>
<version>${slf4j.version}</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller.model</groupId>
- <artifactId>model-flow-statistics</artifactId>
- <version>1.0-SNAPSHOT</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.reflections</groupId>
- <artifactId>reflections</artifactId>
- <version>0.9.9-RC1</version>
- <scope>test</scope>
- </dependency>
</dependencies>
</project>
Map<Type, WeakReference<Class>> typeToClass = new ConcurrentHashMap<>();
@SuppressWarnings("rawtypes")
- private ConcurrentMap<Type, ChoiceCaseCodecImpl> typeToCaseNodes = new ConcurrentHashMap<>();
+ private ConcurrentMap<Type, ChoiceCaseCodecImpl> typeToCaseCodecs = new ConcurrentHashMap<>();
private CaseClassMapFacade classToCaseRawCodec = new CaseClassMapFacade();
}
return weakRef.get();
}
-
+
@Override
- public void putPathToClass(List<QName> names,Class<?> cls) {
+ public void putPathToClass(List<QName> names, Class<?> cls) {
Type reference = Types.typeForClass(cls);
- pathToInstantiatedType.put(names, reference );
+ pathToInstantiatedType.put(names, reference);
bindingClassEncountered(cls);
}
-
@Override
public IdentifierCodec<?> getKeyCodecForPath(List<QName> names) {
@SuppressWarnings("unchecked")
return potential;
}
ConcreteType typeref = Types.typeForClass(caseClass);
- ChoiceCaseCodecImpl caseCodec = typeToCaseNodes.get(typeref);
+ ChoiceCaseCodecImpl caseCodec = typeToCaseCodecs.get(typeref);
+ checkState(caseCodec != null, "Case Codec was not created proactivelly for %s", caseClass.getName());
+ checkState(caseCodec.getSchema() != null, "Case schema is not available for %s", caseClass.getName());
@SuppressWarnings("unchecked")
- Class<? extends BindingCodec> newCodec = generator.caseCodecFor(caseClass, caseCodec.schema);
+ Class<? extends BindingCodec> newCodec = generator.caseCodecFor(caseClass, caseCodec.getSchema());
BindingCodec newInstance = newInstanceOf(newCodec);
caseCodec.setDelegate(newInstance);
caseCodecs.put(caseClass, caseCodec);
for (Entry<SchemaPath, GeneratedTypeBuilder> caseNode : cases.entrySet()) {
ReferencedTypeImpl typeref = new ReferencedTypeImpl(caseNode.getValue().getPackageName(), caseNode
.getValue().getName());
+
+ LOG.info("Case path: {} Type : {}", caseNode.getKey(), caseNode.getValue().getFullyQualifiedName());
+ pathToType.put(caseNode.getKey(), caseNode.getValue());
+
ChoiceCaseNode node = (ChoiceCaseNode) SchemaContextUtil.findDataSchemaNode(module, caseNode.getKey());
+
if (node == null) {
LOG.error("YANGTools Bug: SchemaNode for {}, with path {} was not found in context.",
typeref.getFullyQualifiedName(), caseNode.getKey());
+ @SuppressWarnings("rawtypes")
+ ChoiceCaseCodecImpl value = new ChoiceCaseCodecImpl();
+ typeToCaseCodecs.putIfAbsent(typeref, value);
continue;
}
-
- pathToType.put(caseNode.getKey(), caseNode.getValue());
@SuppressWarnings("rawtypes")
ChoiceCaseCodecImpl value = new ChoiceCaseCodecImpl(node);
- typeToCaseNodes.putIfAbsent(typeref, value);
+ typeToCaseCodecs.putIfAbsent(typeref, value);
}
}
choiceCodecs.put(choiceClass, newCodec);
CodecMapping.setClassToCaseMap(choiceCodec, (Map<Class<?>, BindingCodec<?, ?>>) classToCaseRawCodec);
CodecMapping.setCompositeNodeToCaseMap(choiceCodec, newCodec.getCompositeToCase());
-
+
tryToCreateCasesCodecs(schema);
}
private void tryToCreateCasesCodecs(ChoiceNode schema) {
- for(ChoiceCaseNode caseNode : schema.getCases()) {
+ for (ChoiceCaseNode caseNode : schema.getCases()) {
SchemaPath path = caseNode.getPath();
GeneratedTypeBuilder type;
- if(path != null && (type = pathToType.get(path)) != null) {
+ if (path != null && (type = pathToType.get(path)) != null) {
+ ReferencedTypeImpl typeref = new ReferencedTypeImpl(type.getPackageName(), type.getName());
+ ChoiceCaseCodecImpl partialCodec = typeToCaseCodecs.get(typeref);
+ if(partialCodec.getSchema() == null ) {
+ partialCodec.setSchema(caseNode);
+ }
+
Class<?> caseClass = ClassLoaderUtils.tryToLoadClassWithTCCL(type.getFullyQualifiedName());
- if(caseClass != null) {
+ if (caseClass != null) {
getCaseCodecFor(caseClass);
}
}
}
@Override
- public void onDataContainerCodecCreated(Class<?> dataClass,
- Class<? extends BindingCodec<?,?>> dataCodec) {
+ public void onDataContainerCodecCreated(Class<?> dataClass, Class<? extends BindingCodec<?, ?>> dataCodec) {
if (Augmentable.class.isAssignableFrom(dataClass)) {
AugmentableCompositeCodec augmentableCodec = getAugmentableCodec(dataClass);
CodecMapping.setAugmentationCodec(dataCodec, augmentableCodec);
@SuppressWarnings("rawtypes")
private static class ChoiceCaseCodecImpl<T extends DataContainer> implements ChoiceCaseCodec<T>, //
Delegator<BindingCodec> {
- private final boolean augmenting;
+ private boolean augmenting;
private BindingCodec delegate;
- private final Set<String> validNames;
- private final Set<QName> validQNames;
+ private Set<String> validNames;
+ private Set<QName> validQNames;
private ChoiceCaseNode schema;
- public ChoiceCaseCodecImpl(ChoiceCaseNode caseNode) {
- this.delegate = NOT_READY_CODEC;
+ public void setSchema(ChoiceCaseNode caseNode) {
+ this.schema = schema;
this.schema = caseNode;
validNames = new HashSet<>();
validQNames = new HashSet<>();
augmenting = caseNode.isAugmenting();
}
+ public ChoiceCaseCodecImpl() {
+ this.delegate = NOT_READY_CODEC;
+ }
+
+ public ChoiceCaseCodecImpl(ChoiceCaseNode caseNode) {
+ this.delegate = NOT_READY_CODEC;
+ setSchema(caseNode);
+ }
+
@Override
public ValueWithQName<T> deserialize(Node<?> input) {
throw new UnsupportedOperationException("Direct invocation of this codec is not allowed.");
for (entry : newBinding.moduleContexts.entrySet) {
registry.onModuleContextAdded(schemaContext, entry.key, entry.value);
-
+ binding.pathToType.putAll(entry.value.childNodes)
//val module = entry.key;
val context = entry.value;
updateBindingFor(context.childNodes, schemaContext);
}
private def void updateBindingFor(Map<SchemaPath, GeneratedTypeBuilder> map, SchemaContext module) {
+
for (entry : map.entrySet) {
val schemaNode = SchemaContextUtil.findDataSchemaNode(module, entry.key);
//LOG.info("{} : {}",entry.key,entry.value.fullyQualifiedName)
+ val typeRef = new ReferencedTypeImpl(entry.value.packageName,entry.value.name)
+ typeToDefinition.put(typeRef, entry.value);
if (schemaNode != null) {
- val typeRef = new ReferencedTypeImpl(entry.value.packageName,entry.value.name)
typeToSchemaNode.put(typeRef, schemaNode);
- typeToDefinition.put(typeRef, entry.value);
updatePromisedSchemas(typeRef, schemaNode);
}
+
}
}
import org.opendaylight.yangtools.binding.generator.util.ReferencedTypeImpl
import org.opendaylight.yangtools.yang.model.util.ExtendedType
import org.opendaylight.yangtools.yang.model.util.EnumerationType
+import static com.google.common.base.Preconditions.*
+import org.opendaylight.yangtools.yang.model.api.SchemaPath
class TransformerGenerator {
@Property
var Map<Type, GeneratedTypeBuilder> typeToDefinition = new ConcurrentHashMap();
+ @Property
+ var Map<SchemaPath, GeneratedTypeBuilder> pathToType = new ConcurrentHashMap();
+
@Property
var Map<Type, SchemaNode> typeToSchemaNode = new ConcurrentHashMap();
val ref = Types.typeForClass(inputType)
val node = typeToSchemaNode.get(ref)
val typeSpecBuilder = typeToDefinition.get(ref)
+ checkState(typeSpecBuilder !== null, "Could not find typedefinition for %s", inputType.name);
+ val typeSpec = typeSpecBuilder.toInstance();
+ val newret = generateTransformerFor(inputType, typeSpec, node);
+ listener.onClassProcessed(inputType);
+ return newret as Class<? extends BindingCodec<Map<QName,Object>, Object>>;
+ ]
+ }
+
+ def Class<? extends BindingCodec<Map<QName, Object>, Object>> transformerFor(Class<?> inputType, DataSchemaNode node) {
+ return withClassLoaderAndLock(inputType.classLoader, lock) [ |
+ val ret = getGeneratedClass(inputType)
+ if (ret !== null) {
+ listener.onClassProcessed(inputType);
+ return ret as Class<? extends BindingCodec<Map<QName,Object>, Object>>;
+ }
+ val ref = Types.typeForClass(inputType)
+ var typeSpecBuilder = typeToDefinition.get(ref)
+ if (typeSpecBuilder == null) {
+ typeSpecBuilder = pathToType.get(node.path);
+ }
+ checkState(typeSpecBuilder !== null, "Could not find TypeDefinition for %s, $s", inputType.name, node);
val typeSpec = typeSpecBuilder.toInstance();
val newret = generateTransformerFor(inputType, typeSpec, node);
listener.onClassProcessed(inputType);
keyTransformerFor(cls, type, node);
}
- private def serializer(Type type) {
+ private def serializer(Type type, DataSchemaNode node) {
val cls = loadClassWithTCCL(type.resolvedName);
-
- transformerFor(cls);
-
+ transformerFor(cls, node);
}
private def Class<?> getValueSerializer(GeneratedTransferObject type) {
]
val ret = ctCls.toClassImpl(inputType.classLoader, inputType.protectionDomain) as Class<? extends BindingCodec<Object, Object>>
- listener?.onDataContainerCodecCreated(inputType,ret);
+ listener?.onDataContainerCodecCreated(inputType, ret);
log.info("DOM Codec for {} was generated {}", inputType, ret)
return ret;
} catch (Exception e) {
Object _listItem = _iterator.next();
_is_empty = false;
//System.out.println(" item" + _listItem);
- Object _value = «type.actualTypeArguments.get(0).serializer.resolvedName».fromDomStatic(_localQName,_listItem);
+ Object _value = «type.actualTypeArguments.get(0).serializer(schema).resolvedName».fromDomStatic(_localQName,_listItem);
//System.out.println(" value" + _value);
«propertyName».add(_value);
_hasNext = _iterator.hasNext();
if(_dom_«propertyName»_list != null && _dom_«propertyName»_list.size() > 0) {
_is_empty = false;
java.util.Map _dom_«propertyName» = (java.util.Map) _dom_«propertyName»_list.get(0);
- «propertyName» = «type.serializer.resolvedName».fromDomStatic(_localQName,_dom_«propertyName»);
+ «propertyName» = «type.serializer(schema).resolvedName».fromDomStatic(_localQName,_dom_«propertyName»);
}
'''
private def dispatch CharSequence deserializeProperty(ChoiceNode schema, Type type, String propertyName) '''
- «type.resolvedName» «propertyName» = «type.serializer.resolvedName».fromDomStatic(_localQName,_compositeNode);
+ «type.resolvedName» «propertyName» = «type.serializer(schema).resolvedName».fromDomStatic(_localQName,_compositeNode);
if(«propertyName» != null) {
_is_empty = false;
}
boolean _hasNext = _iterator.hasNext();
while(_hasNext) {
Object _listItem = _iterator.next();
- Object _domValue = «type.actualTypeArguments.get(0).serializer.resolvedName».toDomStatic(_resultName,_listItem);
+ Object _domValue = «type.actualTypeArguments.get(0).serializer(schema).resolvedName».toDomStatic(_resultName,_listItem);
_childNodes.add(_domValue);
_hasNext = _iterator.hasNext();
}
String propertyName) '''
«type.resolvedName» «propertyName» = value.«propertyName»();
if(«propertyName» != null) {
- java.util.List domValue = «type.serializer.resolvedName».toDomStatic(_resultName,«propertyName»);
+ java.util.List domValue = «type.serializer(container).resolvedName».toDomStatic(_resultName,«propertyName»);
_childNodes.addAll(domValue);
}
'''
String propertyName) '''
«type.resolvedName» «propertyName» = value.«propertyName»();
if(«propertyName» != null) {
- Object domValue = «type.serializer.resolvedName».toDomStatic(_resultName,«propertyName»);
+ Object domValue = «type.serializer(container).resolvedName».toDomStatic(_resultName,«propertyName»);
_childNodes.add(domValue);
}
'''
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
+import com.google.common.base.Joiner;
import com.google.common.base.Optional;
public final class ClassLoaderUtils {
if ("byte[]".equals(name)) {
return byte[].class;
}
-
- return Thread.currentThread().getContextClassLoader().loadClass(name);
+ try {
+ return Thread.currentThread().getContextClassLoader().loadClass(name);
+ } catch (ClassNotFoundException e) {
+ String[] components = name.split("\\.");
+ String potentialOuter;
+ int length = components.length;
+ if (length > 2 && (potentialOuter = components[length - 2]) != null && Character.isUpperCase(potentialOuter.charAt(0))) {
+
+ String outerName = Joiner.on(".").join(Arrays.asList(components).subList(0, length - 1));
+ String innerName = outerName + "$" + components[length-1];
+ return Thread.currentThread().getContextClassLoader().loadClass(innerName);
+ } else {
+ throw e;
+ }
+ }
}
public static Class<?> tryToLoadClassWithTCCL(String fullyQualifiedName) {
try {
return loadClassWithTCCL(fullyQualifiedName);
} catch (ClassNotFoundException e) {
-
+
}
return null;
}
import org.opendaylight.controller.sal.binding.impl.DataBrokerImpl;
import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingIndependentDataServiceConnector;
import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingIndependentMappingService;
+import org.opendaylight.controller.sal.binding.test.util.BindingBrokerTestFactory;
+import org.opendaylight.controller.sal.binding.test.util.BindingTestContext;
import org.opendaylight.controller.sal.binding.dom.serializer.impl.RuntimeGeneratedMappingServiceImpl;
import org.opendaylight.controller.sal.core.api.data.DataBrokerService;
import org.opendaylight.controller.sal.core.api.data.DataStore;
protected org.opendaylight.controller.sal.core.api.data.DataProviderService biDataService;
protected DataProviderService baDataService;
-
- /**
- * Workaround for JUNIT sharing classloaders
- *
- */
- protected static final ClassPool POOL = new ClassPool();
-
- protected RuntimeGeneratedMappingServiceImpl mappingServiceImpl;
protected BindingIndependentMappingService mappingService;
- protected DataBrokerImpl baDataImpl;
- protected org.opendaylight.controller.sal.dom.broker.DataBrokerImpl biDataImpl;
- protected ListeningExecutorService executor;
- protected BindingIndependentDataServiceConnector connectorServiceImpl;
- protected HashMapDataStore rawDataStore;
- protected SchemaAwareDataStoreAdapter schemaAwareDataStore;
private DataStoreStatsWrapper dataStoreStats;
-
protected DataStore dataStore;
+ protected BindingTestContext testContext;
@Before
public void setUp() {
- executor = MoreExecutors.sameThreadExecutor();
- baDataImpl = new DataBrokerImpl();
- baDataService = baDataImpl;
- baDataImpl.setExecutor(executor);
-
- biDataImpl = new org.opendaylight.controller.sal.dom.broker.DataBrokerImpl();
- biDataService = biDataImpl;
- biDataImpl.setExecutor(executor);
-
- rawDataStore = new HashMapDataStore();
- schemaAwareDataStore = new SchemaAwareDataStoreAdapter();
- schemaAwareDataStore.changeDelegate(rawDataStore);
- dataStoreStats = new DataStoreStatsWrapper(schemaAwareDataStore);
- dataStore = dataStoreStats;
-
- org.opendaylight.yangtools.yang.data.api.InstanceIdentifier treeRoot = org.opendaylight.yangtools.yang.data.api.InstanceIdentifier
- .builder().toInstance();
- biDataImpl.registerConfigurationReader(treeRoot, dataStore);
- biDataImpl.registerOperationalReader(treeRoot, dataStore);
- biDataImpl.registerCommitHandler(treeRoot, dataStore);
-
- mappingServiceImpl = new RuntimeGeneratedMappingServiceImpl();
- mappingServiceImpl.setPool(POOL);
- mappingService = mappingServiceImpl;
- File pathname = new File("target/gen-classes-debug");
- // System.out.println("Generated classes are captured in " +
- // pathname.getAbsolutePath());
- mappingServiceImpl.start(null);
- // mappingServiceImpl.getBinding().setClassFileCapturePath(pathname);
-
- connectorServiceImpl = new BindingIndependentDataServiceConnector();
- connectorServiceImpl.setBaDataService(baDataService);
- connectorServiceImpl.setBiDataService(biDataService);
- connectorServiceImpl.setMappingService(mappingServiceImpl);
- connectorServiceImpl.start();
-
- String[] yangFiles = getModelFilenames();
- if (yangFiles != null && yangFiles.length > 0) {
- SchemaContext context = getContext(yangFiles);
- mappingServiceImpl.onGlobalContextUpdated(context);
- schemaAwareDataStore.onGlobalContextUpdated(context);
- }
+ ListeningExecutorService executor = MoreExecutors.sameThreadExecutor();
+ BindingBrokerTestFactory factory = new BindingBrokerTestFactory();
+ factory.setExecutor(executor);
+ factory.setStartWithParsedSchema(getStartWithSchema());
+ testContext = factory.getTestContext();
+ testContext.start();
+
+ baDataService = testContext.getBindingDataBroker();
+ biDataService = testContext.getDomDataBroker();
+ dataStore = testContext.getDomDataStore();
+ mappingService = testContext.getBindingToDomMappingService();
}
- protected String[] getModelFilenames() {
- return getAllModelFilenames();
- }
-
- public static String[] getAllModelFilenames() {
- Predicate<String> predicate = new Predicate<String>() {
- @Override
- public boolean apply(String input) {
- return input.endsWith(".yang");
- }
- };
- Reflections reflection = new Reflections("META-INF.yang", new ResourcesScanner());
- Set<String> result = reflection.getResources(predicate);
- return (String[]) result.toArray(new String[result.size()]);
- }
-
- public static SchemaContext getContext(String[] yangFiles) {
-
- ClassLoader loader = AbstractDataServiceTest.class.getClassLoader();
-
- List<InputStream> streams = new ArrayList<>();
- for (String string : yangFiles) {
- InputStream stream = loader.getResourceAsStream(string);
- streams.add(stream);
-
- }
- YangParserImpl parser = new YangParserImpl();
-
- Set<Module> modules = parser.parseYangModelsFromStreams(streams);
- return parser.resolveSchemaContext(modules);
+ protected boolean getStartWithSchema() {
+ return true;
}
@After
public void afterTest() {
- log.info("BIDataStore Statistics: Configuration Read Count: {} TotalTime: {} ms AverageTime (ns): {} ms",
- dataStoreStats.getConfigurationReadCount(), dataStoreStats.getConfigurationReadTotalTime(),
- dataStoreStats.getConfigurationReadAverageTime());
-
- log.info("BIDataStore Statistics: Operational Read Count: {} TotalTime: {} ms AverageTime (ns): {} ms",
- dataStoreStats.getOperationalReadCount(), dataStoreStats.getOperationalReadTotalTime(),
- dataStoreStats.getOperationalReadAverageTime());
-
- log.info("BIDataStore Statistics: Request Commit Count: {} TotalTime: {} ms AverageTime (ns): {} ms",
- dataStoreStats.getRequestCommitCount(), dataStoreStats.getRequestCommitTotalTime(),
- dataStoreStats.getRequestCommitAverageTime());
+ testContext.logDataStoreStatistics();
}
}
+++ /dev/null
-package org.opendaylight.controller.sal.binding.test.bugfix;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-
-
-
-import org.junit.Test;
-import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
-import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest;
-import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.Flows;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.Flow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
-
-import static org.junit.Assert.*;
-
-public class DOMCodecBug01Test extends AbstractDataServiceTest {
-
- private static final QName NODE_ID_QNAME = QName.create(Node.QNAME, "id");
- private static final QName FLOW_ID_QNAME = QName.create(Flow.QNAME, "id");
- private static final QName FLOW_NODE_QNAME = QName.create(Flow.QNAME, "node");
- private static final long FLOW_ID = 1234;
- private static final String NODE_ID = "node:1";
-
- private static final NodeKey NODE_KEY = new NodeKey(new NodeId(NODE_ID));
-
- private static final Map<QName, Object> NODE_KEY_BI = Collections.<QName, Object> singletonMap(NODE_ID_QNAME,
- NODE_ID);
-
- private static final InstanceIdentifier<Node> NODE_INSTANCE_ID_BA = InstanceIdentifier.builder(Nodes.class) //
- .child(Node.class, NODE_KEY).toInstance();
-
- private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier NODE_INSTANCE_ID_BI = //
- org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.builder() //
- .node(Nodes.QNAME) //
- .nodeWithKey(Node.QNAME, NODE_KEY_BI) //
- .toInstance();
- private static final NodeRef NODE_REF = new NodeRef(NODE_INSTANCE_ID_BA);
-
- private static final FlowKey FLOW_KEY = new FlowKey(FLOW_ID, NODE_REF);
-
- private static final Map<QName, Object> FLOW_KEY_BI = //
- ImmutableMap.<QName, Object> of(FLOW_ID_QNAME, FLOW_ID, FLOW_NODE_QNAME, NODE_INSTANCE_ID_BI);
-
- private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier FLOW_INSTANCE_ID_BI = //
- org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.builder() //
- .node(Flows.QNAME) //
- .nodeWithKey(Flow.QNAME, FLOW_KEY_BI) //
- .toInstance();
- private static final InstanceIdentifier<? extends DataObject> FLOW_INSTANCE_ID_BA = //
- InstanceIdentifier.builder(Flows.class) //
- .child(Flow.class, FLOW_KEY) //
- .toInstance();
-
-
-
- /**
- *
- * Testcase for https://bugs.opendaylight.org/show_bug.cgi?id=
- *
- * Cannot compile CoDec for
- * org.opendaylight.yang.gen.v1.urn.opendaylight.flow
- * .config.rev130819.flows.Flow
- *
- * When invoking following code in the consumer, user got an
- * IllegalStateException during creation of mapping between Java DTOs and
- * data-dom.
- *
- * Exception was compilation error which was caused by incorect generation
- * of code.
- *
- * Reported by Depthi V V
- *
- */
- @Test
- public void testIndirectGeneration() throws Exception {
-
- ExecutorService basePool = Executors.newFixedThreadPool(2);
- ListeningExecutorService listenablePool = MoreExecutors.listeningDecorator(basePool);
-
- createFlow();
-
- Object lock = new Object();
- CreateFlowTask task1 = new CreateFlowTask(lock);
- CreateFlowTask task2 = new CreateFlowTask(lock);
- CreateFlowTask task3 = new CreateFlowTask(lock);
-
- ListenableFuture<Void> task1Future = listenablePool.submit(task1);
- ListenableFuture<Void> task2Future = listenablePool.submit(task2);
- ListenableFuture<Void> task3Future = listenablePool.submit(task3);
-
-
- @SuppressWarnings("unchecked")
- ListenableFuture<List<Void>> compositeFuture = Futures.allAsList(task1Future,task2Future,task3Future);
-
- Thread.sleep(500);
- //lock.notifyAll();
- compositeFuture.get();
-
- verifyDataAreStoredProperly();
-
- DataModificationTransaction modification2 = baDataService.beginTransaction();
- modification2.removeConfigurationData(FLOW_INSTANCE_ID_BA);
-
- DataObject originalData = modification2.getOriginalConfigurationData().get(FLOW_INSTANCE_ID_BA);
- assertNotNull(originalData);
- RpcResult<TransactionStatus> ret2 = modification2.commit().get();
-
- assertNotNull(ret2);
- assertEquals(TransactionStatus.COMMITED, ret2.getResult());
-
- // Data are not in the store.
- assertNull(baDataService.readConfigurationData(FLOW_INSTANCE_ID_BA));
-
- }
-
- private void createFlow() throws Exception {
-
- DataModificationTransaction modification = baDataService.beginTransaction();
-
- FlowBuilder flow = new FlowBuilder();
- MatchBuilder match = new MatchBuilder();
- VlanMatchBuilder vlanBuilder = new VlanMatchBuilder();
- VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
- VlanId vlanId = new VlanId(10);
- vlanBuilder.setVlanId(vlanIdBuilder.setVlanId(vlanId).build());
- match.setVlanMatch(vlanBuilder.build());
-
- flow.setKey(FLOW_KEY);
- flow.setMatch(match.build());
- flow.setNode(NODE_REF);
- InstructionsBuilder instructions = new InstructionsBuilder();
- InstructionBuilder instruction = new InstructionBuilder();
-
- instruction.setOrder(10);
- ApplyActionsBuilder applyActions = new ApplyActionsBuilder();
- List<Action> actionList = new ArrayList<>();
- PopMplsActionBuilder popMplsAction = new PopMplsActionBuilder();
- popMplsAction.setEthernetType(34);
- actionList.add(new ActionBuilder().setAction(popMplsAction.build()).setOrder(10).build());
-
- applyActions.setAction(actionList );
-
-
-
- instruction.setInstruction(applyActions.build());
-
-
- List<Instruction> instructionList = Collections.<Instruction>singletonList(instruction.build());
- instructions.setInstruction(instructionList );
-
- flow.setInstructions(instructions.build());
- modification.putConfigurationData(FLOW_INSTANCE_ID_BA, flow.build());
- RpcResult<TransactionStatus> ret = modification.commit().get();
- assertNotNull(ret);
- assertEquals(TransactionStatus.COMMITED, ret.getResult());
- }
-
- private void createFlow2() throws Exception {
- DataModificationTransaction modification = baDataService.beginTransaction();
- long id = 123;
- FlowKey key = new FlowKey(id, new NodeRef(NODE_INSTANCE_ID_BA));
- InstanceIdentifier<?> path1;
- FlowBuilder flow = new FlowBuilder();
- flow.setKey(key);
- MatchBuilder match = new MatchBuilder();
- match.setLayer4Match(new TcpMatchBuilder().build());
- flow.setMatch(match.build());
-
- System.out.println("Putting the configuration Data................");
- path1 = InstanceIdentifier.builder(Flows.class).child(Flow.class, key).toInstance();
- // DataObject cls = (DataObject) modification.readConfigurationData(path1);
- modification.putConfigurationData(path1, flow.build());
- modification.commit();
-
- }
-
- private class CreateFlowTask implements Callable<Void> {
-
- public CreateFlowTask(Object startSync) {
- }
-
- @Override
- public Void call() {
- try {
- //startSyncObject.wait();
- //Thread.sleep(500);
- createFlow();
- createFlow2();
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- return null;
- }
- }
-
- private void verifyDataAreStoredProperly() {
- CompositeNode biFlows = biDataService.readConfigurationData(org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.of(Flows.QNAME));
- assertNotNull(biFlows);
- CompositeNode biFlow = biFlows.getFirstCompositeByName(Flow.QNAME);
- assertNotNull(biFlow);
- }
-
-
-}
+++ /dev/null
-package org.opendaylight.controller.sal.binding.test.bugfix;
-
-import java.util.Collections;
-import java.util.Map;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-
-import org.junit.Test;
-import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
-import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest;
-import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.Flow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-
-import static org.junit.Assert.*;
-
-public class DOMCodecBug02Test extends AbstractDataServiceTest {
-
- private static final QName NODE_ID_QNAME = QName.create(Node.QNAME, "id");
- private static final String NODE_ID = "node:1";
-
- private static final NodeKey NODE_KEY = new NodeKey(new NodeId(NODE_ID));
-
- private static final Map<QName, Object> NODE_KEY_BI = Collections.<QName, Object> singletonMap(NODE_ID_QNAME,
- NODE_ID);
-
- private static final InstanceIdentifier<Nodes> NODES_INSTANCE_ID_BA = InstanceIdentifier.builder(Nodes.class) //
- .toInstance();
-
- private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier NODES_INSTANCE_ID_BI = //
- org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.builder() //
- .node(Nodes.QNAME) //
- .toInstance();
-
- private static final InstanceIdentifier<Node> NODE_INSTANCE_ID_BA = InstanceIdentifier.builder(Nodes.class) //
- .child(Node.class, NODE_KEY).toInstance();
-
- private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier NODE_INSTANCE_ID_BI = //
- org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.builder() //
- .node(Nodes.QNAME) //
- .nodeWithKey(Node.QNAME, NODE_KEY_BI) //
- .toInstance();
- private static final NodeRef NODE_REF = new NodeRef(NODE_INSTANCE_ID_BA);
-
- @Override
- protected String[] getModelFilenames() {
- return null;
- }
-
- /**
- *
- *
- * @throws Exception
- */
- @Test
- public void testSchemaContextNotAvailable() throws Exception {
-
- ExecutorService testExecutor = Executors.newFixedThreadPool(1);
-
- Future<Future<RpcResult<TransactionStatus>>> future = testExecutor.submit(new Callable<Future<RpcResult<TransactionStatus>>>() {
- @Override
- public Future<RpcResult<TransactionStatus>> call() throws Exception {
- NodesBuilder nodesBuilder = new NodesBuilder();
- nodesBuilder.setNode(Collections.<Node> emptyList());
- DataModificationTransaction transaction = baDataService.beginTransaction();
- transaction.putOperationalData(NODES_INSTANCE_ID_BA, nodesBuilder.build());
- return transaction.commit();
- }
- });
-
- SchemaContext ctx = getContext(getAllModelFilenames());
- schemaAwareDataStore.onGlobalContextUpdated(ctx);
- mappingServiceImpl.onGlobalContextUpdated(ctx);
- RpcResult<TransactionStatus> result = future.get().get();
- assertEquals(TransactionStatus.COMMITED, result.getResult());
-
-
- Nodes nodes = checkForNodes();
- assertNotNull(nodes);
-
- }
-
- private Nodes checkForNodes() {
- return (Nodes) baDataService.readOperationalData(NODES_INSTANCE_ID_BA);
-
- }
-
-}
+++ /dev/null
-package org.opendaylight.controller.sal.binding.test.bugfix;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import org.junit.Test;
-import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
-import org.opendaylight.controller.md.sal.common.api.data.DataChangeEvent;
-import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest;
-import org.opendaylight.controller.sal.binding.api.data.DataChangeListener;
-import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.flow.node.SupportedActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.flow.node.SupportedActionsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.flow.node.supported.actions.ActionType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.flow.node.supported.actions.ActionTypeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.SupportType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesKey;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-
-import static org.junit.Assert.*;
-
-public class DOMCodecBug03Test extends AbstractDataServiceTest implements DataChangeListener {
-
- private static final QName NODE_ID_QNAME = QName.create(Node.QNAME, "id");
- private static final String NODE_ID = "openflow:1";
-
- private static final NodeKey NODE_KEY = new NodeKey(new NodeId(NODE_ID));
-
- private static final Map<QName, Object> NODE_KEY_BI = Collections.<QName, Object> singletonMap(NODE_ID_QNAME,
- NODE_ID);
-
- private static final InstanceIdentifier<Nodes> NODES_INSTANCE_ID_BA = InstanceIdentifier.builder(Nodes.class) //
- .toInstance();
-
-
- private static final InstanceIdentifier<Node> NODE_INSTANCE_ID_BA = InstanceIdentifier//
- .builder(NODES_INSTANCE_ID_BA) //
- .child(Node.class, NODE_KEY).toInstance();
-
-
- private static final InstanceIdentifier<SupportedActions> SUPPORTED_ACTIONS_INSTANCE_ID_BA = InstanceIdentifier//
- .builder(NODES_INSTANCE_ID_BA) //
- .child(Node.class, NODE_KEY) //
- .augmentation(FlowCapableNode.class) //
- .child(SupportedActions.class)
- .toInstance();
-
-
- private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier NODE_INSTANCE_ID_BI = //
- org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.builder() //
- .node(Nodes.QNAME) //
- .nodeWithKey(Node.QNAME, NODE_KEY_BI) //
- .toInstance();
- private static final QName SUPPORTED_ACTIONS_QNAME = QName.create(FlowCapableNode.QNAME, SupportedActions.QNAME.getLocalName());
-
-
- private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier SUPPORTED_ACTIONS_INSTANCE_ID_BI = //
- org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.builder() //
- .node(Nodes.QNAME) //
- .nodeWithKey(Node.QNAME, NODE_KEY_BI) //
- .node(SUPPORTED_ACTIONS_QNAME) //
- .toInstance();
-
- private DataChangeEvent<InstanceIdentifier<?>, DataObject> receivedChangeEvent;
-
-
-
- /**
- * Test for Bug 148
- *
- * @throws Exception
- */
- @Test
- public void testAugmentSerialization() throws Exception {
-
-
- baDataService.registerDataChangeListener(NODES_INSTANCE_ID_BA, this);
-
- NodeBuilder nodeBuilder = new NodeBuilder();
- nodeBuilder.setId(new NodeId(NODE_ID));
- nodeBuilder.setKey(NODE_KEY);
- DataModificationTransaction transaction = baDataService.beginTransaction();
-
-
- FlowCapableNodeBuilder fnub = new FlowCapableNodeBuilder();
- fnub.setHardware("Hardware Foo");
- fnub.setManufacturer("Manufacturer Foo");
- fnub.setSerialNumber("Serial Foo");
- fnub.setDescription("Description Foo");
- fnub.setSoftware("JUnit emulated");
- FlowCapableNode fnu = fnub.build();
- nodeBuilder.addAugmentation(FlowCapableNode.class, fnu);
- Node original = nodeBuilder.build();
- transaction.putOperationalData(NODE_INSTANCE_ID_BA, original);
-
- RpcResult<TransactionStatus> result = transaction.commit().get();
- assertEquals(TransactionStatus.COMMITED, result.getResult());
-
- assertNotNull(receivedChangeEvent);
-
- verifyNodes((Nodes) receivedChangeEvent.getUpdatedOperationalSubtree(),original);
- assertBindingIndependentVersion(NODE_INSTANCE_ID_BI);
- Nodes nodes = checkForNodes();
- verifyNodes(nodes,original);
-
- testAddingNodeConnector();
- testNodeRemove();
-
- }
-
- @Test
- public void testAugmentNestedSerialization() throws Exception {
- DataModificationTransaction transaction = baDataService.beginTransaction();
-
- SupportedActionsBuilder actions = new SupportedActionsBuilder();
- ActionTypeBuilder action = new ActionTypeBuilder();
- action.setAction("foo-action");
- action.setSupportState(SupportType.Native);
- List<ActionType> actionTypes = Collections.singletonList(action.build());
- actions.setActionType(actionTypes );
-
- transaction.putOperationalData(SUPPORTED_ACTIONS_INSTANCE_ID_BA, actions.build());
- RpcResult<TransactionStatus> putResult = transaction.commit().get();
- assertNotNull(putResult);
- assertEquals(TransactionStatus.COMMITED, putResult.getResult());
- SupportedActions readedTable = (SupportedActions) baDataService.readOperationalData(SUPPORTED_ACTIONS_INSTANCE_ID_BA);
- assertNotNull(readedTable);
-
- CompositeNode biSupportedActions = biDataService.readOperationalData(SUPPORTED_ACTIONS_INSTANCE_ID_BI);
- assertNotNull(biSupportedActions);
-
- }
-
- private void testAddingNodeConnector() throws Exception {
-
- NodeConnectorId ncId = new NodeConnectorId("openflow:1:bar");
- NodeConnectorKey nodeKey = new NodeConnectorKey(ncId );
- InstanceIdentifier<NodeConnector> ncInstanceId = InstanceIdentifier.builder(NODE_INSTANCE_ID_BA).child(NodeConnector.class, nodeKey).toInstance();
- NodeConnectorBuilder ncBuilder = new NodeConnectorBuilder();
- ncBuilder.setId(ncId);
- ncBuilder.setKey(nodeKey);
- NodeConnector connector = ncBuilder.build();
- DataModificationTransaction transaction = baDataService.beginTransaction();
- transaction.putOperationalData(ncInstanceId, connector);
- RpcResult<TransactionStatus> result = transaction.commit().get();
- assertEquals(TransactionStatus.COMMITED, result.getResult());
- Node node = (Node) baDataService.readOperationalData(NODE_INSTANCE_ID_BA);
- assertNotNull(node);
- assertNotNull(node.getNodeConnector());
- assertFalse(node.getNodeConnector().isEmpty());
- NodeConnector readedNc = node.getNodeConnector().get(0);
- assertNotNull(readedNc);
- }
-
- private void testNodeRemove() throws Exception {
- DataModificationTransaction transaction = baDataService.beginTransaction();
- transaction.removeOperationalData(NODE_INSTANCE_ID_BA);
- RpcResult<TransactionStatus> result = transaction.commit().get();
- assertEquals(TransactionStatus.COMMITED, result.getResult());
-
- Node node = (Node) baDataService.readOperationalData(NODE_INSTANCE_ID_BA);
- assertNull(node);
- }
-
- private void verifyNodes(Nodes nodes,Node original) {
- assertNotNull(nodes);
- assertNotNull(nodes.getNode());
- assertEquals(1, nodes.getNode().size());
- Node readedNode = nodes.getNode().get(0);
- assertEquals(original.getId(), readedNode.getId());
- assertEquals(original.getKey(), readedNode.getKey());
-
- FlowCapableNode fnu = original.getAugmentation(FlowCapableNode.class);
- FlowCapableNode readedAugment = readedNode.getAugmentation(FlowCapableNode.class);
- assertNotNull(fnu);
- assertEquals(fnu.getDescription(), readedAugment.getDescription());
- assertEquals(fnu.getSerialNumber(), readedAugment.getSerialNumber());
-
- }
-
- private void assertBindingIndependentVersion(
- org.opendaylight.yangtools.yang.data.api.InstanceIdentifier nodeId) {
- CompositeNode node = biDataService.readOperationalData(nodeId);
- assertNotNull(node);
- }
-
- private Nodes checkForNodes() {
- return (Nodes) baDataService.readOperationalData(NODES_INSTANCE_ID_BA);
- }
-
- @Override
- public void onDataChanged(DataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
- receivedChangeEvent = change;
- }
-
-}
+++ /dev/null
-package org.opendaylight.controller.sal.binding.test.bugfix;
-
-public class RpcRegistrationNullPointer {
-
-
-
-
-}
+++ /dev/null
-package org.opendaylight.controller.sal.binding.test.connect.dom;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
-
-import java.util.concurrent.Future;
-
-
-import org.junit.Test;
-import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
-import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
-
-import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest;
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-
-public class BrokerIntegrationTest extends AbstractDataServiceTest {
-
- @Test
- public void simpleModifyOperation() throws Exception {
-
- NodeRef node1 = createNodeRef("0");
- DataObject node = baDataService.readConfigurationData(node1.getValue());
- assertNull(node);
- Node nodeData1 = createNode("0");
-
- DataModificationTransaction transaction = baDataService.beginTransaction();
- transaction.putConfigurationData(node1.getValue(), nodeData1);
- Future<RpcResult<TransactionStatus>> commitResult = transaction.commit();
- assertNotNull(commitResult);
-
- RpcResult<TransactionStatus> result = commitResult.get();
-
- assertNotNull(result);
- assertNotNull(result.getResult());
- assertEquals(TransactionStatus.COMMITED, result.getResult());
-
- Node readedData = (Node) baDataService.readConfigurationData(node1.getValue());
- assertNotNull(readedData);
- assertEquals(nodeData1.getKey(), readedData.getKey());
-
- NodeRef nodeFoo = createNodeRef("foo");
- NodeRef nodeBar = createNodeRef("bar");
- Node nodeFooData = createNode("foo");
- Node nodeBarData = createNode("bar");
-
- DataModificationTransaction insertMoreTr = baDataService.beginTransaction();
- insertMoreTr.putConfigurationData(nodeFoo.getValue(), nodeFooData);
- insertMoreTr.putConfigurationData(nodeBar.getValue(), nodeBarData);
- RpcResult<TransactionStatus> result2 = insertMoreTr.commit().get();
-
- assertNotNull(result2);
- assertNotNull(result2.getResult());
- assertEquals(TransactionStatus.COMMITED, result.getResult());
-
- Nodes allNodes = (Nodes) baDataService.readConfigurationData(InstanceIdentifier.builder(Nodes.class)
- .toInstance());
- assertNotNull(allNodes);
- assertNotNull(allNodes.getNode());
- assertEquals(3, allNodes.getNode().size());
-
- /**
- * We create transaction no 2
- *
- */
- DataModificationTransaction removalTransaction = baDataService.beginTransaction();
- assertNotNull(transaction);
-
- /**
- * We remove node 1
- *
- */
- removalTransaction.removeConfigurationData(node1.getValue());
-
- /**
- * We commit transaction
- */
- Future<RpcResult<TransactionStatus>> commitResult2 = removalTransaction.commit();
- assertNotNull(commitResult2);
-
- RpcResult<TransactionStatus> result3 = commitResult2.get();
-
- assertNotNull(result3);
- assertNotNull(result3.getResult());
- assertEquals(TransactionStatus.COMMITED, result2.getResult());
-
- DataObject readedData2 = baDataService.readConfigurationData(node1.getValue());
- assertNull(readedData2);
- }
-
- private static NodeRef createNodeRef(String string) {
- NodeKey key = new NodeKey(new NodeId(string));
- InstanceIdentifier<Node> path = InstanceIdentifier.builder(Nodes.class).child(Node.class, key)
- .toInstance();
- return new NodeRef(path);
- }
-
- private static Node createNode(String string) {
- NodeBuilder ret = new NodeBuilder();
- ret.setId(new NodeId(string));
- ret.setKey(new NodeKey(ret.getId()));
- return ret.build();
- }
-}
+++ /dev/null
-package org.opendaylight.controller.sal.binding.test.connect.dom;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
-
-
-
-
-
-
-
-
-
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.Future;
-
-
-
-
-
-
-
-
-
-
-
-import org.junit.Test;
-import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
-import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler;
-import org.opendaylight.controller.md.sal.common.api.data.DataModification;
-import org.opendaylight.controller.sal.binding.impl.connect.dom.CommitHandlersTransactions;
-import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest;
-import org.opendaylight.controller.sal.core.api.data.DataModificationTransaction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.Flows;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.Flow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
-import org.opendaylight.yangtools.concepts.Registration;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-
-import com.google.common.collect.ImmutableMap;
-
-public class ChangeOriginatedInDomBrokerTest extends AbstractDataServiceTest {
-
- private static final QName NODE_ID_QNAME = QName.create(Node.QNAME, "id");
- private static final QName FLOW_ID_QNAME = QName.create(Flow.QNAME, "id");
- private static final QName FLOW_NODE_QNAME = QName.create(Flow.QNAME, "node");
- private static final long FLOW_ID = 1234;
- private static final String NODE_ID = "node:1";
-
- private DataModification<InstanceIdentifier<? extends DataObject>, DataObject> modificationCapture;
-
-
- private static final NodeKey NODE_KEY = new NodeKey(new NodeId(NODE_ID));
-
- private static final Map<QName, Object> NODE_KEY_BI = Collections.<QName, Object> singletonMap(NODE_ID_QNAME,
- NODE_ID);
-
- private static final InstanceIdentifier<Node> NODE_INSTANCE_ID_BA = InstanceIdentifier.builder(Nodes.class) //
- .child(Node.class, NODE_KEY).toInstance();
-
- private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier NODE_INSTANCE_ID_BI = //
- org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.builder() //
- .node(Nodes.QNAME) //
- .nodeWithKey(Node.QNAME, NODE_KEY_BI) //
- .toInstance();
- private static final NodeRef NODE_REF = new NodeRef(NODE_INSTANCE_ID_BA);
-
- private static final FlowKey FLOW_KEY = new FlowKey(FLOW_ID, NODE_REF);
-
- private static final Map<QName, Object> FLOW_KEY_BI = //
- ImmutableMap.<QName, Object> of(FLOW_ID_QNAME, FLOW_ID, FLOW_NODE_QNAME, NODE_INSTANCE_ID_BI);
-
- private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier FLOW_INSTANCE_ID_BI = //
- org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.builder() //
- .node(Flows.QNAME) //
- .nodeWithKey(Flow.QNAME, FLOW_KEY_BI) //
- .toInstance();
-
- private static final InstanceIdentifier<Flows> FLOWS_PATH_BA = //
- InstanceIdentifier.builder(Flows.class) //
- .toInstance();
-
-
- private static final InstanceIdentifier<Flow> FLOW_INSTANCE_ID_BA = //
- InstanceIdentifier.builder(Flows.class) //
- .child(Flow.class, FLOW_KEY) //
- .toInstance();
-
- @Test
- public void simpleModifyOperation() throws Exception {
-
- registerCommitHandler();
-
- CompositeNode domflow = createXmlFlow();
- DataModificationTransaction biTransaction = biDataService.beginTransaction();
- biTransaction.putConfigurationData(FLOW_INSTANCE_ID_BI, domflow);
- RpcResult<TransactionStatus> biResult = biTransaction.commit().get();
-
- assertNotNull(modificationCapture);
- Flow flow = (Flow) modificationCapture.getCreatedConfigurationData().get(FLOW_INSTANCE_ID_BA);
- assertNotNull(flow);
- assertNotNull(flow.getMatch());
- assertEquals(TransactionStatus.COMMITED, biResult.getResult());
-
- }
-
-
-
- private void registerCommitHandler() {
- DataCommitHandler<InstanceIdentifier<? extends DataObject>, DataObject> flowTestCommitHandler = new DataCommitHandler<InstanceIdentifier<? extends DataObject>, DataObject>() {
-
-
- @Override
- public org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction<InstanceIdentifier<? extends DataObject>, DataObject> requestCommit(
- DataModification<InstanceIdentifier<? extends DataObject>, DataObject> modification) {
- modificationCapture = modification;
- return CommitHandlersTransactions.allwaysSuccessfulTransaction(modification);
- }
-
-
- };
- Registration<DataCommitHandler<InstanceIdentifier<? extends DataObject>, DataObject>> registration = baDataService.registerCommitHandler(FLOWS_PATH_BA, flowTestCommitHandler);
- assertNotNull(registration);
- }
-
- private CompositeNode createXmlFlow() {
-
- FlowBuilder flow = new FlowBuilder();
- MatchBuilder match = new MatchBuilder();
- VlanMatchBuilder vlanBuilder = new VlanMatchBuilder();
- VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
- VlanId vlanId = new VlanId(10);
- vlanBuilder.setVlanId(vlanIdBuilder.setVlanId(vlanId).build());
- match.setVlanMatch(vlanBuilder.build());
-
- flow.setKey(FLOW_KEY);
- flow.setMatch(match.build());
- flow.setNode(NODE_REF);
- InstructionsBuilder instructions = new InstructionsBuilder();
- InstructionBuilder instruction = new InstructionBuilder();
- instruction.setOrder(10);
- ApplyActionsBuilder applyActions = new ApplyActionsBuilder();
- List<Action> actionList = new ArrayList<>();
- PopMplsActionBuilder popMplsAction = new PopMplsActionBuilder();
- popMplsAction.setEthernetType(34);
- actionList.add(new ActionBuilder().setAction(popMplsAction.build()).setOrder(0).build());
-
- applyActions.setAction(actionList );
-
-
-
- instruction.setInstruction(applyActions.build());
-
-
- List<Instruction> instructionList = Collections.<Instruction>singletonList(instruction.build());
- instructions.setInstruction(instructionList );
-
- flow.setInstructions(instructions.build());
-
- CompositeNode domFlow = mappingService.toDataDom(flow.build());
- return domFlow;
- }
-}
--- /dev/null
+package org.opendaylight.controller.sal.binding.test.util;
+
+import java.util.concurrent.ExecutorService;
+
+import javassist.ClassPool;
+
+import org.opendaylight.controller.sal.core.api.data.DataStore;
+import org.opendaylight.controller.sal.dom.broker.impl.DataStoreStatsWrapper;
+import org.opendaylight.controller.sal.dom.broker.impl.HashMapDataStore;
+import org.opendaylight.controller.sal.dom.broker.impl.SchemaAwareDataStoreAdapter;
+
+import com.google.common.base.Preconditions;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
+
+public class BindingBrokerTestFactory {
+
+ private static final ClassPool CLASS_POOL = new ClassPool();
+ private boolean startWithParsedSchema = true;
+ private ExecutorService executor;
+ private ClassPool classPool;
+
+
+ public boolean isStartWithParsedSchema() {
+ return startWithParsedSchema;
+ }
+
+ public void setStartWithParsedSchema(boolean startWithParsedSchema) {
+ this.startWithParsedSchema = startWithParsedSchema;
+ }
+
+ public ExecutorService getExecutor() {
+ return executor;
+ }
+
+ public void setExecutor(ExecutorService executor) {
+ this.executor = executor;
+ }
+
+
+ public BindingTestContext getTestContext() {
+ Preconditions.checkState(executor != null, "Executor is not set.");
+ ListeningExecutorService listenableExecutor = MoreExecutors.listeningDecorator(executor);
+ return new BindingTestContext(listenableExecutor, getClassPool(),startWithParsedSchema);
+ }
+
+ public ClassPool getClassPool() {
+ if(classPool == null) {
+ return CLASS_POOL;
+ }
+
+ return classPool;
+ }
+
+ public void setClassPool(ClassPool classPool) {
+ this.classPool = classPool;
+ }
+
+}
--- /dev/null
+package org.opendaylight.controller.sal.binding.test.util;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import javassist.ClassPool;
+
+import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
+import org.opendaylight.controller.sal.binding.dom.serializer.impl.RuntimeGeneratedMappingServiceImpl;
+import org.opendaylight.controller.sal.binding.impl.DataBrokerImpl;
+import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingIndependentDataServiceConnector;
+import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingIndependentMappingService;
+import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest;
+import org.opendaylight.controller.sal.core.api.data.DataStore;
+import org.opendaylight.controller.sal.dom.broker.impl.DataStoreStatsWrapper;
+import org.opendaylight.controller.sal.dom.broker.impl.HashMapDataStore;
+import org.opendaylight.controller.sal.dom.broker.impl.SchemaAwareDataStoreAdapter;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
+import org.reflections.Reflections;
+import org.reflections.scanners.ResourcesScanner;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Predicate;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
+
+import static com.google.common.base.Preconditions.*;
+
+public class BindingTestContext {
+
+
+ public static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier TREE_ROOT = org.opendaylight.yangtools.yang.data.api.InstanceIdentifier
+ .builder().toInstance();
+
+ private static final Logger LOG = LoggerFactory.getLogger(BindingTestContext.class);
+
+ private RuntimeGeneratedMappingServiceImpl mappingServiceImpl;
+ private DataBrokerImpl baDataImpl;
+ private org.opendaylight.controller.sal.dom.broker.DataBrokerImpl biDataImpl;
+
+ private BindingIndependentDataServiceConnector connectorServiceImpl;
+ private HashMapDataStore rawDataStore;
+ private SchemaAwareDataStoreAdapter schemaAwareDataStore;
+ private DataStoreStatsWrapper dataStoreStats;
+ private DataStore dataStore;
+
+
+ private boolean dataStoreStatisticsEnabled = false;
+
+ private final ListeningExecutorService executor;
+ private final ClassPool classPool;
+
+ private final boolean startWithSchema;
+
+ protected BindingTestContext(ListeningExecutorService executor, ClassPool classPool, boolean startWithSchema) {
+ this.executor = executor;
+ this.classPool = classPool;
+ this.startWithSchema = startWithSchema;
+ }
+
+ public void startDomDataStore() {
+ checkState(dataStore == null, "DataStore already started.");
+ checkState(biDataImpl != null, "Dom Data Broker not present");
+ rawDataStore = new HashMapDataStore();
+ schemaAwareDataStore = new SchemaAwareDataStoreAdapter();
+ schemaAwareDataStore.changeDelegate(rawDataStore);
+ if(dataStoreStatisticsEnabled) {
+ dataStoreStats = new DataStoreStatsWrapper(schemaAwareDataStore);
+ dataStore = dataStoreStats;
+ } else {
+ dataStore = schemaAwareDataStore;
+ }
+
+ biDataImpl.registerConfigurationReader(TREE_ROOT, dataStore);
+ biDataImpl.registerOperationalReader(TREE_ROOT, dataStore);
+ biDataImpl.registerCommitHandler(TREE_ROOT, dataStore);
+ }
+
+ public void startDomDataBroker() {
+ checkState(executor != null,"Executor needs to be set");
+ biDataImpl = new org.opendaylight.controller.sal.dom.broker.DataBrokerImpl();
+ biDataImpl.setExecutor(executor);
+ }
+
+ public void startBindingDataBroker() {
+ checkState(executor != null,"Executor needs to be set");
+ baDataImpl = new DataBrokerImpl();
+ baDataImpl.setExecutor(executor);
+ }
+
+ public void startBindingToDomDataConnector() {
+ checkState(baDataImpl != null,"Binding Data Broker needs to be started");
+ checkState(biDataImpl != null,"DOM Data Broker needs to be started.");
+ checkState(mappingServiceImpl != null,"DOM Mapping Service needs to be started.");
+ connectorServiceImpl = new BindingIndependentDataServiceConnector();
+ connectorServiceImpl.setBaDataService(baDataImpl);
+ connectorServiceImpl.setBiDataService(biDataImpl);
+ connectorServiceImpl.setMappingService(mappingServiceImpl);
+ connectorServiceImpl.start();
+ }
+
+ public void startBindingToDomMappingService() {
+ checkState(classPool != null,"ClassPool needs to be present");
+ mappingServiceImpl = new RuntimeGeneratedMappingServiceImpl();
+ mappingServiceImpl.setPool(classPool);
+ mappingServiceImpl.start(null);
+ }
+
+
+ public void updateYangSchema(String[] files) {
+ SchemaContext context = getContext(files);
+ if(schemaAwareDataStore != null) {
+ schemaAwareDataStore.onGlobalContextUpdated(context);
+ }
+ if(mappingServiceImpl != null) {
+ mappingServiceImpl.onGlobalContextUpdated(context);
+ }
+ }
+
+
+ public static String[] getAllYangFilesOnClasspath() {
+ Predicate<String> predicate = new Predicate<String>() {
+ @Override
+ public boolean apply(String input) {
+ return input.endsWith(".yang");
+ }
+ };
+ Reflections reflection = new Reflections("META-INF.yang", new ResourcesScanner());
+ Set<String> result = reflection.getResources(predicate);
+ return (String[]) result.toArray(new String[result.size()]);
+ }
+
+ private static SchemaContext getContext(String[] yangFiles) {
+ ClassLoader loader = BindingTestContext.class.getClassLoader();
+ List<InputStream> streams = new ArrayList<>();
+ for (String string : yangFiles) {
+ InputStream stream = loader.getResourceAsStream(string);
+ streams.add(stream);
+ }
+ YangParserImpl parser = new YangParserImpl();
+ Set<Module> modules = parser.parseYangModelsFromStreams(streams);
+ return parser.resolveSchemaContext(modules);
+ }
+
+ public void start() {
+ startBindingDataBroker();
+ startDomDataBroker();
+ startDomDataStore();
+ startBindingToDomMappingService();
+ startBindingToDomDataConnector();
+ if(startWithSchema) {
+ loadYangSchemaFromClasspath();
+ }
+ }
+
+ public void loadYangSchemaFromClasspath() {
+ String[] files = getAllYangFilesOnClasspath();
+ updateYangSchema(files);
+ }
+
+ public DataProviderService getBindingDataBroker() {
+ return baDataImpl;
+ }
+
+ public org.opendaylight.controller.sal.core.api.data.DataProviderService getDomDataBroker() {
+ return biDataImpl;
+ }
+
+ public DataStore getDomDataStore() {
+ return dataStore;
+ }
+
+ public BindingIndependentMappingService getBindingToDomMappingService() {
+ return mappingServiceImpl;
+ }
+
+ public void logDataStoreStatistics() {
+ if(dataStoreStats == null) {
+ return;
+ }
+
+ LOG.info("BIDataStore Statistics: Configuration Read Count: {} TotalTime: {} ms AverageTime (ns): {} ms",
+ dataStoreStats.getConfigurationReadCount(), dataStoreStats.getConfigurationReadTotalTime(),
+ dataStoreStats.getConfigurationReadAverageTime());
+
+ LOG.info("BIDataStore Statistics: Operational Read Count: {} TotalTime: {} ms AverageTime (ns): {} ms",
+ dataStoreStats.getOperationalReadCount(), dataStoreStats.getOperationalReadTotalTime(),
+ dataStoreStats.getOperationalReadAverageTime());
+
+ LOG.info("BIDataStore Statistics: Request Commit Count: {} TotalTime: {} ms AverageTime (ns): {} ms",
+ dataStoreStats.getRequestCommitCount(), dataStoreStats.getRequestCommitTotalTime(),
+ dataStoreStats.getRequestCommitAverageTime());
+ }
+}
}\r
\r
override readConfigurationData(P path) {\r
+ val local = this.updatedConfigurationData.get(path);\r
+ if(local != null) {\r
+ return local;\r
+ }\r
+ \r
return broker.readConfigurationData(path);\r
}\r
\r
override readOperationalData(P path) {\r
+ val local = this.updatedOperationalData.get(path);\r
+ if(local != null) {\r
+ return local;\r
+ }\r
return broker.readOperationalData(path);\r
}\r
\r