Update LLDatabaseConnection.java and LLLocalDatabaseConnection.java

This commit is contained in:
Andrea Cavalli 2021-01-30 21:30:18 +01:00
parent a1d4731ae3
commit 490d15413e
2 changed files with 16 additions and 22 deletions

View File

@ -4,10 +4,11 @@ import it.cavallium.dbengine.database.analyzer.TextFieldsAnalyzer;
import java.io.IOException;
import java.time.Duration;
import java.util.List;
import reactor.core.publisher.Mono;
public interface LLDatabaseConnection {
void connect() throws IOException;
Mono<Void> connect();
LLKeyValueDatabase getDatabase(String name, List<Column> columns, boolean lowMemory) throws IOException;
@ -18,9 +19,5 @@ public interface LLDatabaseConnection {
Duration commitDebounceTime,
boolean lowMemory) throws IOException;
void disconnect() throws IOException;
void ping() throws IOException;
double getMediumLatencyMillis() throws IOException;
Mono<Void> disconnect();
}

View File

@ -10,6 +10,8 @@ import it.cavallium.dbengine.database.Column;
import it.cavallium.dbengine.database.LLDatabaseConnection;
import it.cavallium.dbengine.database.LLLuceneIndex;
import it.cavallium.dbengine.database.analyzer.TextFieldsAnalyzer;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;
public class LLLocalDatabaseConnection implements LLDatabaseConnection {
@ -22,10 +24,15 @@ public class LLLocalDatabaseConnection implements LLDatabaseConnection {
}
@Override
public void connect() throws IOException {
public Mono<Void> connect() {
return Mono
.<Void>fromCallable(() -> {
if (Files.notExists(basePath)) {
Files.createDirectories(basePath);
}
return null;
})
.subscribeOn(Schedulers.boundedElastic());
}
@Override
@ -62,17 +69,7 @@ public class LLLocalDatabaseConnection implements LLDatabaseConnection {
}
@Override
public void disconnect() throws IOException {
}
@Override
public void ping() {
}
@Override
public double getMediumLatencyMillis() {
return 0;
public Mono<Void> disconnect() {
return Mono.empty();
}
}