Uploaded image for project: 'Tajo'
  1. Tajo
  2. TAJO-990

Implement a tool to find tajo configurations.

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.9.0
    • Component/s: conf and scripts
    • Labels:
      None

      Description

      I suggest to implement a tool to find tajo configurations like the “hdfs getconf” tool. If we support the tool, users way wish to write shell scripts that interact with their tajo cluster, and it is useful to be able to fetch configs like the state of whether HA is enables or the mode of the worker.

        Issue Links

          Activity

          Hide
          hudson Hudson added a comment -

          SUCCESS: Integrated in Tajo-master-build #327 (See https://builds.apache.org/job/Tajo-master-build/327/)
          TAJO-990: Implement a tool to find tajo configurations. (jaehwa) (blrunner: rev 912df6f081b91785a56cb4b312e94b71228ecfd2)

          • tajo-client/src/main/java/org/apache/tajo/cli/TajoGetConfCommand.java
          • tajo-core/src/test/java/org/apache/tajo/cli/TestTajoCli.java
          • tajo-dist/src/main/bin/tajo
          • tajo-client/src/main/java/org/apache/tajo/client/TajoGetConf.java
          • tajo-client/src/main/java/org/apache/tajo/cli/TajoCli.java
          • tajo-client/src/main/java/org/apache/tajo/client/TajoAdmin.java
          Show
          hudson Hudson added a comment - SUCCESS: Integrated in Tajo-master-build #327 (See https://builds.apache.org/job/Tajo-master-build/327/ ) TAJO-990 : Implement a tool to find tajo configurations. (jaehwa) (blrunner: rev 912df6f081b91785a56cb4b312e94b71228ecfd2) tajo-client/src/main/java/org/apache/tajo/cli/TajoGetConfCommand.java tajo-core/src/test/java/org/apache/tajo/cli/TestTajoCli.java tajo-dist/src/main/bin/tajo tajo-client/src/main/java/org/apache/tajo/client/TajoGetConf.java tajo-client/src/main/java/org/apache/tajo/cli/TajoCli.java tajo-client/src/main/java/org/apache/tajo/client/TajoAdmin.java
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user blrunner closed the pull request at:

          https://github.com/apache/tajo/pull/105

          Show
          githubbot ASF GitHub Bot added a comment - Github user blrunner closed the pull request at: https://github.com/apache/tajo/pull/105
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user blrunner commented on the pull request:

          https://github.com/apache/tajo/pull/105#issuecomment-51707206

          Thanks @hyunsik.
          I've just committed it to the master branch.

          Show
          githubbot ASF GitHub Bot added a comment - Github user blrunner commented on the pull request: https://github.com/apache/tajo/pull/105#issuecomment-51707206 Thanks @hyunsik. I've just committed it to the master branch.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user hyunsik commented on the pull request:

          https://github.com/apache/tajo/pull/105#issuecomment-51672351

          +1

          The patch looks good to me.

          Show
          githubbot ASF GitHub Bot added a comment - Github user hyunsik commented on the pull request: https://github.com/apache/tajo/pull/105#issuecomment-51672351 +1 The patch looks good to me.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user blrunner commented on the pull request:

          https://github.com/apache/tajo/pull/105#issuecomment-51480046

          I added some unit cases.

          Show
          githubbot ASF GitHub Bot added a comment - Github user blrunner commented on the pull request: https://github.com/apache/tajo/pull/105#issuecomment-51480046 I added some unit cases.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user hyunsik commented on the pull request:

          https://github.com/apache/tajo/pull/105#issuecomment-51433547

          The patch looks good to me. Could you add unit tests in TestTajoCli?I'm sorry for mentioning it lately.

          Show
          githubbot ASF GitHub Bot added a comment - Github user hyunsik commented on the pull request: https://github.com/apache/tajo/pull/105#issuecomment-51433547 The patch looks good to me. Could you add unit tests in TestTajoCli?I'm sorry for mentioning it lately.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user blrunner commented on the pull request:

          https://github.com/apache/tajo/pull/105#issuecomment-51432189

          I updated a semantic for this patch.
          For reference, I applied "showmasters" instead of "show-masters". Because, "-" is a illegal character value in Options.

          Show
          githubbot ASF GitHub Bot added a comment - Github user blrunner commented on the pull request: https://github.com/apache/tajo/pull/105#issuecomment-51432189 I updated a semantic for this patch. For reference, I applied "showmasters" instead of "show-masters". Because, "-" is a illegal character value in Options.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user blrunner commented on the pull request:

          https://github.com/apache/tajo/pull/105#issuecomment-51422833

          Thanks @hyunsik.
          I also agree with you, I'll update my patch soon.

          Show
          githubbot ASF GitHub Bot added a comment - Github user blrunner commented on the pull request: https://github.com/apache/tajo/pull/105#issuecomment-51422833 Thanks @hyunsik. I also agree with you, I'll update my patch soon.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user hyunsik commented on the pull request:

          https://github.com/apache/tajo/pull/105#issuecomment-51422456

          I have some comments:

          Your proposal is the similar to Hadoop's one. It looks good, but I think that some semantic does not seem to be consistent.

          I'd like to propose as follows:
          ```
          bin/tajo admin -show-masters

          bin/tajo getconf tajo.rootdir
          hdfs://localhost:9010/tajo
          ```

          How do you think about that?

          Show
          githubbot ASF GitHub Bot added a comment - Github user hyunsik commented on the pull request: https://github.com/apache/tajo/pull/105#issuecomment-51422456 I have some comments: Your proposal is the similar to Hadoop's one. It looks good, but I think that some semantic does not seem to be consistent. I'd like to propose as follows: ``` bin/tajo admin -show-masters bin/tajo getconf tajo.rootdir hdfs://localhost:9010/tajo ``` How do you think about that?
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user blrunner commented on the pull request:

          https://github.com/apache/tajo/pull/105#issuecomment-51030961

          @hyunsik , thanks your quick review.

          If you tried to find default configurations, you couldn't find the configuration. Because TajoConf::get just supports to find the configuration in tajo-site.xml. So, I updated TajoGetConf::processConfKey. And you can use this patch as follows:

          • tajo getconf -masters
            localhost
          • tajo getconf -confKey tajo.worker.info-http.addre
            0.0.0.0:28080
          • tajo getconf -confKey tajo.rootdir
            hdfs://localhost:9010/tajo (your root dir)
          • tajo getconf -confKey tajo.username
            blrunner (your user name)
          Show
          githubbot ASF GitHub Bot added a comment - Github user blrunner commented on the pull request: https://github.com/apache/tajo/pull/105#issuecomment-51030961 @hyunsik , thanks your quick review. If you tried to find default configurations, you couldn't find the configuration. Because TajoConf::get just supports to find the configuration in tajo-site.xml. So, I updated TajoGetConf::processConfKey. And you can use this patch as follows: tajo getconf -masters localhost tajo getconf -confKey tajo.worker.info-http.addre 0.0.0.0:28080 tajo getconf -confKey tajo.rootdir hdfs://localhost:9010/tajo (your root dir) tajo getconf -confKey tajo.username blrunner (your user name)
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user blrunner commented on a diff in the pull request:

          https://github.com/apache/tajo/pull/105#discussion_r15742509

          — Diff: tajo-client/src/main/java/org/apache/tajo/client/TajoGetConf.java —
          @@ -0,0 +1,173 @@
          +/**
          + * Licensed to the Apache Software Foundation (ASF) under one
          + * or more contributor license agreements. See the NOTICE file
          + * distributed with this work for additional information
          + * regarding copyright ownership. The ASF licenses this file
          + * to you under the Apache License, Version 2.0 (the
          + * "License"); you may not use this file except in compliance
          + * with the License. You may obtain a copy of the License at
          + *
          + * http://www.apache.org/licenses/LICENSE-2.0
          + *
          + * Unless required by applicable law or agreed to in writing, software
          + * distributed under the License is distributed on an "AS IS" BASIS,
          + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
          + * See the License for the specific language governing permissions and
          + * limitations under the License.
          + */
          +
          +package org.apache.tajo.client;
          +
          +import com.google.protobuf.ServiceException;
          +import org.apache.commons.cli.*;
          +import org.apache.commons.lang.StringUtils;
          +import org.apache.tajo.QueryId;
          +import org.apache.tajo.TajoProtos;
          +import org.apache.tajo.conf.TajoConf;
          +import org.apache.tajo.ipc.ClientProtos.BriefQueryInfo;
          +import org.apache.tajo.ipc.ClientProtos.WorkerResourceInfo;
          +import org.apache.tajo.util.NetUtils;
          +import org.apache.tajo.util.TajoIdUtils;
          +
          +import java.io.IOException;
          +import java.io.PrintWriter;
          +import java.io.Writer;
          +import java.net.InetSocketAddress;
          +import java.sql.SQLException;
          +import java.text.DecimalFormat;
          +import java.text.SimpleDateFormat;
          +import java.util.ArrayList;
          +import java.util.List;
          +
          +public class TajoGetConf {
          + private static final org.apache.commons.cli.Options options;
          +
          + static

          { + options = new Options(); + options.addOption("h", "host", true, "Tajo server host"); + options.addOption("p", "port", true, "Tajo server port"); + options.addOption("masters", null, false, "gets list of tajomasters in the cluster"); + options.addOption("confKey", null, true, "gets a specific key from the configuration"); + }

          +
          + private TajoConf tajoConf;
          + private TajoClient tajoClient;
          + private Writer writer;
          +
          + public TajoGetConf(TajoConf tajoConf, Writer writer)

          { + this(tajoConf, writer, null); + }

          +
          + public TajoGetConf(TajoConf tajoConf, Writer writer, TajoClient tajoClient)

          { + this.tajoConf = tajoConf; + this.writer = writer; + this.tajoClient = tajoClient; + }

          +
          + private void printUsage()

          { + HelpFormatter formatter = new HelpFormatter(); + formatter.printHelp( "getconf [options]", options ); + }

          +
          + public void runCommand(String[] args) throws Exception {
          + CommandLineParser parser = new PosixParser();
          + CommandLine cmd = parser.parse(options, args);
          +
          + String param = "";
          + int cmdType = 0;
          +
          + String hostName = null;
          + Integer port = null;
          + if (cmd.hasOption("h"))

          { + hostName = cmd.getOptionValue("h"); + }

          + if (cmd.hasOption("p"))

          { + port = Integer.parseInt(cmd.getOptionValue("p")); + }

          +
          + if (cmd.hasOption("masters"))

          { + cmdType = 1; + }

          else if (cmd.hasOption("confKey"))

          { + cmdType = 2; + param = cmd.getOptionValue("confKey"); + }

          +
          + // if there is no "-h" option,
          + if(hostName == null) {
          + if (tajoConf.getVar(TajoConf.ConfVars.TAJO_MASTER_CLIENT_RPC_ADDRESS) != null)

          { + // it checks if the client service address is given in configuration and distributed mode. + // if so, it sets entryAddr. + hostName = tajoConf.getVar(TajoConf.ConfVars.TAJO_MASTER_CLIENT_RPC_ADDRESS).split(":")[0]; + }

          + }
          + if (port == null) {
          + if (tajoConf.getVar(TajoConf.ConfVars.TAJO_MASTER_CLIENT_RPC_ADDRESS) != null)

          { + // it checks if the client service address is given in configuration and distributed mode. + // if so, it sets entryAddr. + port = Integer.parseInt(tajoConf.getVar(TajoConf.ConfVars.TAJO_MASTER_CLIENT_RPC_ADDRESS).split(":")[1]); + }

          + }
          +
          + if (cmdType == 0)

          { + printUsage(); + return; + }

          +
          + if ((hostName == null) ^ (port == null))

          { + return; + }

          else if (hostName != null && port != null)

          { + tajoConf.setVar(TajoConf.ConfVars.TAJO_MASTER_CLIENT_RPC_ADDRESS, hostName + ":" + port); + tajoClient = new TajoClient(tajoConf); + }

          else if (hostName == null && port == null)

          { + tajoClient = new TajoClient(tajoConf); + }

          +
          + switch (cmdType)

          { + case 1: + processMasters(writer); + break; + case 2: + processConfKey(writer, param); + break; + default: + printUsage(); + break; + }

          +
          + writer.flush();
          + }
          +
          + private void processMasters(Writer writer) throws ParseException, IOException,
          + ServiceException, SQLException

          { + String confMasterServiceAddr = tajoConf.getVar(TajoConf.ConfVars.TAJO_MASTER_UMBILICAL_RPC_ADDRESS); + InetSocketAddress masterAddress = NetUtils.createSocketAddr(confMasterServiceAddr); + writer.write(masterAddress.getHostName()); + writer.write("\n"); + }

          +
          + private void processConfKey(Writer writer, String param) throws ParseException, IOException,
          + ServiceException, SQLException {
          + String value = tajoConf.get(param);
          +
          + if (value != null)

          { + writer.write(value); + }

          else {
          + writer.write("Configuration a is missing.");
          — End diff –

          Thanks, @hyunsik .
          I've just updated it.

          Show
          githubbot ASF GitHub Bot added a comment - Github user blrunner commented on a diff in the pull request: https://github.com/apache/tajo/pull/105#discussion_r15742509 — Diff: tajo-client/src/main/java/org/apache/tajo/client/TajoGetConf.java — @@ -0,0 +1,173 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.tajo.client; + +import com.google.protobuf.ServiceException; +import org.apache.commons.cli.*; +import org.apache.commons.lang.StringUtils; +import org.apache.tajo.QueryId; +import org.apache.tajo.TajoProtos; +import org.apache.tajo.conf.TajoConf; +import org.apache.tajo.ipc.ClientProtos.BriefQueryInfo; +import org.apache.tajo.ipc.ClientProtos.WorkerResourceInfo; +import org.apache.tajo.util.NetUtils; +import org.apache.tajo.util.TajoIdUtils; + +import java.io.IOException; +import java.io.PrintWriter; +import java.io.Writer; +import java.net.InetSocketAddress; +import java.sql.SQLException; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.List; + +public class TajoGetConf { + private static final org.apache.commons.cli.Options options; + + static { + options = new Options(); + options.addOption("h", "host", true, "Tajo server host"); + options.addOption("p", "port", true, "Tajo server port"); + options.addOption("masters", null, false, "gets list of tajomasters in the cluster"); + options.addOption("confKey", null, true, "gets a specific key from the configuration"); + } + + private TajoConf tajoConf; + private TajoClient tajoClient; + private Writer writer; + + public TajoGetConf(TajoConf tajoConf, Writer writer) { + this(tajoConf, writer, null); + } + + public TajoGetConf(TajoConf tajoConf, Writer writer, TajoClient tajoClient) { + this.tajoConf = tajoConf; + this.writer = writer; + this.tajoClient = tajoClient; + } + + private void printUsage() { + HelpFormatter formatter = new HelpFormatter(); + formatter.printHelp( "getconf [options]", options ); + } + + public void runCommand(String[] args) throws Exception { + CommandLineParser parser = new PosixParser(); + CommandLine cmd = parser.parse(options, args); + + String param = ""; + int cmdType = 0; + + String hostName = null; + Integer port = null; + if (cmd.hasOption("h")) { + hostName = cmd.getOptionValue("h"); + } + if (cmd.hasOption("p")) { + port = Integer.parseInt(cmd.getOptionValue("p")); + } + + if (cmd.hasOption("masters")) { + cmdType = 1; + } else if (cmd.hasOption("confKey")) { + cmdType = 2; + param = cmd.getOptionValue("confKey"); + } + + // if there is no "-h" option, + if(hostName == null) { + if (tajoConf.getVar(TajoConf.ConfVars.TAJO_MASTER_CLIENT_RPC_ADDRESS) != null) { + // it checks if the client service address is given in configuration and distributed mode. + // if so, it sets entryAddr. + hostName = tajoConf.getVar(TajoConf.ConfVars.TAJO_MASTER_CLIENT_RPC_ADDRESS).split(":")[0]; + } + } + if (port == null) { + if (tajoConf.getVar(TajoConf.ConfVars.TAJO_MASTER_CLIENT_RPC_ADDRESS) != null) { + // it checks if the client service address is given in configuration and distributed mode. + // if so, it sets entryAddr. + port = Integer.parseInt(tajoConf.getVar(TajoConf.ConfVars.TAJO_MASTER_CLIENT_RPC_ADDRESS).split(":")[1]); + } + } + + if (cmdType == 0) { + printUsage(); + return; + } + + if ((hostName == null) ^ (port == null)) { + return; + } else if (hostName != null && port != null) { + tajoConf.setVar(TajoConf.ConfVars.TAJO_MASTER_CLIENT_RPC_ADDRESS, hostName + ":" + port); + tajoClient = new TajoClient(tajoConf); + } else if (hostName == null && port == null) { + tajoClient = new TajoClient(tajoConf); + } + + switch (cmdType) { + case 1: + processMasters(writer); + break; + case 2: + processConfKey(writer, param); + break; + default: + printUsage(); + break; + } + + writer.flush(); + } + + private void processMasters(Writer writer) throws ParseException, IOException, + ServiceException, SQLException { + String confMasterServiceAddr = tajoConf.getVar(TajoConf.ConfVars.TAJO_MASTER_UMBILICAL_RPC_ADDRESS); + InetSocketAddress masterAddress = NetUtils.createSocketAddr(confMasterServiceAddr); + writer.write(masterAddress.getHostName()); + writer.write("\n"); + } + + private void processConfKey(Writer writer, String param) throws ParseException, IOException, + ServiceException, SQLException { + String value = tajoConf.get(param); + + if (value != null) { + writer.write(value); + } else { + writer.write("Configuration a is missing."); — End diff – Thanks, @hyunsik . I've just updated it.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user hyunsik commented on the pull request:

          https://github.com/apache/tajo/pull/105#issuecomment-51023868

          Could you give more description of this utility?

          Show
          githubbot ASF GitHub Bot added a comment - Github user hyunsik commented on the pull request: https://github.com/apache/tajo/pull/105#issuecomment-51023868 Could you give more description of this utility?
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user hyunsik commented on a diff in the pull request:

          https://github.com/apache/tajo/pull/105#discussion_r15742373

          — Diff: tajo-client/src/main/java/org/apache/tajo/client/TajoGetConf.java —
          @@ -0,0 +1,173 @@
          +/**
          + * Licensed to the Apache Software Foundation (ASF) under one
          + * or more contributor license agreements. See the NOTICE file
          + * distributed with this work for additional information
          + * regarding copyright ownership. The ASF licenses this file
          + * to you under the Apache License, Version 2.0 (the
          + * "License"); you may not use this file except in compliance
          + * with the License. You may obtain a copy of the License at
          + *
          + * http://www.apache.org/licenses/LICENSE-2.0
          + *
          + * Unless required by applicable law or agreed to in writing, software
          + * distributed under the License is distributed on an "AS IS" BASIS,
          + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
          + * See the License for the specific language governing permissions and
          + * limitations under the License.
          + */
          +
          +package org.apache.tajo.client;
          +
          +import com.google.protobuf.ServiceException;
          +import org.apache.commons.cli.*;
          +import org.apache.commons.lang.StringUtils;
          +import org.apache.tajo.QueryId;
          +import org.apache.tajo.TajoProtos;
          +import org.apache.tajo.conf.TajoConf;
          +import org.apache.tajo.ipc.ClientProtos.BriefQueryInfo;
          +import org.apache.tajo.ipc.ClientProtos.WorkerResourceInfo;
          +import org.apache.tajo.util.NetUtils;
          +import org.apache.tajo.util.TajoIdUtils;
          +
          +import java.io.IOException;
          +import java.io.PrintWriter;
          +import java.io.Writer;
          +import java.net.InetSocketAddress;
          +import java.sql.SQLException;
          +import java.text.DecimalFormat;
          +import java.text.SimpleDateFormat;
          +import java.util.ArrayList;
          +import java.util.List;
          +
          +public class TajoGetConf {
          + private static final org.apache.commons.cli.Options options;
          +
          + static

          { + options = new Options(); + options.addOption("h", "host", true, "Tajo server host"); + options.addOption("p", "port", true, "Tajo server port"); + options.addOption("masters", null, false, "gets list of tajomasters in the cluster"); + options.addOption("confKey", null, true, "gets a specific key from the configuration"); + }

          +
          + private TajoConf tajoConf;
          + private TajoClient tajoClient;
          + private Writer writer;
          +
          + public TajoGetConf(TajoConf tajoConf, Writer writer)

          { + this(tajoConf, writer, null); + }

          +
          + public TajoGetConf(TajoConf tajoConf, Writer writer, TajoClient tajoClient)

          { + this.tajoConf = tajoConf; + this.writer = writer; + this.tajoClient = tajoClient; + }

          +
          + private void printUsage()

          { + HelpFormatter formatter = new HelpFormatter(); + formatter.printHelp( "getconf [options]", options ); + }

          +
          + public void runCommand(String[] args) throws Exception {
          + CommandLineParser parser = new PosixParser();
          + CommandLine cmd = parser.parse(options, args);
          +
          + String param = "";
          + int cmdType = 0;
          +
          + String hostName = null;
          + Integer port = null;
          + if (cmd.hasOption("h"))

          { + hostName = cmd.getOptionValue("h"); + }

          + if (cmd.hasOption("p"))

          { + port = Integer.parseInt(cmd.getOptionValue("p")); + }

          +
          + if (cmd.hasOption("masters"))

          { + cmdType = 1; + }

          else if (cmd.hasOption("confKey"))

          { + cmdType = 2; + param = cmd.getOptionValue("confKey"); + }

          +
          + // if there is no "-h" option,
          + if(hostName == null) {
          + if (tajoConf.getVar(TajoConf.ConfVars.TAJO_MASTER_CLIENT_RPC_ADDRESS) != null)

          { + // it checks if the client service address is given in configuration and distributed mode. + // if so, it sets entryAddr. + hostName = tajoConf.getVar(TajoConf.ConfVars.TAJO_MASTER_CLIENT_RPC_ADDRESS).split(":")[0]; + }

          + }
          + if (port == null) {
          + if (tajoConf.getVar(TajoConf.ConfVars.TAJO_MASTER_CLIENT_RPC_ADDRESS) != null)

          { + // it checks if the client service address is given in configuration and distributed mode. + // if so, it sets entryAddr. + port = Integer.parseInt(tajoConf.getVar(TajoConf.ConfVars.TAJO_MASTER_CLIENT_RPC_ADDRESS).split(":")[1]); + }

          + }
          +
          + if (cmdType == 0)

          { + printUsage(); + return; + }

          +
          + if ((hostName == null) ^ (port == null))

          { + return; + }

          else if (hostName != null && port != null)

          { + tajoConf.setVar(TajoConf.ConfVars.TAJO_MASTER_CLIENT_RPC_ADDRESS, hostName + ":" + port); + tajoClient = new TajoClient(tajoConf); + }

          else if (hostName == null && port == null)

          { + tajoClient = new TajoClient(tajoConf); + }

          +
          + switch (cmdType)

          { + case 1: + processMasters(writer); + break; + case 2: + processConfKey(writer, param); + break; + default: + printUsage(); + break; + }

          +
          + writer.flush();
          + }
          +
          + private void processMasters(Writer writer) throws ParseException, IOException,
          + ServiceException, SQLException

          { + String confMasterServiceAddr = tajoConf.getVar(TajoConf.ConfVars.TAJO_MASTER_UMBILICAL_RPC_ADDRESS); + InetSocketAddress masterAddress = NetUtils.createSocketAddr(confMasterServiceAddr); + writer.write(masterAddress.getHostName()); + writer.write("\n"); + }

          +
          + private void processConfKey(Writer writer, String param) throws ParseException, IOException,
          + ServiceException, SQLException {
          + String value = tajoConf.get(param);
          +
          + if (value != null)

          { + writer.write(value); + }

          else {
          + writer.write("Configuration a is missing.");
          — End diff –

          It seems to be a typo.

          Show
          githubbot ASF GitHub Bot added a comment - Github user hyunsik commented on a diff in the pull request: https://github.com/apache/tajo/pull/105#discussion_r15742373 — Diff: tajo-client/src/main/java/org/apache/tajo/client/TajoGetConf.java — @@ -0,0 +1,173 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.tajo.client; + +import com.google.protobuf.ServiceException; +import org.apache.commons.cli.*; +import org.apache.commons.lang.StringUtils; +import org.apache.tajo.QueryId; +import org.apache.tajo.TajoProtos; +import org.apache.tajo.conf.TajoConf; +import org.apache.tajo.ipc.ClientProtos.BriefQueryInfo; +import org.apache.tajo.ipc.ClientProtos.WorkerResourceInfo; +import org.apache.tajo.util.NetUtils; +import org.apache.tajo.util.TajoIdUtils; + +import java.io.IOException; +import java.io.PrintWriter; +import java.io.Writer; +import java.net.InetSocketAddress; +import java.sql.SQLException; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.List; + +public class TajoGetConf { + private static final org.apache.commons.cli.Options options; + + static { + options = new Options(); + options.addOption("h", "host", true, "Tajo server host"); + options.addOption("p", "port", true, "Tajo server port"); + options.addOption("masters", null, false, "gets list of tajomasters in the cluster"); + options.addOption("confKey", null, true, "gets a specific key from the configuration"); + } + + private TajoConf tajoConf; + private TajoClient tajoClient; + private Writer writer; + + public TajoGetConf(TajoConf tajoConf, Writer writer) { + this(tajoConf, writer, null); + } + + public TajoGetConf(TajoConf tajoConf, Writer writer, TajoClient tajoClient) { + this.tajoConf = tajoConf; + this.writer = writer; + this.tajoClient = tajoClient; + } + + private void printUsage() { + HelpFormatter formatter = new HelpFormatter(); + formatter.printHelp( "getconf [options]", options ); + } + + public void runCommand(String[] args) throws Exception { + CommandLineParser parser = new PosixParser(); + CommandLine cmd = parser.parse(options, args); + + String param = ""; + int cmdType = 0; + + String hostName = null; + Integer port = null; + if (cmd.hasOption("h")) { + hostName = cmd.getOptionValue("h"); + } + if (cmd.hasOption("p")) { + port = Integer.parseInt(cmd.getOptionValue("p")); + } + + if (cmd.hasOption("masters")) { + cmdType = 1; + } else if (cmd.hasOption("confKey")) { + cmdType = 2; + param = cmd.getOptionValue("confKey"); + } + + // if there is no "-h" option, + if(hostName == null) { + if (tajoConf.getVar(TajoConf.ConfVars.TAJO_MASTER_CLIENT_RPC_ADDRESS) != null) { + // it checks if the client service address is given in configuration and distributed mode. + // if so, it sets entryAddr. + hostName = tajoConf.getVar(TajoConf.ConfVars.TAJO_MASTER_CLIENT_RPC_ADDRESS).split(":")[0]; + } + } + if (port == null) { + if (tajoConf.getVar(TajoConf.ConfVars.TAJO_MASTER_CLIENT_RPC_ADDRESS) != null) { + // it checks if the client service address is given in configuration and distributed mode. + // if so, it sets entryAddr. + port = Integer.parseInt(tajoConf.getVar(TajoConf.ConfVars.TAJO_MASTER_CLIENT_RPC_ADDRESS).split(":")[1]); + } + } + + if (cmdType == 0) { + printUsage(); + return; + } + + if ((hostName == null) ^ (port == null)) { + return; + } else if (hostName != null && port != null) { + tajoConf.setVar(TajoConf.ConfVars.TAJO_MASTER_CLIENT_RPC_ADDRESS, hostName + ":" + port); + tajoClient = new TajoClient(tajoConf); + } else if (hostName == null && port == null) { + tajoClient = new TajoClient(tajoConf); + } + + switch (cmdType) { + case 1: + processMasters(writer); + break; + case 2: + processConfKey(writer, param); + break; + default: + printUsage(); + break; + } + + writer.flush(); + } + + private void processMasters(Writer writer) throws ParseException, IOException, + ServiceException, SQLException { + String confMasterServiceAddr = tajoConf.getVar(TajoConf.ConfVars.TAJO_MASTER_UMBILICAL_RPC_ADDRESS); + InetSocketAddress masterAddress = NetUtils.createSocketAddr(confMasterServiceAddr); + writer.write(masterAddress.getHostName()); + writer.write("\n"); + } + + private void processConfKey(Writer writer, String param) throws ParseException, IOException, + ServiceException, SQLException { + String value = tajoConf.get(param); + + if (value != null) { + writer.write(value); + } else { + writer.write("Configuration a is missing."); — End diff – It seems to be a typo.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user blrunner commented on the pull request:

          https://github.com/apache/tajo/pull/104#issuecomment-51021182

          I closed this request because of a typo.

          Show
          githubbot ASF GitHub Bot added a comment - Github user blrunner commented on the pull request: https://github.com/apache/tajo/pull/104#issuecomment-51021182 I closed this request because of a typo.
          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user blrunner opened a pull request:

          https://github.com/apache/tajo/pull/105

          TAJO-990: Implement a tool to find tajo configurations.

          I created pull request again because I missed a title of previous request.

          You can merge this pull request into a Git repository by running:

          $ git pull https://github.com/blrunner/tajo TAJO-990

          Alternatively you can review and apply these changes as the patch at:

          https://github.com/apache/tajo/pull/105.patch

          To close this pull request, make a commit to your master/trunk branch
          with (at least) the following in the commit message:

          This closes #105


          commit 492bc4ed54100d5f1a7eb5c3682d25f4c2902158
          Author: blrunner <blrunner@freegiansui-mbp.server.gruter.com>
          Date: 2014-08-04T06:09:49Z

          TAJO-990: Implement a tool to find tajo configurations.

          commit b2b6ef75355d48181461645882377e7ff24d4be2
          Author: blrunner <blrunner@freegiansui-mbp.server.gruter.com>
          Date: 2014-08-04T06:12:33Z

          Modified local variable name.


          Show
          githubbot ASF GitHub Bot added a comment - GitHub user blrunner opened a pull request: https://github.com/apache/tajo/pull/105 TAJO-990 : Implement a tool to find tajo configurations. I created pull request again because I missed a title of previous request. You can merge this pull request into a Git repository by running: $ git pull https://github.com/blrunner/tajo TAJO-990 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/tajo/pull/105.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #105 commit 492bc4ed54100d5f1a7eb5c3682d25f4c2902158 Author: blrunner <blrunner@freegiansui-mbp.server.gruter.com> Date: 2014-08-04T06:09:49Z TAJO-990 : Implement a tool to find tajo configurations. commit b2b6ef75355d48181461645882377e7ff24d4be2 Author: blrunner <blrunner@freegiansui-mbp.server.gruter.com> Date: 2014-08-04T06:12:33Z Modified local variable name.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user blrunner closed the pull request at:

          https://github.com/apache/tajo/pull/104

          Show
          githubbot ASF GitHub Bot added a comment - Github user blrunner closed the pull request at: https://github.com/apache/tajo/pull/104

            People

            • Assignee:
              blrunner Jaehwa Jung
              Reporter:
              blrunner Jaehwa Jung
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development