users@grizzly.java.net

Re: Thread name is always...GrizzlyWorkerThread-8080 ?

From: Jeanfrancois Arcand <Jeanfrancois.Arcand_at_Sun.COM>
Date: Mon, 26 May 2008 09:46:52 -0400

Salut,

hit the send button too fast:

Once your pipeline is created, set it on the Controller:

controller.setPipeline(...)

Hope that help.

-- Jeanfrancois

Jeanfrancois Arcand wrote:
> Salut,
>
> add the following:
>
> DefaultPipeline pipeline = new DefaultPipeline();
> pipeline.setName(...);
> pipeline.setPort(...);
>
> to changes the default value.
>
> A+
>
> -- Jeanfrancois
>
> Neil Avery wrote:
>> ServerCode for its creation follows.......
>> Cheers Neil.
>>
>>
>> public class GrizzlyReceiver implements Receiver {
>> static final Logger LOGGER =
>> Logger.getLogger(GrizzlyReceiver.class);
>>
>> private final URI startPoint;
>> final ProtocolFilter read = new ReadFilter();
>> final LogFilter log = new LogFilter();
>> final TCPSelectorHandler tcpHandler = new TCPSelectorHandler();
>> final Controller controller = new Controller();
>> ProtocolFilter protocolFilter;
>> public GrizzlyReceiver(URI address, Receiver receiver) {
>> this.startPoint = address;
>> this.receiver = receiver;
>> }
>>
>> public void start() {
>> if (state == LifeCycle.State.STARTED) return;
>> state = LifeCycle.State.STARTED;
>> LOGGER.info("GrizzlyReceiver starting on[" + startPoint + "]");
>> tcpHandler.setPort(startPoint.getPort());
>> controller.setSelectorHandler(tcpHandler);
>>
>> final ProtocolFilter myFilter = new LLProtocolFilter();
>> controller.setProtocolChainInstanceHandler(new
>> DefaultProtocolChainInstanceHandler() {
>> public ProtocolChain poll() {
>> ProtocolChain protocolChain = protocolChains.poll();
>> if (protocolChain == null) {
>> protocolChain = new DefaultProtocolChain();
>> protocolChain.addFilter(read);
>> protocolChain.addFilter(log);
>> protocolChain.addFilter(new MyProtocolFilter());
>> }
>> return protocolChain;
>> }
>>
>> });
>> new Thread(controller).start();
>> }
>> public class MyProtocolFilter implements ProtocolFilter {
>>
>> public boolean postExecute(Context ctx) throws IOException {
>> return true;
>> }
>>
>> public boolean execute(Context ctx) throws IOException {
>> final WorkerThread workerThread =
>> ((WorkerThread) Thread.currentThread());
>> ByteBuffer buffer = workerThread.getByteBuffer();
>> buffer.flip();
>> System.out.println("Thread is:" +
>> Thread.currentThread().getName());
>> // handler code <snipped>
>> return false;
>> }
>> public boolean postExecute(Context ctx) throws IOException {
>> return true;
>> }
>>
>> }
>> }
>>
>>
>>
>>
>> Date: Mon, 26 May 2008 11:23:20 +0200
>> From: Oleksiy Stashok <Oleksiy.Stashok_at_Sun.COM>
>> Content-type: text/plain; delsp=yes; format=flowed; charset=US-ASCII
>> Subject: Thread name is always...GrizzlyWorkerThread-8080 ?
>>
>>
>> Hello Neil,
>> can you pls. share the code, how you instantiate the server?
>>
>> Thanks.
>>
>> WBR,
>> Alexey.
>>
>> On May 25, 2008, at 20:26 , Neil Avery wrote:
>>
>>> Hi,
>>> Ive started using Grizzly and in the testcases Im writing I will
>>
>>> fire of multiple Servers - however as each instance receives its
>>> payload, the WorkerThread always has a name of
>>> "GrizzlyWorkerThread-8080-" regardless of the address and port being
>>
>>> used.
>>>
>>> Is it possible to have the WorkerThread pool use the correct name
>>> and port ?
>>>
>>> Regards Neil.
>>
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>