Search in sources :

Example 1 with AlwaysFailoverSpi

use of org.apache.ignite.spi.failover.always.AlwaysFailoverSpi in project ignite by apache.

the class FaultTolerance method always.

void always() {
    // tag::always[]
    AlwaysFailoverSpi failSpi = new AlwaysFailoverSpi();
    // Override maximum failover attempts.
    failSpi.setMaximumFailoverAttempts(5);
    // Override the default failover SPI.
    IgniteConfiguration cfg = new IgniteConfiguration().setFailoverSpi(failSpi);
    // Start a node.
    Ignite ignite = Ignition.start(cfg);
    // end::always[]
    ignite.close();
}
Also used : AlwaysFailoverSpi(org.apache.ignite.spi.failover.always.AlwaysFailoverSpi) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) Ignite(org.apache.ignite.Ignite)

Example 2 with AlwaysFailoverSpi

use of org.apache.ignite.spi.failover.always.AlwaysFailoverSpi in project ignite by apache.

the class GridFailoverSelfTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    cfg.setFailoverSpi(new AlwaysFailoverSpi());
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) AlwaysFailoverSpi(org.apache.ignite.spi.failover.always.AlwaysFailoverSpi)

Example 3 with AlwaysFailoverSpi

use of org.apache.ignite.spi.failover.always.AlwaysFailoverSpi in project ignite by apache.

the class GridFailoverCustomTopologySelfTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@SuppressWarnings("deprecation")
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    cfg.setNodeId(null);
    cfg.setFailoverSpi(new AlwaysFailoverSpi() {

        /**
         * {@inheritDoc}
         */
        @Override
        public ClusterNode failover(FailoverContext ctx, List<ClusterNode> top) {
            failCnt.incrementAndGet();
            return super.failover(ctx, top);
        }
    });
    return cfg;
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) AlwaysFailoverSpi(org.apache.ignite.spi.failover.always.AlwaysFailoverSpi) FailoverContext(org.apache.ignite.spi.failover.FailoverContext)

Example 4 with AlwaysFailoverSpi

use of org.apache.ignite.spi.failover.always.AlwaysFailoverSpi in project ignite by apache.

the class GridManagerStopSelfTest method testStopFailoverManager.

/**
 * @throws Exception If failed.
 */
@Test
public void testStopFailoverManager() throws Exception {
    AlwaysFailoverSpi spi = new AlwaysFailoverSpi();
    injectLogger(spi);
    ctx.config().setFailoverSpi(spi);
    GridFailoverManager mgr = new GridFailoverManager(ctx);
    mgr.stop(true);
}
Also used : AlwaysFailoverSpi(org.apache.ignite.spi.failover.always.AlwaysFailoverSpi) GridFailoverManager(org.apache.ignite.internal.managers.failover.GridFailoverManager) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 5 with AlwaysFailoverSpi

use of org.apache.ignite.spi.failover.always.AlwaysFailoverSpi in project ignite by apache.

the class GridCacheAffinityRoutingSelfTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    AlwaysFailoverSpi failSpi = new AlwaysFailoverSpi();
    failSpi.setMaximumFailoverAttempts(MAX_FAILOVER_ATTEMPTS);
    cfg.setFailoverSpi(failSpi);
    if (!igniteInstanceName.equals(getTestIgniteInstanceName(GRID_CNT))) {
        // Default cache configuration.
        CacheConfiguration dfltCacheCfg = defaultCacheConfiguration();
        dfltCacheCfg.setCacheMode(PARTITIONED);
        dfltCacheCfg.setBackups(1);
        dfltCacheCfg.setWriteSynchronizationMode(FULL_SYNC);
        // Non-default cache configuration.
        CacheConfiguration namedCacheCfg = defaultCacheConfiguration();
        namedCacheCfg.setCacheMode(PARTITIONED);
        namedCacheCfg.setBackups(1);
        namedCacheCfg.setWriteSynchronizationMode(FULL_SYNC);
        namedCacheCfg.setName(NON_DFLT_CACHE_NAME);
        cfg.setCacheConfiguration(dfltCacheCfg, namedCacheCfg);
    } else {
        // No cache should be configured for extra node.
        cfg.setCacheConfiguration();
    }
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) AlwaysFailoverSpi(org.apache.ignite.spi.failover.always.AlwaysFailoverSpi) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Aggregations

AlwaysFailoverSpi (org.apache.ignite.spi.failover.always.AlwaysFailoverSpi)11 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)10 ClusterNode (org.apache.ignite.cluster.ClusterNode)3 FailoverContext (org.apache.ignite.spi.failover.FailoverContext)3 Ignite (org.apache.ignite.Ignite)2 UUID (java.util.UUID)1 CacheKeyConfiguration (org.apache.ignite.cache.CacheKeyConfiguration)1 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)1 BinaryMarshaller (org.apache.ignite.internal.binary.BinaryMarshaller)1 GridFailoverManager (org.apache.ignite.internal.managers.failover.GridFailoverManager)1 IgniteInstanceResource (org.apache.ignite.resources.IgniteInstanceResource)1 TcpCommunicationSpi (org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi)1 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)1 Test (org.junit.Test)1