/** * @return Collection of all locked entries. */ private Collection<GridDistributedCacheEntry> locked() { return F.concat(false, locked.values(), nearLocked.values()); }
/** * @return Collection of active transactions. */ public Collection<IgniteInternalTx> activeTransactions() { return F.concat(false, idMap.values(), nearIdMap.values()); }
/** * Resolves coordinator. Nodes that are leaving or failed (but are still in * topology) are removed from search as well as provided filter. * * @param filter Nodes to exclude when resolving coordinator (optional). * @return Coordinator node or {@code null} if there are no coordinator * (i.e. local node is the last one and is currently stopping). */ @Nullable private TcpDiscoveryNode resolveCoordinator( @Nullable Collection<TcpDiscoveryNode> filter) { synchronized (mux) { Collection<TcpDiscoveryNode> excluded = F.concat(false, failedNodes.keySet(), leavingNodes); if (!F.isEmpty(filter)) excluded = F.concat(false, excluded, filter); return ring.coordinator(excluded); } }
/** {@inheritDoc} */ @Override public String insertQuery(String fullTblName, Collection<String> keyCols, Collection<String> valCols) { Collection<String> cols = F.concat(false, keyCols, valCols); return String.format("INSERT INTO %s(%s) VALUES(%s)", fullTblName, mkString(cols, ","), repeat("?", cols.size(), "", ",", "")); }
/** {@inheritDoc} */ @Override public String mergeQuery(String fullTblName, Collection<String> keyCols, Collection<String> uniqCols) { Collection<String> cols = F.concat(false, keyCols, uniqCols); String updPart = mkString(uniqCols, new C1<String, String>() { @Override public String apply(String col) { return String.format("%s = VALUES(%s)", col, col); } }, "", ", ", ""); return String.format("INSERT INTO %s (%s) VALUES (%s) ON DUPLICATE KEY UPDATE %s", fullTblName, mkString(cols, ", "), repeat("?", cols.size(), "", ",", ""), updPart); }
/** {@inheritDoc} */ @Override public String mergeQuery(String fullTblName, Collection<String> keyCols, Collection<String> uniqCols) { Collection<String> cols = F.concat(false, keyCols, uniqCols); return String.format("MERGE INTO %s (%s) KEY (%s) VALUES(%s)", fullTblName, mkString(cols, ","), mkString(keyCols, ","), repeat("?", cols.size(), "", ", ", "")); } }
/** {@inheritDoc} */ @Override public Collection<IgniteTxEntry> allEntries() { return F.concat(false, writeEntries(), readEntries()); }
/** {@inheritDoc} */ @Override public void onReadyForRead(ReadOnlyMetastorage metastorage) { try { metastorage.iterate(ENCRYPTION_KEY_PREFIX, (key, val) -> { Integer grpId = Integer.valueOf(key.replace(ENCRYPTION_KEY_PREFIX, "")); byte[] encGrpKey = (byte[])val; grpEncKeys.putIfAbsent(grpId, getSpi().decryptKey(encGrpKey)); }, true); if (!grpEncKeys.isEmpty()) { U.quietAndInfo(log, "Encryption keys loaded from metastore. [grps=" + F.concat(grpEncKeys.keySet(), ",") + "]"); } } catch (IgniteCheckedException e) { throw new IgniteException("Failed to read encryption keys state.", e); } }
/** {@inheritDoc} */ @Override public final ClusterGroup forOthers(ClusterNode node, ClusterNode... nodes) { A.notNull(node, "node"); return forOthers(F.concat(false, node.id(), F.nodeIds(Arrays.asList(nodes)))); }
/** {@inheritDoc} */ @Override public long getRowCount() { return F.concat(false, ctx.discovery().allNodes(), ctx.discovery().daemonNodes()).size(); } }
/** * @return Configuration. */ private Configuration configMixed() { Configuration conf = HadoopUtils.safeCreateConfiguration(); setupFileSystems(conf); conf.set(MRConfig.FRAMEWORK_NAME, IgniteHadoopClientProtocolProvider.FRAMEWORK_NAME); Collection<String> addrs = new ArrayList<>(); addrs.add("localhost"); addrs.add("127.0.0.1:" + Integer.toString(REST_PORT + 1)); conf.set(MRConfig.MASTER_ADDRESS, F.concat(addrs, ",")); conf.set("fs.defaultFS", "igfs://" + igfsName + "@/"); return conf; }
/** * @param srvsCnt Count ov servers. * @return Configuration. */ private Configuration configMultipleAddrs(int srvsCnt) { Configuration conf = HadoopUtils.safeCreateConfiguration(); setupFileSystems(conf); conf.set(MRConfig.FRAMEWORK_NAME, IgniteHadoopClientProtocolProvider.FRAMEWORK_NAME); Collection<String> addrs = new ArrayList<>(srvsCnt); for (int i = 0; i < srvsCnt; ++i) addrs.add("127.0.0.1:" + Integer.toString(REST_PORT + i)); conf.set(MRConfig.MASTER_ADDRESS, F.concat(addrs, ",")); conf.set("fs.defaultFS", "igfs://" + igfsName + "@/"); return conf; }
/** {@inheritDoc} */ @Override public void collectJoiningNodeData(DiscoveryDataBag dataBag) { HashMap<Integer, byte[]> knownEncKeys = knownEncryptionKeys(); HashMap<Integer, byte[]> newKeys = newEncryptionKeys(knownEncKeys == null ? Collections.EMPTY_SET : knownEncKeys.keySet()); if ((knownEncKeys == null && newKeys == null) || dataBag.isJoiningNodeClient()) return; if (log.isInfoEnabled()) { String knownGrps = F.isEmpty(knownEncKeys) ? null : F.concat(knownEncKeys.keySet(), ","); if (knownGrps != null) U.quietAndInfo(log, "Sending stored group keys to coordinator [grps=" + knownGrps + "]"); String newGrps = F.isEmpty(newKeys) ? null : F.concat(newKeys.keySet(), ","); if (newGrps != null) U.quietAndInfo(log, "Sending new group keys to coordinator [grps=" + newGrps + "]"); } dataBag.addJoiningNodeData(ENCRYPTION_MGR.ordinal(), new NodeEncryptionKeys(knownEncKeys, newKeys)); }
Collection<String> cols = F.concat(false, keyCols, uniqCols);
Collection<String> cols = F.concat(false, keyCols, uniqCols);
/** {@inheritDoc} */ @Override public Collection<IgniteTxEntry> optimisticLockEntries() { if (serializable() && optimistic()) return F.concat(false, writeEntries(), readEntries()); return writeEntries(); }
/** {@inheritDoc} */ @Override public Iterator<Row> getRows(Session ses, SearchRow first, SearchRow last) { List<Row> rows = new ArrayList<>(); Collection<ClusterNode> nodes; SqlSystemViewColumnCondition idCond = conditionForColumn("ID", first, last); if (idCond.isEquality()) { UUID nodeId = uuidFromValue(idCond.valueForEquality()); nodes = nodeId == null ? Collections.emptySet() : Collections.singleton(ctx.discovery().node(nodeId)); } else nodes = F.concat(false, ctx.discovery().allNodes(), ctx.discovery().daemonNodes()); for (ClusterNode node : nodes) { if (node != null) rows.add( createRow( ses, node.id(), node.consistentId(), node.version(), node.isClient(), node.isDaemon(), node.order(), node.addresses(), node.hostNames() ) ); } return rows.iterator(); }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); CacheConfiguration ccfg = new CacheConfiguration("abc"); if (indexingEnabled()) ccfg.setIndexedTypes(Integer.class, Abc.class); ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); ccfg.setRebalanceMode(CacheRebalanceMode.SYNC); cfg.setCacheConfiguration(F.concat(cfg.getCacheConfiguration(), ccfg)); return cfg; }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); // Enables template with default test configuration cfg.setCacheConfiguration(F.concat(cfg.getCacheConfiguration(), cacheConfiguration(igniteInstanceName).setName("*"))); ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1); cfg.setMarshaller(new BinaryMarshaller()); // TODO remove key configuration when https://issues.apache.org/jira/browse/IGNITE-5795 is fixed. cfg.setCacheKeyConfiguration(new CacheKeyConfiguration(Person.Key.class.getName(), "orgId")); AlwaysFailoverSpi failSpi = new AlwaysFailoverSpi(); failSpi.setMaximumFailoverAttempts(MAX_FAILOVER_ATTEMPTS); cfg.setFailoverSpi(failSpi); return cfg; }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration icfg = super.getConfiguration(igniteInstanceName); CacheConfiguration[] ccfgs = icfg.getCacheConfiguration(); TopologyValidator val1 = new TopologyValidator() { @Override public boolean validate(Collection<ClusterNode> nodes) { return nodes.size() == 2; } }; TopologyValidator val2 = new TopologyValidator() { @Override public boolean validate(Collection<ClusterNode> nodes) { return nodes.size() >= 2; } }; for (CacheConfiguration ccfg : ccfgs) { if (CACHE_NAME_1.equals(ccfg.getName()) || CACHE_NAME_2.equals(ccfg.getName())) ccfg.setGroupName(GROUP_1).setTopologyValidator(val1); } CacheConfiguration ccfg3 = cacheConfiguration(igniteInstanceName) .setName(CACHE_NAME_3) .setGroupName(GROUP_2) .setTopologyValidator(val2); CacheConfiguration ccfg4 = cacheConfiguration(igniteInstanceName) .setName(CACHE_NAME_4) .setGroupName(GROUP_2) .setTopologyValidator(val2); return icfg.setCacheConfiguration(F.concat(ccfgs, ccfg3, ccfg4)); }