Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stream apis #41

Merged
merged 29 commits into from Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f003851
chore: use immudb v1.4.0
jeroiraz Oct 25, 2022
4b6d55f
chore: state handling by database name
jeroiraz Oct 25, 2022
de50cda
chore: session-based authentication
jeroiraz Oct 25, 2022
90bac3c
chore: session keep alive heartbeat
jeroiraz Nov 1, 2022
f4d73de
feat: wip stream apis
jeroiraz Nov 7, 2022
675e9eb
test: session-related coverage
jeroiraz Nov 7, 2022
e8f5282
chore: scanAll, zscanAll, historyAll
jeroiraz Nov 14, 2022
938667c
chore: simplified stream apis
jeroiraz Nov 15, 2022
df01598
fix: chunking implementation
jeroiraz Nov 16, 2022
1526156
test: unit testing for LatchHolder
jeroiraz Nov 16, 2022
33c7feb
test: basic zadd unit testing
jeroiraz Nov 16, 2022
ef0bf9e
chore: use temp folders during unit testing
jeroiraz Nov 16, 2022
aad86cd
test: unit testing database mgmt
jeroiraz Nov 16, 2022
7d50531
chore: simplified start
jeroiraz Nov 21, 2022
2fb8dac
test: reduced db mgmt
jeroiraz Nov 21, 2022
6e29fe2
test: zscan unit testing
jeroiraz Nov 21, 2022
0f2fa05
test: increase set, get coverage
jeroiraz Nov 21, 2022
83311e7
test: history unit testing
jeroiraz Nov 22, 2022
4408243
test: stream set and get
jeroiraz Nov 22, 2022
362cef4
test: stream scan unit testing
jeroiraz Nov 22, 2022
7198016
test: shorter multithread unit testing
jeroiraz Nov 23, 2022
b002915
test: simplified user mgmt test
jeroiraz Nov 23, 2022
5f64bd2
test: validate no more entries
jeroiraz Nov 23, 2022
afc9380
test: basic user mgmt test
jeroiraz Nov 23, 2022
f057c14
test: streamSetAll
jeroiraz Nov 25, 2022
631ceca
feat: extended scan and zscan api
jeroiraz Nov 25, 2022
2e09dd1
chore: gradle clean
jeroiraz Nov 25, 2022
d6d7c89
chore: bump gradle version
jeroiraz Nov 25, 2022
373a575
fix: zscanAll optional seekKey
jeroiraz Nov 25, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
run: ./gradlew clean build
- name: Coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
Expand Down
13 changes: 5 additions & 8 deletions build.gradle
Expand Up @@ -133,14 +133,7 @@ task immudbStart {
pb = new ProcessBuilder()
pb.command("/bin/bash", "immudb/start.sh")
Process proc = pb.start()

proc.waitFor(10, TimeUnit.SECONDS)

if (proc.isAlive()) {
println "immudb has been started."
} else {
throw new GradleException("Process exit bad: " + proc.exitValue())
}
proc.waitFor(15, TimeUnit.SECONDS)
}

task immudbStop(type: Exec) {
Expand All @@ -167,6 +160,10 @@ test {
}
// Run the unit tests sequentially.
maxParallelForks = 1

testLogging {
events "FAILED"
}
}

test.dependsOn immudbStart
Expand Down
3 changes: 1 addition & 2 deletions immudb/clean.sh
Expand Up @@ -11,7 +11,6 @@ then
fi

rm -rf data
rm -rf states

echo "immudb's data and immudb4j's states folders were removed."
echo "immudb's data folder was removed."

4 changes: 2 additions & 2 deletions immudb/start.sh
Expand Up @@ -13,10 +13,10 @@ then
echo "Downloading immudb..."

if [[ "$OSTYPE" == "linux-gnu"* ]]; then
URL=https://github.com/vchain-us/immudb/releases/download/v1.3.0/immudb-v1.3.0-linux-amd64
URL=https://github.com/vchain-us/immudb/releases/download/v1.4.0/immudb-v1.4.0-linux-amd64
wget -O immudb $URL
elif [[ "$OSTYPE" == "darwin"* ]]; then
URL=https://github.com/vchain-us/immudb/releases/download/v1.3.0/immudb-v1.3.0-darwin-amd64
URL=https://github.com/vchain-us/immudb/releases/download/v1.4.0/immudb-v1.4.0-darwin-amd64
curl -o immudb -L $URL
fi

Expand Down
13 changes: 13 additions & 0 deletions src/main/java/io/codenotary/immudb4j/Entry.java
Expand Up @@ -28,8 +28,15 @@ public class Entry {

private Reference referencedBy;

private long revision;

private Entry() {}

public Entry(byte[] key, byte[] value) {
this.key = key;
this.value = value;
}

public static Entry valueOf(ImmudbProto.Entry e) {
final Entry entry = new Entry();

Expand All @@ -45,6 +52,8 @@ public static Entry valueOf(ImmudbProto.Entry e) {
entry.referencedBy = Reference.valueOf(e.getReferencedBy());
}

entry.revision = e.getRevision();

return entry;
}

Expand All @@ -68,6 +77,10 @@ public Reference getReferenceBy() {
return referencedBy;
}

public long getRevision() {
return revision;
}

public byte[] getEncodedKey() {
if (referencedBy == null) {
return Utils.wrapWithPrefix(key, Consts.SET_KEY_PREFIX);
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/io/codenotary/immudb4j/FileImmuStateHolder.java
Expand Up @@ -59,21 +59,21 @@ private FileImmuStateHolder(Builder builder) throws IOException, IllegalStateExc
}

@Override
public synchronized ImmuState getState(String serverUuid, String database) {
return stateHolder.getState(serverUuid, database);
public synchronized ImmuState getState(String database) {
return stateHolder.getState(database);
}

@Override
public synchronized void setState(String serverUuid, ImmuState state) throws IllegalStateException {
public synchronized void setState(ImmuState state) throws IllegalStateException {

ImmuState currentState = stateHolder.getState(serverUuid, state.getDatabase());
ImmuState currentState = stateHolder.getState(state.getDatabase());
if (currentState != null && currentState.getTxId() >= state.getTxId()) {
return;
}

stateHolder.setState(serverUuid, state);
stateHolder.setState(state);

Path newStateFile = statesFolder.resolve("state_" + serverUuid + "_" + state.getDatabase() + "_" + System.nanoTime());
Path newStateFile = statesFolder.resolve("state_" + state.getDatabase() + "_" + System.nanoTime());

if (Files.exists(newStateFile)) {
throw new RuntimeException("Failed attempting to create a new state file. Please retry.");
Expand Down