/** * Creates node predicate that evaluates to {@code true} for all * provided node IDs. Implementation will make a defensive copy. * * @param ids Optional node IDs. If none provided - predicate will always return {@code false}. */ public GridNodePredicate(@Nullable Collection<UUID> ids) { this.ids = F.isEmpty(ids) ? Collections.<UUID>emptySet() : ids.size() == 1 ? Collections.singleton(F.first(ids)) : new HashSet<>(ids); }
/** * @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 protected Void run(VisorCacheStopTaskArg arg) { Collection<String> cacheNames = F.isEmpty(arg.getCacheNames()) ? F.asList(arg.getCacheName()) : new HashSet<>(arg.getCacheNames()); if (F.isEmpty(cacheNames)) throw new IllegalStateException("Cache names was not specified."); ignite.destroyCaches(cacheNames); return null; }
/** {@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(); }
/** * @return Current value and stamp. */ public IgniteBiTuple<T, S> get() { return F.t(val, stamp); }
/** {@inheritDoc} */ @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, @Nullable Void arg) { return absMap(t.get1(), F.asList(t.get2()), subgrid, lb); } }
/** {@inheritDoc} */ @Override public Map<IgniteTxKey, IgniteTxEntry> writeMap() { return entry != null ? F.asMap(entry.get(0).txKey(), entry.get(0)) : Collections.<IgniteTxKey, IgniteTxEntry>emptyMap(); }
/** * @return Collection of active transactions. */ public Collection<IgniteInternalTx> activeTransactions() { return F.concat(false, idMap.values(), nearIdMap.values()); }
/** {@inheritDoc} */ @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, @Nullable Void arg) { return F.asMap(new ComputeJobAdapter() { @TaskSessionResource private ComputeTaskSession ses; @Override public Object execute() { return ses.getTaskName(); } }, F.rand(subgrid)); }
/** * Adds configuration to bind on. Should not be called after thread start. * * @param cfg Configuration. * @param mgmt Management flag. */ public void addConfiguration(IgfsIpcEndpointConfiguration cfg, boolean mgmt) { bindCfgs.add(F.t(cfg, mgmt)); }
/** {@inheritDoc} */ @Override public IgniteFuture<?> addData(Map.Entry<K, V> entry) { A.notNull(entry, "entry"); return addData(F.asList(entry)); }
/** * Convert Hadoop permission into IGFS file attribute. * * @param perm Hadoop permission. * @return IGFS attributes. */ private Map<String, String> permission(FsPermission perm) { if (perm == null) perm = FsPermission.getDefault(); return F.asMap(IgfsUtils.PROP_PERMISSION, toString(perm)); }
/** * @return Collection of all locked entries. */ private Collection<GridDistributedCacheEntry> locked() { return F.concat(false, locked.values(), nearLocked.values()); }
/** * @return {@code True} if have cache stop requests. */ public boolean hasStop() { return !F.isEmpty(cachesToStop); }
/** {@inheritDoc} */ @Override public boolean equals(Object obj) { if (obj != null && obj instanceof ClientListenerProtocolVersion) { ClientListenerProtocolVersion other = (ClientListenerProtocolVersion)obj; return F.eq(major, other.major) && F.eq(minor, other.minor) && F.eq(maintenance, other.maintenance); } return false; }