/* * (c) Copyright 2010 Epimorphics Ltd. * All rights reserved. * [See end of file] */ package dev ; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import org.apache.jena.larq.IndexBuilderString; import org.apache.jena.larq.IndexLARQ; import org.apache.jena.larq.LARQ; import org.apache.log4j.Logger; import org.apache.lucene.queryParser.ParseException; import org.junit.Test; import com.hp.hpl.jena.query.Query; import com.hp.hpl.jena.query.QueryExecution; import com.hp.hpl.jena.query.QueryExecutionFactory; import com.hp.hpl.jena.query.QueryFactory; import com.hp.hpl.jena.query.ResultSet; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.shared.Lock; public class Report_LARQ_Concurrent { static final int numThreads = 2; static final long duration = 2; long startTime = System.currentTimeMillis(); long endTime; Model model; @Test public void test_concurrent_larq_query() throws ParseException, InterruptedException, ExecutionException { endTime = startTime + duration * 1000; model = ModelFactory.createDefaultModel(); IndexBuilderString larqBuilder = new IndexBuilderString() ; IndexLARQ index = larqBuilder.getIndex() ; LARQ.setDefaultIndex(index) ; ExecutorService executorService = Executors.newCachedThreadPool(); Future[] future = new Future[numThreads]; for (int t=0; t