Example usage for java.lang Exception getMessage

List of usage examples for java.lang Exception getMessage

Introduction

In this page you can find the example usage for java.lang Exception getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.joseflavio.iperoxo.IpeRoxo.java

/**
 * Mtodo inicial.//  www  .  j a v  a  2 s.  co m
 */
public static void main(String[] args) {

    try {

        log.info(getMensagem(null, "Log.Inicio"));

        executarConfiguracaoGeral();
        executarConfiguracao(args);
        executarFonteDeDados();

        if (Boolean.parseBoolean(getPropriedade("IpeRoxo.FinalizarAposDataSource"))) {
            log.info(getMensagem(null, "Log.FinalizandoAposDataSource"));
            System.exit(0);
        }

        executarInicializacao();
        executarCopaiba();

    } catch (Exception e) {
        log.error(e.getMessage(), e);
        System.exit(1);
    }

}

From source file:edu.lternet.pasta.doi.EzidRegistrar.java

/**
 * @param args/*from   w w  w  .j a  va2s  .c o m*/
 */
public static void main(String[] args) {

    EzidRegistrar ezidRegistrar = null;

    try {
        ezidRegistrar = new EzidRegistrar();
        ezidRegistrar.obsoleteDoi("doi:10.6073/pasta/dcbd7c1aab57af6a65672aa917bb3faf");
    } catch (Exception e) {
        logger.error(e.getMessage());
        e.printStackTrace();
    }

}

From source file:apps.quantification.LearnQuantificationSVMPerf.java

public static void main(String[] args) throws IOException {
    String cmdLineSyntax = LearnQuantificationSVMPerf.class.getName()
            + " [OPTIONS] <path to svm_perf_learn> <path to svm_perf_classify> <trainingIndexDirectory> <outputDirectory>";

    Options options = new Options();

    OptionBuilder.withArgName("f");
    OptionBuilder.withDescription("Number of folds");
    OptionBuilder.withLongOpt("f");
    OptionBuilder.isRequired(true);//from  w  ww.j av  a 2 s . co  m
    OptionBuilder.hasArg();
    options.addOption(OptionBuilder.create());

    OptionBuilder.withArgName("c");
    OptionBuilder.withDescription("The c value for svm_perf (default 0.01)");
    OptionBuilder.withLongOpt("c");
    OptionBuilder.isRequired(false);
    OptionBuilder.hasArg();
    options.addOption(OptionBuilder.create());

    OptionBuilder.withArgName("t");
    OptionBuilder.withDescription("Path for temporary files");
    OptionBuilder.withLongOpt("t");
    OptionBuilder.isRequired(false);
    OptionBuilder.hasArg();
    options.addOption(OptionBuilder.create());

    OptionBuilder.withArgName("l");
    OptionBuilder.withDescription("The loss function to optimize (default 2):\n"
            + "               0  Zero/one loss: 1 if vector of predictions contains error, 0 otherwise.\n"
            + "               1  F1: 100 minus the F1-score in percent.\n"
            + "               2  Errorrate: Percentage of errors in prediction vector.\n"
            + "               3  Prec/Rec Breakeven: 100 minus PRBEP in percent.\n"
            + "               4  Prec@p: 100 minus precision at p in percent.\n"
            + "               5  Rec@p: 100 minus recall at p in percent.\n"
            + "               10  ROCArea: Percentage of swapped pos/neg pairs (i.e. 100 - ROCArea).");
    OptionBuilder.withLongOpt("l");
    OptionBuilder.isRequired(false);
    OptionBuilder.hasArg();
    options.addOption(OptionBuilder.create());

    OptionBuilder.withArgName("w");
    OptionBuilder.withDescription("Choice of structural learning algorithm (default 9):\n"
            + "               0: n-slack algorithm described in [2]\n"
            + "               1: n-slack algorithm with shrinking heuristic\n"
            + "               2: 1-slack algorithm (primal) described in [5]\n"
            + "               3: 1-slack algorithm (dual) described in [5]\n"
            + "               4: 1-slack algorithm (dual) with constraint cache [5]\n"
            + "               9: custom algorithm in svm_struct_learn_custom.c");
    OptionBuilder.withLongOpt("w");
    OptionBuilder.isRequired(false);
    OptionBuilder.hasArg();
    options.addOption(OptionBuilder.create());

    OptionBuilder.withArgName("p");
    OptionBuilder.withDescription("The value of p used by the prec@p and rec@p loss functions (default 0)");
    OptionBuilder.withLongOpt("p");
    OptionBuilder.isRequired(false);
    OptionBuilder.hasArg();
    options.addOption(OptionBuilder.create());

    OptionBuilder.withArgName("v");
    OptionBuilder.withDescription("Verbose output");
    OptionBuilder.withLongOpt("v");
    OptionBuilder.isRequired(false);
    OptionBuilder.hasArg(false);
    options.addOption(OptionBuilder.create());

    OptionBuilder.withArgName("s");
    OptionBuilder.withDescription("Don't delete temporary training file in svm_perf format (default: delete)");
    OptionBuilder.withLongOpt("s");
    OptionBuilder.isRequired(false);
    OptionBuilder.hasArg(false);
    options.addOption(OptionBuilder.create());

    SvmPerfLearnerCustomizer classificationLearnerCustomizer = null;
    SvmPerfClassifierCustomizer classificationCustomizer = null;

    int folds = -1;

    GnuParser parser = new GnuParser();
    String[] remainingArgs = null;
    try {
        CommandLine line = parser.parse(options, args);

        remainingArgs = line.getArgs();

        classificationLearnerCustomizer = new SvmPerfLearnerCustomizer(remainingArgs[0]);
        classificationCustomizer = new SvmPerfClassifierCustomizer(remainingArgs[1]);

        folds = Integer.parseInt(line.getOptionValue("f"));

        if (line.hasOption("c"))
            classificationLearnerCustomizer.setC(Float.parseFloat(line.getOptionValue("c")));

        if (line.hasOption("w"))
            classificationLearnerCustomizer.setW(Integer.parseInt(line.getOptionValue("w")));

        if (line.hasOption("p"))
            classificationLearnerCustomizer.setP(Integer.parseInt(line.getOptionValue("p")));

        if (line.hasOption("l"))
            classificationLearnerCustomizer.setL(Integer.parseInt(line.getOptionValue("l")));

        if (line.hasOption("v"))
            classificationLearnerCustomizer.printSvmPerfOutput(true);

        if (line.hasOption("s"))
            classificationLearnerCustomizer.setDeleteTrainingFiles(false);

        if (line.hasOption("t")) {
            classificationLearnerCustomizer.setTempPath(line.getOptionValue("t"));
            classificationCustomizer.setTempPath(line.getOptionValue("t"));
        }

    } catch (Exception exp) {
        System.err.println("Parsing failed.  Reason: " + exp.getMessage());
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(cmdLineSyntax, options);
        System.exit(-1);
    }

    assert (classificationLearnerCustomizer != null);

    if (remainingArgs.length != 4) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(cmdLineSyntax, options);
        System.exit(-1);
    }

    String indexFile = remainingArgs[2];

    File file = new File(indexFile);

    String indexName = file.getName();
    String indexPath = file.getParent();

    String outputPath = remainingArgs[3];

    SvmPerfLearner classificationLearner = new SvmPerfLearner();

    classificationLearner.setRuntimeCustomizer(classificationLearnerCustomizer);

    FileSystemStorageManager fssm = new FileSystemStorageManager(indexPath, false);
    fssm.open();

    IIndex training = TroveReadWriteHelper.readIndex(fssm, indexName, TroveContentDBType.Full,
            TroveClassificationDBType.Full);

    final TextualProgressBar progressBar = new TextualProgressBar("Learning the quantifiers");

    IOperationStatusListener status = new IOperationStatusListener() {

        @Override
        public void operationStatus(double percentage) {
            progressBar.signal((int) percentage);
        }
    };

    QuantificationLearner quantificationLearner = new QuantificationLearner(folds, classificationLearner,
            classificationLearnerCustomizer, classificationCustomizer, ClassificationMode.PER_CATEGORY,
            new LogisticFunction(), status);

    IQuantifier[] quantifiers = quantificationLearner.learn(training);

    File executableFile = new File(classificationLearnerCustomizer.getSvmPerfLearnPath());
    IDataManager classifierDataManager = new SvmPerfDataManager(new SvmPerfClassifierCustomizer(
            executableFile.getParentFile().getAbsolutePath() + Os.pathSeparator() + "svm_perf_classify"));
    String description = "_SVMPerf_C-" + classificationLearnerCustomizer.getC() + "_W-"
            + classificationLearnerCustomizer.getW() + "_L-" + classificationLearnerCustomizer.getL();
    if (classificationLearnerCustomizer.getL() == 4 || classificationLearnerCustomizer.getL() == 5)
        description += "_P-" + classificationLearnerCustomizer.getP();
    if (classificationLearnerCustomizer.getAdditionalParameters().length() > 0)
        description += "_" + classificationLearnerCustomizer.getAdditionalParameters();
    String quantifierPrefix = indexName + "_Quantifier-" + folds + description;

    FileSystemStorageManager fssmo = new FileSystemStorageManager(
            outputPath + File.separatorChar + quantifierPrefix, true);
    fssmo.open();
    QuantificationLearner.write(quantifiers, fssmo, classifierDataManager);
    fssmo.close();

    BufferedWriter bfs = new BufferedWriter(
            new FileWriter(outputPath + File.separatorChar + quantifierPrefix + "_rates.txt"));
    TShortDoubleHashMap simpleTPRs = quantificationLearner.getSimpleTPRs();
    TShortDoubleHashMap simpleFPRs = quantificationLearner.getSimpleFPRs();
    TShortDoubleHashMap scaledTPRs = quantificationLearner.getScaledTPRs();
    TShortDoubleHashMap scaledFPRs = quantificationLearner.getScaledFPRs();

    ContingencyTableSet contingencyTableSet = quantificationLearner.getContingencyTableSet();

    short[] cats = simpleTPRs.keys();
    for (int i = 0; i < cats.length; ++i) {
        short cat = cats[i];
        String catName = training.getCategoryDB().getCategoryName(cat);
        ContingencyTable contingencyTable = contingencyTableSet.getCategoryContingencyTable(cat);
        double simpleTPR = simpleTPRs.get(cat);
        double simpleFPR = simpleFPRs.get(cat);
        double scaledTPR = scaledTPRs.get(cat);
        double scaledFPR = scaledFPRs.get(cat);
        String line = quantifierPrefix + "\ttrain\tsimple\t" + catName + "\t" + cat + "\t"
                + contingencyTable.tp() + "\t" + contingencyTable.fp() + "\t" + contingencyTable.fn() + "\t"
                + contingencyTable.tn() + "\t" + simpleTPR + "\t" + simpleFPR + "\n";
        bfs.write(line);
        line = quantifierPrefix + "\ttrain\tscaled\t" + catName + "\t" + cat + "\t" + contingencyTable.tp()
                + "\t" + contingencyTable.fp() + "\t" + contingencyTable.fn() + "\t" + contingencyTable.tn()
                + "\t" + scaledTPR + "\t" + scaledFPR + "\n";
        bfs.write(line);
    }
    bfs.close();
}

From source file:org.openiot.gsn.utils.VSMonitor.java

public static void main(String[] args) {

    PropertyConfigurator.configure(DEFAULT_GSN_LOG4J_PROPERTIES);
    String configFileName;/*ww w.ja  v a 2  s.  co  m*/

    if (args.length >= 2) {
        configFileName = args[0];
        System.out.println("Using config file: " + configFileName);
        for (int i = 1; i < args.length; i++) {
            System.out.println("Adding e-mail: " + args[i]);
            listOfMails.add(args[i]);
        }
    } else {
        System.out.println("Usage java -jar VSMonitor.jar <config_file> <list_of_mails>");
        System.out.println("e.g.  java -jar VSMonitor.jar conf/monitoring.cfg user@gmail.com admin@gmail.com");
        return;
    }

    initFromFile(configFileName);

    // for each monitored GSN server
    Iterator iter = listOfGSNSessions.iterator();
    while (iter.hasNext()) {

        try {
            readStatus((GSNSessionAddress) iter.next());
        } catch (Exception e) {
            logger.error("Exception: " + e.getMessage());
            logger.error("StackTrace:\n" + getStackTrace(e));
        }
    }

    checkUpdateTimes();

    // Generate Report
    report.append("\n[ERROR]\n" + errorsBuffer).append("\n[WARNING]\n" + warningsBuffer)
            .append("\n[INFO]\n" + infosBuffer);

    if ((nSensorsLate > 0) || (nHostsDown > 0)) {
        summary.append("WARNING: ");
        if (nHostsDown > 0)
            summary.append(nHostsDown + " host(s) down. ");
        if (nSensorsLate > 0)
            summary.append(nSensorsLate + " sensor(s) not updated. ");

        // Send e-mail only if there are errors
        try {
            sendMail();
        } catch (EmailException e) {
            logger.error("Cannot send e-mail. " + e.getMessage());
            logger.error("StackTrace:\n" + getStackTrace(e));
        }
    }

    // Showing report
    System.out.println(summary);
    System.out.println(report);
}

From source file:gsn.utils.VSMonitor.java

public static void main(String[] args) {

    String configFileName;//from   w  w  w  .  j av  a 2s.c om

    if (args.length >= 2) {
        configFileName = args[0];
        System.out.println("Using config file: " + configFileName);
        for (int i = 1; i < args.length; i++) {
            System.out.println("Adding e-mail: " + args[i]);
            listOfMails.add(args[i]);
        }
    } else {
        System.out.println("Usage java -jar VSMonitor.jar <config_file> <list_of_mails>");
        System.out.println("e.g.  java -jar VSMonitor.jar conf/monitoring.cfg user@gmail.com admin@gmail.com");
        return;
    }

    initFromFile(configFileName);

    // for each monitored GSN server
    Iterator iter = listOfGSNSessions.iterator();
    while (iter.hasNext()) {

        try {
            readStatus((GSNSessionAddress) iter.next());
        } catch (Exception e) {
            logger.error("Exception: " + e.getMessage());
            logger.error("StackTrace:\n" + getStackTrace(e));
        }
    }

    checkUpdateTimes();

    // Generate Report
    report.append("\n[ERROR]\n" + errorsBuffer).append("\n[WARNING]\n" + warningsBuffer)
            .append("\n[INFO]\n" + infosBuffer);

    if ((nSensorsLate > 0) || (nHostsDown > 0)) {
        summary.append("WARNING: ");
        if (nHostsDown > 0)
            summary.append(nHostsDown + " host(s) down. ");
        if (nSensorsLate > 0)
            summary.append(nSensorsLate + " sensor(s) not updated. ");

        // Send e-mail only if there are errors
        try {
            sendMail();
        } catch (EmailException e) {
            logger.error("Cannot send e-mail. " + e.getMessage());
            logger.error("StackTrace:\n" + getStackTrace(e));
        }
    }

    // Showing report
    System.out.println(summary);
    System.out.println(report);
}

From source file:aula1.Aula1.java

/**
 * @param args the command line arguments
 *//* ww w . java  2s  .  c  o m*/
public static void main(String[] args) {
    Scanner dados = new Scanner(System.in);
    int escolha;
    double ini;
    double fim;
    String exp;
    String info;
    int sens = 0;
    boolean valida = true;

    do {
        System.out.println(
                "Decida a operao: 0 para montar grfico, 1 para calcular limite, 2 para calcular qualquer expresso");
        escolha = dados.nextInt();
        switch (escolha) {
        case 0:
            System.out.println("Informe o inicio do dominio");
            ini = dados.nextDouble();
            System.out.println("Informe o fim do dominio");
            fim = dados.nextDouble();
            System.out.println("Informe a quantidade de casas decimais desejadas: ");
            sens = dados.nextInt();
            System.out.println("Informe a expresso: ");
            exp = dados.next();
            double[] x = montaDominio(ini, fim, sens);
            calcula(x, exp);
            valida = false;
            break;
        case 1:
            System.out.println("Informe a expresso: ");
            exp = dados.next();
            System.out.println("Informe o ponto limite: ");
            info = dados.next();
            try {
                calculaLimite(exp, info);
            } catch (Exception ex) {
                System.out
                        .println("Erro: " + ex.getMessage() + "Tentativade aplcao do teorema do confronto");

            }
            valida = false;
            break;
        case 2:
            System.out.println("Informe a expresso:");
            info = dados.next();
            try {
                System.out.println(conversor(info, "0"));
            } catch (Exception ex) {
                System.out.println("Erro: " + ex.getMessage());
            }
            valida = false;
            break;
        default:
            System.out.println("Escolha invlida!");
            break;
        }
    } while (valida);

    //        Double[] vet = new Double[3];         
    //        vet = lerDados();
    //        montaDominio(vet[0], vet[1], vet[2].intValue());
    //        calculaLimite(3);
}

From source file:com.boundary.sdk.event.EventCLI.java

/**
 * Main entry point of the Event CLI.//from w w  w.  ja  v  a  2 s. c o m
 * 
 * @param args Command line arguments
 */
public static void main(String[] args) {
    EventCLI cli = new EventCLI();
    try {
        String eventId = cli.execute(args);

        if (eventId != null) {
            System.out.println(eventId);
        }
    } catch (Exception e) {
        LOG.error("{}", e.getMessage());
    }
}

From source file:de.prozesskraft.pkraft.Commitit.java

public static void main(String[] args) throws org.apache.commons.cli.ParseException, IOException {

    //      try/* w  ww  .  j  a  v a  2 s.  c  o  m*/
    //      {
    //         if (args.length != 3)
    //         {
    //            System.out.println("Please specify processdefinition file (xml) and an outputfilename");
    //         }
    //         
    //      }
    //      catch (ArrayIndexOutOfBoundsException e)
    //      {
    //         System.out.println("***ArrayIndexOutOfBoundsException: Please specify processdefinition.xml, openoffice_template.od*, newfile_for_processdefinitions.odt\n" + e.toString());
    //      }

    /*----------------------------
      get options from ini-file
    ----------------------------*/
    java.io.File inifile = new java.io.File(
            WhereAmI.getInstallDirectoryAbsolutePath(Commitit.class) + "/" + "../etc/pkraft-commitit.ini");

    if (inifile.exists()) {
        try {
            ini = new Ini(inifile);
        } catch (InvalidFileFormatException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
    } else {
        System.err.println("ini file does not exist: " + inifile.getAbsolutePath());
        System.exit(1);
    }

    /*----------------------------
      create boolean options
    ----------------------------*/
    Option ohelp = new Option("help", "print this message");

    /*----------------------------
      create argument options
    ----------------------------*/
    Option oinstance = OptionBuilder.withArgName("FILE").hasArg()
            .withDescription("[mandatory] process instance file")
            //            .isRequired()
            .create("instance");

    Option ostep = OptionBuilder.withArgName("STEPNAME").hasArg()
            .withDescription("[optional, default: root] process step to commit to")
            //            .isRequired()
            .create("step");

    Option ofile = OptionBuilder.withArgName("FILE").hasArg()
            .withDescription("[optional] this file will be committed as file. key will be set to 'default'")
            //            .isRequired()
            .create("file");

    Option okey = OptionBuilder.withArgName("KEY").hasArg()
            .withDescription(
                    "[optional, default: default] this string will be considered as the key for the commit.")
            //            .isRequired()
            .create("key");

    Option ovariable = OptionBuilder.withArgName("VALUE").hasArg()
            .withDescription("[optional] this string will be committed as a variable.")
            //            .isRequired()
            .create("variable");

    /*----------------------------
      create options object
    ----------------------------*/
    Options options = new Options();

    options.addOption(ohelp);
    options.addOption(oinstance);
    options.addOption(ostep);
    options.addOption(ofile);
    options.addOption(okey);
    options.addOption(ovariable);

    /*----------------------------
      create the parser
    ----------------------------*/
    CommandLineParser parser = new GnuParser();
    try {
        // parse the command line arguments
        commandline = parser.parse(options, args);

    } catch (Exception exp) {
        // oops, something went wrong
        System.err.println("Parsing failed. Reason: " + exp.getMessage());
        exiter();
    }

    /*----------------------------
      usage/help
    ----------------------------*/
    if (commandline.hasOption("help")) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("commit", options);
        System.exit(0);
    }

    /*----------------------------
      ueberpruefen ob eine schlechte kombination von parametern angegeben wurde
    ----------------------------*/
    if (!(commandline.hasOption("instance"))) {
        System.out.println("option -instance is mandatory.");
        exiter();
    }

    else if (!(commandline.hasOption("dir")) && !(commandline.hasOption("file"))
            && !(commandline.hasOption("varfile")) && !(commandline.hasOption("varname"))
            && !(commandline.hasOption("varvalue")) && !(commandline.hasOption("variable"))) {
        System.out.println(
                "at least one of these options needed. -dir -file -varfile -variable -varname -varvalue.");
        exiter();
    }

    else if ((commandline.hasOption("varname") && !(commandline.hasOption("varvalue")))
            || (!(commandline.hasOption("varname")) && commandline.hasOption("varvalue"))) {
        System.out.println("use options -varname and -varvalue only in combination with each other.");
        exiter();
    }

    /*----------------------------
      die lizenz ueberpruefen und ggf abbrechen
    ----------------------------*/

    // check for valid license
    ArrayList<String> allPortAtHost = new ArrayList<String>();
    allPortAtHost.add(ini.get("license-server", "license-server-1"));
    allPortAtHost.add(ini.get("license-server", "license-server-2"));
    allPortAtHost.add(ini.get("license-server", "license-server-3"));

    MyLicense lic = new MyLicense(allPortAtHost, "1", "user-edition", "0.1");

    // lizenz-logging ausgeben
    for (String actLine : (ArrayList<String>) lic.getLog()) {
        System.err.println(actLine);
    }

    // abbruch, wenn lizenz nicht valide
    if (!lic.isValid()) {
        System.exit(1);
    }

    /*----------------------------
      die eigentliche business logic
    ----------------------------*/

    // setzen des steps
    String stepname = "root";
    if (commandline.hasOption("step")) {
        stepname = commandline.getOptionValue("step");
    }

    // setzen des key
    String key = "default";
    if (commandline.hasOption("key")) {
        key = commandline.getOptionValue("key");
    }

    Process p1 = new Process();

    p1.setInfilebinary(commandline.getOptionValue("instance"));
    System.out.println("info: reading process instance " + commandline.getOptionValue("instance"));
    Process p2 = p1.readBinary();
    p2.setOutfilebinary(commandline.getOptionValue("instance"));

    // step ueber den namen heraussuchen
    Step step = p2.getStep(stepname);
    if (step == null) {
        System.err.println("step not found: " + stepname);
        exiter();
    }

    // den Commit 'by-process-commitit' heraussuchen oder einen neuen Commit dieses Namens erstellen
    Commit commit = step.getCommit("by-hand");
    if (commit == null) {
        commit = new Commit(step);
        commit.setName("by-process-commitit");
    }

    // committen
    if (commandline.hasOption("file")) {
        File file = new File();
        file.setKey(key);
        file.setGlob(commandline.getOptionValue("file"));
        commit.addFile(file);
        commit.doIt();
    }

    if (commandline.hasOption("variable")) {
        Variable variable = new Variable();
        variable.setKey(key);
        variable.setValue(commandline.getOptionValue("variable"));
        commit.addVariable(variable);
        commit.doIt();
    }

    p2.writeBinary();
    System.out.println("info: writing process instance " + p2.getOutfilebinary());

}

From source file:com.bah.applefox.main.Ingest.java

public static void main(String[] args) throws Exception {

    if (args.length == 1 && args[0].equals("--help")) {
        System.out.println("Not enough arguments");
        System.out.println("Arguments should be in the format <properties file> <command>");
        System.out.println("Valid commands:");
        System.out.println("\tpr: Calculates Page Rank");
        System.out.println("\timageload: Loads Images from URLs");
        System.out.println("\tload: Loads Full Text Data");
        System.out.println("\tingest: Ingests URLs from given seed");
        System.out.println("\tftsample: Creates a Full Text Index Sample HashMap");
        System.out.println("\timagesample: Creates an Image Hash and Image Tag Sample HashMap");
    }/*  ww  w.j ava  2s  .  c o  m*/
    if (args.length > 2) {
        System.out.println("2 Arguments expected, " + args.length + " given.");
    }

    if (args.length < 2) {
        System.out.println("Not enough arguments");
        System.out.println("Arguments should be in the format <properties file> <command>");
        System.out.println("Valid commands:");
        System.out.println("\tpr: Calculates Page Rank");
        System.out.println("\timageload: Loads Images from URLs");
        System.out.println("\tload: Loads Full Text Data");
        System.out.println("\tingest: Ingests URLs from given seed");
        System.out.println("\tftsample: Creates a Full Text Index Sample HashMap");
        System.out.println("\timagesample: Creates an Image Hash and Image Tag Sample HashMap");
    }
    injector = Guice.createInjector(new IngesterModule());

    // The properties object to read from the configuration file
    Properties properties = new Properties();

    try {
        // Load configuration file from the command line
        properties.load(new FileInputStream(args[0]));
    } catch (Exception e) {
        log.error("ABORT: File not found or could not read from file ->" + e.getMessage());
        log.error("Enter the location of the configuration file");
        System.exit(1);
    }

    // Initialize variables from configuration file

    // Accumulo Variables
    INSTANCE_NAME = properties.getProperty("INSTANCE_NAME");
    ZK_SERVERS = properties.getProperty("ZK_SERVERS");
    USERNAME = properties.getProperty("USERNAME");
    PASSWORD = properties.getProperty("PASSWORD");
    SPLIT_SIZE = properties.getProperty("SPLIT_SIZE");
    NUM_ITERATIONS = Integer.parseInt(properties.getProperty("NUM_ITERATIONS"));
    NUM_NODES = Integer.parseInt(properties.getProperty("NUM_NODES"));

    // General Search Variables
    MAX_NGRAMS = Integer.parseInt(properties.getProperty("MAX_NGRAMS"));
    GENERAL_STOP = properties.getProperty("GENERAL_STOP");

    // Full Text Variables
    FT_DATA_TABLE = properties.getProperty("FT_DATA_TABLE");
    FT_SAMPLE = properties.getProperty("FT_SAMPLE");
    FT_CHECKED_TABLE = properties.getProperty("FT_CHECKED_TABLE");
    FT_DIVS_FILE = properties.getProperty("FT_DIVS_FILE");
    FT_SPLIT_SIZE = properties.getProperty("FT_SPLIT_SIZE");

    // Web Crawler Variables
    URL_TABLE = properties.getProperty("URL_TABLE");
    SEED = properties.getProperty("SEED");
    USER_AGENT = properties.getProperty("USER_AGENT");
    URL_SPLIT_SIZE = properties.getProperty("URL_SPLIT_SIZE");

    // Page Rank Variables
    PR_TABLE_PREFIX = properties.getProperty("PR_TABLE_PREFIX");
    PR_URL_MAP_TABLE_PREFIX = properties.getProperty("PR_URL_MAP_TABLE_PREFIX");
    PR_OUT_LINKS_COUNT_TABLE = properties.getProperty("PR_OUT_LINKS_COUNT_TABLE");
    PR_FILE = properties.getProperty("PR_FILE");
    PR_DAMPENING_FACTOR = Double.parseDouble(properties.getProperty("PR_DAMPENING_FACTOR"));
    PR_ITERATIONS = Integer.parseInt(properties.getProperty("PR_ITERATIONS"));
    PR_SPLIT_SIZE = properties.getProperty("PR_SPLIT_SIZE");

    // Image Variables
    IMG_HASH_TABLE = properties.getProperty("IMG_HASH_TABLE");
    IMG_CHECKED_TABLE = properties.getProperty("IMG_CHECKED_TABLE");
    IMG_TAG_TABLE = properties.getProperty("IMG_TAG_TABLE");
    IMG_HASH_SAMPLE_TABLE = properties.getProperty("IMG_HASH_SAMPLE_TABLE");
    IMG_TAG_SAMPLE_TABLE = properties.getProperty("IMG_TAG_SAMPLE_TABLE");
    IMG_SPLIT_SIZE = properties.getProperty("IMG_SPLIT_SIZE");

    // Future Use:
    // Work Directory in HDFS
    WORK_DIR = properties.getProperty("WORK_DIR");

    // Initialize variable from command line
    RUN = args[1].toLowerCase();

    // Set the instance information for AccumuloUtils
    AccumuloUtils.setInstanceName(INSTANCE_NAME);
    AccumuloUtils.setInstancePassword(PASSWORD);
    AccumuloUtils.setUser(USERNAME);
    AccumuloUtils.setZooserver(ZK_SERVERS);
    AccumuloUtils.setSplitSize(SPLIT_SIZE);

    String[] temp = new String[25];

    // Accumulo Variables
    temp[0] = INSTANCE_NAME;
    temp[1] = ZK_SERVERS;
    temp[2] = USERNAME;
    temp[3] = PASSWORD;

    // Number of Map Tasks
    temp[4] = Integer.toString((int) Math.ceil(1.75 * NUM_NODES * 2));

    // Web Crawler Variables
    temp[5] = URL_TABLE;
    temp[6] = USER_AGENT;

    // Future Use
    temp[7] = WORK_DIR;

    // General Search
    temp[8] = GENERAL_STOP;
    temp[9] = Integer.toString(MAX_NGRAMS);

    // Full Text Variables
    temp[10] = FT_DATA_TABLE;
    temp[11] = FT_CHECKED_TABLE;

    // Page Rank Variables
    temp[12] = PR_URL_MAP_TABLE_PREFIX;
    temp[13] = PR_TABLE_PREFIX;
    temp[14] = Double.toString(PR_DAMPENING_FACTOR);
    temp[15] = PR_OUT_LINKS_COUNT_TABLE;
    temp[16] = PR_FILE;

    // Image Variables
    temp[17] = IMG_HASH_TABLE;
    temp[18] = IMG_CHECKED_TABLE;
    temp[19] = IMG_TAG_TABLE;

    temp[20] = FT_DIVS_FILE;

    // Table Split Sizes
    temp[21] = FT_SPLIT_SIZE;
    temp[22] = IMG_SPLIT_SIZE;
    temp[23] = URL_SPLIT_SIZE;
    temp[24] = PR_SPLIT_SIZE;

    if (RUN.equals("pr")) {
        // Run PR_ITERATIONS number of iterations for page ranking
        PageRank.createPageRank(temp, PR_ITERATIONS, URL_SPLIT_SIZE);
    } else if (RUN.equals("imageload")) {
        // Load image index
        AccumuloUtils.setSplitSize(URL_SPLIT_SIZE);
        ToolRunner.run(new ImageLoader(), temp);
    } else if (RUN.equals("ingest")) {
        // Ingest
        System.out.println("Ingesting");
        // Set table split size
        AccumuloUtils.setSplitSize(URL_SPLIT_SIZE);
        // Write the seed value to the table
        BatchWriter w;
        Value v = new Value();
        v.set("0".getBytes());
        Mutation m = new Mutation(SEED);
        m.put("0", "0", v);
        w = AccumuloUtils.connectBatchWrite(URL_TABLE);
        w.addMutation(m);

        for (int i = 0; i < NUM_ITERATIONS; i++) {
            // Run the ToolRunner for NUM_ITERATIONS iterations
            ToolRunner.run(CachedConfiguration.getInstance(), injector.getInstance(Ingester.class), temp);
        }
    } else if (RUN.equals("load")) {
        // Parse the URLs and add to the data table
        AccumuloUtils.setSplitSize(URL_SPLIT_SIZE);
        BatchWriter w = AccumuloUtils.connectBatchWrite(FT_CHECKED_TABLE);
        w.close();

        AccumuloUtils.setSplitSize(FT_SPLIT_SIZE);
        w = AccumuloUtils.connectBatchWrite(FT_DATA_TABLE);
        w.close();
        ToolRunner.run(CachedConfiguration.getInstance(), injector.getInstance(Loader.class), temp);
    } else if (RUN.equals("ftsample")) {
        // Create a sample table for full text index
        FTAccumuloSampler ftSampler = new FTAccumuloSampler(FT_SAMPLE, FT_DATA_TABLE, FT_CHECKED_TABLE);
        ftSampler.createSample();

    } else if (RUN.equals("imagesample")) {
        // Create a sample table for images
        ImageAccumuloSampler imgHashSampler = new ImageAccumuloSampler(IMG_HASH_SAMPLE_TABLE, IMG_HASH_TABLE,
                IMG_CHECKED_TABLE);
        imgHashSampler.createSample();

        ImageAccumuloSampler imgTagSampler = new ImageAccumuloSampler(IMG_TAG_SAMPLE_TABLE, IMG_TAG_TABLE,
                IMG_CHECKED_TABLE);
        imgTagSampler.createSample();
    } else {
        System.out.println("Invalid argument " + RUN + ".");
        System.out.println("Valid Arguments:");
        System.out.println("\tpr: Calculates Page Rank");
        System.out.println("\timageload: Loads Images from URLs");
        System.out.println("\tload: Loads Full Text Data");
        System.out.println("\tingest: Ingests URLs from given seed");
        System.out.println("\tftsample: Creates a Full Text Index Sample HashMap");
        System.out.println("\timagesample: Creates an Image Hash and Image Tag Sample HashMap");
    }

}