/** {@inheritDoc} */ @Override public boolean equals(Object o) { if (o == this) return true; if (o == null || getClass() != o.getClass()) return false; IgfsBlockLocationImpl that = (IgfsBlockLocationImpl) o; return len == that.len && start == that.start && F.eq(nodeIds, that.nodeIds) && F.eq(names, that.names) && F.eq(hosts, that.hosts); }
/** * @param exp Expected. * @param act Actual. */ protected void assertEqualsCollections(Collection<?> exp, Collection<?> act) { if (exp.size() != act.size()) fail("Collections are not equal:\nExpected:\t" + exp + "\nActual:\t" + act); Iterator<?> it1 = exp.iterator(); Iterator<?> it2 = act.iterator(); int idx = 0; while (it1.hasNext()) { Object item1 = it1.next(); Object item2 = it2.next(); if (!F.eq(item1, item2)) fail( "Collections are not equal (position " + idx + "):\nExpected: " + exp + "\nActual: " + act); idx++; } }
/** * @param cfg Configuration. * @param cacheName Cache name. * @return Cache configuration. */ protected CacheConfiguration cacheConfiguration(IgniteConfiguration cfg, String cacheName) { for (CacheConfiguration ccfg : cfg.getCacheConfiguration()) { if (F.eq(cacheName, ccfg.getName())) return ccfg; } fail("Failed to find cache configuration for cache: " + cacheName); return null; }
/** {@inheritDoc} */ @Override public void checkPath(Path path) { URI uri = path.toUri(); if (uri.isAbsolute()) { if (!F.eq(uri.getScheme(), IGFS_SCHEME)) throw new InvalidPathException( "Wrong path scheme [expected=" + IGFS_SCHEME + ", actual=" + uri.getAuthority() + ']'); if (!F.eq(uri.getAuthority(), uriAuthority)) throw new InvalidPathException( "Wrong path authority [expected=" + uriAuthority + ", actual=" + uri.getAuthority() + ']'); } }
/** * Checks state of the bean. * * @param gridName Grid name. * @param exec Try to execute something on the grid. */ void checkState(String gridName, boolean exec) { assert log != null; assert appCtx != null; assert F.eq(gridName, ignite.name()); if (exec) // Execute any grid method. G.ignite(gridName).events().localQuery(F.<Event>alwaysTrue()); }
/** * @param cacheId Cache ID. * @return {@code True} if local client has been added. */ public boolean isLocalClientAdded(int cacheId) { if (!F.isEmpty(reqs)) { for (DynamicCacheChangeRequest req : reqs) { if (req.start() && F.eq(req.initiatingNodeId(), cctx.localNodeId())) { if (CU.cacheId(req.cacheName()) == cacheId) return true; } } } return false; }
/** * @param mainSpace Main space. * @param allSpaces All spaces. * @return List of all extra spaces or {@code null} if none. */ private List<String> extraSpaces(String mainSpace, Set<String> allSpaces) { if (F.isEmpty(allSpaces) || (allSpaces.size() == 1 && allSpaces.contains(mainSpace))) return null; ArrayList<String> res = new ArrayList<>(allSpaces.size()); for (String space : allSpaces) { if (!F.eq(space, mainSpace)) res.add(space); } return res; }
/** * @param cacheId Cache ID to check. * @param topVer Topology version. * @return {@code True} if cache was added during this exchange. */ public boolean isCacheAdded(int cacheId, AffinityTopologyVersion topVer) { if (!F.isEmpty(reqs)) { for (DynamicCacheChangeRequest req : reqs) { if (req.start() && !req.clientStartOnly()) { if (CU.cacheId(req.cacheName()) == cacheId) return true; } } } GridCacheContext<?, ?> cacheCtx = cctx.cacheContext(cacheId); return cacheCtx != null && F.eq(cacheCtx.startTopologyVersion(), topVer); }
/** {@inheritDoc} */ @Override public boolean contains(Object o) { if (!(o instanceof Cache.Entry)) return false; Cache.Entry<K, V> entry = (Cache.Entry<K, V>) o; try { return partId == ctx.affinity().partition(entry.getKey()) && F.eq(entry.getValue(), localPeek(entry.getKey(), CachePeekModes.ONHEAP_ONLY, null)); } catch (IgniteCheckedException e) { throw new IgniteException(e); } }
/** * Processes cache query request. * * @param sndId Sender node id. * @param req Query request. */ @SuppressWarnings("unchecked") @Override void processQueryRequest(UUID sndId, GridCacheQueryRequest req) { if (req.cancel()) { cancelIds.add(new CancelMessageId(req.id(), sndId)); if (req.fields()) removeFieldsQueryResult(sndId, req.id()); else removeQueryResult(sndId, req.id()); } else { if (!cancelIds.contains(new CancelMessageId(req.id(), sndId))) { if (!F.eq(req.cacheName(), cctx.name())) { GridCacheQueryResponse res = new GridCacheQueryResponse( cctx.cacheId(), req.id(), new IgniteCheckedException( "Received request for incorrect cache [expected=" + cctx.name() + ", actual=" + req.cacheName())); sendQueryResponse(sndId, res, 0); } else { threads.put(req.id(), Thread.currentThread()); try { GridCacheQueryInfo info = distributedQueryInfo(sndId, req); if (info == null) return; if (req.fields()) runFieldsQuery(info); else runQuery(info); } catch (Throwable e) { U.error(log(), "Failed to run query.", e); sendQueryResponse( sndId, new GridCacheQueryResponse(cctx.cacheId(), req.id(), e.getCause()), 0); if (e instanceof Error) throw (Error) e; } finally { threads.remove(req.id()); } } } } }