users@grizzly.java.net

Re: Cannot stop Grizzly

From: Mark Hig <mark.higginbottom_at_gmail.com>
Date: Wed, 17 Sep 2008 02:10:03 -0700 (PDT)

Yes we see the problem when no messages have been processed (i.e. a straight
start and stop).

   /**
     * Stop the listener
     */
    public void stop()
    {
        isRunning=false;
        try
        {
            con.stop();
        }
        catch(Exception e)
        {
            e.printStackTrace();
            loggingExceptionHandler.handle(Thread.currentThread(), e);
        }

    }
    /**
     * @see java.lang.Runnable#run()
     * Run the listener
     */
    public void run()
    {
        // tell Grizzly to use our logger
        LoggerUtils.setLogger(new GrizzlyLoggingBridge(log));
        
        sel = new SelectorThread();
        sel.setPort(port);
        sel.setEnableNioLogging(true);
        
        con = new Controller();
        con.setReadThreadsCount(readThreadsCount);
        sel.setController(con);
        sel.setMaxThreads(maxThreads);
        sel.setMinThreads(minThreads);
        sel.setKeepAliveTimeoutInSeconds(keepAliveTimeoutInSeconds);
        sel.setSsBackLog(backlog);
        SelectorThread.setSelectorTimeout(1000000);
        
        // pre-register the JMX beans
// try
// {
// sel.preRegister(mbs, new
ObjectName("Grizzly:type=GrizzlyKeepAliveStats,name=GrizzlyKeepAliveStats"));
// sel.preRegister(mbs, new
ObjectName("Grizzly:type=GrizzlyPipelineStats,name=GrizzlyPipelineStats"));
// sel.preRegister(mbs, new
ObjectName("Grizzly:type=GrizzlyRequestGroupInfo,name=GrizzlyRequestGroupInfo"));
// sel.preRegister(mbs, new
ObjectName("Grizzly:type=GrizzlyRequestInfo,name=GrizzlyRequestInfo"));
// }
// catch (Exception e1)
// {
// // not a fatal error but log it
// log.error("Failed to pre-register Grizzly JMX beans.");
// }

        // create the JMX manager
// sel.setManagement(management);
        
        //Get and set up the Grizzly filter
        ICallbackAdapter adapter =
(ICallbackAdapter)SpringBeanFactory.getInstance().getBean(GRIZZLY_ADAPTER);
        adapter.setCallbackKey(CALLBACK_KEY);
        sel.setAdapter((Adapter)adapter);

        //Get and set up the Grizzly adapter
        final AsyncHandler handler = new DefaultAsyncHandler();
        ICallbackFilter filter =
(ICallbackFilter)SpringBeanFactory.getInstance().getBean(GRIZZLY_FILTER);
        filter.setCallbackKey(CALLBACK_KEY);
        handler.addAsyncFilter((AsyncFilter)filter);

        sel.setAsyncHandler(handler);
        sel.setEnableAsyncExecution(true);
        sel.setDisplayConfiguration(false);
        sel.setEnableNioLogging(false);

        try
        {
            sel.initEndpoint();
                           
            isRunning=true;
            log.info("accepting requests on port " + port);
            con.start();
            
            sel.startEndpoint();
        }
        catch(Exception e)
        {
            log.error("unable to accept requests - failed to start
listener...");
            isRunning=false;
            loggingExceptionHandler.handle(Thread.currentThread(), e);
        }
        log.info("nolonger accepting requests.");

    }

-- 
View this message in context: http://www.nabble.com/Cannot-stop-Grizzly-tp19495137p19527777.html
Sent from the Grizzly - Users mailing list archive at Nabble.com.