Example usage for com.google.common.base Optional get

List of usage examples for com.google.common.base Optional get

Introduction

In this page you can find the example usage for com.google.common.base Optional get.

Prototype

public abstract T get();

Source Link

Document

Returns the contained instance, which must be present.

Usage

From source file:com.google.devtools.build.xcode.actoolzip.ActoolZip.java

public static void main(String[] args) throws IOException, InterruptedException {
    Optional<File> infoPlistPath = replaceInfoPlistPath(args);
    try {/*from   ww w .  ja va2  s  . c o  m*/
        OutErr outErr = Wrappers.executeCapturingOutput(args, new ActoolZip());
        if (infoPlistPath.isPresent() && !infoPlistPath.get().exists()) {
            outErr.print();
            System.exit(1);
        }
    } catch (CommandFailedException e) {
        Wrappers.handleException(e);
    }
}

From source file:cn.lhfei.spark.rdd.PairRDDLeftJoinApp.java

public static void main(String[] args) {
    SparkConf conf = new SparkConf().setMaster("local").setAppName("PairRDD");
    SparkContext sc = new SparkContext(conf);
    JavaSparkContext jsc = new JavaSparkContext(sc);

    JavaRDD<String> ipRepo = jsc.textFile("src/test/resources/data/IP_REPO_CN.txt").cache();
    JavaRDD<String> logs = jsc.textFile("src/test/resources/data/IP_LOGS.log").cache();

    JavaPairRDD<String, String> ipRepoPair = ipRepo.mapToPair(new PairFunction<String, String, String>() {
        @Override/*w w w . j a  va  2  s . c  o  m*/
        public Tuple2<String, String> call(String line) throws Exception {
            //log.debug("====================={}", line);
            String ip = line.split("\t")[0].trim();
            return new Tuple2(ip, line.replaceAll(ip + "\t", ""));
        }
    }).distinct().cache();

    // collect logs by cat code and format time to time range.
    JavaRDD<VideologPair> logRdd = logs.map(new Function<String, VideologPair>() {
        @Override
        public VideologPair call(String line) throws Exception {
            VideologPair pair = VideologFilter.filte(line, "2015-07-02", "0000");

            return pair;
        }
    }).cache();

    // 
    JavaPairRDD<String, String> ipPair = logRdd.mapToPair(new PairFunction<VideologPair, String, String>() {

        @Override
        public Tuple2<String, String> call(VideologPair pair) throws Exception {

            return new Tuple2<String, String>(pair.getIp(), pair.getKey() + "\t" + pair.getValue());
        }

    }).cache();

    //   
    JavaPairRDD<String, Tuple2<String, Optional<String>>> logsFullyRdd = ipPair.leftOuterJoin(ipRepoPair)
            .cache();

    JavaRDD<String> resultRdd = logsFullyRdd
            .map(new Function<Tuple2<String, Tuple2<String, Optional<String>>>, String>() {

                @Override
                public String call(Tuple2<String, Tuple2<String, Optional<String>>> val) throws Exception {

                    Tuple2<String, Optional<String>> option = val._2();
                    String line = option._1();
                    Optional<String> isp = option._2();

                    String result = new String(line + "\t");

                    if (isp.isPresent()) {
                        result += isp.get();
                    } else {
                        result += NORMAL_ISP_OPTIONAL.get();
                    }

                    log.debug("{}", result);

                    return result;
                }

            }).cache();

    resultRdd.count();

    jsc.close();

}

From source file:io.crate.frameworks.mesos.Main.java

public static void main(String[] args) throws Exception {
    BasicConfigurator.configure();/*from   w  w w  .  ja va 2s. c  o  m*/
    Configuration configuration = parseConfiguration(args);

    final double frameworkFailoverTimeout = 31536000d; // 60 * 60 * 24 * 365 = 1y

    final String host = System.getenv("MESOS_HOSTNAME");
    final String webUri = UriBuilder.fromPath("/cluster").scheme("http")
            .host(host == null ? currentHost() : host).port(configuration.apiPort).build().toString();
    Protos.FrameworkInfo.Builder frameworkBuilder = Protos.FrameworkInfo.newBuilder()
            .setName(configuration.frameworkName).setUser(configuration.user).setRole(configuration.role)
            .setWebuiUrl(webUri).setCheckpoint(true) // will be enabled by default in Mesos 0.22
            .setFailoverTimeout(frameworkFailoverTimeout);

    PersistentStateStore stateStore = new PersistentStateStore(
            new ZooKeeperState(configuration.zookeeper, 20_000, TimeUnit.MILLISECONDS,
                    String.format("/%s/%s", configuration.frameworkName, configuration.clusterName)),
            configuration.nodeCount);

    Optional<String> frameworkId = stateStore.state().frameworkId();
    if (frameworkId.isPresent()) {
        frameworkBuilder.setId(Protos.FrameworkID.newBuilder().setValue(frameworkId.get()).build());
    }

    final Scheduler scheduler = new CrateScheduler(stateStore, configuration);

    // create the driver
    MesosSchedulerDriver driver;

    String mesosMaster = configuration.mesosMaster();
    Optional<Protos.Credential> credential = readCredentials();
    if (credential.isPresent()) {
        frameworkBuilder.setPrincipal(credential.get().getPrincipal());
        driver = new MesosSchedulerDriver(scheduler, frameworkBuilder.build(), mesosMaster, credential.get());
    } else {
        frameworkBuilder.setPrincipal("crate-framework");
        driver = new MesosSchedulerDriver(scheduler, frameworkBuilder.build(), mesosMaster);
    }

    CrateHttpService api = new CrateHttpService(stateStore, configuration);
    api.start();
    int status = driver.run() == Protos.Status.DRIVER_STOPPED ? 0 : 1;

    // Ensure that the driver process terminates.
    api.stop();
    driver.stop();
    System.exit(status);
}

From source file:com.github.rinde.dynurg.Experimentation.java

public static void main(String[] args) {
    System.out.println(System.getProperty("jppf.config"));

    final long time = System.currentTimeMillis();
    final Experiment.Builder experimentBuilder = Experiment.build(SUM).computeDistributed().withRandomSeed(123)
            .repeat(10).numBatches(10)//from w  w  w.  ja  va2s .c o m
            .addScenarios(
                    FileProvider.builder().add(Paths.get(DATASET)).filter("glob:**[01].[0-9]0#[0-5].scen"))
            .addResultListener(new CommandLineProgress(System.out))
            .addConfiguration(
                    Central.solverConfiguration(CheapestInsertionHeuristic.supplier(SUM), "-CheapInsert"))
            .addConfiguration(Central.solverConfiguration(CheapestInsertionHeuristic.supplier(TARDINESS),
                    "-CheapInsert-Tard"))
            .addConfiguration(Central.solverConfiguration(CheapestInsertionHeuristic.supplier(DISTANCE),
                    "-CheapInsert-Dist"))
            .addConfiguration(Central.solverConfiguration(
                    Opt2.breadthFirstSupplier(CheapestInsertionHeuristic.supplier(SUM), SUM),
                    "-bfsOpt2-CheapInsert"))
            .addConfiguration(Central.solverConfiguration(
                    Opt2.breadthFirstSupplier(CheapestInsertionHeuristic.supplier(TARDINESS), TARDINESS),
                    "-bfsOpt2-CheapInsert-Tard"))
            .addConfiguration(Central.solverConfiguration(
                    Opt2.breadthFirstSupplier(CheapestInsertionHeuristic.supplier(DISTANCE), DISTANCE),
                    "-bfsOpt2-CheapInsert-Dist"))
            .addConfiguration(Central.solverConfiguration(
                    Opt2.depthFirstSupplier(CheapestInsertionHeuristic.supplier(SUM), SUM),
                    "-dfsOpt2-CheapInsert"))
            .addConfiguration(Central.solverConfiguration(
                    Opt2.depthFirstSupplier(CheapestInsertionHeuristic.supplier(TARDINESS), TARDINESS),
                    "-dfsOpt2-CheapInsert-Tard"))
            .addConfiguration(Central.solverConfiguration(
                    Opt2.depthFirstSupplier(CheapestInsertionHeuristic.supplier(DISTANCE), DISTANCE),
                    "-dfsOpt2-CheapInsert-Dist"));

    final Menu m = ExperimentCli.createMenuBuilder(experimentBuilder)
            .add(Option.builder("nv", ArgumentParser.INTEGER).longName("number-of-vehicles")
                    .description("Changes the number of vehicles in all scenarios.").build(), experimentBuilder,
                    new ArgHandler<Experiment.Builder, Integer>() {
                        @Override
                        public void execute(Experiment.Builder subject, Optional<Integer> argument) {
                            subject.setScenarioReader(new NumVehiclesScenarioParser(argument.get()));
                        }
                    })
            .build();

    final Optional<String> error = m.safeExecute(args);
    if (error.isPresent()) {
        System.err.println(error.get());
        return;
    }
    final ExperimentResults results = experimentBuilder.perform();

    final long duration = System.currentTimeMillis() - time;
    System.out
            .println("Done, computed " + results.results.size() + " simulations in " + duration / 1000d + "s");

    final Multimap<MASConfiguration, SimulationResult> groupedResults = LinkedHashMultimap.create();
    for (final SimulationResult sr : results.sortedResults()) {
        groupedResults.put(sr.masConfiguration, sr);
    }

    for (final MASConfiguration config : groupedResults.keySet()) {
        final Collection<SimulationResult> group = groupedResults.get(config);

        final File configResult = new File(RESULTS + config.toString() + ".csv");
        try {
            Files.createParentDirs(configResult);
        } catch (final IOException e1) {
            throw new IllegalStateException(e1);
        }
        // deletes the file in case it already exists
        configResult.delete();
        try {
            Files.append(
                    "dynamism,urgency_mean,urgency_sd,cost,travel_time,tardiness,over_time,is_valid,scenario_id,random_seed,comp_time,num_vehicles\n",
                    configResult, Charsets.UTF_8);
        } catch (final IOException e1) {
            throw new IllegalStateException(e1);
        }

        for (final SimulationResult sr : group) {
            final String pc = sr.scenario.getProblemClass().getId();
            final String id = sr.scenario.getProblemInstanceId();
            final int numVehicles = FluentIterable.from(sr.scenario.asList()).filter(AddVehicleEvent.class)
                    .size();
            try {
                final List<String> propsStrings = Files
                        .readLines(new File("files/dataset/" + pc + id + ".properties"), Charsets.UTF_8);
                final Map<String, String> properties = Splitter.on("\n").withKeyValueSeparator(" = ")
                        .split(Joiner.on("\n").join(propsStrings));

                final double dynamism = Double.parseDouble(properties.get("dynamism"));
                final double urgencyMean = Double.parseDouble(properties.get("urgency_mean"));
                final double urgencySd = Double.parseDouble(properties.get("urgency_sd"));

                final double cost = SUM.computeCost(sr.stats);
                final double travelTime = SUM.travelTime(sr.stats);
                final double tardiness = SUM.tardiness(sr.stats);
                final double overTime = SUM.overTime(sr.stats);
                final boolean isValidResult = SUM.isValidResult(sr.stats);
                final long computationTime = sr.stats.computationTime;

                final String line = Joiner.on(",")
                        .appendTo(new StringBuilder(),
                                asList(dynamism, urgencyMean, urgencySd, cost, travelTime, tardiness, overTime,
                                        isValidResult, pc + id, sr.seed, computationTime, numVehicles))
                        .append(System.lineSeparator()).toString();
                if (!isValidResult) {
                    System.err.println("WARNING: FOUND AN INVALID RESULT: ");
                    System.err.println(line);
                }
                Files.append(line, configResult, Charsets.UTF_8);
            } catch (final IOException e) {
                throw new IllegalStateException(e);
            }
        }
    }
}

From source file:eu.thebluemountain.customers.dctm.brownbag.badcontentslister.Main.java

public static void main(String[] args) {
    try {/*w  w  w.j a v  a2  s  . c  o  m*/
        Map<Command, Optional<String>> cmds = Command.parse(args);
        if ((cmds.containsKey(Command.HELP)) || (!cmds.containsKey(Command.CONFIG))) {
            usage();
            return;
        }
        final JDBCConfig config = config(cmds.get(Command.CONFIG).get());

        String pwd = config.password.orNull();
        if (null == pwd) {
            Optional<String> opt = passwordOf("database", config.user);
            if (!opt.isPresent()) {
                throw new ExitException(RetCode.ERR_CANCELLED);
            }
            pwd = opt.get();
        }
        try (JDBCConnection from = create(config, pwd); CSVWriter writer = makeLog(config.user)) {
            Stopwatch watch = Stopwatch.createStarted();
            Stores stores = StoresReader.STORESREADER.apply(from);
            System.out.println("spent " + watch.stop() + " to load stores");
            final Function<DecoratedContent, Checks.Result> checker = Checks.checker(stores);
            final Multiset<Checks.Code> codes = TreeMultiset.create();
            watch.reset().start();
            ResponseUI rui = ResponseUI.create(1024, 64);
            try (CloseableIterator<DecoratedContent> it = DCReader.reader(from, stores)) {
                long count = 0L;
                while (it.hasNext()) {
                    DecoratedContent dc = it.next();
                    count++;
                    final Checks.Result result = checker.apply(dc);
                    assert null != result;
                    rui.onResponse(result);
                    final Checks.Code code = result.code;
                    codes.add(code);
                    if (code != Checks.Code.OK) {
                        // we've got an error then ....
                        writer.writeError(dc, result);
                    }
                }
                rui.finish();
                System.out.println("spent " + watch.stop() + " to read " + count + " d.c.");
                System.out.println("stats: " + codes);
                System.out.println("bye");
            }
        }
    } catch (SQLException e) {
        e.printStackTrace(System.err);
        System.err.flush();
        System.out.println();
        usage();
        System.exit(RetCode.ERR_SQL.ordinal());
    } catch (ExitException e) {
        e.exit();
    } catch (RuntimeException | IOException e) {
        e.printStackTrace(System.err);
        System.err.flush();
        System.out.println();
        usage();
        System.exit(RetCode.ERR_OTHER.ordinal());
    }
}

From source file:com.accumulobook.designs.graph.TwitterGraph.java

public static void main(String[] args) throws Exception {

    Connector conn = ExampleMiniCluster.getConnector();

    // create our table and get some data
    BatchWriter writer = Graph.setupTable(conn, TWITTER_GRAPH_TABLE, true);

    int seconds = 30;
    ingest(args, writer, seconds);/*  www.ja v  a2 s.  co m*/

    // visualize our graph, one node at a time
    System.out.println("visualizing graph ...");
    UbigraphClient client = new UbigraphClient();

    for (String startNode : new String[] { "a", "b", "c", "d", "e", "f", "g", "h", "i" }) {

        Scanner startNodeScanner = conn.createScanner(TWITTER_GRAPH_TABLE, Authorizations.EMPTY);
        Optional<String> node = Graph.discoverNode(startNode, startNodeScanner);
        startNodeScanner.close();

        if (node.isPresent()) {

            // visualize start node
            int nodeId = client.newVertex();
            client.setVertexAttribute(nodeId, "label", node.get());

            Scanner neighborScanner = conn.createScanner(TWITTER_GRAPH_TABLE, Authorizations.EMPTY);
            for (String neighbor : Graph.getNeighbors(node.get(), neighborScanner, "ALL")) {

                // visualize neighbor node
                int neighborId = client.newVertex();
                client.setVertexAttribute(neighborId, "label", neighbor);

                // visualize edge
                client.newEdge(nodeId, neighborId);
            }
            neighborScanner.close();
        }
    }
}

From source file:com.amazonaws.services.dynamodbv2.streams.connectors.CommandLineInterface.java

/**
 * Command line main method entry point/*  w w w  . j av a2s . c  om*/
 *
 * @param args
 *            command line arguments
 */
public static void main(String[] args) {
    try {
        final Optional<Worker> workerOption = mainUnsafe(args);
        if (!workerOption.isPresent()) {
            return;
        }
        System.out.println("Starting replication now, check logs for more details.");
        workerOption.get().run();
    } catch (ParameterException e) {
        log.error(e);
        JCommander.getConsole().println(e.toString());
        System.exit(StatusCodes.EINVAL);
    } catch (Exception e) {
        log.fatal(e);
        JCommander.getConsole().println(e.toString());
        System.exit(StatusCodes.EINVAL);
    }
}

From source file:com.github.rinde.vanlon15prima.PerformExperiment.java

public static void main(String[] args) {
    final long time = System.currentTimeMillis();
    final Experiment.Builder experimentBuilder = Experiment.build(SUM).computeLocal().withRandomSeed(123)
            .withThreads(Runtime.getRuntime().availableProcessors()).repeat(1)
            .addScenarios(FileProvider.builder().add(Paths.get(DATASET)).filter("glob:**[09].scen"))
            .addResultListener(new CommandLineProgress(System.out))
            .usePostProcessor(PostProcessors.statisticsPostProcessor())
            // central: cheapest insertion configuration
            .addConfiguration(// w  ww. java2  s.c om
                    Central.solverConfiguration(CheapestInsertionHeuristic.supplier(SUM), "CheapInsert"))
            // central: random
            .addConfiguration(Central.solverConfiguration(RandomSolver.supplier()))
            // mas: auction cheapest insertion with 2-opt per vehicle
            .addConfiguration(MASConfiguration.pdptwBuilder().setName("Auction-R-opt2cih-B-cih")
                    .addEventHandler(AddVehicleEvent.class, new VehicleHandler(
                            SolverRoutePlanner.supplier(
                                    Opt2.breadthFirstSupplier(CheapestInsertionHeuristic.supplier(SUM), SUM)),
                            SolverBidder.supplier(SUM, CheapestInsertionHeuristic.supplier(SUM))))
                    .addModel(SolverModel.builder()).addModel(AuctionCommModel.builder()).build());

    final Optional<ExperimentResults> results = experimentBuilder.perform(System.out, args);
    final long duration = System.currentTimeMillis() - time;
    if (!results.isPresent()) {
        return;
    }

    System.out.println("Done, computed " + results.get().getResults().size() + " simulations in "
            + duration / 1000d + "s");

    final Multimap<MASConfiguration, SimulationResult> groupedResults = LinkedHashMultimap.create();
    for (final SimulationResult sr : results.get().sortedResults()) {
        groupedResults.put(sr.getSimArgs().getMasConfig(), sr);
    }

    for (final MASConfiguration config : groupedResults.keySet()) {
        final Collection<SimulationResult> group = groupedResults.get(config);

        final File configResult = new File(RESULTS + config.getName() + ".csv");
        try {
            Files.createParentDirs(configResult);
        } catch (final IOException e1) {
            throw new IllegalStateException(e1);
        }
        // deletes the file in case it already exists
        configResult.delete();
        try {
            Files.append(
                    "dynamism,urgency,scale,cost,travel_time,tardiness,over_time,is_valid,scenario_id,random_seed,comp_time,num_vehicles,num_orders\n",
                    configResult, Charsets.UTF_8);
        } catch (final IOException e1) {
            throw new IllegalStateException(e1);
        }

        for (final SimulationResult sr : group) {
            final String pc = sr.getSimArgs().getScenario().getProblemClass().getId();
            final String id = sr.getSimArgs().getScenario().getProblemInstanceId();
            final int numVehicles = FluentIterable.from(sr.getSimArgs().getScenario().getEvents())
                    .filter(AddVehicleEvent.class).size();
            try {
                final String scenarioName = Joiner.on("-").join(pc, id);
                final List<String> propsStrings = Files
                        .readLines(new File(DATASET + scenarioName + ".properties"), Charsets.UTF_8);
                final Map<String, String> properties = Splitter.on("\n").withKeyValueSeparator(" = ")
                        .split(Joiner.on("\n").join(propsStrings));

                final double dynamism = Double.parseDouble(properties.get("dynamism_bin"));
                final long urgencyMean = Long.parseLong(properties.get("urgency"));
                final double scale = Double.parseDouble(properties.get("scale"));

                final StatisticsDTO stats = (StatisticsDTO) sr.getResultObject();
                final double cost = SUM.computeCost(stats);
                final double travelTime = SUM.travelTime(stats);
                final double tardiness = SUM.tardiness(stats);
                final double overTime = SUM.overTime(stats);
                final boolean isValidResult = SUM.isValidResult(stats);
                final long computationTime = stats.computationTime;

                final long numOrders = Long.parseLong(properties.get("AddParcelEvent"));

                final String line = Joiner.on(",")
                        .appendTo(new StringBuilder(),
                                asList(dynamism, urgencyMean, scale, cost, travelTime, tardiness, overTime,
                                        isValidResult, scenarioName, sr.getSimArgs().getRandomSeed(),
                                        computationTime, numVehicles, numOrders))
                        .append(System.lineSeparator()).toString();
                if (!isValidResult) {
                    System.err.println("WARNING: FOUND AN INVALID RESULT: ");
                    System.err.println(line);
                }
                Files.append(line, configResult, Charsets.UTF_8);
            } catch (final IOException e) {
                throw new IllegalStateException(e);
            }
        }
    }
}

From source file:io.urmia.job.run.Main.java

public static void main(String[] args) throws Exception {

    LoggerContext loggerContext = ((ch.qos.logback.classic.Logger) log).getLoggerContext();
    URL mainURL = ConfigurationWatchListUtil.getMainWatchURL(loggerContext);
    System.err.println(mainURL);//from   w w  w  . j  a  va 2  s  . co  m
    // or even
    log.info("Logback used '{}' as the configuration file.", mainURL);

    CuratorFramework client = null;
    PathChildrenCache cache = null;

    boolean autoRegister = ArgumentParseUtil.isAutoRegister(args);
    String zkURL = ArgumentParseUtil.getZooKeeperURL(args);

    log.info("starting with zk at: {}, auto register: {}", zkURL, autoRegister);

    ns = new ZkNamingServiceImpl(zkURL, AZ);

    Optional<ServiceInstance<NodeType>> meOpt = ns.whoAmI(NodeType.JRS, autoRegister);

    if (!meOpt.isPresent()) {
        System.err.println("unable to find my instance. use auto register or cli-admin to add my node");
        System.exit(1);
        return;
    }

    Runtime.getRuntime().addShutdownHook(new ShutdownHook());

    try {
        me = meOpt.get();

        log.info("my service instance: {}", me);

        ServiceInstance<NodeType> ods = getMyMatchingODSInstance(me);

        id = getId(ods);//me.getId();

        //ns.register(me);
        meWithOdsId = meWithId(me, id);
        ns.register(meWithOdsId);

        mountPoint = getMountPoint(ods);

        String zkPath = getPath(AZ, id);

        System.err.println("instance id: " + me.getId());
        System.err.println("ODS q id   : " + id);
        System.err.println("zk  path   : " + zkPath);
        System.err.println("mount point: " + mountPoint);

        client = CuratorFrameworkFactory.newClient(zkURL, new ExponentialBackoffRetry(1000, 3));
        client.start();

        cache = new PathChildrenCache(client, zkPath, true);
        cache.start();

        cache.getListenable().addListener(new ChildrenListener(), executor);

        log.info("listening path: {}", zkPath);

        loopForever();

    } finally {
        System.err.println("finally block...");
        ns.deregister(meWithOdsId);
        CloseableUtils.closeQuietly(cache);
        CloseableUtils.closeQuietly(client);
    }
}

From source file:io.urmia.job.Main.java

public static void main(String[] args) throws Exception {

    boolean autoRegister = ArgumentParseUtil.isAutoRegister(args);
    String zkURL = ArgumentParseUtil.getZooKeeperURL(args);

    log.info("starting with zk at: {}, auto register: {}", zkURL, autoRegister);

    ns = new ZkNamingServiceImpl(zkURL, AZ);

    Optional<ServiceInstance<NodeType>> meOpt = ns.whoAmI(NodeType.JDS, autoRegister);

    if (!meOpt.isPresent()) {
        System.err.println("unable to find my instance. use auto register or cli-admin to add my node");
        System.exit(1);//from ww w . j  a  v a2 s. c  o  m
        return;
    }

    Runtime.getRuntime().addShutdownHook(new ShutdownHook());

    EventLoopGroup bossGroup = new NioEventLoopGroup(/*1*/);

    try {
        me = meOpt.get();

        log.info("my service instance: {}", me);

        BoneCPConfig boneCPConfig = getBoneCPConfig(ns);

        ns.register(me);

        int port = me.getPort();

        CuratorFramework client = CuratorFrameworkFactory.newClient(zkURL,
                new ExponentialBackoffRetry(1000, 3));
        client.start();

        JdbcPool pool = new JdbcPool.BoneCPJdbcPool(boneCPConfig);

        MetadataRepository repository = new PsqlMetadataRepositoryImpl(pool);

        MetadataService mds = new DefaultMetadataServiceImpl(repository);

        ServerBootstrap b = new ServerBootstrap();

        b.group(bossGroup).channel(NioServerSocketChannel.class).childOption(ChannelOption.AUTO_READ, true)
                .childOption(ChannelOption.ALLOCATOR, new PooledByteBufAllocator())
                .childHandler(new JobApiServerInitializer(client, mds));

        Channel ch = b.bind(port).sync().channel();
        log.info("Job API Server (JDS) at port: {}", port);

        ch.closeFuture().sync();
    } finally {
        ns.deregister(me);
        bossGroup.shutdownGracefully();
        //workerGroup.shutdownGracefully();
    }
}