Repository: incubator-ignite Updated Branches: refs/heads/ignite-901 ebd399e29 -> e42d197f9
# ignite-901 Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/e42d197f Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/e42d197f Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/e42d197f Branch: refs/heads/ignite-901 Commit: e42d197f9226a6e428ac80b5b3965869abd51976 Parents: ebd399e Author: sboikov <sboi...@gridgain.com> Authored: Mon Jul 13 14:47:00 2015 +0300 Committer: sboikov <sboi...@gridgain.com> Committed: Mon Jul 13 15:40:42 2015 +0300 ---------------------------------------------------------------------- .../apache/ignite/internal/IgniteKernal.java | 111 ++++++++++--------- .../discovery/GridDiscoveryManager.java | 3 +- .../clock/GridClockSyncProcessor.java | 4 +- .../ignite/spi/discovery/tcp/ClientImpl.java | 31 +++++- 4 files changed, 90 insertions(+), 59 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e42d197f/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 4718d75..29f7e9d 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 @@ -903,82 +903,87 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable { @Override public void run() { if (log.isInfoEnabled()) { - ClusterMetrics m = cluster().localNode().metrics(); + try { + ClusterMetrics m = cluster().localNode().metrics(); - double cpuLoadPct = m.getCurrentCpuLoad() * 100; - double avgCpuLoadPct = m.getAverageCpuLoad() * 100; - double gcPct = m.getCurrentGcCpuLoad() * 100; + double cpuLoadPct = m.getCurrentCpuLoad() * 100; + double avgCpuLoadPct = m.getAverageCpuLoad() * 100; + double gcPct = m.getCurrentGcCpuLoad() * 100; - long heapUsed = m.getHeapMemoryUsed(); - long heapMax = m.getHeapMemoryMaximum(); + long heapUsed = m.getHeapMemoryUsed(); + long heapMax = m.getHeapMemoryMaximum(); - long heapUsedInMBytes = heapUsed / 1024 / 1024; - long heapCommInMBytes = m.getHeapMemoryCommitted() / 1024 / 1024; + long heapUsedInMBytes = heapUsed / 1024 / 1024; + long heapCommInMBytes = m.getHeapMemoryCommitted() / 1024 / 1024; - double freeHeapPct = heapMax > 0 ? ((double)((heapMax - heapUsed) * 100)) / heapMax : -1; + double freeHeapPct = heapMax > 0 ? ((double)((heapMax - heapUsed) * 100)) / heapMax : -1; - int hosts = 0; - int nodes = 0; - int cpus = 0; + int hosts = 0; + int nodes = 0; + int cpus = 0; - try { - ClusterMetrics metrics = cluster().metrics(); + try { + ClusterMetrics metrics = cluster().metrics(); - Collection<ClusterNode> nodes0 = cluster().nodes(); + Collection<ClusterNode> nodes0 = cluster().nodes(); - hosts = U.neighborhood(nodes0).size(); - nodes = metrics.getTotalNodes(); - cpus = metrics.getTotalCpus(); - } - catch (IgniteException ignore) { - // No-op. - } + hosts = U.neighborhood(nodes0).size(); + nodes = metrics.getTotalNodes(); + cpus = metrics.getTotalCpus(); + } + catch (IgniteException ignore) { + // No-op. + } - int pubPoolActiveThreads = 0; - int pubPoolIdleThreads = 0; - int pubPoolQSize = 0; + int pubPoolActiveThreads = 0; + int pubPoolIdleThreads = 0; + int pubPoolQSize = 0; - if (execSvc instanceof ThreadPoolExecutor) { - ThreadPoolExecutor exec = (ThreadPoolExecutor)execSvc; + if (execSvc instanceof ThreadPoolExecutor) { + ThreadPoolExecutor exec = (ThreadPoolExecutor)execSvc; - int poolSize = exec.getPoolSize(); + int poolSize = exec.getPoolSize(); - pubPoolActiveThreads = Math.min(poolSize, exec.getActiveCount()); - pubPoolIdleThreads = poolSize - pubPoolActiveThreads; - pubPoolQSize = exec.getQueue().size(); - } + pubPoolActiveThreads = Math.min(poolSize, exec.getActiveCount()); + pubPoolIdleThreads = poolSize - pubPoolActiveThreads; + pubPoolQSize = exec.getQueue().size(); + } - int sysPoolActiveThreads = 0; - int sysPoolIdleThreads = 0; - int sysPoolQSize = 0; + int sysPoolActiveThreads = 0; + int sysPoolIdleThreads = 0; + int sysPoolQSize = 0; - if (sysExecSvc instanceof ThreadPoolExecutor) { - ThreadPoolExecutor exec = (ThreadPoolExecutor)sysExecSvc; + if (sysExecSvc instanceof ThreadPoolExecutor) { + ThreadPoolExecutor exec = (ThreadPoolExecutor)sysExecSvc; - int poolSize = exec.getPoolSize(); + int poolSize = exec.getPoolSize(); - sysPoolActiveThreads = Math.min(poolSize, exec.getActiveCount()); - sysPoolIdleThreads = poolSize - sysPoolActiveThreads; - sysPoolQSize = exec.getQueue().size(); - } + sysPoolActiveThreads = Math.min(poolSize, exec.getActiveCount()); + sysPoolIdleThreads = poolSize - sysPoolActiveThreads; + sysPoolQSize = exec.getQueue().size(); + } - String id = U.id8(localNode().id()); + String id = U.id8(localNode().id()); - String msg = NL + - "Metrics for local node (to disable set 'metricsLogFrequency' to 0)" + NL + - " ^-- Node [id=" + id + ", name=" + name() + "]" + NL + - " ^-- H/N/C [hosts=" + hosts + ", nodes=" + nodes + ", CPUs=" + cpus + "]" + NL + - " ^-- CPU [cur=" + dblFmt.format(cpuLoadPct) + "%, avg=" + + String msg = NL + + "Metrics for local node (to disable set 'metricsLogFrequency' to 0)" + NL + + " ^-- Node [id=" + id + ", name=" + name() + "]" + 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=" + + " ^-- Heap [used=" + dblFmt.format(heapUsedInMBytes) + "MB, free=" + dblFmt.format(freeHeapPct) + "%, comm=" + dblFmt.format(heapCommInMBytes) + "MB]" + NL + - " ^-- Public thread pool [active=" + pubPoolActiveThreads + ", idle=" + + " ^-- Public thread pool [active=" + pubPoolActiveThreads + ", idle=" + pubPoolIdleThreads + ", qSize=" + pubPoolQSize + "]" + NL + - " ^-- System thread pool [active=" + sysPoolActiveThreads + ", idle=" + + " ^-- System thread pool [active=" + sysPoolActiveThreads + ", idle=" + sysPoolIdleThreads + ", qSize=" + sysPoolQSize + "]" + NL + - " ^-- Outbound messages queue [size=" + m.getOutboundMessagesQueueSize() + "]"; + " ^-- Outbound messages queue [size=" + m.getOutboundMessagesQueueSize() + "]"; - log.info(msg); + log.info(msg); + } + catch (IgniteClientDisconnectedException ignore) { + // No-op. + } } } }, metricsLogFreq, metricsLogFreq); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e42d197f/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java index 12556f4..de56a16 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java @@ -1941,8 +1941,7 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> { } case EVT_CLIENT_NODE_DISCONNECTED: { - if (log.isInfoEnabled()) - log.info("Client node disconnected from topology: " + node); + // No-op. break; } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e42d197f/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockSyncProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockSyncProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockSyncProcessor.java index 478426f..3ac44f2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockSyncProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockSyncProcessor.java @@ -57,7 +57,7 @@ public class GridClockSyncProcessor extends GridProcessorAdapter { /** Time coordinator thread. */ private volatile TimeCoordinator timeCoord; - /** Time delta history. Constructed on coorinator. */ + /** Time delta history. Constructed on coordinator. */ private NavigableMap<GridClockDeltaVersion, GridClockDeltaSnapshot> timeSyncHist = new GridBoundedConcurrentOrderedMap<>(MAX_TIME_SYNC_HISTORY); @@ -222,7 +222,7 @@ public class GridClockSyncProcessor extends GridProcessorAdapter { minNodeOrder = node.order(); } - ClusterNode locNode = ctx.grid().localNode(); + ClusterNode locNode = ctx.discovery().localNode(); if (locNode.order() == minNodeOrder) { if (log.isDebugEnabled()) http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e42d197f/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java index 1abc4fc..b6e9573 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java @@ -990,6 +990,9 @@ class ClientImpl extends TcpDiscoveryImpl { long startTime = U.currentTimeMillis(); + if (log.isDebugEnabled()) + log.debug("Started reconnect process [join=" + join + ", timeout=" + timeout + ']'); + try { while (true) { sock = joinTopology(true, timeout); @@ -1031,6 +1034,10 @@ class ClientImpl extends TcpDiscoveryImpl { TcpDiscoveryClientReconnectMessage res = (TcpDiscoveryClientReconnectMessage)msg; if (res.creatorNodeId().equals(getLocalNodeId())) { + if (log.isDebugEnabled()) + log.debug("Received reconnect response [success=" + res.success() + + ", msg=" + msg + ']'); + if (res.success()) { msgWorker.addMessage(res); @@ -1147,6 +1154,10 @@ class ClientImpl extends TcpDiscoveryImpl { break; } else if (state == DISCONNECTED) { + if (log.isDebugEnabled()) + log.debug("Failed to reconnect, local node segmented " + + "[joinTimeout=" + spi.joinTimeout + ']'); + state = SEGMENTED; notifyDiscovery(EVT_NODE_SEGMENTED, topVer, locNode, allVisibleNodes()); @@ -1183,6 +1194,9 @@ class ClientImpl extends TcpDiscoveryImpl { } } else { + if (log.isDebugEnabled()) + log.debug("Connection closed, will try to restore connection."); + assert reconnector == null; final Reconnector reconnector = new Reconnector(join); @@ -1199,6 +1213,11 @@ class ClientImpl extends TcpDiscoveryImpl { if (spi.isClientReconnectDisabled()) { if (state != SEGMENTED && state != STOPPED) { + if (log.isDebugEnabled()) { + log.debug("Failed to restore closed connection, reconnect disabled, " + + "local node segmented [networkTimeout=" + spi.netTimeout + ']'); + } + state = SEGMENTED; notifyDiscovery(EVT_NODE_SEGMENTED, topVer, locNode, allVisibleNodes()); @@ -1206,6 +1225,11 @@ class ClientImpl extends TcpDiscoveryImpl { } else { if (state == STARTING || state == CONNECTED) { + if (log.isDebugEnabled()) { + log.debug("Failed to restore closed connection, will try to reconnect " + + "[networkTimeout=" + spi.netTimeout + ", joinTimeout=" + spi.joinTimeout + ']'); + } + state = DISCONNECTED; nodeAdded = false; @@ -1226,9 +1250,12 @@ class ClientImpl extends TcpDiscoveryImpl { UUID newId = UUID.randomUUID(); - if (log.isInfoEnabled()) + if (log.isInfoEnabled()) { + log.info("Client node disconnected from cluster: " + locNode); + log.info("Client will try to reconnect to cluster with new id " + - "[id=" + newId + ", prevId=" + locNode.id() + ']'); + "[newId=" + newId + ", prevId=" + locNode.id() + ']'); + } locNode.onClientDisconnected(newId);