Skip to content

Commit

Permalink
fix: concurrency bug in Blazegraph
Browse files Browse the repository at this point in the history
  • Loading branch information
lroffia committed May 29, 2024
1 parent 4adec9b commit 313e7ad
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 36 deletions.
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
# 1) docker build -t vaimeedock/sepa:latest -f Dockerfile .
# 2) docker login -u YOUR-USER-NAME.
# Build command on Apple M1: docker buildx build --platform linux/amd64 --push -t vaimeedock/engine .
FROM maven:3.6-jdk-13 as BUILD
FROM maven:3.6-jdk-11 as BUILD
COPY . .

ENV JMX_HOSTNAME=0.0.0.0
ENV JMX_PORT=7090

RUN mvn clean package

FROM openjdk:13-jdk-alpine
FROM openjdk:11.0-jre

COPY --from=BUILD ./engine/target/engine-1.0.0-SNAPSHOT.jar /engine.jar
COPY --from=BUILD ./engine/src/main/resources/jmxremote.password /jmxremote.password
Expand All @@ -19,9 +22,6 @@ COPY --from=BUILD ./engine/src/main/resources/endpoints /endpoints

RUN chmod 600 /jmxremote.password

ENV JMX_HOSTNAME=0.0.0.0
ENV JMX_PORT=7090

EXPOSE 8000
EXPOSE 9000
EXPOSE ${JMX_PORT}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
*/

public class Engine implements EngineMBean {
private final static String version = "0.13.0";
private final static String version = "v0.14.3";

private EngineProperties properties = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public QueryProcessor(SPARQL11Properties properties) throws SEPAProtocolExceptio
SEPABeans.registerMBean("SEPA:type=" + this.getClass().getSimpleName(), this);

if (properties.getProtocolScheme().equals("jena-api") && properties.getHost().equals("in-memory")) endpoint = new JenaInMemoryEndpoint();
else endpoint = new RemoteEndpoint();
}

public Response process(InternalQueryRequest req) throws SEPASecurityException, IOException {
Expand All @@ -59,9 +60,7 @@ public Response process(InternalQueryRequest req) throws SEPASecurityException,
Response ret;
do {
long start = Timings.getTime();
if (!(properties.getProtocolScheme().equals("jena-api") && properties.getHost().equals("in-memory"))) endpoint = new RemoteEndpoint();
ret = endpoint.query(request);
endpoint.close();
long stop = Timings.getTime();

UpdateProcessorBeans.timings(start, stop);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public UpdateProcessor(SPARQL11Properties properties) throws SEPAProtocolExcepti
SEPABeans.registerMBean("SEPA:type=" + this.getClass().getSimpleName(), this);

if (properties.getProtocolScheme().equals("jena-api") && properties.getHost().equals("in-memory")) endpoint = new JenaInMemoryEndpoint();
else endpoint = new RemoteEndpoint();
}

public Response process(InternalUpdateRequest req) throws SEPASecurityException, IOException {
Expand All @@ -59,9 +60,7 @@ public Response process(InternalUpdateRequest req) throws SEPASecurityException,
int n = 0;
do {
long start = Timings.getTime();
if (!(properties.getProtocolScheme().equals("jena-api") && properties.getHost().equals("in-memory"))) endpoint = new RemoteEndpoint();
ret = endpoint.update(request);
endpoint.close();
long stop = Timings.getTime();

UpdateProcessorBeans.timings(start, stop);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,4 @@ public Response update(UpdateRequest req) {
});
return new UpdateResponse("Jena-in-memory-update");
}

@Override
public void close() {

}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package it.unibo.arces.wot.sepa.engine.processing.endpoint;

import java.io.IOException;

import it.unibo.arces.wot.sepa.api.SPARQL11Protocol;
import it.unibo.arces.wot.sepa.commons.exceptions.SEPASecurityException;
import it.unibo.arces.wot.sepa.commons.request.QueryRequest;
import it.unibo.arces.wot.sepa.commons.request.UpdateRequest;
import it.unibo.arces.wot.sepa.commons.response.Response;
import it.unibo.arces.wot.sepa.logging.Logging;

public class RemoteEndpoint implements SPARQLEndpoint {
SPARQL11Protocol endpoint;
Expand All @@ -26,13 +23,4 @@ public Response update(UpdateRequest req) {
return endpoint.update(req);
}

@Override
public void close() {
try {
endpoint.close();
} catch (IOException e) {
Logging.logger.error(e.getMessage());
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@
public interface SPARQLEndpoint {
public Response query(QueryRequest req);
public Response update(UpdateRequest req);
public void close();
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public Notification postUpdateInternalProcessing(UpdateResponse res) throws SEPA
ret = manager.processQuery(subscribe);
} catch (SEPASecurityException | IOException e) {
if (Logging.logger.isTraceEnabled()) e.printStackTrace();
Logging.logger.log(Logging.getLevel("spu"),"SEPASecurityException "+e.getMessage());
Logging.logger.log(Logging.getLevel("spu"),"Exception on query procesing "+e.getMessage());
throw new SEPAProcessingException("postUpdateInternalProcessing exception "+e.getMessage());
}

Expand Down
15 changes: 8 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
</modules>
<name>SEPA Project</name>
<url>https://github.com/vaimee/SEPA.git</url>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<revision>1.0.0-SNAPSHOT</revision>
<update>0</update>
</properties>
<licenses>
<license>
<name>GNU Lesser General Public License v3.0</name>
Expand Down Expand Up @@ -43,13 +50,7 @@
<developerConnection>scm:git:ssh://github.com/vaimee/sepa.git</developerConnection>
<url>https://github.com/vaimee/SEPA</url>
</scm>
<properties>
<maven.compiler.source>13</maven.compiler.source>
<maven.compiler.target>13</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<revision>v0.14.0</revision>
<update>0</update>
</properties>

<distributionManagement>
<repository>
<id>github</id>
Expand Down

0 comments on commit 313e7ad

Please sign in to comment.