/** * @param key Removed key. * @param ver Removed version. * @throws GridException If failed. */ public void onDeferredDelete(K key, GridCacheVersion ver) throws GridException { try { T2<K, GridCacheVersion> evicted = rmvQueue.add(new T2<>(key, ver)); if (evicted != null) cctx.dht().removeVersionedEntry(evicted.get1(), evicted.get2()); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new GridInterruptedException(e); } }
/** * Resolves GGFS mode for the given path. * * @param path GGFS path. * @return GGFS mode. */ public GridGgfsMode resolveMode(GridGgfsPath path) { assert path != null; if (modes == null) return dfltMode; else { GridGgfsMode mode = modesCache.get(path); if (mode == null) { for (T2<GridGgfsPath, GridGgfsMode> entry : modes) { if (startsWith(path, 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; } }
/** * @return Item data and index. */ synchronized T2<V, Long> get() { return new T2<>(item, idx); }
/** {@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; }
/** * @param cls Class to write. * @return Data for {@code writeClass} method. */ static T2<Integer, Integer> writeClassData(Class<?> cls) { assert cls != null; String name = cls.getName(); Integer superHdr = ggxName2id.get(name); if (superHdr != null) return new T2<>(superHdr, null); Integer id; if ((id = ggName2id.get(name)) != null) return new T2<>(HEADER_GG_NAME, id); if (usrName2Id != null && (id = usrName2Id.get(name)) != null) return new T2<>(HEADER_USER_NAME, id); if (cls.isArray()) return new T2<>(HEADER_ARRAY, null); return new T2<>(HEADER_NAME, null); }
/** * Resolves GGFS mode for the given path. * * @param path GGFS path. * @return GGFS mode. */ public GridGgfsMode resolveMode(GridGgfsPath path) { assert path != null; if (modes == null) return dfltMode; else { GridGgfsMode mode = modesCache.get(path); if (mode == null) { for (T2<GridGgfsPath, GridGgfsMode> entry : modes) { if (startsWith(path, 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; } }
/** {@inheritDoc} */ @Override public void onDeferredDelete(GridCacheEntryEx<K, V> entry, GridCacheVersion ver) { assert entry.isNear(); try { T2<K, 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(); } } }
/** * Adds field to this index. * * @param field Field name. * @param orderNum Field order number in this index. * @param descending Sort order. */ public void addField(String field, int orderNum, boolean descending) { fields.add(new T2<>(field, orderNum)); if (descending) { if (descendings == null) descendings = new HashSet<>(); descendings.add(field); } }
/** * Checks that local and remove configurations have the same value of given attribute. * * @param log Logger used to log warning message (used only if fail flag is not set). * @param locCfg Local configuration. * @param rmtCfg Remote configuration. * @param rmt Remote node. * @param attr Attribute name. * @param fail If true throws GridException in case of attribute values mismatch, otherwise logs warning. * @throws GridException If attribute values are different and fail flag is true. */ public static void checkAttributeMismatch(GridLogger log, GridCacheConfiguration locCfg, GridCacheConfiguration rmtCfg, GridNode rmt, T2<String, String> attr, boolean fail) throws GridException { assert rmt != null; assert attr != null; assert attr.get1() != null; assert attr.get2() != null; Object locVal = U.property(locCfg, attr.get1()); Object rmtVal = U.property(rmtCfg, attr.get1()); checkAttributeMismatch(log, rmtCfg.getName(), rmt, attr.get1(), attr.get2(), locVal, rmtVal, fail); }
/** * @param path Path. * @return Set of all modes that children paths could have. */ public Set<GridGgfsMode> resolveChildrenModes(GridGgfsPath path) { assert path != null; if (modes == null) return Collections.singleton(dfltMode); else { Set<GridGgfsMode> children = childrenModesCache.get(path); if (children == null) { children = new HashSet<>(GridGgfsMode.values().length, 1.0f); GridGgfsMode pathDefault = dfltMode; for (T2<GridGgfsPath, GridGgfsMode> child : modes) { if (startsWith(path, child.getKey())) { pathDefault = child.getValue(); break; } else if (startsWith(child.getKey(), path)) children.add(child.getValue()); } children.add(pathDefault); childrenModesCache.put(path, children); } return children; } }
/** * @param entry Entry. * @param nodes Nodes. * @param map Map. * @throws GridException If failed. */ @SuppressWarnings( {"MismatchedQueryAndUpdateOfCollection"}) private void map(GridCacheEntryEx<K, V> entry, @Nullable Iterable<? extends GridNode> nodes, Map<GridNode, List<T2<K, byte[]>>> map) throws GridException { if (nodes != null) { for (GridNode n : nodes) { List<T2<K, byte[]>> keys = map.get(n); if (keys == null) map.put(n, keys = new LinkedList<>()); keys.add(new T2<>(entry.key(), entry.getOrMarshalKeyBytes())); } } }
/** * @param path Path. * @return Set of all modes that children paths could have. */ public Set<GridGgfsMode> resolveChildrenModes(GridGgfsPath path) { assert path != null; if (modes == null) return Collections.singleton(dfltMode); else { Set<GridGgfsMode> children = childrenModesCache.get(path); if (children == null) { children = new HashSet<>(GridGgfsMode.values().length, 1.0f); GridGgfsMode pathDefault = dfltMode; for (T2<GridGgfsPath, GridGgfsMode> child : modes) { if (startsWith(path, child.getKey())) { pathDefault = child.getValue(); break; } else if (startsWith(child.getKey(), path)) children.add(child.getValue()); } children.add(pathDefault); childrenModesCache.put(path, children); } return children; } }
/** {@inheritDoc} */ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { props = U.readStringMap(in); dfltMode = GridGgfsMode.fromOrdinal(U.readEnumOrdinal0(in)); if (in.readBoolean()) { int size = in.readInt(); pathModes = new ArrayList<>(size); for (int i = 0; i < size; i++) { GridGgfsPath path = new GridGgfsPath(); path.readExternal(in); T2<GridGgfsPath, GridGgfsMode> entry = new T2<>(path, GridGgfsMode.fromOrdinal(U.readEnumOrdinal0(in))); pathModes.add(entry); } } } }
/** {@inheritDoc} */ @Override public void writeExternal(ObjectOutput out) throws IOException { U.writeStringMap(out, props); U.writeEnum0(out, dfltMode); if (pathModes != null) { out.writeBoolean(true); out.writeInt(pathModes.size()); for (T2<GridGgfsPath, GridGgfsMode> pathMode : pathModes) { pathMode.getKey().writeExternal(out); U.writeEnum0(out, pathMode.getValue()); } } else out.writeBoolean(false); }