Search in sources :

Example 1 with ResourceProvider

use of org.apache.ignite.mesos.resource.ResourceProvider in project ignite by apache.

the class IgniteFramework method main.

/**
     * Main methods has only one optional parameter - path to properties files.
     *
     * @param args Args.
     * @throws Exception If failed.
     */
public static void main(String[] args) throws Exception {
    IgniteFramework igniteFramework = new IgniteFramework();
    ClusterProperties clusterProps = ClusterProperties.from(args.length >= 1 ? args[0] : null);
    String baseUrl = String.format("http://%s:%d", clusterProps.httpServerHost(), clusterProps.httpServerPort());
    JettyServer httpSrv = new JettyServer();
    httpSrv.start(new ResourceHandler(clusterProps.userLibs(), clusterProps.igniteCfg(), clusterProps.igniteWorkDir()), clusterProps);
    ResourceProvider provider = new ResourceProvider();
    IgniteProvider igniteProvider = new IgniteProvider(clusterProps.igniteWorkDir());
    provider.init(clusterProps, igniteProvider, baseUrl);
    // Create the scheduler.
    Scheduler scheduler = new IgniteScheduler(clusterProps, provider);
    // Create the driver.
    MesosSchedulerDriver driver;
    if (System.getenv(MESOS_AUTHENTICATE) != null) {
        log.info("Enabling authentication for the framework");
        if (System.getenv(DEFAULT_PRINCIPAL) == null) {
            log.log(Level.SEVERE, "Expecting authentication principal in the environment");
            System.exit(1);
        }
        if (System.getenv(DEFAULT_SECRET) == null) {
            log.log(Level.SEVERE, "Expecting authentication secret in the environment");
            System.exit(1);
        }
        Protos.Credential cred = Protos.Credential.newBuilder().setPrincipal(System.getenv(DEFAULT_PRINCIPAL)).setSecret(ByteString.copyFrom(System.getenv(DEFAULT_SECRET).getBytes())).build();
        driver = new MesosSchedulerDriver(scheduler, igniteFramework.getFrameworkInfo(), clusterProps.masterUrl(), cred);
    } else
        driver = new MesosSchedulerDriver(scheduler, igniteFramework.getFrameworkInfo(), clusterProps.masterUrl());
    int status = driver.run() == Protos.Status.DRIVER_STOPPED ? 0 : 1;
    httpSrv.stop();
    // Ensure that the driver process terminates.
    driver.stop();
    System.exit(status);
}
Also used : IgniteProvider(org.apache.ignite.mesos.resource.IgniteProvider) Scheduler(org.apache.mesos.Scheduler) ResourceHandler(org.apache.ignite.mesos.resource.ResourceHandler) ByteString(com.google.protobuf.ByteString) Protos(org.apache.mesos.Protos) ResourceProvider(org.apache.ignite.mesos.resource.ResourceProvider) JettyServer(org.apache.ignite.mesos.resource.JettyServer) MesosSchedulerDriver(org.apache.mesos.MesosSchedulerDriver)

Aggregations

ByteString (com.google.protobuf.ByteString)1 IgniteProvider (org.apache.ignite.mesos.resource.IgniteProvider)1 JettyServer (org.apache.ignite.mesos.resource.JettyServer)1 ResourceHandler (org.apache.ignite.mesos.resource.ResourceHandler)1 ResourceProvider (org.apache.ignite.mesos.resource.ResourceProvider)1 MesosSchedulerDriver (org.apache.mesos.MesosSchedulerDriver)1 Protos (org.apache.mesos.Protos)1 Scheduler (org.apache.mesos.Scheduler)1