use of org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode in project ignite by apache.
the class TcpDiscoverySelfTest method testNodeAdded.
/**
* @throws Exception If any error occurs.
*/
public void testNodeAdded() throws Exception {
try {
final Ignite g1 = startGrid(1);
final CountDownLatch cnt = new CountDownLatch(2);
g1.events().localListen(new IgnitePredicate<Event>() {
@Override
public boolean apply(Event evt) {
info("Node joined: " + evt.message());
DiscoveryEvent discoEvt = (DiscoveryEvent) evt;
TcpDiscoveryNode node = ((TcpDiscoveryNode) discoMap.get(g1.name()).getNode(discoEvt.eventNode().id()));
assert node != null && node.visible();
cnt.countDown();
return true;
}
}, EventType.EVT_NODE_JOINED);
startGrid(2);
startGrid(3);
info("Nodes were started");
assert cnt.await(1, SECONDS);
} finally {
stopAllGrids();
}
}
use of org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode in project ignite by apache.
the class CacheMetricsForClusterGroupSelfTest method testMetricsStatisticsDisabled.
/**
* Test cluster group metrics in case of statistics disabled.
*/
public void testMetricsStatisticsDisabled() throws Exception {
createCaches(false);
populateCacheData(cache1, ENTRY_CNT_CACHE1);
populateCacheData(cache2, ENTRY_CNT_CACHE2);
readCacheData(cache1, ENTRY_CNT_CACHE1);
readCacheData(cache2, ENTRY_CNT_CACHE2);
awaitMetricsUpdate();
Collection<ClusterNode> nodes = grid(0).cluster().forRemotes().nodes();
for (ClusterNode node : nodes) {
Map<Integer, CacheMetrics> metrics = ((TcpDiscoveryNode) node).cacheMetrics();
assertNotNull(metrics);
assertTrue(metrics.isEmpty());
}
assertMetrics(cache1);
assertMetrics(cache2);
destroyCaches();
}
use of org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode in project ignite by apache.
the class IgniteKernal method dumpDebugInfo.
/** {@inheritDoc} */
public void dumpDebugInfo() {
try {
GridKernalContextImpl ctx = this.ctx;
GridDiscoveryManager discoMrg = ctx != null ? ctx.discovery() : null;
ClusterNode locNode = discoMrg != null ? discoMrg.localNode() : null;
if (ctx != null && discoMrg != null && locNode != null) {
boolean client = ctx.clientNode();
UUID routerId = locNode instanceof TcpDiscoveryNode ? ((TcpDiscoveryNode) locNode).clientRouterNodeId() : null;
U.warn(log, "Dumping debug info for node [id=" + locNode.id() + ", name=" + ctx.igniteInstanceName() + ", order=" + locNode.order() + ", topVer=" + discoMrg.topologyVersion() + ", client=" + client + (client && routerId != null ? ", routerId=" + routerId : "") + ']');
ctx.cache().context().exchange().dumpDebugInfo();
} else
U.warn(log, "Dumping debug info for node, context is not initialized [name=" + igniteInstanceName + ']');
} catch (Exception e) {
U.error(log, "Failed to dump debug info for node: " + e, e);
}
}
use of org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode in project ignite by apache.
the class TcpDiscoverySpiFailureTimeoutSelfTest method testConnectionCheckMessage.
/**
* @throws Exception In case of error.
*/
public void testConnectionCheckMessage() throws Exception {
TestTcpDiscoverySpi nextSpi = null;
try {
assert firstSpi().connCheckStatusMsgCntSent == 0;
TcpDiscoveryNode nextNode = ((ServerImpl) (firstSpi().impl)).ring().nextNode();
assertNotNull(nextNode);
nextSpi = null;
for (int i = 1; i < spis.size(); i++) if (spis.get(i).getLocalNode().id().equals(nextNode.id())) {
nextSpi = (TestTcpDiscoverySpi) spis.get(i);
break;
}
assertNotNull(nextSpi);
assert nextSpi.connCheckStatusMsgCntReceived == 0;
firstSpi().cntConnCheckMsg = true;
nextSpi.cntConnCheckMsg = true;
Thread.sleep(firstSpi().failureDetectionTimeout());
firstSpi().cntConnCheckMsg = false;
nextSpi.cntConnCheckMsg = false;
int sent = firstSpi().connCheckStatusMsgCntSent;
int received = nextSpi.connCheckStatusMsgCntReceived;
assert sent >= 3 && sent < 7 : "messages sent: " + sent;
assert received >= 3 && received < 7 : "messages received: " + received;
} finally {
firstSpi().resetState();
if (nextSpi != null)
nextSpi.resetState();
}
}
use of org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode in project ignite by apache.
the class TcpDiscoverySelfTest method testThreeNodesStartStop.
/**
* @throws Exception If any error occurs.
*/
public void testThreeNodesStartStop() throws Exception {
try {
IgniteEx ignite1 = startGrid(1);
IgniteEx ignite2 = startGrid(2);
IgniteEx ignite3 = startGrid(3);
TcpDiscoverySpi spi1 = (TcpDiscoverySpi) ignite1.configuration().getDiscoverySpi();
TcpDiscoverySpi spi2 = (TcpDiscoverySpi) ignite2.configuration().getDiscoverySpi();
TcpDiscoverySpi spi3 = (TcpDiscoverySpi) ignite3.configuration().getDiscoverySpi();
TcpDiscoveryNode node = (TcpDiscoveryNode) spi1.getNode(ignite2.localNode().id());
assertNotNull(node);
assertNotNull(node.lastSuccessfulAddress());
LinkedHashSet<InetSocketAddress> addrs = spi1.getNodeAddresses(node);
assertEquals(addrs.iterator().next(), node.lastSuccessfulAddress());
assertTrue(spi1.pingNode(ignite3.localNode().id()));
node = (TcpDiscoveryNode) spi1.getNode(ignite3.localNode().id());
assertNotNull(node);
assertNotNull(node.lastSuccessfulAddress());
addrs = spi1.getNodeAddresses(node);
assertEquals(addrs.iterator().next(), node.lastSuccessfulAddress());
node = (TcpDiscoveryNode) spi2.getNode(ignite1.localNode().id());
assertNotNull(node);
assertNotNull(node.lastSuccessfulAddress());
node = (TcpDiscoveryNode) spi2.getNode(ignite3.localNode().id());
assertNotNull(node);
assertNotNull(node.lastSuccessfulAddress());
node = (TcpDiscoveryNode) spi3.getNode(ignite1.localNode().id());
assertNotNull(node);
assertNotNull(node.lastSuccessfulAddress());
} finally {
stopAllGrids();
}
}
Aggregations