This is an automated email from the ASF dual-hosted git repository.
ilyak pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new 07812d4 IGNITE-12505 Improve node start-up and periodic logging -
Fixes #7209.
07812d4 is described below
commit 07812d440fabc0ac40305467d6c075345cf8b338
Author: Ilya Kasnacheev <[email protected]>
AuthorDate: Mon Jan 20 11:10:46 2020 +0300
IGNITE-12505 Improve node start-up and periodic logging - Fixes #7209.
Signed-off-by: Ilya Kasnacheev <[email protected]>
---
.../org/apache/ignite/internal/IgniteKernal.java | 293 +++++++++++----------
.../IgniteCacheDatabaseSharedManager.java | 23 +-
.../ignite/internal/util/GridStringBuilder.java | 13 +
.../apache/ignite/internal/util/IgniteUtils.java | 13 +-
.../internal/GridNodeMetricsLogPdsSelfTest.java | 51 +---
.../internal/GridNodeMetricsLogSelfTest.java | 89 +++++--
6 files changed, 265 insertions(+), 217 deletions(-)
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 497d766..3c4698d 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
@@ -17,6 +17,7 @@
package org.apache.ignite.internal;
+import java.text.DecimalFormatSymbols;
import javax.cache.CacheException;
import javax.management.JMException;
import java.io.Externalizable;
@@ -140,6 +141,7 @@ import
org.apache.ignite.internal.processors.cache.IgniteInternalCache;
import
org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl;
import org.apache.ignite.internal.processors.cache.mvcc.MvccProcessorImpl;
import org.apache.ignite.internal.processors.cache.persistence.DataRegion;
+import
org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager;
import
org.apache.ignite.internal.processors.cache.persistence.filename.PdsConsistentIdProcessor;
import
org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor;
import org.apache.ignite.internal.processors.closure.GridClosureProcessor;
@@ -210,7 +212,6 @@ import org.apache.ignite.internal.util.typedef.internal.SB;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.internal.worker.WorkersRegistry;
import org.apache.ignite.lang.IgniteBiTuple;
-import org.apache.ignite.lang.IgniteClosure;
import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.lang.IgnitePredicate;
import org.apache.ignite.lang.IgniteProductVersion;
@@ -226,6 +227,7 @@ import org.apache.ignite.plugin.PluginNotFoundException;
import org.apache.ignite.plugin.PluginProvider;
import org.apache.ignite.spi.IgniteSpi;
import org.apache.ignite.spi.IgniteSpiVersionCheckException;
+import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
import org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode;
import org.apache.ignite.thread.IgniteStripedThreadPoolExecutor;
import org.jetbrains.annotations.Nullable;
@@ -296,6 +298,7 @@ import static
org.apache.ignite.internal.IgniteVersionUtils.COPYRIGHT;
import static org.apache.ignite.internal.IgniteVersionUtils.REV_HASH_STR;
import static org.apache.ignite.internal.IgniteVersionUtils.VER;
import static org.apache.ignite.internal.IgniteVersionUtils.VER_STR;
+import static
org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager.INTERNAL_DATA_REGION_NAMES;
import static org.apache.ignite.lifecycle.LifecycleEventType.AFTER_NODE_START;
import static org.apache.ignite.lifecycle.LifecycleEventType.BEFORE_NODE_START;
@@ -344,6 +347,9 @@ public class IgniteKernal implements IgniteEx,
IgniteMXBean, Externalizable {
/** System line separator. */
private static final String NL = U.nl();
+ /** System megabyte. */
+ private static final int MEGABYTE = 1024 * 1024;
+
/**
* Default interval of checking thread pool state for the starvation. Will
be used only if the
* {@link IgniteSystemProperties#IGNITE_STARVATION_CHECK_INTERVAL} system
property is not set.
@@ -1505,7 +1511,7 @@ public class IgniteKernal implements IgniteEx,
IgniteMXBean, Externalizable {
if (metricsLogFreq > 0) {
metricsLogTask = ctx.timeout().schedule(new Runnable() {
- private final DecimalFormat dblFmt = new DecimalFormat("#.##");
+ private final DecimalFormat dblFmt = doubleFormat();
@Override public void run() {
ackNodeMetrics(dblFmt, execSvc, sysExecSvc,
customExecSvcs);
@@ -1547,6 +1553,11 @@ public class IgniteKernal implements IgniteEx,
IgniteMXBean, Externalizable {
startTimer.finishGlobalStage("Await exchange");
}
+ /** */
+ private static DecimalFormat doubleFormat() {
+ return new DecimalFormat("#.##",
DecimalFormatSymbols.getInstance(Locale.US));
+ }
+
/**
* @return Ignite security processor. See {@link IgniteSecurity} for
details.
*/
@@ -2185,12 +2196,6 @@ public class IgniteKernal implements IgniteEx,
IgniteMXBean, Externalizable {
ClusterNode locNode = localNode();
if (log.isQuiet()) {
- ackDataRegions(s -> {
- U.quiet(false, s);
-
- return null;
- });
-
U.quiet(false, "");
U.quiet(false, "Ignite node started OK (id=" + U.id8(locNode.id())
+
@@ -2198,12 +2203,6 @@ public class IgniteKernal implements IgniteEx,
IgniteMXBean, Externalizable {
}
if (log.isInfoEnabled()) {
- ackDataRegions(s -> {
- log.info(s);
-
- return null;
- });
-
String ack = "Ignite ver. " + VER_STR + '#' + BUILD_TSTAMP_STR +
"-sha1:" + REV_HASH_STR;
String dash = U.dash(ack.length());
@@ -2240,49 +2239,6 @@ public class IgniteKernal implements IgniteEx,
IgniteMXBean, Externalizable {
}
/**
- * @param clo Message output closure.
- */
- public void ackDataRegions(IgniteClosure<String, Void> clo) {
- DataStorageConfiguration memCfg =
ctx.config().getDataStorageConfiguration();
-
- if (memCfg == null)
- return;
-
- clo.apply("Data Regions Configured:");
-
clo.apply(dataRegionConfigurationMessage(memCfg.getDefaultDataRegionConfiguration()));
-
- DataRegionConfiguration[] dataRegions =
memCfg.getDataRegionConfigurations();
-
- if (dataRegions != null) {
- for (DataRegionConfiguration dataRegion : dataRegions) {
- String msg = dataRegionConfigurationMessage(dataRegion);
-
- if (msg != null)
- clo.apply(msg);
- }
- }
- }
-
- /**
- * @param regCfg Data region configuration.
- * @return Data region message.
- */
- private String dataRegionConfigurationMessage(DataRegionConfiguration
regCfg) {
- if (regCfg == null)
- return null;
-
- SB m = new SB();
-
- m.a(" ^-- ").a(regCfg.getName()).a(" [");
- m.a("initSize=").a(U.readableSize(regCfg.getInitialSize(), false));
- m.a(", maxSize=").a(U.readableSize(regCfg.getMaxSize(), false));
- m.a(", persistence=" + regCfg.isPersistenceEnabled());
- m.a(", lazyMemoryAllocation=" +
regCfg.isLazyMemoryAllocation()).a(']');
-
- return m.toString();
- }
-
- /**
* Logs out OS information.
*/
private void ackOsInfo() {
@@ -2336,8 +2292,7 @@ public class IgniteKernal implements IgniteEx,
IgniteMXBean, Externalizable {
try {
ClusterMetrics m = cluster().localNode().metrics();
- final int MByte = 1024 * 1024;
-
+ int localCpus = m.getTotalCpus();
double cpuLoadPct = m.getCurrentCpuLoad() * 100;
double avgCpuLoadPct = m.getAverageCpuLoad() * 100;
double gcPct = m.getCurrentGcCpuLoad() * 100;
@@ -2346,13 +2301,14 @@ public class IgniteKernal implements IgniteEx,
IgniteMXBean, Externalizable {
long heapUsed = m.getHeapMemoryUsed();
long heapMax = m.getHeapMemoryMaximum();
- long heapUsedInMBytes = heapUsed / MByte;
- long heapCommInMBytes = m.getHeapMemoryCommitted() / MByte;
+ long heapUsedInMBytes = heapUsed / MEGABYTE;
+ long heapCommInMBytes = m.getHeapMemoryCommitted() / MEGABYTE;
double freeHeapPct = heapMax > 0 ? ((double)((heapMax - heapUsed)
* 100)) / heapMax : -1;
int hosts = 0;
- int nodes = 0;
+ int servers = 0;
+ int clients = 0;
int cpus = 0;
try {
@@ -2361,120 +2317,175 @@ public class IgniteKernal implements IgniteEx,
IgniteMXBean, Externalizable {
Collection<ClusterNode> nodes0 = cluster().nodes();
hosts = U.neighborhood(nodes0).size();
- nodes = metrics.getTotalNodes();
+ servers = cluster().forServers().nodes().size();
+ clients = cluster().forClients().nodes().size();
cpus = metrics.getTotalCpus();
}
catch (IgniteException ignore) {
// No-op.
}
- int loadedPages = 0;
+ String dataStorageInfo =
dataStorageReport(ctx.cache().context().database(), dblFmt, true);
+
+ String id = U.id8(localNode().id());
+
+ AffinityTopologyVersion topVer =
ctx.discovery().topologyVersionEx();
+
+ ClusterNode locNode = ctx.discovery().localNode();
+
+ String networkDetails = "";
- // Off-heap params.
- Collection<DataRegion> regions =
ctx.cache().context().database().dataRegions();
+ if (!F.isEmpty(cfg.getLocalHost()))
+ networkDetails += ", localHost=" + cfg.getLocalHost();
- StringBuilder dataRegionsInfo = new StringBuilder();
- StringBuilder pdsRegionsInfo = new StringBuilder();
+ if (locNode instanceof TcpDiscoveryNode)
+ networkDetails += ", discoPort=" +
((TcpDiscoveryNode)locNode).discoveryPort();
- long offHeapUsedSummary = 0;
- long offHeapMaxSummary = 0;
- long offHeapCommSummary = 0;
- long pdsUsedSummary = 0;
+ if (cfg.getCommunicationSpi() instanceof TcpCommunicationSpi)
+ networkDetails += ", commPort=" +
((TcpCommunicationSpi)cfg.getCommunicationSpi()).boundPort();
- boolean persistenceDisabled = true;
+ SB msg = new SB();
- if (!F.isEmpty(regions)) {
- for (DataRegion region : regions) {
- long pagesCnt = region.pageMemory().loadedPages();
+ msg.nl()
+ .a("Metrics for local node (to disable set
'metricsLogFrequency' to 0)").nl()
+ .a(" ^-- Node [id=").a(id).a(name() != null ? ", name=" +
name() : "").a(", uptime=")
+ .a(getUpTimeFormatted()).a("]").nl()
+ .a(" ^-- Cluster [hosts=").a(hosts).a(",
CPUs=").a(cpus).a(", servers=").a(servers)
+ .a(", clients=").a(clients).a(",
topVer=").a(topVer.topologyVersion())
+ .a(",
minorTopVer=").a(topVer.minorTopologyVersion()).a("]").nl()
+ .a(" ^-- Network
[addrs=").a(locNode.addresses()).a(networkDetails).a("]").nl()
+ .a(" ^-- CPU [CPUs=").a(localCpus).a(",
curLoad=").a(dblFmt.format(cpuLoadPct))
+ .a("%, avgLoad=").a(dblFmt.format(avgCpuLoadPct)).a("%,
GC=").a(dblFmt.format(gcPct)).a("%]").nl()
+ .a(" ^-- Heap [used=").a(dblFmt.format(heapUsedInMBytes))
+ .a("MB, free=").a(dblFmt.format(freeHeapPct))
+ .a("%, comm=").a(dblFmt.format(heapCommInMBytes)).a("MB]").nl()
+ .a(dataStorageInfo)
+ .a(" ^-- Outbound messages queue
[size=").a(m.getOutboundMessagesQueueSize()).a("]").nl()
+ .a(" ^-- ").a(createExecutorDescription("Public thread
pool", execSvc)).nl()
+ .a(" ^-- ").a(createExecutorDescription("System thread
pool", sysExecSvc));
- long offHeapUsed = region.pageMemory().systemPageSize() *
pagesCnt;
- long offHeapMax = region.config().getMaxSize();
- long offHeapComm = region.memoryMetrics().getOffHeapSize();
+ if (customExecSvcs != null) {
+ for (Map.Entry<String, ? extends ExecutorService> entry :
customExecSvcs.entrySet())
+ msg.nl().a(" ^--
").a(createExecutorDescription(entry.getKey(), entry.getValue()));
+ }
- long offHeapUsedInMBytes = offHeapUsed / MByte;
- long offHeapCommInMBytes = offHeapComm / MByte;
+ log.info(msg.toString());
- double freeOffHeapPct = offHeapMax > 0 ?
- ((double)((offHeapMax - offHeapUsed) * 100)) /
offHeapMax : -1;
+ ctx.cache().context().database().dumpStatistics(log);
+ }
+ catch (IgniteClientDisconnectedException ignore) {
+ // No-op.
+ }
+ }
- offHeapUsedSummary += offHeapUsed;
- offHeapMaxSummary += offHeapMax;
- offHeapCommSummary += offHeapComm;
- loadedPages += pagesCnt;
+ /** */
+ public static String dataStorageReport(IgniteCacheDatabaseSharedManager
db, boolean includeMemoryStatistics) {
+ return dataStorageReport(db, doubleFormat(), includeMemoryStatistics);
+ }
- dataRegionsInfo.append(" ^-- ")
- .append(region.config().getName()).append(" region")
- .append("
[used=").append(dblFmt.format(offHeapUsedInMBytes))
- .append("MB,
free=").append(dblFmt.format(freeOffHeapPct))
- .append("%,
comm=").append(dblFmt.format(offHeapCommInMBytes)).append("MB]")
- .append(NL);
+ /** */
+ private static String dataStorageReport(IgniteCacheDatabaseSharedManager
db, DecimalFormat dblFmt,
+ boolean includeMemoryStatistics) {
+ // Off-heap params.
+ Collection<DataRegion> regions = db.dataRegions();
- if (region.config().isPersistenceEnabled()) {
- long pdsUsed =
region.memoryMetrics().getTotalAllocatedSize();
- long pdsUsedMBytes = pdsUsed / MByte;
+ SB dataRegionsInfo = new SB();
- pdsUsedSummary += pdsUsed;
+ long loadedPages = 0;
+ long offHeapUsedSummary = 0;
+ long offHeapMaxSummary = 0;
+ long offHeapCommSummary = 0;
+ long pdsUsedSummary = 0;
- String pdsUsedSize = dblFmt.format(pdsUsedMBytes) +
"MB";
+ boolean persistenceEnabled = false;
- pdsRegionsInfo.append(" ^-- ")
- .append(region.config().getName()).append("
region")
- .append(" [used=").append(pdsUsedSize).append("]")
- .append(NL);
+ if (!F.isEmpty(regions)) {
+ for (DataRegion region : regions) {
+ DataRegionConfiguration regCfg = region.config();
- persistenceDisabled = false;
- }
- }
- }
+ long pagesCnt = region.pageMemory().loadedPages();
- long offHeapUsedInMBytes = offHeapUsedSummary / MByte;
- long offHeapCommInMBytes = offHeapCommSummary / MByte;
- long pdsUsedMBytes = pdsUsedSummary / MByte;
+ long offHeapUsed = region.pageMemory().systemPageSize() *
pagesCnt;
+ long offHeapInit = regCfg.getInitialSize();
+ long offHeapMax = regCfg.getMaxSize();
+ long offHeapComm = region.memoryMetrics().getOffHeapSize();
- double freeOffHeapPct = offHeapMaxSummary > 0 ?
- ((double)((offHeapMaxSummary - offHeapUsedSummary) * 100)) /
offHeapMaxSummary : -1;
+ long offHeapUsedInMBytes = offHeapUsed / MEGABYTE;
+ long offHeapMaxInMBytes = offHeapMax / MEGABYTE;
+ long offHeapCommInMBytes = offHeapComm / MEGABYTE;
+ long offHeapInitInMBytes = offHeapInit / MEGABYTE;
- String pdsInfo = persistenceDisabled ? "" :
- " ^-- Ignite persistence [used=" +
dblFmt.format(pdsUsedMBytes) + "MB]" + NL + pdsRegionsInfo;
+ double freeOffHeapPct = offHeapMax > 0 ?
+ ((double)((offHeapMax - offHeapUsed) * 100)) / offHeapMax
: -1;
- String id = U.id8(localNode().id());
+ offHeapUsedSummary += offHeapUsed;
+ offHeapMaxSummary += offHeapMax;
+ offHeapCommSummary += offHeapComm;
+ loadedPages += pagesCnt;
- String msg = NL +
- "Metrics for local node (to disable set 'metricsLogFrequency'
to 0)" + NL +
- " ^-- Node [id=" + id + (name() != null ? ", 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 +
- " ^-- PageMemory [pages=" + loadedPages + "]" + NL +
- " ^-- Heap [used=" + dblFmt.format(heapUsedInMBytes) + "MB,
free=" +
- dblFmt.format(freeHeapPct) + "%, comm=" +
dblFmt.format(heapCommInMBytes) + "MB]" + NL +
- " ^-- Off-heap [used=" + dblFmt.format(offHeapUsedInMBytes)
+ "MB, free=" +
- dblFmt.format(freeOffHeapPct) + "%, comm=" +
dblFmt.format(offHeapCommInMBytes) + "MB]" + NL +
- dataRegionsInfo +
- pdsInfo +
- " ^-- Outbound messages queue [size=" +
m.getOutboundMessagesQueueSize() + "]" + NL +
- " ^-- " + createExecutorDescription("Public thread pool",
execSvc) + NL +
- " ^-- " + createExecutorDescription("System thread pool",
sysExecSvc);
+ String type = "user";
- if (customExecSvcs != null) {
- StringBuilder customSvcsMsg = new StringBuilder();
+ try {
+ if (region == db.dataRegion(null))
+ type = "default";
+ else if
(INTERNAL_DATA_REGION_NAMES.contains(regCfg.getName()))
+ type = "internal";
+ }
+ catch (IgniteCheckedException ice) {
+ // Should never happen
+ ice.printStackTrace();
+ }
+
+ dataRegionsInfo.a(" ^-- ")
+ .a(regCfg.getName()).a(" region [type=").a(type)
+ .a(", persistence=").a(regCfg.isPersistenceEnabled())
+ .a(",
lazyAlloc=").a(regCfg.isLazyMemoryAllocation()).a(',').nl()
+ .a(" ... ")
+ .a("initCfg=").a(dblFmt.format(offHeapInitInMBytes))
+ .a("MB, maxCfg=").a(dblFmt.format(offHeapMaxInMBytes))
+ .a("MB, usedRam=").a(dblFmt.format(offHeapUsedInMBytes))
+ .a("MB, freeRam=").a(dblFmt.format(freeOffHeapPct))
+ .a("%,
allocRam=").a(dblFmt.format(offHeapCommInMBytes)).a("MB");
+
+ if (regCfg.isPersistenceEnabled()) {
+ long pdsUsed =
region.memoryMetrics().getTotalAllocatedSize();
+ long pdsUsedInMBytes = pdsUsed / MEGABYTE;
+
+ pdsUsedSummary += pdsUsed;
- for (Map.Entry<String, ? extends ExecutorService> entry :
customExecSvcs.entrySet()) {
- customSvcsMsg.append(NL).append(" ^-- ")
- .append(createExecutorDescription(entry.getKey(),
entry.getValue()));
+ dataRegionsInfo.a(",
allocTotal=").a(dblFmt.format(pdsUsedInMBytes)).a("MB");
+
+ persistenceEnabled = true;
}
- msg += customSvcsMsg;
+ dataRegionsInfo.a(']').nl();
}
+ }
- log.info(msg);
+ SB info = new SB();
- ctx.cache().context().database().dumpStatistics(log);
+ if (includeMemoryStatistics) {
+ long offHeapUsedInMBytes = offHeapUsedSummary / MEGABYTE;
+ long offHeapCommInMBytes = offHeapCommSummary / MEGABYTE;
+
+ double freeOffHeapPct = offHeapMaxSummary > 0 ?
+ ((double)((offHeapMaxSummary - offHeapUsedSummary) * 100)) /
offHeapMaxSummary : -1;
+
+ info.a(" ^-- Off-heap memory
[used=").a(dblFmt.format(offHeapUsedInMBytes))
+ .a("MB, free=").a(dblFmt.format(freeOffHeapPct))
+ .a("%,
allocated=").a(dblFmt.format(offHeapCommInMBytes)).a("MB]").nl()
+ .a(" ^-- Page memory [pages=").a(loadedPages).a("]").nl();
}
- catch (IgniteClientDisconnectedException ignore) {
- // No-op.
+
+ info.a(dataRegionsInfo);
+
+ if (persistenceEnabled) {
+ long pdsUsedMBytes = pdsUsedSummary / MEGABYTE;
+
+ info.a(" ^-- Ignite persistence
[used=").a(dblFmt.format(pdsUsedMBytes)).a("MB]").nl();
}
+
+ return info.toString();
}
/**
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/IgniteCacheDatabaseSharedManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/IgniteCacheDatabaseSharedManager.java
index bb99e44..865a09e 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/IgniteCacheDatabaseSharedManager.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/IgniteCacheDatabaseSharedManager.java
@@ -19,6 +19,7 @@ package
org.apache.ignite.internal.processors.cache.persistence;
import java.io.File;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
@@ -44,6 +45,7 @@ import org.apache.ignite.failure.FailureContext;
import org.apache.ignite.failure.FailureType;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.IgniteKernal;
import org.apache.ignite.internal.managers.discovery.GridDiscoveryManager;
import
org.apache.ignite.internal.managers.systemview.walker.PagesListViewWalker;
import org.apache.ignite.internal.mem.DirectMemoryProvider;
@@ -90,6 +92,8 @@ import static
org.apache.ignite.configuration.DataStorageConfiguration.DFLT_DATA
import static
org.apache.ignite.configuration.DataStorageConfiguration.DFLT_PAGE_SIZE;
import static
org.apache.ignite.configuration.DataStorageConfiguration.DFLT_WAL_ARCHIVE_MAX_SIZE;
import static
org.apache.ignite.configuration.DataStorageConfiguration.DFLT_WAL_HISTORY_SIZE;
+import static
org.apache.ignite.internal.processors.cache.mvcc.txlog.TxLog.TX_LOG_CACHE_NAME;
+import static
org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager.METASTORE_DATA_REGION_NAME;
/**
*
@@ -99,6 +103,10 @@ public class IgniteCacheDatabaseSharedManager extends
GridCacheSharedManagerAdap
/** DataRegionConfiguration name reserved for internal caches. */
public static final String SYSTEM_DATA_REGION_NAME = "sysMemPlc";
+ /** DataRegionConfiguration names reserved for various internal needs. */
+ public static Set<String> INTERNAL_DATA_REGION_NAMES =
Collections.unmodifiableSet(
+ new HashSet<>(Arrays.asList(SYSTEM_DATA_REGION_NAME,
TX_LOG_CACHE_NAME, METASTORE_DATA_REGION_NAME)));
+
/** System view name for page lists. */
public static final String DATA_REGION_PAGE_LIST_VIEW =
"dataRegionPageLists";
@@ -735,8 +743,8 @@ public class IgniteCacheDatabaseSharedManager extends
GridCacheSharedManagerAdap
if (observedNames.contains(regName))
throw new IgniteCheckedException("Two MemoryPolicies have the same
name: " + regName);
- if (SYSTEM_DATA_REGION_NAME.equals(regName))
- throw new IgniteCheckedException("'" + SYSTEM_DATA_REGION_NAME +
"' policy name is reserved for internal use.");
+ if (INTERNAL_DATA_REGION_NAMES.contains(regName))
+ throw new IgniteCheckedException("'" + regName + "' policy name is
reserved for internal use.");
observedNames.add(regName);
}
@@ -1344,7 +1352,16 @@ public class IgniteCacheDatabaseSharedManager extends
GridCacheSharedManagerAdap
dataRegionsStarted = true;
- U.log(log, "Configured data regions started successfully [total=" +
dataRegionMap.size() + ']');
+ if (log.isQuiet()) {
+ U.quiet(false, "Data Regions Started: " + dataRegionMap.size());
+
+ U.quietMultipleLines(false, IgniteKernal.dataStorageReport(this,
false));
+ }
+ else if (log.isInfoEnabled()) {
+ log.info("Data Regions Started: " + dataRegionMap.size());
+
+ log.info(IgniteKernal.dataStorageReport(this, false));
+ }
}
/** {@inheritDoc} */
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/util/GridStringBuilder.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/GridStringBuilder.java
index 7fbe035..93e0750 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/util/GridStringBuilder.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/util/GridStringBuilder.java
@@ -21,6 +21,7 @@ import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
+import org.apache.ignite.internal.util.typedef.internal.U;
/**
* Optimized string builder with better API.
@@ -274,6 +275,18 @@ public class GridStringBuilder implements Serializable {
}
/**
+ * Adds a platform-dependent newline to this buffer.
+ *
+ * @return This buffer for chaining method calls.
+ */
+ public GridStringBuilder nl() {
+ impl.append(U.nl());
+
+ return this;
+ }
+
+
+ /**
*
* @param start Start position to replace from.
* @param end End position.
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
index 1b51d45..e11a896 100755
---
a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
@@ -4666,6 +4666,17 @@ public abstract class IgniteUtils {
}
/**
+ *
+ * @param err Whether to print to {@code System.err}.
+ * @param multiline Multiple lines string to print.
+ */
+ public static void quietMultipleLines(boolean err, String multiline) {
+ assert multiline != null;
+
+ quiet(err, multiline.split(NL));
+ }
+
+ /**
* Prints out the message in quiet and info modes.
*
* @param log Logger.
@@ -11545,7 +11556,7 @@ public abstract class IgniteUtils {
private static class WriteLockTracer extends
ReentrantReadWriteLock.WriteLock {
/** */
private static final long serialVersionUID = 0L;
-
+
/** */
public WriteLockTracer(ReentrantReadWriteLock lock) {
super(lock);
diff --git
a/modules/core/src/test/java/org/apache/ignite/internal/GridNodeMetricsLogPdsSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/GridNodeMetricsLogPdsSelfTest.java
index 41c3588..ac9e4c4 100644
---
a/modules/core/src/test/java/org/apache/ignite/internal/GridNodeMetricsLogPdsSelfTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/internal/GridNodeMetricsLogPdsSelfTest.java
@@ -17,16 +17,10 @@
package org.apache.ignite.internal;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.stream.Collectors;
import org.apache.ignite.configuration.DataRegionConfiguration;
import org.apache.ignite.configuration.DataStorageConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.configuration.WALMode;
-import org.apache.ignite.internal.util.typedef.F;
/**
* Check logging local node metrics with PDS enabled.
@@ -70,48 +64,11 @@ public class GridNodeMetricsLogPdsSelfTest extends
GridNodeMetricsLogSelfTest {
String msg = "Metrics are missing in the log or have an unexpected
format";
- assertTrue(msg, logOutput.matches("(?s).*Ignite persistence
\\[used=.*].*"));
+ assertTrue(msg, logOutput.matches("(?s).*Ignite persistence
\\[used=[\\d]+MB].*"));
}
- /** {@inheritDoc} */
- @Override protected void checkMemoryMetrics(String logOutput) {
- super.checkMemoryMetrics(logOutput);
-
- boolean summaryFmtMatches = false;
-
- Set<String> regions = new HashSet<>();
-
- Pattern ptrn = Pattern.compile("(?m).{2,}( {3}(?<name>.+)
region|Ignite persistence) " +
- "\\[used=(?<used>[-.\\d]+)?.*]");
-
- Matcher matcher = ptrn.matcher(logOutput);
-
- while (matcher.find()) {
- String subj = logOutput.substring(matcher.start(), matcher.end());
-
- assertFalse("\"used\" cannot be empty: " + subj,
F.isEmpty(matcher.group("used")));
-
- String usedSize = matcher.group("used");
-
- int used = Integer.parseInt(usedSize);
-
- assertTrue(used + " should be non negative: " + subj, used >= 0);
-
- String regName = matcher.group("name");
-
- if (F.isEmpty(regName))
- summaryFmtMatches = true;
- else
- regions.add(regName);
- }
-
- assertTrue("Persistence metrics have unexpected format.",
summaryFmtMatches);
-
- Set<String> expRegions =
grid(0).context().cache().context().database().dataRegions().stream()
- .filter(v -> v.config().isPersistenceEnabled())
- .map(v -> v.config().getName().trim())
- .collect(Collectors.toSet());
-
- assertEquals(expRegions, regions);
+ /** */
+ @Override protected boolean persistenceEnabled() {
+ return true;
}
}
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
index 055487c..3557994 100644
---
a/modules/core/src/test/java/org/apache/ignite/internal/GridNodeMetricsLogSelfTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/internal/GridNodeMetricsLogSelfTest.java
@@ -95,7 +95,9 @@ public class GridNodeMetricsLogSelfTest extends
GridCommonAbstractTest {
checkNodeMetricsFormat(logOutput);
- checkMemoryMetrics(logOutput);
+ checkOffHeapMetrics(logOutput);
+
+ checkDataRegionsMetrics(logOutput);
}
/**
@@ -109,12 +111,15 @@ public class GridNodeMetricsLogSelfTest extends
GridCommonAbstractTest {
// Don't check the format strictly, but check that all expected
metrics are present.
assertTrue(msg, fullLog.contains("Metrics for local node (to disable
set 'metricsLogFrequency' to 0)"));
assertTrue(msg, fullLog.matches("(?s).*Node \\[id=.*, name=.*,
uptime=.*].*"));
- assertTrue(msg, fullLog.matches("(?s).*H/N/C \\[hosts=.*, nodes=.*,
CPUs=.*].*"));
- assertTrue(msg, fullLog.matches("(?s).*CPU \\[cur=.*, avg=.*,
GC=.*].*"));
- assertTrue(msg, fullLog.matches("(?s).*PageMemory \\[pages=.*].*"));
+ assertTrue(msg, fullLog.matches("(?s).*Cluster \\[hosts=.*, CPUs=.*,
servers=.*, clients=.*, topVer=.*, minorTopVer=.*].*"));
+ assertTrue(msg, fullLog.matches("(?s).*Network \\[addrs=\\[.*],
localHost=.*, discoPort=.*, commPort=.*].*"));
+ assertTrue(msg, fullLog.matches("(?s).*CPU \\[CPUs=.*, curLoad=.*,
avgLoad=.*, GC=.*].*"));
+ assertTrue(msg, fullLog.matches("(?s).*Page memory \\[pages=.*].*"));
assertTrue(msg, fullLog.matches("(?s).*Heap \\[used=.*, free=.*,
comm=.*].*"));
- assertTrue(msg, fullLog.matches("(?s).*Off-heap \\[used=.*, free=.*,
comm=.*].*"));
- assertTrue(msg, fullLog.matches("(?s).* region \\[used=.*, free=.*,
comm=.*].*"));
+ assertTrue(msg, fullLog.matches("(?s).*Off-heap memory \\[used=.*,
free=.*, allocated=.*].*"));
+ assertTrue(msg, fullLog.matches("(?s).* region \\[type=internal,
persistence=(true|false), lazyAlloc=(true|false).*"));
+ assertTrue(msg, fullLog.matches("(?s).* region \\[type=default,
persistence=(true|false), lazyAlloc=(true|false).*"));
+ assertTrue(msg, fullLog.matches("(?s).*... initCfg=.*, maxCfg=.*,
usedRam=.*, freeRam=.*, allocRam=.*].*"));
assertTrue(msg, fullLog.matches("(?s).*Outbound messages queue
\\[size=.*].*"));
assertTrue(msg, fullLog.matches("(?s).*Public thread pool
\\[active=.*, idle=.*, qSize=.*].*"));
assertTrue(msg, fullLog.matches("(?s).*System thread pool
\\[active=.*, idle=.*, qSize=.*].*"));
@@ -127,44 +132,78 @@ public class GridNodeMetricsLogSelfTest extends
GridCommonAbstractTest {
*
* @param logOutput Logging output.
*/
- protected void checkMemoryMetrics(String logOutput) {
- boolean summaryFmtMatches = false;
-
+ protected void checkDataRegionsMetrics(String logOutput) {
Set<String> regions = new HashSet<>();
- Matcher matcher = Pattern.compile("(?m).{2,}( {3}(?<name>.+)
region|Off-heap) " +
- "\\[used=(?<used>[-.\\d]*).*, free=(?<free>[-.\\d]*).*,
comm=(?<comm>[-.\\d]*).*]")
+ Matcher matcher = Pattern.compile("(?m).{2,} {3}(?<name>.+) region
\\[type=(default|internal), " +
+ "persistence=(true|false),
lazyAlloc=(true|false),\\s*\\.\\.\\.\\s*" +
+ "initCfg=(?<init>[-\\d]+)MB, maxCfg=(?<max>[-\\d]+)MB,
usedRam=(?<used>[-\\d]+).*MB, " +
+ "freeRam=(?<free>[-.\\d]+)%, allocRam=(?<alloc>[-\\d]+)MB(,
allocTotal=(?<total>[-\\d]+)MB)?]")
.matcher(logOutput);
while (matcher.find()) {
String subj = logOutput.substring(matcher.start(), matcher.end());
- assertFalse("\"used\" cannot be empty: " + subj,
F.isEmpty(matcher.group("used")));
- assertFalse("\"free\" cannot be empty: " + subj,
F.isEmpty(matcher.group("free")));
- assertFalse("\"comm\" cannot be empty: " + subj,
F.isEmpty(matcher.group("comm")));
-
+ int init = Integer.parseInt(matcher.group("init"));
+ int max = Integer.parseInt(matcher.group("max"));
int used = Integer.parseInt(matcher.group("used"));
- int comm = Integer.parseInt(matcher.group("comm"));
double free = Double.parseDouble(matcher.group("free"));
+ int alloc = Integer.parseInt(matcher.group("alloc"));
+ assertTrue(init + " should be non negative: " + subj, init >= 0);
+ assertTrue(max + " is less then " + init + ": " + subj, max >=
init);
assertTrue(used + " should be non negative: " + subj, used >= 0);
- assertTrue(comm + " is less then " + used + ": " + subj, comm >=
used);
+ assertTrue(alloc + " is less then " + used + ": " + subj, alloc >=
used);
assertTrue(free + " is not between 0 and 100: " + subj, 0 <= free
&& free <= 100);
- String regName = matcher.group("name");
+ if (persistenceEnabled()) {
+ int total = Integer.parseInt(matcher.group("total"));
- if (F.isEmpty(regName))
- summaryFmtMatches = true;
- else
- regions.add(regName.trim());
- }
+ assertTrue(total + " is less then " + used + ": " + subj,
total >= used);
+ } else
+ assertTrue(F.isEmpty(matcher.group("total")));
- assertTrue("Off-heap metrics have unexpected format.",
summaryFmtMatches);
+ regions.add(matcher.group("name").trim());
+ }
Set<String> expRegions =
grid(0).context().cache().context().database().dataRegions().stream()
.map(v -> v.config().getName().trim())
.collect(Collectors.toSet());
- assertEquals("Off-heap per-region metrics have unexpected format.",
expRegions, regions);
+ assertFalse("No data regions in the log.", regions.isEmpty());
+
+ assertEquals("Unexpected names of data regions.", expRegions, regions);
+ }
+
+ /**
+ * Check memory metrics values.
+ *
+ * @param logOutput Logging output.
+ */
+ protected void checkOffHeapMetrics(String logOutput) {
+ Matcher matcher = Pattern.compile("Off-heap memory " +
+ "\\[used=(?<used>[-.\\d]*).*, free=(?<free>[-.\\d]*).*,
allocated=(?<comm>[-.\\d]*).*]")
+ .matcher(logOutput);
+
+ assertTrue("Off-heap metrics not found in the log.", matcher.find());
+
+ String subj = logOutput.substring(matcher.start(), matcher.end());
+
+ assertFalse("\"used\" cannot be empty: " + subj,
F.isEmpty(matcher.group("used")));
+ assertFalse("\"free\" cannot be empty: " + subj,
F.isEmpty(matcher.group("free")));
+ assertFalse("\"comm\" cannot be empty: " + subj,
F.isEmpty(matcher.group("comm")));
+
+ int used = Integer.parseInt(matcher.group("used"));
+ int comm = Integer.parseInt(matcher.group("comm"));
+ double free = Double.parseDouble(matcher.group("free"));
+
+ assertTrue(used + " should be non negative: " + subj, used >= 0);
+ assertTrue(comm + " is less then " + used + ": " + subj, comm >= used);
+ assertTrue(free + " is not between 0 and 100: " + subj, 0 <= free &&
free <= 100);
+ }
+
+ /** */
+ protected boolean persistenceEnabled() {
+ return false;
}
}