Search in sources :

Example 6 with IgniteThread

use of org.apache.ignite.thread.IgniteThread in project ignite by apache.

the class GridContinuousProcessor method stop.

/** {@inheritDoc} */
@Override
public void stop(boolean cancel) throws IgniteCheckedException {
    if (ctx.config().isDaemon())
        return;
    ctx.io().removeMessageListener(TOPIC_CONTINUOUS);
    for (IgniteThread thread : bufCheckThreads.values()) {
        U.interrupt(thread);
        U.join(thread);
    }
    if (log.isDebugEnabled())
        log.debug("Continuous processor stopped.");
}
Also used : IgniteThread(org.apache.ignite.thread.IgniteThread)

Example 7 with IgniteThread

use of org.apache.ignite.thread.IgniteThread in project ignite by apache.

the class IgfsFragmentizerManager method checkLaunchCoordinator.

/**
     * Checks if current node is the oldest node in topology and starts coordinator thread if so.
     * Note that once node is the oldest one, it will be the oldest until it leaves grid.
     *
     * @param discoEvt Discovery event.
     */
private void checkLaunchCoordinator(DiscoveryEvent discoEvt) {
    rw.readLock();
    try {
        if (stopping)
            return;
        if (fragmentizerCrd == null) {
            long minNodeOrder = Long.MAX_VALUE;
            Collection<ClusterNode> nodes = discoEvt.topologyNodes();
            for (ClusterNode node : nodes) {
                if (node.order() < minNodeOrder && igfsCtx.igfsNode(node))
                    minNodeOrder = node.order();
            }
            ClusterNode locNode = igfsCtx.kernalContext().grid().localNode();
            if (locNode.order() == minNodeOrder) {
                if (log.isDebugEnabled())
                    log.debug("Detected local node to be the eldest IGFS node in topology, starting fragmentizer " + "coordinator thread [discoEvt=" + discoEvt + ", locNode=" + locNode + ']');
                synchronized (this) {
                    if (fragmentizerCrd == null && !stopping) {
                        fragmentizerCrd = new FragmentizerCoordinator();
                        new IgniteThread(fragmentizerCrd).start();
                    }
                }
            }
        }
    } finally {
        rw.readUnlock();
    }
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) IgniteThread(org.apache.ignite.thread.IgniteThread)

Example 8 with IgniteThread

use of org.apache.ignite.thread.IgniteThread in project ignite by apache.

the class StripedCompositeReadWriteLock method readLock.

/** {@inheritDoc} */
@NotNull
@Override
public Lock readLock() {
    int idx;
    if (Thread.currentThread() instanceof IgniteThread) {
        IgniteThread igniteThread = (IgniteThread) Thread.currentThread();
        idx = igniteThread.compositeRwLockIndex();
        if (idx == IgniteThread.GRP_IDX_UNASSIGNED) {
            idx = IDX_GEN.incrementAndGet();
            igniteThread.compositeRwLockIndex(idx);
        }
    } else
        idx = IDX.get();
    return locks[idx % locks.length].readLock();
}
Also used : IgniteThread(org.apache.ignite.thread.IgniteThread) NotNull(org.jetbrains.annotations.NotNull)

Example 9 with IgniteThread

use of org.apache.ignite.thread.IgniteThread in project ignite by apache.

the class TcpCommunicationSpi method spiStart.

/** {@inheritDoc} */
@Override
public void spiStart(String igniteInstanceName) throws IgniteSpiException {
    assert locHost != null;
    // Start SPI start stopwatch.
    startStopwatch();
    // Ack parameters.
    if (log.isDebugEnabled()) {
        log.debug(configInfo("locAddr", locAddr));
        log.debug(configInfo("locPort", locPort));
        log.debug(configInfo("locPortRange", locPortRange));
        log.debug(configInfo("idleConnTimeout", idleConnTimeout));
        log.debug(configInfo("directBuf", directBuf));
        log.debug(configInfo("directSendBuf", directSndBuf));
        log.debug(configInfo("selectorsCnt", selectorsCnt));
        log.debug(configInfo("tcpNoDelay", tcpNoDelay));
        log.debug(configInfo("sockSndBuf", sockSndBuf));
        log.debug(configInfo("sockRcvBuf", sockRcvBuf));
        log.debug(configInfo("shmemPort", shmemPort));
        log.debug(configInfo("msgQueueLimit", msgQueueLimit));
        log.debug(configInfo("connectionsPerNode", connectionsPerNode));
        if (failureDetectionTimeoutEnabled()) {
            log.debug(configInfo("connTimeout", connTimeout));
            log.debug(configInfo("maxConnTimeout", maxConnTimeout));
            log.debug(configInfo("reconCnt", reconCnt));
        } else
            log.debug(configInfo("failureDetectionTimeout", failureDetectionTimeout()));
        log.debug(configInfo("sockWriteTimeout", sockWriteTimeout));
        log.debug(configInfo("ackSndThreshold", ackSndThreshold));
        log.debug(configInfo("unackedMsgsBufSize", unackedMsgsBufSize));
    }
    if (!tcpNoDelay)
        U.quietAndWarn(log, "'TCP_NO_DELAY' for communication is off, which should be used with caution " + "since may produce significant delays with some scenarios.");
    if (slowClientQueueLimit > 0 && msgQueueLimit > 0 && slowClientQueueLimit >= msgQueueLimit) {
        U.quietAndWarn(log, "Slow client queue limit is set to a value greater than message queue limit " + "(slow client queue limit will have no effect) [msgQueueLimit=" + msgQueueLimit + ", slowClientQueueLimit=" + slowClientQueueLimit + ']');
    }
    if (msgQueueLimit == 0)
        U.quietAndWarn(log, "Message queue limit is set to 0 which may lead to " + "potential OOMEs when running cache operations in FULL_ASYNC or PRIMARY_SYNC modes " + "due to message queues growth on sender and receiver sides.");
    registerMBean(igniteInstanceName, new TcpCommunicationSpiMBeanImpl(this), TcpCommunicationSpiMBean.class);
    connectGate = new ConnectGateway();
    if (shmemSrv != null) {
        shmemAcceptWorker = new ShmemAcceptWorker(shmemSrv);
        new IgniteThread(shmemAcceptWorker).start();
    }
    nioSrvr.start();
    commWorker = new CommunicationWorker(igniteInstanceName);
    commWorker.start();
    // Ack start.
    if (log.isDebugEnabled())
        log.debug(startInfo());
}
Also used : IgniteThread(org.apache.ignite.thread.IgniteThread)

Example 10 with IgniteThread

use of org.apache.ignite.thread.IgniteThread in project ignite by apache.

the class HadoopShuffleJob method startSending.

/**
     * @param igniteInstanceName Ignite instance name.
     * @param io IO Closure for sending messages.
     */
@SuppressWarnings("BusyWait")
public void startSending(String igniteInstanceName, IgniteInClosure2X<T, HadoopMessage> io) {
    assert snd == null;
    assert io != null;
    this.io = io;
    if (!stripeMappers) {
        if (!flushed) {
            snd = new GridWorker(igniteInstanceName, "hadoop-shuffle-" + job.id(), log) {

                @Override
                protected void body() throws InterruptedException {
                    try {
                        while (!isCancelled()) {
                            if (throttle > 0)
                                Thread.sleep(throttle);
                            collectUpdatesAndSend(false);
                        }
                    } catch (IgniteCheckedException e) {
                        throw new IllegalStateException(e);
                    }
                }
            };
            new IgniteThread(snd).start();
        }
    }
    ioInitLatch.countDown();
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteThread(org.apache.ignite.thread.IgniteThread) GridWorker(org.apache.ignite.internal.util.worker.GridWorker)

Aggregations

IgniteThread (org.apache.ignite.thread.IgniteThread)21 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)8 IOException (java.io.IOException)3 Ignite (org.apache.ignite.Ignite)3 ClusterNode (org.apache.ignite.cluster.ClusterNode)3 DiscoveryEvent (org.apache.ignite.events.DiscoveryEvent)3 GridWorker (org.apache.ignite.internal.util.worker.GridWorker)3 Collection (java.util.Collection)2 IgniteException (org.apache.ignite.IgniteException)2 IgniteClientDisconnectedCheckedException (org.apache.ignite.internal.IgniteClientDisconnectedCheckedException)2 IgniteInterruptedCheckedException (org.apache.ignite.internal.IgniteInterruptedCheckedException)2 ClusterTopologyCheckedException (org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)2 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)2 CI1 (org.apache.ignite.internal.util.typedef.CI1)2 SparseDistributedMatrix (org.apache.ignite.ml.math.impls.matrix.SparseDistributedMatrix)2 InetSocketAddress (java.net.InetSocketAddress)1 ServerSocket (java.net.ServerSocket)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 UUID (java.util.UUID)1