Apache Ignite embedded cluster mode

Viewed 514

I have run two application with embedded mode having the following config:

public IgniteConfigurer config() {
    return cfg -> {
        // The node will be started as a client node.
        cfg.setClientMode(false);
        // Classes of custom Java logic will be transferred over the wire from this app.
        cfg.setPeerClassLoadingEnabled(false);
        // Setting up an IP Finder to ensure the client can locate the servers.
        final TcpDiscoveryMulticastIpFinder ipFinder = new TcpDiscoveryMulticastIpFinder();
        ipFinder.setAddresses(Collections.singletonList(cacheServerIp));
        cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(ipFinder));
        // Cache Metrics log frequency. If 0 then log print disable.
        cfg.setMetricsLogFrequency(Integer.parseInt(cacheMetricsLogFrequency));
        // setting up storage configuration
        final DataStorageConfiguration storageCfg = new DataStorageConfiguration();
        storageCfg.getDefaultDataRegionConfiguration().setPersistenceEnabled(true);
        storageCfg.setStoragePath(cacheStorage);
        // setting up data region for storage
        final DataRegionConfiguration defaultRegion = new DataRegionConfiguration();
        defaultRegion.setName(cacheDefaultRegionName);
        // Sets initial memory region size. When the used memory size exceeds this value, new chunks of memory will be allocated
        defaultRegion.setInitialSize(Long.parseLong(cacheRegionInitSize));
        storageCfg.setDefaultDataRegionConfiguration(defaultRegion);
        cfg.setDataStorageConfiguration(storageCfg);
        cfg.setWorkDirectory(cacheStorage);
        final TcpCommunicationSpi communicationSpi = new TcpCommunicationSpi();
        // Sets message queue limit for incoming and outgoing messages
        communicationSpi.setMessageQueueLimit(Integer.parseInt(cacheTcpCommunicationSpiMessageQueueLimit));
        cfg.setCommunicationSpi(communicationSpi);
        final CacheCheckpointSpi cpSpi = new CacheCheckpointSpi();
        cfg.setCheckpointSpi(cpSpi);
        final FifoQueueCollisionSpi colSpi = new FifoQueueCollisionSpi();
        // Execute all jobs sequentially by setting parallel job number to 1.
        colSpi.setParallelJobsNumber(Integer.parseInt(cacheParallelJobs));
        cfg.setCollisionSpi(colSpi);
        // set failure handler for auto connection if ignite server stop/starts.
        cfg.setFailureHandler(new StopNodeFailureHandler());
    };
}

App1 put data in cache where as App2 read data from cache. I have set local IP i.e ipFinder.setAddresses(Collections.singletonList("127.0.0.1:47500..47509"));

So locally both apps i.e app1 and app2 connected on cluster. When i put same config on server with IP change i.e ipFinder.setAddresses(Collections.singletonList("server1.com:47500..47509"));

Both servers i.e app1 and app2 not connected in cluster.

Is it embedded work only when all apps i.e app1 and app2 are on same machine?

1 Answers

Try using a static TcpDiscoveryVmIpFinder instead to locate the issue. By default, TcpDiscoveryMulticastIpFinder tries to scan all available hosts to discover Ignite nodes, and depending on timeouts this might take a while.

Assuming both of your nodes are still running on the same machine, you might keep the localhost configuration: "127.0.0.1:47500..47509". "server1.com:47500..47509" should also work if DNS name "server1.com" resolves to the correct IP address, the best way to check that - just to run a ping command to check how localhost and server1.com are being resolved.

If you are running on different machines, then you need to have a list of addresses rather than a singleton: "server1.com:47500..47509", "server2.com:47500.47509" etc.

It's also recommended to check whether the ports are opened and probably to configure a localHost explicitly if there are many different interfaces available.

Related