org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder Java Examples

The following examples show how to use org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder. 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: IgfsOneClientNodeTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    cfg.setCacheConfiguration(cacheConfiguration(CACHE_NAME));

    cfg.setDiscoverySpi(new TcpDiscoverySpi()
        .setForceServerMode(true)
        .setIpFinder(new TcpDiscoveryVmIpFinder(true)));

    FileSystemConfiguration igfsCfg = new FileSystemConfiguration();

    igfsCfg.setName("igfs");
    igfsCfg.setMetaCacheConfiguration(cacheConfiguration(DEFAULT_CACHE_NAME));
    igfsCfg.setDataCacheConfiguration(cacheConfiguration(DEFAULT_CACHE_NAME));

    cfg.setFileSystemConfiguration(igfsCfg);

    return cfg;
}
 
Example #2
Source File: GridCacheLocalLoadAllSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    MvccFeatureChecker.skipIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE);

    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    TcpDiscoverySpi disco = new TcpDiscoverySpi();

    disco.setIpFinder(new TcpDiscoveryVmIpFinder(true));

    cfg.setDiscoverySpi(disco);

    CacheConfiguration ccfg = defaultCacheConfiguration();

    ccfg.setName("test-cache");
    ccfg.setCacheMode(LOCAL);
    ccfg.setCacheStoreFactory(singletonFactory(new TestStore()));
    ccfg.setReadThrough(true);
    ccfg.setWriteThrough(true);
    ccfg.setLoadPreviousValue(true);

    cfg.setCacheConfiguration(ccfg);

    return cfg;
}
 
Example #3
Source File: IgniteInterpreterTest.java    From zeppelin with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() {
  TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
  ipFinder.setAddresses(Collections.singletonList(HOST));

  TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
  discoSpi.setIpFinder(ipFinder);

  IgniteConfiguration cfg = new IgniteConfiguration();
  cfg.setDiscoverySpi(discoSpi);

  cfg.setGridName("test");

  ignite = Ignition.start(cfg);

  Properties props = new Properties();
  props.setProperty(IgniteSqlInterpreter.IGNITE_JDBC_URL,
          "jdbc:ignite:cfg://[email protected]");
  props.setProperty(IgniteInterpreter.IGNITE_CLIENT_MODE, "false");
  props.setProperty(IgniteInterpreter.IGNITE_PEER_CLASS_LOADING_ENABLED, "false");
  props.setProperty(IgniteInterpreter.IGNITE_ADDRESSES, HOST);

  intp = new IgniteInterpreter(props);
  intp.open();
}
 
Example #4
Source File: P2PScanQueryUndeployTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    cfg.setPeerClassLoadingEnabled(true);

    cfg.setCacheConfiguration(
        new CacheConfiguration()
            .setName(CACHE_NAME)
            .setBackups(1)
    );

    cfg.setDiscoverySpi(
        new TcpDiscoverySpi()
            .setIpFinder(
                new TcpDiscoveryVmIpFinder(true)
                    .setAddresses(Collections.singletonList("127.0.0.1:47500..47509"))
            )
    );

    cfg.setCommunicationSpi(new MessageCountingCommunicationSpi());

    return cfg;
}
 
Example #5
Source File: Runner.java    From ignite with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
    ClientConnectorConfiguration connectorConfiguration = new ClientConnectorConfiguration().setPort(10890);

    TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder()
            .setAddresses(Collections.singleton("127.0.0.1:47500"));

    TcpDiscoverySpi discoSpi = new TcpDiscoverySpi()
        .setIpFinder(ipFinder)
        .setSocketTimeout(300)
        .setNetworkTimeout(300);

    CacheConfiguration expiryCacheCfg = new CacheConfiguration("twoSecondCache")
            .setExpiryPolicyFactory(FactoryBuilder.factoryOf(
                    new CreatedExpiryPolicy(new Duration(TimeUnit.SECONDS, 2))));

    IgniteConfiguration cfg = new IgniteConfiguration()
            .setClientConnectorConfiguration(connectorConfiguration)
            .setDiscoverySpi(discoSpi)
            .setCacheConfiguration(expiryCacheCfg)
            .setLocalHost("127.0.0.1");

    Ignition.start(cfg);
}
 
Example #6
Source File: CacheTopologyCommandHandlerTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration() throws Exception {
    // Discovery config.
    TcpDiscoverySpi disco = new TcpDiscoverySpi()
        .setIpFinder(new TcpDiscoveryVmIpFinder(true))
        .setJoinTimeout(5000);

    // Cache config.
    CacheConfiguration ccfg = new CacheConfiguration("cache*")
        .setCacheMode(CacheMode.LOCAL)
        .setAtomicityMode(CacheAtomicityMode.ATOMIC);

    ConnectorConfiguration clnCfg = new ConnectorConfiguration()
        .setHost("127.0.0.1");

    return super.getConfiguration()
        .setLocalHost("127.0.0.1")
        .setConnectorConfiguration(clnCfg)
        .setDiscoverySpi(disco)
        .setCacheConfiguration(ccfg);
}
 
Example #7
Source File: ClientConnectorConfigurationValidationSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * Get base node configuration.
 *
 * @return Configuration.
 * @throws Exception If failed.
 */
@SuppressWarnings("unchecked")
private IgniteConfiguration baseConfiguration() throws Exception {
    final IgniteConfiguration cfg = super.getConfiguration();

    cfg.setIgniteInstanceName(ClientConnectorConfigurationValidationSelfTest.class.getName() + "-" +
        NODE_IDX_GEN.incrementAndGet());

    cfg.setLocalHost("127.0.0.1");
    cfg.setMarshaller(new BinaryMarshaller());

    TcpDiscoverySpi spi = new TcpDiscoverySpi();
    spi.setIpFinder(new TcpDiscoveryVmIpFinder(true));

    cfg.setDiscoverySpi(spi);

    CacheConfiguration ccfg = new CacheConfiguration(CACHE_NAME)
        .setIndexedTypes(ClientConnectorKey.class, ClientConnectorValue.class);

    cfg.setCacheConfiguration(ccfg);

    return cfg;
}
 
Example #8
Source File: CacheBlockOnReadAbstractTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
@Params(atomicityMode = TRANSACTIONAL, cacheMode = REPLICATED, timeout = 5_000L)
@Test
public void testStopClientTransactionalReplicated() throws Exception {
    startNodesInClientMode(true);

    customIpFinder = new TcpDiscoveryVmIpFinder(false)
        .setAddresses(
            Collections.singletonList("127.0.0.1:47502")
        );

    for (int i = 0; i < 3; i++)
        clients.add(startGrid(UUID.randomUUID().toString()));

    customIpFinder = null;

    doTest(
        TcpDiscoveryNodeLeftMessage.class,
        () -> stopGrid(clients.remove(clients.size() - 1).name())
    );
}
 
Example #9
Source File: CacheBlockOnReadAbstractTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Params(atomicityMode = TRANSACTIONAL, cacheMode = REPLICATED)
@Test
public void testStartClientTransactionalReplicated() throws Exception {
    doTest(
        TcpDiscoveryNodeAddFinishedMessage.class,
        () -> {
            startNodesInClientMode(true);

            customIpFinder = new TcpDiscoveryVmIpFinder(false)
                .setAddresses(
                    Collections.singletonList("127.0.0.1:47502")
                );

            try {
                startGrid(UUID.randomUUID().toString());
            }
            finally {
                customIpFinder = null;
            }
        }
    );
}
 
Example #10
Source File: TcpDiscoverySpiConfigSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testLocalPortRange() throws Exception {
    try {
        IgniteConfiguration cfg = getConfiguration();

        TcpDiscoverySpi spi = new TcpDiscoverySpi();

        spi.setIpFinder(new TcpDiscoveryVmIpFinder(true));
        spi.setLocalPortRange(0);
        cfg.setDiscoverySpi(spi);

        startGrid(cfg.getIgniteInstanceName(), cfg);
    }
    finally {
        stopAllGrids();
    }
}
 
Example #11
Source File: IgfsBlockMessageSystemPoolStarvationSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@SuppressWarnings({"unchecked", "ConstantConditions"})
@Override protected void beforeTest() throws Exception {
    super.beforeTest();

    // Start nodes.
    TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);

    victim = Ignition.start(config(NODE_1_NAME, ipFinder));
    attacker = Ignition.start(config(NODE_2_NAME, ipFinder));

    // Check if we selected victim correctly.
    if (F.eq(dataCache(victim).affinity().mapKeyToNode(DATA_KEY).id(), attacker.cluster().localNode().id())) {
        Ignite tmp = victim;

        victim = attacker;

        attacker = tmp;
    }
}
 
Example #12
Source File: HadoopAbstractSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected void beforeTest() throws Exception {
    super.beforeTest();

    // IP finder should be re-created before each test,
    // since predecessor grid shutdown does not guarantee finder's state cleanup.
    singleTestIpFinder = new TcpDiscoveryVmIpFinder(true);
}
 
Example #13
Source File: WalPageCompressionIntegrationTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteName) throws Exception {
    DataStorageConfiguration dsCfg = new DataStorageConfiguration()
        .setDefaultDataRegionConfiguration(new DataRegionConfiguration().setPersistenceEnabled(true))
        .setWalPageCompression(compression)
        .setWalPageCompressionLevel(compressionLevel);

    return super.getConfiguration(igniteName)
        .setDataStorageConfiguration(dsCfg)
        // Set new IP finder for each node to start independent clusters.
        .setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(new TcpDiscoveryVmIpFinder(true)));
}
 
Example #14
Source File: IgniteTopologyValidatorGridSplitCacheTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);

    int idx = getTestIgniteInstanceIndex(gridName);

    Map<String, Object> userAttrs = new HashMap<>(4);

    int segment = idx % 2;

    userAttrs.put(DC_NODE_ATTR, segment);

    TcpDiscoverySpi disco = (TcpDiscoverySpi)cfg.getDiscoverySpi();

    disco.setLocalPort(getDiscoPort(idx));

    disco.setIpFinder(new TcpDiscoveryVmIpFinder().setAddresses(segmented() ?
        (segment == 0 ? SEG_FINDER_0 : SEG_FINDER_1) : SEG_FINDER_ALL));

    if (idx != CONFIGLESS_GRID_IDX) {
        if (idx == RESOLVER_GRID_IDX) {
            userAttrs.put(ACTIVATOR_NODE_ATTR, "true");
        }
        else
            cfg.setActiveOnStart(false);
    }
    cfg.setUserAttributes(userAttrs);

    cfg.setMemoryConfiguration(new MemoryConfiguration().
        setDefaultMemoryPolicySize((50L << 20) + (100L << 20) * CACHES_CNT / GRID_CNT));

    return cfg;
}
 
Example #15
Source File: GridCacheCommandHandlerSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration() throws Exception {
    // Discovery config.
    TcpDiscoverySpi disco = new TcpDiscoverySpi();

    disco.setIpFinder(new TcpDiscoveryVmIpFinder(true));
    disco.setJoinTimeout(5000);

    // Cache config.
    CacheConfiguration cacheCfg = defaultCacheConfiguration();

    cacheCfg.setCacheMode(CacheMode.LOCAL);

    cacheCfg.setAtomicityMode(atomicityMode());

    // Grid config.
    IgniteConfiguration cfg = super.getConfiguration();

    cfg.setLocalHost("127.0.0.1");

    ConnectorConfiguration clnCfg = new ConnectorConfiguration();
    clnCfg.setHost("127.0.0.1");

    cfg.setConnectorConfiguration(clnCfg);
    cfg.setDiscoverySpi(disco);
    cfg.setCacheConfiguration(cacheCfg); // Add 'null' cache configuration.

    return cfg;
}
 
Example #16
Source File: SqlConnectorConfigurationValidationSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * Perform check.
 *
 * @param sqlCfg SQL configuration.
 * @param success Success flag. * @throws Exception If failed.
 */
@SuppressWarnings({"unchecked"})
private void check(SqlConnectorConfiguration sqlCfg, boolean success) throws Exception {
    final IgniteConfiguration cfg = super.getConfiguration();

    cfg.setIgniteInstanceName(SqlConnectorConfigurationValidationSelfTest.class.getName() + "-" +
        NODE_IDX_GEN.incrementAndGet());

    cfg.setLocalHost("127.0.0.1");
    cfg.setSqlConnectorConfiguration(sqlCfg);
    cfg.setMarshaller(new BinaryMarshaller());

    TcpDiscoverySpi spi = new TcpDiscoverySpi();
    spi.setIpFinder(new TcpDiscoveryVmIpFinder(true));

    cfg.setDiscoverySpi(spi);

    CacheConfiguration ccfg = new CacheConfiguration(CACHE_NAME)
        .setIndexedTypes(SqlConnectorKey.class, SqlConnectorValue.class);

    cfg.setCacheConfiguration(ccfg);

    if (success)
        startGrid(cfg.getIgniteInstanceName(), cfg);
    else {
        GridTestUtils.assertThrows(log, new Callable<Void>() {
            @Override public Void call() throws Exception {
                startGrid(cfg.getIgniteInstanceName(), cfg);

                return null;
            }
        }, IgniteException.class, null);
    }
}
 
Example #17
Source File: OdbcConfigurationValidationSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * Perform check.
 *
 * @param odbcCfg ODBC configuration.
 * @param success Success flag. * @throws Exception If failed.
 */
private void check(OdbcConfiguration odbcCfg, boolean success) throws Exception {
    final IgniteConfiguration cfg = super.getConfiguration();

    cfg.setIgniteInstanceName(OdbcConfigurationValidationSelfTest.class.getName() + "-" +
        NODE_IDX_GEN.incrementAndGet());

    cfg.setLocalHost("127.0.0.1");
    cfg.setOdbcConfiguration(odbcCfg);
    cfg.setMarshaller(new BinaryMarshaller());

    TcpDiscoverySpi spi = new TcpDiscoverySpi();
    spi.setIpFinder(new TcpDiscoveryVmIpFinder(true));

    cfg.setDiscoverySpi(spi);

    if (success)
        startGrid(cfg.getIgniteInstanceName(), cfg);
    else {
        GridTestUtils.assertThrows(log, new Callable<Void>() {
            @Override public Void call() throws Exception {
                startGrid(cfg.getIgniteInstanceName(), cfg);

                return null;
            }
        }, IgniteException.class, null);
    }
}
 
Example #18
Source File: HibernateL2CacheStrategySelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(new TcpDiscoveryVmIpFinder(true));

    cfg.setCacheConfiguration(cacheConfiguration(ENTITY3_NAME),
        cacheConfiguration(ENTITY4_NAME),
        cacheConfiguration("cache1"),
        cacheConfiguration("cache2"),
        cacheConfiguration(DEFAULT_UPDATE_TIMESTAMPS_REGION_UNQUALIFIED_NAME),
        cacheConfiguration(DEFAULT_QUERY_RESULTS_REGION_UNQUALIFIED_NAME));

    return cfg;
}
 
Example #19
Source File: HibernateL2CacheStrategySelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(new TcpDiscoveryVmIpFinder(true));

    cfg.setCacheConfiguration(cacheConfiguration(ENTITY3_NAME),
        cacheConfiguration(ENTITY4_NAME),
        cacheConfiguration("cache1"),
        cacheConfiguration("cache2"),
        cacheConfiguration(TIMESTAMP_CACHE),
        cacheConfiguration(QUERY_CACHE));

    return cfg;
}
 
Example #20
Source File: JdbcNoCacheStreamingSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @param gridName Grid name.
 * @return Grid configuration used for starting the grid.
 * @throws Exception If failed.
 */
private IgniteConfiguration getConfiguration0(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);

    CacheConfiguration<?,?> cache = defaultCacheConfiguration();

    cache.setCacheMode(PARTITIONED);
    cache.setBackups(1);
    cache.setWriteSynchronizationMode(FULL_SYNC);
    cache.setIndexedTypes(
        Integer.class, Integer.class
    );

    cfg.setCacheConfiguration(cache);
    cfg.setLocalHost("127.0.0.1");

    TcpDiscoverySpi disco = new TcpDiscoverySpi();

    TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
    ipFinder.setAddresses(Collections.singleton("127.0.0.1:47500..47501"));

    disco.setIpFinder(ipFinder);

    cfg.setDiscoverySpi(disco);

    cfg.setConnectorConfiguration(new ConnectorConfiguration());

    return cfg;
}
 
Example #21
Source File: JdbcBulkLoadSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @param gridName Grid name.
 * @return Grid configuration used for starting the grid.
 * @throws Exception If failed.
 */
private IgniteConfiguration getConfiguration0(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);

    CacheConfiguration<?,?> cache = defaultCacheConfiguration();

    cache.setCacheMode(PARTITIONED);
    cache.setBackups(1);
    cache.setWriteSynchronizationMode(FULL_SYNC);
    cache.setIndexedTypes(
        Integer.class, Person.class
    );

    cfg.setCacheConfiguration(cache);
    cfg.setLocalHost("127.0.0.1");

    TcpDiscoverySpi disco = new TcpDiscoverySpi();

    TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
    ipFinder.setAddresses(Collections.singleton("127.0.0.1:47500..47501"));

    disco.setIpFinder(ipFinder);

    cfg.setDiscoverySpi(disco);

    cfg.setConnectorConfiguration(new ConnectorConfiguration());

    return cfg;
}
 
Example #22
Source File: JdbcStreamingToPublicCacheTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);

    CacheConfiguration<?,?> cache = defaultCacheConfiguration();

    cache.setCacheMode(PARTITIONED);
    cache.setBackups(1);
    cache.setWriteSynchronizationMode(FULL_SYNC);
    cache.setIndexedTypes(
        Integer.class, Integer.class
    );

    cfg.setCacheConfiguration(cache);
    cfg.setLocalHost("127.0.0.1");

    TcpDiscoverySpi disco = new TcpDiscoverySpi();

    TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
    ipFinder.setAddresses(Collections.singleton("127.0.0.1:47500..47501"));

    disco.setIpFinder(ipFinder);

    cfg.setDiscoverySpi(disco);

    cfg.setConnectorConfiguration(new ConnectorConfiguration());

    return cfg;
}
 
Example #23
Source File: FileStoreHeapUtilizationJolBenchmark.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** */
private IgniteConfiguration getConfiguration(String igniteInstanceName) {
    IgniteConfiguration cfg = new IgniteConfiguration();

    cfg.setIgniteInstanceName(igniteInstanceName);

    cfg.setDiscoverySpi(
        new TcpDiscoverySpi()
            .setIpFinder(
                new TcpDiscoveryVmIpFinder()
                    .setAddresses(Collections.singleton("127.0.0.1:47500..47502"))
            )
    );

    CacheConfiguration ccfg = new CacheConfiguration(CACHE_NAME);

    ccfg.setAffinity(new RendezvousAffinityFunction(false, CacheConfiguration.MAX_PARTITIONS_COUNT));

    cfg.setCacheConfiguration(ccfg);

    cfg.setActiveOnStart(false);

    DataStorageConfiguration memCfg = new DataStorageConfiguration()
        .setDefaultDataRegionConfiguration(
            new DataRegionConfiguration()
                .setPersistenceEnabled(true)
                .setMaxSize(DataStorageConfiguration.DFLT_DATA_REGION_INITIAL_SIZE)
        )
        .setWalMode(WALMode.LOG_ONLY);

    cfg.setDataStorageConfiguration(memCfg);

    return cfg;
}
 
Example #24
Source File: BinaryMetadataRegistrationInsideEntryProcessorTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration() {
    TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder()
        .setAddresses(Collections.singletonList("127.0.0.1:47500..47509"));

    return new IgniteConfiguration()
        .setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(ipFinder))
        .setPeerClassLoadingEnabled(true);
}
 
Example #25
Source File: CacheInterceptorPartitionCounterLocalSanityTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(new TcpDiscoveryVmIpFinder(true));

    return cfg;
}
 
Example #26
Source File: TcpClientDiscoverySpiCoordinatorChangeTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * Checks that a client node doesn't fail because of coordinator change.
 *
 * @throws Exception If test fails.
 */
@Test
public void testClientNotFailed() throws Exception {
    TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);

    // Start server A.
    Ignite srvA = startNode("server-a", ipFinder, false);

    // Start the client.
    Ignite client = startNode("client", ipFinder, true);

    AtomicBoolean clientReconnectState = getClientReconnectState(client);

    // Start server B.
    Ignite srvB = startNode("server-b", ipFinder, false);

    // Stop server A.
    srvA.close();

    // Will throw an exception if the client is disconnected.
    client.getOrCreateCache("CACHE-NAME");

    // Check that the client didn't disconnect/reconnect quickly.
    assertFalse("Client node was failed and reconnected to the cluster.", clientReconnectState.get());

    // Stop the client.
    client.close();

    // Stop server B.
    srvB.close();
}
 
Example #27
Source File: VisorManagementEventSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = new IgniteConfiguration();

    // Enable visor management events.
    cfg.setIncludeEventTypes(
        EVT_MANAGEMENT_TASK_STARTED
    );

    cfg.setCacheConfiguration(
        new CacheConfiguration<Integer, Integer>()
            .setName("TEST")
            .setIndexedTypes(Integer.class, Integer.class)
            .setStatisticsEnabled(true)
    );

    TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();

    List<String> addrs = Arrays.asList("127.0.0.1:47500..47502");

    ipFinder.setAddresses(addrs);

    TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();

    discoSpi.setIpFinder(ipFinder);

    cfg.setDiscoverySpi(discoSpi);

    return cfg;
}
 
Example #28
Source File: IgniteTcpCommunicationConnectOnInitTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    cfg.setCommunicationSpi(new TestCommunicationSpi());
    cfg.setDiscoverySpi(new TestDiscoverySpi().setIpFinder(new TcpDiscoveryVmIpFinder()
        .setAddresses(Collections.singleton("127.0.0.1:47500..47502"))));

    return cfg;
}
 
Example #29
Source File: IgniteInterpreter.java    From zeppelin with Apache License 2.0 5 votes vote down vote up
private Ignite getIgnite() {
  if (ignite == null) {
    try {
      String cfgUrl = getProperty(IGNITE_CFG_URL);

      if (cfgUrl != null && !cfgUrl.isEmpty()) {
        ignite = Ignition.start(new URL(cfgUrl));
      } else {
        IgniteConfiguration conf = new IgniteConfiguration();

        conf.setClientMode(Boolean.parseBoolean(getProperty(IGNITE_CLIENT_MODE)));

        TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
        ipFinder.setAddresses(getAddresses());

        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
        discoSpi.setIpFinder(ipFinder);
        conf.setDiscoverySpi(discoSpi);

        conf.setPeerClassLoadingEnabled(
                Boolean.parseBoolean(getProperty(IGNITE_PEER_CLASS_LOADING_ENABLED)));

        ignite = Ignition.start(conf);
      }

      initEx = null;
    } catch (Exception e) {
      logger.error("Error in IgniteInterpreter while getIgnite: " , e);
      initEx = e;
    }
  }
  return ignite;
}
 
Example #30
Source File: IgniteLaunchInModularEnvTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @return default configuration for test without spring module.
 */
private IgniteConfiguration igniteConfiguration() {
    IgniteConfiguration cfg = new IgniteConfiguration();

    TcpDiscoveryVmIpFinder finder = new TcpDiscoveryVmIpFinder();
    finder.setAddresses(Collections.singletonList("127.0.0.1"));
    cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(finder));
    return cfg;
}