use of org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi in project ignite by apache.
the class DataStreamerMultiThreadedSelfTest method getConfiguration.
/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
((TcpCommunicationSpi) cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
discoSpi.setIpFinder(IP_FINDER);
cfg.setDiscoverySpi(discoSpi);
if (!dynamicCache)
cfg.setCacheConfiguration(cacheConfiguration());
return cfg;
}
use of org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi in project ignite by apache.
the class GridTcpSpiForwardingSelfTest method getConfiguration.
/** {@inheritDoc} */
@SuppressWarnings({ "IfMayBeConditional", "deprecation" })
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
if (ipFinderUseLocPorts)
ipFinder.setAddresses(Arrays.asList("127.0.0.1:" + locPort1, "127.0.0.1:" + locPort2));
else
ipFinder.setAddresses(Arrays.asList("127.0.0.1:" + extPort1, "127.0.0.1:" + extPort2));
TcpDiscoverySpi spi = new TcpDiscoverySpi();
final int locPort;
final int commLocPort;
if (getTestIgniteInstanceName(0).equals(igniteInstanceName)) {
locPort = locPort1;
commLocPort = commLocPort1;
} else if (getTestIgniteInstanceName(1).equals(igniteInstanceName)) {
locPort = locPort2;
commLocPort = commLocPort2;
} else
throw new IllegalArgumentException("Unknown Ignite instance name");
spi.setIpFinder(ipFinder);
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
spi.setLocalPort(locPort);
spi.setLocalPortRange(1);
cfg.setDiscoverySpi(spi);
cfg.setLocalHost("127.0.0.1");
cfg.setConnectorConfiguration(null);
TcpCommunicationSpi commSpi = new TcpCommunicationSpi() {
@Override
protected GridCommunicationClient createTcpClient(ClusterNode node, int connIdx) throws IgniteCheckedException {
Map<String, Object> attrs = new HashMap<>(node.attributes());
attrs.remove(createSpiAttributeName(ATTR_PORT));
((TcpDiscoveryNode) node).setAttributes(attrs);
return super.createTcpClient(node, connIdx);
}
};
commSpi.setLocalAddress("127.0.0.1");
commSpi.setLocalPort(commLocPort);
commSpi.setLocalPortRange(1);
commSpi.setSharedMemoryPort(-1);
commSpi.setConnectionsPerNode(1);
cfg.setCommunicationSpi(commSpi);
assert rslvr != null;
cfg.setAddressResolver(rslvr);
return cfg;
}
use of org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi in project ignite by apache.
the class GridTaskFailoverAffinityRunTest method getConfiguration.
/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(ipFinder);
((TcpCommunicationSpi) cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
boolean client = clientMode && igniteInstanceName.equals(getTestIgniteInstanceName(0));
if (client) {
cfg.setClientMode(true);
((TcpDiscoverySpi) cfg.getDiscoverySpi()).setForceServerMode(true);
}
CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfg.setCacheMode(PARTITIONED);
ccfg.setBackups(1);
ccfg.setAtomicityMode(ATOMIC);
ccfg.setRebalanceMode(SYNC);
cfg.setCacheConfiguration(ccfg);
return cfg;
}
use of org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi in project ignite by apache.
the class GridCommunicationSendMessageSelfTest method getConfiguration.
/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration c = super.getConfiguration(igniteInstanceName);
TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
discoSpi.setIpFinder(ipFinder);
c.setDiscoverySpi(discoSpi);
TcpCommunicationSpi commSpi = new TcpCommunicationSpi();
c.setCommunicationSpi(commSpi);
return c;
}
use of org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi in project ignite by apache.
the class IgniteCommunicationBalanceTest method waitNioBalanceStop.
/**
* @param nodes Node.
* @param timeout Timeout.
* @throws Exception If failed.
*/
private void waitNioBalanceStop(List<Ignite> nodes, long timeout) throws Exception {
final List<GridNioServer> srvs = new ArrayList<>();
for (Ignite node : nodes) {
TcpCommunicationSpi spi = (TcpCommunicationSpi) node.configuration().getCommunicationSpi();
GridNioServer srv = GridTestUtils.getFieldValue(spi, "nioSrvr");
srvs.add(srv);
}
assertTrue(GridTestUtils.waitForCondition(new GridAbsPredicateX() {
@Override
public boolean applyx() throws IgniteCheckedException {
List<Long> rCnts = new ArrayList<>();
List<Long> wCnts = new ArrayList<>();
for (GridNioServer srv : srvs) {
long readerMovCnt1 = srv.readerMoveCount();
long writerMovCnt1 = srv.writerMoveCount();
rCnts.add(readerMovCnt1);
wCnts.add(writerMovCnt1);
}
U.sleep(2000);
for (int i = 0; i < srvs.size(); i++) {
GridNioServer srv = srvs.get(i);
long readerMovCnt1 = rCnts.get(i);
long writerMovCnt1 = wCnts.get(i);
long readerMovCnt2 = srv.readerMoveCount();
long writerMovCnt2 = srv.writerMoveCount();
if (readerMovCnt1 != readerMovCnt2) {
log.info("Readers balance is in progress [node=" + i + ", cnt1=" + readerMovCnt1 + ", cnt2=" + readerMovCnt2 + ']');
return false;
}
if (writerMovCnt1 != writerMovCnt2) {
log.info("Writers balance is in progress [node=" + i + ", cnt1=" + writerMovCnt1 + ", cnt2=" + writerMovCnt2 + ']');
return false;
}
}
return true;
}
}, timeout));
}
Aggregations