Search in sources :

Example 1 with IgniteNodeRunner

use of org.apache.ignite.testframework.junits.multijvm.IgniteNodeRunner in project ignite by apache.

the class IgniteCompatibilityNodeRunner method main.

/**
 * Starts {@link Ignite} with test's default configuration.
 *
 * Command-line arguments specification:
 * <pre>
 * args[0] - required - path to closure for tuning IgniteConfiguration before node startup;
 * args[1] - required - name of the starting node;
 * args[2] - required - id of the starting node;
 * args[3] - required - sync-id of a node for synchronization of startup. Must be equals
 * to arg[2] in case of starting the first node in the Ignite cluster;
 * args[4] - required - expected Ignite's version to check at startup;
 * args[5] - optional - path to closure for actions after node startup.
 * </pre>
 *
 * @param args Command-line arguments.
 * @throws Exception In case of an error.
 */
public static void main(String[] args) throws Exception {
    try {
        X.println(GridJavaProcess.PID_MSG_PREFIX + U.jvmPid());
        X.println("Starting Ignite Node... Args=" + Arrays.toString(args));
        if (args.length < 5) {
            throw new IllegalArgumentException("At least five arguments expected:" + " [path/to/closure/file] [ignite-instance-name] [node-id] [sync-node-id] [node-ver]" + " [optional/path/to/closure/file]");
        }
        final Thread watchdog = delayedDumpClasspath();
        IgniteConfiguration cfg = CompatibilityTestsFacade.getConfiguration();
        IgniteInClosure<IgniteConfiguration> cfgClo = readClosureFromFileAndDelete(args[0]);
        cfgClo.apply(cfg);
        final UUID nodeId = UUID.fromString(args[2]);
        final UUID syncNodeId = UUID.fromString(args[3]);
        final IgniteProductVersion expNodeVer = IgniteProductVersion.fromString(args[4]);
        // Ignite instance name and id must be set according to arguments
        // it's used for nodes managing: start, stop etc.
        cfg.setIgniteInstanceName(args[1]);
        cfg.setNodeId(nodeId);
        final Ignite ignite = Ignition.start(cfg);
        assert ignite.cluster().node(syncNodeId) != null : "Node has not joined [id=" + nodeId + "]";
        assert ignite.cluster().localNode().version().compareToIgnoreTimestamp(expNodeVer) == 0 : "Node is of unexpected " + "version: [act=" + ignite.cluster().localNode().version() + ", exp=" + expNodeVer + ']';
        // It needs to set private static field 'ignite' of the IgniteNodeRunner class via reflection
        GridTestUtils.setFieldValue(new IgniteNodeRunner(), "ignite", ignite);
        if (args.length == 6) {
            IgniteInClosure<Ignite> clo = readClosureFromFileAndDelete(args[5]);
            clo.apply(ignite);
        }
        X.println(IgniteCompatibilityAbstractTest.SYNCHRONIZATION_LOG_MESSAGE + nodeId);
        watchdog.interrupt();
    } catch (Throwable e) {
        e.printStackTrace();
        X.println("Dumping classpath, error occurred: " + e);
        dumpClasspath();
        throw e;
    }
}
Also used : IgniteNodeRunner(org.apache.ignite.testframework.junits.multijvm.IgniteNodeRunner) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) IgniteProductVersion(org.apache.ignite.lang.IgniteProductVersion) Ignite(org.apache.ignite.Ignite) UUID(java.util.UUID)

Aggregations

UUID (java.util.UUID)1 Ignite (org.apache.ignite.Ignite)1 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)1 IgniteProductVersion (org.apache.ignite.lang.IgniteProductVersion)1 IgniteNodeRunner (org.apache.ignite.testframework.junits.multijvm.IgniteNodeRunner)1