Friday, July 20, 2007

Status Report for 07/11/2007 -- 07/18/2007

Progress

Some problems and solutions in detail design for IUMSC 12 sensors Atom Feed

1. Synchronization in writing data to Atom Feed

  • Problem

It is possible that data from 12 sensors could come simultaneously, but each sensor data should be written to the Feed sequentially. In that case, if the data is being written to Feed, the other data should not be written to the Feed. On the other hand, the incoming data is updated in memory first, then written to the Feed. So the updating should be synchronized too.

  • Solution

Put the Feed updating statements in a synchronized block and this synchronized block should be as small as possible.

2. Exception in thread

  • Problem

After CIMA Client ran for about 15 to 20 minutes, there was an exception in Thread and no parcel comes afterward.

Error message is shown below:

Exception in thread "Thread-3" java.lang.IllegalStateException:

IllegalStateException:

at org.apache.axis.components.threadpool.ThreadPool.addWorker(ThreadPool.java:103)

at org.apache.axis.transport.http.SimpleAxisServer.run(SimpleAxisServer.java:243)

at java.lang.Thread.run(Thread.java:595)

  • Solution

(1) It seems that the program ran out of threads. It was addWorker that throws this when the thread pool runs out of threads.

(2) Check that the default maximum thread count (org.apache.axis.components.threadpool.ThreadPool, public static final int DEFAULT_MAX_THREADS) is set to 100 when the instance of ThreadPool is created.

(3) Change SimpleAxisServer() to SimpleAxisServer(int maxPoolSize, int

maxSessions). Both of the constructor parameters default to 100. Now we make them 1000 instead.

3. A problem caused by Synchronization

  • Problem

It has been no thread exceptions for 1 hour, but I found another problem by observing the output window in eclipse. That is, if only a few sensor data come at the same time, the program has enough time to write the data to the Feed and receive new incoming data after that. If sometimes many sensor data come at the same time, the program needs to write these data one by one, during this period the program cannot receive any parcel and it seems the program has been dead for twenty or more minutes.

  • Possible solution

Instead of the critical sections using "synchronized" around the whole feed writing process we need some other way to serialize the writing of the feed. Maybe we should add a queue data structure into which each change is added, then the writer reads everything available in the queue, writes the feed, and reads the next batch of changes. This would limit the critical section to updating and reading an in-memory data structure rather than reading and writing a file.

Discussion

1. Functionalities for users to select different sensors and/or just show the sensors with abnormal data.

Future work

1. Get sensor values based on the user’s requirement;

2. Show only values not in normal range;

3. The issues described in Discussion section

No comments: