Search in sources :

Example 1 with FailoverContext

use of org.apache.ignite.spi.failover.FailoverContext 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 2 with FailoverContext

use of org.apache.ignite.spi.failover.FailoverContext 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 3 with FailoverContext

use of org.apache.ignite.spi.failover.FailoverContext 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)

Aggregations

ClusterNode (org.apache.ignite.cluster.ClusterNode)3 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)3 FailoverContext (org.apache.ignite.spi.failover.FailoverContext)3 AlwaysFailoverSpi (org.apache.ignite.spi.failover.always.AlwaysFailoverSpi)3 UUID (java.util.UUID)1 Ignite (org.apache.ignite.Ignite)1 IgniteInstanceResource (org.apache.ignite.resources.IgniteInstanceResource)1