james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anagha Mudigonda <anaghamudigo...@gmail.com>
Subject Re: need suggestions for JAMES fast fail optimization
Date Wed, 03 Aug 2005 15:08:53 GMT
On 8/3/05, Stefano Bagnara <apache@bago.org> wrote:
> > I am thinking of having one set of SMTPSession and all the
> > CommandHandler objects created and configured at the start up
> > in SMTPServer. These will cloned and handed over whenever
> > SMTP session objects are needed for the actual protocol session.
> >
> > Would like to know if there is a better technique to
> > a) keep the commandhandler specific configuration parsing
> > code encapsulated.
> > b) not to parse the XML configuration every time
> > CommandHandler object is created.
> IMHO you should have a single set of command handlers (thread safe) for a
> single smtpserver.
> Cloning the whole command-handler stuff at every connection would be a
> resource consuming task.
> The Configuration should be passed to the command handlers when initialized
> and not at every session.
> This would be very similar to the current mailet processing: we have a set
> of thread-safe mailets that are invoked for each MailImpl by different
> threads. You will have a set of thread-safe commandhandler that are invoked
> for each SMTPSession by different threads.
> Does this make sense?

Makes sense.  Sounds a like better approach. 

Since CommandHandlers need to be thread safe, I will make the calls
re-entrant by passing SMTPSession object with every call.

The interface of Commanhandler would be like this

import org.apache.avalon.framework.configuration.Configuration;
public interface CommandHandler {
    void configure(Configuration configuration);
    void processCommand(SMTPSession session); //takes SMTPSession
    void processMessage(SMTPSession session);
    String getCommand(); //New interface added

The commandHandlers would not store any state and hence there is no
need for synchronization.

The logic would now be something like this.

At startup, all CommandHandlers are loaded.  The CommandHandler Map is filled 
with CommandName as key and  CommandHandler object as value.

When SMTPSession gets a command it gets the appropriate CommandHandler
from the Map and handles the command. 

All the state is stored back in SMTPSession and hence there can be 
single set CommandHandler objects.

Did I get it right?


> Stefano
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
> For additional commands, e-mail: server-dev-help@james.apache.org

To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org

View raw message