Uploaded image for project: 'ZooKeeper'
  1. ZooKeeper
  2. ZOOKEEPER-1897

ZK Shell/Cli not processing commands

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.4.6
    • 3.4.7, 3.5.0
    • java client, scripts
    • None

    Description

      When running zookeeper 3.4.5 I was able to run commands using zkCli such as

      zkCli.sh -server 127.0.0.1:2182 ls /
      zkCli.sh -server 127.0.0.1:2182 get /blah

      After upgrading to 3.4.6 these commands no longer work.

      I think issue https://issues.apache.org/jira/browse/ZOOKEEPER-1535 was the reason the commands were running in previous versions.

      It looks like the client exits when a command is present.

      ZooKeeperMain.java
          void run() throws KeeperException, IOException, InterruptedException {
              if (cl.getCommand() == null) {
                  System.out.println("Welcome to ZooKeeper!");
      
                  boolean jlinemissing = false;
                  // only use jline if it's in the classpath
                  try {
                      Class consoleC = Class.forName("jline.ConsoleReader");
                      Class completorC =
                          Class.forName("org.apache.zookeeper.JLineZNodeCompletor");
      
                      System.out.println("JLine support is enabled");
      
                      Object console =
                          consoleC.getConstructor().newInstance();
      
                      Object completor =
                          completorC.getConstructor(ZooKeeper.class).newInstance(zk);
                      Method addCompletor = consoleC.getMethod("addCompletor",
                              Class.forName("jline.Completor"));
                      addCompletor.invoke(console, completor);
      
                      String line;
                      Method readLine = consoleC.getMethod("readLine", String.class);
                      while ((line = (String)readLine.invoke(console, getPrompt())) != null) {
                          executeLine(line);
                      }
                  } catch (ClassNotFoundException e) {
                      LOG.debug("Unable to start jline", e);
                      jlinemissing = true;
                  } catch (NoSuchMethodException e) {
                      LOG.debug("Unable to start jline", e);
                      jlinemissing = true;
                  } catch (InvocationTargetException e) {
                      LOG.debug("Unable to start jline", e);
                      jlinemissing = true;
                  } catch (IllegalAccessException e) {
                      LOG.debug("Unable to start jline", e);
                      jlinemissing = true;
                  } catch (InstantiationException e) {
                      LOG.debug("Unable to start jline", e);
                      jlinemissing = true;
                  }
      
                  if (jlinemissing) {
                      System.out.println("JLine support is disabled");
                      BufferedReader br =
                          new BufferedReader(new InputStreamReader(System.in));
      
                      String line;
                      while ((line = br.readLine()) != null) {
                          executeLine(line);
                      }
                  }
              }
          }
      

      Attachments

        1. ZOOKEEPER-1897v3.txt
          0.5 kB
          Michael Stack
        2. ZOOKEEPER-1897v2.txt
          0.6 kB
          Michael Stack
        3. ZOOKEEPER-1897.txt
          0.6 kB
          Michael Stack

        Issue Links

          Activity

            People

              stack Michael Stack
              gnoremac Cameron Gandevia
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: