List of usage examples for java.lang.reflect InvocationTargetException toString
public String toString()
From source file:com.strider.datadefender.FileDiscoverer.java
@SuppressWarnings("unchecked") public List<FileMatchMetaData> discover(final Properties fileDiscoveryProperties) throws FileDiscoveryException, DatabaseDiscoveryException, IOException, SAXException, TikaException { log.info("Data discovery in process"); // Get the probability threshold from property file final double probabilityThreshold = parseDouble( fileDiscoveryProperties.getProperty("probability_threshold")); log.info("Probability threshold [" + probabilityThreshold + "]"); // Get list of models used in data discovery final String models = fileDiscoveryProperties.getProperty("models"); modelList = models.split(","); log.info("Model list [" + Arrays.toString(modelList) + "]"); List<FileMatchMetaData> finalList = new ArrayList<>(); for (final String model : modelList) { log.info("********************************"); log.info("Processing model " + model); log.info("********************************"); final Model modelPerson = createModel(fileDiscoveryProperties, model); fileMatches = discoverAgainstSingleModel(fileDiscoveryProperties, modelPerson, probabilityThreshold); finalList = ListUtils.union(finalList, fileMatches); }/* w w w .jav a 2s. c o m*/ // Special case String[] specialCaseFunctions = null; boolean specialCase = false; final String extentionList = fileDiscoveryProperties.getProperty("extentions"); final String directories = fileDiscoveryProperties.getProperty("directories"); final String exclusions = fileDiscoveryProperties.getProperty("exclusions"); String exclusionList[] = null; if ((exclusions == null) || exclusions.equals("")) { log.info("exclusions property is empty in firediscovery.properties file"); } else { exclusionList = exclusions.split(","); log.info("File types not considered for analysis: " + exclusions); } log.info("Directories to analyze: " + directories); if ((directories == null) || directories.equals("")) { log.error("directories property is empty in firediscovery.properties file"); throw new DatabaseDiscoveryException("directories property is empty in firediscovery.properties file"); } final String[] directoryList = directories.split(","); if (!CommonUtils.isEmptyString(extentionList)) { log.info("***** Extension list:" + extentionList); specialCaseFunctions = extentionList.split(","); if ((specialCaseFunctions != null) && (specialCaseFunctions.length > 0)) { log.debug("special case:" + specialCase); File node; Metadata metadata; try { log.info("**************" + specialCaseFunctions.toString()); for (int j = 0; j < specialCaseFunctions.length; j++) { for (final String directory : directoryList) { node = new File(directory); final List<File> files = (List<File>) FileUtils.listFiles(node, null, true); for (final File fich : files) { final String file = fich.getName(); final String recursivedir = fich.getParent(); log.info("Analyzing [" + fich.getCanonicalPath() + "]"); final String ext = CommonUtils.getFileExtension(fich).toLowerCase(Locale.ENGLISH); log.debug("Extension: " + ext); if ((exclusionList != null) && Arrays.asList(exclusionList).contains(ext)) { log.info("Ignoring type " + ext); continue; } final BodyContentHandler handler = new BodyContentHandler(-1); final AutoDetectParser parser = new AutoDetectParser(); metadata = new Metadata(); String handlerString = ""; try { final InputStream stream = new FileInputStream(fich.getCanonicalPath()); log.debug("Loading data into the stream"); if (stream != null) { parser.parse(stream, handler, metadata); handlerString = handler.toString().replaceAll("( )+", " ") .replaceAll("[\\t\\n\\r]+", " "); String[] tokens = handlerString.split(" "); for (int t = 0; t < tokens.length; t++) { String token = tokens[t]; if (token.trim().length() < 1) { continue; } String specialFunction = specialCaseFunctions[j]; log.info(specialFunction); FileMatchMetaData returnData = null; try { returnData = (FileMatchMetaData) callExtention( new FileMatchMetaData(recursivedir, file), specialFunction, token); } catch (InvocationTargetException e) { continue; } if (returnData != null) { returnData.setModel("sin"); returnData.setAverageProbability(1.0); List<FileMatchMetaData> specialFileMatches = new ArrayList(); specialFileMatches.add(returnData); finalList = ListUtils.union(finalList, specialFileMatches); } log.debug(tokens[t]); } } } catch (IOException e) { log.info("Unable to read " + fich.getCanonicalPath() + ".Ignoring..."); } log.info("Finish processing " + fich.getCanonicalPath()); } log.info("Finish speclai case " + specialCaseFunctions[j]); } } } catch (IOException | IllegalAccessException | IllegalArgumentException | NoSuchMethodException | SecurityException | SQLException | TikaException | SAXException e) { log.error(e.toString()); } } } final DecimalFormat decimalFormat = new DecimalFormat("#.##"); log.info("List of suspects:"); log.info(String.format("%40s %20s %20s %20s", "Directory*", "File*", "Probability*", "Model*")); finalList = uniqueList(finalList); Collections.sort(finalList, Comparator.comparing(FileMatchMetaData::getFileName)); for (final FileMatchMetaData data : finalList) { String result = ""; final String probability = decimalFormat.format(data.getAverageProbability()); result = String.format("%40s %20s %20s %20s", data.getDirectory(), data.getFileName(), probability, data.getModel()); log.info(result); } return Collections.unmodifiableList(fileMatches); }
From source file:org.apache.hadoop.hbase.ipc.ScheduleHBaseServer.java
@Override public Writable call(Writable param, long receivedTime) throws IOException { try {/*w w w . jav a 2 s . c om*/ Invocation call = (Invocation) param; if (call.getMethodName() == null) { throw new IOException("Could not find requested method, the usual " + "cause is a version mismatch between client and server."); } Method method = implementation.getMethod(call.getMethodName(), call.getParameterClasses()); long startTime = System.currentTimeMillis(); Object value = method.invoke(instance, call.getParameters()); /** * do with openScanner option, added by ScheduleHBaseServer */ if (call.getMethodName().endsWith("openScanner")) { this.initScannerPri(call, value); } int processingTime = (int) (System.currentTimeMillis() - startTime); int qTime = (int) (startTime - receivedTime); if (LOG.isDebugEnabled()) { LOG.debug("Served: " + call.getMethodName() + " queueTime= " + qTime + " procesingTime= " + processingTime); } rpcMetrics.rpcQueueTime.inc(qTime); rpcMetrics.rpcProcessingTime.inc(processingTime); rpcMetrics.inc(call.getMethodName(), processingTime); return new HbaseObjectWritable(method.getReturnType(), value); } catch (InvocationTargetException e) { Throwable target = e.getTargetException(); if (target instanceof IOException) { throw (IOException) target; } IOException ioe = new IOException(target.toString()); ioe.setStackTrace(target.getStackTrace()); throw ioe; } catch (Throwable e) { IOException ioe = new IOException(e.toString()); ioe.setStackTrace(e.getStackTrace()); throw ioe; } }