Search in sources :

Example 6 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);
    TcpDiscoverySpi spi = new TcpDiscoverySpi();
    spi.setIpFinder(IP_FINDER);
    cfg.setDiscoverySpi(spi);
    AlwaysFailoverSpi failSpi = new AlwaysFailoverSpi();
    cfg.setFailoverSpi(failSpi);
    // Do not configure cache on client.
    if (igniteInstanceName.equals(getTestIgniteInstanceName(SRVS))) {
        cfg.setClientMode(true);
        spi.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) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 7 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 8 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 9 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 10 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)10 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)9 ClusterNode (org.apache.ignite.cluster.ClusterNode)3 FailoverContext (org.apache.ignite.spi.failover.FailoverContext)3 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)2 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)2 UUID (java.util.UUID)1 Ignite (org.apache.ignite.Ignite)1 CacheKeyConfiguration (org.apache.ignite.cache.CacheKeyConfiguration)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