Return-Path: X-Original-To: apmail-logging-commits-archive@minotaur.apache.org Delivered-To: apmail-logging-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2726F10084 for ; Tue, 30 Jul 2013 18:20:58 +0000 (UTC) Received: (qmail 91981 invoked by uid 500); 30 Jul 2013 18:20:58 -0000 Delivered-To: apmail-logging-commits-archive@logging.apache.org Received: (qmail 91939 invoked by uid 500); 30 Jul 2013 18:20:55 -0000 Mailing-List: contact commits-help@logging.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@logging.apache.org Delivered-To: mailing list commits@logging.apache.org Received: (qmail 91926 invoked by uid 99); 30 Jul 2013 18:20:53 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Jul 2013 18:20:53 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Jul 2013 18:20:48 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 0ADFE2388900; Tue, 30 Jul 2013 18:20:27 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1508572 - in /logging/log4j/log4j2/trunk: flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/ samples/flume-common/src/main/java/org/apache/logging/log4j/samples/app/ src/changes/ Date: Tue, 30 Jul 2013 18:20:26 -0000 To: commits@logging.apache.org From: rgoers@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20130730182027.0ADFE2388900@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: rgoers Date: Tue Jul 30 18:20:26 2013 New Revision: 1508572 URL: http://svn.apache.org/r1508572 Log: LOG4J2-328 - FlumePersistentManager was calling Berkeley DB's count method too frequently Modified: logging/log4j/log4j2/trunk/flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumePersistentManager.java logging/log4j/log4j2/trunk/samples/flume-common/src/main/java/org/apache/logging/log4j/samples/app/LoggingController.java logging/log4j/log4j2/trunk/src/changes/changes.xml Modified: logging/log4j/log4j2/trunk/flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumePersistentManager.java URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumePersistentManager.java?rev=1508572&r1=1508571&r2=1508572&view=diff ============================================================================== --- logging/log4j/log4j2/trunk/flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumePersistentManager.java (original) +++ logging/log4j/log4j2/trunk/flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumePersistentManager.java Tue Jul 30 18:20:26 2013 @@ -437,7 +437,8 @@ public class FlumePersistentManager exte long nextBatch = System.currentTimeMillis() + manager.delay; while (!shutdown) { long now = System.currentTimeMillis(); - if (database.count() >= batchSize || (database.count() > 0 && nextBatch < now)) { + long dbCount = database.count(); + if (dbCount >= batchSize || (dbCount > 0 && nextBatch < now)) { nextBatch = now + manager.delay; try { boolean errors = false; @@ -546,7 +547,7 @@ public class FlumePersistentManager exte LOGGER.warn("WriterThread encountered an exception. Continuing.", ex); } } else { - while (!shutdown && (database.count() == 0 || database.count() < batchSize && nextBatch > now)) { + while (!shutdown && (dbCount == 0 || dbCount < batchSize && nextBatch > now)) { try { final long interval = nextBatch - now; gate.waitForOpen(interval, TimeUnit.MILLISECONDS); @@ -557,7 +558,8 @@ public class FlumePersistentManager exte break; } now = System.currentTimeMillis(); - if (database.count() == 0) { + dbCount = database.count(); + if (!gate.isSignalled()) { nextBatch = now + manager.delay; } } Modified: logging/log4j/log4j2/trunk/samples/flume-common/src/main/java/org/apache/logging/log4j/samples/app/LoggingController.java URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/samples/flume-common/src/main/java/org/apache/logging/log4j/samples/app/LoggingController.java?rev=1508572&r1=1508571&r2=1508572&view=diff ============================================================================== --- logging/log4j/log4j2/trunk/samples/flume-common/src/main/java/org/apache/logging/log4j/samples/app/LoggingController.java (original) +++ logging/log4j/log4j2/trunk/samples/flume-common/src/main/java/org/apache/logging/log4j/samples/app/LoggingController.java Tue Jul 30 18:20:26 2013 @@ -49,13 +49,30 @@ public class LoggingController { private final Random ran = new Random(); private List events; + private int timeBase = 1000; @RequestMapping(value = "/start.do", method = RequestMethod.GET) public ModelAndView startLogging( @RequestParam(value = "member", required = false, defaultValue = "fakemember") final String member, + @RequestParam(value = "interval", required = false, defaultValue = "1000") final String interval, + @RequestParam(value = "threads", required = false, defaultValue = "1") final String threadCount, final HttpServletRequest servletRequest) { - - System.out.println("STARTING.................."); + int numThreads = 1; + if (threadCount != null && threadCount.length() > 0) { + try { + numThreads = Integer.parseInt(threadCount); + } catch (Exception ex) { + System.out.println("Invalid threadCount specified: " + threadCount); + } + } + if (interval != null && interval.length() > 0) { + try { + timeBase = Integer.parseInt(interval); + } catch (Exception ex) { + System.out.println("Invalid interval specified: " + interval); + } + } + System.out.println("STARTING - Using " + numThreads + " threads at interval: " + timeBase); if (events == null) { events = MockEventsSupplier.getAllEvents(member); @@ -63,52 +80,54 @@ public class LoggingController { generateLog = true; - (new Thread() { + for (int i = 0; i < numThreads; ++i) { + (new Thread() { - @Override - public void run() { - ThreadContext.clear(); - - RequestContext.setSessionId("session1234"); - RequestContext.setIpAddress("127.0.0.1"); - RequestContext.setClientId("02121"); - RequestContext.setProductName("IB"); - RequestContext.setProductVersion("4.18.1"); - RequestContext.setLocale("en_US"); - RequestContext.setRegion("prod"); - while (generateLog) { - // Generate rand number between 1 to 10 - final int rand = ran.nextInt(9) + 1; - - // Sleep for rand seconds - try { - Thread.sleep(rand * 1000); - } catch (final InterruptedException e) { - logger.warn("WARN", e); - } + @Override + public void run() { + ThreadContext.clear(); + + RequestContext.setSessionId("session1234"); + RequestContext.setIpAddress("127.0.0.1"); + RequestContext.setClientId("02121"); + RequestContext.setProductName("IB"); + RequestContext.setProductVersion("4.18.1"); + RequestContext.setLocale("en_US"); + RequestContext.setRegion("prod"); + while (generateLog) { + // Generate rand number between 1 to 10 + final int rand = ran.nextInt(9) + 1; + + // Sleep for rand seconds + try { + Thread.sleep(rand * timeBase); + } catch (final InterruptedException e) { + logger.warn("WARN", e); + } - // Write rand number of logs - for (int i = 0; i < rand; i++) { - final int eventIndex = (Math.abs(ran.nextInt())) % events.size(); - final AuditEvent event = events.get(eventIndex); - RequestContext.setUserId(member); - event.logEvent(); - - if ((rand % 4) == 1) { - logger.debug("DEBUG level logging....."); - } else if ((rand % 4) == 2) { - logger.info("INFO level logging....."); - } else if ((rand % 4) == 3) { - logger.warn("WARN level logging....."); - } else { - logger.error("ERROR level logging....."); + // Write rand number of logs + for (int i = 0; i < rand; i++) { + final int eventIndex = (Math.abs(ran.nextInt())) % events.size(); + final AuditEvent event = events.get(eventIndex); + RequestContext.setUserId(member); + event.logEvent(); + + if ((rand % 4) == 1) { + logger.debug("DEBUG level logging....."); + } else if ((rand % 4) == 2) { + logger.info("INFO level logging....."); + } else if ((rand % 4) == 3) { + logger.warn("WARN level logging....."); + } else { + logger.error("ERROR level logging....."); + } } - } + } + ThreadContext.cloneStack(); } - ThreadContext.cloneStack(); - } - }).start(); + }).start(); + } return new ModelAndView("start.jsp"); } Modified: logging/log4j/log4j2/trunk/src/changes/changes.xml URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/changes/changes.xml?rev=1508572&r1=1508571&r2=1508572&view=diff ============================================================================== --- logging/log4j/log4j2/trunk/src/changes/changes.xml (original) +++ logging/log4j/log4j2/trunk/src/changes/changes.xml Tue Jul 30 18:20:26 2013 @@ -21,6 +21,9 @@ + + FlumePersistentManager was calling Berkeley DB's count method too frequently. + Update JDBC tests to use H2 database 1.3.173 from 1.3.172.