Search in sources :

Example 11 with ClusterNode

use of org.apache.ignite.cluster.ClusterNode in project ignite by apache.

the class ClusterMetricsSnapshot method oldest.

/**
     * Gets the oldest node in given collection.
     *
     * @param nodes Nodes.
     * @return Oldest node or {@code null} if collection is empty.
     */
@Nullable
private static ClusterNode oldest(Collection<ClusterNode> nodes) {
    long min = Long.MAX_VALUE;
    ClusterNode oldest = null;
    for (ClusterNode n : nodes) if (n.order() < min) {
        min = n.order();
        oldest = n;
    }
    return oldest;
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) Nullable(org.jetbrains.annotations.Nullable)

Example 12 with ClusterNode

use of org.apache.ignite.cluster.ClusterNode in project ignite by apache.

the class IgniteKernal method ackStart.

/**
     * Prints start info.
     *
     * @param rtBean Java runtime bean.
     */
private void ackStart(RuntimeMXBean rtBean) {
    ClusterNode locNode = localNode();
    if (log.isQuiet()) {
        U.quiet(false, "");
        U.quiet(false, "Ignite node started OK (id=" + U.id8(locNode.id()) + (F.isEmpty(igniteInstanceName) ? "" : ", instance name=" + igniteInstanceName) + ')');
    }
    if (log.isInfoEnabled()) {
        log.info("");
        String ack = "Ignite ver. " + VER_STR + '#' + BUILD_TSTAMP_STR + "-sha1:" + REV_HASH_STR;
        String dash = U.dash(ack.length());
        SB sb = new SB();
        for (GridPortRecord rec : ctx.ports().records()) sb.a(rec.protocol()).a(":").a(rec.port()).a(" ");
        String str = NL + NL + ">>> " + dash + NL + ">>> " + ack + NL + ">>> " + dash + NL + ">>> OS name: " + U.osString() + NL + ">>> CPU(s): " + locNode.metrics().getTotalCpus() + NL + ">>> Heap: " + U.heapSize(locNode, 2) + "GB" + NL + ">>> VM name: " + rtBean.getName() + NL + (igniteInstanceName == null ? "" : ">>> Ignite instance name: " + igniteInstanceName + NL) + ">>> Local node [" + "ID=" + locNode.id().toString().toUpperCase() + ", order=" + locNode.order() + ", clientMode=" + ctx.clientNode() + "]" + NL + ">>> Local node addresses: " + U.addressesAsString(locNode) + NL + ">>> Local ports: " + sb + NL;
        log.info(str);
    }
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) GridPortRecord(org.apache.ignite.internal.processors.port.GridPortRecord) SB(org.apache.ignite.internal.util.typedef.internal.SB)

Example 13 with ClusterNode

use of org.apache.ignite.cluster.ClusterNode in project ignite by apache.

the class GridifyDefaultRangeTask method map.

/** {@inheritDoc} */
@Override
public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, GridifyRangeArgument arg) {
    assert !subgrid.isEmpty() : "Subgrid should not be empty: " + subgrid;
    assert ignite != null : "Grid instance could not be injected";
    if (splitSize < threshold && splitSize != 0 && threshold != 0) {
        throw new IgniteException("Incorrect Gridify annotation parameters. Value for parameter " + "'splitSize' should not be less than parameter 'threshold' [splitSize=" + splitSize + ", threshold=" + threshold + ']');
    }
    Collection<ClusterNode> exclNodes = new LinkedList<>();
    // Filter nodes.
    if (nodeFilter != null) {
        for (ClusterNode node : subgrid) {
            if (!nodeFilter.apply(node, ses))
                exclNodes.add(node);
        }
        if (exclNodes.size() == subgrid.size())
            throw new IgniteException("Failed to execute on grid where all nodes excluded.");
    }
    int inputPerNode = splitSize;
    // Calculate input elements size per node for default annotation splitSize parameter.
    if (splitSize <= 0) {
        // For iterable input splitSize will be assigned with threshold value.
        if (threshold > 0 && arg.getInputSize() == UNKNOWN_SIZE)
            inputPerNode = threshold;
        else // Otherwise, splitSize equals (inputSize / nodesCount)
        {
            assert arg.getInputSize() != UNKNOWN_SIZE;
            int gridSize = subgrid.size() - exclNodes.size();
            gridSize = (gridSize <= 0 ? subgrid.size() : gridSize);
            inputPerNode = calculateInputSizePerNode(gridSize, arg.getInputSize(), threshold, limitedSplit);
            if (log.isDebugEnabled()) {
                log.debug("Calculated input elements size per node [inputSize=" + arg.getInputSize() + ", gridSize=" + gridSize + ", threshold=" + threshold + ", limitedSplit=" + limitedSplit + ", inputPerNode=" + inputPerNode + ']');
            }
        }
    }
    GridifyArgumentBuilder argBuilder = new GridifyArgumentBuilder();
    Iterator<?> inputIter = arg.getInputIterator();
    while (inputIter.hasNext()) {
        Collection<Object> nodeInput = new LinkedList<>();
        for (int i = 0; i < inputPerNode && inputIter.hasNext(); i++) nodeInput.add(inputIter.next());
        // Create job argument.
        GridifyArgument jobArg = argBuilder.createJobArgument(arg, nodeInput);
        ComputeJob job = new GridifyJobAdapter(jobArg);
        mapper.send(job, balancer.getBalancedNode(job, exclNodes));
    }
    // Map method can return null because job already sent by continuous mapper.
    return null;
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) GridifyArgument(org.apache.ignite.compute.gridify.GridifyArgument) ComputeJob(org.apache.ignite.compute.ComputeJob) IgniteException(org.apache.ignite.IgniteException) GridifyJobAdapter(org.apache.ignite.internal.util.gridify.GridifyJobAdapter) GridifyArgumentBuilder(org.apache.ignite.internal.util.gridify.GridifyArgumentBuilder) LinkedList(java.util.LinkedList)

Example 14 with ClusterNode

use of org.apache.ignite.cluster.ClusterNode in project ignite by apache.

the class GridifyDefaultTask method map.

/** {@inheritDoc} */
@Override
public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, GridifyArgument arg) {
    assert !subgrid.isEmpty() : "Subgrid should not be empty: " + subgrid;
    assert ignite != null : "Grid instance could not be injected";
    assert balancer != null : "Load balancer could not be injected";
    ComputeJob job = new GridifyJobAdapter(arg);
    ClusterNode node = balancer.getBalancedNode(job, Collections.<ClusterNode>singletonList(ignite.cluster().localNode()));
    if (node != null) {
        // Give preference to remote nodes.
        return Collections.singletonMap(job, node);
    }
    return Collections.singletonMap(job, balancer.getBalancedNode(job, null));
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) ComputeJob(org.apache.ignite.compute.ComputeJob) GridifyJobAdapter(org.apache.ignite.internal.util.gridify.GridifyJobAdapter)

Example 15 with ClusterNode

use of org.apache.ignite.cluster.ClusterNode in project ignite by apache.

the class ClusterGroupAdapter method node.

/** {@inheritDoc} */
@Override
public final ClusterNode node(UUID id) {
    A.notNull(id, "id");
    guard();
    try {
        if (ids != null)
            return ids.contains(id) ? ctx.discovery().node(id) : null;
        else {
            ClusterNode node = ctx.discovery().node(id);
            return node != null && (p == null || p.apply(node)) ? node : null;
        }
    } finally {
        unguard();
    }
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode)

Aggregations

ClusterNode (org.apache.ignite.cluster.ClusterNode)621 UUID (java.util.UUID)154 ArrayList (java.util.ArrayList)141 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)124 Ignite (org.apache.ignite.Ignite)121 HashMap (java.util.HashMap)80 Map (java.util.Map)72 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)72 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)66 IgniteException (org.apache.ignite.IgniteException)60 List (java.util.List)59 Collection (java.util.Collection)54 ClusterTopologyCheckedException (org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)39 HashSet (java.util.HashSet)36 Event (org.apache.ignite.events.Event)35 CountDownLatch (java.util.concurrent.CountDownLatch)34 KeyCacheObject (org.apache.ignite.internal.processors.cache.KeyCacheObject)31 DiscoveryEvent (org.apache.ignite.events.DiscoveryEvent)30 IgniteKernal (org.apache.ignite.internal.IgniteKernal)30 GridTestTaskSession (org.apache.ignite.GridTestTaskSession)29