ReusableExecution behaving different between Embedded Server and JBoss Environement
sanjeev.gour Dec 5, 2012 1:41 PMHi,
We are making use of ReusableExecution in our translator and seeing differences in its behaviour under a test case using embedded server and when deployed in JBoss. We are execuing some queries under the continuous execution. When the translator is called in a junit test case under the embedded server, we see the contructor is called only once and and we keep on getting the data. However, when the same translator is deployed under JBoss, we observe repetitive call to the constructor. We believe this is expected to be called just once.
We can provide a test case and a sample translator for this if needed. Before this we just want to make sure if this is a known problem and already reported or we are doing something wrong or if a Jira issue is required to address this.
We are at Teiid 8.1.0 currently, tested this against Teiid 8.2 Final as well with the same outcome.
Here is the quick snippet of the translator code-
public class H2ContinuousExecution extends JDBCQueryExecution implements
ReusableExecution<Connection> {
private final AtomicBoolean mustExecute = new AtomicBoolean(true);
public H2ContinuousExecution( final Command command, final Connection connection,
final ExecutionContext context, final JDBCExecutionFactory env) {
super(command, connection, context, env);
System.out.println("H2ContinuousExecution.H2ContinuousExecution()"); // this is printed just once under the test case and repeatedly under JBoss
}
}
@Override
synchronized public void execute() throws TranslatorException {
if (this.mustExecute.compareAndSet(true, false)) {
super.execute();
} else {
throw DataNotAvailableException.NO_POLLING;
}
}
@Override
synchronized public List<?> next() throws TranslatorException,
DataNotAvailableException {
return super.next();
}
@Override
public synchronized void close() {
super.close();
}
@Override
public synchronized void cancel() throws TranslatorException {
// TODO Auto-generated method stub
super.cancel();
}
@Override
synchronized public void reset(final Command c,
final ExecutionContext executionContext, final Connection connection) {
this.context = executionContext;
this.command = c;
this.connection = connection;
}
@Override
public void dispose() {
}
}
------------------
@Translator(name = "h2-continuous", description = "A translator for h2 continuous executions")
public class H2ContinuousExecutionFactory extends H2ExecutionFactory {
public H2ContinuousExecutionFactory() {
super();
}
@Override
public ResultSetExecution createResultSetExecution(
final QueryExpression command,
final ExecutionContext executionContext,
final RuntimeMetadata metadata, final Connection conn)
throws TranslatorException {
return new H2ContinuousExecution(this.eventBus, command, conn,
executionContext, this);
}
}