<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>
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();
this.portUUID = portUUID;
}
+ public String getID() {
+ return id;
+ }
+
public void setID(String id) {
this.id = id;
}