Skip to content

Commit

Permalink
VIVO 3828: Remove SDB in preparation to moving to new Jena.
Browse files Browse the repository at this point in the history
The Jena version being switched to (Jena 4) removed SDB.

The `DatasetWrapperFactory` and `StaticDatasetFactory` should no longer be needed.
These seems to exist only to provide SDB specific functionality.
The code is simplified a little with the removal of these.

The `DatasetFactory.createMem()` function is replaced with `DatasetFactory.createGeneral()`.
This serves several purposes:
1) The method is deprecated.
2) The `DatasetFactory.createGeneral()` is the compatible equivalent.
3) The `DatasetFactory.createGeneral()` better supports TDB (which is the main reason for including in this commit set).
4) This better prepares the code for the upcoming Jena upgrade changes.

The documentation for `example.runtime.properties` refers to `VitroConnection.DataSource.*` only being used by SDB but this is incorrect.
The OpenSocial code appears to talk directly to an SQL database using these properties.
Update the documentation in this regard and replace the references to SDB with OpenSocial.

Remove no longer necessary SDB helper code that is added to TDB as well because it "shouldn't hurt".

Remove much of the documentation and installation functionality using or referencing SDB.

The `IndividualDaoSDB.java` file is implemting `getAllIndividualUris()` and `getUpdatedSinceIterator()` via the now removed `IndivdiualSDB` class.
This functionality is used by `RebuildIndexTask` and `UpdateUrisTask` classes.
Additional investigation is needed to review and determine if the SDB related code needs to be re-implemented in `IndividualDaoJena`.
This commit does not address this concern.

I originally removed the close command and replaced the dataset wrapper with just the dataset itself.
My reasoning is that the previous code is only closing the connection when the SDB has a connection.
When using TDB, this should ba a no-op and the close is never called.
After further thought, I concluded that it makes more sense to properly and consistently close the connection.
The code now explicitly calls the dataset close function.
Additional problems in the tests appeared that suggested dataset closure problems and race conditions.
The changes to using dataset have therefore been revertted and the `DatasetWrapper` has been retroactively added back.

The dataset wrapper has been observed to be used for assisting in closing the Dataset.
The `Dataset` is an interface and cannot be easily extended without some wrapper or helper.
I considered and tried using a helper utility for preventing an already closed exception on close.
This is simpler and easier to maintain.
This did not solve the test failure closure problems and race conditions and is not implemented within this commit.

The DatasetWrapper itself has the actual dataset closure removed.
This is done because theoretically the SDB connection is NULL for non-SDB cases such as with TDB.
Because this is always NULL the `dataset.close()` never gets called.
This effectively reverts back to my original concept of removing the close command as mentioned above.
  • Loading branch information
kaladay committed Mar 1, 2023
1 parent 4d60cd9 commit 71541ee
Show file tree
Hide file tree
Showing 44 changed files with 94 additions and 3,715 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ public int compare (DataProperty dp1, DataProperty dp2) {
}

public DataPropertyDaoJena(RDFService rdfService,
DatasetWrapperFactory dwf,
DatasetWrapper dw,
WebappDaoFactoryJena wadf) {
super(rdfService, dwf, wadf);
super(rdfService, dw, wadf);
}

public void deleteDataProperty(DataProperty dtp) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ public class DataPropertyStatementDaoJena extends JenaBaseDao implements DataPro
private static final Log log = LogFactory.getLog(DataPropertyStatementDaoJena.class);


private DatasetWrapperFactory dwf;
private DatasetWrapper dw;

public DataPropertyStatementDaoJena(DatasetWrapperFactory dwf,
public DataPropertyStatementDaoJena(DatasetWrapper dw,
WebappDaoFactoryJena wadf) {
super(wadf);
this.dwf = dwf;
this.dw = dw;
}


Expand Down Expand Up @@ -366,13 +366,11 @@ public List<Literal> getDataPropertyValuesForIndividualByProperty(String subject

// Run the SPARQL query to get the properties
List<Literal> values = new ArrayList<Literal>();
DatasetWrapper w = dwf.getDatasetWrapper();
Dataset dataset = w.getDataset();
Dataset dataset = dw.getDataset();
dataset.getLock().enterCriticalSection(Lock.READ);
QueryExecution qexec = null;
try {
qexec = QueryExecutionFactory.create(
queryString, dataset);
qexec = QueryExecutionFactory.create(queryString, dataset);
ResultSet results = qexec.execSelect();

while (results.hasNext()) {
Expand All @@ -388,7 +386,7 @@ public List<Literal> getDataPropertyValuesForIndividualByProperty(String subject

} finally {
dataset.getLock().leaveCriticalSection();
w.close();
dw.close();
if (qexec != null) {
qexec.close();
}
Expand Down Expand Up @@ -430,8 +428,7 @@ public List<Literal> getDataPropertyValuesForIndividualByProperty(

// Run the SPARQL query to get the properties
List<Literal> values = new ArrayList<Literal>();
DatasetWrapper w = dwf.getDatasetWrapper();
Dataset dataset = w.getDataset();
Dataset dataset = dw.getDataset();
dataset.getLock().enterCriticalSection(Lock.READ);
QueryExecution qexec = null;
try {
Expand Down Expand Up @@ -459,7 +456,7 @@ public List<Literal> getDataPropertyValuesForIndividualByProperty(
return Collections.emptyList();
} finally {
dataset.getLock().leaveCriticalSection();
w.close();
dw.close();
if (qexec != null) {
qexec.close();
}
Expand Down Expand Up @@ -497,8 +494,7 @@ private Model constructModelForSelectQueries(String subjectUri,
initialBindings.add(
"property", ResourceFactory.createResource(propertyUri));

DatasetWrapper w = dwf.getDatasetWrapper();
Dataset dataset = w.getDataset();
Dataset dataset = dw.getDataset();
dataset.getLock().enterCriticalSection(Lock.READ);
QueryExecution qe = null;
try {
Expand All @@ -512,7 +508,7 @@ private Model constructModelForSelectQueries(String subjectUri,
qe.close();
}
dataset.getLock().leaveCriticalSection();
w.close();
dw.close();
}
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

public class DatasetWrapper {

private SDBConnection conn;
private Dataset dataset;
private boolean closed = false;

Expand All @@ -17,7 +16,6 @@ public DatasetWrapper(Dataset dataset) {

public DatasetWrapper(Dataset dataset, SDBConnection conn) {
this.dataset = dataset;
this.conn = conn;
}

public Dataset getDataset() {
Expand All @@ -29,10 +27,6 @@ public Dataset getDataset() {
public void close() {
if (!closed) {
closed = true;
if (conn != null) {
dataset.close();
conn.close();
}
}
}

Expand Down

This file was deleted.

Loading

0 comments on commit 71541ee

Please sign in to comment.