You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2020/08/12 08:52:57 UTC

[GitHub] [ignite] nizhikov opened a new pull request #8145: IGNITE-13349: Tcp discovery statistics migrated to the new metrics framework.

nizhikov opened a new pull request #8145:
URL: https://github.com/apache/ignite/pull/8145


   Thank you for submitting the pull request to the Apache Ignite.
   
   In order to streamline the review of the contribution 
   we ask you to ensure the following steps have been taken:
   
   ### The Contribution Checklist
   - [ ] There is a single JIRA ticket related to the pull request. 
   - [ ] The web-link to the pull request is attached to the JIRA ticket.
   - [ ] The JIRA ticket has the _Patch Available_ state.
   - [ ] The pull request body describes changes that have been made. 
   The description explains _WHAT_ and _WHY_ was made instead of _HOW_.
   - [ ] The pull request title is treated as the final commit message. 
   The following pattern must be used: `IGNITE-XXXX Change summary` where `XXXX` - number of JIRA issue.
   - [ ] A reviewer has been mentioned through the JIRA comments 
   (see [the Maintainers list](https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute#HowtoContribute-ReviewProcessandMaintainers)) 
   - [ ] The pull request has been checked by the Teamcity Bot and 
   the `green visa` attached to the JIRA ticket (see [TC.Bot: Check PR](https://mtcga.gridgain.com/prs.html))
   
   ### Notes
   - [How to Contribute](https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute)
   - [Coding abbreviation rules](https://cwiki.apache.org/confluence/display/IGNITE/Abbreviation+Rules)
   - [Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Coding+Guidelines)
   - [Apache Ignite Teamcity Bot](https://cwiki.apache.org/confluence/display/IGNITE/Apache+Ignite+Teamcity+Bot)
   
   If you need any help, please email dev@ignite.apache.org or ask anу advice on http://asf.slack.com _#ignite_ channel.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] NSAmelchev commented on a change in pull request #8145: IGNITE-13349: Tcp discovery statistics migrated to the new metrics framework.

Posted by GitBox <gi...@apache.org>.
NSAmelchev commented on a change in pull request #8145:
URL: https://github.com/apache/ignite/pull/8145#discussion_r471489407



##########
File path: modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiMBeanTest.java
##########
@@ -64,21 +70,121 @@
      */
     @Test
     public void testMBean() throws Exception {
-        startGrids(3);
+        int cnt = 3;
+        int cliIdx = cnt - 1;
+
+        startGrids(cnt - 1);
+        startClientGrid(cliIdx);
+
+        ClusterNode crd = U.oldest(grid(0).context().discovery().aliveServerNodes(), null);
+
+        assertNotNull(crd);
 
         try {
-            for (int i = 0; i < 3; i++) {
+            for (int i = 0; i < cnt; i++) {
                 IgniteEx grid = grid(i);
 
+                MetricRegistry discoReg = grid.context().metric().registry(DISCO_METRICS);
+
                 TcpDiscoverySpiMBean bean = getMxBean(grid.context().igniteInstanceName(), "SPIs",
                     TcpDiscoverySpi.class, TcpDiscoverySpiMBean.class);
 
                 assertNotNull(bean);
+
                 assertEquals(grid.cluster().topologyVersion(), bean.getCurrentTopologyVersion());
+                assertEquals(grid.cluster().topologyVersion(),
+                    discoReg.<LongMetric>findMetric("CurrentTopologyVersion").value());
+
+                if (i != cliIdx) {
+                    assertEquals(crd.id(), bean.getCoordinator());
+                    assertEquals(crd.id(), discoReg.<ObjectMetric<UUID>>findMetric("Coordinator").value());
+                }
+                else {
+                    assertNull(bean.getCoordinator());
+                    assertNull(discoReg.findMetric("Coordinator"));
+                }
+
+                if (grid.localNode().id().equals(bean.getCoordinator())) {
+                    assertTrue(bean.getCoordinatorSinceTimestamp() > 0);
+                    assertTrue(discoReg.<LongMetric>findMetric("CoordinatorSince").value() > 0);
+                }
+                else {
+                    assertEquals(0, bean.getCoordinatorSinceTimestamp());
+
+                    if (i == cliIdx)
+                        assertNull(discoReg.findMetric("CoordinatorSince"));
+                    else
+                        assertEquals(0L, discoReg.<LongMetric>findMetric("CoordinatorSince").value());
+                }
+
+                // `getNodesJoined` returns count of joined nodes since local node startup.
+                assertEquals((cnt - 1) - i, bean.getNodesJoined());
+                assertEquals((cnt - 1) - i, discoReg.<IntMetric>findMetric("JoinedNodes").value());
+
+                assertEquals(0L, bean.getNodesFailed());
+                assertEquals(0, discoReg.<IntMetric>findMetric("FailedNodes").value());
+
+                assertEquals(0L, bean.getNodesLeft());
+                assertEquals(0, discoReg.<IntMetric>findMetric("LeftNodes").value());
+
+                assertTrue(bean.getTotalReceivedMessages() > 0);
+                assertTrue(discoReg.<IntMetric>findMetric("TotalReceivedMessages").value() > 0);
+
+                assertTrue(bean.getTotalProcessedMessages() > 0);
+                assertTrue(discoReg.<IntMetric>findMetric("TotalProcessedMessages").value() > 0);
+
+                if (i != cliIdx) {
+                    assertTrue(bean.getPendingMessagesRegistered() > 0);
+                    assertTrue(discoReg.<IntMetric>findMetric("PendingMessagesRegistered").value() > 0);
+                }
+                else {
+                    assertEquals(0, bean.getPendingMessagesRegistered());
+                    assertEquals(0, discoReg.<IntMetric>findMetric("PendingMessagesRegistered").value());
+                }
+
+                assertEquals(0, bean.getPendingMessagesDiscarded());
 
                 bean.dumpRingStructure();
                 assertTrue(strLog.toString().contains("TcpDiscoveryNodesRing"));
+
+                assertFalse(bean.getProcessedMessages().isEmpty());
+                assertFalse(bean.getReceivedMessages().isEmpty());
+                assertTrue(bean.getMaxMessageProcessingTime() > 0);
+                assertEquals(i == cliIdx, bean.isClientMode());
+            }
+
+            stopGrid(0);
+
+            crd = U.oldest(grid(1).context().discovery().aliveServerNodes(), null);
+
+            for (int i = 1; i < cnt; i++) {
+                IgniteEx grid = grid(i);
+
+                MetricRegistry discoReg = grid.context().metric().registry(DISCO_METRICS);
+
+                TcpDiscoverySpiMBean bean = getMxBean(grid.context().igniteInstanceName(), "SPIs",
+                    TcpDiscoverySpi.class, TcpDiscoverySpiMBean.class);
+
+                assertNotNull(bean);
+
+                assertEquals(grid.cluster().topologyVersion(), bean.getCurrentTopologyVersion());
+                assertEquals(grid.cluster().topologyVersion(),
+                    discoReg.<LongMetric>findMetric("CurrentTopologyVersion").value());
+
+                if (i != cliIdx) {
+                    assertEquals(crd.id(), bean.getCoordinator());
+                    assertEquals(crd.id(), discoReg.<ObjectMetric<UUID>>findMetric("Coordinator").value());
+                }
+
+                if (grid.localNode().id().equals(crd.id())) {
+                    assertTrue(bean.getCoordinatorSinceTimestamp() > 0);
+                    assertTrue(discoReg.<LongMetric>findMetric("CoordinatorSince").value() > 0);
+                }
+
+                assertEquals(1L, bean.getNodesLeft());
+                assertEquals(1, discoReg.<IntMetric>findMetric("LeftNodes").value());
             }
+

Review comment:
       Why this changed?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] nizhikov commented on pull request #8145: IGNITE-13349: Tcp discovery statistics migrated to the new metrics framework.

Posted by GitBox <gi...@apache.org>.
nizhikov commented on pull request #8145:
URL: https://github.com/apache/ignite/pull/8145#issuecomment-672919583


   Hello, @ingvard can you, please, take a look at my changes?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] NSAmelchev commented on a change in pull request #8145: IGNITE-13349: Tcp discovery statistics migrated to the new metrics framework.

Posted by GitBox <gi...@apache.org>.
NSAmelchev commented on a change in pull request #8145:
URL: https://github.com/apache/ignite/pull/8145#discussion_r471478243



##########
File path: modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
##########
@@ -2115,6 +2109,23 @@ protected void onExchange(DiscoveryDataPacket dataPacket, ClassLoader clsLdr) {
     @Override public void spiStart(@Nullable String igniteInstanceName) throws IgniteSpiException {
         initializeImpl();
 
+        MetricRegistry discoReg =

Review comment:
       Can be one-line

##########
File path: modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
##########
@@ -359,7 +364,7 @@
     private Marshaller marsh;
 
     /** Statistics. */
-    protected final TcpDiscoveryStatistics stats = new TcpDiscoveryStatistics();
+    protected TcpDiscoveryStatistics stats;

Review comment:
       Now we can get NPE from public methods until SPI was started.

##########
File path: modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
##########
@@ -1358,15 +1363,6 @@ public long getPendingMessagesRegistered() {
         return stats.pendingMessagesRegistered();
     }
 
-    /**
-     * Gets pending messages discarded count.
-     *
-     * @return Pending messages registered count.
-     */
-    public long getPendingMessagesDiscarded() {

Review comment:
       Why the public API was changed?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] ingvard commented on a change in pull request #8145: IGNITE-13349: Tcp discovery statistics migrated to the new metrics framework.

Posted by GitBox <gi...@apache.org>.
ingvard commented on a change in pull request #8145:
URL: https://github.com/apache/ignite/pull/8145#discussion_r471371426



##########
File path: modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
##########
@@ -2115,6 +2115,20 @@ protected void onExchange(DiscoveryDataPacket dataPacket, ClassLoader clsLdr) {
     @Override public void spiStart(@Nullable String igniteInstanceName) throws IgniteSpiException {
         initializeImpl();
 
+        MetricRegistry discoReg =
+            ((IgniteEx)ignite()).context().metric().registry(metricName("io", "discovery"));

Review comment:
       Do we want to make a set of constants for ("io", "discovery")?

##########
File path: modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryStatistics.java
##########
@@ -287,23 +158,18 @@ public synchronized void onMessageProcessingStarted(TcpDiscoveryAbstractMessage
     public synchronized void onMessageProcessingFinished(TcpDiscoveryAbstractMessage msg) {
         assert msg != null;
 
-        Long startTs = msgsProcStartTs.get(msg.id());
+        Long startTs = msgsProcStartTs.remove(msg.id());
 
-        if (startTs != null) {
+        if (startTs == null) {

Review comment:
       Is it mistake?  long duration = U.currentTimeMillis() - startTs;  startTs is always null.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] nizhikov commented on a change in pull request #8145: IGNITE-13349: Tcp discovery statistics migrated to the new metrics framework.

Posted by GitBox <gi...@apache.org>.
nizhikov commented on a change in pull request #8145:
URL: https://github.com/apache/ignite/pull/8145#discussion_r471436074



##########
File path: modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
##########
@@ -2115,6 +2115,20 @@ protected void onExchange(DiscoveryDataPacket dataPacket, ClassLoader clsLdr) {
     @Override public void spiStart(@Nullable String igniteInstanceName) throws IgniteSpiException {
         initializeImpl();
 
+        MetricRegistry discoReg =
+            ((IgniteEx)ignite()).context().metric().registry(metricName("io", "discovery"));

Review comment:
       Fixed.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] nizhikov merged pull request #8145: IGNITE-13349: Tcp discovery statistics migrated to the new metrics framework.

Posted by GitBox <gi...@apache.org>.
nizhikov merged pull request #8145:
URL: https://github.com/apache/ignite/pull/8145


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] nizhikov commented on a change in pull request #8145: IGNITE-13349: Tcp discovery statistics migrated to the new metrics framework.

Posted by GitBox <gi...@apache.org>.
nizhikov commented on a change in pull request #8145:
URL: https://github.com/apache/ignite/pull/8145#discussion_r471509871



##########
File path: modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
##########
@@ -1358,15 +1363,6 @@ public long getPendingMessagesRegistered() {
         return stats.pendingMessagesRegistered();
     }
 
-    /**
-     * Gets pending messages discarded count.
-     *
-     * @return Pending messages registered count.
-     */
-    public long getPendingMessagesDiscarded() {

Review comment:
       fixed.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] nizhikov commented on a change in pull request #8145: IGNITE-13349: Tcp discovery statistics migrated to the new metrics framework.

Posted by GitBox <gi...@apache.org>.
nizhikov commented on a change in pull request #8145:
URL: https://github.com/apache/ignite/pull/8145#discussion_r471436184



##########
File path: modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryStatistics.java
##########
@@ -287,23 +158,18 @@ public synchronized void onMessageProcessingStarted(TcpDiscoveryAbstractMessage
     public synchronized void onMessageProcessingFinished(TcpDiscoveryAbstractMessage msg) {
         assert msg != null;
 
-        Long startTs = msgsProcStartTs.get(msg.id());
+        Long startTs = msgsProcStartTs.remove(msg.id());
 
-        if (startTs != null) {
+        if (startTs == null) {

Review comment:
       Yes, my fault.
   
   Thanks for noticing.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org