/** * @param grpId Group ID. * @param partId Partition ID. * @return Destroy request to wait for if destroy has begun. */ private PartitionDestroyRequest cancelDestroy(int grpId, int partId) { PartitionDestroyRequest rmvd = pendingReqs.remove(new T2<>(grpId, partId)); return rmvd == null ? null : !rmvd.cancel() ? rmvd : null; } }
/** {@inheritDoc} */ @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, @Nullable T2<ClusterNode, String> tup) { final String val = tup.getValue(); return F.asMap( new ComputeJobAdapter() { @IgniteInstanceResource private Ignite ignite; @Override public Object execute() { X.println("Executing CacheDeploymentTestTask3 job on node " + ignite.cluster().localNode().id()); ignite.<String, CacheDeploymentTestValue>cache("default").put(val, new CacheDeploymentTestValue()); return null; } }, tup.get1() ); }
/** * Resolves IGFS mode for the given path. * * @param path IGFS path. * @return IGFS mode. */ public IgfsMode resolveMode(IgfsPath path) { assert path != null; if (modes == null) return dfltMode; else { IgfsMode mode = modesCache.get(path); if (mode == null) { for (T2<IgfsPath, IgfsMode> entry : modes) { if (F.eq(path, entry.getKey()) || path.isSubDirectoryOf(entry.getKey())) { // As modes ordered from most specific to least specific first mode found is ours. mode = entry.getValue(); break; } } if (mode == null) mode = dfltMode; modesCache.put(path, mode); } return mode; } }
/** * Starts grid with given configuration. If the grid is already started and failIfStarted set to TRUE * an exception will be thrown. * * @param cfg Grid configuration. This cannot be {@code null}. * @param springCtx Optional Spring application context, possibly {@code null}. * Spring bean definitions for bean injection are taken from this context. * If provided, this context can be injected into grid tasks and grid jobs using * {@link SpringApplicationContextResource @SpringApplicationContextResource} annotation. * @param failIfStarted Throw or not an exception if grid is already started. * @return Tuple with: grid instance and flag to indicate the instance is started by this call. * So, when the new ignite instance is started the flag is {@code true}. If an existing instance is returned * the flag is {@code false}. * @throws IgniteCheckedException If grid could not be started. This exception will be thrown * also if named grid has already been started. */ public static T2<Ignite, Boolean> start(IgniteConfiguration cfg, @Nullable GridSpringResourceContext springCtx, boolean failIfStarted) throws IgniteCheckedException { A.notNull(cfg, "cfg"); T2<IgniteNamedInstance, Boolean> res = start0(new GridStartContext(cfg, null, springCtx), failIfStarted); return new T2<>((Ignite)res.get1().grid(), res.get2()); }
/** {@inheritDoc} */ @Override protected void body() throws InterruptedException { addrs = requestAddresses(mcastAddr, sockAddr).get1(); }
/** * @throws Exception If failed. */ @Test public void testTuple() throws Exception { T2 t = new T2("key", "value"); jcache().put("tupleKey", t); String ret = content(DEFAULT_CACHE_NAME, GridRestCommand.CACHE_GET, "key", "tupleKey"); info("Get command result: " + ret); JsonNode res = assertResponseSucceeded(ret, false); assertEquals(t.getKey(), res.get("key").asText()); assertEquals(t.getValue(), res.get("value").asText()); }
/** * @param cntrs Update counters. */ private void addUpdateCounters(Map<Integer, T2<Long, Long>> cntrs) { if (updateCntrs == null) updateCntrs = new HashMap<>(); for (Map.Entry<Integer, T2<Long, Long>> e : cntrs.entrySet()) { T2<Long, Long> cntr0 = updateCntrs.get(e.getKey()); T2<Long, Long> cntr1 = e.getValue(); if (cntr0 == null || cntr1.get2() > cntr0.get2()) updateCntrs.put(e.getKey(), cntr1); } }
/** {@inheritDoc} */ @Override public Collection<String> fields() { Collection<String> res = new ArrayList<>(fields.size()); for (T2<String, Integer> t : fields) res.add(t.get1()); return res; }
/** * Gets set of methods with given annotation. * * @param dep Deployment. * @param cls Class in which search for methods. * @param annCls Annotation. * @return Set of methods with given annotations. */ GridResourceMethod[] getMethodsWithAnnotation(@Nullable GridDeployment dep, Class<?> cls, Class<? extends Annotation> annCls) { ClassDescriptor desc = descriptor(dep, cls); T2<GridResourceField[], GridResourceMethod[]> t2 = desc.annotatedMembers(annCls); return t2 == null ? GridResourceMethod.EMPTY_ARRAY : t2.get2(); }
/** {@inheritDoc} */ @Override public void writeExternal(ObjectOutput out) throws IOException { U.writeEnum(out, dfltMode); if (modes != null) { out.writeBoolean(true); out.writeInt(modes.size()); for (T2<IgfsPath, IgfsMode> pathMode : modes) { assert pathMode.getKey() != null; pathMode.getKey().writeExternal(out); U.writeEnum(out, pathMode.getValue()); } } else out.writeBoolean(false); if (!F.isEmpty(dualParentsWithPrimaryChildren)) { out.writeBoolean(true); out.writeInt(dualParentsWithPrimaryChildren.size()); for (IgfsPath p : dualParentsWithPrimaryChildren) p.writeExternal(out); } else out.writeBoolean(false); }
/** * Adds event of the job preparation. * * @param ts Timestamp of the event. */ public void onJobPrepare(long ts) { assert nodeId != null; evts.add(new T2<>("JOB prepare " + nodeId, ts)); }
/** {@inheritDoc} */ @Override public Collection<String> fields() { Collection<String> res = new ArrayList<>(fields.size()); for (T2<String, Integer> t : fields) res.add(t.get1()); return res; }
/** {@inheritDoc} */ @Override public void releaseHistoryForPreloading() { for (Map.Entry<T2<Integer, Integer>, T2<Long, WALPointer>> e : reservedForPreloading.entrySet()) { try { cctx.wal().release(e.getValue().get2()); } catch (IgniteCheckedException ex) { U.error(log, "Could not release WAL reservation", ex); throw new IgniteException(ex); } } reservedForPreloading.clear(); }
/** * Adds event of the job start. * * @param ts Timestamp of the event. */ public void onJobStart(long ts) { assert nodeId != null; evts.add(new T2<>("JOB start " + nodeId, ts)); }
/** {@inheritDoc} */ @Override public void onDeferredDelete(GridCacheEntryEx entry, GridCacheVersion ver) { assert entry.isNear(); try { T2<KeyCacheObject, GridCacheVersion> evicted = rmvQueue.add(new T2<>(entry.key(), ver)); if (evicted != null) removeVersionedEntry(evicted.get1(), evicted.get2()); } catch (InterruptedException ignore) { if (log.isDebugEnabled()) log.debug("Failed to enqueue deleted entry [key=" + entry.key() + ", ver=" + ver + ']'); Thread.currentThread().interrupt(); } } }