With the changes in ask protocol due to to tell based
integration, shards stats had incorrectly reported
write transaction counts. Since backend doesnt care
about the difference between write-only and read-write
transactions and all are read-write from backend point of view
we can safely remove writeOnly counter.
Change-Id: I18046ad3b229755bbd0daa788a3fe62f59e4140d
Signed-off-by: Tomas Cere <tomas.cere@pantheon.tech>
}
ReadOnlyShardDataTreeTransaction newReadOnlyTransaction(final TransactionIdentifier txId) {
}
ReadOnlyShardDataTreeTransaction newReadOnlyTransaction(final TransactionIdentifier txId) {
+ shard.getShardMBean().incrementReadOnlyTransactionCount();
+
if (txId.getHistoryId().getHistoryId() == 0) {
return new ReadOnlyShardDataTreeTransaction(this, txId, dataTree.takeSnapshot());
}
if (txId.getHistoryId().getHistoryId() == 0) {
return new ReadOnlyShardDataTreeTransaction(this, txId, dataTree.takeSnapshot());
}
}
ReadWriteShardDataTreeTransaction newReadWriteTransaction(final TransactionIdentifier txId) {
}
ReadWriteShardDataTreeTransaction newReadWriteTransaction(final TransactionIdentifier txId) {
+ shard.getShardMBean().incrementReadWriteTransactionCount();
+
if (txId.getHistoryId().getHistoryId() == 0) {
return new ReadWriteShardDataTreeTransaction(ShardDataTree.this, txId, dataTree.takeSnapshot()
.newModification());
if (txId.getHistoryId().getHistoryId() == 0) {
return new ReadWriteShardDataTreeTransaction(ShardDataTree.this, txId, dataTree.takeSnapshot()
.newModification());
switch (type) {
case READ_ONLY:
transaction = dataTree.newReadOnlyTransaction(transactionID);
switch (type) {
case READ_ONLY:
transaction = dataTree.newReadOnlyTransaction(transactionID);
- shardMBean.incrementReadOnlyTransactionCount();
- transaction = dataTree.newReadWriteTransaction(transactionID);
- shardMBean.incrementReadWriteTransactionCount();
- break;
case WRITE_ONLY:
transaction = dataTree.newReadWriteTransaction(transactionID);
case WRITE_ONLY:
transaction = dataTree.newReadWriteTransaction(transactionID);
- shardMBean.incrementWriteOnlyTransactionCount();
break;
default:
throw new IllegalArgumentException("Unsupported transaction type " + type);
break;
default:
throw new IllegalArgumentException("Unsupported transaction type " + type);
private long readOnlyTransactionCount;
private long readOnlyTransactionCount;
- private long writeOnlyTransactionCount;
-
private long readWriteTransactionCount;
private long lastCommittedTransactionTime;
private long readWriteTransactionCount;
private long lastCommittedTransactionTime;
return readOnlyTransactionCount;
}
return readOnlyTransactionCount;
}
- @Override
- public long getWriteOnlyTransactionCount() {
- return writeOnlyTransactionCount;
- }
-
@Override
public long getReadWriteTransactionCount() {
return readWriteTransactionCount;
@Override
public long getReadWriteTransactionCount() {
return readWriteTransactionCount;
return ++readOnlyTransactionCount;
}
return ++readOnlyTransactionCount;
}
- public long incrementWriteOnlyTransactionCount() {
- return ++writeOnlyTransactionCount;
- }
-
public long incrementReadWriteTransactionCount() {
return ++readWriteTransactionCount;
}
public long incrementReadWriteTransactionCount() {
return ++readWriteTransactionCount;
}
readOnlyTransactionCount = 0;
readOnlyTransactionCount = 0;
- writeOnlyTransactionCount = 0;
-
readWriteTransactionCount = 0;
lastCommittedTransactionTime = 0;
readWriteTransactionCount = 0;
lastCommittedTransactionTime = 0;
long getReadOnlyTransactionCount();
long getReadOnlyTransactionCount();
- long getWriteOnlyTransactionCount();
-
long getReadWriteTransactionCount();
long getLastLogIndex();
long getReadWriteTransactionCount();
long getLastLogIndex();
readWriteTx.write(CarsModel.newCarPath("car" + carIndex), cars.getLast());
IntegrationTestKit.verifyShardStats(leaderDistributedDataStore, "cars",
readWriteTx.write(CarsModel.newCarPath("car" + carIndex), cars.getLast());
IntegrationTestKit.verifyShardStats(leaderDistributedDataStore, "cars",
- stats -> assertEquals("getReadWriteTransactionCount", 1, stats.getReadWriteTransactionCount()));
+ stats -> assertEquals("getReadWriteTransactionCount", 5, stats.getReadWriteTransactionCount()));
// Disable elections on the leader so it switches to follower.
// Disable elections on the leader so it switches to follower.
*/
package org.opendaylight.controller.cluster.datastore;
*/
package org.opendaylight.controller.cluster.datastore;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
import akka.actor.ActorRef;
import akka.actor.Props;
import akka.testkit.TestActorRef;
import java.util.concurrent.TimeUnit;
import akka.actor.ActorRef;
import akka.actor.Props;
import akka.testkit.TestActorRef;
import java.util.concurrent.TimeUnit;
+import org.junit.Before;
-import org.mockito.Mockito;
import org.opendaylight.controller.cluster.access.concepts.MemberName;
import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier;
import org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard.ShardStats;
import org.opendaylight.controller.cluster.access.concepts.MemberName;
import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier;
import org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard.ShardStats;
private static final TransactionType RO = TransactionType.READ_ONLY;
private static final TransactionType RW = TransactionType.READ_WRITE;
private static final TransactionType RO = TransactionType.READ_ONLY;
private static final TransactionType RW = TransactionType.READ_WRITE;
- private static final Shard MOCK_SHARD = Mockito.mock(Shard.class);
+ private static final Shard MOCK_SHARD = mock(Shard.class);
private static final ShardDataTree STORE = new ShardDataTree(MOCK_SHARD, TEST_SCHEMA_CONTEXT, TreeType.OPERATIONAL);
private static final ShardDataTree STORE = new ShardDataTree(MOCK_SHARD, TEST_SCHEMA_CONTEXT, TreeType.OPERATIONAL);
+ @Before
+ public void setup() {
+ ShardStats stats = mock(ShardStats.class);
+ when(MOCK_SHARD.getShardMBean()).thenReturn(stats);
+ }
+
@Test(expected = ReadFailedException.class)
public void testNegativeReadWithReadOnlyTransactionClosed() throws Exception {
@Test(expected = ReadFailedException.class)
public void testNegativeReadWithReadOnlyTransactionClosed() throws Exception {