Search in sources :

Example 16 with GridTimeoutProcessor

use of org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor in project ignite by apache.

the class GridTcpCommunicationSpiRecoveryAckSelfTest method startSpis.

/**
 * @param ackCnt Recovery acknowledgement count.
 * @param idleTimeout Idle connection timeout.
 * @param queueLimit Message queue limit.
 * @throws Exception If failed.
 */
private void startSpis(int ackCnt, int idleTimeout, int queueLimit) throws Exception {
    spis.clear();
    nodes.clear();
    spiRsrcs.clear();
    Map<ClusterNode, GridSpiTestContext> ctxs = new HashMap<>();
    timeoutProcessor = new GridTimeoutProcessor(new GridTestKernalContext(log));
    timeoutProcessor.start();
    timeoutProcessor.onKernalStart(true);
    for (int i = 0; i < SPI_CNT; i++) {
        TcpCommunicationSpi spi = getSpi(ackCnt, idleTimeout, queueLimit);
        IgniteTestResources rsrcs = new IgniteTestResources();
        GridTestNode node = new GridTestNode(rsrcs.getNodeId());
        GridSpiTestContext ctx = initSpiContext();
        MessageFactoryProvider testMsgFactory = new MessageFactoryProvider() {

            @Override
            public void registerAll(IgniteMessageFactory factory) {
                factory.register(GridTestMessage.DIRECT_TYPE, GridTestMessage::new);
            }
        };
        ctx.messageFactory(new IgniteMessageFactoryImpl(new MessageFactory[] { new GridIoMessageFactory(), testMsgFactory }));
        ctx.setLocalNode(node);
        ctx.timeoutProcessor(timeoutProcessor);
        spiRsrcs.add(rsrcs);
        rsrcs.inject(spi);
        GridTestUtils.setFieldValue(spi, IgniteSpiAdapter.class, "igniteInstanceName", "grid-" + i);
        spi.setListener(new TestListener());
        node.order(i);
        nodes.add(node);
        spi.spiStart(getTestIgniteInstanceName() + (i + 1));
        node.setAttributes(spi.getNodeAttributes());
        spis.add(spi);
        spi.onContextInitialized(ctx);
        ctxs.put(node, ctx);
    }
    // For each context set remote nodes.
    for (Map.Entry<ClusterNode, GridSpiTestContext> e : ctxs.entrySet()) {
        for (ClusterNode n : nodes) {
            if (!n.equals(e.getKey()))
                e.getValue().remoteNodes().add(n);
        }
    }
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) GridSpiTestContext(org.apache.ignite.testframework.GridSpiTestContext) GridTestMessage(org.apache.ignite.spi.communication.GridTestMessage) GridTimeoutProcessor(org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor) MessageFactory(org.apache.ignite.plugin.extensions.communication.MessageFactory) GridIoMessageFactory(org.apache.ignite.internal.managers.communication.GridIoMessageFactory) IgniteMessageFactory(org.apache.ignite.plugin.extensions.communication.IgniteMessageFactory) HashMap(java.util.HashMap) GridTestKernalContext(org.apache.ignite.testframework.junits.GridTestKernalContext) GridTestNode(org.apache.ignite.testframework.GridTestNode) IgniteMessageFactory(org.apache.ignite.plugin.extensions.communication.IgniteMessageFactory) IgniteMessageFactoryImpl(org.apache.ignite.internal.managers.communication.IgniteMessageFactoryImpl) IgniteTestResources(org.apache.ignite.testframework.junits.IgniteTestResources) MessageFactoryProvider(org.apache.ignite.plugin.extensions.communication.MessageFactoryProvider) GridIoMessageFactory(org.apache.ignite.internal.managers.communication.GridIoMessageFactory) HashMap(java.util.HashMap) Map(java.util.Map)

Example 17 with GridTimeoutProcessor

use of org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor in project ignite by apache.

the class GridAbstractCommunicationSelfTest method startSpis.

/**
 * @throws Exception If failed.
 */
private void startSpis() throws Exception {
    spis.clear();
    nodes.clear();
    spiRsrcs.clear();
    Map<ClusterNode, GridSpiTestContext> ctxs = new HashMap<>();
    timeoutProcessor = new GridTimeoutProcessor(new GridTestKernalContext(log));
    timeoutProcessor.start();
    timeoutProcessor.onKernalStart(true);
    for (int i = 0; i < getSpiCount(); i++) {
        CommunicationSpi<Message> spi = getSpi(i);
        GridTestUtils.setFieldValue(spi, IgniteSpiAdapter.class, "igniteInstanceName", "grid-" + i);
        IgniteTestResources rsrcs = new IgniteTestResources();
        GridTestNode node = new GridTestNode(rsrcs.getNodeId());
        GridSpiTestContext ctx = initSpiContext();
        MessageFactoryProvider testMsgFactory = new MessageFactoryProvider() {

            @Override
            public void registerAll(IgniteMessageFactory factory) {
                factory.register(GridTestMessage.DIRECT_TYPE, GridTestMessage::new);
            }
        };
        ctx.messageFactory(new IgniteMessageFactoryImpl(new MessageFactory[] { new GridIoMessageFactory(), testMsgFactory }));
        ctx.setLocalNode(node);
        ctx.timeoutProcessor(timeoutProcessor);
        info(">>> Initialized context: nodeId=" + ctx.localNode().id());
        spiRsrcs.add(rsrcs);
        rsrcs.inject(spi);
        GridTestUtils.setFieldValue(spi, IgniteSpiAdapter.class, "igniteInstanceName", "grid-" + i);
        if (useSsl) {
            IgniteMock ignite = GridTestUtils.getFieldValue(spi, IgniteSpiAdapter.class, "ignite");
            IgniteConfiguration cfg = ignite.configuration().setSslContextFactory(GridTestUtils.sslFactory());
            ignite.setStaticCfg(cfg);
        }
        spi.setListener(new MessageListener(rsrcs.getNodeId()));
        node.setAttribute(ATTR_MACS, F.concat(U.allLocalMACs(), ", "));
        node.order(i + 1);
        nodes.add(node);
        spi.spiStart(getTestIgniteInstanceName() + (i + 1));
        node.setAttributes(spi.getNodeAttributes());
        spis.put(rsrcs.getNodeId(), spi);
        spi.onContextInitialized(ctx);
        ctxs.put(node, ctx);
    }
    // For each context set remote nodes.
    for (Entry<ClusterNode, GridSpiTestContext> e : ctxs.entrySet()) {
        for (ClusterNode n : nodes) {
            if (!n.equals(e.getKey()))
                e.getValue().remoteNodes().add(n);
        }
    }
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) GridSpiTestContext(org.apache.ignite.testframework.GridSpiTestContext) GridTimeoutProcessor(org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor) Message(org.apache.ignite.plugin.extensions.communication.Message) MessageFactory(org.apache.ignite.plugin.extensions.communication.MessageFactory) GridIoMessageFactory(org.apache.ignite.internal.managers.communication.GridIoMessageFactory) IgniteMessageFactory(org.apache.ignite.plugin.extensions.communication.IgniteMessageFactory) HashMap(java.util.HashMap) GridTestKernalContext(org.apache.ignite.testframework.junits.GridTestKernalContext) GridTestNode(org.apache.ignite.testframework.GridTestNode) IgniteMessageFactory(org.apache.ignite.plugin.extensions.communication.IgniteMessageFactory) IgniteMessageFactoryImpl(org.apache.ignite.internal.managers.communication.IgniteMessageFactoryImpl) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) IgniteTestResources(org.apache.ignite.testframework.junits.IgniteTestResources) MessageFactoryProvider(org.apache.ignite.plugin.extensions.communication.MessageFactoryProvider) GridIoMessageFactory(org.apache.ignite.internal.managers.communication.GridIoMessageFactory) IgniteMock(org.apache.ignite.testframework.junits.IgniteMock)

Example 18 with GridTimeoutProcessor

use of org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor in project gridgain by gridgain.

the class IgniteKernal method start.

/**
 * @param cfg Ignite configuration to use.
 * @param errHnd Error handler to use for notification about startup problems.
 * @param workerRegistry Worker registry.
 * @param hnd Default uncaught exception handler used by thread pools.
 * @throws IgniteCheckedException Thrown in case of any errors.
 */
public void start(final IgniteConfiguration cfg, GridAbsClosure errHnd, WorkersRegistry workerRegistry, Thread.UncaughtExceptionHandler hnd, TimeBag startTimer) throws IgniteCheckedException {
    gw.compareAndSet(null, new GridKernalGatewayImpl(cfg.getIgniteInstanceName()));
    GridKernalGateway gw = this.gw.get();
    gw.writeLock();
    try {
        switch(gw.getState()) {
            case STARTED:
                {
                    U.warn(log, "Grid has already been started (ignored).");
                    return;
                }
            case STARTING:
                {
                    U.warn(log, "Grid is already in process of being started (ignored).");
                    return;
                }
            case STOPPING:
                {
                    throw new IgniteCheckedException("Grid is in process of being stopped");
                }
            case STOPPED:
                {
                    break;
                }
        }
        gw.setState(STARTING);
    } finally {
        gw.writeUnlock();
    }
    assert cfg != null;
    // Make sure we got proper configuration.
    validateCommon(cfg);
    igniteInstanceName = cfg.getIgniteInstanceName();
    this.cfg = cfg;
    log = (GridLoggerProxy) cfg.getGridLogger().getLogger(getClass().getName() + (igniteInstanceName != null ? '%' + igniteInstanceName : ""));
    longJVMPauseDetector = new LongJVMPauseDetector(log);
    longJVMPauseDetector.start();
    RuntimeMXBean rtBean = ManagementFactory.getRuntimeMXBean();
    // Ack various information.
    ackAsciiLogo();
    ackConfigUrl();
    ackConfiguration(cfg);
    ackDaemon();
    ackOsInfo();
    ackLanguageRuntime();
    ackRemoteManagement();
    ackLogger();
    ackVmArguments(rtBean);
    ackClassPaths(rtBean);
    ackSystemProperties();
    ackEnvironmentVariables();
    ackMemoryConfiguration();
    ackCacheConfiguration();
    ackP2pConfiguration();
    ackRebalanceConfiguration();
    ackIPv4StackFlagIsSet();
    ackWaitForBackupsOnShutdownPropertyIsUsed();
    // Ack 3-rd party licenses location.
    if (log.isInfoEnabled() && cfg.getIgniteHome() != null)
        log.info("3-rd party licenses can be found at: " + cfg.getIgniteHome() + File.separatorChar + "libs" + File.separatorChar + "licenses");
    // with internally reserved names.
    for (String name : cfg.getUserAttributes().keySet()) if (name.startsWith(ATTR_PREFIX))
        throw new IgniteCheckedException("User attribute has illegal name: '" + name + "'. Note that all names " + "starting with '" + ATTR_PREFIX + "' are reserved for internal use.");
    // Ack local node user attributes.
    logNodeUserAttributes();
    // Ack configuration.
    ackSpis();
    List<PluginProvider> plugins = cfg.getPluginProviders() != null && cfg.getPluginProviders().length > 0 ? Arrays.asList(cfg.getPluginProviders()) : U.allPluginProviders();
    // Spin out SPIs & managers.
    try {
        ctx = new GridKernalContextImpl(log, this, cfg, gw, plugins, MarshallerUtils.classNameFilter(this.getClass().getClassLoader()), workerRegistry, hnd, longJVMPauseDetector);
        startProcessor(new DiagnosticProcessor(ctx));
        mBeansMgr = new IgniteMBeansManager(this);
        cfg.getMarshaller().setContext(ctx.marshallerContext());
        startProcessor(new GridInternalSubscriptionProcessor(ctx));
        ClusterProcessor clusterProc = new ClusterProcessor(ctx);
        startProcessor(clusterProc);
        U.onGridStart();
        // Start and configure resource processor first as it contains resources used
        // by all other managers and processors.
        GridResourceProcessor rsrcProc = new GridResourceProcessor(ctx);
        rsrcProc.setSpringContext(rsrcCtx);
        scheduler = new IgniteSchedulerImpl(ctx);
        startProcessor(rsrcProc);
        // Inject resources into lifecycle beans.
        if (!cfg.isDaemon() && cfg.getLifecycleBeans() != null) {
            for (LifecycleBean bean : cfg.getLifecycleBeans()) {
                if (bean != null)
                    rsrcProc.inject(bean);
            }
        }
        // Lifecycle notification.
        notifyLifecycleBeans(BEFORE_NODE_START);
        // Starts lifecycle aware components.
        U.startLifecycleAware(lifecycleAwares(cfg));
        startProcessor(new IgnitePluginProcessor(ctx, cfg, plugins));
        startProcessor(new FailureProcessor(ctx));
        startProcessor(new PoolProcessor(ctx));
        // Run background network diagnostics.
        GridDiagnostic.runBackgroundCheck(igniteInstanceName, ctx.pools().getExecutorService(), log);
        // Closure processor should be started before all others
        // (except for resource processor), as many components can depend on it.
        startProcessor(new GridClosureProcessor(ctx));
        // Start some other processors (order & place is important).
        startProcessor(new GridPortProcessor(ctx));
        startProcessor(new GridJobMetricsProcessor(ctx));
        // Timeout processor needs to be started before managers,
        // as managers may depend on it.
        startProcessor(new GridTimeoutProcessor(ctx));
        // Start security processors.
        startProcessor(securityProcessor());
        // NOTE: that order matters as there are dependencies between managers.
        try {
            startManager(new GridTracingManager(ctx, false));
        } catch (IgniteCheckedException e) {
            startManager(new GridTracingManager(ctx, true));
        }
        startManager(new GridMetricManager(ctx));
        startManager(new GridSystemViewManager(ctx));
        startManager(new GridIoManager(ctx));
        startManager(new GridCheckpointManager(ctx));
        startManager(new GridEventStorageManager(ctx));
        startManager(new GridDeploymentManager(ctx));
        startManager(new GridLoadBalancerManager(ctx));
        startManager(new GridFailoverManager(ctx));
        startManager(new GridCollisionManager(ctx));
        startManager(new GridIndexingManager(ctx));
        ackSecurity();
        // Assign discovery manager to context before other processors start so they
        // are able to register custom event listener.
        GridDiscoveryManager discoMgr = new GridDiscoveryManager(ctx);
        ctx.add(discoMgr, false);
        // Start the encryption manager after assigning the discovery manager to context, so it will be
        // able to register custom event listener.
        startManager(new GridEncryptionManager(ctx));
        startProcessor(new PdsConsistentIdProcessor(ctx));
        MaintenanceProcessor mntcProcessor = new MaintenanceProcessor(ctx);
        startProcessor(mntcProcessor);
        if (mntcProcessor.isMaintenanceMode()) {
            if (log.isInfoEnabled()) {
                log.info("Node is being started in maintenance mode. " + "Starting IsolatedDiscoverySpi instead of configured discovery SPI.");
            }
            cfg.setClusterStateOnStart(ClusterState.INACTIVE);
            if (log.isInfoEnabled())
                log.info("Overriding 'clusterStateOnStart' configuration to 'INACTIVE'.");
            ctx.config().setDiscoverySpi(new IsolatedDiscoverySpi());
            discoMgr = new GridDiscoveryManager(ctx);
            // Reinitialized discovery manager won't have a valid consistentId on creation.
            discoMgr.consistentId(ctx.pdsFolderResolver().resolveFolders().consistentId());
            ctx.add(discoMgr, false);
        }
        // be able to start receiving messages once discovery completes.
        try {
            startProcessor(COMPRESSION.createOptional(ctx));
            startProcessor(new GridMarshallerMappingProcessor(ctx));
            startProcessor(new MvccProcessorImpl(ctx));
            startProcessor(createComponent(DiscoveryNodeValidationProcessor.class, ctx));
            startProcessor(new GridAffinityProcessor(ctx));
            startProcessor(createComponent(GridSegmentationProcessor.class, ctx));
            startTimer.finishGlobalStage("Start managers");
            startProcessor(createComponent(IgniteCacheObjectProcessor.class, ctx));
            startTimer.finishGlobalStage("Configure binary metadata");
            startProcessor(createComponent(IGridClusterStateProcessor.class, ctx));
            startProcessor(new IgniteAuthenticationProcessor(ctx));
            startProcessor(new GridCacheProcessor(ctx));
            startProcessor(new GridQueryProcessor(ctx));
            startProcessor(new ClientListenerProcessor(ctx));
            startProcessor(createServiceProcessor());
            startProcessor(new GridTaskSessionProcessor(ctx));
            startProcessor(new GridJobProcessor(ctx));
            startProcessor(new GridTaskProcessor(ctx));
            startProcessor(SCHEDULE.createOptional(ctx));
            startProcessor(new GridRestProcessor(ctx));
            startProcessor(new DataStreamProcessor(ctx));
            startProcessor(new GridContinuousProcessor(ctx));
            startProcessor(new DataStructuresProcessor(ctx));
            startProcessor(createComponent(PlatformProcessor.class, ctx));
            if (isFeatureEnabled(IGNITE_DISTRIBUTED_META_STORAGE_FEATURE))
                startProcessor(new DistributedMetaStorageImpl(ctx));
            startProcessor(new DistributedConfigurationProcessor(ctx));
            startProcessor(new DurableBackgroundTasksProcessor(ctx));
            // Start transactional data replication processor.
            startProcessor(createComponent(TransactionalDrProcessor.class, ctx));
            startTimer.finishGlobalStage("Start processors");
            // Start plugins.
            for (PluginProvider provider : ctx.plugins().allProviders()) {
                ctx.add(new GridPluginComponent(provider));
                provider.start(ctx.plugins().pluginContextForProvider(provider));
                startTimer.finishGlobalStage("Start '" + provider.name() + "' plugin");
            }
            // Start platform plugins.
            if (ctx.config().getPlatformConfiguration() != null)
                startProcessor(new PlatformPluginProcessor(ctx));
            mBeansMgr.registerMBeansDuringInitPhase();
            ctx.cluster().initDiagnosticListeners();
            fillNodeAttributes(clusterProc.updateNotifierEnabled());
            ctx.cache().context().database().notifyMetaStorageSubscribersOnReadyForRead();
            if (isFeatureEnabled(IGNITE_DISTRIBUTED_META_STORAGE_FEATURE))
                ((DistributedMetaStorageImpl) ctx.distributedMetastorage()).inMemoryReadyForRead();
            startTimer.finishGlobalStage("Init metastore");
            ctx.cache().context().database().startMemoryRestore(ctx, startTimer);
            ctx.recoveryMode(false);
            startTimer.finishGlobalStage("Finish recovery");
        } catch (Throwable e) {
            U.error(log, "Exception during start processors, node will be stopped and close connections", e);
            // Stop discovery spi to close tcp socket.
            ctx.discovery().stop(true);
            throw e;
        }
        // All components exept Discovery are started, time to check if maintenance is still needed.
        mntcProcessor.prepareAndExecuteMaintenance();
        gw.writeLock();
        try {
            gw.setState(STARTED);
            // Start discovery manager last to make sure that grid is fully initialized.
            startManager(discoMgr);
        } finally {
            gw.writeUnlock();
        }
        startTimer.finishGlobalStage("Join topology");
        // Check whether UTF-8 is the default character encoding.
        checkFileEncoding();
        // Check whether physical RAM is not exceeded.
        checkPhysicalRam();
        // Suggest configuration optimizations.
        suggestOptimizations(cfg);
        // Suggest JVM optimizations.
        ctx.performance().addAll(JvmConfigurationSuggestions.getSuggestions());
        // Suggest Operation System optimizations.
        ctx.performance().addAll(OsConfigurationSuggestions.getSuggestions());
        DiscoveryLocalJoinData joinData = ctx.discovery().localJoin();
        IgniteInternalFuture<Boolean> transitionWaitFut = joinData.transitionWaitFuture();
        // Notify discovery manager the first to make sure that topology is discovered.
        // Active flag is not used in managers, so it is safe to pass true.
        ctx.discovery().onKernalStart(true);
        // Notify IO manager the second so further components can send and receive messages.
        // Must notify the IO manager before transition state await to make sure IO connection can be established.
        ctx.io().onKernalStart(true);
        boolean active;
        if (transitionWaitFut != null) {
            if (log.isInfoEnabled()) {
                log.info("Join cluster while cluster state transition is in progress, " + "waiting when transition finish.");
            }
            active = transitionWaitFut.get();
        } else
            active = joinData.active();
        startTimer.finishGlobalStage("Await transition");
        ctx.pools().registerMetrics();
        registerMetrics();
        ctx.cluster().registerMetrics();
        // Register MBeans.
        mBeansMgr.registerMBeansAfterNodeStarted();
        boolean recon = false;
        // Callbacks.
        for (GridComponent comp : ctx) {
            // Skip discovery manager.
            if (comp instanceof GridDiscoveryManager)
                continue;
            // Skip IO manager.
            if (comp instanceof GridIoManager)
                continue;
            if (comp instanceof GridPluginComponent)
                continue;
            if (!skipDaemon(comp)) {
                try {
                    comp.onKernalStart(active);
                } catch (IgniteNeedReconnectException e) {
                    ClusterNode locNode = ctx.discovery().localNode();
                    assert locNode.isClient();
                    if (!ctx.discovery().reconnectSupported())
                        throw new IgniteCheckedException("Client node in forceServerMode " + "is not allowed to reconnect to the cluster and will be stopped.");
                    if (log.isDebugEnabled())
                        log.debug("Failed to start node components on node start, will wait for reconnect: " + e);
                    recon = true;
                }
            }
        }
        // Start plugins.
        for (PluginProvider provider : ctx.plugins().allProviders()) provider.onIgniteStart();
        if (recon)
            reconnectState.waitFirstReconnect();
        // Lifecycle bean notifications.
        notifyLifecycleBeans(AFTER_NODE_START);
    } catch (Throwable e) {
        IgniteSpiVersionCheckException verCheckErr = X.cause(e, IgniteSpiVersionCheckException.class);
        if (verCheckErr != null)
            U.error(log, verCheckErr.getMessage());
        else if (X.hasCause(e, InterruptedException.class, IgniteInterruptedCheckedException.class))
            U.warn(log, "Grid startup routine has been interrupted (will rollback).");
        else
            U.error(log, "Got exception while starting (will rollback startup routine).", e);
        errHnd.apply();
        stop(true);
        if (e instanceof Error)
            throw e;
        else if (e instanceof IgniteCheckedException)
            throw (IgniteCheckedException) e;
        else
            throw new IgniteCheckedException(e);
    }
    // Mark start timestamp.
    startTime = U.currentTimeMillis();
    String intervalStr = IgniteSystemProperties.getString(IGNITE_STARVATION_CHECK_INTERVAL);
    // Start starvation checker if enabled.
    boolean starveCheck = !isDaemon() && !"0".equals(intervalStr);
    if (starveCheck) {
        final long interval = F.isEmpty(intervalStr) ? DFLT_PERIODIC_STARVATION_CHECK_FREQ : Long.parseLong(intervalStr);
        starveTask = ctx.timeout().schedule(new Runnable() {

            /**
             * Last completed task count.
             */
            private long lastCompletedCntPub;

            /**
             * Last completed task count.
             */
            private long lastCompletedCntSys;

            /**
             * Last completed task count.
             */
            private long lastCompletedCntQry;

            @Override
            public void run() {
                if (ctx.pools().getExecutorService() instanceof ThreadPoolExecutor) {
                    ThreadPoolExecutor exec = (ThreadPoolExecutor) ctx.pools().getExecutorService();
                    lastCompletedCntPub = checkPoolStarvation(exec, lastCompletedCntPub, "public");
                }
                if (ctx.pools().getSystemExecutorService() instanceof ThreadPoolExecutor) {
                    ThreadPoolExecutor exec = (ThreadPoolExecutor) ctx.pools().getSystemExecutorService();
                    lastCompletedCntSys = checkPoolStarvation(exec, lastCompletedCntSys, "system");
                }
                if (ctx.pools().getQueryExecutorService() instanceof ThreadPoolExecutor) {
                    ThreadPoolExecutor exec = (ThreadPoolExecutor) ctx.pools().getQueryExecutorService();
                    lastCompletedCntQry = checkPoolStarvation(exec, lastCompletedCntQry, "query");
                }
                if (ctx.pools().getStripedExecutorService() != null)
                    ctx.pools().getStripedExecutorService().detectStarvation();
            }

            /**
             * @param exec Thread pool executor to check.
             * @param lastCompletedCnt Last completed tasks count.
             * @param pool Pool name for message.
             * @return Current completed tasks count.
             */
            private long checkPoolStarvation(ThreadPoolExecutor exec, long lastCompletedCnt, String pool) {
                long completedCnt = exec.getCompletedTaskCount();
                // at least one waiting request, then it is possible starvation.
                if (exec.getPoolSize() == exec.getActiveCount() && completedCnt == lastCompletedCnt && !exec.getQueue().isEmpty())
                    LT.warn(log, "Possible thread pool starvation detected (no task completed in last " + interval + "ms, is " + pool + " thread pool size large enough?)");
                return completedCnt;
            }
        }, interval, interval);
    }
    long metricsLogFreq = cfg.getMetricsLogFrequency();
    if (metricsLogFreq > 0) {
        metricsLogTask = ctx.timeout().schedule(new Runnable() {

            private final DecimalFormat dblFmt = doubleFormat();

            @Override
            public void run() {
                ackNodeMetrics(dblFmt, ctx.pools().getExecutorService(), ctx.pools().getSystemExecutorService(), ctx.pools().getStripedExecutorService(), ctx.pools().customExecutors());
            }
        }, metricsLogFreq, metricsLogFreq);
    }
    ctx.performance().add("Disable assertions (remove '-ea' from JVM options)", !U.assertionsEnabled());
    ctx.performance().logSuggestions(log, igniteInstanceName);
    U.quietAndInfo(log, "To start Console Management & Monitoring run ignitevisorcmd.{sh|bat}");
    if (!IgniteSystemProperties.getBoolean(IgniteSystemProperties.IGNITE_QUIET, true))
        ackClassPathContent();
    ackStart(rtBean);
    if (!isDaemon())
        ctx.discovery().ackTopology(ctx.discovery().localJoin().joinTopologyVersion().topologyVersion(), EventType.EVT_NODE_JOINED, localNode());
    startTimer.finishGlobalStage("Await exchange");
}
Also used : DataStructuresProcessor(org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) DiscoveryLocalJoinData(org.apache.ignite.internal.managers.discovery.DiscoveryLocalJoinData) IgniteSystemProperties.getBoolean(org.apache.ignite.IgniteSystemProperties.getBoolean) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) MvccProcessorImpl(org.apache.ignite.internal.processors.cache.mvcc.MvccProcessorImpl) GridCheckpointManager(org.apache.ignite.internal.managers.checkpoint.GridCheckpointManager) ClusterNode(org.apache.ignite.cluster.ClusterNode) GridIndexingManager(org.apache.ignite.internal.managers.indexing.GridIndexingManager) GridEncryptionManager(org.apache.ignite.internal.managers.encryption.GridEncryptionManager) GridInternalSubscriptionProcessor(org.apache.ignite.internal.processors.subscription.GridInternalSubscriptionProcessor) GridMarshallerMappingProcessor(org.apache.ignite.internal.processors.marshaller.GridMarshallerMappingProcessor) GridTaskSessionProcessor(org.apache.ignite.internal.processors.session.GridTaskSessionProcessor) PlatformPluginProcessor(org.apache.ignite.internal.processors.platform.plugin.PlatformPluginProcessor) PluginProvider(org.apache.ignite.plugin.PluginProvider) DurableBackgroundTasksProcessor(org.apache.ignite.internal.processors.localtask.DurableBackgroundTasksProcessor) IgniteAuthenticationProcessor(org.apache.ignite.internal.processors.authentication.IgniteAuthenticationProcessor) GridCacheProcessor(org.apache.ignite.internal.processors.cache.GridCacheProcessor) GridRestProcessor(org.apache.ignite.internal.processors.rest.GridRestProcessor) GridPortProcessor(org.apache.ignite.internal.processors.port.GridPortProcessor) GridDiscoveryManager(org.apache.ignite.internal.managers.discovery.GridDiscoveryManager) IsolatedDiscoverySpi(org.apache.ignite.spi.discovery.isolated.IsolatedDiscoverySpi) GridTracingManager(org.apache.ignite.internal.managers.tracing.GridTracingManager) GridSystemViewManager(org.apache.ignite.internal.managers.systemview.GridSystemViewManager) GridAffinityProcessor(org.apache.ignite.internal.processors.affinity.GridAffinityProcessor) IgniteMBeansManager(org.apache.ignite.internal.managers.IgniteMBeansManager) GridJobMetricsProcessor(org.apache.ignite.internal.processors.jobmetrics.GridJobMetricsProcessor) GridQueryProcessor(org.apache.ignite.internal.processors.query.GridQueryProcessor) GridMetricManager(org.apache.ignite.internal.processors.metric.GridMetricManager) IgniteSpiVersionCheckException(org.apache.ignite.spi.IgniteSpiVersionCheckException) GridLoadBalancerManager(org.apache.ignite.internal.managers.loadbalancer.GridLoadBalancerManager) DataStreamProcessor(org.apache.ignite.internal.processors.datastreamer.DataStreamProcessor) FailureProcessor(org.apache.ignite.internal.processors.failure.FailureProcessor) GridEventStorageManager(org.apache.ignite.internal.managers.eventstorage.GridEventStorageManager) IgnitePluginProcessor(org.apache.ignite.internal.processors.plugin.IgnitePluginProcessor) PdsConsistentIdProcessor(org.apache.ignite.internal.processors.cache.persistence.filename.PdsConsistentIdProcessor) MaintenanceProcessor(org.apache.ignite.internal.maintenance.MaintenanceProcessor) GridTimeoutProcessor(org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor) DecimalFormat(java.text.DecimalFormat) GridDeploymentManager(org.apache.ignite.internal.managers.deployment.GridDeploymentManager) ClusterProcessor(org.apache.ignite.internal.processors.cluster.ClusterProcessor) OsDiscoveryNodeValidationProcessor(org.apache.ignite.internal.processors.nodevalidation.OsDiscoveryNodeValidationProcessor) DiscoveryNodeValidationProcessor(org.apache.ignite.internal.processors.nodevalidation.DiscoveryNodeValidationProcessor) ClientListenerProcessor(org.apache.ignite.internal.processors.odbc.ClientListenerProcessor) DistributedMetaStorageImpl(org.apache.ignite.internal.processors.metastorage.persistence.DistributedMetaStorageImpl) NoOpTransactionalDrProcessor(org.apache.ignite.internal.processors.txdr.NoOpTransactionalDrProcessor) TransactionalDrProcessor(org.apache.ignite.internal.processors.txdr.TransactionalDrProcessor) LifecycleBean(org.apache.ignite.lifecycle.LifecycleBean) IGridClusterStateProcessor(org.apache.ignite.internal.processors.cluster.IGridClusterStateProcessor) DiagnosticProcessor(org.apache.ignite.internal.processors.diagnostic.DiagnosticProcessor) GridSegmentationProcessor(org.apache.ignite.internal.processors.segmentation.GridSegmentationProcessor) GridCollisionManager(org.apache.ignite.internal.managers.collision.GridCollisionManager) IgniteCacheObjectProcessor(org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor) GridTaskProcessor(org.apache.ignite.internal.processors.task.GridTaskProcessor) GridContinuousProcessor(org.apache.ignite.internal.processors.continuous.GridContinuousProcessor) RuntimeMXBean(java.lang.management.RuntimeMXBean) DistributedConfigurationProcessor(org.apache.ignite.internal.processors.configuration.distributed.DistributedConfigurationProcessor) GridClosureProcessor(org.apache.ignite.internal.processors.closure.GridClosureProcessor) GridFailoverManager(org.apache.ignite.internal.managers.failover.GridFailoverManager) PlatformProcessor(org.apache.ignite.internal.processors.platform.PlatformProcessor) GridIoManager(org.apache.ignite.internal.managers.communication.GridIoManager) GridResourceProcessor(org.apache.ignite.internal.processors.resource.GridResourceProcessor) PoolProcessor(org.apache.ignite.internal.processors.pool.PoolProcessor) GridJobProcessor(org.apache.ignite.internal.processors.job.GridJobProcessor) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor)

Example 19 with GridTimeoutProcessor

use of org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor in project gridgain by gridgain.

the class IgniteTxManager method scheduleDumpTask.

/**
 * Scheduling tasks for dumping long operations. Closes current task
 * (if any) and if the {@code timeout > 0} schedules a new task
 * with a new timeout, delay and start period equal to
 * {@code timeout}, otherwise task is deleted.
 *
 * @param taskKey Appropriate key in {@link IgniteTxManager#timeoutOperations}
 * @param r Task.
 * @param timeout Long operations dump timeout.
 */
void scheduleDumpTask(String taskKey, Runnable r, long timeout) {
    if (isStopping())
        return;
    GridTimeoutProcessor.CancelableTask longOpDumpTask;
    GridTimeoutProcessor timeoutProc = cctx.kernalContext().timeout();
    synchronized (timeoutOperations) {
        GridTimeoutProcessor.CancelableTask task = timeoutOperations.get(taskKey);
        if (nonNull(task))
            task.close();
        longOpDumpTask = timeout > 0 ? timeoutProc.schedule(r, timeout, timeout) : null;
        timeoutOperations.put(taskKey, longOpDumpTask);
    }
}
Also used : GridTimeoutProcessor(org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor)

Example 20 with GridTimeoutProcessor

use of org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor in project gridgain by gridgain.

the class LocalPendingTransactionsTrackerTest method setUp.

/**
 */
@Before
public void setUp() {
    GridTimeoutProcessor time = Mockito.mock(GridTimeoutProcessor.class);
    Mockito.when(time.addTimeoutObject(Mockito.any())).thenAnswer(mock -> {
        GridTimeoutObject timeoutObj = (GridTimeoutObject) mock.getArguments()[0];
        long endTime = timeoutObj.endTime();
        timeoutExecutor.schedule(timeoutObj::onTimeout, endTime - U.currentTimeMillis(), TimeUnit.MILLISECONDS);
        return null;
    });
    GridCacheSharedContext<?, ?> cctx = Mockito.mock(GridCacheSharedContext.class);
    Mockito.when(cctx.time()).thenReturn(time);
    Mockito.when(cctx.logger(LocalPendingTransactionsTracker.class)).thenReturn(new GridTestLog4jLogger());
    tracker = new LocalPendingTransactionsTracker(cctx);
}
Also used : GridTimeoutProcessor(org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor) GridTimeoutObject(org.apache.ignite.internal.processors.timeout.GridTimeoutObject) GridTestLog4jLogger(org.apache.ignite.testframework.junits.logger.GridTestLog4jLogger) Before(org.junit.Before)

Aggregations

GridTimeoutProcessor (org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor)24 GridTestKernalContext (org.apache.ignite.testframework.junits.GridTestKernalContext)16 ClusterNode (org.apache.ignite.cluster.ClusterNode)15 HashMap (java.util.HashMap)13 GridIoMessageFactory (org.apache.ignite.internal.managers.communication.GridIoMessageFactory)12 IgniteMessageFactoryImpl (org.apache.ignite.internal.managers.communication.IgniteMessageFactoryImpl)12 MessageFactory (org.apache.ignite.plugin.extensions.communication.MessageFactory)12 MessageFactoryProvider (org.apache.ignite.plugin.extensions.communication.MessageFactoryProvider)12 GridSpiTestContext (org.apache.ignite.testframework.GridSpiTestContext)12 GridTestNode (org.apache.ignite.testframework.GridTestNode)12 IgniteTestResources (org.apache.ignite.testframework.junits.IgniteTestResources)12 Map (java.util.Map)11 Test (org.junit.Test)10 GridTestMessage (org.apache.ignite.spi.communication.GridTestMessage)7 IgniteMock (org.apache.ignite.testframework.junits.IgniteMock)7 IgniteMessageFactory (org.apache.ignite.plugin.extensions.communication.IgniteMessageFactory)6 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)5 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)5 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)5 Message (org.apache.ignite.plugin.extensions.communication.Message)5