ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject ignite git commit: IGNITE-2555
Date Thu, 11 Feb 2016 15:54:48 GMT
Repository: ignite
Updated Branches:
  refs/heads/master 877be93ee -> 35b0e6bf1


 IGNITE-2555


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/35b0e6bf
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/35b0e6bf
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/35b0e6bf

Branch: refs/heads/master
Commit: 35b0e6bf149bb86a3eefefcbc657c822e25681f3
Parents: 877be93
Author: ruskim <ruskim@gmail.com>
Authored: Thu Feb 11 18:53:50 2016 +0300
Committer: Anton Vinogradov <av@apache.org>
Committed: Thu Feb 11 18:53:50 2016 +0300

----------------------------------------------------------------------
 .../apache/ignite/internal/IgniteKernal.java    | 14 ++-
 .../internal/GridNodeMetricsLogSelfTest.java    | 98 ++++++++++++++++++++
 .../ignite/testsuites/IgniteBasicTestSuite.java |  2 +
 3 files changed, 113 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/35b0e6bf/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index e3017ff..5d8daf6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -989,6 +989,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable
{
                             double avgCpuLoadPct = m.getAverageCpuLoad() * 100;
                             double gcPct = m.getCurrentGcCpuLoad() * 100;
 
+                            //Heap params
                             long heapUsed = m.getHeapMemoryUsed();
                             long heapMax = m.getHeapMemoryMaximum();
 
@@ -997,6 +998,15 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable
{
 
                             double freeHeapPct = heapMax > 0 ? ((double)((heapMax - heapUsed)
* 100)) / heapMax : -1;
 
+                            //Non heap params
+                            long nonHeapUsed = m.getNonHeapMemoryUsed();
+                            long nonHeapMax = m.getNonHeapMemoryMaximum();
+
+                            long nonHeapUsedInMBytes = nonHeapUsed / 1024 / 1024;
+                            long nonHeapCommInMBytes = m.getNonHeapMemoryCommitted() / 1024
/ 1024;
+
+                            double freeNonHeapPct = nonHeapMax > 0 ? ((double)((nonHeapMax
- nonHeapUsed) * 100)) / nonHeapMax : -1;
+
                             int hosts = 0;
                             int nodes = 0;
                             int cpus = 0;
@@ -1046,12 +1056,14 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable
{
 
                             String msg = NL +
                                 "Metrics for local node (to disable set 'metricsLogFrequency'
to 0)" + NL +
-                                "    ^-- Node [id=" + id + ", name=" + name() + "]" + NL
+
+                                "    ^-- Node [id=" + id + ", name=" + name() + ", uptime="
+ getUpTimeFormatted() + "]" + NL +
                                 "    ^-- H/N/C [hosts=" + hosts + ", nodes=" + nodes + ",
CPUs=" + cpus + "]" + NL +
                                 "    ^-- CPU [cur=" + dblFmt.format(cpuLoadPct) + "%, avg="
+
                                 dblFmt.format(avgCpuLoadPct) + "%, GC=" + dblFmt.format(gcPct)
+ "%]" + NL +
                                 "    ^-- Heap [used=" + dblFmt.format(heapUsedInMBytes) +
"MB, free=" +
                                 dblFmt.format(freeHeapPct) + "%, comm=" + dblFmt.format(heapCommInMBytes)
+ "MB]" + NL +
+                                "    ^-- Non heap [used=" + dblFmt.format(nonHeapUsedInMBytes)
+ "MB, free=" +
+                                dblFmt.format(freeNonHeapPct) + "%, comm=" + dblFmt.format(nonHeapCommInMBytes)
+ "MB]" + NL +
                                 "    ^-- Public thread pool [active=" + pubPoolActiveThreads
+ ", idle=" +
                                 pubPoolIdleThreads + ", qSize=" + pubPoolQSize + "]" + NL
+
                                 "    ^-- System thread pool [active=" + sysPoolActiveThreads
+ ", idle=" +

http://git-wip-us.apache.org/repos/asf/ignite/blob/35b0e6bf/modules/core/src/test/java/org/apache/ignite/internal/GridNodeMetricsLogSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridNodeMetricsLogSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/GridNodeMetricsLogSelfTest.java
new file mode 100644
index 0000000..fe5922e
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridNodeMetricsLogSelfTest.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal;
+
+
+import java.io.StringWriter;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.testframework.junits.common.GridCommonTest;
+import org.apache.log4j.Layout;
+import org.apache.log4j.Logger;
+import org.apache.log4j.SimpleLayout;
+import org.apache.log4j.WriterAppender;
+
+/**
+ * Check logging local node metrics
+ */
+@SuppressWarnings({"ProhibitedExceptionDeclared"})
+@GridCommonTest(group = "Kernal")
+public class GridNodeMetricsLogSelfTest extends GridCommonAbstractTest {
+    /** */
+
+    public GridNodeMetricsLogSelfTest() {
+        super(false);
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings({"unchecked"})
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        cfg.setMetricsLogFrequency(1000);
+
+        return cfg;
+    }
+
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testNodeMetricsLog() throws Exception {
+        // Log to string, to check log content
+        Layout layout = new SimpleLayout();
+
+        StringWriter strWr = new StringWriter();
+
+        WriterAppender app = new WriterAppender(layout, strWr);
+
+        Logger.getRootLogger().addAppender(app);
+
+        Ignite g1 = startGrid(1);
+
+        IgniteCache<Integer, String> cache1 = g1.createCache("TestCache1");
+
+        cache1.put(1, "one");
+
+        Ignite g2 = startGrid(2);
+
+        IgniteCache<Integer, String> cache2 = g2.createCache("TestCache2");
+
+        cache2.put(2, "two");
+
+        Thread.sleep(10000);
+
+        //Check that nodes are alie
+        assert cache1.get(1).equals("one");
+        assert cache2.get(2).equals("two");
+
+        String fullLog = strWr.toString();
+
+        Logger.getRootLogger().removeAppender(app);
+
+        assert fullLog.contains("Metrics for local node");
+        assert fullLog.contains("uptime=");
+        assert fullLog.contains("Non heap");
+        assert fullLog.contains("Outbound messages queue");
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/35b0e6bf/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
index c904ef4..3903910 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
@@ -25,6 +25,7 @@ import org.apache.ignite.internal.ClusterGroupSelfTest;
 import org.apache.ignite.internal.GridFailFastNodeFailureDetectionSelfTest;
 import org.apache.ignite.internal.GridLifecycleAwareSelfTest;
 import org.apache.ignite.internal.GridLifecycleBeanSelfTest;
+import org.apache.ignite.internal.GridNodeMetricsLogSelfTest;
 import org.apache.ignite.internal.GridProjectionForCachesSelfTest;
 import org.apache.ignite.internal.GridReduceSelfTest;
 import org.apache.ignite.internal.GridReleaseTypeSelfTest;
@@ -114,6 +115,7 @@ public class IgniteBasicTestSuite extends TestSuite {
         suite.addTestSuite(IgniteSlowClientDetectionSelfTest.class);
         GridTestUtils.addTestIfNeeded(suite, IgniteDaemonNodeMarshallerCacheTest.class, ignoredTests);
         suite.addTestSuite(IgniteMarshallerCacheConcurrentReadWriteTest.class);
+        suite.addTestSuite(GridNodeMetricsLogSelfTest.class);
 
         suite.addTestSuite(IgniteExceptionInNioWorkerSelfTest.class);
 


Mime
View raw message