Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
Merge pull request #12 from batiati/modules
Browse files Browse the repository at this point in the history
Closes #11
  • Loading branch information
batiati authored Sep 30, 2022
2 parents 6be0225 + 5b6cd00 commit 40c8c3f
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 10 deletions.
2 changes: 1 addition & 1 deletion scripts/benchmark.bat
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ timeout /t 2

echo.
echo Benchmarking...
java -cp ./src/tigerbeetle-java/target/classes Benchmark
java -cp ./src/tigerbeetle-java/target/classes benchmark/Benchmark
exit /b %errorlevel%
2 changes: 1 addition & 1 deletion scripts/benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ sleep 1

echo ""
echo "Benchmarking..."
java -cp ./src/tigerbeetle-java/target/classes Benchmark
java -cp ./src/tigerbeetle-java/target/classes benchmark/Benchmark
echo ""

for I in 0
Expand Down
2 changes: 1 addition & 1 deletion src/tigerbeetle-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
<exclude>com/tigerbeetle/JNILoader$Arch.class</exclude>

<!-- Excluding the benchmark -->
<exclude>Benchmark.class</exclude>
<exclude>benchmark/Benchmark.class</exclude>
</excludes>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package benchmark;

import java.util.concurrent.CompletableFuture;
import com.tigerbeetle.*;

public class Benchmark {

public static void main(String[] args) {
try (var client = new Client(0, new String[] {"127.0.0.1:3001"}, 32)) {
try (var client = new Client(0, new String[] {"127.0.0.1:3001"})) {

var accounts = new AccountBatch(2);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* TigerBeetle client for Java.
*
* @see <a href="https://docs.tigerbeetle.com">TigerBeetle Docs</a>
* @see <a href="https://github.com/tigerbeetledb/tigerbeetle-java">Source code</a>
*/
package com.tigerbeetle;
3 changes: 3 additions & 0 deletions src/tigerbeetle-java/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module com.tigerbeetle {
exports com.tigerbeetle;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

import javax.management.OperationsException;
import org.junit.Test;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
Expand Down Expand Up @@ -1139,7 +1138,7 @@ private static class Server implements AutoCloseable {

private Process process;

public Server() throws IOException, OperationsException, InterruptedException {
public Server() throws IOException, Exception, InterruptedException {

cleanUp();

Expand All @@ -1158,21 +1157,21 @@ public Server() throws IOException, OperationsException, InterruptedException {
if (format.waitFor() != 0) {
var reader = new BufferedReader(new InputStreamReader(format.getErrorStream()));
var error = reader.lines().collect(Collectors.joining(". "));
throw new OperationsException("Format failed. " + error);
throw new Exception("Format failed. " + error);
}

this.process = Runtime.getRuntime()
.exec(new String[] {exe, "start", "--addresses=" + TB_PORT, TB_FILE});
if (process.waitFor(100, TimeUnit.MILLISECONDS))
throw new OperationsException("Start server failed");
throw new Exception("Start server failed");
}

@Override
public void close() throws Exception {
cleanUp();
}

private void cleanUp() throws OperationsException {
private void cleanUp() throws Exception {
try {

if (process != null && process.isAlive()) {
Expand All @@ -1182,7 +1181,7 @@ private void cleanUp() throws OperationsException {
var file = new File("./" + TB_FILE);
file.delete();
} catch (Throwable any) {
throw new OperationsException("Cleanup has failed");
throw new Exception("Cleanup has failed");
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/tigerbeetle-java/src/test/java/module-info.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
open module com.tigerbeetle {
requires junit;
}

0 comments on commit 40c8c3f

Please sign in to comment.