Java Code Examples for org.apache.commons.lang.exception.ExceptionUtils#getFullStackTrace()

The following examples show how to use org.apache.commons.lang.exception.ExceptionUtils#getFullStackTrace() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FederatedWorkerHandler.java    From systemds with Apache License 2.0 6 votes vote down vote up
private FederatedResponse constructResponse(FederatedRequest request) {
	FederatedRequest.FedMethod method = request.getMethod();
	try {
		switch (method) {
			case READ:
				return readMatrix(request);
			case MATVECMULT:
				return executeMatVecMult(request);
			case TRANSFER:
				return getVariableData(request);
			case AGGREGATE:
				return executeAggregation(request);
			case SCALAR:
				return executeScalarOperation(request);
			default:
				String message = String.format("Method %s is not supported.", method);
				return new FederatedResponse(FederatedResponse.Type.ERROR, message);
		}
	}
	catch (Exception exception) {
		return new FederatedResponse(FederatedResponse.Type.ERROR, ExceptionUtils.getFullStackTrace(exception));
	}
}
 
Example 2
Source File: ExceptionNotificationServiceImpl.java    From telekom-workflow-engine with MIT License 6 votes vote down vote up
public void handleException( Exception exception ){
    if( isServiceEnabled() ){
        Date now = new Date();
        newExceptionsCount.incrementAndGet();

        if( nextPossibleNotification.before( now ) ){
            int count = newExceptionsCount.getAndSet( 0 );

            String subject = count + " exception(s) occured in " + mailEnvironment + " Workflow Engine";
            String body = ""
                    + count + " exception(s) occured with ip " + getHostIpAddress() + ". \n"
                    + "\n"
                    + "The most recent exception occured at " + format( now ) + " with the following stacktrace:\n"
                    + "\n"
                    + ExceptionUtils.getFullStackTrace( exception );

            sendEmail( mailFrom, recipients, subject, body );

            nextPossibleNotification = DateUtils.addMinutes( now, notificationIntervalMinutes );
        }
    }
}
 
Example 3
Source File: FederatedResponse.java    From systemds with Apache License 2.0 5 votes vote down vote up
public String getErrorMessage() {
	if (_data[0] instanceof Throwable )
		return ExceptionUtils.getFullStackTrace( (Throwable) _data[0] );
	else if (_data[0] instanceof String)
		return (String) _data[0];
	else return "No readable error message";
}
 
Example 4
Source File: CompactionAuditCountVerifier.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
/**
 * Verify a specific dataset by following below steps
 *    1) Retrieve a tier-to-count mapping
 *    2) Read count from {@link CompactionAuditCountVerifier#gobblinTier}
 *    3) Read count from all other {@link CompactionAuditCountVerifier#referenceTiers}
 *    4) Compare count retrieved from steps 2) and 3), if any of (gobblin/refenence) >= threshold, return true, else return false
 * @param dataset Dataset needs to be verified
 * @return If verification is succeeded
 */
public Result verify (FileSystemDataset dataset) {
  if (!enabled) {
    return new Result(true, "");
  }
  if (auditCountClient == null) {
    log.debug("No audit count client specified, skipped");
    return new Result(true, "");
  }

  CompactionPathParser.CompactionParserResult result = new CompactionPathParser(state).parse(dataset);
  ZonedDateTime startTime = ZonedDateTime.ofInstant(Instant.ofEpochMilli(result.getTime().getMillis()), zone);
  ZonedDateTime endTime = TimeIterator.inc(startTime, granularity, 1);
  String datasetName = result.getDatasetName();
  try {
    Map<String, Long> countsByTier = auditCountClient.fetch(datasetName,
        startTime.toInstant().toEpochMilli(), endTime.toInstant().toEpochMilli());
    for (String tier: referenceTiers) {
      Result rst = passed (datasetName, countsByTier, tier);
      if (rst.isSuccessful()) {
        return new Result(true, "");
      }
    }
  } catch (IOException e) {
    return new Result(false, ExceptionUtils.getFullStackTrace(e));
  }

  return new Result(false, String.format("%s data is not complete between %s and %s", datasetName, startTime, endTime));
}
 
Example 5
Source File: CompactionThresholdVerifier.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
/**
 * There are two record count we are comparing here
 *    1) The new record count in the input folder
 *    2) The record count we compacted previously from last run
 * Calculate two numbers difference and compare with a predefined threshold.
 *
 * (Alternatively we can save the previous record count to a state store. However each input
 * folder is a dataset. We may end up with loading too many redundant job level state for each
 * dataset. To avoid scalability issue, we choose a stateless approach where each dataset tracks
 * record count by themselves and persist it in the file system)
 *
 * @return true iff the difference exceeds the threshold or this is the first time compaction
 */
public Result verify(FileSystemDataset dataset) {

  Map<String, Double> thresholdMap = RecompactionConditionBasedOnRatio.
      getDatasetRegexAndRecompactThreshold(
          state.getProp(MRCompactor.COMPACTION_LATEDATA_THRESHOLD_FOR_RECOMPACT_PER_DATASET, StringUtils.EMPTY));

  CompactionPathParser.CompactionParserResult result = new CompactionPathParser(state).parse(dataset);

  double threshold =
      RecompactionConditionBasedOnRatio.getRatioThresholdByDatasetName(result.getDatasetName(), thresholdMap);
  log.debug("Threshold is {} for dataset {}", threshold, result.getDatasetName());

  InputRecordCountHelper helper = new InputRecordCountHelper(state);
  try {
    double newRecords = 0;
    if (!dataset.isVirtual()) {
      newRecords = helper.calculateRecordCount(Lists.newArrayList(new Path(dataset.datasetURN())));
    }
    double oldRecords = helper.readRecordCount(new Path(result.getDstAbsoluteDir()));

    if (oldRecords == 0) {
      return new Result(true, "");
    }
    if (newRecords < oldRecords) {
      return new Result(false, "Illegal state: Current records count should old be smaller.");
    }

    if ((newRecords - oldRecords) / oldRecords > threshold) {
      log.debug("Dataset {} records exceeded the threshold {}", dataset.datasetURN(), threshold);
      return new Result(true, "");
    }

    return new Result(false, String
        .format("%s is failed for dataset %s. Prev=%f, Cur=%f, not reaching to threshold %f", this.getName(),
            result.getDatasetName(), oldRecords, newRecords, threshold));
  } catch (IOException e) {
    return new Result(false, ExceptionUtils.getFullStackTrace(e));
  }
}
 
Example 6
Source File: XmlIngesterServiceImpl.java    From rice with Educational Community License v2.0 5 votes vote down vote up
private static void addProcessingException(XmlDoc xmlDoc, String message, Throwable t) {
    String msg = xmlDoc.getProcessingMessage();
    if (msg == null) {
        msg = "";
    }
    msg += message + "\n" + ExceptionUtils.getFullStackTrace(t);
    xmlDoc.setProcessingMessage(msg);
}
 
Example 7
Source File: XmlDigesterServiceImpl.java    From rice with Educational Community License v2.0 5 votes vote down vote up
private static void addProcessingException(XmlDoc xmlDoc, String message, Throwable t) {
    String msg = xmlDoc.getProcessingMessage();
    if (msg == null) {
        msg = "";
    }
    msg += message + "\n" + ExceptionUtils.getFullStackTrace(t);
    xmlDoc.setProcessingMessage(msg);
}
 
Example 8
Source File: TaskExceptionProbeIndex.java    From DataLink with Apache License 2.0 4 votes vote down vote up
private String buildExceptionInfo(Throwable t) {
    return ExceptionUtils.getFullStackTrace(t);
}
 
Example 9
Source File: ComplianceUtils.java    From scim2-compliance-test-suite with Apache License 2.0 4 votes vote down vote up
public static Wire getWire(Throwable e) {
    return new Wire(ExceptionUtils.getFullStackTrace(e), "", "");
}
 
Example 10
Source File: ComplienceUtils.java    From scim2-compliance-test-suite with Apache License 2.0 4 votes vote down vote up
public static Wire getWire(Throwable e) {
    return new Wire(ExceptionUtils.getFullStackTrace(e), "");
}
 
Example 11
Source File: ExtensionLoader.java    From tddl5 with Apache License 2.0 4 votes vote down vote up
private static <S> S loadFile(Class<S> service, String activateName, ClassLoader loader) {
    try {
        boolean foundFromCache = true;
        List<Class> extensions = providers.get(service);
        if (extensions == null) {
            synchronized (service) {
                extensions = providers.get(service);
                if (extensions == null) {
                    extensions = findAllExtensionClass(service, activateName, loader);
                    foundFromCache = false;
                    providers.put(service, extensions);
                }
            }
        }

        // 为避免被覆盖,每个activateName的查找,允许再加一层子目录
        if (StringUtils.isNotEmpty(activateName)) {
            loadFile(service, TDDL_DIRECTORY + activateName.toLowerCase() + "/", loader, extensions);

            List<Class> activateExtensions = new ArrayList<Class>();
            for (int i = 0; i < extensions.size(); i++) {
                Class clz = extensions.get(i);
                Activate activate = (Activate) clz.getAnnotation(Activate.class);
                if (activate != null && activateName.equals(activate.name())) {
                    activateExtensions.add(clz);
                }
            }

            extensions = activateExtensions;
        }

        if (extensions.isEmpty()) {
            throw new ExtensionNotFoundException("not found service provider for : " + service.getName() + "["
                                                 + activateName + "] and classloader : "
                                                 + ObjectUtils.toString(loader));
        }
        Class<?> extension = extensions.get(extensions.size() - 1);// 最大的一个
        S result = service.cast(extension.newInstance());
        if (!foundFromCache && logger.isInfoEnabled()) {
            logger.info("load " + service.getSimpleName() + "[" + activateName + "] extension by class["
                        + extension.getName() + "]");
        }
        return result;
    } catch (Throwable e) {
        if (e instanceof ExtensionNotFoundException) {
            throw (ExtensionNotFoundException) e;
        } else {
            throw new ExtensionNotFoundException("not found service provider for : " + service.getName()
                                                 + " caused by " + ExceptionUtils.getFullStackTrace(e));
        }
    }
}
 
Example 12
Source File: ExceptionErrorCodeUtils.java    From tddl5 with Apache License 2.0 4 votes vote down vote up
public static String exceptionToString(Throwable ex) {
    return ExceptionUtils.getFullStackTrace(ex);
}
 
Example 13
Source File: BodyHttpServlet.java    From hop with Apache License 2.0 4 votes vote down vote up
public void doGet( HttpServletRequest request, HttpServletResponse response ) throws IOException {
  if ( isJettyMode() && !request.getContextPath().startsWith( getContextPath() ) ) {
    return;
  }

  if ( log.isDebug() ) {
    logDebug( messages.getString( "Log.Execute" ) );
  }

  boolean useXML = useXML( request );
  PrintWriter out = new PrintWriter( response.getOutputStream() );

  try {

    if ( useXML ) {
      startXml( response, out );
    } else {
      beginHtml( response, out );
    }

    WebResult result = generateBody( request, response, useXML );
    if ( result != null ) {
      out.println( result.getXml() );
    }

  } catch ( Exception e ) {
    String st = ExceptionUtils.getFullStackTrace( e );
    if ( useXML ) {
      out.println( new WebResult( WebResult.STRING_ERROR, st ).getXml() );
    } else {
      out.println( "<p><pre>" );
      out.println( Encode.forHtml( st ) );
      out.println( "</pre>" );
    }
  } finally {
    if ( !useXML ) {
      endHtml( out );
    }
    out.flush();
    IOUtils.closeQuietly( out );
  }
}
 
Example 14
Source File: ExtensionLoader.java    From tddl with Apache License 2.0 4 votes vote down vote up
private static <S> List<Class> findAllExtensionClass(Class<S> service, String activateName, ClassLoader loader) {
    List<Class> extensions = Lists.newArrayList();
    try {
        loadFile(service, SERVICES_DIRECTORY, loader, extensions);
        loadFile(service, TDDL_DIRECTORY, loader, extensions);
    } catch (IOException e) {
        throw new ExtensionNotFoundException("not found service provider for : " + service.getName()
                                             + " caused by " + ExceptionUtils.getFullStackTrace(e));
    }

    if (extensions.isEmpty()) {
        return extensions;
    }

    // 做一下排序
    Collections.sort(extensions, new Comparator<Class>() {

        public int compare(Class c1, Class c2) {
            Integer o1 = 0;
            Integer o2 = 0;
            Activate a1 = (Activate) c1.getAnnotation(Activate.class);
            Activate a2 = (Activate) c2.getAnnotation(Activate.class);

            if (a1 != null) {
                o1 = a1.order();
            }

            if (a2 != null) {
                o2 = a2.order();
            }

            return o1.compareTo(o2);

        }
    });

    if (activateName != null) { // 如果有激活条件
        for (int i = extensions.size() - 1; i >= 0; i--) {
            Class clz = extensions.get(i);
            Activate activate = (Activate) clz.getAnnotation(Activate.class);
            if (activate != null && activateName.equals(activate.name())) {
                return Arrays.asList(clz);
            }
        }

        throw new ExtensionNotFoundException("not found service provider for : " + service.getName()
                                             + " activateName : " + activateName);
    } else {
        return extensions;
    }

}
 
Example 15
Source File: Result.java    From honeydew with MIT License 4 votes vote down vote up
public Result(String errorMessage, Throwable exception) {
    this(errorMessage);
    this.stackTrace = ExceptionUtils.getFullStackTrace(exception);
}
 
Example 16
Source File: BodyHttpServlet.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public void doGet( HttpServletRequest request, HttpServletResponse response ) throws IOException {
  if ( isJettyMode() && !request.getContextPath().startsWith( getContextPath() ) ) {
    return;
  }

  if ( log.isDebug() ) {
    logDebug( messages.getString( "Log.Execute" ) );
  }

  boolean useXML = useXML( request );
  PrintWriter out = new PrintWriter( response.getOutputStream() );

  try {

    if ( useXML ) {
      startXml( response, out );
    } else {
      beginHtml( response, out );
    }

    WebResult result = generateBody( request, response, useXML );
    if ( result != null ) {
      out.println( result.getXML() );
    }

  } catch ( Exception e ) {
    String st = ExceptionUtils.getFullStackTrace( e );
    if ( useXML ) {
      out.println( new WebResult( WebResult.STRING_ERROR, st ).getXML() );
    } else {
      out.println( "<p><pre>" );
      out.println( Encode.forHtml( st ) );
      out.println( "</pre>" );
    }
  } finally {
    if ( !useXML ) {
      endHtml( out );
    }
    out.flush();
    IOUtils.closeQuietly( out );
  }
}
 
Example 17
Source File: MCUtil.java    From Kettle with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Quickly generate a stack trace for current location
 *
 * @return Stacktrace
 */
public static String stack() {
    return ExceptionUtils.getFullStackTrace(new Throwable());
}
 
Example 18
Source File: MCUtil.java    From Kettle with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Quickly generate a stack trace for current location with message
 *
 * @param str
 * @return Stacktrace
 */
public static String stack(String str) {
    return ExceptionUtils.getFullStackTrace(new Throwable(str));
}