Example usage for java.lang System getProperty

List of usage examples for java.lang System getProperty

Introduction

In this page you can find the example usage for java.lang System getProperty.

Prototype

public static String getProperty(String key) 

Source Link

Document

Gets the system property indicated by the specified key.

Usage

From source file:com.hpe.nv.samples.basic.BasicComparisonWithoutNV.java

public static void main(String[] args) throws Exception {
    try {/*from w  ww  . j a  va2 s . c o m*/
        // program arguments
        Options options = new Options();
        options.addOption("i", "server-ip", true, "[mandatory] NV Test Manager IP");
        options.addOption("o", "server-port", true, "[mandatory] NV Test Manager port");
        options.addOption("u", "username", true, "[mandatory] NV username");
        options.addOption("w", "password", true, "[mandatory] NV password");
        options.addOption("e", "ssl", true, "[optional] Pass true to use SSL. Default: false");
        options.addOption("y", "proxy", true, "[optional] Proxy server host:port");
        options.addOption("a", "active-adapter-ip", true,
                "[optional] Active adapter IP. Default: --server-ip argument");
        options.addOption("t", "site-url", true,
                "[optional] Site under test URL. Default: HPE Network Virtualization site URL. If you change this value, make sure to change the --xpath argument too");
        options.addOption("x", "xpath", true,
                "[optional] Parameter for ExpectedConditions.visibilityOfElementLocated(By.xpath(...)) method. Use an xpath expression of some element in the site. Default: //div[@id='content']");
        options.addOption("k", "analysis-ports", true,
                "[optional] A comma-separated list of ports for test analysis");
        options.addOption("b", "browser", true,
                "[optional] The browser for which the Selenium WebDriver is built. Possible values: Chrome, Firefox. Default: Firefox");
        options.addOption("d", "debug", true,
                "[optional] Pass true to view console debug messages during execution. Default: false");
        options.addOption("h", "help", false, "[optional] Generates and prints help information");

        // parse and validate the command line arguments
        CommandLineParser parser = new DefaultParser();
        CommandLine line = parser.parse(options, args);

        if (line.hasOption("help")) {
            // print help if help argument is passed
            HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp("BasicComparisonWithoutNV.java", options);
            return;
        }

        if (line.hasOption("server-ip")) {
            serverIp = line.getOptionValue("server-ip");
            if (serverIp.equals("0.0.0.0")) {
                throw new Exception(
                        "Please replace the server IP argument value (0.0.0.0) with your NV Test Manager IP");
            }
        } else {
            throw new Exception("Missing argument -i/--server-ip <serverIp>");
        }

        if (line.hasOption("server-port")) {
            serverPort = Integer.parseInt(line.getOptionValue("server-port"));
        } else {
            throw new Exception("Missing argument -o/--server-port <serverPort>");
        }

        if (line.hasOption("username")) {
            username = line.getOptionValue("username");
        } else {
            throw new Exception("Missing argument -u/--username <username>");
        }

        if (line.hasOption("password")) {
            password = line.getOptionValue("password");
        } else {
            throw new Exception("Missing argument -w/--password <password>");
        }

        if (line.hasOption("ssl")) {
            ssl = Boolean.parseBoolean(line.getOptionValue("ssl"));
        }

        if (line.hasOption("site-url")) {
            siteUrl = line.getOptionValue("site-url");
        } else {
            siteUrl = "http://www8.hp.com/us/en/software-solutions/network-virtualization/index.html";
        }

        if (line.hasOption("xpath")) {
            xpath = line.getOptionValue("xpath");
        } else {
            xpath = "//div[@id='content']";
        }

        if (line.hasOption("proxy")) {
            proxySetting = line.getOptionValue("proxy");
        }

        if (line.hasOption("active-adapter-ip")) {
            activeAdapterIp = line.getOptionValue("active-adapter-ip");
        } else {
            activeAdapterIp = serverIp;
        }

        if (line.hasOption("analysis-ports")) {
            String analysisPortsStr = line.getOptionValue("analysis-ports");
            analysisPorts = analysisPortsStr.split(",");
        } else {
            analysisPorts = new String[] { "80", "8080" };
        }

        if (line.hasOption("browser")) {
            browser = line.getOptionValue("browser");
        } else {
            browser = "Firefox";
        }

        if (line.hasOption("debug")) {
            debug = Boolean.parseBoolean(line.getOptionValue("debug"));
        }

        String newLine = System.getProperty("line.separator");
        String testDescription = "***    This sample demonstrates how NV helps you test your application under various network conditions.                          ***"
                + newLine
                + "***    This test starts by navigating to the home page in the HPE Network Virtualization website using the Selenium WebDriver.    ***"
                + newLine
                + "***    This initial step runs without NV emulation and provides a basis for comparison.                                           ***"
                + newLine
                + "***                                                                                                                               ***"
                + newLine
                + "***    Next, the sample starts an NV test configured with a \"3G Busy\" network scenario.                                           ***"
                + newLine
                + "***    The same step runs as before - navigating to the home page in the HPE Network Virtualization website - but this time,      ***"
                + newLine
                + "***    it does so over an emulated \"3G Busy\" network as part of an NV transaction.                                                ***"
                + newLine
                + "***                                                                                                                               ***"
                + newLine
                + "***    When the sample finishes running, it prints a summary to the console. This summary displays a comparison of the time       ***"
                + newLine
                + "***    it took to navigate to the site both with and without NV's network emulation. The results show that the slow \"3G Busy\"     ***"
                + newLine
                + "***    network increases the time it takes to navigate to the site, as you would expect.                                          ***"
                + newLine
                + "***                                                                                                                               ***"
                + newLine
                + "***    You can view the actual steps of this sample in the BasicComparisonWithoutNV.java file.                                    ***"
                + newLine;

        // print the sample's description
        System.out.println(testDescription);

        // start console spinner
        if (!debug) {
            spinner = new Thread(new Spinner());
            spinner.start();
        }

        // sample execution steps
        /*****    Part 1 - Navigate to the site without using NV emulation                       *****/
        printPartDescription("\b------    Part 1 - Navigate to the site without using NV emulation");
        buildSeleniumWebDriver();
        startNoNV = System.currentTimeMillis();
        seleniumNavigateToPage();
        stopNoNV = System.currentTimeMillis();
        driverCloseAndQuit();
        printPartSeparator();
        /*****    Part 2 - Navigate to the site using NV "3G Busy" network scenario emulation    *****/
        printPartDescription(
                "------    Part 2 - Navigate to the site using NV \"3G Busy\" network scenario emulation");
        initTestManager();
        setActiveAdapter();
        startBusyTest();
        testRunning = true;
        connectToTransactionManager();
        startTransaction();
        transactionInProgress = true;
        buildSeleniumWebDriver();
        seleniumNavigateToPage();
        stopTransaction();
        transactionInProgress = false;
        driverCloseAndQuit();
        stopTest();
        testRunning = false;
        printPartSeparator();
        /*****    Part 3 - Analyze the NV test and print the results to the console              *****/
        printPartDescription("------    Part 3 - Analyze the NV test and print the results to the console");
        analyzeTestJson();
        printPartSeparator();
        doneCallback();

    } catch (Exception e) {
        try {
            handleError(e.getMessage());
        } catch (Exception e2) {
            System.out.println("Error occurred: " + e2.getMessage());
        }
    }
}

From source file:com.joseflavio.unhadegato.Concentrador.java

/**
 * @param args [0] = Diretrio de configuraes.
 *///from   ww  w  .j  a  v a  2  s. c  om
public static void main(String[] args) {

    log.info(Util.getMensagem("unhadegato.iniciando"));

    try {

        /***********************/

        if (args.length > 0) {
            if (!args[0].isEmpty()) {
                configuracao = new File(args[0]);
                if (!configuracao.isDirectory()) {
                    String msg = Util.getMensagem("unhadegato.diretorio.incorreto");
                    System.out.println(msg);
                    log.error(msg);
                    System.exit(1);
                }
            }
        }

        if (configuracao == null) {
            configuracao = new File(System.getProperty("user.home") + File.separator + "unhadegato");
            configuracao.mkdirs();
        }

        log.info(Util.getMensagem("unhadegato.diretorio.endereco", configuracao.getAbsolutePath()));

        /***********************/

        File confGeralArq = new File(configuracao, "unhadegato.conf");

        if (!confGeralArq.exists()) {
            try (InputStream is = Concentrador.class.getResourceAsStream("/unhadegato.conf");
                    OutputStream os = new FileOutputStream(confGeralArq);) {
                IOUtils.copy(is, os);
            }
        }

        Properties confGeral = new Properties();

        try (FileInputStream fis = new FileInputStream(confGeralArq)) {
            confGeral.load(fis);
        }

        String prop_porta = confGeral.getProperty("porta");
        String prop_porta_segura = confGeral.getProperty("porta.segura");
        String prop_seg_pri = confGeral.getProperty("seguranca.privada");
        String prop_seg_pri_senha = confGeral.getProperty("seguranca.privada.senha");
        String prop_seg_pri_tipo = confGeral.getProperty("seguranca.privada.tipo");
        String prop_seg_pub = confGeral.getProperty("seguranca.publica");
        String prop_seg_pub_senha = confGeral.getProperty("seguranca.publica.senha");
        String prop_seg_pub_tipo = confGeral.getProperty("seguranca.publica.tipo");

        if (StringUtil.tamanho(prop_porta) == 0)
            prop_porta = "8885";
        if (StringUtil.tamanho(prop_porta_segura) == 0)
            prop_porta_segura = "8886";
        if (StringUtil.tamanho(prop_seg_pri) == 0)
            prop_seg_pri = "servidor.jks";
        if (StringUtil.tamanho(prop_seg_pri_senha) == 0)
            prop_seg_pri_senha = "123456";
        if (StringUtil.tamanho(prop_seg_pri_tipo) == 0)
            prop_seg_pri_tipo = "JKS";
        if (StringUtil.tamanho(prop_seg_pub) == 0)
            prop_seg_pub = "cliente.jks";
        if (StringUtil.tamanho(prop_seg_pub_senha) == 0)
            prop_seg_pub_senha = "123456";
        if (StringUtil.tamanho(prop_seg_pub_tipo) == 0)
            prop_seg_pub_tipo = "JKS";

        /***********************/

        File seg_pri = new File(prop_seg_pri);
        if (!seg_pri.isAbsolute())
            seg_pri = new File(configuracao.getAbsolutePath() + File.separator + prop_seg_pri);

        if (seg_pri.exists()) {
            System.setProperty("javax.net.ssl.keyStore", seg_pri.getAbsolutePath());
            System.setProperty("javax.net.ssl.keyStorePassword", prop_seg_pri_senha);
            System.setProperty("javax.net.ssl.keyStoreType", prop_seg_pri_tipo);
        }

        File seg_pub = new File(prop_seg_pub);
        if (!seg_pub.isAbsolute())
            seg_pub = new File(configuracao.getAbsolutePath() + File.separator + prop_seg_pub);

        if (seg_pub.exists()) {
            System.setProperty("javax.net.ssl.trustStore", seg_pub.getAbsolutePath());
            System.setProperty("javax.net.ssl.trustStorePassword", prop_seg_pub_senha);
            System.setProperty("javax.net.ssl.trustStoreType", prop_seg_pub_tipo);
        }

        /***********************/

        new Thread() {

            File arquivo = new File(configuracao, "copaibas.conf");

            long ultimaData = -1;

            @Override
            public void run() {

                while (true) {

                    long data = arquivo.lastModified();

                    if (data > ultimaData) {
                        executarCopaibas(arquivo);
                        ultimaData = data;
                    }

                    try {
                        Thread.sleep(5 * 1000);
                    } catch (InterruptedException e) {
                        return;
                    }

                }

            }

        }.start();

        /***********************/

        log.info(Util.getMensagem("unhadegato.conexao.esperando"));

        log.info(Util.getMensagem("copaiba.porta.normal.abrindo", prop_porta));
        Portal portal1 = new Portal(new SocketServidor(Integer.parseInt(prop_porta), false, true));

        log.info(Util.getMensagem("copaiba.porta.segura.abrindo", prop_porta_segura));
        Portal portal2 = new Portal(new SocketServidor(Integer.parseInt(prop_porta_segura), true, true));

        portal1.start();
        portal2.start();

        portal1.join();

        /***********************/

    } catch (Exception e) {

        log.error(e.getMessage(), e);

    } finally {

        for (CopaibaGerenciador gerenciador : gerenciadores.values())
            gerenciador.encerrar();
        gerenciadores.clear();
        gerenciadores = null;

    }

}

From source file:edu.ku.brc.specify.config.init.SpecifyDBSetupWizardFrame.java

/**
 * @param args//from ww  w . j a  va2  s . c om
 */
public static void main(String[] args) {
    // Set App Name, MUST be done very first thing!
    UIRegistry.setAppName("Specify"); //$NON-NLS-1$

    try {
        ResourceBundle.getBundle("resources", Locale.getDefault()); //$NON-NLS-1$

    } catch (MissingResourceException ex) {
        Locale.setDefault(Locale.ENGLISH);
        UIRegistry.setResourceLocale(Locale.ENGLISH);
    }

    try {
        if (!System.getProperty("os.name").equals("Mac OS X")) {
            UIManager.setLookAndFeel(new Plastic3DLookAndFeel());
            PlasticLookAndFeel.setPlasticTheme(new DesertBlue());
        }
    } catch (Exception e) {
        edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(SpecifyDBSetupWizard.class, e);
        e.printStackTrace();
    }

    AppBase.processArgs(args);
    AppBase.setupTeeForStdErrStdOut(true, false);

    System.setProperty("appdatadir", "..");

    // Then set this
    IconManager.setApplicationClass(Specify.class);
    IconManager.loadIcons(XMLHelper.getConfigDir("icons_datamodel.xml")); //$NON-NLS-1$
    IconManager.loadIcons(XMLHelper.getConfigDir("icons_plugins.xml")); //$NON-NLS-1$
    IconManager.loadIcons(XMLHelper.getConfigDir("icons_disciplines.xml")); //$NON-NLS-1$

    // Load Local Prefs
    AppPreferences localPrefs = AppPreferences.getLocalPrefs();
    //try {
    //System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> "+(new File(UIRegistry.getAppDataDir()).getCanonicalPath())+"]");
    //} catch (IOException ex) {}

    localPrefs.setDirPath(UIRegistry.getAppDataDir());

    // Check to see if we should check for a new version
    if (localPrefs.getBoolean(VERSION_CHECK, null) == null) {
        localPrefs.putBoolean(VERSION_CHECK, true);
    }

    if (localPrefs.getBoolean(EXTRA_CHECK, null) == null) {
        localPrefs.putBoolean(EXTRA_CHECK, true);
    }

    if (UIHelper.isLinux()) {
        Specify.checkForSpecifyAppsRunning();
    }

    if (UIRegistry.isEmbedded()) {
        ProcessListUtil.checkForMySQLProcesses(new ProcessListener() {
            @Override
            public void done(PROC_STATUS status) // called on the UI thread
            {
                if (status == PROC_STATUS.eOK || status == PROC_STATUS.eFoundAndKilled) {
                    startupContinuing();
                }
            }
        });
    } else {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                startupContinuing();
            }
        });
    }
}

From source file:com.clustercontrol.winservice.util.RequestWinRM.java

/**
 * /*ww w .jav a2  s  .  c  om*/
 * @param args
 */
public static void main(String[] args) {
    try {
        RequestWinRM winRM = new RequestWinRM("SNMP");
        winRM.polling("172.26.98.119", "Administrator", "Hinemos24", 5985, "http", 3000, 5);

        System.out.println("MSG = " + winRM.getMessage());
        System.out.println("MSG_ORG = " + winRM.getMessageOrg());

        System.out.println(System.getProperty("javax.xml.transform.TransformerFactory"));

    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    }
}

From source file:com.hpe.nv.samples.basic.BasicAnalyze2Scenarios.java

public static void main(String[] args) {
    try {/*  w  ww .j av a  2s .co m*/
        // program arguments
        Options options = new Options();
        options.addOption("i", "server-ip", true, "[mandatory] NV Test Manager IP");
        options.addOption("o", "server-port", true, "[mandatory] NV Test Manager port");
        options.addOption("u", "username", true, "[mandatory] NV username");
        options.addOption("w", "password", true, "[mandatory] NV password");
        options.addOption("e", "ssl", true, "[optional] Pass true to use SSL. Default: false");
        options.addOption("y", "proxy", true, "[optional] Proxy server host:port");
        options.addOption("a", "active-adapter-ip", true,
                "[optional] Active adapter IP. Default: --server-ip argument");
        options.addOption("z", "zip-result-file-path", true,
                "[optional] File path to store the analysis results as a .zip file");
        options.addOption("k", "analysis-ports", true,
                "[optional] A comma-separated list of ports for test analysis");
        options.addOption("b", "browser", true,
                "[optional] The browser for which the Selenium WebDriver is built. Possible values: Chrome and Firefox. Default: Firefox");
        options.addOption("d", "debug", true,
                "[optional] Pass true to view console debug messages during execution. Default: false");
        options.addOption("h", "help", false, "[optional] Generates and prints help information");

        // parse and validate the command line arguments
        CommandLineParser parser = new DefaultParser();
        CommandLine line = parser.parse(options, args);

        if (line.hasOption("help")) {
            // print help if help argument is passed
            HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp("BasicAnalyze2Scenarios.java", options);
            return;
        }

        if (line.hasOption("server-ip")) {
            serverIp = line.getOptionValue("server-ip");
            if (serverIp.equals("0.0.0.0")) {
                throw new Exception(
                        "Please replace the server IP argument value (0.0.0.0) with your NV Test Manager IP");
            }
        } else {
            throw new Exception("Missing argument -i/--server-ip <serverIp>");
        }

        if (line.hasOption("server-port")) {
            serverPort = Integer.parseInt(line.getOptionValue("server-port"));
        } else {
            throw new Exception("Missing argument -o/--server-port <serverPort>");
        }

        if (line.hasOption("username")) {
            username = line.getOptionValue("username");
        } else {
            throw new Exception("Missing argument -u/--username <username>");
        }

        if (line.hasOption("password")) {
            password = line.getOptionValue("password");
        } else {
            throw new Exception("Missing argument -w/--password <password>");
        }

        if (line.hasOption("ssl")) {
            ssl = Boolean.parseBoolean(line.getOptionValue("ssl"));
        }

        if (line.hasOption("zip-result-file-path")) {
            zipResultFilePath = line.getOptionValue("zip-result-file-path");
        }

        if (line.hasOption("proxy")) {
            proxySetting = line.getOptionValue("proxy");
        }

        if (line.hasOption("active-adapter-ip")) {
            activeAdapterIp = line.getOptionValue("active-adapter-ip");
        } else {
            activeAdapterIp = serverIp;
        }

        if (line.hasOption("analysis-ports")) {
            String analysisPortsStr = line.getOptionValue("analysis-ports");
            analysisPorts = analysisPortsStr.split(",");
        } else {
            analysisPorts = new String[] { "80", "8080" };
        }

        if (line.hasOption("browser")) {
            browser = line.getOptionValue("browser");
        } else {
            browser = "Firefox";
        }

        if (line.hasOption("debug")) {
            debug = Boolean.parseBoolean(line.getOptionValue("debug"));
        }

        String newLine = System.getProperty("line.separator");
        String testDescription = "***   This sample demonstrates a comparison between two network scenarios - \"WiFi\" and \"3G Busy\".                                 ***"
                + newLine
                + "***                                                                                                                               ***"
                + newLine
                + "***   In this sample, the NV test starts with the \"WiFi\" network scenario, running three transactions (see below).                ***"
                + newLine
                + "***   Then, the sample updates the NV test's network scenario to \"3G Busy\" using the real-time update API and runs the same       ***"
                + newLine
                + "***   transactions again.                                                                                                         ***"
                + newLine
                + "***                                                                                                                               ***"
                + newLine
                + "***   After the sample analyzes the NV test and extracts the transaction times from the analysis results, it prints a             ***"
                + newLine
                + "***   summary to the console. The summary displays the comparative network times for each transaction in both                     ***"
                + newLine
                + "***   network scenarios.                                                                                                          ***"
                + newLine
                + "***                                                                                                                               ***"
                + newLine
                + "***   This sample runs three identical NV transactions before and after the real-time update:                                     ***"
                + newLine
                + "***   1. \"Home Page\" transaction: Navigates to the home page in the HPE Network Virtualization website                            ***"
                + newLine
                + "***   2. \"Get Started\" transaction: Navigates to the Get Started Now page in the HPE Network Virtualization website               ***"
                + newLine
                + "***   3. \"Overview\" transaction: Navigates back to the home page in the HPE Network Virtualization website                        ***"
                + newLine
                + "***                                                                                                                               ***"
                + newLine
                + "***   You can view the actual steps of this sample in the BasicAnalyze2Scenarios.java file.                                       ***"
                + newLine;

        // print the sample's description
        System.out.println(testDescription);

        // start console spinner
        if (!debug) {
            spinner = new Thread(new Spinner());
            spinner.start();
        }

        // sample execution steps
        /*****    Part 1 - Start the NV test with the "WiFi" network scenario                                                                      *****/
        printPartDescription("\b------    Part 1 - Start the NV test with the \"WiFi\" network scenario");
        initTestManager();
        setActiveAdapter();
        startTest();
        testRunning = true;
        printPartSeparator();
        /*****    Part 2 - Run three transactions - "Home Page", "Get Started" and "Overview"                                                      *****/
        printPartDescription(
                "------    Part 2 - Run three transactions - \"Home Page\", \"Get Started\" and \"Overview\"");
        connectToTransactionManager();
        startTransaction(1);
        transactionInProgress = true;
        buildSeleniumWebDriver();
        seleniumNavigateToPage();
        stopTransaction(1);
        transactionInProgress = false;
        startTransaction(2);
        transactionInProgress = true;
        seleniumGetStartedClick();
        stopTransaction(2);
        transactionInProgress = false;
        startTransaction(3);
        transactionInProgress = true;
        seleniumOverviewClick();
        stopTransaction(3);
        transactionInProgress = false;
        driverCloseAndQuit();
        printPartSeparator();
        /*****    Part 3 - Update the NV test in real time to the "3G Busy" network scenario                                                     *****/
        printPartDescription(
                "------    Part 3 - Update the NV test in real time to the \"3G Busy\" network scenario");
        realTimeUpdateTest();
        printPartSeparator();
        /*****    Part 4 - Rerun the transactions                                                                                                *****/
        printPartDescription("------    Part 4 - Rerun the transactions");
        startTransactionAfterRTU(1);
        transactionInProgress = true;
        buildSeleniumWebDriver();
        seleniumNavigateToPage();
        stopTransaction(1);
        transactionInProgress = false;
        startTransactionAfterRTU(2);
        transactionInProgress = true;
        seleniumGetStartedClick();
        stopTransaction(2);
        transactionInProgress = false;
        startTransactionAfterRTU(3);
        transactionInProgress = true;
        seleniumOverviewClick();
        stopTransaction(3);
        transactionInProgress = false;
        driverCloseAndQuit();
        printPartSeparator();
        /*****    Part 5 - Stop the NV test, analyze it and print the results to the console                                                                *****/
        printPartDescription(
                "------    Part 5 - Stop the NV test, analyze it and print the results to the console");
        stopTest();
        testRunning = false;
        analyzeTestZip();
        analyzeTestJson();
        printPartSeparator();
        doneCallback();
    } catch (Exception e) {
        try {
            handleError(e.getMessage());
        } catch (Exception e2) {
            System.out.println("Error occurred: " + e2.getMessage());
        }
    }
}

From source file:gsn.tests.performance.Queries.java

public static void main(String[] args) {
    Queries queries = new Queries(Integer.parseInt(System.getProperty("nbQueries")),
            Integer.parseInt(System.getProperty("nbThreads")));
    ////from  w ww . j  a  v a  2  s . c  o m
    String op; // optional parameter
    if ((op = System.getProperty("maxQuerySize")) != null)
        queries.setMaxQuerySize(Integer.parseInt(op));
    if ((op = System.getProperty("gsnUrl")) != null)
        queries.setGsnUrl(op);
    //
    queries.updateListOfVirtualSensors();
    //
    queries.runQueries();

}

From source file:com.twosigma.beaker.core.Main.java

public static void main(String[] args) throws Exception {
    CommandLine options = parseCommandLine(args);

    final Integer portBase = options.hasOption("port-base")
            ? Integer.parseInt(options.getOptionValue("port-base"))
            : findPortBase(PORT_BASE_START_DEFAULT);
    final Boolean useKerberos = options.hasOption("disable-kerberos")
            ? !parseBoolean(options.getOptionValue("disable-kerberos"))
            : USE_KERBEROS_DEFAULT;//w  ww .  j av a 2 s. c  om
    final Boolean openBrowser = options.hasOption("open-browser")
            ? parseBoolean(options.getOptionValue("open-browser"))
            : OPEN_BROWSER_DEFAULT;
    final String useHttpsCert = options.hasOption("use-ssl-cert") ? options.getOptionValue("use-ssl-cert")
            : null;
    final String useHttpsKey = options.hasOption("use-ssl-key") ? options.getOptionValue("use-ssl-key") : null;
    final Boolean publicServer = options.hasOption("public-server");
    final Boolean requirePassword = options.hasOption("require-password");
    final String password = options.hasOption("password") ? options.getOptionValue("password") : null;
    final String listenInterface = options.hasOption("listen-interface")
            ? options.getOptionValue("listen-interface")
            : null;
    final Boolean portable = options.hasOption("portable");
    final Boolean showZombieLogging = options.hasOption("show-zombie-logging");

    // create preferences for beaker core from cli options and others
    // to be used by BeakerCoreConfigModule to initialize its config
    BeakerConfigPref beakerCorePref = createBeakerCoreConfigPref(useKerberos, publicServer, false, portBase,
            options.getOptionValue("default-notebook"), getPluginOptions(options), useHttpsCert, useHttpsKey,
            requirePassword, password, listenInterface, portable, showZombieLogging);

    WebAppConfigPref webAppPref = createWebAppConfigPref(portBase + BEAKER_SERVER_PORT_OFFSET,
            System.getProperty("user.dir") + "/src/main/web");

    Injector injector = Guice.createInjector(new DefaultBeakerConfigModule(beakerCorePref),
            new DefaultWebServerConfigModule(webAppPref), new GeneralUtilsModule(), new WebServerModule(),
            new SerializerModule(), new GuiceCometdModule(), new URLConfigModule(beakerCorePref));

    PluginServiceLocatorRest processStarter = injector.getInstance(PluginServiceLocatorRest.class);
    processStarter.setAuthToken(beakerCorePref.getAuthToken());
    processStarter.start();

    BeakerConfig bkConfig = injector.getInstance(BeakerConfig.class);

    writePID(bkConfig);

    Server server = injector.getInstance(Server.class);
    server.start();

    // openBrower and show connection instruction message
    final String initUrl = bkConfig.getBaseURL();
    if (openBrowser) {
        injector.getInstance(GeneralUtils.class).openUrl(initUrl);
        System.out.println("\nConnecting to " + initUrl);
    } else {
        System.out.println("\nBeaker hash " + bkConfig.getHash());
        System.out.println("Beaker listening on " + initUrl);
    }
    if (publicServer && StringUtils.isEmpty(password)) {
        System.out.println("Submit this password: " + bkConfig.getPassword());
    }
    System.out.println("");
}

From source file:Main.java

static boolean isOSX() {
    return System.getProperty("mrj.version") != null;
}

From source file:alluxio.cli.JournalCrashTest.java

/**
 * Runs the crash test.//from  www  .  j  a v a2  s . c om
 *
 * @param args no arguments
 */
public static void main(String[] args) {
    // Parse the input args.
    if (!parseInputArgs(args)) {
        System.exit(EXIT_FAILED);
    }

    System.out.println("Stop the current Alluxio cluster...");
    stopCluster();

    // Set NO_STORE and NO_PERSIST so that this test can work without AlluxioWorker.
    sCreateFileOptions = CreateFileOptions.defaults().setWriteType(WriteType.NONE);
    // Set the max retry to avoid long pending for client disconnect.
    if (System.getProperty(PropertyKey.USER_RPC_RETRY_MAX_NUM_RETRY.toString()) == null) {
        System.setProperty(PropertyKey.USER_RPC_RETRY_MAX_NUM_RETRY.toString(), "10");
    }

    System.out.println("Start Journal Crash Test...");
    long startTimeMs = System.currentTimeMillis();
    boolean ret = true;
    startMaster();

    int rounds = 0;
    while (System.currentTimeMillis() - startTimeMs < sTotalTimeMs) {
        rounds++;
        long aliveTimeMs = (long) (Math.random() * sMaxAliveTimeMs) + 100;
        LOG.info("Round {}: Planning Master Alive Time {}ms.", rounds, aliveTimeMs);

        System.out.println("Round " + rounds + " : Launch Clients...");
        sFileSystem = FileSystem.Factory.get();
        try {
            sFileSystem.delete(new AlluxioURI(sTestDir));
        } catch (Exception e) {
            // Test Directory not exist
        }

        // Launch all the client threads.
        setupClientThreads();
        for (Thread thread : sClientThreadList) {
            thread.start();
        }

        CommonUtils.sleepMs(LOG, aliveTimeMs);
        System.out.println("Round " + rounds + " : Crash Master...");
        killMaster();
        for (ClientThread clientThread : sClientThreadList) {
            clientThread.setIsStopped(true);
        }
        for (Thread thread : sClientThreadList) {
            try {
                thread.join();
            } catch (InterruptedException e) {
                LOG.error("Error when waiting thread", e);
            }
        }

        System.out.println("Round " + rounds + " : Check Status...");
        startMaster();
        boolean checkSuccess = false;
        try {
            checkSuccess = checkStatus();
        } catch (Exception e) {
            LOG.error("Failed to check status", e);
        }
        CliUtils.printPassInfo(checkSuccess);
        ret &= checkSuccess;
    }

    stopCluster();
    System.exit(ret ? EXIT_SUCCESS : EXIT_FAILED);
}

From source file:Main.java

public static String systemEol() {
    return System.getProperty("line.separator");
}