Ejemplo n.º 1
0
  public static void main(String args[]) throws IOException {
    // process command line args
    CliOptions cliOptions = new CliOptions();
    cliOptions.processArgs(css_, args);

    // connect to cassandra server if host argument specified.
    if (css_.hostName != null) {
      connect(css_.hostName, css_.thriftPort);
    } else {
      // If not, client must connect explicitly using the "connect" CLI statement.
      cliClient_ = new CliClient(css_, null);
    }

    ConsoleReader reader = new ConsoleReader();
    reader.setBellEnabled(false);

    String historyFile = System.getProperty("user.home") + File.separator + HISTORYFILE;

    reader.setHistory(new History(new File(historyFile)));

    printBanner();

    String line;
    while ((line = reader.readLine(PROMPT + "> ")) != null) {
      processLine(line);
    }
  }
Ejemplo n.º 2
0
  // process a statement of the form: connect hostname/port
  private void executeConnect(CommonTree ast) {
    int portNumber = Integer.parseInt(ast.getChild(1).getText());
    Tree idList = ast.getChild(0);

    StringBuilder hostName = new StringBuilder();
    int idCount = idList.getChildCount();
    for (int idx = 0; idx < idCount; idx++) {
      hostName.append(idList.getChild(idx).getText());
    }

    // disconnect current connection, if any.
    // This is a no-op, if you aren't currently connected.
    CliMain.disconnect();

    // now, connect to the newly specified host name and port
    css_.hostName = hostName.toString();
    css_.thriftPort = portNumber;
    CliMain.connect(css_.hostName, css_.thriftPort);
  }