Java Code Examples for org.apache.ignite.configuration.IgniteConfiguration#setCommunicationSpi()

The following examples show how to use org.apache.ignite.configuration.IgniteConfiguration#setCommunicationSpi() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TxRecoveryStoreEnabledTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);

    cfg.setCommunicationSpi(new TestCommunicationSpi());

    CacheConfiguration ccfg = defaultCacheConfiguration();

    ccfg.setName(CACHE_NAME);
    ccfg.setNearConfiguration(null);
    ccfg.setCacheMode(CacheMode.PARTITIONED);
    ccfg.setBackups(1);
    ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
    ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    ccfg.setCacheStoreFactory(new TestCacheStoreFactory());
    ccfg.setReadThrough(true);
    ccfg.setWriteThrough(true);
    ccfg.setWriteBehindEnabled(false);

    cfg.setCacheConfiguration(ccfg);

    cfg.setFailureHandler(new StopNodeFailureHandler());

    return cfg;
}
 
Example 2
Source File: HadoopIgfs20FileSystemAbstractSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();

    discoSpi.setIpFinder(IP_FINDER);

    cfg.setDiscoverySpi(discoSpi);
    cfg.setFileSystemConfiguration(igfsConfiguration(igniteInstanceName));
    cfg.setIncludeEventTypes(EVT_TASK_FAILED, EVT_TASK_FINISHED, EVT_JOB_MAPPED);
    cfg.setLocalHost("127.0.0.1");
    cfg.setCommunicationSpi(communicationSpi());

    return cfg;
}
 
Example 3
Source File: TxRollbackOnTimeoutTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    cfg.setConsistentId(igniteInstanceName);
    cfg.setCommunicationSpi(new TestRecordingCommunicationSpi());

    if (!"client".equals(igniteInstanceName)) {
        CacheConfiguration ccfg = new CacheConfiguration(CACHE_NAME);

        if (nearCacheEnabled())
            ccfg.setNearConfiguration(new NearCacheConfiguration());

        ccfg.setAtomicityMode(TRANSACTIONAL);
        ccfg.setBackups(2);
        ccfg.setWriteSynchronizationMode(FULL_SYNC);

        cfg.setCacheConfiguration(ccfg);
    }

    return cfg;
}
 
Example 4
Source File: StandaloneGridKernalContext.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @return Ignite configuration which allows to start requied processors for WAL reader
 */
protected IgniteConfiguration prepareIgniteConfiguration() {
    IgniteConfiguration cfg = new IgniteConfiguration();

    cfg.setDiscoverySpi(new StandaloneNoopDiscoverySpi());
    cfg.setCommunicationSpi(new StandaloneNoopCommunicationSpi());

    final Marshaller marshaller = new BinaryMarshaller();
    cfg.setMarshaller(marshaller);

    final DataStorageConfiguration pstCfg = new DataStorageConfiguration();
    final DataRegionConfiguration regCfg = new DataRegionConfiguration();
    regCfg.setPersistenceEnabled(true);
    pstCfg.setDefaultDataRegionConfiguration(regCfg);

    cfg.setDataStorageConfiguration(pstCfg);

    marshaller.setContext(marshallerCtx);

    cfg.setMetricExporterSpi(new NoopMetricExporterSpi());
    cfg.setSystemViewExporterSpi(new JmxSystemViewExporterSpi());

    return cfg;
}
 
Example 5
Source File: TxRollbackOnMapOnInvalidTopologyTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    cfg.setConsistentId(igniteInstanceName);
    cfg.setCommunicationSpi(new TestRecordingCommunicationSpi());

    CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);

    ccfg.setAtomicityMode(TRANSACTIONAL);
    ccfg.setBackups(2);
    ccfg.setWriteSynchronizationMode(FULL_SYNC);

    cfg.setCacheConfiguration(ccfg);

    return cfg;
}
 
Example 6
Source File: IgnitePdsSpuriousRebalancingOnNodeJoinTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    cfg.setCommunicationSpi(new TestRecordingCommunicationSpi());

    cfg.setConsistentId(igniteInstanceName);

    DataStorageConfiguration dsCfg = new DataStorageConfiguration();
    dsCfg.setWalSegmentSize(4 * 1024 * 1024);
    dsCfg.setPageSize(1024);

    dsCfg.setDefaultDataRegionConfiguration(new DataRegionConfiguration().
        setInitialSize(100L * 1024 * 1024).
        setMaxSize(200L * 1024 * 1024).
        setPersistenceEnabled(true));

    cfg.setDataStorageConfiguration(dsCfg);

    cfg.setCacheConfiguration(new CacheConfiguration(DEFAULT_CACHE_NAME).
        setAtomicityMode(TRANSACTIONAL).
        setCacheMode(REPLICATED).
        setAffinity(new RendezvousAffinityFunction(false, PARTS)));

    return cfg;
}
 
Example 7
Source File: IgniteTxPessimisticOriginatingNodeFailureAbstractSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    cfg.setCommunicationSpi(new TcpCommunicationSpi() {
        @Override public void sendMessage(ClusterNode node, Message msg,
            IgniteInClosure<IgniteException> ackClosure) throws IgniteSpiException {
            if (getSpiContext().localNode().id().equals(failingNodeId)) {
                if (ignoredMessage((GridIoMessage)msg) && ignoreMsgNodeIds != null) {
                    for (UUID ignored : ignoreMsgNodeIds) {
                        if (node.id().equals(ignored))
                            return;
                    }
                }
            }

            super.sendMessage(node, msg, ackClosure);
        }
    });

    cfg.getTransactionConfiguration().setDefaultTxConcurrency(PESSIMISTIC);

    return cfg;
}
 
Example 8
Source File: SlowHistoricalRebalanceSmallHistoryTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String name) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(name);

    cfg.setConsistentId(name);

    cfg.setDataStorageConfiguration(
        new DataStorageConfiguration()
            .setWalHistorySize(WAL_HISTORY_SIZE)
            .setDefaultDataRegionConfiguration(
                new DataRegionConfiguration()
                    .setMaxSize(DataStorageConfiguration.DFLT_DATA_REGION_INITIAL_SIZE)
                    .setPersistenceEnabled(true)
            )
            .setWalSegmentSize(512 * 1024)
    );

    cfg.setFailureHandler(new StopNodeFailureHandler());

    cfg.setCommunicationSpi(new RebalanceBlockingSPI());

    return cfg;
}
 
Example 9
Source File: NodeWithFilterRestartTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
    @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

        if (getTestIgniteInstanceName(5).equals(igniteInstanceName))
            cfg.setUserAttributes(F.asMap("FILTER", "true"));

//        if (getTestIgniteInstanceName(3).equals(igniteInstanceName))
//            cfg.setUserAttributes(F.asMap("FILTER", "true"));

        cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER));

        if (getTestIgniteInstanceName(0).equals(igniteInstanceName)) {
            TestRecordingCommunicationSpi commSpi = new TestRecordingCommunicationSpi();

            commSpi.blockMessages(new IgniteBiPredicate<ClusterNode, Message>() {
                /** {@inheritDoc} */
                @Override public boolean apply(ClusterNode node, Message msg) {
                    if (msg instanceof GridDhtPartitionsFullMessage && (node.id().getLeastSignificantBits() & 0xFFFF) == 5) {
                        GridDhtPartitionsFullMessage fullMsg = (GridDhtPartitionsFullMessage)msg;

                        if (fullMsg.exchangeId() != null && fullMsg.topologyVersion().equals(new AffinityTopologyVersion(8, 0))) {
                            info("Going to block message [node=" + node + ", msg=" + msg + ']');

                            return true;
                        }
                    }

                    return false;
                }
            });

            cfg.setCommunicationSpi(commSpi);
        }
        else
            cfg.setCommunicationSpi(new TestRecordingCommunicationSpi());

        return cfg;
    }
 
Example 10
Source File: CacheMvccTxRecoveryTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);

    cfg.setCommunicationSpi(new TestRecordingCommunicationSpi());

    return cfg;
}
 
Example 11
Source File: CachePartitionLostAfterSupplierHasLeftTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    cfg.setCommunicationSpi(new TestRecordingCommunicationSpi());

    cfg.setActiveOnStart(false);

    cfg.setConsistentId(igniteInstanceName);

    cfg.setDataStorageConfiguration(
        new DataStorageConfiguration()
            .setWalMode(WALMode.LOG_ONLY)
            .setWalSegmentSize(4 * 1024 * 1024)
            .setDefaultDataRegionConfiguration(
                new DataRegionConfiguration()
                    .setPersistenceEnabled(persistence)
                    .setMaxSize(100L * 1024 * 1024))
    );

    cfg.setCacheConfiguration(new CacheConfiguration(DEFAULT_CACHE_NAME).
        setAtomicityMode(TRANSACTIONAL).
        setCacheMode(PARTITIONED).
        setBackups(1).
        setPartitionLossPolicy(lossPlc).
        setAffinity(new RendezvousAffinityFunction(false, PARTS_CNT)));

    return cfg;
}
 
Example 12
Source File: FullHistRebalanceOnClientStopTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);

    cfg.setConsistentId(gridName);

    CacheConfiguration<Object, Object> ccfg1 = new CacheConfiguration<>(CACHE_NAME)
        .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL)
        .setCacheMode(CacheMode.PARTITIONED)
        .setBackups(1)
        .setAffinity(new RendezvousAffinityFunction(false, PARTS_CNT));

    cfg.setCacheConfiguration(ccfg1);

    DataStorageConfiguration dbCfg = new DataStorageConfiguration()
        .setWalMode(WALMode.LOG_ONLY)
        .setDefaultDataRegionConfiguration(
            new DataRegionConfiguration()
                .setPersistenceEnabled(true)
                .setMaxSize(100 * 1024 * 1024)
        );

    cfg.setDataStorageConfiguration(dbCfg);

    cfg.setCommunicationSpi(new RebalanceCheckingCommunicationSpi());

    return cfg;
}
 
Example 13
Source File: CacheClientsConcurrentStartTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);

    TcpDiscoverySpi testSpi = new TcpDiscoverySpi() {
        @Override protected void writeToSocket(Socket sock, OutputStream out, TcpDiscoveryAbstractMessage msg, long timeout) throws IOException, IgniteCheckedException {
            if (msg instanceof TcpDiscoveryCustomEventMessage && msg.verified()) {
                try {
                    System.out.println(Thread.currentThread().getName() + " delay custom message");

                    U.sleep(ThreadLocalRandom.current().nextLong(500) + 100);
                }
                catch (Exception e) {
                    e.printStackTrace();
                }
            }

            super.writeToSocket(sock, out, msg, timeout);
        }
    };

    cfg.setMarshaller(null);

    cfg.setCommunicationSpi(new TestRecordingCommunicationSpi());

    if (getTestIgniteInstanceIndex(gridName) < SRV_CNT) {
        CacheConfiguration ccfgs[] = new CacheConfiguration[CACHES / 2];

        for (int i = 0; i < ccfgs.length; i++)
            ccfgs[i] = cacheConfiguration("cache-" + i);

        cfg.setCacheConfiguration(ccfgs);
    }

    return cfg;
}
 
Example 14
Source File: GridExchangeFreeCellularSwitchAbstractTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    TestRecordingCommunicationSpi commSpi = new TestRecordingCommunicationSpi();

    cfg.setCommunicationSpi(commSpi);

    cfg.setCacheConfiguration(cacheConfiguration());

    cfg.setClusterStateOnStart(ClusterState.INACTIVE);

    DataStorageConfiguration dsCfg = new DataStorageConfiguration();

    DataRegionConfiguration drCfg = new DataRegionConfiguration();

    drCfg.setPersistenceEnabled(true);

    dsCfg.setDefaultDataRegionConfiguration(drCfg);

    cfg.setDataStorageConfiguration(dsCfg);

    cfg.setGridLogger(listeningLog);

    return cfg;
}
 
Example 15
Source File: IgniteConnectionConcurrentReserveAndRemoveTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration c = super.getConfiguration(igniteInstanceName);

    DataStorageConfiguration memCfg = new DataStorageConfiguration().setDefaultDataRegionConfiguration(
        new DataRegionConfiguration().setMaxSize(50 * 1024 * 1024));

    c.setDataStorageConfiguration(memCfg);

    TestRecordingCommunicationSpi spi = new TestRecordingCommunicationSpi();
    spi.setIdleConnectionTimeout(Integer.MAX_VALUE);

    c.setCommunicationSpi(spi);

    return c;
}
 
Example 16
Source File: IgniteTcpCommunicationHandshakeWaitTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    cfg.setPeerClassLoadingEnabled(false);

    TcpDiscoverySpi discoSpi = new SlowTcpDiscoverySpi();

    discoSpi.setIpFinder(sharedStaticIpFinder);

    cfg.setDiscoverySpi(discoSpi);

    TcpCommunicationSpi commSpi = new TcpCommunicationSpi();

    commSpi.setConnectTimeout(COMMUNICATION_TIMEOUT);
    commSpi.setMaxConnectTimeout(4 * COMMUNICATION_TIMEOUT);
    commSpi.setReconnectCount(3);

    cfg.setCommunicationSpi(commSpi);

    return cfg;
}
 
Example 17
Source File: HadoopIgfs20FileSystemAbstractSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * Starts the nodes for this test.
 *
 * @throws Exception If failed.
 */
private void startNodes() throws Exception {
    if (mode != PRIMARY) {
        // Start secondary IGFS.
        FileSystemConfiguration igfsCfg = new FileSystemConfiguration();

        igfsCfg.setName("igfs_secondary");
        igfsCfg.setIpcEndpointConfiguration(secondaryIpcEndpointConfiguration());
        igfsCfg.setManagementPort(-1);
        igfsCfg.setBlockSize(512 * 1024);
        igfsCfg.setPrefetchBlocks(1);

        CacheConfiguration dataCacheCfg = defaultCacheConfiguration();

        dataCacheCfg.setName("partitioned");
        dataCacheCfg.setCacheMode(PARTITIONED);
        dataCacheCfg.setNearConfiguration(null);
        dataCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
        dataCacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(GRP_SIZE));
        dataCacheCfg.setBackups(0);
        dataCacheCfg.setAtomicityMode(TRANSACTIONAL);

        CacheConfiguration metaCacheCfg = defaultCacheConfiguration();

        metaCacheCfg.setName("replicated");
        metaCacheCfg.setCacheMode(REPLICATED);
        metaCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
        metaCacheCfg.setAtomicityMode(TRANSACTIONAL);

        igfsCfg.setDataCacheConfiguration(dataCacheCfg);
        igfsCfg.setMetaCacheConfiguration(metaCacheCfg);

        IgniteConfiguration cfg = new IgniteConfiguration();

        cfg.setIgniteInstanceName("grid_secondary");

        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();

        discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true));

        cfg.setDiscoverySpi(discoSpi);
        cfg.setCacheConfiguration(metaCacheCfg, dataCacheCfg);
        cfg.setFileSystemConfiguration(igfsCfg);
        cfg.setIncludeEventTypes(EVT_TASK_FAILED, EVT_TASK_FINISHED, EVT_JOB_MAPPED);
        cfg.setLocalHost(U.getLocalHost().getHostAddress());
        cfg.setCommunicationSpi(communicationSpi());

        G.start(cfg);
    }

    startGrids(4);

    awaitPartitionMapExchange();
}
 
Example 18
Source File: GridSingleSplitsNewNodesAbstractLoadTest.java    From ignite with Apache License 2.0 3 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    cfg.setCommunicationSpi(new TcpCommunicationSpi());

    cfg.setDiscoverySpi(getDiscoverySpi(cfg));

    cfg.setMetricsHistorySize(1000);

    cfg.setPublicThreadPoolSize(100);

    return cfg;
}
 
Example 19
Source File: ClusterStateNoRebalanceAbstractTest.java    From ignite with Apache License 2.0 3 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);

    cfg.setActiveOnStart(false);

    cfg.setCacheConfiguration(cacheConfiguration(DEFAULT_CACHE_NAME));

    cfg.setClientMode(gridName.startsWith("client"));

    cfg.setCommunicationSpi(new TestCommunicationSpi());

    return cfg;
}
 
Example 20
Source File: IgniteCacheReadFromBackupTest.java    From ignite with Apache License 2.0 3 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    TestRecordingCommunicationSpi commSpi = new TestRecordingCommunicationSpi();

    cfg.setCommunicationSpi(commSpi);

    return cfg;
}