Package org.apache.accumulo.core.util.shell.Shell

Examples of org.apache.accumulo.core.util.shell.Shell.PrintFile


  private Option optEndRowExclusive;
  private Option timeoutOption;
  private Option profileOpt;
 
  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
    final PrintFile printFile = getOutputFile(cl);
   
    final String tableName = OptUtil.getTableOpt(cl, shellState);
   
    final Class<? extends Formatter> formatter = getFormatter(cl, tableName, shellState);
    final ScanInterpreter interpeter = getInterpreter(cl, tableName, shellState);
   
    // handle first argument, if present, the authorizations list to
    // scan with
    final Authorizations auths = getAuths(cl, shellState);
    final Scanner scanner = shellState.getConnector().createScanner(tableName, auths);
   
    // handle session-specific scan iterators
    addScanIterators(shellState, cl, scanner, tableName);
   
    // handle remaining optional arguments
    scanner.setRange(getRange(cl, interpeter));
   
    // handle columns
    fetchColumns(cl, scanner, interpeter);
   
    // set timeout
    scanner.setTimeout(getTimeout(cl), TimeUnit.MILLISECONDS);

    // output the records
    if (cl.hasOption(showFewOpt.getOpt())) {
      final String showLength = cl.getOptionValue(showFewOpt.getOpt());
      try {
        final int length = Integer.parseInt(showLength);
        if (length < 1) {
          throw new IllegalArgumentException();
        }
        BinaryFormatter.getlength(length);
        printBinaryRecords(cl, shellState, scanner, printFile);
      } catch (NumberFormatException nfe) {
        shellState.getReader().printString("Arg must be an integer. \n");
      } catch (IllegalArgumentException iae) {
        shellState.getReader().printString("Arg must be greater than one. \n");
      }
     
    } else {
      printRecords(cl, shellState, scanner, formatter, printFile);
    }
    if (printFile != null) {
      printFile.close();
    }
   
    return 0;
  }
View Full Code Here


    return 0;
  }
 
  protected PrintFile getOutputFile(final CommandLine cl) throws FileNotFoundException {
    final String outputFile = cl.getOptionValue(outputFileOpt.getOpt());
    return (outputFile == null ? null : new PrintFile(outputFile));
  }
View Full Code Here

    final String m = cl.getOptionValue(maxSplitsOpt.getOpt());
    final int maxSplits = m == null ? 0 : Integer.parseInt(m);
    final boolean encode = cl.hasOption(base64Opt.getOpt());
    final boolean verbose = cl.hasOption(verboseOpt.getOpt());
   
    final PrintLine p = outputFile == null ? new PrintShell(shellState.getReader()) : new PrintFile(outputFile);
   
    try {
      if (!verbose) {
        for (Text row : maxSplits > 0 ? shellState.getConnector().tableOperations().listSplits(tableName, maxSplits) : shellState.getConnector()
            .tableOperations().listSplits(tableName)) {
View Full Code Here

 
  private Option numThreadsOpt;
 
  @Override
  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
    final PrintFile printFile = getOutputFile(cl);
   
    final String tableName = OptUtil.getTableOpt(cl, shellState);
   
    if (cl.getArgList().isEmpty()) {
      throw new MissingArgumentException("No terms specified");
View Full Code Here

      // display properties
      final TreeMap<String,String> systemConfig = new TreeMap<String,String>();
      systemConfig.putAll(shellState.getConnector().instanceOperations().getSystemConfiguration());
     
      final String outputFile = cl.getOptionValue(outputFileOpt.getOpt());
      final PrintFile printFile = outputFile == null ? null : new PrintFile(outputFile);
     
      final TreeMap<String,String> siteConfig = new TreeMap<String,String>();
      siteConfig.putAll(shellState.getConnector().instanceOperations().getSiteConfiguration());
     
      final TreeMap<String,String> defaults = new TreeMap<String,String>();
      for (Entry<String,String> defaultEntry : AccumuloConfiguration.getDefaultConfiguration()) {
        defaults.put(defaultEntry.getKey(), defaultEntry.getValue());
      }
      Iterable<Entry<String,String>> acuconf = shellState.getConnector().instanceOperations().getSystemConfiguration().entrySet();
      if (tableName != null) {
        acuconf = shellState.getConnector().tableOperations().getProperties(tableName);
      }
      final TreeMap<String,String> sortedConf = new TreeMap<String,String>();
      for (Entry<String,String> propEntry : acuconf) {
        sortedConf.put(propEntry.getKey(), propEntry.getValue());
      }
     
      for (Entry<String,String> propEntry : acuconf) {
        final String key = propEntry.getKey();
        // only show properties with similar names to that
        // specified, or all of them if none specified
        if (cl.hasOption(filterOpt.getOpt()) && !key.contains(cl.getOptionValue(filterOpt.getOpt()))) {
          continue;
        }
        if (tableName != null && !Property.isValidTablePropertyKey(key)) {
          continue;
        }
        COL2 = Math.max(COL2, propEntry.getKey().length() + 3);
      }
     
      final ArrayList<String> output = new ArrayList<String>();
      printConfHeader(output);
     
      for (Entry<String,String> propEntry : sortedConf.entrySet()) {
        final String key = propEntry.getKey();
       
        // only show properties with similar names to that
        // specified, or all of them if none specified
        if (cl.hasOption(filterOpt.getOpt()) && !key.contains(cl.getOptionValue(filterOpt.getOpt()))) {
          continue;
        }
        if (tableName != null && !Property.isValidTablePropertyKey(key)) {
          continue;
        }
        String siteVal = siteConfig.get(key);
        String sysVal = systemConfig.get(key);
        String curVal = propEntry.getValue();
        String dfault = defaults.get(key);
        boolean printed = false;
       
        if (dfault != null && key.toLowerCase().contains("password")) {
          siteVal = sysVal = dfault = curVal = curVal.replaceAll(".", "*");
        }
        if (sysVal != null) {
          if (defaults.containsKey(key)) {
            printConfLine(output, "default", key, dfault);
            printed = true;
          }
          if (!defaults.containsKey(key) || !defaults.get(key).equals(siteVal)) {
            printConfLine(output, "site", printed ? "   @override" : key, siteVal == null ? "" : siteVal);
            printed = true;
          }
          if (!siteConfig.containsKey(key) || !siteVal.equals(sysVal)) {
            printConfLine(output, "system", printed ? "   @override" : key, sysVal == null ? "" : sysVal);
            printed = true;
          }
        }
       
        // show per-table value only if it is different (overridden)
        if (tableName != null && !curVal.equals(sysVal)) {
          printConfLine(output, "table", printed ? "   @override" : key, curVal);
        }
      }
      printConfFooter(output);
      shellState.printLines(output.iterator(), !cl.hasOption(disablePaginationOpt.getOpt()), printFile);
      if (printFile != null) {
        printFile.close();
      }
    }
    return 0;
  }
View Full Code Here

  private Option timeoutOption;
  private Option profileOpt;
 
  @Override
  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
    final PrintFile printFile = getOutputFile(cl);
    final String tableName = OptUtil.getTableOpt(cl, shellState);
   
    final Class<? extends Formatter> formatter = getFormatter(cl, tableName, shellState);
    final ScanInterpreter interpeter = getInterpreter(cl, tableName, shellState);
   
    // handle first argument, if present, the authorizations list to
    // scan with
    final Authorizations auths = getAuths(cl, shellState);
    final Scanner scanner = shellState.getConnector().createScanner(tableName, auths);
   
    // handle session-specific scan iterators
    addScanIterators(shellState, cl, scanner, tableName);
   
    // handle remaining optional arguments
    scanner.setRange(getRange(cl, interpeter));
   
    // handle columns
    fetchColumns(cl, scanner, interpeter);
   
    // set timeout
    scanner.setTimeout(getTimeout(cl), TimeUnit.MILLISECONDS);
   
    // output the records
    if (cl.hasOption(showFewOpt.getOpt())) {
      final String showLength = cl.getOptionValue(showFewOpt.getOpt());
      try {
        final int length = Integer.parseInt(showLength);
        if (length < 1) {
          throw new IllegalArgumentException();
        }
        BinaryFormatter.getlength(length);
        printBinaryRecords(cl, shellState, scanner, printFile);
      } catch (NumberFormatException nfe) {
        shellState.getReader().println("Arg must be an integer.");
      } catch (IllegalArgumentException iae) {
        shellState.getReader().println("Arg must be greater than one.");
      }
     
    } else {
      printRecords(cl, shellState, scanner, formatter, printFile);
    }
    if (printFile != null) {
      printFile.close();
    }
   
    return 0;
  }
View Full Code Here

    return 0;
  }
 
  protected PrintFile getOutputFile(final CommandLine cl) throws FileNotFoundException {
    final String outputFile = cl.getOptionValue(outputFileOpt.getOpt());
    return (outputFile == null ? null : new PrintFile(outputFile));
  }
View Full Code Here

    final String m = cl.getOptionValue(maxSplitsOpt.getOpt());
    final int maxSplits = m == null ? 0 : Integer.parseInt(m);
    final boolean encode = cl.hasOption(base64Opt.getOpt());
    final boolean verbose = cl.hasOption(verboseOpt.getOpt());
   
    final PrintLine p = outputFile == null ? new PrintShell(shellState.getReader()) : new PrintFile(outputFile);
   
    try {
      if (!verbose) {
        for (Text row : maxSplits > 0 ? shellState.getConnector().tableOperations().listSplits(tableName, maxSplits) : shellState.getConnector()
            .tableOperations().listSplits(tableName)) {
View Full Code Here

    final String m = cl.getOptionValue(maxSplitsOpt.getOpt());
    final int maxSplits = m == null ? 0 : Integer.parseInt(m);
    final boolean encode = cl.hasOption(base64Opt.getOpt());
    final boolean verbose = cl.hasOption(verboseOpt.getOpt());
   
    PrintLine p = outputFile == null ? new PrintShell(shellState.getReader()) : new PrintFile(outputFile);
   
    try {
      if (!verbose) {
        for (Text row : maxSplits > 0 ? shellState.getConnector().tableOperations().getSplits(tableName, maxSplits) : shellState.getConnector()
            .tableOperations().getSplits(tableName)) {
View Full Code Here

    final String m = cl.getOptionValue(maxSplitsOpt.getOpt());
    final int maxSplits = m == null ? 0 : Integer.parseInt(m);
    final boolean encode = cl.hasOption(base64Opt.getOpt());
    final boolean verbose = cl.hasOption(verboseOpt.getOpt());
   
    final PrintLine p = outputFile == null ? new PrintShell(shellState.getReader()) : new PrintFile(outputFile);
   
    try {
      if (!verbose) {
        for (Text row : maxSplits > 0 ? shellState.getConnector().tableOperations().listSplits(tableName, maxSplits) : shellState.getConnector()
            .tableOperations().listSplits(tableName)) {
View Full Code Here

TOP

Related Classes of org.apache.accumulo.core.util.shell.Shell.PrintFile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.