You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by paul bryant <pa...@brysystems.co.uk> on 2007/11/22 11:01:05 UTC
Applet not destroying cleanly
Hi
I am using mina 1.1.3 for communications between an applet and a server
process, using DemuxingProtocolCodecFactory and a DemuxingIoHandler my
implementation is based on the GraphicalCharGen example.
The Problem: Applet Not Destroying cleanly
>From reading the forum it would appear that the Executor is not destroying
it threads but since I rely on the in built functionally I do not have a set
of Executors to clean up. Is that my problem? Should I have my own
Executors?
Many Thanks in Advance
Paul
The applet on destroy produces the following trace output.
DEBUG [AnonymousIoService-5] org.apache.mina.filter.executor.ExecutorFilter
- Exiting since queue is empty for /172.18.1.15:8082
Stop Applet
Destroy Applet
INFO [thread applet-com.bae.nads.gui.NADSApplet.class]
com.bae.nads.tcp.client.NadControlClient - [/172.18.1.15:8082] CLOSE
DEBUG [SocketConnectorIoProcessor-0.0]
org.apache.mina.filter.executor.ExecutorFilter - Launching thread for
/172.18.1.15:8082
Applet Destroyed
INFO [AnonymousIoService-6] com.bae.nads.tcp.client.NadControlClient -
[/172.18.1.15:8082] CLOSED
DEBUG [AnonymousIoService-6] com.bae.nads.tcp.client.NadControlClient -
[/172.18.1.15:8082] Session Closed
DEBUG [AnonymousIoService-6] org.apache.mina.filter.executor.ExecutorFilter
- Exiting since queue is empty for /172.18.1.15:8082
Exception in thread "AnonymousIoService-1"
java.lang.IllegalMonitorStateException
at java.util.concurrent.locks.ReentrantLock$Sync.tryRelease(Unknown Source)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.release(Unknown
Source)
at java.util.concurrent.locks.ReentrantLock.unlock(Unknown Source)
at java.util.concurrent.LinkedBlockingQueue.take(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.getTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
And so on upto 20 repeatations of the same AnonymousIoService-n.
The socket creation code
public NadControlClient(String host, int port,NadsMessageListener
messageListener) {
this.host = host;
this.port = port;
this.messageListener = messageListener;
connector = new SocketConnector();
// Change the worker timeout to 1 second to make the I/O thread quit soon
// when there's no connection to manage.
connector.setWorkerTimeout(1);
// Configure the service.
cfg = new SocketConnectorConfig();
cfg.setConnectTimeout(CONNECT_TIMEOUT);
cfg.getFilterChain().addLast("codec",
new ProtocolCodecFilter(new NadsProtocolCodecFactory(false)));
cfg.getFilterChain().addLast("logger", new LoggingFilter());
this.addMessageHandler(SummaryMessage.class, new SummaryMessageHandler(
this.messageListener));
this.addMessageHandler(AckMessage.class, new AckMessageHandler(
this.messageListener));
this.addMessageHandler(AlarmsMessage.class, new AlarmsMessageHandler(
this.messageListener));
}
Socket Connection and Disconnection code snippets
public boolean connect() {
boolean result = false;
ConnectFuture connectFuture = connector.connect(new InetSocketAddress(
host, port), this, cfg);
connectFuture.join(CONNECT_TIMEOUT);
try {
session = connectFuture.getSession();
if (session != null)
result = session.isConnected();
} catch (RuntimeIOException e) {
result = false;
}
return result;
}
public void disconnect() {
connector.setWorkerTimeout(0);
if (session != null) {
CloseFuture future = session.close();
// Wait until the connection is closed
future.join();
session = null;
}
}
--
View this message in context: http://www.nabble.com/Applet-not-destroying-cleanly-tf4855371s16868.html#a13893939
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.
Re: Applet not destroying cleanly
Posted by Trustin Lee <tr...@gmail.com>.
On Nov 22, 2007 9:45 PM, paul bryant <pa...@brysystems.co.uk> wrote:
> Well I knew as soon as I posted to the forum I would fix it. (Been trying to
> fix it for a day on and off)
> For others here the fix is below in bold.
> I think the problem is the demo's have not been updated to reflect various
> changes in MINA
> Trustin
> If I get a couple hours I will knock up a simple multiple binary message
> client / server example using DemuxingProtocolCodecFactory and a
> DemuxingIoHandler.
Great to hear that you fixed your problem before I answer. :)
Let me look forward to your contribution then.
Thanks,
Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6
Re: Applet not destroying cleanly
Posted by paul bryant <pa...@brysystems.co.uk>.
Well I knew as soon as I posted to the forum I would fix it. (Been trying to
fix it for a day on and off)
For others here the fix is below in bold.
I think the problem is the demo's have not been updated to reflect various
changes in MINA
Trustin
If I get a couple hours I will knock up a simple multiple binary message
client / server example using DemuxingProtocolCodecFactory and a
DemuxingIoHandler.
cheers
Paul
public NadControlClient(String host, int port,
NadsMessageListener messageListener) {
this.host = host;
this.port = port;
this.messageListener = messageListener;
connector = new
SocketConnector(Runtime.getRuntime().availableProcessors()+1,Executors.newCachedThreadPool());
// Change the worker timeout to 1 second to make the I/O thread quit soon
// when there's no connection to manage.
connector.setWorkerTimeout(1);
// Configure the service.
cfg = new SocketConnectorConfig();
cfg.setThreadModel(ThreadModel.MANUAL);
cfg.setConnectTimeout(CONNECT_TIMEOUT);
cfg.getFilterChain().addLast("codec",
new ProtocolCodecFilter(new NadsProtocolCodecFactory(false)));
cfg.getFilterChain().addLast("logger", new LoggingFilter());
this.addMessageHandler(SummaryMessage.class, new SummaryMessageHandler(
this.messageListener));
this.addMessageHandler(AckMessage.class, new AckMessageHandler(
this.messageListener));
this.addMessageHandler(AlarmsMessage.class, new AlarmsMessageHandler(
this.messageListener));
}
--
View this message in context: http://www.nabble.com/Applet-not-destroying-cleanly-tf4855371s16868.html#a13896088
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.