/** {@inheritDoc} */ @Override public int getTotalBaselineNodes() { Collection<BaselineNode> baselineNodes = cluster.ignite().cluster().currentBaselineTopology(); return baselineNodes != null ? baselineNodes.size() : 0; }
/** {@inheritDoc} */ @Override public long getTopologyVersion() { return cluster.ignite().cluster().topologyVersion(); }
/** * Constructor. * * @param platformCtx Context. * @param grp Cluster group. */ public PlatformCompute(PlatformContext platformCtx, ClusterGroup grp, String platformAttr) { super(platformCtx); assert grp != null; assert platformAttr != null; compute = (IgniteComputeImpl)grp.ignite().compute(grp); ClusterGroup platformGrp = grp.forAttribute(platformAttr, platformCtx.platform()); computeForPlatform = (IgniteComputeImpl)grp.ignite().compute(platformGrp); }
/** * Gets a metrics snapshot for this cluster group. * * @return Metrics snapshot. */ private ClusterMetrics metrics() { if (clusterMetricsExpireTime < System.currentTimeMillis()) { synchronized (clusterMetricsMux) { if (clusterMetricsExpireTime < System.currentTimeMillis()) { clusterMetricsSnapshot = cluster.metrics(); clusterMetricsExpireTime = System.currentTimeMillis() + cluster.ignite().configuration().getMetricsUpdateFrequency(); } } } return clusterMetricsSnapshot; }
/** * @param prj Projection. * @return {@link org.apache.ignite.IgniteCompute} for given projection. */ protected IgniteCompute compute(ClusterGroup prj) { return prj.ignite().compute(prj); }
/** {@inheritDoc} */ @Override public int getActiveBaselineNodes() { Collection<BaselineNode> baselineNodes = cluster.ignite().cluster().currentBaselineTopology(); if (baselineNodes != null && !baselineNodes.isEmpty()) { Set<Object> bltIds = new HashSet<>(baselineNodes.size()); for (BaselineNode baselineNode : baselineNodes) bltIds.add(baselineNode.consistentId()); int count = 0; for (ClusterNode node : cluster.forServers().nodes()) if (bltIds.contains(node.consistentId())) count++; return count; } return 0; }
/** * @param prj Projection. * @return {@link org.apache.ignite.IgniteMessaging} for given projection. */ protected IgniteMessaging message(ClusterGroup prj) { return prj.ignite().message(prj); }
/** * @param prj Projection. * @return {@link org.apache.ignite.IgniteMessaging} for given projection. */ protected IgniteEvents events(ClusterGroup prj) { return prj.ignite().events(prj); }
/** * @param cnt Counter. * @throws Exception If failed. */ private void executorService(AtomicInteger cnt) throws Exception { cnt.set(0); ExecutorService execSrvc = prj.ignite().executorService(prj); Future<String> fut = execSrvc.submit(new TestCallable<String>() { @Override public String call() throws Exception { return "submit1"; } }); waitForValue(cnt, 1); assertEquals("submit1", fut.get()); cnt.set(0); fut = execSrvc.submit(new TestRunnable(), "submit2"); waitForValue(cnt, 1); assertEquals("submit2", fut.get()); cnt.set(0); Future<?> runFut = execSrvc.submit(new TestRunnable()); waitForValue(cnt, 1); runFut.get(); }
/** * Querying events here throws {@link IgniteCheckedException}. * This is correct behavior. * * @param g Grid. * @param filter Event filter. */ private void executeFail(ClusterGroup g, IgnitePredicate<Event> filter) { try { g.ignite().events(g).remoteQuery(filter, 0); assert false; // Exception must be thrown. } catch (IgniteException e) { // Throwing exception is a correct behaviour. info("Received correct exception: " + e); } }
/** * @throws Exception If test failed. */ @Test public void testProjection() throws Exception { assert prj != null; assert prj.ignite() != null; assert prj.predicate() != null; int size = projectionSize(); assert prj.nodes().size() == size; Collection<UUID> nodeIds = projectionNodeIds(); for (ClusterNode node : prj.nodes()) assert nodeIds.contains(node.id()); }
@Override public IgniteFuture<?> applyx(ClusterGroup prj) { Affinity<Object> aff = prj.ignite().affinity(DEFAULT_CACHE_NAME); ClusterNode node = F.first(prj.nodes()); return compute(prj).affinityCallAsync(DEFAULT_CACHE_NAME, keyForNode(aff, node), new TestCallable()); } });
@Override public IgniteFuture<?> applyx(ClusterGroup prj) { Affinity<Object> aff = prj.ignite().affinity(DEFAULT_CACHE_NAME); ClusterNode node = F.first(prj.nodes()); return compute(prj).affinityRunAsync(DEFAULT_CACHE_NAME, keyForNode(aff, node), new TestRunnable()); } });
/** @throws Exception If failed. */ @Test public void testProjectionAffinity() throws Exception { waitTopologyUpdate(); Ignite g0 = grid(0); Ignite g1 = grid(1); ClusterGroup g0Pinned = g0.cluster().forNodeIds(F.asList(g0.cluster().localNode().id())); ClusterGroup g01Pinned = g1.cluster().forNodeIds(F.asList(g0.cluster().localNode().id(), g1.cluster().localNode().id())); for (int i = 0; i < 100; i++) assertEquals(g0Pinned.ignite().affinity(DEFAULT_CACHE_NAME).mapKeyToNode(i).id(), g01Pinned.ignite().affinity(DEFAULT_CACHE_NAME).mapKeyToNode(i).id()); }
/** {@inheritDoc} */ @Override public int getTotalBaselineNodes() { Collection<BaselineNode> baselineNodes = cluster.ignite().cluster().currentBaselineTopology(); return baselineNodes != null ? baselineNodes.size() : 0; }
/** {@inheritDoc} */ @Override public long getTopologyVersion() { return cluster.ignite().cluster().topologyVersion(); }
/** * Constructor. * * @param platformCtx Context. * @param grp Cluster group. */ public PlatformCompute(PlatformContext platformCtx, ClusterGroup grp, String platformAttr) { super(platformCtx); assert grp != null; assert platformAttr != null; compute = (IgniteComputeImpl)grp.ignite().compute(grp); ClusterGroup platformGrp = grp.forAttribute(platformAttr, platformCtx.platform()); computeForPlatform = (IgniteComputeImpl)grp.ignite().compute(platformGrp); }
/** * Gets a metrics snapshot for this cluster group. * * @return Metrics snapshot. */ private ClusterMetrics metrics() { if (clusterMetricsExpireTime < System.currentTimeMillis()) { synchronized (clusterMetricsMux) { if (clusterMetricsExpireTime < System.currentTimeMillis()) { clusterMetricsSnapshot = cluster.metrics(); clusterMetricsExpireTime = System.currentTimeMillis() + cluster.ignite().configuration().getMetricsUpdateFrequency(); } } } return clusterMetricsSnapshot; }
/** {@inheritDoc} */ @Override public int getActiveBaselineNodes() { Collection<BaselineNode> baselineNodes = cluster.ignite().cluster().currentBaselineTopology(); if (baselineNodes != null && !baselineNodes.isEmpty()) { Set<Object> bltIds = new HashSet<>(baselineNodes.size()); for (BaselineNode baselineNode : baselineNodes) bltIds.add(baselineNode.consistentId()); int count = 0; for (ClusterNode node : cluster.forServers().nodes()) if (bltIds.contains(node.consistentId())) count++; return count; } return 0; }