List of usage examples for java.lang Throwable Throwable
public Throwable()
From source file:jetbrains.exodus.env.EnvironmentImpl.java
@SuppressWarnings({ "AccessToStaticFieldLockedOnInstance" }) @Override// w w w. j a va 2 s.c o m public void close() { if (configMBean != null) { configMBean.unregister(); } // in order to avoid deadlock, do not finish gc inside lock // it is safe to invoke gc.finish() several times gc.finish(); final double logCacheHitRate; final double storeGetCacheHitRate; final double treeNodesCacheHitRate; synchronized (commitLock) { if (!isOpen()) { throw new IllegalStateException("Already closed, see cause for previous close stack trace", throwableOnClose); } checkInactive(ec.getEnvCloseForcedly()); try { if (!ec.getEnvIsReadonly()) { gc.saveUtilizationProfile(); } ec.removeChangedSettingsListener(envSettingsListener); logCacheHitRate = log.getCacheHitRate(); log.close(); } finally { log.release(); } storeGetCacheHitRate = storeGetCache == null ? 0 : storeGetCache.hitRate(); final LongObjectCacheBase treeNodesCache = this.treeNodesCache == null ? null : this.treeNodesCache.get(); treeNodesCacheHitRate = treeNodesCache == null ? 0 : treeNodesCache.hitRate(); throwableOnClose = new Throwable(); throwableOnCommit = EnvironmentClosedException.INSTANCE; } runAllTransactionSafeTasks(); if (logging.isInfoEnabled()) { logging.info("Store get cache hit rate: " + ObjectCacheBase.formatHitRate(storeGetCacheHitRate)); logging.info("Tree nodes cache hit rate: " + ObjectCacheBase.formatHitRate(treeNodesCacheHitRate)); logging.info("Exodus log cache hit rate: " + ObjectCacheBase.formatHitRate(logCacheHitRate)); } }
From source file:com.krawler.database.DbPool.java
/** * return a connection to use for the Krawler database. * //ww w. ja v a 2s . co m * @param * @return * @throws ServiceException */ public static Connection getConnection() throws ServiceException { java.sql.Connection conn = null; long start = KrawlerPerf.STOPWATCH_DB_CONN.start(); try { conn = sPoolingDataSource.getConnection(); if (conn.getAutoCommit() != false) conn.setAutoCommit(false); // We want READ COMMITTED transaction isolation level for duplicate // handling code in BucketBlobStore.newBlobInfo(). conn.setTransactionIsolation(java.sql.Connection.TRANSACTION_READ_COMMITTED); } catch (SQLException e) { throw ServiceException.FAILURE("getting database connection", e); } // If the connection pool is overutilized, warn about potential leaks int numActive = sConnectionPool.getNumActive(); int maxActive = sConnectionPool.getMaxActive(); if (numActive > maxActive * 0.75) { String stackTraceMsg = "Turn on debug logging for KrawlerLog.dbconn to see stack " + "traces of connections not returned to the pool."; if (KrawlerLog.dbconn.isDebugEnabled()) { StringBuffer buf = new StringBuffer(); synchronized (sConnectionStackCounter) { Iterator i = sConnectionStackCounter.iterator(); while (i.hasNext()) { String stackTrace = (String) i.next(); int count = sConnectionStackCounter.getCount(stackTrace); if (count == 0) { i.remove(); } else { buf.append(count + " connections allocated at " + stackTrace + "\n"); } } } stackTraceMsg = buf.toString(); } KrawlerLog.dbconn.warn("Connection pool is 75% utilized. " + numActive + " connections out of a maximum of " + maxActive + " in use. " + stackTraceMsg); } if (KrawlerLog.sqltrace.isDebugEnabled() || KrawlerLog.perf.isDebugEnabled()) { // conn = new DebugConnection(conn); //TODO: uncomment later[BS] } Connection krawlerCon = new Connection(conn); // If we're debugging, update the counter with the current stack trace if (KrawlerLog.dbconn.isDebugEnabled()) { Throwable t = new Throwable(); krawlerCon.setStackTrace(t); String stackTrace = SystemUtil.getStackTrace(t); synchronized (sConnectionStackCounter) { sConnectionStackCounter.increment(stackTrace); } } KrawlerPerf.STOPWATCH_DB_CONN.stop(start); return krawlerCon; }
From source file:org.apache.hadoop.raid.LogUtils.java
static public void logFileCheckMetrics(LOGRESULTS result, Codec codec, Path srcPath, FileSystem fs, long offset, long limit, Throwable ex, Progressable context) { LOGTYPES type = LOGTYPES.TOOL_FILECHECK; try {/*from w ww. j av a 2 s .c o m*/ incrLogMetricCounter(context, fs, type, result, codec.id); LogSample sample = new LogSample(); sample.addNormalValue(LOGKEYS.Result.name(), result.name()); sample.addNormalValue(LOGKEYS.Code.name(), codec.id); sample.addNormalValue(LOGKEYS.Path.name(), srcPath.toString()); sample.addNormalValue(LOGKEYS.Type.name(), type.name()); sample.addNormalValue(LOGKEYS.Cluster.name(), fs.getUri().getAuthority()); sample.addIntValue(LOGKEYS.Offset.name(), offset); sample.addIntValue(LOGKEYS.Limit.name(), limit); if (ex != null) { sample.addNormalValue(LOGKEYS.Error.name(), StringUtils.stringifyException(ex)); } new Throwable().printStackTrace(); FILECHECK_METRICS_LOG.info(sample.toJSON()); } catch (Exception e) { LOG.warn("Exception when logging the Raid metrics: " + e.getMessage(), e); } }
From source file:org.ebayopensource.turmeric.eclipse.core.logging.SOALogger.java
/** * Warning.//from www.jav a2 s.c o m * * @param messages the messages * @see java.util.logging.Level#WARNING */ public void warning(Object... messages) { StackTraceElement[] elements = new Throwable().getStackTrace(); logp(Level.WARNING, elements[1].getClassName(), elements[1].getMethodName(), StringUtil.toString(messages)); }
From source file:com.momock.util.Logger.java
public static void error(String msg) { if (!enabled || logLevel > LEVEL_ERROR) return;// www . ja v a2 s .c o m if (msg == null) msg = ""; Throwable t = new Throwable(); StackTraceElement trace = t.getStackTrace()[1]; android.util.Log.e(logName, msg + " @ " + getSourceInfo(trace)); checkLogFile(); logStream.println(getLog("ERROR", msg)); logStream.flush(); event.fireEvent(null, new LogEventArgs(msg, null)); }
From source file:org.ebayopensource.turmeric.eclipse.core.logging.SOALogger.java
/** * Warning./*w w w . j a v a 2s . c o m*/ * * @param cause the cause * @param messages The warning messages * @see java.util.logging.Level#WARNING */ public void warning(Throwable cause, Object... messages) { StackTraceElement[] elements = new Throwable().getStackTrace(); logp(Level.WARNING, elements[1].getClassName(), elements[1].getMethodName(), StringUtil.toString(messages), cause); }
From source file:com.sun.grizzly.http.jk.common.JniHandler.java
/** send and get the response in the same buffer. This calls the * method on the wrapped jk_bean object. *///from w w w . j a v a 2 s . c om protected int nativeDispatch(Msg msg, MsgContext ep, int code, int raw) throws IOException { if (LoggerUtils.getLogger().isLoggable(Level.FINEST)) { LoggerUtils.getLogger().log(Level.FINEST, "Sending packet " + code + " " + raw); } if (raw == 0) { msg.end(); } // Create ( or reuse ) the jk_endpoint ( the native pair of // MsgContext ) long xEnv = ep.getJniEnv(); long nativeContext = ep.getJniContext(); if (nativeContext == 0 || xEnv == 0) { setNativeEndpoint(ep); xEnv = ep.getJniEnv(); nativeContext = ep.getJniContext(); } if (xEnv == 0 || nativeContext == 0 || nativeJkHandlerP == 0) { LoggerUtils.getLogger().log(Level.SEVERE, "invokeNative: Null pointer "); return -1; } // Will process the message in the current thread. // No wait needed to receive the response, if any int status = AprImpl.jkInvoke(xEnv, nativeJkHandlerP, nativeContext, code, msg.getBuffer(), 0, msg.getLen(), raw); if (status != 0 && status != 2) { LoggerUtils.getLogger().log(Level.SEVERE, "nativeDispatch: error " + status, new Throwable()); } if (LoggerUtils.getLogger().isLoggable(Level.FINEST)) { LoggerUtils.getLogger().log(Level.FINEST, "Sending packet - done " + status); } return status; }
From source file:org.alfresco.repo.node.integrity.IntegrityChecker.java
/** * Ensures that this service is registered with the transaction and saves the event * //from w w w . ja v a 2 s . c o m * @param event IntegrityEvent */ @SuppressWarnings("unchecked") private void save(IntegrityEvent event) { // optionally set trace if (traceOn) { // get a stack trace Throwable t = new Throwable(); t.fillInStackTrace(); StackTraceElement[] trace = t.getStackTrace(); event.addTrace(trace); // done } // register this service AlfrescoTransactionSupport.bindIntegrityChecker(this); // get the event list Map<IntegrityEvent, IntegrityEvent> events = (Map<IntegrityEvent, IntegrityEvent>) AlfrescoTransactionSupport .getResource(KEY_EVENT_SET); if (events == null) { events = new HashMap<IntegrityEvent, IntegrityEvent>(113, 0.75F); AlfrescoTransactionSupport.bindResource(KEY_EVENT_SET, events); } // check if the event is present IntegrityEvent existingEvent = events.get(event); if (existingEvent != null) { // the event (or its equivalent is already present - transfer the trace if (traceOn) { existingEvent.getTraces().addAll(event.getTraces()); } } else { // the event doesn't already exist events.put(event, event); } if (logger.isDebugEnabled()) { logger.debug("" + (existingEvent != null ? "Event already present in" : "Added event to") + " event set: \n" + " event: " + event); } }
From source file:org.ebayopensource.turmeric.eclipse.core.logging.SOALogger.java
/** * <p>This method will work if the <code>WARNING</code> logging level is enabled.</p> * @param message The message/*from w w w. jav a2s . c o m*/ * @param cause The cause of the problem * @see java.util.logging.Level#WARNING */ public void warning(Object message, Throwable cause) { StackTraceElement[] elements = new Throwable().getStackTrace(); logp(Level.WARNING, elements[1].getClassName(), elements[1].getMethodName(), String.valueOf(message), cause); }
From source file:org.coconut.core.LoggersTest.java
@Test public void testToHandler() { final org.apache.commons.logging.Log log = context.mock(org.apache.commons.logging.Log.class); final Throwable t = new Throwable(); context.checking(new Expectations() { {/*from ww w . jav a2 s. c om*/ one(log).debug("a"); one(log).debug("b", t); one(log).error("c"); one(log).error("d", t); one(log).fatal("e"); one(log).fatal("f", t); one(log).info("g"); one(log).info("h", t); one(log).trace("i"); one(log).trace("j", t); one(log).warn("k"); one(log).warn("l", t); one(log).isDebugEnabled(); will(returnValue(true)); one(log).isErrorEnabled(); will(returnValue(true)); one(log).isFatalEnabled(); will(returnValue(true)); one(log).isInfoEnabled(); will(returnValue(true)); one(log).isTraceEnabled(); will(returnValue(true)); one(log).isWarnEnabled(); will(returnValue(true)); } }); runMock(Loggers.Commons.from(log), t); }