<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-dom-xsql</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-dom-xsql-config</artifactId>
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-binding-api</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>netconf-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>netconf-auth</artifactId>
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>ietf-netconf-monitoring</artifactId>
<feature name='odl-netconf-api' version='${project.version}' description="OpenDaylight :: Netconf :: API">
<feature version='${protocol-framework.version}'>odl-protocol-framework</feature>
<bundle>mvn:org.opendaylight.controller/netconf-api/${project.version}</bundle>
+ <bundle>mvn:org.opendaylight.controller/netconf-auth/${project.version}</bundle>
<bundle>mvn:org.opendaylight.controller/ietf-netconf-monitoring/${project.version}</bundle>
<bundle>mvn:org.opendaylight.controller/ietf-netconf-monitoring-extension/${project.version}</bundle>
<bundle>mvn:org.opendaylight.yangtools.model/ietf-inet-types/${ietf-inet-types.version}</bundle>
will pick the pom.xml from the parent directory as the parent pom, which may or may
not be correct.
-->
+ <!--
+ Necessary TODO: Replace the contents of src/main/resources/80-${repoName}.xml with
+ the proper config subsystem contents for your module
+ -->
<artifactId>${artifactId}</artifactId>
<groupId>${groupId}</groupId>
<description>Configuration files for md-sal</description>
<packaging>jar</packaging>
<properties>
<!-- Optional TODO: Rename your configfile to taste -->
- <configfile>80-configfile.xml</configfile>
+ <configfile>80-${repoName}.xml</configfile>
</properties>
<build>
<plugins>
<type>xml</type>
<classifier>config</classifier>
</artifact>
+ <!--
+ Optional TODO: Add additional config files
+ You may need to add more than one config file
+ if so, you just need to add additional <artifact> entries
+ here WITH DIFFERENT CLASSIFIERS
+ Example:
+ <artifact>
+ <file>${project.build.directory}/classes/<another-configfile></file>
+ <type>xml</type>
+ <classifier>config-<meaningful suffix to describe your other configfile></classifier>
+ </artifact>
+ -->
</artifacts>
</configuration>
</execution>
<artifactId>sal-dom-xsql</artifactId>
<version>${mdsal.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-dom-xsql-config</artifactId>
+ <version>${mdsal.version}</version>
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-core-api</artifactId>
import java.util.Date;
import java.util.HashSet;
import java.util.List;
+import java.util.regex.Pattern;
import org.opendaylight.controller.sal.common.util.Arguments;
import org.opendaylight.controller.sal.core.AdvertisedBandwidth;
import org.opendaylight.controller.sal.core.Bandwidth;
private final static Class<NodeConnector> NODECONNECTOR_CLASS = NodeConnector.class;
+ private final static Pattern COLON_NUMBERS_EOL = Pattern.compile(":[0-9]+$");
+
+ private final static Pattern NUMBERS_ONLY = Pattern.compile("[0-9]+");
+
+ private final static Pattern ALL_CHARS_TO_COLON = Pattern.compile("^.*:");
+
private NodeMapping() {
throw new UnsupportedOperationException("Utility class. Instantiation is not allowed.");
}
return org.opendaylight.controller.sal.core.NodeConnector.SPECIALNODECONNECTORID;
}
- String nodeConnectorIdStripped = nodeConnectorId.getValue().replaceFirst("^.*:", "");
- if (nodeConnectorIdStripped.matches("[0-9]+")) {
+ String nodeConnectorIdStripped = ALL_CHARS_TO_COLON.matcher(nodeConnectorId.getValue()).replaceFirst("");
+
+ if (NUMBERS_ONLY.matcher(nodeConnectorIdStripped).matches()) {
Short nodeConnectorIdVal = null;
try {
nodeConnectorIdVal = Short.valueOf(nodeConnectorIdStripped);
+ return nodeConnectorIdVal;
} catch (NumberFormatException e) {
- LOG.warn("nodeConnectorId not supported (short): {}", nodeConnectorIdStripped, e);
+ LOG.warn("nodeConnectorId not supported (long): {}", nodeConnectorIdStripped, e);
}
- return nodeConnectorIdVal;
}
return nodeConnectorIdStripped;
}
public static NodeId toAdNodeId(final NodeConnectorId nodeConnectorId) {
NodeId nodeId = null;
if (nodeConnectorId != null) {
- nodeId = new NodeId(nodeConnectorId.getValue().replaceFirst(":[0-9]+$", ""));
+ nodeId = new NodeId(COLON_NUMBERS_EOL.matcher(nodeConnectorId.getValue()).replaceFirst(""));
}
return nodeId;
}
<!-- XSQL -->
<module>sal-dom-xsql</module>
+ <module>sal-dom-xsql-config</module>
<!-- Yang Test Models for MD-SAL -->
<module>sal-test-model</module>
<!-- Clustering -->
<module>sal-remoterpc-connector</module>
- <module>sal-dom-xsql-config</module>
</modules>
<build>
mavenBundle("org.javassist", "javassist").versionAsInProject(), // //
mavenBundle(YANGTOOLS, "yang-data-api").versionAsInProject(), // //
+ mavenBundle(YANGTOOLS, "yang-data-util").versionAsInProject(), // //
mavenBundle(YANGTOOLS, "yang-data-impl").versionAsInProject(), // //
mavenBundle(YANGTOOLS, "yang-model-api").versionAsInProject(), // //
mavenBundle(YANGTOOLS, "yang-model-util").versionAsInProject(), // //
package org.opendaylight.controller.cluster.datastore;
-import java.util.concurrent.TimeUnit;
-
-import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreConfigProperties;
import com.google.common.base.Preconditions;
-
+import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreConfigProperties;
import scala.concurrent.duration.Duration;
+import java.util.concurrent.TimeUnit;
+
/**
* Contains contextual data for shards.
*
* @author Thomas Pantelis
*/
-public class ShardContext {
+public class DatastoreContext {
private final InMemoryDOMDataStoreConfigProperties dataStoreProperties;
private final Duration shardTransactionIdleTimeout;
- public ShardContext() {
+ public DatastoreContext() {
this.dataStoreProperties = null;
this.shardTransactionIdleTimeout = Duration.create(10, TimeUnit.MINUTES);
}
- public ShardContext(InMemoryDOMDataStoreConfigProperties dataStoreProperties,
- Duration shardTransactionIdleTimeout) {
+ public DatastoreContext(InMemoryDOMDataStoreConfigProperties dataStoreProperties,
+ Duration shardTransactionIdleTimeout) {
this.dataStoreProperties = Preconditions.checkNotNull(dataStoreProperties);
this.shardTransactionIdleTimeout = Preconditions.checkNotNull(shardTransactionIdleTimeout);
}
public Duration getShardTransactionIdleTimeout() {
return shardTransactionIdleTimeout;
}
+
+
}
private static final Logger LOG = LoggerFactory.getLogger(DistributedDataStore.class);
private final ActorContext actorContext;
- private final ShardContext shardContext;
+ private final DatastoreContext datastoreContext;
public DistributedDataStore(ActorSystem actorSystem, String type, ClusterWrapper cluster,
Configuration configuration, DistributedDataStoreProperties dataStoreProperties) {
LOG.info("Creating ShardManager : {}", shardManagerId);
- shardContext = new ShardContext(InMemoryDOMDataStoreConfigProperties.create(
+ datastoreContext = new DatastoreContext(InMemoryDOMDataStoreConfigProperties.create(
dataStoreProperties.getMaxShardDataChangeExecutorPoolSize(),
dataStoreProperties.getMaxShardDataChangeExecutorQueueSize(),
dataStoreProperties.getMaxShardDataChangeListenerQueueSize()),
actorContext
= new ActorContext(
actorSystem, actorSystem.actorOf(
- ShardManager.props(type, cluster, configuration, shardContext).
+ ShardManager.props(type, cluster, configuration, datastoreContext).
withMailbox(ActorContext.MAILBOX), shardManagerId ), cluster, configuration);
}
public DistributedDataStore(ActorContext actorContext) {
this.actorContext = Preconditions.checkNotNull(actorContext, "actorContext should not be null");
- this.shardContext = new ShardContext();
+ this.datastoreContext = new DatastoreContext();
}
private final List<ActorSelection> dataChangeListeners = new ArrayList<>();
- private final ShardContext shardContext;
+ private final DatastoreContext datastoreContext;
+
private SchemaContext schemaContext;
private Shard(ShardIdentifier name, Map<ShardIdentifier, String> peerAddresses,
- ShardContext shardContext) {
+ DatastoreContext datastoreContext) {
super(name.toString(), mapPeerAddresses(peerAddresses), Optional.of(configParams));
this.name = name;
- this.shardContext = shardContext;
+ this.datastoreContext = datastoreContext;
String setting = System.getProperty("shard.persistent");
LOG.info("Shard created : {} persistent : {}", name, persistent);
store = InMemoryDOMDataStoreFactory.create(name.toString(), null,
- shardContext.getDataStoreProperties());
+ datastoreContext.getDataStoreProperties());
shardMBean = ShardMBeanFactory.getShardStatsMBean(name.toString());
+
}
private static Map<String, String> mapPeerAddresses(
public static Props props(final ShardIdentifier name,
final Map<ShardIdentifier, String> peerAddresses,
- ShardContext shardContext) {
+ DatastoreContext datastoreContext) {
Preconditions.checkNotNull(name, "name should not be null");
Preconditions.checkNotNull(peerAddresses, "peerAddresses should not be null");
- Preconditions.checkNotNull(shardContext, "shardContext should not be null");
+ Preconditions.checkNotNull(datastoreContext, "shardContext should not be null");
- return Props.create(new ShardCreator(name, peerAddresses, shardContext));
+ return Props.create(new ShardCreator(name, peerAddresses, datastoreContext));
}
@Override public void onReceiveCommand(Object message) {
return getContext().actorOf(
ShardTransaction.props(store.newReadOnlyTransaction(), getSelf(),
- schemaContext, shardContext), transactionId.toString());
+ schemaContext,datastoreContext, name.toString()), transactionId.toString());
} else if (createTransaction.getTransactionType()
== TransactionProxy.TransactionType.READ_WRITE.ordinal()) {
return getContext().actorOf(
ShardTransaction.props(store.newReadWriteTransaction(), getSelf(),
- schemaContext, shardContext), transactionId.toString());
+ schemaContext, datastoreContext,name.toString()), transactionId.toString());
} else if (createTransaction.getTransactionType()
return getContext().actorOf(
ShardTransaction.props(store.newWriteOnlyTransaction(), getSelf(),
- schemaContext, shardContext), transactionId.toString());
+ schemaContext, datastoreContext, name.toString()), transactionId.toString());
} else {
throw new IllegalArgumentException(
"Shard="+name + ":CreateTransaction message has unidentified transaction type="
private void createTransactionChain() {
DOMStoreTransactionChain chain = store.createTransactionChain();
ActorRef transactionChain = getContext().actorOf(
- ShardTransactionChain.props(chain, schemaContext, shardContext));
+ ShardTransactionChain.props(chain, schemaContext, datastoreContext,name.toString() ));
getSender().tell(new CreateTransactionChainReply(transactionChain.path()).toSerializable(),
getSelf());
}
final ShardIdentifier name;
final Map<ShardIdentifier, String> peerAddresses;
- final ShardContext shardContext;
+ final DatastoreContext datastoreContext;
ShardCreator(ShardIdentifier name, Map<ShardIdentifier, String> peerAddresses,
- ShardContext shardContext) {
+ DatastoreContext datastoreContext) {
this.name = name;
this.peerAddresses = peerAddresses;
- this.shardContext = shardContext;
+ this.datastoreContext = datastoreContext;
}
@Override
public Shard create() throws Exception {
- return new Shard(name, peerAddresses, shardContext);
+ return new Shard(name, peerAddresses, datastoreContext);
}
}
}
private ShardManagerInfoMBean mBean;
- private final ShardContext shardContext;
+ private final DatastoreContext datastoreContext;
/**
* @param type defines the kind of data that goes into shards created by this shard manager. Examples of type would be
* configuration or operational
*/
private ShardManager(String type, ClusterWrapper cluster, Configuration configuration,
- ShardContext shardContext) {
+ DatastoreContext datastoreContext) {
this.type = Preconditions.checkNotNull(type, "type should not be null");
this.cluster = Preconditions.checkNotNull(cluster, "cluster should not be null");
this.configuration = Preconditions.checkNotNull(configuration, "configuration should not be null");
- this.shardContext = shardContext;
+ this.datastoreContext = datastoreContext;
// Subscribe this actor to cluster member events
cluster.subscribeToMemberEvents(getSelf());
public static Props props(final String type,
final ClusterWrapper cluster,
final Configuration configuration,
- final ShardContext shardContext) {
+ final DatastoreContext datastoreContext) {
Preconditions.checkNotNull(type, "type should not be null");
Preconditions.checkNotNull(cluster, "cluster should not be null");
Preconditions.checkNotNull(configuration, "configuration should not be null");
- return Props.create(new ShardManagerCreator(type, cluster, configuration, shardContext));
+ return Props.create(new ShardManagerCreator(type, cluster, configuration, datastoreContext));
}
@Override
ShardIdentifier shardId = getShardIdentifier(memberName, shardName);
Map<ShardIdentifier, String> peerAddresses = getPeerAddresses(shardName);
ActorRef actor = getContext()
- .actorOf(Shard.props(shardId, peerAddresses, shardContext).
+ .actorOf(Shard.props(shardId, peerAddresses, datastoreContext).
withMailbox(ActorContext.MAILBOX), shardId.toString());
localShardActorNames.add(shardId.toString());
final String type;
final ClusterWrapper cluster;
final Configuration configuration;
- final ShardContext shardContext;
+ final DatastoreContext datastoreContext;
ShardManagerCreator(String type, ClusterWrapper cluster,
- Configuration configuration, ShardContext shardContext) {
+ Configuration configuration, DatastoreContext datastoreContext) {
this.type = type;
this.cluster = cluster;
this.configuration = configuration;
- this.shardContext = shardContext;
+ this.datastoreContext = datastoreContext;
}
@Override
public ShardManager create() throws Exception {
- return new ShardManager(type, cluster, configuration, shardContext);
+ return new ShardManager(type, cluster, configuration, datastoreContext);
}
}
}
private final DOMStoreReadTransaction transaction;
public ShardReadTransaction(DOMStoreReadTransaction transaction, ActorRef shardActor,
- SchemaContext schemaContext) {
- super(shardActor, schemaContext);
+ SchemaContext schemaContext,String shardName) {
+ super(shardActor, schemaContext, shardName);
this.transaction = transaction;
}
private final DOMStoreReadWriteTransaction transaction;
public ShardReadWriteTransaction(DOMStoreReadWriteTransaction transaction, ActorRef shardActor,
- SchemaContext schemaContext) {
- super(shardActor, schemaContext);
+ SchemaContext schemaContext,String shardName) {
+ super(shardActor, schemaContext, shardName);
this.transaction = transaction;
}
import akka.actor.Props;
import akka.actor.ReceiveTimeout;
import akka.japi.Creator;
-
import com.google.common.base.Optional;
import com.google.common.util.concurrent.CheckedFuture;
-
import org.opendaylight.controller.cluster.datastore.exceptions.UnknownMessageException;
+import org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard.ShardMBeanFactory;
import org.opendaylight.controller.cluster.datastore.messages.CloseTransaction;
import org.opendaylight.controller.cluster.datastore.messages.CloseTransactionReply;
import org.opendaylight.controller.cluster.datastore.messages.DataExists;
private final ActorRef shardActor;
protected final SchemaContext schemaContext;
+ private final String shardName;
+
private final MutableCompositeModification modification = new MutableCompositeModification();
- protected ShardTransaction(ActorRef shardActor, SchemaContext schemaContext) {
+ protected ShardTransaction(ActorRef shardActor, SchemaContext schemaContext,
+ String shardName) {
this.shardActor = shardActor;
this.schemaContext = schemaContext;
+ this.shardName = shardName;
}
public static Props props(DOMStoreTransaction transaction, ActorRef shardActor,
- SchemaContext schemaContext, ShardContext shardContext) {
+ SchemaContext schemaContext,DatastoreContext datastoreContext, String shardName) {
return Props.create(new ShardTransactionCreator(transaction, shardActor, schemaContext,
- shardContext));
+ datastoreContext, shardName));
}
protected abstract DOMStoreTransaction getDOMStoreTransaction();
sender.tell(new ReadDataReply(schemaContext,null).toSerializable(), self);
}
} catch (Exception e) {
- sender.tell(new akka.actor.Status.Failure(e),self);
+ ShardMBeanFactory.getShardStatsMBean(shardName).incrementFailedReadTransactionsCount();
+ sender.tell(new akka.actor.Status.Failure(e), self);
}
}
protected void readyTransaction(DOMStoreWriteTransaction transaction, ReadyTransaction message) {
DOMStoreThreePhaseCommitCohort cohort = transaction.ready();
ActorRef cohortActor = getContext().actorOf(
- ThreePhaseCommitCohort.props(cohort, shardActor, modification), "cohort");
+ ThreePhaseCommitCohort.props(cohort, shardActor, modification, shardName), "cohort");
getSender()
.tell(new ReadyTransactionReply(cohortActor.path()).toSerializable(), getSelf());
final DOMStoreTransaction transaction;
final ActorRef shardActor;
final SchemaContext schemaContext;
- final ShardContext shardContext;
+ final DatastoreContext datastoreContext;
+ final String shardName;
ShardTransactionCreator(DOMStoreTransaction transaction, ActorRef shardActor,
- SchemaContext schemaContext, ShardContext actorContext) {
+ SchemaContext schemaContext, DatastoreContext datastoreContext, String shardName) {
this.transaction = transaction;
this.shardActor = shardActor;
- this.shardContext = actorContext;
+ this.shardName = shardName;
this.schemaContext = schemaContext;
+ this.datastoreContext = datastoreContext;
}
@Override
ShardTransaction tx;
if(transaction instanceof DOMStoreReadWriteTransaction) {
tx = new ShardReadWriteTransaction((DOMStoreReadWriteTransaction)transaction,
- shardActor, schemaContext);
+ shardActor, schemaContext, shardName);
} else if(transaction instanceof DOMStoreReadTransaction) {
tx = new ShardReadTransaction((DOMStoreReadTransaction)transaction, shardActor,
- schemaContext);
+ schemaContext, shardName);
} else {
tx = new ShardWriteTransaction((DOMStoreWriteTransaction)transaction,
- shardActor, schemaContext);
+ shardActor, schemaContext, shardName);
}
- tx.getContext().setReceiveTimeout(shardContext.getShardTransactionIdleTimeout());
+ tx.getContext().setReceiveTimeout(datastoreContext.getShardTransactionIdleTimeout());
return tx;
}
}
public class ShardTransactionChain extends AbstractUntypedActor {
private final DOMStoreTransactionChain chain;
- private final ShardContext shardContext;
+ private final DatastoreContext datastoreContext;
private final SchemaContext schemaContext;
+ private final String shardName;
public ShardTransactionChain(DOMStoreTransactionChain chain, SchemaContext schemaContext,
- ShardContext shardContext) {
+ DatastoreContext datastoreContext,String shardName) {
this.chain = chain;
- this.shardContext = shardContext;
+ this.datastoreContext = datastoreContext;
this.schemaContext = schemaContext;
+ this.shardName = shardName;
}
@Override
TransactionProxy.TransactionType.READ_ONLY.ordinal()) {
return getContext().actorOf(
ShardTransaction.props( chain.newReadOnlyTransaction(), getShardActor(),
- schemaContext, shardContext), transactionId);
+ schemaContext, datastoreContext,shardName), transactionId);
} else if (createTransaction.getTransactionType() ==
TransactionProxy.TransactionType.READ_WRITE.ordinal()) {
return getContext().actorOf(
ShardTransaction.props( chain.newReadWriteTransaction(), getShardActor(),
- schemaContext, shardContext), transactionId);
+ schemaContext, datastoreContext,shardName), transactionId);
} else if (createTransaction.getTransactionType() ==
TransactionProxy.TransactionType.WRITE_ONLY.ordinal()) {
return getContext().actorOf(
ShardTransaction.props( chain.newWriteOnlyTransaction(), getShardActor(),
- schemaContext, shardContext), transactionId);
+ schemaContext, datastoreContext,shardName), transactionId);
} else {
throw new IllegalArgumentException (
"CreateTransaction message has unidentified transaction type=" +
}
public static Props props(DOMStoreTransactionChain chain, SchemaContext schemaContext,
- ShardContext shardContext) {
- return Props.create(new ShardTransactionChainCreator(chain, schemaContext, shardContext));
+ DatastoreContext datastoreContext, String shardName) {
+ return Props.create(new ShardTransactionChainCreator(chain, schemaContext, datastoreContext, shardName));
}
private static class ShardTransactionChainCreator implements Creator<ShardTransactionChain> {
private static final long serialVersionUID = 1L;
final DOMStoreTransactionChain chain;
- final ShardContext shardContext;
+ final DatastoreContext datastoreContext;
final SchemaContext schemaContext;
+ final String shardName;
+
ShardTransactionChainCreator(DOMStoreTransactionChain chain, SchemaContext schemaContext,
- ShardContext shardContext) {
+ DatastoreContext datastoreContext, String shardName) {
this.chain = chain;
- this.shardContext = shardContext;
+ this.datastoreContext = datastoreContext;
this.schemaContext = schemaContext;
+ this.shardName = shardName;
}
@Override
public ShardTransactionChain create() throws Exception {
- return new ShardTransactionChain(chain, schemaContext, shardContext);
+ return new ShardTransactionChain(chain, schemaContext, datastoreContext,shardName);
}
}
}
private final DOMStoreWriteTransaction transaction;
public ShardWriteTransaction(DOMStoreWriteTransaction transaction, ActorRef shardActor,
- SchemaContext schemaContext) {
- super(shardActor, schemaContext);
+ SchemaContext schemaContext,String shardName) {
+ super(shardActor, schemaContext, shardName);
this.transaction = transaction;
}
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
+import org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard.ShardMBeanFactory;
import org.opendaylight.controller.cluster.datastore.messages.AbortTransaction;
import org.opendaylight.controller.cluster.datastore.messages.AbortTransactionReply;
import org.opendaylight.controller.cluster.datastore.messages.CanCommitTransaction;
private final DOMStoreThreePhaseCommitCohort cohort;
private final ActorRef shardActor;
private final CompositeModification modification;
+ private final String shardName;
public ThreePhaseCommitCohort(DOMStoreThreePhaseCommitCohort cohort,
- ActorRef shardActor, CompositeModification modification) {
+ ActorRef shardActor, CompositeModification modification,String shardName) {
this.cohort = cohort;
this.shardActor = shardActor;
this.modification = modification;
+ this.shardName = shardName;
}
private final LoggingAdapter log =
Logging.getLogger(getContext().system(), this);
public static Props props(final DOMStoreThreePhaseCommitCohort cohort,
- final ActorRef shardActor, final CompositeModification modification) {
- return Props.create(new ThreePhaseCommitCohortCreator(cohort, shardActor, modification));
+ final ActorRef shardActor, final CompositeModification modification,
+ String shardName) {
+ return Props.create(new ThreePhaseCommitCohortCreator(cohort, shardActor, modification,
+ shardName));
}
@Override
Futures.addCallback(future, new FutureCallback<Void>() {
@Override
public void onSuccess(Void v) {
+ ShardMBeanFactory.getShardStatsMBean(shardName).incrementAbortTransactionsCount();
sender
.tell(new AbortTransactionReply().toSerializable(),
- self);
+ self);
}
@Override
final DOMStoreThreePhaseCommitCohort cohort;
final ActorRef shardActor;
final CompositeModification modification;
+ final String shardName;
ThreePhaseCommitCohortCreator(DOMStoreThreePhaseCommitCohort cohort,
- ActorRef shardActor, CompositeModification modification) {
+ ActorRef shardActor, CompositeModification modification, String shardName) {
this.cohort = cohort;
this.shardActor = shardActor;
this.modification = modification;
+ this.shardName = shardName;
}
@Override
public ThreePhaseCommitCohort create() throws Exception {
- return new ThreePhaseCommitCohort(cohort, shardActor, modification);
+ return new ThreePhaseCommitCohort(cohort, shardActor, modification, shardName);
}
}
}
Preconditions.checkState(transactionType != TransactionType.READ_ONLY,
"Modification operation on read-only transaction is not allowed");
Preconditions.checkState(!inReadyState,
- "Transaction is sealed - further modifications are allowed");
+ "Transaction is sealed - further modifications are not allowed");
}
@Override
returnFuture.setException(new ReadFailedException(
"Error reading data for path " + path, failure));
+
} else {
LOG.debug("Tx {} read operation succeeded", identifier, failure);
/**
* All MBeans should extend this class that help in registering and
* unregistering the MBeans.
- *
+ * @author Basheeruddin <syedbahm@cisco.com>
*/
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
package org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard;
import java.util.HashMap;
import java.util.Map;
/**
- * @author: syedbahm
- * Date: 7/16/14
+ * @author Basheeruddin syedbahm@cisco.com
+ *
*/
public class ShardMBeanFactory {
private static Map<String, ShardStats> shardMBeans =
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
package org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard;
import org.opendaylight.controller.cluster.datastore.jmx.mbeans.AbstractBaseMBean;
import java.util.Date;
/**
- * @author: syedbahm
+ * @author Basheeruddin syedbahm@cisco.com
*/
public class ShardStats extends AbstractBaseMBean implements ShardStatsMBean {
private final String shardName;
- private Long committedTransactionsCount = 0L;
+ private long committedTransactionsCount = 0L;
- private Long readOnlyTransactionCount = 0L;
+ private long readOnlyTransactionCount = 0L;
- private Long writeOnlyTransactionCount = 0L;
+ private long writeOnlyTransactionCount = 0L;
- private Long readWriteTransactionCount = 0L;
+ private long readWriteTransactionCount = 0L;
private String leader;
private String raftState;
- private Long lastLogTerm = -1L;
+ private long lastLogTerm = -1L;
- private Long lastLogIndex = -1L;
+ private long lastLogIndex = -1L;
- private Long currentTerm = -1L;
+ private long currentTerm = -1L;
- private Long commitIndex = -1L;
+ private long commitIndex = -1L;
- private Long lastApplied = -1L;
+ private long lastApplied = -1L;
private Date lastCommittedTransactionTime = new Date(0L);
- private Long failedTransactionsCount = 0L;
+ private long failedTransactionsCount = 0L;
+
+ private long failedReadTransactionsCount = 0L;
+
+ private long abortTransactionsCount = 0L;
private SimpleDateFormat sdf =
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
}
@Override
- public Long getCommittedTransactionsCount() {
+ public long getCommittedTransactionsCount() {
return committedTransactionsCount;
}
return raftState;
}
- @Override public Long getReadOnlyTransactionCount() {
+ @Override public long getReadOnlyTransactionCount() {
return readOnlyTransactionCount;
}
- @Override public Long getWriteOnlyTransactionCount() {
+ @Override public long getWriteOnlyTransactionCount() {
return writeOnlyTransactionCount;
}
- @Override public Long getReadWriteTransactionCount() {
+ @Override public long getReadWriteTransactionCount() {
return readWriteTransactionCount;
}
- @Override public Long getLastLogIndex() {
+ @Override public long getLastLogIndex() {
return lastLogIndex;
}
- @Override public Long getLastLogTerm() {
+ @Override public long getLastLogTerm() {
return lastLogTerm;
}
- @Override public Long getCurrentTerm() {
+ @Override public long getCurrentTerm() {
return currentTerm;
}
- @Override public Long getCommitIndex() {
+ @Override public long getCommitIndex() {
return commitIndex;
}
- @Override public Long getLastApplied() {
+ @Override public long getLastApplied() {
return lastApplied;
}
return sdf.format(lastCommittedTransactionTime);
}
- @Override public Long getFailedTransactionsCount() {
+ @Override public long getFailedTransactionsCount() {
return failedTransactionsCount;
}
- public Long incrementCommittedTransactionCount() {
+ @Override public long getFailedReadTransactionsCount() {
+ return failedReadTransactionsCount;
+ }
+
+ @Override public long getAbortTransactionsCount() {
+ return abortTransactionsCount;
+ }
+
+ public long incrementCommittedTransactionCount() {
return committedTransactionsCount++;
}
- public Long incrementReadOnlyTransactionCount() {
+ public long incrementReadOnlyTransactionCount() {
return readOnlyTransactionCount++;
}
- public Long incrementWriteOnlyTransactionCount() {
+ public long incrementWriteOnlyTransactionCount() {
return writeOnlyTransactionCount++;
}
- public Long incrementReadWriteTransactionCount() {
+ public long incrementReadWriteTransactionCount() {
return readWriteTransactionCount++;
}
+ public long incrementFailedTransactionsCount() {
+ return failedTransactionsCount++;
+ }
+
+ public long incrementFailedReadTransactionsCount() {
+ return failedReadTransactionsCount++;
+ }
+
+ public long incrementAbortTransactionsCount () { return abortTransactionsCount++;}
+
public void setLeader(String leader) {
this.leader = leader;
}
this.raftState = raftState;
}
- public void setLastLogTerm(Long lastLogTerm) {
+ public void setLastLogTerm(long lastLogTerm) {
this.lastLogTerm = lastLogTerm;
}
- public void setLastLogIndex(Long lastLogIndex) {
+ public void setLastLogIndex(long lastLogIndex) {
this.lastLogIndex = lastLogIndex;
}
- public void setCurrentTerm(Long currentTerm) {
+ public void setCurrentTerm(long currentTerm) {
this.currentTerm = currentTerm;
}
- public void setCommitIndex(Long commitIndex) {
+ public void setCommitIndex(long commitIndex) {
this.commitIndex = commitIndex;
}
- public void setLastApplied(Long lastApplied) {
+ public void setLastApplied(long lastApplied) {
this.lastApplied = lastApplied;
}
return JMX_CATEGORY_SHARD;
}
+ /**
+ * resets the counters related to transactions
+ */
+
+ public void resetTransactionCounters(){
+ committedTransactionsCount = 0L;
+
+ readOnlyTransactionCount = 0L;
+
+ writeOnlyTransactionCount = 0L;
+
+ readWriteTransactionCount = 0L;
+
+ lastCommittedTransactionTime = new Date(0L);
+
+ failedTransactionsCount = 0L;
+
+ failedReadTransactionsCount = 0L;
+
+ abortTransactionsCount = 0L;
- public void incrementFailedTransactionsCount() {
- this.failedTransactionsCount++;
}
+
+
}
public interface ShardStatsMBean {
String getShardName();
- Long getCommittedTransactionsCount();
+ long getCommittedTransactionsCount();
String getLeader();
String getRaftState();
- Long getReadOnlyTransactionCount();
+ long getReadOnlyTransactionCount();
- Long getWriteOnlyTransactionCount();
+ long getWriteOnlyTransactionCount();
- Long getReadWriteTransactionCount();
+ long getReadWriteTransactionCount();
- Long getLastLogIndex();
+ long getLastLogIndex();
- Long getLastLogTerm();
+ long getLastLogTerm();
- Long getCurrentTerm();
+ long getCurrentTerm();
- Long getCommitIndex();
+ long getCommitIndex();
- Long getLastApplied();
+ long getLastApplied();
String getLastCommittedTransactionTime();
- Long getFailedTransactionsCount();
+ long getFailedTransactionsCount();
+
+ long getFailedReadTransactionsCount();
+
+ long getAbortTransactionsCount();
+
+ void resetTransactionCounters();
}
.shardName("inventory").type("config").build();
final SchemaContext schemaContext = TestModel.createTestContext();
- ShardContext shardContext = new ShardContext();
+ DatastoreContext datastoreContext = new DatastoreContext();
- final Props props = Shard.props(identifier, Collections.EMPTY_MAP, shardContext);
+ final Props props = Shard.props(identifier, Collections.EMPTY_MAP, datastoreContext);
final ActorRef shard = getSystem().actorOf(props);
new Within(duration("10 seconds")) {
new JavaTestKit(system) {{
final Props props = ShardManager
.props("config", new MockClusterWrapper(),
- new MockConfiguration(), new ShardContext());
+ new MockConfiguration(), new DatastoreContext());
final TestActorRef<ShardManager> subject =
TestActorRef.create(system, props);
new JavaTestKit(system) {{
final Props props = ShardManager
.props("config", new MockClusterWrapper(),
- new MockConfiguration(), new ShardContext());
+ new MockConfiguration(), new DatastoreContext());
final TestActorRef<ShardManager> subject =
TestActorRef.create(system, props);
new JavaTestKit(system) {{
final Props props = ShardManager
.props("config", new MockClusterWrapper(),
- new MockConfiguration(), new ShardContext());
+ new MockConfiguration(), new DatastoreContext());
final TestActorRef<ShardManager> subject =
TestActorRef.create(system, props);
new JavaTestKit(system) {{
final Props props = ShardManager
.props("config", mockClusterWrapper,
- new MockConfiguration(), new ShardContext());
+ new MockConfiguration(), new DatastoreContext());
final TestActorRef<ShardManager> subject =
TestActorRef.create(system, props);
new JavaTestKit(system) {{
final Props props = ShardManager
.props("config", new MockClusterWrapper(),
- new MockConfiguration(), new ShardContext());
+ new MockConfiguration(), new DatastoreContext());
final TestActorRef<ShardManager> subject =
TestActorRef.create(system, props);
new JavaTestKit(system) {{
final Props props = ShardManager
.props("config", new MockClusterWrapper(),
- new MockConfiguration(), new ShardContext());
+ new MockConfiguration(), new DatastoreContext());
final TestActorRef<ShardManager> subject =
TestActorRef.create(system, props);
public class ShardTest extends AbstractActorTest {
- private static final ShardContext shardContext = new ShardContext();
+ private static final DatastoreContext DATA_STORE_CONTEXT = new DatastoreContext();
@Test
public void testOnReceiveCreateTransactionChain() throws Exception {
ShardIdentifier.builder().memberName("member-1")
.shardName("inventory").type("config").build();
- final Props props = Shard.props(identifier, Collections.EMPTY_MAP, shardContext);
+ final Props props = Shard.props(identifier, Collections.EMPTY_MAP, DATA_STORE_CONTEXT);
final ActorRef subject =
getSystem().actorOf(props, "testCreateTransactionChain");
ShardIdentifier.builder().memberName("member-1")
.shardName("inventory").type("config").build();
- final Props props = Shard.props(identifier, Collections.EMPTY_MAP, shardContext);
+ final Props props = Shard.props(identifier, Collections.EMPTY_MAP, DATA_STORE_CONTEXT);
final ActorRef subject =
getSystem().actorOf(props, "testRegisterChangeListener");
ShardIdentifier.builder().memberName("member-1")
.shardName("inventory").type("config").build();
- final Props props = Shard.props(identifier, Collections.EMPTY_MAP, shardContext);
+ final Props props = Shard.props(identifier, Collections.EMPTY_MAP, DATA_STORE_CONTEXT);
final ActorRef subject =
getSystem().actorOf(props, "testCreateTransaction");
.shardName("inventory").type("config").build();
peerAddresses.put(identifier, null);
- final Props props = Shard.props(identifier, peerAddresses, shardContext);
+ final Props props = Shard.props(identifier, peerAddresses, DATA_STORE_CONTEXT);
final ActorRef subject =
getSystem().actorOf(props, "testPeerAddressResolved");
private static final SchemaContext testSchemaContext = TestModel.createTestContext();
- private static final ShardContext shardContext = new ShardContext();
+ private static final DatastoreContext DATA_STORE_CONTEXT = new DatastoreContext();
+
+ private static final String mockShardName = "mockShardName";
@BeforeClass
public static void staticSetup() {
public void testOnReceiveCreateTransaction() throws Exception {
new JavaTestKit(getSystem()) {{
final Props props = ShardTransactionChain.props(store.createTransactionChain(),
- testSchemaContext, shardContext);
+ testSchemaContext, DATA_STORE_CONTEXT, mockShardName);
final ActorRef subject = getSystem().actorOf(props, "testCreateTransaction");
new Within(duration("1 seconds")) {
public void testOnReceiveCloseTransactionChain() throws Exception {
new JavaTestKit(getSystem()) {{
final Props props = ShardTransactionChain.props(store.createTransactionChain(),
- testSchemaContext, shardContext);
+ testSchemaContext, DATA_STORE_CONTEXT,mockShardName );
final ActorRef subject = getSystem().actorOf(props, "testCloseTransactionChain");
new Within(duration("1 seconds")) {
ShardIdentifier.builder().memberName("member-1")
.shardName("inventory").type("operational").build();
- private final ShardContext shardContext = new ShardContext();
+ private final DatastoreContext datastoreContext = new DatastoreContext();
@BeforeClass
public static void staticSetup() {
throws Throwable {
final ActorRef shard =
- getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, new ShardContext()));
+ getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, new DatastoreContext()));
final Props props = ShardTransaction.props(store.newReadOnlyTransaction(), shard,
- testSchemaContext, shardContext);
+ testSchemaContext, datastoreContext,SHARD_IDENTIFIER.toString());
final TestActorRef<ShardTransaction> subject = TestActorRef
.create(getSystem(), props,
throws Throwable {
final ActorRef shard =
- getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, new ShardContext()));
+ getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, new DatastoreContext()));
final Props props = ShardTransaction.props(store.newReadWriteTransaction(), shard,
- testSchemaContext, shardContext);
+ testSchemaContext, datastoreContext,SHARD_IDENTIFIER.toString());
final TestActorRef<ShardTransaction> subject = TestActorRef
.create(getSystem(), props,
throws Throwable {
final ActorRef shard =
- getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, new ShardContext()));
+ getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, new DatastoreContext()));
final Props props = ShardTransaction.props(store.newReadWriteTransaction(), shard,
- testSchemaContext, shardContext);
+ testSchemaContext, datastoreContext,SHARD_IDENTIFIER.toString());
final TestActorRef<ShardTransaction> subject = TestActorRef
.create(getSystem(), props,
final ActorRef shard =
- getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, new ShardContext()));
+ getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, new DatastoreContext()));
final Props props = ShardTransaction.props(store.newWriteOnlyTransaction(), shard,
- testSchemaContext, shardContext);
+ testSchemaContext, datastoreContext,SHARD_IDENTIFIER.toString());
final TestActorRef<ShardTransaction> subject = TestActorRef
.create(getSystem(), props,
final ActorRef shard =
- getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, new ShardContext()));
+ getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, new DatastoreContext()));
final Props props = ShardTransaction.props(store.newReadWriteTransaction(), shard,
- testSchemaContext, shardContext);
+ testSchemaContext, datastoreContext,SHARD_IDENTIFIER.toString());
final TestActorRef<ShardTransaction> subject = TestActorRef
.create(getSystem(), props,
final ActorRef shard =
- getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, new ShardContext()));
+ getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, new DatastoreContext()));
final Props props = ShardTransaction.props(store.newReadWriteTransaction(), shard,
- testSchemaContext, shardContext);
+ testSchemaContext, datastoreContext,SHARD_IDENTIFIER.toString());
final TestActorRef<ShardTransaction> subject = TestActorRef
.create(getSystem(), props, "testNegativeMergeTransactionReady");
final ActorRef shard =
- getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, new ShardContext()));
+ getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, new DatastoreContext()));
final Props props = ShardTransaction.props(store.newReadWriteTransaction(), shard,
- testSchemaContext, shardContext);
+ testSchemaContext, datastoreContext,SHARD_IDENTIFIER.toString());
final TestActorRef<ShardTransaction> subject = TestActorRef
.create(getSystem(), props,
ShardIdentifier.builder().memberName("member-1")
.shardName("inventory").type("config").build();
- private ShardContext shardContext = new ShardContext();
+ private DatastoreContext datastoreContext = new DatastoreContext();
@BeforeClass
public static void staticSetup() {
public void testOnReceiveReadData() throws Exception {
new JavaTestKit(getSystem()) {{
final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER,
- Collections.EMPTY_MAP, new ShardContext()));
+ Collections.EMPTY_MAP, new DatastoreContext()));
final Props props = ShardTransaction.props(store.newReadOnlyTransaction(), shard,
- testSchemaContext, shardContext);
+ testSchemaContext, datastoreContext,SHARD_IDENTIFIER.toString());
final ActorRef subject = getSystem().actorOf(props, "testReadData");
new Within(duration("1 seconds")) {
public void testOnReceiveReadDataWhenDataNotFound() throws Exception {
new JavaTestKit(getSystem()) {{
final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER,
- Collections.EMPTY_MAP, new ShardContext()));
+ Collections.EMPTY_MAP, new DatastoreContext()));
final Props props = ShardTransaction.props( store.newReadOnlyTransaction(), shard,
- testSchemaContext, shardContext);
+ testSchemaContext, datastoreContext,SHARD_IDENTIFIER.toString());
final ActorRef subject = getSystem().actorOf(props, "testReadDataWhenDataNotFound");
new Within(duration("1 seconds")) {
public void testOnReceiveDataExistsPositive() throws Exception {
new JavaTestKit(getSystem()) {{
final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER,
- Collections.EMPTY_MAP, new ShardContext()));
+ Collections.EMPTY_MAP, new DatastoreContext()));
final Props props = ShardTransaction.props(store.newReadOnlyTransaction(), shard,
- testSchemaContext, shardContext);
+ testSchemaContext, datastoreContext,SHARD_IDENTIFIER.toString());
final ActorRef subject = getSystem().actorOf(props, "testDataExistsPositive");
new Within(duration("1 seconds")) {
public void testOnReceiveDataExistsNegative() throws Exception {
new JavaTestKit(getSystem()) {{
final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER,
- Collections.EMPTY_MAP, new ShardContext()));
+ Collections.EMPTY_MAP, new DatastoreContext()));
final Props props = ShardTransaction.props(store.newReadOnlyTransaction(), shard,
- testSchemaContext, shardContext);
+ testSchemaContext, datastoreContext,SHARD_IDENTIFIER.toString());
final ActorRef subject = getSystem().actorOf(props, "testDataExistsNegative");
new Within(duration("1 seconds")) {
public void testOnReceiveWriteData() throws Exception {
new JavaTestKit(getSystem()) {{
final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER,
- Collections.EMPTY_MAP, new ShardContext()));
+ Collections.EMPTY_MAP, new DatastoreContext()));
final Props props = ShardTransaction.props(store.newWriteOnlyTransaction(), shard,
- testSchemaContext, shardContext);
+ testSchemaContext, datastoreContext,SHARD_IDENTIFIER.toString());
final ActorRef subject =
getSystem().actorOf(props, "testWriteData");
public void testOnReceiveMergeData() throws Exception {
new JavaTestKit(getSystem()) {{
final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER,
- Collections.EMPTY_MAP, new ShardContext()));
+ Collections.EMPTY_MAP, new DatastoreContext()));
final Props props = ShardTransaction.props(store.newReadWriteTransaction(), shard,
- testSchemaContext, shardContext);
+ testSchemaContext, datastoreContext,SHARD_IDENTIFIER.toString());
final ActorRef subject =
getSystem().actorOf(props, "testMergeData");
public void testOnReceiveDeleteData() throws Exception {
new JavaTestKit(getSystem()) {{
final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER,
- Collections.EMPTY_MAP, new ShardContext()));
+ Collections.EMPTY_MAP, new DatastoreContext()));
final Props props = ShardTransaction.props( store.newWriteOnlyTransaction(), shard,
- testSchemaContext, shardContext);
+ testSchemaContext, datastoreContext,SHARD_IDENTIFIER.toString());
final ActorRef subject =
getSystem().actorOf(props, "testDeleteData");
public void testOnReceiveReadyTransaction() throws Exception {
new JavaTestKit(getSystem()) {{
final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER,
- Collections.EMPTY_MAP, new ShardContext()));
+ Collections.EMPTY_MAP, new DatastoreContext()));
final Props props = ShardTransaction.props( store.newReadWriteTransaction(), shard,
- testSchemaContext, shardContext);
+ testSchemaContext, datastoreContext,SHARD_IDENTIFIER.toString());
final ActorRef subject =
getSystem().actorOf(props, "testReadyTransaction");
public void testOnReceiveCloseTransaction() throws Exception {
new JavaTestKit(getSystem()) {{
final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER,
- Collections.EMPTY_MAP, new ShardContext()));
+ Collections.EMPTY_MAP, new DatastoreContext()));
final Props props = ShardTransaction.props(store.newReadWriteTransaction(), shard,
- testSchemaContext, shardContext);
+ testSchemaContext, datastoreContext,SHARD_IDENTIFIER.toString());
final ActorRef subject =
getSystem().actorOf(props, "testCloseTransaction");
@Test(expected=UnknownMessageException.class)
public void testNegativePerformingWriteOperationOnReadTransaction() throws Exception {
final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER,
- Collections.EMPTY_MAP, new ShardContext()));
+ Collections.EMPTY_MAP, new DatastoreContext()));
final Props props = ShardTransaction.props(store.newReadOnlyTransaction(), shard,
- testSchemaContext, shardContext);
+ testSchemaContext, datastoreContext,SHARD_IDENTIFIER.toString());
final TestActorRef subject = TestActorRef.apply(props,getSystem());
subject.receive(new DeleteData(TestModel.TEST_PATH).toSerializable(), ActorRef.noSender());
@Test
public void testShardTransactionInactivity() {
- shardContext = new ShardContext(InMemoryDOMDataStoreConfigProperties.getDefault(),
+ datastoreContext = new DatastoreContext(InMemoryDOMDataStoreConfigProperties.getDefault(),
Duration.create(500, TimeUnit.MILLISECONDS));
new JavaTestKit(getSystem()) {{
final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER,
- Collections.EMPTY_MAP, new ShardContext()));
+ Collections.EMPTY_MAP, new DatastoreContext()));
final Props props = ShardTransaction.props(store.newReadWriteTransaction(), shard,
- testSchemaContext, shardContext);
+ testSchemaContext, datastoreContext,SHARD_IDENTIFIER.toString());
final ActorRef subject =
getSystem().actorOf(props, "testShardTransactionInactivity");
ShardIdentifier.builder().memberName("member-1")
.shardName("inventory").type("config").build();
- private final ShardContext shardContext = new ShardContext();
+ private final DatastoreContext datastoreContext = new DatastoreContext();
+
@BeforeClass
public static void staticSetup() {
public void testNegativeAbortResultsInException() throws Exception {
final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER,
- Collections.EMPTY_MAP, shardContext));
+ Collections.EMPTY_MAP, datastoreContext));
final DOMStoreThreePhaseCommitCohort mockCohort = Mockito
.mock(DOMStoreThreePhaseCommitCohort.class);
final CompositeModification mockComposite =
Mockito.mock(CompositeModification.class);
final Props props =
- ThreePhaseCommitCohort.props(mockCohort, shard, mockComposite);
+ ThreePhaseCommitCohort.props(mockCohort, shard, mockComposite,SHARD_IDENTIFIER.toString());
final TestActorRef<ThreePhaseCommitCohort> subject = TestActorRef
.create(getSystem(), props,
public void testNegativeCanCommitResultsInException() throws Exception {
final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER,
- Collections.EMPTY_MAP, shardContext));
+ Collections.EMPTY_MAP, datastoreContext));
final DOMStoreThreePhaseCommitCohort mockCohort = Mockito
.mock(DOMStoreThreePhaseCommitCohort.class);
final CompositeModification mockComposite =
Mockito.mock(CompositeModification.class);
final Props props =
- ThreePhaseCommitCohort.props(mockCohort, shard, mockComposite);
+ ThreePhaseCommitCohort.props(mockCohort, shard, mockComposite,SHARD_IDENTIFIER.toString());
final TestActorRef<ThreePhaseCommitCohort> subject = TestActorRef
.create(getSystem(), props,
public void testNegativePreCommitResultsInException() throws Exception {
final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER,
- Collections.EMPTY_MAP, shardContext));
+ Collections.EMPTY_MAP, datastoreContext));
final DOMStoreThreePhaseCommitCohort mockCohort = Mockito
.mock(DOMStoreThreePhaseCommitCohort.class);
final CompositeModification mockComposite =
Mockito.mock(CompositeModification.class);
final Props props =
- ThreePhaseCommitCohort.props(mockCohort, shard, mockComposite);
+ ThreePhaseCommitCohort.props(mockCohort, shard, mockComposite,SHARD_IDENTIFIER.toString());
final TestActorRef<ThreePhaseCommitCohort> subject = TestActorRef
.create(getSystem(), props,
public void testNegativeCommitResultsInException() throws Exception {
final TestActorRef<Shard> subject = TestActorRef.create(getSystem(),
- Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, shardContext),
+ Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, datastoreContext),
"testNegativeCommitResultsInException");
final ActorRef shardTransaction =
getSystem().actorOf(ShardTransaction.props(store.newReadWriteTransaction(), subject,
- testSchemaContext, shardContext));
+ testSchemaContext, datastoreContext,SHARD_IDENTIFIER.toString()));
ShardTransactionMessages.WriteData writeData =
ShardTransactionMessages.WriteData.newBuilder()
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
package org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard;
import org.junit.After;
Object attribute =
mbeanServer.getAttribute(testMBeanName, "FailedTransactionsCount");
Assert.assertEquals((Long) attribute, (Long) 2L);
+ }
+
+ @Test
+ public void testGetAbortTransactionsCount() throws Exception {
+ //let us increment AbortTransactions count and then check
+ shardStats.incrementAbortTransactionsCount();
+ shardStats.incrementAbortTransactionsCount();
+
+
+ //now let us get from MBeanServer what is the transaction count.
+ Object attribute =
+ mbeanServer.getAttribute(testMBeanName, "AbortTransactionsCount");
+ Assert.assertEquals((Long) attribute, (Long) 2L);
+ }
+
+ @Test
+ public void testGetFailedReadTransactionsCount() throws Exception {
+ //let us increment FailedReadTransactions count and then check
+ shardStats.incrementFailedReadTransactionsCount();
+ shardStats.incrementFailedReadTransactionsCount();
+
+
+ //now let us get from MBeanServer what is the transaction count.
+ Object attribute =
+ mbeanServer.getAttribute(testMBeanName, "FailedReadTransactionsCount");
+ Assert.assertEquals((Long) attribute, (Long) 2L);
+ }
+
+ @Test
+ public void testResetTransactionCounters() throws Exception {
+
+ //let us increment committed transactions count and then check
+ shardStats.incrementCommittedTransactionCount();
+ shardStats.incrementCommittedTransactionCount();
+ shardStats.incrementCommittedTransactionCount();
+
+ //now let us get from MBeanServer what is the transaction count.
+ Object attribute = mbeanServer.getAttribute(testMBeanName,
+ "CommittedTransactionsCount");
+ Assert.assertEquals((Long) attribute, (Long) 3L);
+
+ //let us increment FailedReadTransactions count and then check
+ shardStats.incrementFailedReadTransactionsCount();
+ shardStats.incrementFailedReadTransactionsCount();
+
+
+ //now let us get from MBeanServer what is the transaction count.
+ attribute =
+ mbeanServer.getAttribute(testMBeanName, "FailedReadTransactionsCount");
+ Assert.assertEquals((Long) attribute, (Long) 2L);
+
+
+ //here we will reset the counters and check the above ones are 0 after reset
+ mbeanServer.invoke(testMBeanName, "resetTransactionCounters", null, null);
+
+ //now let us get from MBeanServer what is the transaction count.
+ attribute = mbeanServer.getAttribute(testMBeanName,
+ "CommittedTransactionsCount");
+ Assert.assertEquals((Long) attribute, (Long) 0L);
+ attribute =
+ mbeanServer.getAttribute(testMBeanName, "FailedReadTransactionsCount");
+ Assert.assertEquals((Long) attribute, (Long) 0L);
}
QName childNode = NetconfMessageTransformUtil.IETF_NETCONF_MONITORING_SCHEMA_FORMAT.withoutRevision();
- final String formatAsString = getSingleChildNodeValue(schemaNode, childNode).get();
+ String formatAsString = getSingleChildNodeValue(schemaNode, childNode).get();
+ //This is HotFix for situations where format statement in netconf-monitoring might be passed with prefix.
+ if (formatAsString.contains(":")) {
+ String[] prefixedString = formatAsString.split(":");
+ //FIXME: might be good idea to check prefix against model namespace
+ formatAsString = prefixedString[1];
+ }
if(formatAsString.equals(Yang.QNAME.getLocalName()) == false) {
logger.debug("{}: Ignoring schema due to unsupported format: {}", id, formatAsString);
return Optional.absent();
import java.io.OutputStreamWriter;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
+import java.net.URI;
+import java.util.Iterator;
import javax.ws.rs.Produces;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
import org.opendaylight.controller.sal.restconf.impl.InstanceIdentifierContext;
import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext;
import org.opendaylight.controller.sal.restconf.impl.RestconfDocumentedException;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
+import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
+import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
+import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
+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.codec.gson.JSONNormalizedNodeStreamWriter;
+import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
@Provider
@Produces({ Draft02.MediaTypes.API + RestconfService.JSON, Draft02.MediaTypes.DATA + RestconfService.JSON,
public void writeTo(final NormalizedNodeContext t, final Class<?> type, final Type genericType, final Annotation[] annotations,
final MediaType mediaType, final MultivaluedMap<String, Object> httpHeaders, final OutputStream entityStream)
throws IOException, WebApplicationException {
- if (t.getData() == null) {
+ NormalizedNode<?, ?> data = t.getData();
+ InstanceIdentifierContext context = t.getInstanceIdentifierContext();
+ DataSchemaNode schema = context.getSchemaNode();
+ SchemaPath path = context.getSchemaNode().getPath();
+ OutputStreamWriter outputWriter = new OutputStreamWriter(entityStream, Charsets.UTF_8);
+ if (data == null) {
throw new RestconfDocumentedException(Response.Status.NOT_FOUND);
}
- InstanceIdentifierContext pathContext = t.getInstanceIdentifierContext();
- OutputStreamWriter ouWriter = new OutputStreamWriter(entityStream, Charsets.UTF_8);
- NormalizedNodeStreamWriter jsonWriter = JSONNormalizedNodeStreamWriter.create(pathContext.getSchemaContext(),ouWriter);
+ boolean isDataRoot = false;
+ URI initialNs = null;
+ outputWriter.write('{');
+ if (SchemaPath.ROOT.equals(path)) {
+ isDataRoot = true;
+ } else {
+ path = path.getParent();
+ // FIXME: Add proper handling of reading root.
+ }
+ if(!schema.isAugmenting() && !(schema instanceof SchemaContext)) {
+ initialNs = schema.getQName().getNamespace();
+ }
+ NormalizedNodeStreamWriter jsonWriter = JSONNormalizedNodeStreamWriter.create(context.getSchemaContext(),path,initialNs,outputWriter);
NormalizedNodeWriter nnWriter = NormalizedNodeWriter.forStreamWriter(jsonWriter);
-
- nnWriter.write(t.getData());
+ if(isDataRoot) {
+ writeDataRoot(outputWriter,nnWriter,(ContainerNode) data);
+ } else {
+ if(data instanceof MapEntryNode) {
+ data = ImmutableNodes.mapNodeBuilder(data.getNodeType()).withChild(((MapEntryNode) data)).build();
+ }
+ nnWriter.write(data);
+ }
nnWriter.flush();
+ outputWriter.write('}');
+ outputWriter.flush();
}
+
+ private void writeDataRoot(OutputStreamWriter outputWriter, NormalizedNodeWriter nnWriter, ContainerNode data) throws IOException {
+ Iterator<DataContainerChild<? extends PathArgument, ?>> iterator = data.getValue().iterator();
+ while(iterator.hasNext()) {
+ DataContainerChild<? extends PathArgument, ?> child = iterator.next();
+ nnWriter.write(child);
+ nnWriter.flush();
+ if(iterator.hasNext()) {
+ outputWriter.write(",");
+ }
+ }
+ }
+
}
*/
package org.opendaylight.controller.sal.rest.impl;
+import com.google.common.base.Throwables;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.annotation.Annotation;
import org.opendaylight.controller.sal.restconf.impl.InstanceIdentifierContext;
import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext;
import org.opendaylight.controller.sal.restconf.impl.RestconfDocumentedException;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
+import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
+import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
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.codec.xml.XMLStreamNormalizedNodeStreamWriter;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
@Provider
@Produces({ Draft02.MediaTypes.API + RestconfService.XML, Draft02.MediaTypes.DATA + RestconfService.XML,
- Draft02.MediaTypes.OPERATION + RestconfService.XML, MediaType.APPLICATION_XML, MediaType.TEXT_XML })
-
+ Draft02.MediaTypes.OPERATION + RestconfService.XML, MediaType.APPLICATION_XML, MediaType.TEXT_XML })
public class NormalizedNodeXmlBodyWriter implements MessageBodyWriter<NormalizedNodeContext> {
-
private static final XMLOutputFactory XML_FACTORY;
static {
- XML_FACTORY = XMLOutputFactory.newFactory();
+ XML_FACTORY = XMLOutputFactory.newFactory();
XML_FACTORY.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, true);
}
-
@Override
- public boolean isWriteable(final Class<?> type, final Type genericType, final Annotation[] annotations, final MediaType mediaType) {
+ public boolean isWriteable(final Class<?> type, final Type genericType, final Annotation[] annotations,
+ final MediaType mediaType) {
return type.equals(NormalizedNodeContext.class);
}
@Override
- public long getSize(final NormalizedNodeContext t, final Class<?> type, final Type genericType, final Annotation[] annotations, final MediaType mediaType) {
+ public long getSize(final NormalizedNodeContext t, final Class<?> type, final Type genericType,
+ final Annotation[] annotations, final MediaType mediaType) {
return -1;
}
@Override
- public void writeTo(final NormalizedNodeContext t, final Class<?> type, final Type genericType, final Annotation[] annotations,
- final MediaType mediaType, final MultivaluedMap<String, Object> httpHeaders, final OutputStream entityStream)
- throws IOException, WebApplicationException {
+ public void writeTo(final NormalizedNodeContext t, final Class<?> type, final Type genericType,
+ final Annotation[] annotations, final MediaType mediaType,
+ final MultivaluedMap<String, Object> httpHeaders, final OutputStream entityStream) throws IOException,
+ WebApplicationException {
InstanceIdentifierContext pathContext = t.getInstanceIdentifierContext();
if (t.getData() == null) {
throw new RestconfDocumentedException(Response.Status.NOT_FOUND);
throw new IllegalStateException(e);
}
NormalizedNode<?, ?> data = t.getData();
- SchemaPath schemaPath = pathContext.getSchemaNode().getPath().getParent();
- if(data instanceof MapEntryNode) {
- data = ImmutableNodes.mapNodeBuilder(data.getNodeType()).addChild((MapEntryNode) data).build();
- //schemaPath = pathContext.getSchemaNode().getPath();
+ SchemaPath schemaPath = pathContext.getSchemaNode().getPath();
+
+ boolean isDataRoot = false;
+ if (SchemaPath.ROOT.equals(schemaPath)) {
+ isDataRoot = true;
+ } else {
+ schemaPath = schemaPath.getParent();
}
- NormalizedNodeStreamWriter jsonWriter = XMLStreamNormalizedNodeStreamWriter.create(xmlWriter,pathContext.getSchemaContext(),schemaPath);
+ NormalizedNodeStreamWriter jsonWriter = XMLStreamNormalizedNodeStreamWriter.create(xmlWriter,
+ pathContext.getSchemaContext(), schemaPath);
NormalizedNodeWriter nnWriter = NormalizedNodeWriter.forStreamWriter(jsonWriter);
+ if (isDataRoot) {
+ writeRootElement(xmlWriter, nnWriter, (ContainerNode) data);
+ } else {
+ if (data instanceof MapEntryNode) {
+ // Restconf allows returning one list item. We need to wrap it
+ // in map node in order to serialize it properly
+ data = ImmutableNodes.mapNodeBuilder(data.getNodeType()).addChild((MapEntryNode) data).build();
+ }
+ nnWriter.write(data);
+ nnWriter.flush();
+ }
+ }
- nnWriter.write(data);
- nnWriter.flush();
+ private void writeRootElement(XMLStreamWriter xmlWriter, NormalizedNodeWriter nnWriter, ContainerNode data)
+ throws IOException {
+ try {
+ QName name = SchemaContext.NAME;
+ xmlWriter.writeStartElement(name.getNamespace().toString(), name.getLocalName());
+ for (DataContainerChild<? extends PathArgument, ?> child : data.getValue()) {
+ nnWriter.write(child);
+ }
+ nnWriter.flush();
+ xmlWriter.writeEndElement();
+ xmlWriter.flush();
+ } catch (XMLStreamException e) {
+ Throwables.propagate(e);
+ }
}
}
}
protected abstract void cleanupSingleStat(DataModificationTransaction trans, K item);
protected abstract K updateSingleStat(DataModificationTransaction trans, I item);
+ protected abstract K createInvariantKey(K item);
public abstract void request();
public final synchronized void updateStats(List<I> list) {
final DataModificationTransaction trans = startTransaction();
-
for (final I item : list) {
- trackedItems.put(updateSingleStat(trans, item), requestCounter);
+ K key = updateSingleStat(trans, item);
+ trackedItems.put(createInvariantKey(key), requestCounter);
}
trans.commit();
return false;
return true;
}
+
+ @Override
+ public String toString() {
+ return "FlowStatsEntry [tableId=" + tableId + ", flow=" + flow + "]";
+ }
}
}
return flowCookieMap;
}
+
+ @Override
+ protected FlowStatsEntry createInvariantKey(final FlowStatsEntry item) {
+ FlowBuilder newFlow = new FlowBuilder();
+ newFlow.setId(item.getFlow().getId());
+ newFlow.setKey(item.getFlow().getKey());
+ newFlow.fieldsFrom(item.getFlow());
+ return new FlowStatsEntry(item.getTableId(),newFlow.build());
+ }
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMapBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.statistics.FlowTableStatistics;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.statistics.FlowTableStatisticsBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
requestHelper(flowTableStatsService.getFlowTablesStatistics(input.build()));
}
}
+
+ @Override
+ protected FlowTableAndStatisticsMap createInvariantKey(FlowTableAndStatisticsMap item) {
+ FlowTableAndStatisticsMapBuilder flowTableAndStatisticsMapBuilder = new FlowTableAndStatisticsMapBuilder();
+ flowTableAndStatisticsMapBuilder.setTableId(item.getTableId());
+ flowTableAndStatisticsMapBuilder.setKey(item.getKey());
+ return flowTableAndStatisticsMapBuilder.build();
+ }
}
super.start(dbs);
}
+
+ @Override
+ protected GroupDescStats createInvariantKey(GroupDescStats item) {
+ // No invariant data exist in the group description stats.
+ return item;
+ }
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.OpendaylightGroupStatisticsService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.group.statistics.GroupStatisticsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStatsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey;
super.start(dbs);
}
+
+ @Override
+ protected GroupStats createInvariantKey(GroupStats item) {
+ GroupStatsBuilder groupStatsBuilder = new GroupStatsBuilder();
+ groupStatsBuilder.setKey(item.getKey());
+ groupStatsBuilder.setGroupId(item.getGroupId());
+ return groupStatsBuilder.build();
+ }
}
super.start(dbs);
}
+
+ @Override
+ protected MeterConfigStats createInvariantKey(MeterConfigStats item) {
+ // No invariant data exist in the meter config stats.
+ return item;
+ }
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.OpendaylightMeterStatisticsService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.nodes.node.meter.MeterStatisticsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStatsBuilder;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
super.start(dbs);
}
+
+ @Override
+ protected MeterStats createInvariantKey(MeterStats item) {
+ MeterStatsBuilder meterStatsBuilder = new MeterStatsBuilder();
+ meterStatsBuilder.setKey(item.getKey());
+ meterStatsBuilder.setMeterId(item.getMeterId());
+ return meterStatsBuilder.build();
+ }
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.flow.capable.node.connector.statistics.FlowCapableNodeConnectorStatisticsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
requestHelper(portStatsService.getAllNodeConnectorsStatistics(input.build()));
}
}
+
+ @Override
+ protected NodeConnectorStatisticsAndPortNumberMap createInvariantKey(NodeConnectorStatisticsAndPortNumberMap item) {
+ NodeConnectorStatisticsAndPortNumberMapBuilder ncStatsBuilder = new NodeConnectorStatisticsAndPortNumberMapBuilder();
+ ncStatsBuilder.setNodeConnectorId(item.getNodeConnectorId());
+ ncStatsBuilder.setKey(item.getKey());
+ return ncStatsBuilder.build();
+ }
}
super.start(dbs);
}
+
+ @Override
+ protected QueueStatsEntry createInvariantKey(QueueStatsEntry item) {
+ // No invariant data exist in the group description stats.
+ return item;
+ }
}
public void applyOperation(final ReadWriteTransaction transaction) {
final Link link = toTopologyLink(notification);
final InstanceIdentifier<Link> path = linkPath(link);
- transaction.put(LogicalDatastoreType.OPERATIONAL, path, link);
+ transaction.merge(LogicalDatastoreType.OPERATIONAL, path, link, true);
}
});
}
this.portUUID = portUUID;
}
+ public String getID() {
+ return id;
+ }
+
public void setID(String id) {
this.id = id;
}