Search in sources :

Example 21 with ClusterNode

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

the class GridDeploymentPerLoaderStore method onKernalStart.

/** {@inheritDoc} */
@Override
public void onKernalStart() throws IgniteCheckedException {
    Collection<IsolatedDeployment> rmv = new LinkedList<>();
    // Check existing deployments for presence of obsolete nodes.
    synchronized (mux) {
        for (Iterator<IsolatedDeployment> iter = cache.values().iterator(); iter.hasNext(); ) {
            IsolatedDeployment dep = iter.next();
            ClusterNode node = ctx.discovery().node(dep.senderNodeId());
            if (node == null) {
                dep.undeploy();
                iter.remove();
                rmv.add(dep);
            }
        }
    }
    for (IsolatedDeployment dep : rmv) dep.recordUndeployed();
    if (log.isDebugEnabled())
        log.debug("Registered deployment discovery listener: " + discoLsnr);
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) LinkedList(java.util.LinkedList)

Example 22 with ClusterNode

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

the class GridIoManager method printIoTestResults.

/**
     * @param rawRes Resulting map.
     */
private void printIoTestResults(Map<UUID, IoTestThreadLocalNodeResults>[] rawRes) {
    Map<UUID, IoTestNodeResults> res = new HashMap<>();
    for (Map<UUID, IoTestThreadLocalNodeResults> r : rawRes) {
        for (Entry<UUID, IoTestThreadLocalNodeResults> e : r.entrySet()) {
            IoTestNodeResults r0 = res.get(e.getKey());
            if (r0 == null)
                res.put(e.getKey(), r0 = new IoTestNodeResults());
            r0.add(e.getValue());
        }
    }
    SimpleDateFormat dateFmt = new SimpleDateFormat("HH:mm:ss,SSS");
    StringBuilder b = new StringBuilder(U.nl()).append("IO test results (round-trip count per each latency bin).").append(U.nl());
    for (Entry<UUID, IoTestNodeResults> e : res.entrySet()) {
        ClusterNode node = ctx.discovery().node(e.getKey());
        long binLatencyMcs = e.getValue().binLatencyMcs();
        b.append("Node ID: ").append(e.getKey()).append(" (addrs=").append(node != null ? node.addresses().toString() : "n/a").append(", binLatency=").append(binLatencyMcs).append("mcs").append(')').append(U.nl());
        b.append("Latency bin, mcs | Count exclusive | Percentage exclusive | " + "Count inclusive | Percentage inclusive ").append(U.nl());
        long[] nodeRes = e.getValue().resLatency;
        long sum = 0;
        for (int i = 0; i < nodeRes.length; i++) sum += nodeRes[i];
        long curSum = 0;
        for (int i = 0; i < nodeRes.length; i++) {
            curSum += nodeRes[i];
            if (i < nodeRes.length - 1)
                b.append(String.format("<%11d mcs | %15d | %19.6f%% | %15d | %19.6f%%\n", (i + 1) * binLatencyMcs, nodeRes[i], (100.0 * nodeRes[i]) / sum, curSum, (100.0 * curSum) / sum));
            else
                b.append(String.format(">%11d mcs | %15d | %19.6f%% | %15d | %19.6f%%\n", i * binLatencyMcs, nodeRes[i], (100.0 * nodeRes[i]) / sum, curSum, (100.0 * curSum) / sum));
        }
        b.append(U.nl()).append("Total latency (ns): ").append(U.nl()).append(String.format("%15d", e.getValue().totalLatency)).append(U.nl());
        b.append(U.nl()).append("Max latencies (ns):").append(U.nl());
        format(b, e.getValue().maxLatency, dateFmt);
        b.append(U.nl()).append("Max request send queue times (ns):").append(U.nl());
        format(b, e.getValue().maxReqSendQueueTime, dateFmt);
        b.append(U.nl()).append("Max request receive queue times (ns):").append(U.nl());
        format(b, e.getValue().maxReqRcvQueueTime, dateFmt);
        b.append(U.nl()).append("Max response send queue times (ns):").append(U.nl());
        format(b, e.getValue().maxResSendQueueTime, dateFmt);
        b.append(U.nl()).append("Max response receive queue times (ns):").append(U.nl());
        format(b, e.getValue().maxResRcvQueueTime, dateFmt);
        b.append(U.nl()).append("Max request wire times (millis):").append(U.nl());
        format(b, e.getValue().maxReqWireTimeMillis, dateFmt);
        b.append(U.nl()).append("Max response wire times (millis):").append(U.nl());
        format(b, e.getValue().maxResWireTimeMillis, dateFmt);
        b.append(U.nl());
    }
    if (log.isInfoEnabled())
        log.info(b.toString());
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) UUID(java.util.UUID) SimpleDateFormat(java.text.SimpleDateFormat)

Example 23 with ClusterNode

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

the class GridIoManager method sendToGridTopic.

/**
     * @param nodeId Id of destination node.
     * @param topic Topic to send the message to.
     * @param msg Message to send.
     * @param plc Type of processing.
     * @throws IgniteCheckedException Thrown in case of any errors.
     */
@SuppressWarnings("TypeMayBeWeakened")
public void sendToGridTopic(UUID nodeId, GridTopic topic, Message msg, byte plc) throws IgniteCheckedException {
    ClusterNode node = ctx.discovery().node(nodeId);
    if (node == null)
        throw new IgniteCheckedException("Failed to send message to node (has node left grid?): " + nodeId);
    send(node, topic, topic.ordinal(), msg, plc, false, 0, false, null, false);
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) IgniteCheckedException(org.apache.ignite.IgniteCheckedException)

Example 24 with ClusterNode

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

the class GridIoManager method sendToCustomTopic.

/**
     * @param nodeId Id of destination node.
     * @param topic Topic to send the message to.
     * @param msg Message to send.
     * @param plc Type of processing.
     * @throws IgniteCheckedException Thrown in case of any errors.
     */
public void sendToCustomTopic(UUID nodeId, Object topic, Message msg, byte plc) throws IgniteCheckedException {
    ClusterNode node = ctx.discovery().node(nodeId);
    if (node == null)
        throw new IgniteCheckedException("Failed to send message to node (has node left grid?): " + nodeId);
    sendToCustomTopic(node, topic, msg, plc);
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) IgniteCheckedException(org.apache.ignite.IgniteCheckedException)

Example 25 with ClusterNode

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

the class GridIoManager method sendUserMessage.

/**
     * Sends a peer deployable user message.
     *
     * @param nodes Destination nodes.
     * @param msg Message to send.
     * @param topic Message topic to use.
     * @param ordered Is message ordered?
     * @param timeout Message timeout in milliseconds for ordered messages.
     * @param async Async flag.
     * @throws IgniteCheckedException Thrown in case of any errors.
     */
@SuppressWarnings("ConstantConditions")
public void sendUserMessage(Collection<? extends ClusterNode> nodes, Object msg, @Nullable Object topic, boolean ordered, long timeout, boolean async) throws IgniteCheckedException {
    boolean loc = nodes.size() == 1 && F.first(nodes).id().equals(locNodeId);
    byte[] serMsg = null;
    byte[] serTopic = null;
    if (!loc) {
        serMsg = U.marshal(marsh, msg);
        if (topic != null)
            serTopic = U.marshal(marsh, topic);
    }
    GridDeployment dep = null;
    String depClsName = null;
    if (ctx.config().isPeerClassLoadingEnabled()) {
        Class<?> cls0 = U.detectClass(msg);
        if (U.isJdk(cls0) && topic != null)
            cls0 = U.detectClass(topic);
        dep = ctx.deploy().deploy(cls0, U.detectClassLoader(cls0));
        if (dep == null)
            throw new IgniteDeploymentCheckedException("Failed to deploy user message: " + msg);
        depClsName = cls0.getName();
    }
    Message ioMsg = new GridIoUserMessage(msg, serMsg, depClsName, topic, serTopic, dep != null ? dep.classLoaderId() : null, dep != null ? dep.deployMode() : null, dep != null ? dep.userVersion() : null, dep != null ? dep.participants() : null);
    if (ordered)
        sendOrderedMessageToGridTopic(nodes, TOPIC_COMM_USER, ioMsg, PUBLIC_POOL, timeout, true);
    else if (loc) {
        send(F.first(nodes), TOPIC_COMM_USER, TOPIC_COMM_USER.ordinal(), ioMsg, PUBLIC_POOL, false, 0, false, null, async);
    } else {
        ClusterNode locNode = F.find(nodes, null, F.localNode(locNodeId));
        Collection<? extends ClusterNode> rmtNodes = F.view(nodes, F.remoteNodes(locNodeId));
        if (!rmtNodes.isEmpty())
            sendToGridTopic(rmtNodes, TOPIC_COMM_USER, ioMsg, PUBLIC_POOL);
        // to allow remote nodes execute the requested operation in parallel.
        if (locNode != null) {
            send(locNode, TOPIC_COMM_USER, TOPIC_COMM_USER.ordinal(), ioMsg, PUBLIC_POOL, false, 0, false, null, async);
        }
    }
}
Also used : GridDeployment(org.apache.ignite.internal.managers.deployment.GridDeployment) ClusterNode(org.apache.ignite.cluster.ClusterNode) Message(org.apache.ignite.plugin.extensions.communication.Message) GridNioBackPressureControl.threadProcessingMessage(org.apache.ignite.internal.util.nio.GridNioBackPressureControl.threadProcessingMessage) IgniteDeploymentCheckedException(org.apache.ignite.internal.IgniteDeploymentCheckedException) Collection(java.util.Collection)

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