Search in sources :

Example 11 with AlwaysFailoverSpi

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

the class GridFailoverTaskWithPredicateSelfTest method getConfiguration.

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

        /**
         * {@inheritDoc}
         */
        @Override
        public ClusterNode failover(FailoverContext ctx, List<ClusterNode> grid) {
            ClusterNode failoverNode = super.failover(ctx, grid);
            if (failoverNode != null)
                routed.set(true);
            else
                routed.set(false);
            return failoverNode;
        }
    });
    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 12 with AlwaysFailoverSpi

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

the class GridFailoverTopologySelfTest method getConfiguration.

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

        /**
         * Ignite instance.
         */
        @IgniteInstanceResource
        private Ignite ignite;

        /**
         * {@inheritDoc}
         */
        @Override
        public ClusterNode failover(FailoverContext ctx, List<ClusterNode> grid) {
            if (grid.size() != 1) {
                failed.set(true);
                error("Unexpected grid size [expected=1, grid=" + grid + ']');
            }
            UUID locNodeId = ignite.configuration().getNodeId();
            for (ClusterNode node : grid) {
                if (node.id().equals(locNodeId)) {
                    failed.set(true);
                    error("Grid shouldn't contain local node [localNodeId=" + locNodeId + ", grid=" + grid + ']');
                }
            }
            return super.failover(ctx, grid);
        }
    });
    return cfg;
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) AlwaysFailoverSpi(org.apache.ignite.spi.failover.always.AlwaysFailoverSpi) IgniteInstanceResource(org.apache.ignite.resources.IgniteInstanceResource) Ignite(org.apache.ignite.Ignite) FailoverContext(org.apache.ignite.spi.failover.FailoverContext) UUID(java.util.UUID)

Example 13 with AlwaysFailoverSpi

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

the class CacheAffinityCallSelfTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    AlwaysFailoverSpi failSpi = new AlwaysFailoverSpi();
    cfg.setFailoverSpi(failSpi);
    // Do not configure cache on client.
    if (igniteInstanceName.equals(getTestIgniteInstanceName(SRVS)))
        ((TcpDiscoverySpi) cfg.getDiscoverySpi()).setForceServerMode(true);
    else {
        CacheConfiguration<?, ?> ccfg = defaultCacheConfiguration();
        ccfg.setName(CACHE_NAME);
        ccfg.setCacheMode(PARTITIONED);
        ccfg.setBackups(1);
        cfg.setCacheConfiguration(ccfg);
    }
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) AlwaysFailoverSpi(org.apache.ignite.spi.failover.always.AlwaysFailoverSpi)

Example 14 with AlwaysFailoverSpi

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

the class GridSessionJobFailoverSelfTest 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 15 with AlwaysFailoverSpi

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

the class IgniteCacheLockPartitionOnAffinityRunAbstractTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    // Enables template with default test configuration
    cfg.setCacheConfiguration(F.concat(cfg.getCacheConfiguration(), cacheConfiguration(igniteInstanceName).setName("*")));
    ((TcpCommunicationSpi) cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
    cfg.setMarshaller(new BinaryMarshaller());
    // TODO remove key configuration when https://issues.apache.org/jira/browse/IGNITE-5795 is fixed.
    cfg.setCacheKeyConfiguration(new CacheKeyConfiguration(Person.Key.class.getName(), "orgId"));
    AlwaysFailoverSpi failSpi = new AlwaysFailoverSpi();
    failSpi.setMaximumFailoverAttempts(MAX_FAILOVER_ATTEMPTS);
    cfg.setFailoverSpi(failSpi);
    return cfg;
}
Also used : CacheKeyConfiguration(org.apache.ignite.cache.CacheKeyConfiguration) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) AlwaysFailoverSpi(org.apache.ignite.spi.failover.always.AlwaysFailoverSpi) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi)

Aggregations

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