IGNITE-7126 .NET: Add missing CacheMetrics
authorAlexey Rokhin <arokhin@mail.ru>
Thu, 11 Jan 2018 09:58:19 +0000 (12:58 +0300)
committerPavel Tupitsyn <ptupitsyn@apache.org>
Thu, 11 Jan 2018 09:58:19 +0000 (12:58 +0300)
This closes #3356

modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/CacheMetricsParityTest.cs
modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheMetricsTest.cs
modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICacheMetrics.cs
modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheMetricsImpl.cs

index bbdd6d2..86774c1 100644 (file)
@@ -1472,6 +1472,16 @@ public class PlatformCache extends PlatformAbstractTarget {
         writer.writeBoolean(metrics.isManagementEnabled());
         writer.writeBoolean(metrics.isReadThrough());
         writer.writeBoolean(metrics.isWriteThrough());
+        writer.writeBoolean(metrics.isValidForReading());
+        writer.writeBoolean(metrics.isValidForWriting());
+        writer.writeInt(metrics.getTotalPartitionsCount());
+        writer.writeInt(metrics.getRebalancingPartitionsCount());
+        writer.writeLong(metrics.getKeysToRebalanceLeft());
+        writer.writeLong(metrics.getRebalancingKeysRate());
+        writer.writeLong(metrics.getRebalancingBytesRate());
+        writer.writeLong(metrics.getHeapEntriesCount());
+        writer.writeLong(metrics.getEstimatedRebalancingFinishTime());
+        writer.writeLong(metrics.getRebalancingStartTime());
     }
 
     /**
index 7e8be1e..0a29b9f 100644 (file)
@@ -32,22 +32,6 @@ namespace Apache.Ignite.Core.Tests.ApiParity
             {"name", "CacheName"}
         };
 
-        /** Properties that are missing on .NET side. */
-        private static readonly string[] MissingProperties =
-        {
-            // IGNITE-7126
-            "HeapEntriesCount",
-            "TotalPartitionsCount",
-            "RebalancingPartitionsCount",
-            "KeysToRebalanceLeft",
-            "RebalancingKeysRate",
-            "RebalancingBytesRate",
-            "isValidForReading",
-            "isValidForWriting",
-            "EstimatedRebalancingFinishTime",
-            "RebalancingStartTime"
-        };
-
         /// <summary>
         /// Tests the API parity.
         /// </summary>
@@ -57,8 +41,7 @@ namespace Apache.Ignite.Core.Tests.ApiParity
             ParityTest.CheckInterfaceParity(
                 @"modules\core\src\main\java\org\apache\ignite\cache\CacheMetrics.java",
                 typeof(ICacheMetrics),
-                knownMappings: KnownMappings,
-                knownMissingMembers: MissingProperties);
+                knownMappings: KnownMappings);
         }
     }
 }
\ No newline at end of file
index 4b587a9..3f671d9 100644 (file)
@@ -40,7 +40,10 @@ namespace Apache.Ignite.Core.Tests.Cache
         public void FixtureSetUp()
         {
             Ignition.Start(TestUtils.GetTestConfiguration());
-            Ignition.Start(new IgniteConfiguration(TestUtils.GetTestConfiguration()) {IgniteInstanceName = SecondGridName });
+            Ignition.Start(new IgniteConfiguration(TestUtils.GetTestConfiguration())
+            {
+                IgniteInstanceName = SecondGridName
+            });
         }
 
         /// <summary>
@@ -192,6 +195,14 @@ namespace Apache.Ignite.Core.Tests.Cache
                 Assert.AreEqual(51, metrics.WriteBehindCriticalOverflowCount);
                 Assert.AreEqual(52, metrics.WriteBehindErrorRetryCount);
                 Assert.AreEqual(53, metrics.WriteBehindBufferSize);
+                Assert.AreEqual(54, metrics.TotalPartitionsCount);
+                Assert.AreEqual(55, metrics.RebalancingPartitionsCount);
+                Assert.AreEqual(56, metrics.KeysToRebalanceLeft);
+                Assert.AreEqual(57, metrics.RebalancingKeysRate);
+                Assert.AreEqual(58, metrics.RebalancingBytesRate);
+                Assert.AreEqual(59, metrics.HeapEntriesCount);
+                Assert.AreEqual(62, metrics.EstimatedRebalancingFinishTime);
+                Assert.AreEqual(63, metrics.RebalancingStartTime);
                 Assert.AreEqual("foo", metrics.KeyType);
                 Assert.AreEqual("bar", metrics.ValueType);
                 Assert.AreEqual(true, metrics.IsStoreByValue);
@@ -199,6 +210,8 @@ namespace Apache.Ignite.Core.Tests.Cache
                 Assert.AreEqual(true, metrics.IsManagementEnabled);
                 Assert.AreEqual(true, metrics.IsReadThrough);
                 Assert.AreEqual(true, metrics.IsWriteThrough);
+                Assert.AreEqual(true, metrics.IsValidForReading);
+                Assert.AreEqual(true, metrics.IsValidForWriting);
             }
         }
 
index 8289aaf..43a54c7 100644 (file)
@@ -554,5 +554,88 @@ namespace Apache.Ignite.Core.Cache
         /// True when a cache is in "write-through" mode.
         /// </returns>
         bool IsWriteThrough { get; }
+
+        /// <summary>
+        /// Checks whether cache topology is valid for read operations.
+        /// </summary>
+        /// <returns>
+        /// True when cache topology is valid for reading.
+        /// </returns>
+        bool IsValidForReading { get; }
+
+        /// <summary>
+        /// Checks whether cache topology is valid for write operations.
+        /// </summary>
+        /// <returns>
+        /// True when cache topology is valid for writing.
+        /// </returns>
+        bool IsValidForWriting { get; }
+
+        /// <summary>
+        /// Gets total number of partitions on current node.
+        /// </summary>
+        /// <returns>
+        /// Total number of partitions on current node.
+        /// </returns>
+        int TotalPartitionsCount { get; }
+
+        /// <summary>
+        /// Gets number of currently rebalancing partitions on current node.
+        /// </summary>
+        /// <returns>
+        /// Number of currently rebalancing partitions on current node.
+        /// </returns>
+        int RebalancingPartitionsCount { get; }
+
+        /// <summary>
+        /// Gets estimated number of keys to be rebalanced on current node.
+        /// </summary>
+        /// <returns>
+        /// Estimated number of keys to be rebalanced on current node.
+        /// </returns>
+        long KeysToRebalanceLeft { get; }
+
+        /// <summary>
+        /// Gets estimated rebalancing speed in keys.
+        /// </summary>
+        /// <returns>
+        /// Estimated rebalancing speed in keys.
+        /// </returns>
+        long RebalancingKeysRate { get; }
+
+        /// <summary>
+        /// Gets estimated rebalancing speed in bytes.
+        /// </summary>
+        /// <returns>
+        /// Estimated rebalancing speed in bytes.
+        /// </returns>
+        long RebalancingBytesRate { get; }
+
+        /// <summary>
+        /// Gets the number of cache entries in heap memory, including entries held by active transactions,
+        /// entries in onheap cache and near entries.
+        /// </summary>
+        /// <returns>
+        /// Number of entries in heap memory.
+        /// </returns>
+        long HeapEntriesCount { get; }
+
+        /// <summary>
+        /// Gets estimated rebalancing finish time.
+        /// entries in onheap cache and near entries.
+        /// </summary>
+        /// <returns>
+        /// Estimated rebalancing finish time.
+        /// </returns>
+        long EstimatedRebalancingFinishTime { get; }
+
+        /// <summary>
+        /// Gets rebalancing start time.
+        /// entries in onheap cache and near entries.
+        /// </summary>
+        /// <returns>
+        /// Rebalancing start time.
+        /// </returns>
+        long RebalancingStartTime { get; }
     }
 }
\ No newline at end of file
index 9ce713f..1a3f0dc 100644 (file)
@@ -211,6 +211,36 @@ namespace Apache.Ignite.Core.Impl.Cache
         /** */
         private readonly bool _isWriteThrough;
 
+        /** */
+        private readonly bool _isValidForReading;
+
+        /** */
+        private readonly bool _isValidForWriting;
+
+        /** */
+        private readonly int _totalPartitionsCount;
+
+        /** */
+        private readonly int _rebalancingPartitionsCount;
+
+        /** */
+        private readonly long _keysToRebalanceLeft;
+
+        /** */
+        private readonly long _rebalancingKeysRate;
+
+        /** */
+        private readonly long _rebalancingBytesRate;
+
+        /** */
+        private readonly long _heapEntriesCount;
+
+        /** */
+        private readonly long _estimatedRebalancingFinishTime;
+
+        /** */
+        private readonly long _rebalancingStartTime;
+
         /// <summary>
         /// Initializes a new instance of the <see cref="CacheMetricsImpl"/> class.
         /// </summary>
@@ -279,6 +309,16 @@ namespace Apache.Ignite.Core.Impl.Cache
             _isManagementEnabled = reader.ReadBoolean();
             _isReadThrough = reader.ReadBoolean();
             _isWriteThrough = reader.ReadBoolean();
+            _isValidForReading = reader.ReadBoolean();
+            _isValidForWriting = reader.ReadBoolean();
+            _totalPartitionsCount = reader.ReadInt();
+            _rebalancingPartitionsCount = reader.ReadInt();
+            _keysToRebalanceLeft = reader.ReadLong();
+            _rebalancingKeysRate = reader.ReadLong();
+            _rebalancingBytesRate = reader.ReadLong();
+            _heapEntriesCount = reader.ReadLong();
+            _estimatedRebalancingFinishTime = reader.ReadLong();
+            _rebalancingStartTime = reader.ReadLong();
         }
 
         /** <inheritDoc /> */
@@ -466,5 +506,35 @@ namespace Apache.Ignite.Core.Impl.Cache
 
         /** <inheritDoc /> */
         public bool IsWriteThrough { get { return _isWriteThrough; } }
+
+        /** <inheritDoc /> */
+        public bool IsValidForReading { get { return _isValidForReading; } }
+
+        /** <inheritDoc /> */
+        public bool IsValidForWriting { get { return _isValidForWriting; } }
+
+        /** <inheritDoc /> */
+        public int TotalPartitionsCount { get { return _totalPartitionsCount; } }
+
+        /** <inheritDoc /> */
+        public int RebalancingPartitionsCount { get { return _rebalancingPartitionsCount; } }
+
+        /** <inheritDoc /> */
+        public long KeysToRebalanceLeft { get { return _keysToRebalanceLeft; } }
+
+        /** <inheritDoc /> */
+        public long RebalancingKeysRate { get { return _rebalancingKeysRate; } }
+
+        /** <inheritDoc /> */
+        public long RebalancingBytesRate { get { return _rebalancingBytesRate; } }
+
+        /** <inheritDoc /> */
+        public long HeapEntriesCount { get { return _heapEntriesCount; } }
+
+        /** <inheritDoc /> */
+        public long EstimatedRebalancingFinishTime { get { return _estimatedRebalancingFinishTime; } }
+
+        /** <inheritDoc /> */
+        public long RebalancingStartTime { get { return _rebalancingStartTime; } }
     }
 }
\ No newline at end of file