Skip to content
Snippets Groups Projects
Commit a90a2596 authored by Daniel's avatar Daniel
Browse files

Merge branch 'dev' into f-doc-info-resource

parents 2ddac4d6 25432945
No related branches found
No related tags found
No related merge requests found
# Manual Java-Side Benchmarking #
Benchmarking can be done using the `TransactionBenchmark` class (in package
`caosdb.server.database.misc`).
- Single timings can be added to instances of that class via the
`addBenchmark(object, time)` method. Multiple benchmarks for the same object
(typically just strings) can be averaged.
- Benchmarks can be serialized into XML, `Container` and `Query` objects already
use this with their included benchmarks to output benchmarking results.
- To work with the benchmarks of often used objects, use these methods:
- `Container.getTransactionBenchmark().addBenchmark()`
- `Query.addBenchmark()`
......@@ -32,7 +32,7 @@ runserver:
run: compile
mvn exec:java@run
run-debug: jar
run-debug:
java -Dcaosdb.debug=true -jar target/caosdb-server-0.1-SNAPSHOT-jar-with-dependencies.jar
run-single:
......
......@@ -52,12 +52,12 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j18-impl</artifactId>
<version>2.11.2</version>
<version>2.12.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.8.0-beta4</version>
<version>1.7.28</version>
</dependency>
<dependency>
<groupId>de.timmfitschen</groupId>
......@@ -165,12 +165,12 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.11.2</version>
<version>2.12.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.11.2</version>
<version>2.12.1</version>
</dependency>
</dependencies>
<build>
......
......@@ -415,6 +415,7 @@ public class Query implements QueryInterface, ToElementable, TransactionInterfac
}
public void parse() throws ParsingException {
final long t1 = System.currentTimeMillis();
CQLLexer lexer;
lexer = new CQLLexer(CharStreams.fromString(this.query));
final CommonTokenStream tokens = new CommonTokenStream(lexer);
......@@ -434,6 +435,8 @@ public class Query implements QueryInterface, ToElementable, TransactionInterfac
this.type = cq.t;
this.filter = cq.filter;
this.selections = cq.s;
final long t2 = System.currentTimeMillis();
addBenchmark("parse (" + this.query + ")", t2 - t1);
}
private String executeStrategy() throws QueryException {
......
......@@ -27,6 +27,7 @@ package caosdb.server.resource;
import caosdb.server.FileSystem;
import caosdb.server.accessControl.Principal;
import caosdb.server.accessControl.SessionToken;
import caosdb.server.accessControl.UserSources;
import caosdb.server.entity.FileProperties;
import caosdb.server.entity.Message;
import caosdb.server.scripting.CallerSerializer;
......@@ -82,6 +83,9 @@ public class ScriptingResource extends AbstractCaosDBServerResource {
@Override
protected Representation httpPostInChildClass(Representation entity) throws Exception {
if (isAnonymous()) {
throw ServerMessages.AUTHORIZATION_ERROR;
}
MediaType mediaType = entity.getMediaType();
try {
if (mediaType.equals(MediaType.MULTIPART_FORM_DATA, true)) {
......@@ -202,6 +206,11 @@ public class ScriptingResource extends AbstractCaosDBServerResource {
return SessionToken.generate((Principal) getUser().getPrincipal(), null);
}
boolean isAnonymous() {
boolean ret = getUser().hasRole(UserSources.ANONYMOUS_ROLE);
return ret;
}
public int callScript(
List<String> commandLine, Integer timeoutMs, List<FileProperties> files, Object authToken)
throws Message {
......
......@@ -99,6 +99,7 @@ public class EntityResource extends AbstractCaosDBServerResource {
throws ConnectionException, IOException, SQLException, CaosDBException,
NoSuchAlgorithmException, Exception {
final long t1 = System.currentTimeMillis();
if (!this.get) {
getResponse().setStatus(Status.CLIENT_ERROR_METHOD_NOT_ALLOWED);
return null;
......@@ -112,6 +113,10 @@ public class EntityResource extends AbstractCaosDBServerResource {
final Retrieve retrieve = new Retrieve(entityContainer);
retrieve.execute();
final long t2 = System.currentTimeMillis();
entityContainer
.getTransactionBenchmark()
.addBenchmark(getClass().getSimpleName() + ".httpGetInChildClass", t2 - t1);
final Element rootElem = generateRootElement();
entityContainer.addToElement(rootElem);
doc.setRootElement(rootElem);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment