Java Code Examples for org.apache.ignite.Ignition#getOrStart()
The following examples show how to use
org.apache.ignite.Ignition#getOrStart() .
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: GridFactorySelfTest.java From ignite with Apache License 2.0 | 6 votes |
/** * Tests default grid */ @Test public void testDefaultGridGetOrStart() throws Exception { IgniteConfiguration cfg = getConfiguration(null); try (Ignite ignite = Ignition.getOrStart(cfg)) { try { Ignition.start(cfg); fail("Expected exception after grid started"); } catch (IgniteException ignored) { } Ignite ignite2 = Ignition.getOrStart(cfg); assertEquals("Must return same instance", ignite, ignite2); } assertTrue(G.allGrids().isEmpty()); }
Example 2
Source File: GridFactorySelfTest.java From ignite with Apache License 2.0 | 6 votes |
/** * Tests named grid */ @Test public void testNamedGridGetOrStart() throws Exception { IgniteConfiguration cfg = getConfiguration("test"); try (Ignite ignite = Ignition.getOrStart(cfg)) { try { Ignition.start(cfg); fail("Expected exception after grid started"); } catch (IgniteException ignored) { // No-op. } Ignite ignite2 = Ignition.getOrStart(cfg); assertEquals("Must return same instance", ignite, ignite2); } assertTrue(G.allGrids().isEmpty()); }
Example 3
Source File: IgnitionComponentProxyTest.java From ignite with Apache License 2.0 | 6 votes |
/** * */ @Test public void testGetOrStart() { Supplier<Ignite> s = new Supplier<Ignite>() { @Override public Ignite get() { try { return Ignition.getOrStart(Ignition.localIgnite().configuration()); } catch (Exception e) { throw new IgniteException(e); } } }; check(s); }
Example 4
Source File: RestExecutorSelfTest.java From ignite with Apache License 2.0 | 5 votes |
/** * Try to execute REST command and check response. * * @param nodeCfg Node configuration. * @param uri Node URI. * @param keyStore Key store. * @param keyStorePwd Key store password. * @param trustStore Trust store. * @param trustStorePwd Trust store password. * @param cipherSuites Cipher suites. * @throws Exception If failed. */ private void checkRest( IgniteConfiguration nodeCfg, String uri, String keyStore, String keyStorePwd, String trustStore, String trustStorePwd, List<String> cipherSuites ) throws Exception { try ( Ignite ignite = Ignition.getOrStart(nodeCfg); RestExecutor exec = new RestExecutor(false, keyStore, keyStorePwd, trustStore, trustStorePwd, cipherSuites) ) { Map<String, Object> params = new HashMap<>(); params.put("cmd", "top"); params.put("attr", false); params.put("mtr", false); params.put("caches", false); RestResult res = exec.sendRequest(Collections.singletonList(uri), params, null); JsonNode json = toJson(res); Assert.assertTrue(json.isArray()); for (JsonNode item : json) { Assert.assertTrue(item.get("attributes").isNull()); Assert.assertTrue(item.get("metrics").isNull()); Assert.assertTrue(item.get("caches").isNull()); } } }
Example 5
Source File: Bucket4jJCacheApplication.java From spring-cloud-zuul-ratelimit with Apache License 2.0 | 4 votes |
@Bean @Qualifier("RateLimit") public IgniteCache<String, GridBucketState> cache() { ignite = Ignition.getOrStart(new IgniteConfiguration()); return ignite.getOrCreateCache("rateLimit"); }
Example 6
Source File: Bucket4jIgniteApplication.java From spring-cloud-zuul-ratelimit with Apache License 2.0 | 4 votes |
@Bean @Qualifier("RateLimit") public IgniteCache<String, GridBucketState> cache() { ignite = Ignition.getOrStart(new IgniteConfiguration()); return ignite.getOrCreateCache("rateLimit"); }