mirror of
https://github.com/usatiuk/dhfs.git
synced 2025-10-28 20:47:49 +01:00
working crapfs
This commit is contained in:
@@ -72,6 +72,7 @@ public class DhfsFileService {
|
||||
|
||||
return txm.run(() -> {
|
||||
var file = alloc.create(File.class, new JObjectKey(path));
|
||||
file.setChunks(new TreeMap<>());
|
||||
curTx.putObject(file);
|
||||
return Optional.of(path);
|
||||
});
|
||||
|
||||
@@ -10,13 +10,12 @@ dhfs.files.write_merge_limit=1.2
|
||||
# Don't take blocks of this size and above when merging
|
||||
dhfs.files.write_merge_max_chunk_to_take=1
|
||||
dhfs.files.write_last_chunk_limit=1.5
|
||||
quarkus.log.category."com.usatiuk.dhfs".min-level=TRACE
|
||||
quarkus.log.category."com.usatiuk.dhfs".level=TRACE
|
||||
quarkus.log.category."com.usatiuk.dhfs".min-level=INFO
|
||||
quarkus.log.category."com.usatiuk.dhfs".level=INFO
|
||||
quarkus.http.insecure-requests=enabled
|
||||
quarkus.http.ssl.client-auth=required
|
||||
|
||||
dhfs.objects.persistence.files.root=${HOME}/dhfs_default/dhfsdb
|
||||
quarkus.hibernate-orm.database.generation=drop-and-create
|
||||
quarkus.datasource.jdbc.url=jdbc:h2:file:${HOME}/dhfs_default/dhfsdb
|
||||
quarkus.datasource.db-kind=h2
|
||||
|
||||
quarkus.hibernate-orm.cache."org.acme.files.objects.ChunkData".memory.object-count=500
|
||||
@@ -80,11 +80,11 @@
|
||||
<artifactId>objects-common</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.usatiuk</groupId>
|
||||
<artifactId>objects-common-deployment</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.usatiuk</groupId>-->
|
||||
<!-- <artifactId>objects-common-deployment</artifactId>-->
|
||||
<!-- <version>1.0-SNAPSHOT</version>-->
|
||||
<!-- </dependency>-->
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -13,6 +13,7 @@ import io.quarkus.logging.Log;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.ref.Cleaner;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.*;
|
||||
@@ -85,7 +86,7 @@ public class JObjectManager {
|
||||
//noinspection unused
|
||||
try (var readLock = _storageReadLocker.lock(key)) {
|
||||
var read = objectStorage.readObject(key).orElse(null);
|
||||
if (read == null) throw new IllegalArgumentException("Object not found: " + key);
|
||||
if (read == null) return null;
|
||||
|
||||
var got = objectSerializer.deserialize(read);
|
||||
|
||||
@@ -168,6 +169,27 @@ public class JObjectManager {
|
||||
return transactionFactory.createTransaction(counter, new TransactionObjectSourceImpl(counter));
|
||||
}
|
||||
|
||||
// FIXME:
|
||||
private static class SimpleTxManifest implements Serializable, TxManifest {
|
||||
private final List<JObjectKey> _written;
|
||||
private final List<JObjectKey> _deleted;
|
||||
|
||||
public SimpleTxManifest(List<JObjectKey> written, List<JObjectKey> deleted) {
|
||||
_written = written;
|
||||
_deleted = deleted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JObjectKey> getWritten() {
|
||||
return _written;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JObjectKey> getDeleted() {
|
||||
return _deleted;
|
||||
}
|
||||
}
|
||||
|
||||
public void commit(TransactionPrivate tx) {
|
||||
// This also holds the weak references
|
||||
var toUnlock = new LinkedList<VoidFn>();
|
||||
@@ -290,18 +312,7 @@ public class JObjectManager {
|
||||
|
||||
Log.tracef("Committing transaction %d to storage", tx.getId());
|
||||
|
||||
objectStorage.commitTx(new TxManifest() {
|
||||
@Override
|
||||
public List<JObjectKey> getWritten() {
|
||||
// FIXME:
|
||||
return written.stream().map(JData::getKey).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JObjectKey> getDeleted() {
|
||||
return List.of();
|
||||
}
|
||||
});
|
||||
objectStorage.commitTx(new SimpleTxManifest(written.stream().map(JData::getKey).toList(), Collections.emptyList()));
|
||||
} catch (Throwable t) {
|
||||
Log.error("Error when committing transaction", t);
|
||||
throw t;
|
||||
|
||||
@@ -13,6 +13,10 @@ public interface TransactionManager {
|
||||
void rollback();
|
||||
|
||||
default <T> T run(Supplier<T> supplier) {
|
||||
if (current() != null) {
|
||||
return supplier.get();
|
||||
}
|
||||
|
||||
begin();
|
||||
try {
|
||||
var ret = supplier.get();
|
||||
@@ -25,6 +29,11 @@ public interface TransactionManager {
|
||||
}
|
||||
|
||||
default void run(VoidFn fn) {
|
||||
if (current() != null) {
|
||||
fn.apply();
|
||||
return;
|
||||
}
|
||||
|
||||
begin();
|
||||
try {
|
||||
fn.apply();
|
||||
|
||||
Reference in New Issue
Block a user