hello all,
As i noticed that launching one xquery update on only one element doesn’t take much time (between 200 and 600 ms on my machine) i am trying to make my java client launch many updates at the time in encapsulating every single update in a thread (every single thread using a pooledConnection delivered by one general poolManager, see code below).
Doing so, i have noticed that instead of gaining time, every single thread takes more and more time to complete its run() method.
Am i misunderstanding the way Tamino handles pooled Connections ? Am i doing something wrong ?
Creation of the poolmanager and its descriptor :
public ProcessTEI2(String databaseURI, String collection, String mode) throws TException, Exception {
this.collection = collection;
if (poolManager==null)
poolManager = TConnectionPoolManager.getInstance();
TConnectionPoolDescriptor descriptor = new TConnectionPoolDescriptor();
descriptor.setDatabaseURI(databaseURI);
descriptor.setUser("sag");
descriptor.setPassword("sag");
descriptor.setMaxConnections(100);
descriptor.setInitConnections(50);
descriptor.setTimeOut(30);
poolManager.addConnectionPool(POOL_NAME, descriptor);
}
Launching of one thread per xquery
public void performBatchUpdateXQuery(ArrayList batchQueries, JProgressBar pb, String mode) throws TException {
final TXMLObjectModel dom4jObjectModel = TDOM4JObjectModel.getInstance();
TXMLObjectModel.register( dom4jObjectModel );
for (Iterator it = batchQueries.iterator(); it.hasNext();){
final TXQuery query = (TXQuery)it.next();
new Thread( new Runnable() {
public void run(){
TConnection pooledConnection = null;
TLocalTransaction pooledtloc = null;
try {
pooledConnection = poolManager.getConnection(POOL_NAME);
accessor = pooledConnection.newXMLObjectAccessor( TAccessLocation.newInstance( collection ) , dom4jObjectModel );
TResponse response = accessor.xquery(query);
TXMLObject o = response.getFirstXMLObject();
StringWriter sw = new StringWriter();
o.writeTo(sw);
} catch (TXQueryException tqe) {
log.debug(tqe.getMessage());
} catch (TStreamWriteException tswe) {
log.debug(tswe.getMessage());
} catch (TConnectionNotAvailableException tcnae){
log.debug(tcnae.getMessage());
}
finally {
long duration = System.currentTimeMillis()-start;
log.debug("update duration : " + duration + " ms");
try {
if (pooledConnection!=null){
pooledConnection.close();
}
}
catch (TConnectionCloseException tcce){
log.debug(tcce.getMessage());
}
}
}
}).start();
}
}
Thanks in advance for any piece of advice !
Thomas
ps :