Skip to content
This repository was archived by the owner on Jun 7, 2023. It is now read-only.

Commit 7c1594c

Browse files
author
Rustam Aliyev
committed
Expose POP3 metrics through JMX. Fixes #33
1 parent c84b0ef commit 7c1594c

File tree

3 files changed

+10
-65
lines changed

3 files changed

+10
-65
lines changed

modules/pop3/src/main/java/com/elasticinbox/pop3/Activator.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import com.ecyrd.speed4j.log.Slf4jLog;
4040
import com.elasticinbox.config.Configurator;
4141
import com.elasticinbox.pop3.server.handler.MailboxHandlerFactory;
42-
import com.elasticinbox.pop3.utils.LoggingPeriodicalLog;
4342

4443
public class Activator implements BundleActivator
4544
{
@@ -62,12 +61,12 @@ public void start(BundleContext context) throws Exception
6261

6362
// Setup performance logger for POP3
6463
if(Configurator.isPerformanceCountersEnabled()) {
65-
LoggingPeriodicalLog pLog = new LoggingPeriodicalLog();
64+
PeriodicalLog pLog = new PeriodicalLog();
6665
pLog.setName(SPEED4J_LOG_NAME);
6766
pLog.setMode(PeriodicalLog.Mode.JMX_ONLY);
6867
pLog.setMaxQueueSize(250000);
6968
pLog.setPeriod(Configurator.getPerformanceCountersInterval());
70-
pLog.setJmx("DELIVERY.success,DELIVERY.discard,DELIVERY.defer,DELIVERY.defer_failure,DELIVERY.reject_overQuota,DELIVERY.reject_nonExistent");
69+
pLog.setJmx("AUTH.success,AUTH.fail");
7170
pLog.setSlf4jLogname("com.elasticinbox.speed4j.pop3.PeriodicalLogger");
7271
stopWatchFactory = StopWatchFactory.getInstance(pLog);
7372
} else {

modules/pop3/src/main/java/com/elasticinbox/pop3/server/handler/AuthHandler.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,15 @@
3434
import org.slf4j.Logger;
3535
import org.slf4j.LoggerFactory;
3636

37+
import com.ecyrd.speed4j.StopWatch;
3738
import com.elasticinbox.core.account.authenticator.AuthenticationException;
3839
import com.elasticinbox.core.account.authenticator.AuthenticatorFactory;
3940
import com.elasticinbox.core.account.authenticator.IAuthenticator;
4041
import com.elasticinbox.core.account.validator.IValidator;
4142
import com.elasticinbox.core.account.validator.ValidatorFactory;
4243
import com.elasticinbox.core.account.validator.IValidator.AccountStatus;
4344
import com.elasticinbox.core.model.Mailbox;
45+
import com.elasticinbox.pop3.Activator;
4446

4547
/**
4648
* POP3 Authentication Handler (AUTH)
@@ -69,6 +71,8 @@ protected org.apache.james.protocols.pop3.mailbox.Mailbox auth(POP3Session sessi
6971
logger.debug("POP3: Authenticating session {}, user {}, pass {}",
7072
new Object[] { session.getSessionID(), username, password });
7173

74+
StopWatch stopWatch = Activator.getDefault().getStopWatch();
75+
7276
try {
7377
// authenticate mailbox, if failed return null
7478
AccountStatus status = validator.getAccountStatus(username);
@@ -81,12 +85,16 @@ protected org.apache.james.protocols.pop3.mailbox.Mailbox auth(POP3Session sessi
8185
// authenticate user with password
8286
mailbox = authenticator.authenticate(username, password);
8387

88+
stopWatch.stop("AUTH.success");
89+
8490
// return POP3 handler for mailbox
8591
return backend.getMailboxHander(mailbox);
8692
} catch (IllegalArgumentException iae) {
93+
stopWatch.stop("AUTH.fail");
8794
logger.debug("POP3 Authentication failed. Invalid username [{}]: {}", username, iae.getMessage());
8895
return null;
8996
} catch (AuthenticationException ae) {
97+
stopWatch.stop("AUTH.fail");
9098
logger.debug("POP3 Authentication failed. Invalid username [{}] or password [{}]", username, password);
9199
return null;
92100
}

modules/pop3/src/main/java/com/elasticinbox/pop3/utils/LoggingPeriodicalLog.java

Lines changed: 0 additions & 62 deletions
This file was deleted.

0 commit comments

Comments
 (0)