users@grizzly.java.net

Re: Running Grizzly nio at more than one port

From: Oleksiy Stashok <Oleksiy.Stashok_at_Sun.COM>
Date: Mon, 13 Jul 2009 21:09:58 +0200

Hi Alaska,

> the grizzly-framework-1.9.17-Snapshot.jar seems not to contain packaes
> described in the according API... I"m confused... For example I
> don"t find
> the SelectorThread I"m using as (there is no package
> com.sun.grizzly.http.SelectorThread):
Right, please use this bundle:
http://download.java.net/maven/2/com/sun/grizzly/grizzly-http-webserver/1.9.17-SNAPSHOT/

WBR,
Alexey.

>
> SelectorThread selectorThread = new SelectorThread();
> selectorThread.setPort(PORT);
> selectorThread.setAsyncHttpWriteEnabled(true);
>
>
> Regards,
> alaska
>
>
> Oleksiy Stashok wrote:
>>
>>> Do you think, I should use although two protocolchains and two
>>> protocolChainInstanceHandlers?
>> Yes, because they should be responsible for creating different
>> protocol chains.
>>
>> WBR,
>> Alexey.
>>
>>>
>>> regards,
>>> alaska
>>>
>>>
>>>
>>> Oleksiy Stashok wrote:
>>>>
>>>> Hi,
>>>>
>>>>> where can I dowload 1.9.17-RC1? is this a right source? :
>>>>> http://download.java.net/maven/2/com/sun/grizzly/grizzly-framework/1.9.17-SNAPSHOT/
>>>> I just checked that RC1 wasn't published yet as maven artifact, but
>>>> you can use 1.9.17-SNAPSHOT instead.
>>>>
>>>> WBR,
>>>> Alexey.
>>>>
>>>>
>>>>>
>>>>> Regards,
>>>>> alaska
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Oleksiy Stashok wrote:
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I'd recommend to use Grizzly 1.9.17RC1, because we've fixed one
>>>>>> issue
>>>>>> related to your usecase.
>>>>>> The idea is simple - you need to create 2 TCPSelectorHandlers and
>>>>>> add
>>>>>> them to Controller. Also note, that protocol chain instance
>>>>>> handler
>>>>>> should be assigned not to Controller, in this case, but to each
>>>>>> SelectorHandler
>>>>>> (SelectorHandler.setProtocolChainInstanceHandler())
>>>>>> separately.
>>>>>>
>>>>>> Hope this will help.
>>>>>>
>>>>>>
>>>>>> WBR,
>>>>>> Alexey.
>>>>>>
>>>>>> On Jul 13, 2009, at 12:58 , Alaska wrote:
>>>>>>
>>>>>>>
>>>>>>> Hello!
>>>>>>>
>>>>>>> I"m using grizzly-nio-framework + http-webserver (both are
>>>>>>> v1.9.14),
>>>>>>> my goal
>>>>>>> is to run the code below on more than one port.
>>>>>>> So I need to bind, let us say, the port1 to the parserFilter1
>>>>>>> and
>>>>>>> port2 to
>>>>>>> parserFilter2 (this should be two different protocols (both on
>>>>>>> top
>>>>>>> of the
>>>>>>> tcp, one is a http and another ist the own one)). Than these
>>>>>>> protocols
>>>>>>> should share the same Filters (RequestControllerFilter &
>>>>>>> ProcessRequestFilter). How could I implement this?
>>>>>>>
>>>>>>> Thank you in advance,
>>>>>>> alaska
>>>>>>>
>>>>>>>
>>>>>>> public void start() throws Exception {
>>>>>>>
>>>>>>> final ProtocolFilter parserFilter1 = new
>>>>>>> AsciiCommandProtocolParserFilter();
>>>>>>>
>>>>>>> final ProtocolFilter reqcontrolFilter = new
>>>>>>> RequestControllerFilter();
>>>>>>>
>>>>>>> final Controller controller = new Controller();
>>>>>>>
>>>>>>> final TCPSelectorHandler tcp_handler = new
>>>>>>> TCPSelectorHandler();
>>>>>>> tcp_handler.setPort(PORT1);
>>>>>>> tcp_handler.setSelectionKeyHandler(new
>>>>>>> BaseSelectionKeyHandler());
>>>>>>>
>>>>>>> controller.addSelectorHandler(tcp_handler);
>>>>>>>
>>>>>>> controller.setReadThreadsCount(_selectorThreadsNumber);
>>>>>>>
>>>>>>> final ProtocolChain protocolChain = new
>>>>>>> DefaultProtocolChain();
>>>>>>>
>>>>>>> protocolChain.addFilter(parserFilter1);
>>>>>>> protocolChain.addFilter(reqcontrolFilter);
>>>>>>> protocolChain.addFilter(new ProcessRequestFilter());
>>>>>>>
>>>>>>> ((DefaultProtocolChain)
>>>>>>> protocolChain).setContinuousExecution(true);
>>>>>>>
>>>>>>> ProtocolChainInstanceHandler pciHandler = new
>>>>>>> DefaultProtocolChainInstanceHandler() {
>>>>>>>
>>>>>>> @Override
>>>>>>> public ProtocolChain poll() {
>>>>>>> return protocolChain;
>>>>>>> }
>>>>>>>
>>>>>>> @Override
>>>>>>> public boolean offer(ProtocolChain pc) {
>>>>>>> return false;
>>>>>>> }
>>>>>>> };
>>>>>>>
>>>>>>> controller.setProtocolChainInstanceHandler(pciHandler);
>>>>>>>
>>>>>>> try {
>>>>>>> controller.start();
>>>>>>> } catch (Exception e) {
>>>>>>> LOG.log(Level.SEVERE, "Exception in controller...", e);
>>>>>>> }
>>>>>>>
>>>>>>> }
>>>>>>> --
>>>>>>> View this message in context:
>>>>>>> http://www.nabble.com/Running-Grizzly-nio-at-more-than-one-port-tp24459570p24459570.html
>>>>>>> Sent from the Grizzly - Users mailing list archive at
>>>>>>> Nabble.com.
>>>>>>>
>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
>>>>>>> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>>>>>>>
>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
>>>>>> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/Running-Grizzly-nio-at-more-than-one-port-tp24459570p24460729.html
>>>>> Sent from the Grizzly - Users mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
>>>>> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
>>>> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Running-Grizzly-nio-at-more-than-one-port-tp24459570p24461350.html
>>> Sent from the Grizzly - Users mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
>>> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
>> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Running-Grizzly-nio-at-more-than-one-port-tp24459570p24465248.html
> Sent from the Grizzly - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>