List of usage examples for java.lang RuntimeException printStackTrace
public void printStackTrace()
From source file:org.nebulaframework.grid.cluster.manager.services.jobs.ResultCollectionSupport.java
/** * Adds a failure to the failure trace of the * given worker node./*from www .ja v a2s. c o m*/ * * @param workerId Worker UUID */ protected void addFailureTrace(UUID workerId) { synchronized (failureTrace) { // If first consecutive failure if (!failureTrace.containsKey(workerId)) { failureTrace.put(workerId, 1); } else { // Increment failures int count = failureTrace.get(workerId) + 1; // If fails > MAX if (count > MAX_CONSECUTIVE_NODE_FAILS) { // Add to banned list try { profile.addBannedNode(workerId); } catch (RuntimeException e1) { e1.printStackTrace(); } String msgBody = workerId + "#" + profile.getJobId(); // Send banned message ServiceMessage message = new ServiceMessage(msgBody, ServiceMessageType.NODE_BANNED); try { ServiceMessageSender sender = ClusterManager.getInstance().getServiceMessageSender(); sender.sendServiceMessage(message); log.warn("[JobService] Failing GridNode Banned : " + workerId); } catch (Exception e) { log.error("Error Sending Message", e); } } failureTrace.put(workerId, count); } } }
From source file:com.qmetry.qaf.automation.ui.selenium.SeleniumCommandProcessor.java
private void invokeBeforeCommand(SeleniumCommandTracker commandTracker) { if (!invokingListener) { invokingListener = true;/*from w ww . jav a 2 s.c om*/ for (SeleniumCommandListener listener : commandListeners) { try { listener.beforeCommand(this, commandTracker); } catch (RuntimeException e) { e.printStackTrace(); } } invokingListener = false; } }
From source file:org.apache.sysml.utils.GenerateClassesForMLContext.java
/** * Generate convenience classes recursively. This allows for code such as * {@code ml.scripts.algorithms...}.// www . java2 s . co m * * @param dirPath * path to directory * @return the full name of the class representing the dirPath directory */ public static String recurseDirectoriesForConvenienceClassGeneration(String dirPath) { try { File dir = new File(dirPath); String fullDirClassName = dirPathToFullDirClassName(dirPath); System.out.println("Generating Class: " + fullDirClassName); ClassPool pool = ClassPool.getDefault(); CtClass ctDir = pool.makeClass(fullDirClassName); File[] subdirs = dir.listFiles(new FileFilter() { @Override public boolean accept(File f) { return f.isDirectory(); } }); for (File subdir : subdirs) { String subDirPath = dirPath + File.separator + subdir.getName(); if (skipDir(subdir, false)) { continue; } String fullSubDirClassName = recurseDirectoriesForConvenienceClassGeneration(subDirPath); CtClass subDirClass = pool.get(fullSubDirClassName); String subDirName = subdir.getName(); subDirName = subDirName.replaceAll("-", "_"); subDirName = subDirName.toLowerCase(); System.out.println("Adding " + subDirName + "() to " + fullDirClassName); String methodBody = "{ " + fullSubDirClassName + " z = new " + fullSubDirClassName + "(); return z; }"; CtMethod ctMethod = CtNewMethod.make(Modifier.PUBLIC, subDirClass, subDirName, null, null, methodBody, ctDir); ctDir.addMethod(ctMethod); } File[] scriptFiles = dir.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return (name.toLowerCase().endsWith(".dml") || name.toLowerCase().endsWith(".pydml")); } }); for (File scriptFile : scriptFiles) { String scriptFilePath = scriptFile.getPath(); String fullScriptClassName = BASE_DEST_PACKAGE + "." + scriptFilePathToFullClassNameNoBase(scriptFilePath); CtClass scriptClass = pool.get(fullScriptClassName); String methodName = scriptFilePathToSimpleClassName(scriptFilePath); String methodBody = "{ " + fullScriptClassName + " z = new " + fullScriptClassName + "(); return z; }"; CtMethod ctMethod = CtNewMethod.make(Modifier.PUBLIC, scriptClass, methodName, null, null, methodBody, ctDir); ctDir.addMethod(ctMethod); } ctDir.writeFile(destination); return fullDirClassName; } catch (RuntimeException e) { e.printStackTrace(); } catch (CannotCompileException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (NotFoundException e) { e.printStackTrace(); } return null; }
From source file:com.qmetry.qaf.automation.ui.selenium.SeleniumCommandProcessor.java
private void invokeAfterCommand(SeleniumCommandTracker commandTracker) { if (!invokingListener) { invokingListener = true;/*from w w w .j av a 2s .c o m*/ for (SeleniumCommandListener listener : commandListeners) { try { listener.afterCommand(this, commandTracker); } catch (SeleniumException ex) { ex.printStackTrace(); } catch (RuntimeException e) { e.printStackTrace(); } } invokingListener = false; } }
From source file:org.apache.sysml.utils.GenerateClassesForMLContext.java
/** * Create a class that encapsulates the outputs of a function. * /*from w w w .java 2 s . c o m*/ * @param scriptFilePath * the path to a script file * @param fs * a SystemML function statement */ public static void createFunctionOutputClass(String scriptFilePath, FunctionStatement fs) { try { ArrayList<DataIdentifier> oparams = fs.getOutputParams(); // Note: if a function returns 1 output, simply output it rather // than encapsulating it in a function output class if ((oparams.size() == 0) || (oparams.size() == 1)) { return; } String fullFunctionOutputClassName = getFullFunctionOutputClassName(scriptFilePath, fs); System.out.println("Generating Class: " + fullFunctionOutputClassName); ClassPool pool = ClassPool.getDefault(); CtClass ctFuncOut = pool.makeClass(fullFunctionOutputClassName); // add fields for (int i = 0; i < oparams.size(); i++) { DataIdentifier oparam = oparams.get(i); String type = getParamTypeAsString(oparam); String name = oparam.getName(); String fstring = "public " + type + " " + name + ";"; CtField field = CtField.make(fstring, ctFuncOut); ctFuncOut.addField(field); } // add constructor String simpleFuncOutClassName = fullFunctionOutputClassName .substring(fullFunctionOutputClassName.lastIndexOf(".") + 1); StringBuilder con = new StringBuilder(); con.append("public " + simpleFuncOutClassName + "("); for (int i = 0; i < oparams.size(); i++) { if (i > 0) { con.append(", "); } DataIdentifier oparam = oparams.get(i); String type = getParamTypeAsString(oparam); String name = oparam.getName(); con.append(type + " " + name); } con.append(") {\n"); for (int i = 0; i < oparams.size(); i++) { DataIdentifier oparam = oparams.get(i); String name = oparam.getName(); con.append("this." + name + "=" + name + ";\n"); } con.append("}\n"); String cstring = con.toString(); CtConstructor ctCon = CtNewConstructor.make(cstring, ctFuncOut); ctFuncOut.addConstructor(ctCon); // add toString StringBuilder s = new StringBuilder(); s.append("public String toString(){\n"); s.append("StringBuilder sb = new StringBuilder();\n"); for (int i = 0; i < oparams.size(); i++) { DataIdentifier oparam = oparams.get(i); String name = oparam.getName(); s.append("sb.append(\"" + name + " (" + getSimpleParamTypeAsString(oparam) + "): \" + " + name + " + \"\\n\");\n"); } s.append("String str = sb.toString();\nreturn str;\n"); s.append("}\n"); String toStr = s.toString(); CtMethod toStrMethod = CtNewMethod.make(toStr, ctFuncOut); ctFuncOut.addMethod(toStrMethod); ctFuncOut.writeFile(destination); } catch (RuntimeException e) { e.printStackTrace(); } catch (CannotCompileException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.jfaker.framework.security.web.UserController.java
public void dologin() { String error = ""; String username = getPara("user.username"); String password = getPara("user.password"); if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password)) { error = "???"; }/*from w w w . j a va2s.co m*/ if (StringUtils.isEmpty(error)) { Subject subject = SecurityUtils.getSubject(); UsernamePasswordToken token = new UsernamePasswordToken(username, password); try { subject.login(token); } catch (UnknownAccountException ue) { token.clear(); error = "??"; } catch (IncorrectCredentialsException ie) { ie.printStackTrace(); token.clear(); error = "???"; } catch (RuntimeException re) { re.printStackTrace(); token.clear(); error = ""; } } if (StringUtils.isEmpty(error)) { redirect("/"); } else { keepModel(User.class); setAttr("error", error); render("login.jsp"); } }
From source file:com.qmetry.qaf.automation.ui.selenium.webdriver.QAFWebDriverCommandProcessor.java
private void invokeBeforeCommand(SeleniumCommandTracker commandTracker) { if (!invokingListener) { invokingListener = true;/*www. jav a 2 s . co m*/ for (SeleniumCommandListener listener : commandListeners) { try { listener.beforeCommand(this, commandTracker); } catch (RuntimeException e) { e.printStackTrace(); } } invokingListener = false; } }
From source file:com.qmetry.qaf.automation.ui.selenium.webdriver.QAFWebDriverCommandProcessor.java
private void invokeAfterCommand(SeleniumCommandTracker commandTracker) { if (!invokingListener) { invokingListener = true;//from w w w . j av a2s . co m for (SeleniumCommandListener listener : commandListeners) { try { listener.afterCommand(this, commandTracker); } catch (RuntimeException e) { e.printStackTrace(); } } invokingListener = false; } }
From source file:org.openflexo.foundation.resource.ResourceManager.java
public void deleteFilesToBeDeleted() { for (File f : filesToDelete) { try {/* w w w . ja v a 2s . c o m*/ if (FileUtils.recursiveDeleteFile(f)) { if (logger.isLoggable(Level.INFO)) { logger.info("Successfully deleted " + f.getAbsolutePath()); // filesToDelete.remove(f); } } else if (logger.isLoggable(Level.WARNING)) { logger.warning("Could not delete " + f.getAbsolutePath()); } } catch (RuntimeException e) { e.printStackTrace(); if (logger.isLoggable(Level.WARNING)) { logger.warning("Could not delete " + f.getAbsolutePath()); } } } filesToDelete.clear(); }
From source file:it.greenvulcano.util.xpath.search.jaxen.JaxenXPathAPIImpl.java
/** * @see it.greenvulcano.util.xpath.search.XPathAPIImpl#selectNodeList(Object, * Object, Object)// w w w . j a v a 2 s . c o m */ public Object selectNodeList(Object contextNode, Object xpath, Object namespaceNode) throws TransformerException { JaxenXPath lowlevelXPath = (JaxenXPath) xpath; try { CurrentFunction.putCurrent(contextNode); List<Object> list = lowlevelXPath.selectNodes(contextNode); return contextNode instanceof OMNode ? list : new JaxenNodeList((Node) contextNode, list); } catch (JaxenException e) { throw new TransformerException(e); } catch (RuntimeException exc) { exc.printStackTrace(); throw new RuntimeException( "nodeName=" + (contextNode instanceof Node ? ((Node) contextNode).getNodeName() : "unknown") + ", xpath=" + lowlevelXPath.toString(), exc); } finally { CurrentFunction.removeCurrent(); } }