/* * Copyright 1999-2006 University of Chicago * * Licensed 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. */ import java.sql.ResultSet; import java.text.NumberFormat; import java.text.DecimalFormat; import java.util.HashMap; import java.util.Map; import java.util.Iterator; import java.util.Date; import java.util.Locale; import java.text.SimpleDateFormat; import java.io.PrintStream; public class ErrorReport{ public static void main (String [] args) throws Exception{ String USAGE = "Usage: java JobFlagReport [options] Enter -help for a list of options\n"; String HELP = "Where [options] are:\n"+ " -help Displays help\n"+ " -step Specifies size of step (day by default)\n"+ " -n Specifies number of steps to do\n"; if (args.length == 0){ System.err.println(USAGE); System.exit(1); } else if (args.length == 1 && args[0].equalsIgnoreCase("-help")){ System.err.println(USAGE); System.err.println(HELP); System.exit(1); } int n = 1; String stepStr = "day"; for (int i=0;i"); DatabaseRetriever dbr = new DatabaseRetriever(); HistogramParser gt2hist = new HistogramParser("Breakdown of GT2 Codes", "gt2histogram", "Jobs with Each Error code", n); HistogramParser faulthist = new HistogramParser("Breakdown of Fault Classes", "faulthistogram", "Number of Jobs with Fault Class", n); while(ts.next()){ Date startTime = ts.getTime(); String startDate = ts.getFormattedTime(); ts.stepTime(); gt2hist.nextEntry(startDate, ts.getFormattedTime()); faulthist.nextEntry(startDate, ts.getFormattedTime()); int totalJobs = 0; int gt2Jobs = 0; int faultJobs = 0; ResultSet rs = dbr.retrieve(new String ("gram_packets"), new String [] {"gt2_error_code","fault_class"}, startTime, ts.getTime()); while (rs.next()){ totalJobs++; if (rs.getInt(1) != 0){ gt2Jobs++; gt2hist.addData(rs.getString(1), 1); } if (rs.getInt(2) != 0){ faultJobs++; faulthist.addData(faultNames[rs.getInt(2)], 1); } } rs.close(); System.out.println(" "); System.out.println("\t" + startDate + ""); System.out.println("\t" + ts.getFormattedTime() + ""); System.out.println("\t"+totalJobs+""); System.out.println("\t"+f.format(100.0*gt2Jobs/totalJobs)+""); System.out.println("\t"+f.format(100.0*faultJobs/totalJobs)+""); System.out.println(" "); } dbr.close(); gt2hist.output(System.out); faulthist.output(System.out); System.out.println(""); } }