Example #1
0
        private void PrintHelpMessage(Options options)
        {
            System.Console.Out.WriteLine("Retrieve logs for completed YARN applications.");
            HelpFormatter formatter = new HelpFormatter();

            formatter.PrintHelp("yarn logs -applicationId <application ID> [OPTIONS]", new Options
                                    ());
            formatter.SetSyntaxPrefix(string.Empty);
            formatter.PrintHelp("general options are:", options);
        }
Example #2
0
        /// <summary>
        /// Print the help
        /// </summary>
        public void PrintHelp()
        {
            HelpFormatter formatter = new HelpFormatter();
            string        appName   = this.appName == null ? "App" : this.appName;

            formatter.PrintHelp(appName, this.rules);
        }
Example #3
0
        /// <summary>
        /// Prints this application's usage and help text to StdOut.
        /// </summary>
        private static void PrintUsageAndHelp()
        {
            var hf = new HelpFormatter();

            hf.PrintHelp(
                Assembly.GetExecutingAssembly().GetName().Name,
                Opts,
                true);
        }
Example #4
0
            internal virtual void Usage()
            {
                string header = "The Secondary NameNode is a helper " + "to the primary NameNode. The Secondary is responsible "
                                + "for supporting periodic checkpoints of the HDFS metadata. " + "The current design allows only one Secondary NameNode "
                                + "per HDFS cluster.";
                HelpFormatter formatter = new HelpFormatter();

                formatter.PrintHelp("secondarynamenode", header, options, string.Empty, false);
            }
Example #5
0
        public static void Main(string[] args)
        {
            try
            {
                System.Console.Out.WriteLine("khubla.com Paradox DB reader");

                /*
                 * options
                 */
                Options options = new Options();
                Option  oo      = Option.Builder().ArgName(FileOption).LongOpt(FileOption).Type(Sharpen.Runtime.GetClassForType
                                                                                                    (typeof(string))).HasArg().Required(true).Desc("file to read").Build();
                options.AddOption(oo);

                /*
                 * parse
                 */
                CommandLineParser parser = new DefaultParser();
                CommandLine       cmd    = null;
                try
                {
                    cmd = parser.Parse(options, args);
                }
                catch (Exception e)
                {
                    Sharpen.Runtime.PrintStackTrace(e);
                    HelpFormatter formatter = new HelpFormatter();
                    formatter.PrintHelp("posix", options);
                    System.Environment.Exit(0);
                }

                /*
                 * get file
                 */
                string filename = cmd.GetOptionValue(FileOption);
                if (null != filename)
                {
                    File inputFile = new File(filename);
                    if (inputFile.Exists())
                    {
                        DBTableFile       pdxFile           = new DBTableFile();
                        PDXReaderListener pdxReaderListener = new PDXReaderCSVListenerImpl();
                        pdxFile.Read(inputFile, pdxReaderListener);
                        System.Console.Out.WriteLine("done");
                    }
                }
            }
            catch (Exception e)
            {
                Sharpen.Runtime.PrintStackTrace(e);
            }
        }
Example #6
0
 /// <summary>Outputs the formatted help to standard out</summary>
 internal virtual void OutputHelp()
 {
     if (!ShouldOutputHelp())
     {
         return;
     }
     if (source != null)
     {
         HelpFormatter hlp = new HelpFormatter();
         hlp.PrintHelp(Constants.ProgName + " " + Constants.ProgVersion, source.GetOptionList
                           ());
     }
 }
Example #7
0
        private void ShowHelp()
        {
            var helpFormatter = new HelpFormatter();
            var sb            = new System.Text.StringBuilder();

            sb.AppendLine("Several servers can be passed.");
            sb.AppendLine("Example:");
            sb.AppendLine("Running for one hour (60 minutes) and using COM-Port 'COM3'");
            sb.AppendLine("The used server is 192.168.1.12:8080, user: '******' and password: '******':");
            sb.AppendLine(String.Format("TeamCityWatcher -{0} 60 -{1} COM3", RunTime, Port));
            sb.AppendLine(String.Format("-{0} 192.168.1.12:8080,admin,adminadmin", Server));
            helpFormatter.PrintHelp("TeamCityWatcher", "Parameters for the TeamCityWatcher", _options, sb.ToString());
            Environment.Exit(1);
        }
        /// <summary>
        /// Parse the user-specified options, get the generic options, and modify
        /// configuration accordingly
        /// </summary>
        /// <param name="opts">Options to use for parsing args.</param>
        /// <param name="conf">Configuration to be modified</param>
        /// <param name="args">User-specified arguments</param>
        /// <exception cref="System.IO.IOException"/>
        private void ParseGeneralOptions(Options opts, Configuration conf, string[] args)
        {
            opts = BuildGeneralOptions(opts);
            CommandLineParser parser = new GnuParser();

            try
            {
                commandLine = parser.Parse(opts, PreProcessForWindows(args), true);
                ProcessGeneralOptions(conf, commandLine);
            }
            catch (ParseException e)
            {
                Log.Warn("options parsing failed: " + e.Message);
                HelpFormatter formatter = new HelpFormatter();
                formatter.PrintHelp("general options are: ", opts);
            }
        }
 /// <summary>
 /// Print the help
 /// </summary>
 public void PrintHelp() 
 {
     HelpFormatter formatter = new HelpFormatter();
     string appName = this.appName == null ? "App" : this.appName;
     formatter.PrintHelp(appName, this.rules);
 }
Example #10
0
        /// <summary>Print JMXGet usage information</summary>
        internal static void PrintUsage(Options opts)
        {
            HelpFormatter formatter = new HelpFormatter();

            formatter.PrintHelp("jmxget options are: ", opts);
        }
Example #11
0
 /// <exception cref="Org.Apache.Commons.Cli.ParseException"/>
 private void ProcessOptions(CommandLine line, Options opts)
 {
     if (line.HasOption("help") || line.HasOption('?'))
     {
         HelpFormatter formatter = new HelpFormatter();
         System.Console.Out.WriteLine("Protobuf IPC benchmark.");
         System.Console.Out.WriteLine();
         formatter.PrintHelp(100, "java ... PBRPCBenchmark [options]", "\nSupported options:"
                             , opts, string.Empty);
         return;
     }
     if (line.HasOption('s'))
     {
         serverThreads = System.Convert.ToInt32(line.GetOptionValue('s'));
     }
     if (line.HasOption('r'))
     {
         serverReaderThreads = System.Convert.ToInt32(line.GetOptionValue('r'));
     }
     if (line.HasOption('c'))
     {
         clientThreads = System.Convert.ToInt32(line.GetOptionValue('c'));
     }
     if (line.HasOption('t'))
     {
         secondsToRun = System.Convert.ToInt32(line.GetOptionValue('t'));
     }
     if (line.HasOption('m'))
     {
         msgSize = System.Convert.ToInt32(line.GetOptionValue('m'));
     }
     if (line.HasOption('p'))
     {
         port = System.Convert.ToInt32(line.GetOptionValue('p'));
     }
     if (line.HasOption('h'))
     {
         host = line.GetOptionValue('h');
     }
     if (line.HasOption('e'))
     {
         string eng = line.GetOptionValue('e');
         if ("protobuf".Equals(eng))
         {
             rpcEngine = typeof(ProtobufRpcEngine);
         }
         else
         {
             if ("writable".Equals(eng))
             {
                 rpcEngine = typeof(WritableRpcEngine);
             }
             else
             {
                 throw new ParseException("invalid engine: " + eng);
             }
         }
     }
     string[] remainingArgs = line.GetArgs();
     if (remainingArgs.Length != 0)
     {
         throw new ParseException("Extra arguments: " + Joiner.On(" ").Join(remainingArgs)
                                  );
     }
 }
Example #12
0
        static void Main(string[] arguments)
        {
            ICommandLineParser commandLineParser = new PosixParser();
            CommandLine        commandLine       = commandLineParser.Parse(Options, arguments);

            int port = SocketOpenOfficeConnection.DefaultPort;

            if (commandLine.HasOption(OptionPort.Opt))
            {
                port = Convert.ToInt32(commandLine.GetOptionValue(OptionPort.Opt));
            }

            String outputFormat = null;

            if (commandLine.HasOption(OptionOutputFormat.Opt))
            {
                outputFormat = commandLine.GetOptionValue(OptionOutputFormat.Opt);
            }

            bool verbose = commandLine.HasOption(OptionVerbose.Opt);

            IDocumentFormatRegistry registry = new DefaultDocumentFormatRegistry();

            String[] fileNames = commandLine.Args;
            if ((outputFormat == null && fileNames.Length != 2) || fileNames.Length < 1)
            {
                String        syntax        = "Convert [options] input-file output-file; or\n" + "[options] -f output-format input-file [input-file...]";
                HelpFormatter helpFormatter = new HelpFormatter();
                helpFormatter.PrintHelp(syntax, Options);
                Environment.Exit(ExitCodeTooFewArgs);
            }

            IOpenOfficeConnection connection = new SocketOpenOfficeConnection(port);
            OfficeInfo            oo         = EnvUtils.Get();

            if (oo.Kind == OfficeKind.Unknown)
            {
                Console.Out.WriteLine("please setup OpenOffice or LibreOffice!");
                return;
            }
            try
            {
                if (verbose)
                {
                    Console.Out.WriteLine("-- connecting to OpenOffice.org on port " + port);
                }
                connection.Connect();
            }
            catch (Exception)
            {
                string CmdArguments = string.Format("-headless -accept=\"socket,host={0},port={1};urp;\" -nofirststartwizard", SocketOpenOfficeConnection.DefaultHost, SocketOpenOfficeConnection.DefaultPort);
                if (!EnvUtils.RunCmd(oo.OfficeUnoPath, "soffice", CmdArguments))
                {
                    Console.Error.WriteLine("ERROR: connection failed. Please make sure OpenOffice.org is running and listening on port " + port + ".");
                    Environment.Exit(ExitCodeConnectionFailed);
                }
            }
            try
            {
                IDocumentConverter converter = new OpenOfficeDocumentConverter(connection, registry);
                if (outputFormat == null)
                {
                    FileInfo inputFile  = new FileInfo(fileNames[0]);
                    FileInfo outputFile = new FileInfo(fileNames[1]);
                    ConvertOne(converter, inputFile, outputFile, verbose);
                }
                else
                {
                    foreach (var t in fileNames)
                    {
                        var inputFile  = new FileInfo(t);
                        var outputFile = new FileInfo(inputFile.FullName.Remove(inputFile.FullName.LastIndexOf(".", StringComparison.Ordinal)) + "." + outputFormat);
                        ConvertOne(converter, inputFile, outputFile, verbose);
                    }
                }
            }
            finally
            {
                if (verbose)
                {
                    Console.Out.WriteLine("-- disconnecting");
                }
                connection.Disconnect();
            }
        }
Example #13
0
        public static int Main(string[] args)
        {
            string netConfig = null;
            string hostArg = null, portArg = null;

            StringWriter wout = new StringWriter();
            Options options = GetOptions();

            CommandLine commandLine = null;

            bool failed = false;
            bool isService = false;

            try {
                ICommandLineParser parser = new GnuParser(options);
                commandLine = parser.Parse(args);

                netConfig = commandLine.GetOptionValue("netconfig", "./network.conf");
                hostArg = commandLine.GetOptionValue("host");
                portArg = commandLine.GetOptionValue("port");
            } catch (ParseException) {
                wout.WriteLine("Error parsing arguments.");
                failed = true;
            }

            if (commandLine != null) {
                if (commandLine.HasOption("install")) {
                    try {
                        Install(commandLine);
                        Console.Out.WriteLine("Service installed succesfully.");
                        return 0;
                    } catch (Exception e) {
                        Console.Error.WriteLine("Error installing service: " + e.Message);
            #if DEBUG
                        Console.Error.WriteLine(e.StackTrace);
            #endif
                        return 1;
                    }
                }
                if (commandLine.HasOption("uninstall")) {
                    try {
                        Uninstall();
                        Console.Out.WriteLine("Service uninstalled succesfully.");
                        return 0;
                    } catch (Exception e) {
                        Console.Error.WriteLine("Error uninstalling service: " + e.Message);
            #if DEBUG
                        Console.Error.WriteLine(e.StackTrace);
            #endif
                        return 1;
                    }
                }

                isService = commandLine.HasOption("service");
            }

            if (isService) {
                CloudBClientService clientService = new CloudBClientService(commandLine);

                try {
                    if (Environment.UserInteractive) {
                        clientService.Start(args);
                        Console.Out.WriteLine("Press any key to stop...");
                        Console.Read();
                        clientService.Stop();
                    } else {
                        ServiceBase.Run(clientService);
                    }
                } catch (Exception) {
                    return 1;
                }

                return 0;
            }

            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(OnUnhandledException);
            SetEventHandlers();

            ProductInfo libInfo = ProductInfo.GetProductInfo(typeof(PathClientService));
            ProductInfo nodeInfo = ProductInfo.GetProductInfo(typeof(PathClient));

            Console.Out.WriteLine("{0} {1} ( {2} )", nodeInfo.Title, nodeInfo.Version, nodeInfo.Copyright);
            Console.Out.WriteLine(nodeInfo.Description);
            Console.Out.WriteLine();
            Console.Out.WriteLine("{0} {1} ( {2} )", libInfo.Title, libInfo.Version, libInfo.Copyright);

            // Check arguments that can be null,
            if (netConfig == null) {
                wout.WriteLine("Error, no network configuration given.");
                failed = true;
            }

            if (portArg == null) {
                wout.WriteLine("Error, no port address given.");
                failed = true;
            }

            if (!failed) {
                //TODO: support for remote (eg. HTTP, FTP, TCP/IP) configurations)

                netConfig = NormalizeFilePath(netConfig);

                if (!File.Exists(netConfig)) {
                    wout.WriteLine("Error, node configuration file not found ({0}).", netConfig);
                    failed = true;
                }
            }

            wout.Flush();

            // If failed,
            if (failed) {
                HelpFormatter formatter = new HelpFormatter();
                if (!IsConsoleRedirected()) {
                    formatter.Width = Console.WindowWidth;
                }
                formatter.CommandLineSyntax = "mnode";
                formatter.Options = options;
                formatter.PrintHelp();
                Console.Out.WriteLine();
                Console.Out.WriteLine(wout.ToString());
                return 1;
            }

            try {
            #if DEBUG
                Console.Out.WriteLine("Retrieving network configuration from {0}", netConfig);
            #endif

                // Parse the network configuration string,
                NetworkConfigSource netConfigSource;
                using (FileStream stream = new FileStream(netConfig, FileMode.Open, FileAccess.Read, FileShare.None)) {
                    netConfigSource = new NetworkConfigSource();
                    //TODO: make it configurable ...
                    netConfigSource.LoadProperties(stream);
                }

                //TODO: support also IPv6

                // The base path,
                IPAddress host = null;
                if (hostArg != null) {
                    IPAddress[] addresses = Dns.GetHostAddresses(hostArg);
                    for (int i = 0; i < addresses.Length; i++) {
                        IPAddress address = addresses[i];
                        if (address.AddressFamily == AddressFamily.InterNetwork) {
                            host = address;
                            break;
                        }
                    }
                } else {
                    host = IPAddress.Loopback;
                }

                if (host == null) {
                    Console.Out.WriteLine("Error: couldn't determine the host address.");
                    return 1;
                }

                int port;
                if (!Int32.TryParse(portArg, out port)) {
                    Console.Out.WriteLine("Error: couldn't parse port argument: " + portArg);
                    return 1;
                }

                string storage = commandLine.GetOptionValue("storage", null);

                Console.Out.WriteLine("Path Client Service, " + host + " : " + port);
                //TODO:
                service = new TcpPathClientService(null, null, null);
                service.Init();

                waitHandle = new AutoResetEvent(false);
                waitHandle.WaitOne();
            } catch (Exception e) {
                Console.Out.WriteLine(e.Message);
                Console.Out.WriteLine(e.StackTrace);
                return 1;
            } finally {
                if (service != null)
                    service.Dispose();
            }

            return 0;
        }
Example #14
0
 /// <summary>
 /// Prints this application's usage and help text to StdOut.
 /// </summary>
 private static void PrintUsageAndHelp()
 {
     var hf = new HelpFormatter();
     hf.PrintHelp(
         Assembly.GetExecutingAssembly().GetName().Name,
         Opts,
         true);
 }
 private void ShowHelp()
 {
     var helpFormatter = new HelpFormatter();
     var sb = new System.Text.StringBuilder();
     sb.AppendLine("Several servers can be passed.");
     sb.AppendLine("Example:");
     sb.AppendLine("Running for one hour (60 minutes) and using COM-Port 'COM3'");
     sb.AppendLine("The used server is 192.168.1.12:8080, user: '******' and password: '******':");
     sb.AppendLine(String.Format("TeamCityWatcher -{0} 60 -{1} COM3", RunTime, Port));
     sb.AppendLine(String.Format("-{0} 192.168.1.12:8080,admin,adminadmin", Server));
     helpFormatter.PrintHelp("TeamCityWatcher", "Parameters for the TeamCityWatcher", _options, sb.ToString());
     Environment.Exit(1);
 }
Example #16
0
        public void Man()
        {
            String cmdLine =
                    "man [-c|-f|-k|-w|-tZT device] [-adlhu7V] [-Mpath] [-Ppager] [-Slist] " +
                            "[-msystem] [-pstring] [-Llocale] [-eextension] [section] page ...";
            Options options = new Options().
                    AddOption("a", "all", false, "find all matching manual pages.").
                    AddOption("d", "debug", false, "emit debugging messages.").
                    AddOption("e", "extension", false, "limit search to extension type 'extension'.").
                    AddOption("f", "whatis", false, "equivalent to whatis.").
                    AddOption("k", "apropos", false, "equivalent to apropos.").
                    AddOption("w", "location", false, "print physical location of man page(s).").
                    AddOption("l", "local-file", false, "interpret 'page' argument(s) as local filename(s)").
                    AddOption("u", "update", false, "force a cache consistency check.").
                //FIXME - should generate -r,--prompt string
                    AddOption("r", "prompt", true, "provide 'less' pager with prompt.").
                    AddOption("c", "catman", false, "used by catman to reformat out of date cat pages.").
                    AddOption("7", "ascii", false, "display ASCII translation or certain latin1 chars.").
                    AddOption("t", "troff", false, "use troff format pages.").
                //FIXME - should generate -T,--troff-device device
                    AddOption("T", "troff-device", true, "use groff with selected device.").
                    AddOption("Z", "ditroff", false, "use groff with selected device.").
                    AddOption("D", "default", false, "reset all options to their default values.").
                //FIXME - should generate -M,--manpath path
                    AddOption("M", "manpath", true, "set search path for manual pages to 'path'.").
                //FIXME - should generate -P,--pager pager
                    AddOption("P", "pager", true, "use program 'pager' to display output.").
                //FIXME - should generate -S,--sections list
                    AddOption("S", "sections", true, "use colon separated section list.").
                //FIXME - should generate -m,--systems system
                    AddOption("m", "systems", true, "search for man pages from other unix system(s).").
                //FIXME - should generate -L,--locale locale
                    AddOption("L", "locale", true, "define the locale for this particular man search.").
                //FIXME - should generate -p,--preprocessor string
                    AddOption("p", "preprocessor", true, "string indicates which preprocessor to run.\n" +
                             " e - [n]eqn  p - pic     t - tbl\n" +
                             " g - grap    r - refer   v - vgrind").
                    AddOption("V", "version", false, "show version.").
                    AddOption("h", "help", false, "show this usage message.");

            HelpFormatter hf = new HelpFormatter();
            hf.PrintHelp(options, new HelpSettings {CommandLineSyntax = cmdLine}, Console.Out, false);
        }
Example #17
0
        private static int Main(string[] args)
        {
            string nodeConfig = null, netConfig = null;
            string hostArg = null, portArg = null;

            StringWriter wout    = new StringWriter();
            Options      options = GetOptions();

            CommandLine commandLine = null;

            bool failed    = false;
            bool isService = false;

            try {
                ICommandLineParser parser = new GnuParser(options);
                commandLine = parser.Parse(args);

                nodeConfig = commandLine.GetOptionValue("nodeconfig", "./node.conf");
                netConfig  = commandLine.GetOptionValue("netconfig", "./network.conf");
                hostArg    = commandLine.GetOptionValue("host");
                portArg    = commandLine.GetOptionValue("port");
            } catch (ParseException) {
                wout.WriteLine("Error parsing arguments.");
                failed = true;
            }

            if (commandLine != null)
            {
                if (commandLine.HasOption("install"))
                {
                    try {
                        Install(commandLine);
                        Console.Out.WriteLine("Service installed succesfully.");
                        return(0);
                    } catch (Exception e) {
                        Console.Error.WriteLine("Error installing service: " + e.Message);
#if DEBUG
                        Console.Error.WriteLine(e.StackTrace);
#endif
                        return(1);
                    }
                }
                if (commandLine.HasOption("uninstall"))
                {
                    try {
                        Uninstall();
                        Console.Out.WriteLine("Service uninstalled succesfully.");
                        return(0);
                    } catch (Exception e) {
                        Console.Error.WriteLine("Error uninstalling service: " + e.Message);
#if DEBUG
                        Console.Error.WriteLine(e.StackTrace);
#endif
                        return(1);
                    }
                }

                isService = commandLine.HasOption("service");
            }

            if (isService)
            {
                MachineNodeService mnodeService = new MachineNodeService(commandLine);

                try {
                    if (Environment.UserInteractive)
                    {
                        mnodeService.Start(args);
                        Console.Out.WriteLine("Press any key to stop...");
                        Console.Read();
                        mnodeService.Stop();
                    }
                    else
                    {
                        ServiceBase.Run(mnodeService);
                    }
                } catch (Exception) {
                    return(1);
                }

                return(0);
            }

            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(OnUnhandledException);
            SetEventHandlers();

            ProductInfo libInfo  = ProductInfo.GetProductInfo(typeof(TcpAdminService));
            ProductInfo nodeInfo = ProductInfo.GetProductInfo(typeof(MachineNode));

            Console.Out.WriteLine("{0} {1} ( {2} )", nodeInfo.Title, nodeInfo.Version, nodeInfo.Copyright);
            Console.Out.WriteLine(nodeInfo.Description);
            Console.Out.WriteLine();
            Console.Out.WriteLine("{0} {1} ( {2} )", libInfo.Title, libInfo.Version, libInfo.Copyright);

            // Check arguments that can be null,
            if (netConfig == null)
            {
                wout.WriteLine("Error, no network configuration given.");
                failed = true;
            }
            else if (nodeConfig == null)
            {
                wout.WriteLine("Error, no node configuration file given.");
                failed = true;
            }
            //if (portArg == null) {
            //    wout.WriteLine("Error, no port address given.");
            //    failed = true;
            //}

            if (!failed)
            {
                //TODO: support for remote (eg. HTTP, FTP, TCP/IP) configurations)

                nodeConfig = NormalizeFilePath(nodeConfig);
                netConfig  = NormalizeFilePath(netConfig);

                if (!File.Exists(nodeConfig))
                {
                    wout.WriteLine("Error, node configuration file not found ({0}).", nodeConfig);
                    failed = true;
                }
                else if (!File.Exists(netConfig))
                {
                    wout.WriteLine("Error, node configuration file not found ({0}).", netConfig);
                    failed = true;
                }
            }

            wout.Flush();

            // If failed,
            if (failed)
            {
                HelpFormatter formatter = new HelpFormatter();
                if (!IsConsoleRedirected())
                {
                    formatter.Width = Console.WindowWidth;
                }
                formatter.CommandLineSyntax = "mnode";
                formatter.Options           = options;
                formatter.PrintHelp();
                Console.Out.WriteLine();
                Console.Out.WriteLine(wout.ToString());
                return(1);
            }

            try {
#if DEBUG
                Console.Out.WriteLine("Retrieving node configuration from {0}", nodeConfig);
#endif

                // Get the node configuration file,
                ConfigSource nodeConfigSource = new ConfigSource();
                using (FileStream fin = new FileStream(nodeConfig, FileMode.Open, FileAccess.Read, FileShare.None)) {
                    //TODO: make it configurable ...
                    nodeConfigSource.LoadProperties(new BufferedStream(fin));
                }

#if DEBUG
                Console.Out.WriteLine("Retrieving network configuration from {0}", netConfig);
#endif

                // Parse the network configuration string,
                NetworkConfigSource netConfigSource;
                using (FileStream stream = new FileStream(netConfig, FileMode.Open, FileAccess.Read, FileShare.None)) {
                    netConfigSource = new NetworkConfigSource();
                    //TODO: make it configurable ...
                    netConfigSource.LoadProperties(stream);
                }

                string password = nodeConfigSource.GetString("network_password", null);
                if (password == null)
                {
                    Console.Out.WriteLine("Error: couldn't determine the network password.");
                    return(1);
                }

                // configure the loggers
                Logger.Init(nodeConfigSource);

                //TODO: support also IPv6

                // The base path,
                IPAddress host = null;
                if (hostArg != null)
                {
                    IPAddress[] addresses = Dns.GetHostAddresses(hostArg);
                    for (int i = 0; i < addresses.Length; i++)
                    {
                        IPAddress address = addresses[i];
                        if (address.AddressFamily == AddressFamily.InterNetwork)
                        {
                            host = address;
                            break;
                        }
                    }
                }
                else
                {
                    host = IPAddress.Loopback;
                }

                if (host == null)
                {
                    Console.Out.WriteLine("Error: couldn't determine the host address.");
                    return(1);
                }

                int port = DefaultPort;
                if (!String.IsNullOrEmpty(portArg))
                {
                    if (!Int32.TryParse(portArg, out port))
                    {
                        Console.Out.WriteLine("Error: couldn't parse port argument: " + portArg);
                        return(1);
                    }
                }

                string          storage        = commandLine.GetOptionValue("storage", null);
                IServiceFactory serviceFactory = GetServiceFactory(storage, nodeConfigSource);

                Console.Out.WriteLine("Machine Node, " + host + " : " + port);
                service        = new TcpAdminService(serviceFactory, host, port, password);
                service.Config = netConfigSource;
                service.Start();

                Console.Out.WriteLine();
                Console.Out.WriteLine();
                Console.Out.WriteLine("Press CTRL+C to quit...");

                waitHandle = new AutoResetEvent(false);
                waitHandle.WaitOne();
            } catch (Exception e) {
                Console.Out.WriteLine(e.Message);
                Console.Out.WriteLine(e.StackTrace);
                return(1);
            } finally {
                if (service != null)
                {
                    service.Dispose();
                }
            }

            return(0);
        }
Example #18
0
 /// <exception cref="Org.Apache.Commons.Cli.ParseException"/>
 private void ProcessOptions(CommandLine line, Options opts)
 {
     // --help -h and --version -V must be processed first.
     if (line.HasOption('h'))
     {
         HelpFormatter formatter = new HelpFormatter();
         System.Console.Out.WriteLine("TFile and SeqFile benchmark.");
         System.Console.Out.WriteLine();
         formatter.PrintHelp(100, "java ... TestTFileSeqFileComparison [options]", "\nSupported options:"
                             , opts, string.Empty);
         return;
     }
     if (line.HasOption('c'))
     {
         compress = line.GetOptionValue('c');
     }
     if (line.HasOption('d'))
     {
         dictSize = System.Convert.ToInt32(line.GetOptionValue('d'));
     }
     if (line.HasOption('s'))
     {
         fileSize = long.Parse(line.GetOptionValue('s')) * 1024 * 1024;
     }
     if (line.HasOption('f'))
     {
         format = line.GetOptionValue('f');
     }
     if (line.HasOption('i'))
     {
         fsInputBufferSize = System.Convert.ToInt32(line.GetOptionValue('i'));
     }
     if (line.HasOption('o'))
     {
         fsOutputBufferSize = System.Convert.ToInt32(line.GetOptionValue('o'));
     }
     if (line.HasOption('k'))
     {
         keyLength = System.Convert.ToInt32(line.GetOptionValue('k'));
     }
     if (line.HasOption('v'))
     {
         valueLength = System.Convert.ToInt32(line.GetOptionValue('v'));
     }
     if (line.HasOption('b'))
     {
         minBlockSize = System.Convert.ToInt32(line.GetOptionValue('b')) * 1024;
     }
     if (line.HasOption('r'))
     {
         rootDir = line.GetOptionValue('r');
     }
     if (line.HasOption('S'))
     {
         seed = long.Parse(line.GetOptionValue('S'));
     }
     if (line.HasOption('w'))
     {
         string          min_max = line.GetOptionValue('w');
         StringTokenizer st      = new StringTokenizer(min_max, " \t,");
         if (st.CountTokens() != 2)
         {
             throw new ParseException("Bad word length specification: " + min_max);
         }
         minWordLen = System.Convert.ToInt32(st.NextToken());
         maxWordLen = System.Convert.ToInt32(st.NextToken());
     }
     if (line.HasOption('x'))
     {
         string strOp = line.GetOptionValue('x');
         if (strOp.Equals("r"))
         {
             op = OpRead;
         }
         else
         {
             if (strOp.Equals("w"))
             {
                 op = OpCreate;
             }
             else
             {
                 if (strOp.Equals("rw"))
                 {
                     op = OpCreate | OpRead;
                 }
                 else
                 {
                     throw new ParseException("Unknown action specifier: " + strOp);
                 }
             }
         }
     }
     proceed = true;
 }
Example #19
0
 /// <exception cref="Org.Apache.Commons.Cli.ParseException"/>
 private void ProcessOptions(CommandLine line, Options opts)
 {
     // --help -h and --version -V must be processed first.
     if (line.HasOption('h'))
     {
         HelpFormatter formatter = new HelpFormatter();
         System.Console.Out.WriteLine("TFile and SeqFile benchmark.");
         System.Console.Out.WriteLine();
         formatter.PrintHelp(100, "java ... TestTFileSeqFileComparison [options]", "\nSupported options:"
                             , opts, string.Empty);
         return;
     }
     if (line.HasOption('c'))
     {
         compress = line.GetOptionValue('c');
     }
     if (line.HasOption('d'))
     {
         dictSize = System.Convert.ToInt32(line.GetOptionValue('d'));
     }
     if (line.HasOption('s'))
     {
         fileSize = long.Parse(line.GetOptionValue('s')) * 1024 * 1024;
     }
     if (line.HasOption('i'))
     {
         fsInputBufferSize = System.Convert.ToInt32(line.GetOptionValue('i'));
     }
     if (line.HasOption('o'))
     {
         fsOutputBufferSize = System.Convert.ToInt32(line.GetOptionValue('o'));
     }
     if (line.HasOption('n'))
     {
         seekCount = System.Convert.ToInt32(line.GetOptionValue('n'));
     }
     if (line.HasOption('k'))
     {
         TestTFileSeek.IntegerRange ir = TestTFileSeek.IntegerRange.Parse(line.GetOptionValue
                                                                              ('k'));
         minKeyLen = ir.From();
         maxKeyLen = ir.To();
     }
     if (line.HasOption('v'))
     {
         TestTFileSeek.IntegerRange ir = TestTFileSeek.IntegerRange.Parse(line.GetOptionValue
                                                                              ('v'));
         minValLength = ir.From();
         maxValLength = ir.To();
     }
     if (line.HasOption('b'))
     {
         minBlockSize = System.Convert.ToInt32(line.GetOptionValue('b')) * 1024;
     }
     if (line.HasOption('r'))
     {
         rootDir = line.GetOptionValue('r');
     }
     if (line.HasOption('f'))
     {
         file = line.GetOptionValue('f');
     }
     if (line.HasOption('S'))
     {
         seed = long.Parse(line.GetOptionValue('S'));
     }
     if (line.HasOption('x'))
     {
         string strOp = line.GetOptionValue('x');
         if (strOp.Equals("r"))
         {
             op = OpRead;
         }
         else
         {
             if (strOp.Equals("w"))
             {
                 op = OpCreate;
             }
             else
             {
                 if (strOp.Equals("rw"))
                 {
                     op = OpCreate | OpRead;
                 }
                 else
                 {
                     throw new ParseException("Unknown action specifier: " + strOp);
                 }
             }
         }
     }
     proceed = true;
 }