Search in sources :

Example 1 with IgniteComponent

use of org.apache.ignite.internal.manager.IgniteComponent in project ignite-3 by apache.

the class IgniteImpl method start.

/**
 * Starts ignite node.
 *
 * @param cfg Optional node configuration based on {@link org.apache.ignite.configuration.schemas.runner.NodeConfigurationSchema} and
 *            {@link org.apache.ignite.configuration.schemas.network.NetworkConfigurationSchema}. Following rules are used for applying
 *            the configuration properties:
 *            <ol>
 *            <li>Specified property overrides existing one or just applies itself if it wasn't
 *            previously specified.</li>
 *            <li>All non-specified properties either use previous value or use default one from
 *            corresponding configuration schema.</li>
 *            </ol>
 *            So that, in case of initial node start (first start ever) specified configuration, supplemented with defaults, is
 *            used. If no configuration was provided defaults are used for all configuration properties. In case of node
 *            restart, specified properties override existing ones, non specified properties that also weren't specified
 *            previously use default values. Please pay attention that previously specified properties are searched in the
 *            {@code workDir} specified by the user.
 */
public void start(@Nullable String cfg) {
    List<IgniteComponent> startedComponents = new ArrayList<>();
    try {
        // Vault startup.
        doStartComponent(name, startedComponents, vaultMgr);
        vaultMgr.putName(name).join();
        // Node configuration manager startup.
        doStartComponent(name, startedComponents, nodeCfgMgr);
        // Node configuration manager bootstrap.
        if (cfg != null) {
            try {
                nodeCfgMgr.bootstrap(cfg);
            } catch (Exception e) {
                throw new IgniteException("Unable to parse user-specific configuration.", e);
            }
        } else {
            nodeCfgMgr.configurationRegistry().initializeDefaults();
        }
        // Start the remaining components.
        List<IgniteComponent> otherComponents = List.of(nettyBootstrapFactory, clusterSvc, raftMgr, txManager, metaStorageMgr, clusterCfgMgr, baselineMgr, distributedTblMgr, qryEngine, restComponent, clientHandlerModule);
        for (IgniteComponent component : otherComponents) {
            doStartComponent(name, startedComponents, component);
        }
        notifyConfigurationListeners();
        // Deploy all registered watches because all components are ready and have registered their listeners.
        metaStorageMgr.deployWatches();
        if (!status.compareAndSet(Status.STARTING, Status.STARTED)) {
            throw new NodeStoppingException();
        }
    } catch (Exception e) {
        String errMsg = "Unable to start node=[" + name + "].";
        LOG.error(errMsg, e);
        doStopNode(startedComponents);
        throw new IgniteException(errMsg, e);
    }
}
Also used : IgniteComponent(org.apache.ignite.internal.manager.IgniteComponent) NodeStoppingException(org.apache.ignite.lang.NodeStoppingException) IgniteException(org.apache.ignite.lang.IgniteException) ArrayList(java.util.ArrayList) IgniteInternalException(org.apache.ignite.lang.IgniteInternalException) IgniteException(org.apache.ignite.lang.IgniteException) NodeStoppingException(org.apache.ignite.lang.NodeStoppingException) IOException(java.io.IOException)

Example 2 with IgniteComponent

use of org.apache.ignite.internal.manager.IgniteComponent in project ignite-3 by apache.

the class IgniteImpl method doStopNode.

/**
 * Calls {@link IgniteComponent#beforeNodeStop()} and then {@link IgniteComponent#stop()} for all components in start-reverse-order.
 * Cleanups node started components map and node status map.
 *
 * @param startedComponents List of already started components for given node.
 */
private void doStopNode(@NotNull List<IgniteComponent> startedComponents) {
    ListIterator<IgniteComponent> beforeStopIter = startedComponents.listIterator(startedComponents.size());
    while (beforeStopIter.hasPrevious()) {
        IgniteComponent componentToExecBeforeNodeStop = beforeStopIter.previous();
        try {
            componentToExecBeforeNodeStop.beforeNodeStop();
        } catch (Exception e) {
            LOG.error("Unable to execute before node stop on the component=[" + componentToExecBeforeNodeStop + "] within node=[" + name + ']', e);
        }
    }
    ListIterator<IgniteComponent> stopIter = startedComponents.listIterator(startedComponents.size());
    while (stopIter.hasPrevious()) {
        IgniteComponent componentToStop = stopIter.previous();
        try {
            componentToStop.stop();
        } catch (Exception e) {
            LOG.error("Unable to stop component=[" + componentToStop + "] within node=[" + name + ']', e);
        }
    }
}
Also used : IgniteComponent(org.apache.ignite.internal.manager.IgniteComponent) IgniteInternalException(org.apache.ignite.lang.IgniteInternalException) IgniteException(org.apache.ignite.lang.IgniteException) NodeStoppingException(org.apache.ignite.lang.NodeStoppingException) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)2 IgniteComponent (org.apache.ignite.internal.manager.IgniteComponent)2 IgniteException (org.apache.ignite.lang.IgniteException)2 IgniteInternalException (org.apache.ignite.lang.IgniteInternalException)2 NodeStoppingException (org.apache.ignite.lang.NodeStoppingException)2 ArrayList (java.util.ArrayList)1