Skip to content

Commit d45bdd7

Browse files
author
Yakov Zhdanov
committed
Merge remote-tracking branch 'origin/master'
2 parents 78d9920 + 7f190ca commit d45bdd7

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.jetbrains.annotations.*;
1313

1414
import javax.net.ssl.*;
15+
import java.lang.management.*;
1516

1617
/**
1718
* Contains constants for all system properties and environmental variables in GridGain. These
@@ -447,6 +448,18 @@ public final class IgniteSystemProperties {
447448
*/
448449
public static final String GG_WORK_DIR = "GRIDGAIN_WORK_DIR";
449450

451+
/**
452+
* If this property is set to {@code true} then GridGain will append
453+
* hash code of {@link Ignite} class as hex string and append
454+
* JVM name returned by {@link RuntimeMXBean#getName()}.
455+
* <p>
456+
* This may be helpful when running GridGain in some application server
457+
* clusters or similar environments to avoid MBean name collisions.
458+
* <p>
459+
* Default is {@code false}.
460+
*/
461+
public static final String GG_MBEAN_APPEND_JVM_ID = "GRIDGAIN_MBEAN_APPEND_JVM_ID";
462+
450463
/**
451464
* Enforces singleton.
452465
*/

modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,8 @@ private GridTcpNioCommunicationClient connected(
519519

520520
GridCommunicationClient oldClient = clients.putIfAbsent(node.id(), client);
521521

522-
assert oldClient == null;
522+
assert oldClient == null : "Client already created [node=" + node + ", client=" + client +
523+
", oldClient=" + oldClient + ", recoveryDesc=" + recovery + ']';
523524
}
524525

525526
return client;
@@ -1830,7 +1831,8 @@ private GridCommunicationClient reserveClient(ClusterNode node) throws IgniteChe
18301831
if (client0 != null) {
18311832
GridCommunicationClient old = clients.put(nodeId, client0);
18321833

1833-
assert old == null;
1834+
assert old == null : "Client already created " +
1835+
"[node=" + node + ", client=" + client0 + ", oldClient=" + old + ']';
18341836
}
18351837
else
18361838
U.sleep(200);
@@ -2359,7 +2361,7 @@ private GridNioRecoveryDescriptor recoveryDescriptor(ClusterNode node) {
23592361
int queueLimit = unackedMsgsBufSize != 0 ? unackedMsgsBufSize : (maxSize * 5);
23602362

23612363
GridNioRecoveryDescriptor old =
2362-
recoveryDescs.put(id, recovery = new GridNioRecoveryDescriptor(queueLimit, node, log));
2364+
recoveryDescs.putIfAbsent(id, recovery = new GridNioRecoveryDescriptor(queueLimit, node, log));
23632365

23642366
if (old != null)
23652367
recovery = old;

modules/core/src/main/java/org/gridgain/grid/util/GridUtils.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3867,6 +3867,8 @@ public static ObjectName makeMBeanName(@Nullable String gridName, @Nullable Stri
38673867
throws MalformedObjectNameException {
38683868
SB sb = new SB(JMX_DOMAIN + ':');
38693869

3870+
appendJvmId(sb);
3871+
38703872
if (gridName != null && !gridName.isEmpty())
38713873
sb.a("grid=").a(gridName).a(',');
38723874

@@ -3878,6 +3880,18 @@ public static ObjectName makeMBeanName(@Nullable String gridName, @Nullable Stri
38783880
return new ObjectName(sb.toString());
38793881
}
38803882

3883+
/**
3884+
* @param sb Sb.
3885+
*/
3886+
private static void appendJvmId(SB sb) {
3887+
if (getBoolean(GG_MBEAN_APPEND_JVM_ID)) {
3888+
String gridId = Integer.toHexString(Ignite.class.getClassLoader().hashCode()) + "_"
3889+
+ ManagementFactory.getRuntimeMXBean().getName();
3890+
3891+
sb.a("jvmId=").a(gridId).a(',');
3892+
}
3893+
}
3894+
38813895
/**
38823896
* Mask component name to make sure that it is not {@code null}.
38833897
*
@@ -3902,6 +3916,8 @@ public static ObjectName makeCacheMBeanName(@Nullable String gridName, @Nullable
39023916
throws MalformedObjectNameException {
39033917
SB sb = new SB(JMX_DOMAIN + ':');
39043918

3919+
appendJvmId(sb);
3920+
39053921
if (gridName != null && !gridName.isEmpty())
39063922
sb.a("grid=").a(gridName).a(',');
39073923

0 commit comments

Comments
 (0)