Search in sources :

Example 11 with TcpCommunicationSpi

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;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 12 with TcpCommunicationSpi

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;
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder) HashMap(java.util.HashMap) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi) TcpDiscoveryNode(org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 13 with TcpCommunicationSpi

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;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 14 with TcpCommunicationSpi

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;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 15 with TcpCommunicationSpi

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));
}
Also used : ArrayList(java.util.ArrayList) GridAbsPredicateX(org.apache.ignite.internal.util.lang.GridAbsPredicateX) Ignite(org.apache.ignite.Ignite) GridNioServer(org.apache.ignite.internal.util.nio.GridNioServer) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi)

Aggregations

TcpCommunicationSpi (org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi)109 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)94 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)72 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)29 MemoryEventStorageSpi (org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi)8 CommunicationSpi (org.apache.ignite.spi.communication.CommunicationSpi)6 ClusterNode (org.apache.ignite.cluster.ClusterNode)5 AtomicConfiguration (org.apache.ignite.configuration.AtomicConfiguration)5 TransactionConfiguration (org.apache.ignite.configuration.TransactionConfiguration)5 BinaryMarshaller (org.apache.ignite.internal.binary.BinaryMarshaller)5 HashMap (java.util.HashMap)4 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)4 IgniteSpiException (org.apache.ignite.spi.IgniteSpiException)4 LinkedHashMap (java.util.LinkedHashMap)3 UUID (java.util.UUID)3 IgniteException (org.apache.ignite.IgniteException)3 GridIoManager (org.apache.ignite.internal.managers.communication.GridIoManager)3 DiscoverySpi (org.apache.ignite.spi.discovery.DiscoverySpi)3 ArrayList (java.util.ArrayList)2 CountDownLatch (java.util.concurrent.CountDownLatch)2