List of usage examples for java.lang StackTraceElement toString
public String toString()
From source file:Main.java
public static void main(String[] args) { Thread t = Thread.currentThread(); StackTraceElement e = t.getStackTrace()[0]; System.out.println(e.toString()); }
From source file:de.uni_potsdam.hpi.bpt.promnicat.importer.ModelImporter.java
/** * Usage: <code>'Path to config' Collection PATH [PATH2 [PATH3] ...]]</code> * </br></br>/* w ww. j a v a 2s. c om*/ * <code>Path to config</code> is a path in file system to the configuration file being used * for import. It can be given relative to the PromniCAT folder.</br> * If an empty string is provided, the default file 'PromniCAT/configuration.properties' is used.</br></br> * <code>Collection</code> is the process model collection and can be one of * 'BPMN', 'NPB', 'SAP_RM' or 'AOK' </br></br> * <code>PATH</code> is a path in file system to a directory containing the models that should be imported. */ public static void main(String[] args) { // wrong number of parameter? if (args.length < 3) { printHelpMessage(); return; } try { //read configuration file IPersistenceApi persistenceApi = new ConfigurationParser(args[0]) .getDbInstance(Constants.DATABASE_TYPES.ORIENT_DB); //import models // BPMAI model? if (args[1].toUpperCase().equals(Constants.ORIGIN_BPMAI)) { startImport(new BpmaiImporter(persistenceApi), args); return; } // NPB model? if (args[1].toUpperCase().equals(Constants.ORIGIN_NPB)) { startImport(new NPBImporter(persistenceApi), args); return; } // SAP_RM model? if (args[1].toUpperCase().equals(Constants.ORIGIN_SAP_RM)) { startImport(new SapReferenceModelImporter(persistenceApi), args); return; } // AOK model? if (args[1].toUpperCase().equals(Constants.ORIGIN_AOK)) { startImport(new AokModelImporter(persistenceApi), args); return; } // wrong argument value printHelpMessage(); throw new IllegalArgumentException(WRONG_USAGE_MESSAGE); } catch (Exception e) { logger.severe(e.getMessage()); String stackTraceString = ""; for (StackTraceElement ste : e.getStackTrace()) { stackTraceString = stackTraceString.concat(ste.toString() + "\n"); } logger.severe(stackTraceString); } }
From source file:UnitTest4.java
public static void main(String args[]) { System.setProperty("org.slf4j.simpleLogger.showDateTime", "true"); System.setProperty("org.slf4j.simpleLogger.showThreadName", "true"); System.setProperty("org.slf4j.simpleLogger.levelInBrackets", "true"); System.setProperty("org.slf4j.simpleLogger.dateTimeFormat", "yyyy-MM-dd HH:mm:ss:SSS Z"); System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "debug"); System.setProperty("org.slf4j.simpleLogger.showLogName", "true"); final Logger log = LoggerFactory.getLogger(UnitTest4.class); UnitTest4.log = log;//from ww w . java 2 s. com System.out.println("hdfjkv \'dfdgdf\'dgdf"); try { throw new Exception(); } catch (Throwable e) { log.debug(e.toString()); //log.debug(" Cause : " + e.getCause().toString()); StackTraceElement stacka[] = e.getStackTrace(); for (StackTraceElement stack : stacka) { log.debug(" StackTrace : " + stack.toString()); } } String a[] = new String[10]; a[0] = "hwedf"; a[6] = "wdeeg"; log.debug("a.toString() : {}", a.toString()); /* List<Integer> list = new ArrayList<Integer>(); for (Integer i : list) { System.out.println(i); } System.out.println("ok"); try { //Test2.execute(); } catch (Exception e) { e.printStackTrace(); } */ }
From source file:voldemort.store.readonly.fetcher.HdfsFetcher.java
public static void main(String[] args) throws Exception { if (args.length < 1) Utils.croak("USAGE: java " + HdfsFetcher.class.getName() + " url [keytab location] [kerberos username] [hadoop-config-path]"); String url = args[0];//from w w w . j av a 2s . co m String keytabLocation = ""; String kerberosUser = ""; String hadoopPath = ""; if (args.length == 4) { keytabLocation = args[1]; kerberosUser = args[2]; hadoopPath = args[3]; } long maxBytesPerSec = 1024 * 1024 * 1024; Path p = new Path(url); final Configuration config = new Configuration(); final URI uri = new URI(url); config.setInt("io.file.buffer.size", VoldemortConfig.DEFAULT_BUFFER_SIZE); config.set("hadoop.rpc.socket.factory.class.ClientProtocol", ConfigurableSocketFactory.class.getName()); config.setInt("io.socket.receive.buffer", 1 * 1024 * 1024 - 10000); FileSystem fs = null; p = new Path(url); HdfsFetcher.keytabPath = keytabLocation; HdfsFetcher.kerberosPrincipal = kerberosUser; boolean isHftpBasedFetch = url.length() > 4 && url.substring(0, 4).equals("hftp"); logger.info("URL : " + url + " and hftp protocol enabled = " + isHftpBasedFetch); if (hadoopPath.length() > 0 && !isHftpBasedFetch) { config.set("hadoop.security.group.mapping", "org.apache.hadoop.security.ShellBasedUnixGroupsMapping"); config.addResource(new Path(hadoopPath + "/core-site.xml")); config.addResource(new Path(hadoopPath + "/hdfs-site.xml")); String security = config.get(CommonConfigurationKeys.HADOOP_SECURITY_AUTHENTICATION); if (security == null || !security.equals("kerberos")) { logger.info("Security isn't turned on in the conf: " + CommonConfigurationKeys.HADOOP_SECURITY_AUTHENTICATION + " = " + config.get(CommonConfigurationKeys.HADOOP_SECURITY_AUTHENTICATION)); logger.info("Fix that. Exiting."); return; } else { logger.info("Security is turned on in the conf. Trying to authenticate ..."); } } try { // Get the filesystem object if (keytabLocation.length() > 0 && !isHftpBasedFetch) { UserGroupInformation.setConfiguration(config); UserGroupInformation.loginUserFromKeytab(kerberosUser, keytabLocation); final Path path = p; try { logger.debug("I've logged in and am now Doasing as " + UserGroupInformation.getCurrentUser().getUserName()); fs = UserGroupInformation.getCurrentUser().doAs(new PrivilegedExceptionAction<FileSystem>() { public FileSystem run() throws Exception { FileSystem fs = path.getFileSystem(config); return fs; } }); } catch (InterruptedException e) { logger.error(e.getMessage()); } catch (Exception e) { logger.error("Got an exception while getting the filesystem object: "); logger.error("Exception class : " + e.getClass()); e.printStackTrace(); for (StackTraceElement et : e.getStackTrace()) { logger.error(et.toString()); } } } else { fs = p.getFileSystem(config); } } catch (IOException e) { e.printStackTrace(); System.err.println("IOException in getting Hadoop filesystem object !!! Exiting !!!"); System.exit(-1); } catch (Throwable te) { te.printStackTrace(); logger.error("Error thrown while trying to get Hadoop filesystem"); System.exit(-1); } FileStatus status = fs.listStatus(p)[0]; long size = status.getLen(); HdfsFetcher fetcher = new HdfsFetcher(null, maxBytesPerSec, VoldemortConfig.REPORTING_INTERVAL_BYTES, VoldemortConfig.DEFAULT_BUFFER_SIZE, 0, keytabLocation, kerberosUser, 5, 5000); long start = System.currentTimeMillis(); File location = fetcher.fetch(url, System.getProperty("java.io.tmpdir") + File.separator + start, hadoopPath); double rate = size * Time.MS_PER_SECOND / (double) (System.currentTimeMillis() - start); NumberFormat nf = NumberFormat.getInstance(); nf.setMaximumFractionDigits(2); System.out.println( "Fetch to " + location + " completed: " + nf.format(rate / (1024.0 * 1024.0)) + " MB/sec."); fs.close(); }
From source file:Main.java
public static String getExceptionStackTrace(Throwable throwable) { if (null == throwable) { return "null"; }//w ww.j a va 2s . c om StringBuilder sb = new StringBuilder(throwable.getMessage()).append("\n"); StackTraceElement[] elements = throwable.getStackTrace(); for (StackTraceElement element : elements) { sb.append(element.toString()).append("\r\n"); } return sb.toString(); }
From source file:Main.java
/** * Gets the stack trace string.// www . j a v a 2 s . c om * * @param e the e * @return the stack trace string */ public static String getStackTraceString(Exception e) { String stackTrace = ""; for (StackTraceElement l : e.getStackTrace()) stackTrace += l.toString(); return stackTrace; }
From source file:Main.java
public static void printStackTrace(StackTraceElement[] trace, PrintStream out) { for (StackTraceElement el : trace) out.println(el.toString()); }
From source file:Main.java
static public void saveCrashTrace(Throwable ex) { StackTraceElement[] elements = ex.getStackTrace(); StringBuilder builder = new StringBuilder(ex.getMessage()); for (StackTraceElement ele : elements) { builder.append('\n').append(ele.toString()); }/*from w w w . ja va 2 s .c o m*/ android.util.Log.e("crash", builder.toString()); }
From source file:Main.java
public static String formatStackTrace(StackTraceElement[] trace) { StringBuilder builder = new StringBuilder(); for (StackTraceElement element : trace) { builder.append(element.toString()); builder.append(NEWLINE);/*from w w w . jav a 2 s .c o m*/ } return builder.toString(); }
From source file:Main.java
public static void printCurrentStackTrace() { for (StackTraceElement ste : Thread.currentThread().getStackTrace()) { Log.i("DEBUG", ste.toString()); }//from ww w. j a v a 2s .c om }