/** * @param nodeId Node ID. * @return Grid. */ private Ignite grid(UUID nodeId) { return G.ignite(nodeId); }
/** * @return Near only cache for this test. */ protected IgniteCache<Object, Object> nearOnlyCache() { assert nearOnlyIgniteInstanceName != null; return G.ignite(nearOnlyIgniteInstanceName).cache(DEFAULT_CACHE_NAME); }
/** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { Ignite ignite = G.ignite(getTestIgniteInstanceName()); assert ignite != null; }
/** * @param nodeIds Node IDs. * @return Ignite instance names. */ private Collection<String> igniteInstanceNames(Collection<UUID> nodeIds) { Collection<String> names = new ArrayList<>(nodeIds.size()); for (UUID nodeId : nodeIds) names.add(G.ignite(nodeId).name()); return names; }
@Override public boolean apply(ClusterNode n) { String igniteInstanceName = G.ignite(n.id()).name(); return igniteInstanceName != null && igniteInstanceName.contains("server"); } };
@Override public boolean apply(ClusterNode n) { String igniteInstanceName = G.ignite(n.id()).name(); return igniteInstanceName != null && igniteInstanceName.contains("client"); } };
/** * @param node Node. * @return Cache. */ private IgniteCache<String, Integer> cache(ClusterNode node) { return G.ignite(node.id()).cache(DEFAULT_CACHE_NAME); }
/** * @param execId Execution ID. */ private void checkTimedOutEvents(final IgniteUuid execId) { Ignite ignite = G.ignite(getTestIgniteInstanceName()); Collection<Event> evts = ignite.events().localQuery(new PE() { @Override public boolean apply(Event evt) { return ((TaskEvent) evt).taskSessionId().equals(execId); } }, EVT_TASK_TIMEDOUT); assert evts.size() == 1 : "Invalid number of timed out tasks: " + evts.size(); }
/** * @param key Key. * @return Primary node for the key. */ @Nullable private Ignite primaryGrid(Integer key) { ClusterNode n = affinity(0).mapKeyToNode(key); assert n != null; return G.ignite(n.id()); }
/** * @param nodeId Node ID. * @param key Key. * @return Near entry. */ @Nullable private static GridCacheEntryEx nearEntry(UUID nodeId, Object key) { Ignite g = G.ignite(nodeId); GridNearCacheAdapter<Object, Integer> near = ((IgniteKernal)g).<Object, Integer>internalCache(DEFAULT_CACHE_NAME).context().near(); return near.peekEx(key); }
/** * @param idx Index. */ private void failServer(int idx) { ((TcpDiscoverySpi)G.ignite("server-" + idx).configuration().getDiscoverySpi()).simulateNodeFailure(); }
/** * @param idx Index. */ private void failClient(int idx) { ((TcpDiscoverySpi)G.ignite("client-" + idx).configuration().getDiscoverySpi()).simulateNodeFailure(); }
/** * @param num Number. */ private void checkTask(int num) { Ignite ignite = G.ignite(getTestIgniteInstanceName()); ComputeTaskFuture<?> fut = ignite.compute().executeAsync(GridTaskSessionTestTask.class.getName(), num); Object res = fut.get(); assert (Integer)res == SPLIT_COUNT : "Invalid result [num=" + num + ", fut=" + fut + ']'; }
/** * @param num Number. * @throws IgniteCheckedException if failed. */ private void checkTask(int num) throws IgniteCheckedException { Ignite ignite = G.ignite(getTestIgniteInstanceName()); ComputeTaskFuture<?> fut = executeAsync(ignite.compute(), GridTaskSessionTestTask.class.getName(), null); int exp = SPLIT_COUNT - 1; Object res = fut.get(); assert (Integer)res == exp : "Invalid result [expected=" + exp + ", actual=" + res + ", iter=" + num + ", fut=" + fut + ']'; }
/** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { ignite = G.ignite(getTestIgniteInstanceName()); long tstamp = startTimestamp(); ignite.compute().localDeployTask(GridAllEventsTestTask.class, GridAllEventsTestTask.class.getClassLoader()); List<Event> evts = pullEvents(tstamp, 1); assertEvent(evts.get(0).type(), EVT_TASK_DEPLOYED, evts); }
/** * @throws Exception if failed. */ @Test public void testSetAttribute() throws Exception { Ignite ignite = G.ignite(getTestIgniteInstanceName()); ignite.compute().localDeployTask(GridTaskSessionTestTask.class, GridTaskSessionTestTask.class.getClassLoader()); refreshInitialData(); for (int i = 0; i < EXEC_COUNT; i++) checkTask(i); }
/** * @throws Exception If failed. */ @Test public void testCollisionSessionAttribute() throws Exception { Ignite ignite = G.ignite(getTestIgniteInstanceName()); ignite.compute().execute(GridSessionTestTask.class, null); info("Executed session collision test task."); }
/** * @throws Exception If failed. */ @Test public void testNoCacheResultMethodUsage() throws Exception { Ignite ignite = G.ignite(getTestIgniteInstanceName()); ignite.compute().withNoResultCache() .execute(GridResultNoCacheResultMethodTestTask.class, "Grid Result No Cache Method Test Argument"); }
/** * Get data cache for the given node ID. * * @param nodeId Node ID. * @return Data cache. */ private GridCacheAdapter<IgfsBlockKey, byte[]> cache(UUID nodeId) { IgniteEx g = (IgniteEx)G.ignite(nodeId); return (GridCacheAdapter<IgfsBlockKey, byte[]>)g.cachex(g.igfsx(IGFS_NAME).configuration() .getDataCacheConfiguration().getName()).<IgfsBlockKey, byte[]>cache(); }
/** * @throws Exception If failed. */ @Test public void testTaskMap() throws Exception { Ignite ignite = G.ignite(getTestIgniteInstanceName()); info("Executing sync mapped task."); ignite.compute().execute(SyncMappedTask.class, null); info("Executing async mapped task."); ignite.compute().execute(AsyncMappedTask.class, null); }