CSE 124
2017 December 1: SurfStore metadata server number

An example of using the -n command-line argument

In part 2 of the SurfStore project, you’ll need to start up multiple metadata servers. To find out which metadata server you are, you can pass in the command-line option -n

Starting metadata store number 1:

[cs124f@ieng6-202]:java:503$ target/surfstore/bin/runMetadataStore ../configs/configDistributed.txt
Dec 01, 2017 4:01:46 PM surfstore.MetadataStore main
INFO: Metadata server number 1 starting
Dec 01, 2017 4:01:47 PM surfstore.MetadataStore start
INFO: Server started, listening on 8391

Starting metadata store number 2:

[cs124f@ieng6-202]:java:503$ target/surfstore/bin/runMetadataStore -n 2 ../configs/configDistributed.txt
Dec 01, 2017 4:01:59 PM surfstore.MetadataStore main
INFO: Metadata server number 2 starting
Dec 01, 2017 4:02:00 PM surfstore.MetadataStore start
INFO: Server started, listening on 8392

Starting metadata store number 3:

[cs124f@ieng6-202]:java:504$ target/surfstore/bin/runMetadataStore -n 3 ../configs/configDistributed.txt
Dec 01, 2017 4:02:09 PM surfstore.MetadataStore main
INFO: Metadata server number 3 starting
Dec 01, 2017 4:02:10 PM surfstore.MetadataStore start
INFO: Server started, listening on 8393

Adding code to your project

To get the command line option, use the c_args.getInt("number") command. For example:

    public static void main(String[] args) throws Exception {
        Namespace c_args = parseArgs(args);
        if (c_args == null){
            throw new RuntimeException("Argument parsing failed");
        }

        File configf = new File(c_args.getString("config_file"));
        ConfigReader config = new ConfigReader(configf);

        int myid = c_args.getInt("number");
        logger.info("Metadata server number " + myid + " starting");

        if (c_args.getInt("number") > config.getNumMetadataServers()) {
            throw new RuntimeException(String.format("metadata%d not in config file", c_args.getInt("number")));
        }