Search in sources :

Example 76 with IgniteConfiguration

use of org.apache.ignite.configuration.IgniteConfiguration in project ignite by apache.

the class GridSingleExecutionTest method getConfigurations.

/**
 * Initializes configurations.
 *
 * @param springCfgPath Configuration file path.
 * @param log Log file name.
 * @return List of configurations.
 * @throws IgniteCheckedException If failed..
 */
@SuppressWarnings("unchecked")
private static Iterable<IgniteConfiguration> getConfigurations(String springCfgPath, String log) throws IgniteCheckedException {
    File path = GridTestUtils.resolveIgnitePath(springCfgPath);
    if (path == null) {
        throw new IgniteCheckedException("Spring XML configuration file path is invalid: " + new File(springCfgPath) + ". Note that this path should be either absolute path or a relative path to IGNITE_HOME.");
    }
    if (!path.isFile())
        throw new IgniteCheckedException("Provided file path is not a file: " + path);
    // Add no-op logger to remove no-appender warning.
    Appender app = new NullAppender();
    Logger.getRootLogger().addAppender(app);
    ApplicationContext springCtx;
    try {
        springCtx = new FileSystemXmlApplicationContext(path.toURI().toURL().toString());
    } catch (BeansException | MalformedURLException e) {
        throw new IgniteCheckedException("Failed to instantiate Spring XML application context: " + e.getMessage(), e);
    }
    Map cfgMap;
    try {
        // Note: Spring is not generics-friendly.
        cfgMap = springCtx.getBeansOfType(IgniteConfiguration.class);
    } catch (BeansException e) {
        throw new IgniteCheckedException("Failed to instantiate bean [type=" + IgniteConfiguration.class + ", err=" + e.getMessage() + ']', e);
    }
    if (cfgMap == null)
        throw new IgniteCheckedException("Failed to find a single grid factory configuration in: " + path);
    // Remove previously added no-op logger.
    Logger.getRootLogger().removeAppender(app);
    if (cfgMap.isEmpty())
        throw new IgniteCheckedException("Can't find grid factory configuration in: " + path);
    Collection<IgniteConfiguration> res = new ArrayList<>();
    for (IgniteConfiguration cfg : (Collection<IgniteConfiguration>) cfgMap.values()) {
        UUID nodeId = UUID.randomUUID();
        cfg.setNodeId(nodeId);
        cfg.setGridLogger(initLogger(log));
        res.add(cfg);
    }
    return res;
}
Also used : NullAppender(org.apache.log4j.varia.NullAppender) Appender(org.apache.log4j.Appender) ConsoleAppender(org.apache.log4j.ConsoleAppender) RollingFileAppender(org.apache.log4j.RollingFileAppender) MalformedURLException(java.net.MalformedURLException) NullAppender(org.apache.log4j.varia.NullAppender) ArrayList(java.util.ArrayList) FileSystemXmlApplicationContext(org.springframework.context.support.FileSystemXmlApplicationContext) FileSystemXmlApplicationContext(org.springframework.context.support.FileSystemXmlApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) Collection(java.util.Collection) UUID(java.util.UUID) File(java.io.File) Map(java.util.Map) BeansException(org.springframework.beans.BeansException)

Example 77 with IgniteConfiguration

use of org.apache.ignite.configuration.IgniteConfiguration in project ignite by apache.

the class GridServiceProxyNodeStopSelfTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER));
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 78 with IgniteConfiguration

use of org.apache.ignite.configuration.IgniteConfiguration in project ignite by apache.

the class GridServiceSerializationSelfTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER));
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 79 with IgniteConfiguration

use of org.apache.ignite.configuration.IgniteConfiguration in project ignite by apache.

the class IgniteServiceDynamicCachesSelfTest method getConfiguration.

/**
 * {@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);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 80 with IgniteConfiguration

use of org.apache.ignite.configuration.IgniteConfiguration in project ignite by apache.

the class IgniteDynamicCacheMultinodeTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    ((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(ipFinder);
    cfg.setClientMode(client);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Aggregations

IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)2118 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)686 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)404 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)385 DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)363 Ignite (org.apache.ignite.Ignite)194 Test (org.junit.Test)182 RendezvousAffinityFunction (org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction)161 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)127 TcpCommunicationSpi (org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi)123 TcpDiscoveryVmIpFinder (org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder)105 TestRecordingCommunicationSpi (org.apache.ignite.internal.TestRecordingCommunicationSpi)98 IgniteEx (org.apache.ignite.internal.IgniteEx)95 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)89 IgniteException (org.apache.ignite.IgniteException)78 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)75 BinaryMarshaller (org.apache.ignite.internal.binary.BinaryMarshaller)72 ConnectorConfiguration (org.apache.ignite.configuration.ConnectorConfiguration)68 BinaryConfiguration (org.apache.ignite.configuration.BinaryConfiguration)65 ArrayList (java.util.ArrayList)55