Compare commits

..

2 Commits

6 changed files with 144 additions and 177 deletions

View File

@ -2,20 +2,20 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
# Changelog for org.gcube.data-access.sh-fuse-integration # Changelog for org.gcube.data-access.sh-fuse-integration
## [v2.1.0-SNAPSHOT] ## [v1.2.0-SNAPSHOT] 2022-02-10
- porting to storagehub-client-2.0.0
## [v2.0.0] 2021-05-19
- porting to uma token [#21441]
### Fixes
- removed internal logback.xml #22814
## [v1.1.1] 2021-01-15 ## [v1.1.1] 2021-01-15
### Fixes
- issue on right displayed - issue on right displayed
- [#20417] - https://support.d4science.org/issues/20417
## [v1.1.0] 2020-09-07 ## [v1.1.0] 2020-09-07
- Solved issue on data download [#19651] ### Fixes
- Solved issue on data download (https://support.d4science.org/issues/19651)

29
pom.xml
View File

@ -4,28 +4,22 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.gcube.data-access</groupId> <groupId>org.gcube.data-access</groupId>
<artifactId>sh-fuse-integration</artifactId> <artifactId>sh-fuse-integration</artifactId>
<version>2.1.0-SNAPSHOT</version> <version>1.2.0-SNAPSHOT</version>
<name>SHFuseIntegration</name> <name>SHFuseIntegration</name>
<parent> <parent>
<artifactId>maven-parent</artifactId> <artifactId>maven-parent</artifactId>
<groupId>org.gcube.tools</groupId> <groupId>org.gcube.tools</groupId>
<version>1.2.0</version> <version>1.1.0</version>
<relativePath/> <relativePath />
</parent> </parent>
<scm> <scm>
<connection>scm:git:https://code-repo.d4science.org/gCubeSystem/sh-fuse-integration.git</connection> <connection>scm:git:https://code-repo.d4science.org/gCubeSystem/sh-fuse-integration.git</connection>
<developerConnection>scm:git:https://code-repo.d4science.org/gCubeSystem/sh-fuse-integration.git <developerConnection>scm:git:https://code-repo.d4science.org/gCubeSystem/sh-fuse-integration.git</developerConnection>
</developerConnection>
<url>https://code-repo.d4science.org/gCubeSystem/sh-fuse-integration</url> <url>https://code-repo.d4science.org/gCubeSystem/sh-fuse-integration</url>
</scm> </scm>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<repositories> <repositories>
<repository> <repository>
<id>central</id> <id>central</id>
@ -39,7 +33,7 @@
<dependency> <dependency>
<groupId>org.gcube.distribution</groupId> <groupId>org.gcube.distribution</groupId>
<artifactId>gcube-bom</artifactId> <artifactId>gcube-bom</artifactId>
<version>2.4.1-SNAPSHOT</version> <version>1.5.0</version>
<type>pom</type> <type>pom</type>
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>
@ -50,29 +44,22 @@
<dependency> <dependency>
<groupId>com.github.serceman</groupId> <groupId>com.github.serceman</groupId>
<artifactId>jnr-fuse</artifactId> <artifactId>jnr-fuse</artifactId>
<version>0.5.8</version> <version>0.5.4</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.common</groupId> <groupId>org.gcube.common</groupId>
<artifactId>gxJRS</artifactId> <artifactId>gxJRS</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>common-authorization</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.gcube.common</groupId> <groupId>org.gcube.common</groupId>
<artifactId>storagehub-client-library</artifactId> <artifactId>storagehub-client-library</artifactId>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.common</groupId> <groupId>org.gcube.common</groupId>
<artifactId>storagehub-model</artifactId> <artifactId>storagehub-model</artifactId>
</dependency> <version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-gcube-calls</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.cache2k</groupId> <groupId>org.cache2k</groupId>

View File

@ -10,7 +10,6 @@ import java.util.concurrent.TimeUnit;
import org.cache2k.Cache; import org.cache2k.Cache;
import org.cache2k.Cache2kBuilder; import org.cache2k.Cache2kBuilder;
import org.gcube.common.authorization.library.AuthorizedTasks; import org.gcube.common.authorization.library.AuthorizedTasks;
import org.gcube.common.authorization.library.provider.AccessTokenProvider;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.common.storagehub.client.dsl.ContainerType; import org.gcube.common.storagehub.client.dsl.ContainerType;
@ -64,11 +63,8 @@ public class StorageHubFS extends FuseStubFS {
super(); super();
this.token = token; this.token = token;
this.scope = scope; this.scope = scope;
logger.debug("using token {} in scope {}", token , scope);
ScopeProvider.instance.set(scope); ScopeProvider.instance.set(scope);
AccessTokenProvider.instance.set(token); SecurityTokenProvider.instance.set(token);
client = new StorageHubClient(); client = new StorageHubClient();
rootDirectory = client.getWSRoot(); rootDirectory = client.getWSRoot();
cache = new Cache2kBuilder<String, ItemContainer<Item>>() {} cache = new Cache2kBuilder<String, ItemContainer<Item>>() {}
@ -85,7 +81,7 @@ public class StorageHubFS extends FuseStubFS {
@Override @Override
public synchronized int write(String path, Pointer buf, long size, long offset, FuseFileInfo fi) { public synchronized int write(String path, Pointer buf, long size, long offset, FuseFileInfo fi) {
ScopeProvider.instance.set(scope); ScopeProvider.instance.set(scope);
AccessTokenProvider.instance.set(token); SecurityTokenProvider.instance.set(token);
logger.trace("{}) calling write {} - {} ",Thread.currentThread().getName(), size , offset); logger.trace("{}) calling write {} - {} ",Thread.currentThread().getName(), size , offset);
SHFile file = tempFiles.get(path); SHFile file = tempFiles.get(path);
@ -114,7 +110,7 @@ public class StorageHubFS extends FuseStubFS {
@Override @Override
public synchronized int create(final String path, @mode_t long mode, FuseFileInfo fi) { public synchronized int create(final String path, @mode_t long mode, FuseFileInfo fi) {
ScopeProvider.instance.set(scope); ScopeProvider.instance.set(scope);
AccessTokenProvider.instance.set(token); SecurityTokenProvider.instance.set(token);
logger.trace(Thread.currentThread().getName()+" ) calling create "+path); logger.trace(Thread.currentThread().getName()+" ) calling create "+path);
if (pathUtils.getPath(path) != null) { if (pathUtils.getPath(path) != null) {
@ -167,7 +163,7 @@ public class StorageHubFS extends FuseStubFS {
public int getattr(String path, FileStat stat) { public int getattr(String path, FileStat stat) {
ScopeProvider.instance.set(scope); ScopeProvider.instance.set(scope);
AccessTokenProvider.instance.set(token); SecurityTokenProvider.instance.set(token);
logger.trace(Thread.currentThread().getName()+" ) calling getattr "+path); logger.trace(Thread.currentThread().getName()+" ) calling getattr "+path);
if (Objects.equals(path, "/") || path.contains("Trash") || path.equals("/"+VREFOLDERS_NAME)) { if (Objects.equals(path, "/") || path.contains("Trash") || path.equals("/"+VREFOLDERS_NAME)) {
@ -230,7 +226,7 @@ public class StorageHubFS extends FuseStubFS {
@Override @Override
public int mkdir(String path, @mode_t long mode) { public int mkdir(String path, @mode_t long mode) {
ScopeProvider.instance.set(scope); ScopeProvider.instance.set(scope);
AccessTokenProvider.instance.set(token); SecurityTokenProvider.instance.set(token);
logger.trace(Thread.currentThread().getName()+" ) calling mkdir"); logger.trace(Thread.currentThread().getName()+" ) calling mkdir");
@ -260,7 +256,7 @@ public class StorageHubFS extends FuseStubFS {
@Override @Override
public int read(String path, Pointer buf, @size_t long size, @off_t long offset, FuseFileInfo fi) { public int read(String path, Pointer buf, @size_t long size, @off_t long offset, FuseFileInfo fi) {
ScopeProvider.instance.set(scope); ScopeProvider.instance.set(scope);
AccessTokenProvider.instance.set(token); SecurityTokenProvider.instance.set(token);
logger.trace("!!! read called in path {} with size {} and offset {} and pointer address {}",path, size, offset, buf.address()); logger.trace("!!! read called in path {} with size {} and offset {} and pointer address {}",path, size, offset, buf.address());
@ -328,7 +324,7 @@ public class StorageHubFS extends FuseStubFS {
public int readdir(String path, Pointer buf, FuseFillDir filter, @off_t long offset, FuseFileInfo fi) { public int readdir(String path, Pointer buf, FuseFillDir filter, @off_t long offset, FuseFileInfo fi) {
logger.trace("readdir called"); logger.trace("readdir called");
ScopeProvider.instance.set(scope); ScopeProvider.instance.set(scope);
AccessTokenProvider.instance.set(token); SecurityTokenProvider.instance.set(token);
logger.trace(Thread.currentThread().getName()+" ) calling readdir "+path); logger.trace(Thread.currentThread().getName()+" ) calling readdir "+path);
if (path.contains(".Trash")) return 0; if (path.contains(".Trash")) return 0;
@ -421,7 +417,7 @@ public class StorageHubFS extends FuseStubFS {
@Override @Override
public int rename(String path, String newName) { public int rename(String path, String newName) {
ScopeProvider.instance.set(scope); ScopeProvider.instance.set(scope);
AccessTokenProvider.instance.set(token); SecurityTokenProvider.instance.set(token);
ItemContainer<? extends Item> folder = pathUtils.getPath(path); ItemContainer<? extends Item> folder = pathUtils.getPath(path);
if (folder == null) { if (folder == null) {
@ -459,7 +455,7 @@ public class StorageHubFS extends FuseStubFS {
return -ErrorCodes.EACCES(); return -ErrorCodes.EACCES();
ScopeProvider.instance.set(scope); ScopeProvider.instance.set(scope);
AccessTokenProvider.instance.set(token); SecurityTokenProvider.instance.set(token);
ItemContainer<? extends Item> folder = pathUtils.getPath(path); ItemContainer<? extends Item> folder = pathUtils.getPath(path);
if (folder == null) { if (folder == null) {
@ -469,7 +465,7 @@ public class StorageHubFS extends FuseStubFS {
return -ErrorCodes.ENOTDIR(); return -ErrorCodes.ENOTDIR();
} }
ScopeProvider.instance.set(scope); ScopeProvider.instance.set(scope);
AccessTokenProvider.instance.set(token); SecurityTokenProvider.instance.set(token);
try { try {
checkSpecialFolderRemove(path); checkSpecialFolderRemove(path);
@ -498,7 +494,7 @@ public class StorageHubFS extends FuseStubFS {
@Override @Override
public int unlink(String path) { public int unlink(String path) {
ScopeProvider.instance.set(scope); ScopeProvider.instance.set(scope);
AccessTokenProvider.instance.set(token); SecurityTokenProvider.instance.set(token);
ItemContainer<? extends Item> file = pathUtils.getPath(path); ItemContainer<? extends Item> file = pathUtils.getPath(path);
if (file == null) { if (file == null) {
@ -508,7 +504,7 @@ public class StorageHubFS extends FuseStubFS {
return -ErrorCodes.EISDIR(); return -ErrorCodes.EISDIR();
} }
ScopeProvider.instance.set(scope); ScopeProvider.instance.set(scope);
AccessTokenProvider.instance.set(token); SecurityTokenProvider.instance.set(token);
try { try {
file.delete(); file.delete();
cache.remove(path); cache.remove(path);
@ -544,7 +540,7 @@ public class StorageHubFS extends FuseStubFS {
logger.info("truncate called {} ",path); logger.info("truncate called {} ",path);
ScopeProvider.instance.set(scope); ScopeProvider.instance.set(scope);
AccessTokenProvider.instance.set(token); SecurityTokenProvider.instance.set(token);
cache.remove(path); cache.remove(path);
uploadFile(path); uploadFile(path);
return 0; return 0;

View File

@ -1,17 +0,0 @@
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{0}: %msg%n</pattern>
</encoder>
</appender>
<logger name="org.gcube.data.access.storagehub.fs" level="TRACE" />
<logger name="org.gcube" level="WARN" />
<root level="WARN">
<appender-ref ref="STDOUT" />
</root>
</configuration>

View File

@ -1,7 +1,6 @@
package org.gcube.data.access.storagehub.fuse; package org.gcube.data.access.storagehub.fuse;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.Objects;
import org.gcube.data.access.storagehub.fs.StorageHubFS; import org.gcube.data.access.storagehub.fs.StorageHubFS;
import org.junit.Test; import org.junit.Test;
@ -10,17 +9,19 @@ import jnr.ffi.Platform;
public class FuseTest { public class FuseTest {
@Test
public void mount() { public void mount() {
StorageHubFS memfs = new StorageHubFS("eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJSSklZNEpoNF9qdDdvNmREY0NlUDFfS1l0akcxVExXVW9oMkQ2Tzk1bFNBIn0","/gcube"); StorageHubFS memfs = new StorageHubFS("b7c80297-e4ed-42ab-ab42-fdc0b8b0eabf-98187548","/gcube");
try { try {
String path; String path;
if (Objects.requireNonNull(Platform.getNativePlatform().getOS()) == Platform.OS.WINDOWS) { switch (Platform.getNativePlatform().getOS()) {
case WINDOWS:
System.out.println("Im here"); System.out.println("Im here");
path = "J:\\"; path = "J:\\";
} else break;
default:
path = "/home/lucio/java/mnt"; path = "/home/lucio/java/mnt";
}
memfs.mount(Paths.get(path), true, true); memfs.mount(Paths.get(path), true, true);
} finally { } finally {
memfs.umount(); memfs.umount();

View File

@ -7,7 +7,7 @@
</appender> </appender>
<logger name="org.gcube.data.access.storagehub.fs" level="WARN" /> <logger name="org.gcube.data.access.storagehub.fs" level="TRACE" />
<logger name="org.gcube" level="WARN" /> <logger name="org.gcube" level="WARN" />
<root level="WARN"> <root level="WARN">