use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.
the class AbstractTestTransPromote method run_03.
private void run_03(boolean readCommitted) {
Assume.assumeTrue(!readCommitted || supportsReadCommitted());
setReadCommitted(readCommitted);
DatasetGraph dsg = create();
dsg.begin(ReadWrite.WRITE);
dsg.commit();
dsg.end();
dsg.begin(ReadWrite.READ);
dsg.add(q1);
dsg.commit();
dsg.end();
}
use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.
the class TestTransactionDSGWithLockWithAbort method create.
@Override
protected Dataset create() {
// The tests don't actually add/delete data.
DatasetGraph dsg = DatasetGraphFactory.createTxnMem();
DatasetGraphWithLock dsgl = new DatasetGraphWithLock(dsg, true);
return DatasetFactory.wrap(dsgl);
}
use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.
the class AbstractTestTransPromote method run_06.
// Async writer after promotion.
private void run_06(boolean readCommitted) {
Assume.assumeTrue(!readCommitted || supportsReadCommitted());
setReadCommitted(readCommitted);
DatasetGraph dsg = create();
AtomicInteger a = new AtomicInteger(0);
Semaphore sema = new Semaphore(0);
Thread t = new Thread(() -> {
sema.release();
Txn.executeWrite(dsg, () -> dsg.add(q3));
sema.release();
});
dsg.begin(ReadWrite.READ);
// Promote
dsg.add(q1);
t.start();
// First release.
sema.acquireUninterruptibly();
// Thread blocked.
dsg.add(q2);
dsg.commit();
dsg.end();
// Until thread exits.
sema.acquireUninterruptibly();
assertCount(3, dsg);
}
use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.
the class TestMultipleEmbedded method multiple_01.
// Two servers, same port -> bad.
@Test(expected = FusekiException.class)
public void multiple_01() {
DatasetGraph dsg = dataset();
int port = FusekiLib.choosePort();
FusekiEmbeddedServer server1 = FusekiEmbeddedServer.create().setPort(port).add("/ds1", dsg).build();
// Same port - Bbad.
FusekiEmbeddedServer server2 = FusekiEmbeddedServer.create().setPort(port).add("/ds2", dsg).build();
server1.start();
try {
server2.start();
} catch (FusekiException ex) {
assertTrue(ex.getCause() instanceof java.net.BindException);
throw ex;
} finally {
try {
server1.stop();
} catch (Exception ex) {
}
try {
server2.stop();
} catch (Exception ex) {
}
}
}
use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.
the class TestMultipleEmbedded method multiple_04.
// Two servers, one dataset under two names.
@Test
public void multiple_04() {
DatasetGraph dsg = dataset();
int port1 = FusekiLib.choosePort();
FusekiEmbeddedServer server1 = FusekiEmbeddedServer.create().setPort(port1).add("/ds1", dsg).build().start();
Txn.executeWrite(dsg, () -> dsg.add(q1));
int port2 = FusekiLib.choosePort();
FusekiEmbeddedServer server2 = FusekiEmbeddedServer.create().setPort(port2).add("/ds2", dsg).build().start();
Txn.executeWrite(dsg, () -> dsg.add(q2));
query("http://localhost:" + port1 + "/ds1", "SELECT * {?s ?p ?o}", qExec -> {
ResultSet rs = qExec.execSelect();
int x = ResultSetFormatter.consume(rs);
assertEquals(2, x);
});
query("http://localhost:" + port2 + "/ds2", "SELECT * {?s ?p ?o}", qExec -> {
ResultSet rs = qExec.execSelect();
int x = ResultSetFormatter.consume(rs);
assertEquals(2, x);
});
server1.stop();
server2.stop();
}
Aggregations