pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] zhaijack commented on a change in pull request #961: Issue 922: allow run bookie together with broker
Date Thu, 01 Jan 1970 00:00:00 GMT
zhaijack commented on a change in pull request #961: Issue 922: allow run bookie together with
broker
URL: https://github.com/apache/incubator-pulsar/pull/961#discussion_r156555016
 
 

 ##########
 File path: pulsar-broker/src/main/java/org/apache/pulsar/PulsarBrokerStarter.java
 ##########
 @@ -44,8 +55,79 @@ private static ServiceConfiguration loadConfig(String configFile) throws
Excepti
         return config;
     }
 
+    private static final Options OPTS = new Options();
+    static {
+        OPTS.addOption("b", "bookie", false, "Run Bookie Server together");
+        OPTS.addOption("a", "bookieautorecovery", false, "Run Bookie Auto Recovery together");
+        OPTS.addOption("c", "bookieconf", true, "Configuration file for Bookie");
+        OPTS.addOption("h", "help", false, "Print help message");
+    }
+
+    /**
+     * Print usage.
+     */
+    private static void printUsage() {
+        HelpFormatter hf = new HelpFormatter();
+        String header = "\n"
+            + "PulsarBrokerStarter is a command to start Pulsar Broker. \n"
+            + "User could use option to choose starting bookie together with broker or not.\n\n";
+        String footer = "\nHere is an example:\n"
+            + "\tPulsarBrokerStarter broker.conf --runbookie --runbookierecovery --bookieconf
bookkeeper.conf\n\n ";
+        hf.printHelp("PulsarBrokerStarter <pulsar_config_file>  ", header, OPTS, footer,
true);
+    }
+
+    private static CommandLine readCommandLine(String[] args) throws ParseException {
+        BasicParser parser = new BasicParser();
+        return parser.parse(OPTS, args);
+    }
+
+    private static boolean runBookieTogether(CommandLine cmdLine) throws IllegalArgumentException
{
+        if (cmdLine.hasOption('b') && cmdLine.hasOption('c')) {
+            return true;
+        } else if(cmdLine.hasOption('b')) {
+            printUsage();
+            throw new IllegalArgumentException("No configuration file for bookie");
+        } else {
+            return false;
+        }
+    }
+
+    private static boolean runBookieAutoRecoveryTogether(CommandLine cmdLine) throws IllegalArgumentException
{
+        if (cmdLine.hasOption('a') && cmdLine.hasOption('c')) {
+            return true;
+        } else if(cmdLine.hasOption('a')) {
+            printUsage();
+            throw new IllegalArgumentException("No configuration file for bookie auto recovery");
+        } else {
+            return false;
+        }
+    }
+
+    private static ServerConfiguration readBookieConfFile(CommandLine cmdLine) throws IllegalArgumentException
{
+        if (!cmdLine.hasOption('c')) {
+            throw new IllegalArgumentException("No configuration file");
+        }
+
+        String bookieConfigFile = cmdLine.getOptionValue("c");
+        ServerConfiguration bookieConf = new ServerConfiguration();
+        try {
+            bookieConf.loadConf(new File(bookieConfigFile).toURI().toURL());
+            bookieConf.validate();
+            log.info("Using bookie configuration file {}", bookieConfigFile);
+        } catch (MalformedURLException e) {
+            log.error("Could not open configuration file: {}", bookieConfigFile, e);
+            throw new IllegalArgumentException();
 
 Review comment:
   Thanks, will change it.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message