All pastes #267617 Raw Edit

Miscellany

public java v1 · immutable
·published 2006-12-04 23:33 UTC
rendered paste body
Suggestion from mailing list> 2. I'm going to be running GATE/ANNIE in Tomcat and feeding strings > via POST/GET.  What is the most memory/speed efficient way to load it > once and run it 100,000 times? Perhaps just create a servlet that > loads itself 'on start' in Tomcat, runs Gate.init once, and waits for a request?Something like this - in init() you call Gate.init() and create your application Controller.  In doGet/doPost you read the text from the request, create a GATE Document, pass it to the controller, do something with the results and release the document (with Factory.deleteResource).You just have to watch out for multi-threading issues - you can't use the same Controller or PRs in different threads at the same time, so if you have a single application you will only be able to serve one request at a time. When I do this kind of thing I create a number of identical copies of the controller in my init() and put them into a pool, so each request gets one copy of the application from the pool and returns it when the request is finished.  @@You need one copy of the application for every request you want to process concurrently, i.e. with a pool of 3 apps you can serve three clients at once.public class RunAnnie extends HttpServlet {    /** The Corpus Pipeline application to contain ANNIE */    private SerialAnalyserController annieController;		public void init() throws ServletException {				try {			Gate.init();		} catch (GateException e) {			e.printStackTrace();		}				try {@@ // This needs to be initialized once per thread/copy for the thread pool						this.initAnnie();		} catch (GateException e) {			e.printStackTrace();		} 	}