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

The following examples show how to use org.apache.ignite.configuration.IgniteConfiguration#setDiscoverySpi() . 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: GridifySingleSplitLoadTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration() throws Exception {
    IgniteConfiguration cfg = super.getConfiguration();

    /* Uncomment following code if you start it manually. */
        CommunicationSpi commSpi = new TcpCommunicationSpi();

        cfg.setCommunicationSpi(commSpi);

        DiscoverySpi discoSpi = new TcpDiscoverySpi();

        cfg.setDiscoverySpi(discoSpi);
    /*
     */
    @SuppressWarnings("TypeMayBeWeakened")
    Log4JLogger log = (Log4JLogger)cfg.getGridLogger();

    log.getLogger("org.apache.ignite").setLevel(Level.INFO);

    return cfg;
}
 
Example 2
Source File: TcpDiscoverySpiConfigSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testLocalPortRange() throws Exception {
    try {
        IgniteConfiguration cfg = getConfiguration();

        TcpDiscoverySpi spi = new TcpDiscoverySpi();

        spi.setIpFinder(new TcpDiscoveryVmIpFinder(true));
        spi.setLocalPortRange(0);
        cfg.setDiscoverySpi(spi);

        startGrid(cfg.getIgniteInstanceName(), cfg);
    }
    finally {
        stopAllGrids();
    }
}
 
Example 3
Source File: GridClosureProcessorRemoteTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration() throws Exception {
    IgniteConfiguration cfg = new IgniteConfiguration();

    cfg.setDiscoverySpi(new TcpDiscoverySpi());

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

    cfg.setDiscoverySpi(new TcpDiscoverySpi());

    CacheConfiguration ccfg = defaultCacheConfiguration();

    ccfg.setCacheMode(PARTITIONED);

    ccfg.setNearConfiguration(near ? new NearCacheConfiguration() : null);

    ccfg.setCacheMode(CacheMode.PARTITIONED);

    ccfg.setName(CACHE_NAME);

    switch (tmConfigurationType) {
        case CACHE_LOOKUP:
            ccfg.setTransactionManagerLookupClassName(TestTxLookup.class.getName());
            break;
        case GLOBAL_LOOKUP:
            cfg.getTransactionConfiguration().setTxManagerLookupClassName(TestTxLookup.class.getName());
            break;
        case FACTORY:
            cfg.getTransactionConfiguration().setTxManagerFactory(new TestTxFactory());
            break;
    }

    cfg.setCacheConfiguration(ccfg);

    return cfg;
}
 
Example 5
Source File: IgniteDemo.java    From banyan with MIT License 5 votes vote down vote up
public static IgniteConfiguration getIgniteConfiguration() {
    IgniteConfiguration configuration = new IgniteConfiguration();
    TcpDiscoverySpi tcpDiscoverySpi = new TcpDiscoverySpi();
    TcpDiscoveryVmIpFinder tcpDiscoveryVmIpFinder = new TcpDiscoveryVmIpFinder();
    tcpDiscoveryVmIpFinder.setAddresses(addresses);
    tcpDiscoverySpi.setIpFinder(tcpDiscoveryVmIpFinder);

    configuration.setDiscoverySpi(tcpDiscoverySpi);
    configuration.setClientMode(true);
    configuration.setPeerClassLoadingEnabled(true);
    return configuration;
}
 
Example 6
Source File: GridCacheNearOneNodeSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override protected IgniteConfiguration getConfiguration() throws Exception {
    MvccFeatureChecker.skipIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE);

    IgniteConfiguration cfg = super.getConfiguration();

    TcpDiscoverySpi disco = new TcpDiscoverySpi();

    disco.setIpFinder(new TcpDiscoveryVmIpFinder(true));

    cfg.setDiscoverySpi(disco);

    CacheConfiguration cacheCfg = defaultCacheConfiguration();

    cacheCfg.setCacheMode(PARTITIONED);
    cacheCfg.setBackups(1);
    cacheCfg.setAtomicityMode(TRANSACTIONAL);
    cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    cacheCfg.setNearConfiguration(new NearCacheConfiguration());

    cacheCfg.setCacheStoreFactory(singletonFactory(store));
    cacheCfg.setReadThrough(true);
    cacheCfg.setWriteThrough(true);
    cacheCfg.setLoadPreviousValue(true);

    cfg.setCacheConfiguration(cacheCfg);

    return cfg;
}
 
Example 7
Source File: DynamicIndexAbstractConcurrentSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration commonConfiguration(int idx) throws Exception {
    IgniteConfiguration cfg = super.commonConfiguration(idx);

    TestTcpDiscoverySpi testSpi = new TestTcpDiscoverySpi();

    if (cfg.getDiscoverySpi() instanceof TcpDiscoverySpi &&
        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).getIpFinder() != null)
        testSpi.setIpFinder(((TcpDiscoverySpi)cfg.getDiscoverySpi()).getIpFinder());

    return cfg.setDiscoverySpi(testSpi);
}
 
Example 8
Source File: GridBinaryCacheEntryMemorySizeSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected Marshaller createMarshaller() throws IgniteCheckedException {
    BinaryMarshaller marsh = new BinaryMarshaller();

    IgniteConfiguration iCfg = new IgniteConfiguration();
    iCfg.setDiscoverySpi(new TcpDiscoverySpi() {
        @Override public void sendCustomEvent(DiscoverySpiCustomMessage msg) throws IgniteException {
            // No-op.
        }
    });
    iCfg.setClientMode(false);
    iCfg.setSystemViewExporterSpi(new JmxSystemViewExporterSpi() {
        @Override protected void register(SystemView<?> sysView) {
            // No-op.
        }
    });

    GridTestKernalContext kernCtx = new GridTestKernalContext(log, iCfg);
    kernCtx.add(new GridSystemViewManager(kernCtx));
    kernCtx.add(new GridDiscoveryManager(kernCtx));

    MarshallerContextTestImpl marshCtx = new MarshallerContextTestImpl(null);
    marshCtx.onMarshallerProcessorStarted(kernCtx, null);

    marsh.setContext(marshCtx);

    BinaryContext pCtx = new BinaryContext(BinaryNoopMetadataHandler.instance(), iCfg, new NullLogger());

    IgniteUtils.invoke(BinaryMarshaller.class, marsh, "setBinaryContext", pCtx, iCfg);

    return marsh;
}
 
Example 9
Source File: SqlConnectorConfigurationValidationSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * Perform check.
 *
 * @param sqlCfg SQL configuration.
 * @param success Success flag. * @throws Exception If failed.
 */
@SuppressWarnings({"unchecked"})
private void check(SqlConnectorConfiguration sqlCfg, boolean success) throws Exception {
    final IgniteConfiguration cfg = super.getConfiguration();

    cfg.setIgniteInstanceName(SqlConnectorConfigurationValidationSelfTest.class.getName() + "-" +
        NODE_IDX_GEN.incrementAndGet());

    cfg.setLocalHost("127.0.0.1");
    cfg.setSqlConnectorConfiguration(sqlCfg);
    cfg.setMarshaller(new BinaryMarshaller());

    TcpDiscoverySpi spi = new TcpDiscoverySpi();
    spi.setIpFinder(new TcpDiscoveryVmIpFinder(true));

    cfg.setDiscoverySpi(spi);

    CacheConfiguration ccfg = new CacheConfiguration(CACHE_NAME)
        .setIndexedTypes(SqlConnectorKey.class, SqlConnectorValue.class);

    cfg.setCacheConfiguration(ccfg);

    if (success)
        startGrid(cfg.getIgniteInstanceName(), cfg);
    else {
        GridTestUtils.assertThrows(log, new Callable<Void>() {
            @Override public Void call() throws Exception {
                startGrid(cfg.getIgniteInstanceName(), cfg);

                return null;
            }
        }, IgniteException.class, null);
    }
}
 
Example 10
Source File: ApplicationConfiguration.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * Ignite instance bean - no instance name provided on RepositoryConfig
 */
@Bean
public Ignite igniteInstance() {
    IgniteConfiguration cfg = new IgniteConfiguration();

    cfg.setIgniteInstanceName(IGNITE_INSTANCE_ONE);

    CacheConfiguration ccfg = new CacheConfiguration("PersonCache");

    ccfg.setIndexedTypes(Integer.class, Person.class);

    cfg.setCacheConfiguration(ccfg);

    TcpDiscoverySpi spi = new TcpDiscoverySpi();

    spi.setIpFinder(new TcpDiscoveryVmIpFinder(true));

    cfg.setDiscoverySpi(spi);

    return Ignition.start(cfg);
}
 
Example 11
Source File: BasicWarmupClosure.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override public void apply(IgniteConfiguration gridCfg) {
    // Remove cache duplicates, clean up the rest, etc.
    IgniteConfiguration cfg = prepareConfiguration(gridCfg);

    // Do nothing if no caches found.
    if (cfg == null)
        return;

    out("Starting grids to warmup caches [gridCnt=" + gridCnt +
        ", caches=" + cfg.getCacheConfiguration().length + ']');

    Collection<Ignite> ignites = new LinkedList<>();

    String old = System.getProperty(IgniteSystemProperties.IGNITE_UPDATE_NOTIFIER);

    try {
        System.setProperty(IgniteSystemProperties.IGNITE_UPDATE_NOTIFIER, "false");

        TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);

        for (int i = 0; i < gridCnt; i++) {
            IgniteConfiguration cfg0 = new IgniteConfiguration(cfg);

            TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();

            discoSpi.setIpFinder(ipFinder);

            discoSpi.setLocalPort(discoveryPort);

            cfg0.setDiscoverySpi(discoSpi);

            cfg0.setGridLogger(new NullLogger());

            cfg0.setIgniteInstanceName("ignite-warmup-grid-" + i);

            ignites.add(Ignition.start(cfg0));
        }

        doWarmup(ignites);
    }
    catch (Exception e) {
        throw new IgniteException(e);
    }
    finally {
        for (Ignite ignite : ignites)
            Ignition.stop(ignite.name(), false);

        out("Stopped warmup grids.");

        if (old == null)
            old = "false";

        System.setProperty(IgniteSystemProperties.IGNITE_UPDATE_NOTIFIER, old);
    }
}
 
Example 12
Source File: ApplicationConfiguration.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * Ignite instance bean - no instance name provided on RepositoryConfig
 */
@Bean
public Ignite igniteInstance() {
    IgniteConfiguration cfg = new IgniteConfiguration();

    cfg.setIgniteInstanceName(IGNITE_INSTANCE_ONE);

    CacheConfiguration ccfg = new CacheConfiguration("PersonCache");

    ccfg.setIndexedTypes(Integer.class, Person.class);

    cfg.setCacheConfiguration(ccfg);

    TcpDiscoverySpi spi = new TcpDiscoverySpi();

    spi.setIpFinder(new TcpDiscoveryVmIpFinder(true));

    cfg.setDiscoverySpi(spi);

    return Ignition.start(cfg);
}
 
Example 13
Source File: IgfsModesSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * Startup secondary file system.
 *
 * @throws Exception If failed.
 */
private void startUpSecondary() throws Exception {
    FileSystemConfiguration igfsCfg = new FileSystemConfiguration();

    igfsCfg.setName("igfs-secondary");
    igfsCfg.setBlockSize(512 * 1024);
    igfsCfg.setDefaultMode(PRIMARY);

    IgfsIpcEndpointConfiguration endpointCfg = new IgfsIpcEndpointConfiguration();

    endpointCfg.setType(IgfsIpcEndpointType.TCP);
    endpointCfg.setPort(11500);

    CacheConfiguration dataCacheCfg = defaultCacheConfiguration();

    dataCacheCfg.setCacheMode(PARTITIONED);
    dataCacheCfg.setNearConfiguration(null);
    dataCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    dataCacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(128));
    dataCacheCfg.setBackups(0);
    dataCacheCfg.setAtomicityMode(TRANSACTIONAL);

    CacheConfiguration metaCacheCfg = defaultCacheConfiguration();

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

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

    IgniteConfiguration cfg = new IgniteConfiguration();

    cfg.setIgniteInstanceName("igfs-grid-secondary");

    TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();

    discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true));

    cfg.setDiscoverySpi(discoSpi);
    cfg.setFileSystemConfiguration(igfsCfg);

    cfg.setLocalHost("127.0.0.1");
    cfg.setConnectorConfiguration(null);

    igfsSecondary = (IgfsImpl)G.start(cfg).fileSystem("igfs-secondary");
}
 
Example 14
Source File: ComputeLeaveAwareNodeStartup.java    From gridgain-advanced-examples with Apache License 2.0 4 votes vote down vote up
/**
 * Executes example.
 *
 * @param args Command line arguments, none required.
 */
public static void main(String[] args) {
    IgniteConfiguration cfg = new IgniteConfiguration();

    HashMap<String, Object> attrs = new HashMap<>();
    attrs.put("checkpoint_key", "slave_node");

    cfg.setUserAttributes(attrs);

    TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
    ipFinder.setAddresses(Arrays.asList("127.0.0.1:47500..47509"));

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

    // Configuring checkpoints spi.
    CacheCheckpointSpi checkpointSpi = new CacheCheckpointSpi();

    checkpointSpi.setCacheName("checkpoints");

    // Overriding default checkpoints SPI
    cfg.setCheckpointSpi(checkpointSpi);

    Ignition.start(cfg);
}
 
Example 15
Source File: SqlQueryHistorySelfTest.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);

    TcpDiscoverySpi disco = new TcpDiscoverySpi();

    disco.setIpFinder(ipFinder);

    cfg.setDiscoverySpi(disco);

    cfg.setCacheConfiguration(configureCache("A"), configureCache("B"));

    cfg.setSqlConfiguration(new SqlConfiguration().setSqlQueryHistorySize(QUERY_HISTORY_SIZE));

    return cfg;
}
 
Example 16
Source File: JavaStandaloneIgniteRDDSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * @param igniteInstanceName Ignite instance name.
 * @param client Client.
 * @return Cache configuration.
 */
private static IgniteConfiguration getConfiguration(String igniteInstanceName, boolean client) throws Exception {
    IgniteConfiguration cfg = new IgniteConfiguration();

    TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();

    discoSpi.setIpFinder(IP_FINDER);

    cfg.setDiscoverySpi(discoSpi);

    cfg.setCacheConfiguration(
        cacheConfiguration(ENTITY_CACHE_NAME, String.class, Entity.class),
        cacheConfiguration(ENTITY_ALL_TYPES_CACHE_NAME, String.class, EntityTestAllTypeFields.class));

    cfg.setClientMode(client);

    cfg.setIgniteInstanceName(igniteInstanceName);

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

    TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();

    discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true));

    c.setDiscoverySpi(discoSpi);

    c.setPublicThreadPoolSize(SPLIT_COUNT * EXEC_COUNT);

    return c;
}
 
Example 18
Source File: TcpClientDiscoverySpiMulticastTest.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.setLocalHost("127.0.0.1");

    TcpDiscoverySpi spi = new TcpDiscoverySpi();

    TcpDiscoveryMulticastIpFinder ipFinder = new TcpDiscoveryMulticastIpFinder();

    ipFinder.setAddressRequestAttempts(5);

    spi.setIpFinder(ipFinder);

    Boolean clientFlag = client.get();

    client.set(null);

    if (clientFlag != null && clientFlag) {
        cfg.setClientMode(true);

        spi.setForceServerMode(forceSrv);
    }
    else {
        Integer port = discoPort.get();

        discoPort.set(null);

        if (port != null)
            spi.setLocalPort(port);
    }

    cfg.setDiscoverySpi(spi);

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

    CommunicationSpi commSpi = new TcpCommunicationSpi();

    cfg.setCommunicationSpi(commSpi);

    DiscoverySpi discoSpi = new TcpDiscoverySpi();

    cfg.setDiscoverySpi(discoSpi);

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

    cfg.setDiscoverySpi(new TcpDiscoverySpi());

    CacheConfiguration ccfg = defaultCacheConfiguration();

    ccfg.setCacheMode(PARTITIONED);

    ccfg.setWriteBehindEnabled(writeBehind);

    ccfg.setCacheMode(CacheMode.PARTITIONED);

    ccfg.setName(CACHE_NAME);

    TestStore store = new TestStore();

    ccfg.setCacheStoreFactory(singletonFactory(store));
    ccfg.setReadThrough(true);
    ccfg.setWriteThrough(true);
    ccfg.setLoadPreviousValue(true);

    lifecycleAwares.add(store.lifecycleAware);

    TestAffinityFunction affinity = new TestAffinityFunction();

    ccfg.setAffinity(affinity);

    lifecycleAwares.add(affinity);

    TestEvictionPolicy evictionPlc = new TestEvictionPolicy();

    ccfg.setEvictionPolicy(evictionPlc);
    ccfg.setOnheapCacheEnabled(true);

    lifecycleAwares.add(evictionPlc);

    if (near) {
        TestEvictionPolicy nearEvictionPlc = new TestEvictionPolicy();

        NearCacheConfiguration nearCfg = new NearCacheConfiguration();

        nearCfg.setNearEvictionPolicy(nearEvictionPlc);

        ccfg.setNearConfiguration(nearCfg);

        lifecycleAwares.add(nearEvictionPlc);
    }

    TestEvictionFilter evictionFilter = new TestEvictionFilter();

    ccfg.setEvictionFilter(evictionFilter);

    lifecycleAwares.add(evictionFilter);

    TestAffinityKeyMapper mapper = new TestAffinityKeyMapper();

    ccfg.setAffinityMapper(mapper);

    lifecycleAwares.add(mapper);

    TestInterceptor interceptor = new TestInterceptor();

    lifecycleAwares.add(interceptor);

    ccfg.setInterceptor(interceptor);

    TestTopologyValidator topValidator = new TestTopologyValidator();

    lifecycleAwares.add(topValidator);

    ccfg.setTopologyValidator(topValidator);

    cfg.setCacheConfiguration(ccfg);

    return cfg;
}