@Override public void visit(OpService opService) { QueryIterator qIter = Service.exec(opService, ARQ.getContext()) ; Table table = TableFactory.create(qIter) ; push(table) ; }
HttpQuery httpQuery = configureQuery(uri, context, query); InputStream in = httpQuery.exec();
if (client != null) httpQuery.setClient(client); setAnyTimeouts(httpQuery, context);
@Override protected QueryIterator nextStage(Binding outerBinding) { Op op = QC.substitute(opService, outerBinding) ; boolean silent = opService.getSilent() ; QueryIterator qIter ; try { qIter = Service.exec((OpService)op, getExecContext().getContext()) ; // This iterator is materialized already otherwise we may end up // not servicing the HTTP connection as needed. // In extremis, can cause a deadlock when SERVICE loops back to this server. // Add tracking. qIter = QueryIter.makeTracked(qIter, getExecContext()) ; } catch (RuntimeException ex) { if ( silent ) { Log.warn(this, "SERVICE <" + opService.getService().toString() + ">: " + ex.getMessage()) ; // Return the input return QueryIterSingleton.create(outerBinding, getExecContext()) ; } throw ex ; } // Need to put the outerBinding as parent to every binding of the service call. // There should be no variables in common because of the OpSubstitute.substitute QueryIterator qIter2 = new QueryIterCommonParent(qIter, outerBinding, getExecContext()) ; return qIter2 ; } }
@Test public void testNumericTimeout() { BasicPattern basicPattern = new BasicPattern(); basicPattern.add(Triple.ANY); Node serviceNode = NodeFactory.createURI(SERVICE); OpService opService = new OpService(serviceNode, new OpBGP(basicPattern), false); Context context = new Context(); ARQ.setNormalMode(context); context.set(Service.queryTimeout, 10); try { Service.exec(opService, context); Assert.fail("Expected QueryExceptionHTTP"); } catch (QueryExceptionHTTP expected) { Throwable thrown = expected.getCause() ; if ( thrown instanceof SocketException || thrown instanceof ConnectTimeoutException ) { // expected } else { Assert.fail(String.format("Expected SocketException or ConnectTimeoutException, instead got: %s %s", thrown.getClass().getName(), thrown.getMessage())); } } }
@Test public void testStringTimeout() { BasicPattern basicPattern = new BasicPattern(); basicPattern.add(Triple.ANY); Node serviceNode = NodeFactory.createURI(SERVICE); OpService opService = new OpService(serviceNode, new OpBGP(basicPattern), false); Context context = new Context(); ARQ.setNormalMode(context); context.set(Service.queryTimeout, "10"); try { Service.exec(opService, context); Assert.fail("Expected QueryExceptionHTTP"); } catch (QueryExceptionHTTP expected) { Throwable thrown = expected.getCause() ; if ( thrown instanceof SocketException || thrown instanceof ConnectTimeoutException ) { // expected } else { Assert.fail(String.format("Expected SocketException or ConnectTimeoutException, instead got: %s %s", thrown.getClass().getName(), thrown.getMessage())); } } }
@Test public void testStringTimeout2() { BasicPattern basicPattern = new BasicPattern(); basicPattern.add(Triple.ANY); Node serviceNode = NodeFactory.createURI(SERVICE); OpService opService = new OpService(serviceNode, new OpBGP(basicPattern), false); Context context = new Context(); ARQ.setNormalMode(context); context.set(Service.queryTimeout, "10,10000"); try { Service.exec(opService, context); Assert.fail("Expected QueryExceptionHTTP"); } catch (QueryExceptionHTTP expected) { Throwable thrown = expected.getCause() ; if ( thrown instanceof SocketException || thrown instanceof ConnectTimeoutException ) { // expected } else { Assert.fail(String.format("Expected SocketException or ConnectTimeoutException, instead got: %s %s", thrown.getClass().getName(), thrown.getMessage())); } } }