Java Code Examples for org.apache.ignite.Ignite#name()
The following examples show how to use
org.apache.ignite.Ignite#name() .
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: GridAbstractTest.java From ignite with Apache License 2.0 | 6 votes |
@SuppressWarnings({"BusyWait"}) protected void waitForRemoteNodes(Ignite ignite, int cnt) throws IgniteCheckedException { while (true) { Collection<ClusterNode> nodes = ignite.cluster().forRemotes().nodes(); if (nodes != null && nodes.size() >= cnt) return; try { Thread.sleep(100); } catch (InterruptedException ignored) { throw new IgniteCheckedException("Interrupted while waiting for remote nodes [igniteInstanceName=" + ignite.name() + ", count=" + cnt + ']'); } } }
Example 2
Source File: BinaryMetadataUpdatesFlowTest.java From ignite with Apache License 2.0 | 6 votes |
/** * Validates that all updates are readable on the specified node. * * @param ignite Ignite instance. */ private void validateCache(Ignite ignite) { String name = ignite.name(); for (Cache.Entry entry : ignite.cache(DEFAULT_CACHE_NAME).withKeepBinary()) { BinaryObject binObj = (BinaryObject)entry.getValue(); Integer idx = binObj.field(SEQ_NUM_FLD); BinaryUpdateDescription desc = updatesList.get(idx - 1); Object val = binObj.field(desc.fieldName); String errMsg = "Field " + desc.fieldName + " has unexpeted value (index=" + idx + ", node=" + name + ")"; if (desc.fieldType == FieldType.OBJECT) assertTrue(errMsg, val instanceof BinaryObject); else if (desc.fieldType == FieldType.ARRAY) assertArrayEquals(errMsg, (byte[])desc.val, (byte[])val); else assertEquals(errMsg, desc.val, binObj.field(desc.fieldName)); } }
Example 3
Source File: CacheExchangeMergeTest.java From ignite with Apache License 2.0 | 6 votes |
/** * @param node Node. * @param startKey Start key. * @param keyRange Keys range. */ private void checkNodeCaches(Ignite node, int startKey, int keyRange) { ThreadLocalRandom rnd = ThreadLocalRandom.current(); for (String cacheName : cacheNames) { String err = "Invalid value [node=" + node.name() + ", client=" + node.configuration().isClientMode() + ", order=" + node.cluster().localNode().order() + ", cache=" + cacheName + ']'; IgniteCache<Object, Object> cache = node.cache(cacheName); for (int i = 0; i < 10; i++) { Integer key = rnd.nextInt(keyRange) + startKey; cache.put(key, i); Object val = cache.get(key); assertEquals(err, i, val); } } }
Example 4
Source File: IgniteInternalServiceProvider.java From joyqueue with Apache License 2.0 | 5 votes |
@Override public void configure(Binder binder) { try { Ignite ignite = startIgnite(); name = ignite.name(); ignite.cluster().active(true); ignite.cluster().setBaselineTopology(ignite.cluster().topologyVersion()); binder.bind(Ignite.class).toInstance(ignite); binder.bind(BrokerDao.class).toInstance(new IgniteBrokerDao(ignite)); binder.bind(ConfigDao.class).toInstance(new IgniteConfigDao(ignite)); binder.bind(ConsumerConfigDao.class).toInstance(new IgniteConsumerConfigDao(ignite)); binder.bind(ConsumerDao.class).toInstance(new IgniteConsumerDao(ignite)); binder.bind(ProducerDao.class).toInstance(new IgniteProducerDao(ignite)); binder.bind(TopicDao.class).toInstance(new IgniteTopicDao(ignite)); binder.bind(PartitionGroupDao.class).toInstance(new IgnitePartitionGroupDao(ignite)); binder.bind(ProducerConfigDao.class).toInstance(new IgniteProducerConfigDao(ignite)); binder.bind(PartitionGroupReplicaDao.class).toInstance(new IgnitePartitionGroupReplicaDao(ignite)); binder.bind(AppTokenDao.class).toInstance(new IgniteAppTokenDao(ignite)); binder.bind(DataCenterDao.class).toInstance(new IgniteDataCenterDao(ignite)); binder.bind(NamespaceDao.class).toInstance(new IgniteNamespaceDao(ignite)); binder.bind(IgniteMessenger.class).toConstructor(IgniteMessenger.class.getConstructor(Ignite.class)); binder.bind(BrokerInternalService.class).toConstructor(IgniteBrokerInternalService.class.getConstructor(BrokerDao.class)); binder.bind(ConfigInternalService.class).toConstructor(IgniteConfigInternalService.class.getConstructor(ConfigDao.class)); binder.bind(ConsumerInternalService.class).toConstructor(IgniteConsumerInternalService.class.getConstructor(ConsumerDao.class, ConsumerConfigDao.class)); binder.bind(ProducerInternalService.class).toConstructor(IgniteProducerInternalService.class.getConstructor(ProducerDao.class, ProducerConfigDao.class)); binder.bind(PartitionGroupInternalService.class).toConstructor(IgnitePartitionGroupInternalService.class.getConstructor(PartitionGroupDao.class)); binder.bind(PartitionGroupReplicaInternalService.class).toConstructor(IgnitePartitionGroupReplicaInternalService.class.getConstructor(PartitionGroupReplicaDao.class)); binder.bind(TopicInternalService.class).toConstructor(IgniteTopicInternalService.class.getConstructor(TopicDao.class)); binder.bind(AppTokenInternalService.class).toConstructor(IgniteAppTokenInternalService.class.getConstructor(AppTokenDao.class)); binder.bind(DataCenterInternalService.class).toConstructor(IgniteDataCenterInternalService.class.getConstructor(DataCenterDao.class)); binder.bind(NamespaceInternalService.class).toConstructor(IgniteNamespaceInternalService.class.getConstructor(NamespaceDao.class)); binder.bind(TransactionInternalService.class).toConstructor(IgniteTransactionInternalService.class.getConstructor()); } catch (Throwable e) { throw new RuntimeException("init ignite bean error.", e); } }
Example 5
Source File: IgniteAbstractOsgiContextActivator.java From ignite with Apache License 2.0 | 5 votes |
/** * Exports the Ignite instance onto the OSGi Service Registry. * * @param ignite Ignite. */ private void exportOsgiService(Ignite ignite) { Dictionary<String, String> dict = new Hashtable<>(); // Only add the service property if the Ignite instance name != null. if (ignite.name() != null) dict.put(OSGI_SERVICE_PROP_IGNITE_NAME, ignite.name()); bundleCtx.registerService(Ignite.class, ignite, dict); if (log.isInfoEnabled()) log.info("Exported OSGi service for Ignite with properties: " + dict); }
Example 6
Source File: IgniteSpiAdapter.java From ignite with Apache License 2.0 | 5 votes |
/** * Inject ignite instance. * * @param ignite Ignite instance. */ @IgniteInstanceResource protected void injectResources(Ignite ignite) { this.ignite = ignite; if (ignite != null) igniteInstanceName = ignite.name(); }
Example 7
Source File: IpcSharedMemoryServerEndpoint.java From ignite with Apache License 2.0 | 5 votes |
/** * Injects resources. * * @param ignite Ignite */ @IgniteInstanceResource private void injectResources(Ignite ignite) { if (ignite != null) { // Inject resources. igniteInstanceName = ignite.name(); locNodeId = ignite.configuration().getNodeId(); } else { // Cleanup resources. igniteInstanceName = null; locNodeId = null; } }
Example 8
Source File: PlatformStartIgniteTask.java From ignite with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override public Object execute() throws IgniteException { Ignite ignite = Ignition.start(springConfig); return ignite.name(); }
Example 9
Source File: CacheStoreUsageMultinodeAbstractTest.java From ignite with Apache License 2.0 | 4 votes |
/** * @param cache Cache. * @param key Key. * @param tc Transaction concurrency mode. * @throws Exception If failed. */ protected void testStoreUpdate(IgniteCache<Object, Object> cache, Object key, @Nullable TransactionConcurrency tc) throws Exception { boolean storeOnPrimary = atomicityMode() == ATOMIC || locStore || writeBehind; assertTrue(writeMap.isEmpty()); Ignite ignite = cache.unwrap(Ignite.class); Affinity<Object> obj = ignite.affinity(cache.getName()); ClusterNode node = obj.mapKeyToNode(key); assertNotNull(node); String expNode = storeOnPrimary ? (String)node.attribute(ATTR_IGNITE_INSTANCE_NAME) : ignite.name(); assertNotNull(expNode); log.info("Put [node=" + ignite.name() + ", key=" + key + ", primary=" + node.attribute(ATTR_IGNITE_INSTANCE_NAME) + ", tx=" + tc + ", nearCache=" + (cache.getConfiguration(CacheConfiguration.class).getNearConfiguration() != null) + ", storeOnPrimary=" + storeOnPrimary + ']'); Transaction tx = tc != null ? ignite.transactions().txStart(tc, REPEATABLE_READ) : null; try { cache.put(key, key); if (tx != null) tx.commit(); } finally { if (tx != null) tx.close(); } boolean wait = GridTestUtils.waitForCondition(new GridAbsPredicate() { @Override public boolean apply() { return !writeMap.isEmpty(); } }, 1000); assertTrue("Store is not updated", wait); assertEquals("Write on wrong node: " + writeMap, locStore ? 2 : 1, writeMap.size()); if (!locStore) assertEquals(expNode, writeMap.keySet().iterator().next()); writeMap.clear(); }
Example 10
Source File: GridCachePartitionedMultiNodeCounterSelfTest.java From ignite with Apache License 2.0 | 3 votes |
/** * @param msg Error message. * @param g Grid. * @param primary Primary flag. * @param v1 V1. * @param v2 V2. * @return String for assertion. */ private static String invalid(String msg, Ignite g, boolean primary, int v1, int v2) { return msg + " [igniteInstanceName=" + g.name() + ", primary=" + primary + ", v1=" + v1 + ", v2=" + v2 + (!primary ? ", nearEntry=" + near(g).peekEx(CNTR_KEY) : ", dhtEntry=" + dht(g).peekEx(CNTR_KEY) + ", dhtNear=" + near(g).peekEx(CNTR_KEY)) + ']'; }
Example 11
Source File: IgniteCacheContinuousQueryClientReconnectTest.java From ignite with Apache License 2.0 | 2 votes |
/** * @throws Exception If failed. */ @Test public void testReconnectClientAndLeftRouter() throws Exception { if (!tcpDiscovery()) return; Ignite client = grid(serverCount()); final Ignite srv = clientRouter(client); final String clnRouterName = srv.name(); assertTrue(client.cluster().localNode().isClient()); final CacheEventListener lsnr = new CacheEventListener(); ContinuousQuery<Object, Object> qry = new ContinuousQuery<>(); qry.setLocalListener(lsnr); IgniteCache<Object, Object> clnCache = client.cache(DEFAULT_CACHE_NAME); QueryCursor<?> cur = clnCache.query(qry); int keyCnt = 100; lsnr.latch = new CountDownLatch(keyCnt); for (int key = 0; key < keyCnt; key++) clnCache.put(key, key); assertTrue("Failed to wait for event.", lsnr.latch.await(5, SECONDS)); reconnectClientNode(client, srv, new Runnable() { @Override public void run() { stopGrid(clnRouterName); } }); assertFalse("Client connected to the same server node.", clnRouterName.equals(clientRouter(client).name())); lsnr.latch = new CountDownLatch(keyCnt); for (int key = 0; key < keyCnt; key++) clnCache.put(key, key); assertTrue("Failed to wait for event.", lsnr.latch.await(5, SECONDS)); cur.close(); }