mirror of
https://github.com/usatiuk/dhfs.git
synced 2025-10-29 04:57:48 +01:00
fuse skeleton
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.DS_Store
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.usatiuk.dhfs.storage</groupId>
|
<groupId>com.usatiuk.dhfs.storage</groupId>
|
||||||
<artifactId>server</artifactId>
|
<artifactId>server</artifactId>
|
||||||
@@ -49,6 +50,16 @@
|
|||||||
<version>1.18.32</version>
|
<version>1.18.32</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.serceman</groupId>
|
||||||
|
<artifactId>jnr-fuse</artifactId>
|
||||||
|
<version>0.5.7</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.jnr</groupId>
|
||||||
|
<artifactId>jnr-ffi</artifactId>
|
||||||
|
<version>2.2.16</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@@ -100,7 +111,9 @@
|
|||||||
</executions>
|
</executions>
|
||||||
<configuration>
|
<configuration>
|
||||||
<systemPropertyVariables>
|
<systemPropertyVariables>
|
||||||
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
|
<native.image.path>
|
||||||
|
${project.build.directory}/${project.build.finalName}-runner
|
||||||
|
</native.image.path>
|
||||||
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
|
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
|
||||||
<maven.home>${maven.home}</maven.home>
|
<maven.home>${maven.home}</maven.home>
|
||||||
</systemPropertyVariables>
|
</systemPropertyVariables>
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.usatiuk.dhfs.storage.files.api;
|
||||||
|
|
||||||
|
import io.quarkus.grpc.GrpcService;
|
||||||
|
import io.smallrye.mutiny.Uni;
|
||||||
|
|
||||||
|
@GrpcService
|
||||||
|
public class DhfsFileGrpcService implements DhfsFilesGrpc {
|
||||||
|
@Override
|
||||||
|
public Uni<FindFilesReply> findFiles(FindFilesRequest request) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Uni<ReadFileReply> readFile(ReadFileRequest request) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Uni<WriteFileReply> writeFile(WriteFileRequest request) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Uni<DeleteFileReply> deleteFile(DeleteFileRequest request) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package com.usatiuk.dhfs.storage.files.objects;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class DirEntry implements Serializable {
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.usatiuk.dhfs.storage.files.objects;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class Directory extends DirEntry {
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.usatiuk.dhfs.storage.files.objects;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class File extends DirEntry {
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.usatiuk.dhfs.storage.files.service;
|
||||||
|
|
||||||
|
import com.usatiuk.dhfs.storage.files.api.*;
|
||||||
|
import io.smallrye.mutiny.Uni;
|
||||||
|
|
||||||
|
public interface DhfsFileService {
|
||||||
|
public Uni<FindFilesReply> findFiles(FindFilesRequest request);
|
||||||
|
|
||||||
|
public Uni<ReadFileReply> readFile(ReadFileRequest request) ;
|
||||||
|
|
||||||
|
public Uni<WriteFileReply> writeFile(WriteFileRequest request) ;
|
||||||
|
|
||||||
|
public Uni<DeleteFileReply> deleteFile(DeleteFileRequest request) ;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.usatiuk.dhfs.storage.files.service;
|
||||||
|
|
||||||
|
import com.usatiuk.dhfs.storage.objects.repository.ObjectRepository;
|
||||||
|
import io.vertx.mutiny.core.Vertx;
|
||||||
|
import jakarta.enterprise.context.ApplicationScoped;
|
||||||
|
import jakarta.inject.Inject;
|
||||||
|
|
||||||
|
@ApplicationScoped
|
||||||
|
public class DhfsFileServiceImp {
|
||||||
|
@Inject
|
||||||
|
Vertx vertx;
|
||||||
|
@Inject
|
||||||
|
ObjectRepository objectRepository;
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package com.usatiuk.dhfs.storage.fuse;
|
||||||
|
|
||||||
|
import io.quarkus.logging.Log;
|
||||||
|
import io.quarkus.runtime.Shutdown;
|
||||||
|
import io.quarkus.runtime.StartupEvent;
|
||||||
|
import jakarta.annotation.Priority;
|
||||||
|
import jakarta.enterprise.context.ApplicationScoped;
|
||||||
|
import jakarta.enterprise.event.Observes;
|
||||||
|
import jnr.ffi.Pointer;
|
||||||
|
import org.eclipse.microprofile.config.inject.ConfigProperty;
|
||||||
|
import ru.serce.jnrfuse.FuseFillDir;
|
||||||
|
import ru.serce.jnrfuse.FuseStubFS;
|
||||||
|
import ru.serce.jnrfuse.struct.FileStat;
|
||||||
|
import ru.serce.jnrfuse.struct.FuseFileInfo;
|
||||||
|
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
|
@ApplicationScoped
|
||||||
|
public class DhfsFuse extends FuseStubFS {
|
||||||
|
@ConfigProperty(name = "dhfs.fuse.root")
|
||||||
|
String root;
|
||||||
|
|
||||||
|
void init(@Observes @Priority(100000) StartupEvent event) {
|
||||||
|
Paths.get(root).toFile().mkdirs();
|
||||||
|
Log.info("Mounting with root " + root);
|
||||||
|
|
||||||
|
mount(Paths.get(root));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getattr(String path, FileStat stat) {
|
||||||
|
return super.getattr(path, stat);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int open(String path, FuseFileInfo fi) {
|
||||||
|
return super.open(path, fi);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int read(String path, Pointer buf, long size, long offset, FuseFileInfo fi) {
|
||||||
|
return super.read(path, buf, size, offset, fi);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int write(String path, Pointer buf, long size, long offset, FuseFileInfo fi) {
|
||||||
|
return super.write(path, buf, size, offset, fi);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int readdir(String path, Pointer buf, FuseFillDir filter, long offset, FuseFileInfo fi) {
|
||||||
|
return super.readdir(path, buf, filter, offset, fi);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Shutdown
|
||||||
|
void shutdown() {
|
||||||
|
Log.info("Unmounting");
|
||||||
|
umount();
|
||||||
|
Log.info("Unmounted");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.usatiuk.dhfs.storage.objects.api;
|
package com.usatiuk.dhfs.storage.objects.api;
|
||||||
|
|
||||||
import com.google.protobuf.ByteString;
|
import com.google.protobuf.ByteString;
|
||||||
import com.usatiuk.dhfs.storage.api.*;
|
|
||||||
import com.usatiuk.dhfs.storage.objects.repository.ObjectRepository;
|
import com.usatiuk.dhfs.storage.objects.repository.ObjectRepository;
|
||||||
import io.quarkus.grpc.GrpcService;
|
import io.quarkus.grpc.GrpcService;
|
||||||
import io.smallrye.mutiny.Uni;
|
import io.smallrye.mutiny.Uni;
|
||||||
|
|||||||
52
server/src/main/proto/dhfs_files.proto
Normal file
52
server/src/main/proto/dhfs_files.proto
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
option java_multiple_files = true;
|
||||||
|
option java_package = "com.usatiuk.dhfs.storage.files.api";
|
||||||
|
option java_outer_classname = "DhfsFilesApi";
|
||||||
|
|
||||||
|
package hello;
|
||||||
|
|
||||||
|
service DhfsFilesGrpc {
|
||||||
|
rpc FindFiles (FindFilesRequest) returns (FindFilesReply) {}
|
||||||
|
rpc ReadFile (ReadFileRequest) returns (ReadFileReply) {}
|
||||||
|
rpc WriteFile (WriteFileRequest) returns (WriteFileReply) {}
|
||||||
|
rpc DeleteFile (DeleteFileRequest) returns (DeleteFileReply) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
message FindFilesRequest {
|
||||||
|
string namespace = 1;
|
||||||
|
string prefix = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message FindFilesReply {
|
||||||
|
message FindFilesEntry {
|
||||||
|
string name = 1;
|
||||||
|
}
|
||||||
|
repeated FindFilesEntry found = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ReadFileRequest {
|
||||||
|
string namespace = 1;
|
||||||
|
string name = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ReadFileReply {
|
||||||
|
bytes data = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
message WriteFileRequest {
|
||||||
|
string namespace = 1;
|
||||||
|
string name = 2;
|
||||||
|
bytes data = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
message WriteFileReply {
|
||||||
|
}
|
||||||
|
|
||||||
|
message DeleteFileRequest {
|
||||||
|
string namespace = 1;
|
||||||
|
string name = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message DeleteFileReply {
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@ syntax = "proto3";
|
|||||||
|
|
||||||
option java_multiple_files = true;
|
option java_multiple_files = true;
|
||||||
option java_package = "com.usatiuk.dhfs.storage.objects.api";
|
option java_package = "com.usatiuk.dhfs.storage.objects.api";
|
||||||
option java_outer_classname = "DhfsStorageApi";
|
option java_outer_classname = "DhfsObjectsApi";
|
||||||
|
|
||||||
package hello;
|
package hello;
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
quarkus.grpc.server.use-separate-server=false
|
quarkus.grpc.server.use-separate-server=false
|
||||||
dhfs.filerepo.root=${HOME}/dhfs_root
|
dhfs.filerepo.root=${HOME}/dhfs_data/dhfs_root
|
||||||
|
dhfs.fuse.root=${HOME}/dhfs_data/dhfs_fuse_root
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.usatiuk.dhfs.storage;
|
package com.usatiuk.dhfs.storage;
|
||||||
|
|
||||||
import com.google.protobuf.ByteString;
|
import com.google.protobuf.ByteString;
|
||||||
import com.usatiuk.dhfs.storage.api.*;
|
import com.usatiuk.dhfs.storage.objects.api.*;
|
||||||
import io.quarkus.grpc.GrpcClient;
|
import io.quarkus.grpc.GrpcClient;
|
||||||
import io.quarkus.test.junit.QuarkusTest;
|
import io.quarkus.test.junit.QuarkusTest;
|
||||||
import org.eclipse.microprofile.config.inject.ConfigProperty;
|
import org.eclipse.microprofile.config.inject.ConfigProperty;
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
dhfs.filerepo.root=${HOME}/dhfs_root_test
|
dhfs.filerepo.root=${HOME}/dhfs_data/dhfs_root_test
|
||||||
|
dhfs.fuse.root=${HOME}/dhfs_data/dhfs_fuse_root_test
|
||||||
|
|||||||
Reference in New Issue
Block a user