Java Code Examples for org.apache.ignite.configuration.IgniteConfiguration#setFailoverSpi()
The following examples show how to use
org.apache.ignite.configuration.IgniteConfiguration#setFailoverSpi() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IgniteCacheLockPartitionOnAffinityRunAbstractTest.java From ignite with Apache License 2.0 | 6 votes |
/** {@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; }
Example 2
Source File: GridFailoverCustomTopologySelfTest.java From ignite with Apache License 2.0 | 6 votes |
/** {@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; }
Example 3
Source File: CacheAffinityCallSelfTest.java From ignite with Apache License 2.0 | 6 votes |
/** {@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; }
Example 4
Source File: GridFailoverTaskWithPredicateSelfTest.java From ignite with Apache License 2.0 | 6 votes |
/** {@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; }
Example 5
Source File: GridSessionJobFailoverSelfTest.java From ignite with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); cfg.setFailoverSpi(new AlwaysFailoverSpi()); return cfg; }
Example 6
Source File: GridCacheAffinityRoutingSelfTest.java From ignite with Apache License 2.0 | 5 votes |
/** {@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; }
Example 7
Source File: GridMultipleSpisSelfTest.java From ignite with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); GridTestFailoverSpi fail1 = new GridTestFailoverSpi("fail2"); GridTestFailoverSpi fail2 = new GridTestFailoverSpi("fail2"); fail1.setName("fail1"); fail2.setName("fail2"); GridTestLoadBalancingSpi load1 = new GridTestLoadBalancingSpi("load2"); GridTestLoadBalancingSpi load2 = new GridTestLoadBalancingSpi("load2"); load1.setName("load1"); load2.setName("load2"); GridTestCheckpointSpi cp1 = new GridTestCheckpointSpi("cp2"); GridTestCheckpointSpi cp2 = new GridTestCheckpointSpi("cp2"); cp1.setName("cp1"); cp2.setName("cp2"); cfg.setFailoverSpi(fail1, fail2); cfg.setLoadBalancingSpi(load1, load2); cfg.setCheckpointSpi(cp1, cp2); return cfg; }
Example 8
Source File: GridFailoverSelfTest.java From ignite with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); cfg.setFailoverSpi(new AlwaysFailoverSpi()); return cfg; }
Example 9
Source File: GridAlwaysFailoverSpiFailSelfTest.java From ignite with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration() throws Exception { IgniteConfiguration cfg = super.getConfiguration(); cfg.setFailoverSpi(new GridTestFailoverSpi()); return cfg; }
Example 10
Source File: GridStopWithWaitSelfTest.java From ignite with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); cfg.setFailoverSpi(new AlwaysFailoverSpi()); return cfg; }
Example 11
Source File: GridFailoverTopologySelfTest.java From ignite with Apache License 2.0 | 5 votes |
/** {@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; }
Example 12
Source File: IgnitionEx.java From ignite with Apache License 2.0 | 4 votes |
/** * Initialize default SPI implementations. * * @param cfg Ignite configuration. */ private void initializeDefaultSpi(IgniteConfiguration cfg) { if (cfg.getDiscoverySpi() == null) cfg.setDiscoverySpi(new TcpDiscoverySpi()); if (cfg.getDiscoverySpi() instanceof TcpDiscoverySpi) { TcpDiscoverySpi tcpDisco = (TcpDiscoverySpi)cfg.getDiscoverySpi(); if (tcpDisco.getIpFinder() == null) tcpDisco.setIpFinder(new TcpDiscoveryMulticastIpFinder()); } if (cfg.getCommunicationSpi() == null) cfg.setCommunicationSpi(new TcpCommunicationSpi()); if (cfg.getDeploymentSpi() == null) cfg.setDeploymentSpi(new LocalDeploymentSpi()); if (cfg.getEventStorageSpi() == null) cfg.setEventStorageSpi(new NoopEventStorageSpi()); if (cfg.getCheckpointSpi() == null) cfg.setCheckpointSpi(new NoopCheckpointSpi()); if (cfg.getCollisionSpi() == null) cfg.setCollisionSpi(new NoopCollisionSpi()); if (cfg.getFailoverSpi() == null) cfg.setFailoverSpi(new AlwaysFailoverSpi()); if (cfg.getLoadBalancingSpi() == null) cfg.setLoadBalancingSpi(new RoundRobinLoadBalancingSpi()); else { Collection<LoadBalancingSpi> spis = new ArrayList<>(); boolean dfltLoadBalancingSpi = false; for (LoadBalancingSpi spi : cfg.getLoadBalancingSpi()) { spis.add(spi); if (!dfltLoadBalancingSpi && spi instanceof RoundRobinLoadBalancingSpi) dfltLoadBalancingSpi = true; } // Add default load balancing SPI for internal tasks. if (!dfltLoadBalancingSpi) spis.add(new RoundRobinLoadBalancingSpi()); cfg.setLoadBalancingSpi(spis.toArray(new LoadBalancingSpi[spis.size()])); } if (cfg.getIndexingSpi() == null) cfg.setIndexingSpi(new NoopIndexingSpi()); if (cfg.getEncryptionSpi() == null) cfg.setEncryptionSpi(new NoopEncryptionSpi()); if (F.isEmpty(cfg.getMetricExporterSpi())) cfg.setMetricExporterSpi(new NoopMetricExporterSpi()); if (F.isEmpty(cfg.getSystemViewExporterSpi())) { if (IgniteComponentType.INDEXING.inClassPath()) { try { cfg.setSystemViewExporterSpi(new JmxSystemViewExporterSpi(), U.newInstance(SYSTEM_VIEW_SQL_SPI)); } catch (IgniteCheckedException e) { throw new IgniteException(e); } } else cfg.setSystemViewExporterSpi(new JmxSystemViewExporterSpi()); } }
Example 13
Source File: GridCachePutAllFailoverSelfTest.java From ignite with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1); cfg.setPeerClassLoadingEnabled(false); cfg.setDeploymentMode(DeploymentMode.CONTINUOUS); TcpDiscoverySpi discoverySpi = (TcpDiscoverySpi)cfg.getDiscoverySpi(); discoverySpi.setAckTimeout(60000); discoverySpi.setForceServerMode(true); cfg.setDiscoverySpi(discoverySpi); if (igniteInstanceName.startsWith("master")) { cfg.setUserAttributes(ImmutableMap.of("segment", "master")); // For sure. failoverSpi.setMaximumFailoverAttempts(100); cfg.setFailoverSpi(failoverSpi); } else if (igniteInstanceName.startsWith("worker")) { cfg.setUserAttributes(ImmutableMap.of("segment", "worker")); CacheConfiguration cacheCfg = defaultCacheConfiguration(); cacheCfg.setName("partitioned"); cacheCfg.setAtomicityMode(atomicityMode()); cacheCfg.setCacheMode(PARTITIONED); cacheCfg.setBackups(backups); cacheCfg.setNearConfiguration(nearEnabled ? new NearCacheConfiguration() : null); cacheCfg.setWriteSynchronizationMode(FULL_SYNC); cfg.setCacheConfiguration(cacheCfg); } else throw new IllegalStateException("Unexpected Ignite instance name: " + igniteInstanceName); return cfg; }
Example 14
Source File: GridAbstractMultinodeRedeployTest.java From ignite with Apache License 2.0 | 3 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); cfg.setDeploymentMode(depMode); cfg.setFailoverSpi(new NeverFailoverSpi()); cfg.setNetworkTimeout(10000); return cfg; }