/** {@inheritDoc} */ @Nullable @Override public Object reduce(List<ComputeJobResult> results) throws IgniteException { assert results.size() == 1; ComputeJobResult res = F.first(results); assert res != null; IgniteException ex = res.getException(); if (ex != null) throw ex; return res.getData(); }
/** * @param nodes Nodes. * @return Backup nodes. */ public static Collection<ClusterNode> backups(Collection<ClusterNode> nodes) { if (nodes == null || nodes.size() <= 1) return Collections.emptyList(); return F.view(nodes, F.notEqualTo(F.first(nodes))); }
/** {@inheritDoc} */ @Override @Nullable public ClusterNode mapKeyToNode(K key) { A.notNull(key, "key"); return F.first(mapKeysToNodes(F.asList(key)).keySet()); }
/** {@inheritDoc} */ @Nullable @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, @Nullable Object arg) { return Collections.singletonMap(new MaxMemoryJob(), F.first(subgrid)); }
/** {@inheritDoc} */ @Nullable @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, @Nullable String arg) throws IgniteException { return Collections.singletonMap(new PlatformStartIgniteJob(arg), F.first(subgrid)); }
/** {@inheritDoc} */ @Nullable @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, @Nullable String arg) { return Collections.singletonMap(new StringTestTaskJob(arg), F.first(subgrid)); }
/** {@inheritDoc} */ @Nullable @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, @Nullable String arg) throws IgniteException { return Collections.singletonMap(new SqlQueryJob(arg), F.first(subgrid)); }
/** {@inheritDoc} */ @Nullable @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, @Nullable String serviceName) throws IgniteException { return Collections.singletonMap(new PlatformDeployServiceJob(serviceName), F.first(subgrid)); }
/** {@inheritDoc} */ @Override public String reduce(List<ComputeJobResult> results) { return F.first(results).getData(); } }
/** {@inheritDoc} */ @Nullable @Override public String fileName() { FileAppender fapp = F.first(fileAppenders); return fapp != null ? fapp.getFile() : null; }
/** @throws Exception If failed. */ @Test public void testEmptyGrid() throws Exception { QueryCursor<List<?>> qry = personCache .query(sqlFieldsQuery("select name, age from Person where age = 25")); List<?> res = F.first(qry.getAll()); assert res != null; assert res.size() == 2; assert "John White".equals(res.get(0)); assert res.get(1).equals(25); }
/** {@inheritDoc} */ @Test @Override public void testSendToManyNodes() throws Exception { super.testSendToManyNodes(); // Test idle clients remove. for (CommunicationSpi spi : spis.values()) { ConcurrentMap<UUID, GridCommunicationClient> clients = U.field(spi, "clients"); assertEquals(getSpiCount() - 1, clients.size()); clients.put(UUID.randomUUID(), F.first(clients.values())); } }
@Override public void run(IgniteCache<String, Integer> cache) throws IgniteCheckedException { Map.Entry<String, Integer> e = F.first(pairs(1).entrySet()); assert e != null; String key = e.getKey(); Integer val = e.getValue(); cache.put(key, val); assert cache.containsKey(key); assert cache.remove(key); assert !cache.containsKey(key); } }, F.t(EVT_CACHE_OBJECT_PUT, gridCnt), F.t(EVT_CACHE_OBJECT_REMOVED, gridCnt));
/** {@inheritDoc} */ @Override public void allowOverwrite(boolean allow) { if (allow == allowOverwrite()) return; ClusterNode node = F.first(ctx.grid().cluster().forCacheNodes(cacheName).nodes()); if (node == null) throw new CacheException("Failed to get node for cache: " + cacheName); rcvr = allow ? DataStreamerCacheUpdaters.<K, V>individual() : ISOLATED_UPDATER; }
@Override public void run(IgniteCache<String, Integer> cache) throws IgniteCheckedException { Map.Entry<String, Integer> e = F.first(pairs(1).entrySet()); assert e != null; String key = e.getKey(); Integer val = e.getValue(); assert cache.getAndPutAsync(key, val).get() == null; assert cache.containsKey(key); assert val.equals(cache.getAsync(key).get()); assert val.equals(cache.getAndRemoveAsync(key).get()); assert !cache.containsKey(key); } }, F.t(EVT_CACHE_OBJECT_PUT, gridCnt), F.t(EVT_CACHE_OBJECT_READ, 3), F.t(EVT_CACHE_OBJECT_REMOVED, gridCnt));
/** * @param cctx Cctx. * @return Local partition. */ private static int anyLocalPartition(GridCacheContext<?, ?> cctx) { return F.first(cctx.topology().localPartitions()).id(); }
/** * @throws Exception If failed. */ @Test public void testVersion() throws Exception { Map<SocketAddress, String> map = client.getVersions(); Assert.assertEquals(1, map.size()); String ver = F.first(map.values()); Assert.assertFalse(F.isEmpty(ver)); }
@Override public IgniteFuture<?> applyx(ClusterGroup prj) { Affinity<Object> aff = prj.ignite().affinity(DEFAULT_CACHE_NAME); ClusterNode node = F.first(prj.nodes()); return compute(prj).affinityCallAsync(DEFAULT_CACHE_NAME, keyForNode(aff, node), new TestCallable()); } });
/** * @throws Exception If failed. */ @Test @Override public void testConnectable() throws Exception { GridClient client = client(); List<GridClientNode> nodes = client.compute().refreshTopology(false, false); assertFalse(F.first(nodes).connectable()); } }