git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/branches/data-access/sh-fuse-integration/1.0@181088 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
bfb4fabd69
commit
c7be9c9c9c
|
@ -11,6 +11,7 @@ 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.SecurityTokenProvider;
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||||
|
import org.gcube.common.gxrest.response.outbound.ErrorCode;
|
||||||
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;
|
||||||
import org.gcube.common.storagehub.client.dsl.FileContainer;
|
import org.gcube.common.storagehub.client.dsl.FileContainer;
|
||||||
|
@ -83,7 +84,7 @@ public class StorageHubFS extends FuseStubFS {
|
||||||
|
|
||||||
logger.trace(Thread.currentThread().getName()+" ) calling write "+ size+" "+offset);
|
logger.trace(Thread.currentThread().getName()+" ) calling write "+ size+" "+offset);
|
||||||
SHFile file = tempFiles.get(path);
|
SHFile file = tempFiles.get(path);
|
||||||
|
|
||||||
return file.write(buf, size, offset);
|
return file.write(buf, size, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,13 +115,13 @@ public class StorageHubFS extends FuseStubFS {
|
||||||
if (pathUtils.getPath(path) != null) {
|
if (pathUtils.getPath(path) != null) {
|
||||||
return -ErrorCodes.EEXIST();
|
return -ErrorCodes.EEXIST();
|
||||||
}
|
}
|
||||||
|
|
||||||
uploadFile(path);
|
|
||||||
return 0;
|
return uploadFile(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void uploadFile(String path) {
|
private int uploadFile(String path) {
|
||||||
final ItemContainer<? extends Item> parentContainer;
|
final ItemContainer<? extends Item> parentContainer;
|
||||||
|
|
||||||
if (path.substring(1).contains("/")) {
|
if (path.substring(1).contains("/")) {
|
||||||
|
@ -128,6 +129,13 @@ public class StorageHubFS extends FuseStubFS {
|
||||||
parentContainer= pathUtils.getPath(parentPath);
|
parentContainer= pathUtils.getPath(parentPath);
|
||||||
} else parentContainer = rootDirectory;
|
} else parentContainer = rootDirectory;
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (!((FolderContainer) parentContainer).canWrite())
|
||||||
|
return -ErrorCodes.EACCES();
|
||||||
|
}catch (Exception e) {
|
||||||
|
return -ErrorCodes.EIO();
|
||||||
|
}
|
||||||
|
|
||||||
final FSInputStream stream = new FSInputStream();
|
final FSInputStream stream = new FSInputStream();
|
||||||
|
|
||||||
FileUpload fileUpload = new FileUpload(stream);
|
FileUpload fileUpload = new FileUpload(stream);
|
||||||
|
@ -146,8 +154,9 @@ public class StorageHubFS extends FuseStubFS {
|
||||||
cache.remove(path);
|
cache.remove(path);
|
||||||
}
|
}
|
||||||
})).start();
|
})).start();
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized int getattr(String path, FileStat stat) {
|
public synchronized int getattr(String path, FileStat stat) {
|
||||||
|
@ -180,7 +189,7 @@ public class StorageHubFS extends FuseStubFS {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void getAttrSHItem(ItemContainer<? extends Item> container, FileStat stat) throws IllegalArgumentException{
|
private void getAttrSHItem(ItemContainer<? extends Item> container, FileStat stat) throws IllegalArgumentException{
|
||||||
if (container.getType()==ContainerType.FILE) {
|
if (container.getType()==ContainerType.FILE) {
|
||||||
|
@ -221,9 +230,6 @@ public class StorageHubFS extends FuseStubFS {
|
||||||
SecurityTokenProvider.instance.set(token);
|
SecurityTokenProvider.instance.set(token);
|
||||||
|
|
||||||
logger.trace(Thread.currentThread().getName()+" ) calling mkdir");
|
logger.trace(Thread.currentThread().getName()+" ) calling mkdir");
|
||||||
if (pathUtils.getPath(path) != null) {
|
|
||||||
return -ErrorCodes.EEXIST();
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemContainer<? extends Item> parentContainer;
|
ItemContainer<? extends Item> parentContainer;
|
||||||
|
|
||||||
|
@ -252,11 +258,11 @@ public class StorageHubFS extends FuseStubFS {
|
||||||
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);
|
||||||
SecurityTokenProvider.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());
|
||||||
|
|
||||||
SHFile fileDownload = null;
|
SHFile fileDownload = null;
|
||||||
|
|
||||||
boolean loop =false;
|
boolean loop =false;
|
||||||
do {
|
do {
|
||||||
synchronized (tempFiles) {
|
synchronized (tempFiles) {
|
||||||
|
@ -268,15 +274,15 @@ public class StorageHubFS extends FuseStubFS {
|
||||||
loop=false;
|
loop=false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Thread.sleep(500);
|
Thread.sleep(500);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}while(loop);
|
}while(loop);
|
||||||
|
|
||||||
|
|
||||||
synchronized (tempFiles) {
|
synchronized (tempFiles) {
|
||||||
|
|
||||||
if (tempFiles.containsKey(path) && tempFiles.get(path) instanceof FileDownload) {
|
if (tempFiles.containsKey(path) && tempFiles.get(path) instanceof FileDownload) {
|
||||||
|
@ -301,11 +307,11 @@ public class StorageHubFS extends FuseStubFS {
|
||||||
tempFiles.put(path, fileDownload);
|
tempFiles.put(path, fileDownload);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int toReturn = fileDownload.read(buf, size, offset);
|
int toReturn = fileDownload.read(buf, size, offset);
|
||||||
|
|
||||||
logger.trace("!!! read ---- returning {}",toReturn);
|
logger.trace("!!! read ---- returning {}",toReturn);
|
||||||
|
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -515,14 +521,14 @@ public class StorageHubFS extends FuseStubFS {
|
||||||
public int readlink(String path, Pointer buf, @size_t long size) {
|
public int readlink(String path, Pointer buf, @size_t long size) {
|
||||||
logger.info("readlink called {}",path);
|
logger.info("readlink called {}",path);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int open(String path, FuseFileInfo fi) {
|
public int open(String path, FuseFileInfo fi) {
|
||||||
logger.info("open called {} {}",path, fi.fh.getMemory().address());
|
logger.info("open called {} {}",path, fi.fh.getMemory().address());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int release(String path, FuseFileInfo fi) {
|
public int release(String path, FuseFileInfo fi) {
|
||||||
logger.info("release called {} {}",path, fi.fh.getMemory().address());
|
logger.info("release called {} {}",path, fi.fh.getMemory().address());
|
||||||
|
@ -532,14 +538,14 @@ public class StorageHubFS extends FuseStubFS {
|
||||||
@Override
|
@Override
|
||||||
public int truncate(String path, long size) {
|
public int truncate(String path, long size) {
|
||||||
logger.info("truncate called {} ",path);
|
logger.info("truncate called {} ",path);
|
||||||
|
|
||||||
ScopeProvider.instance.set(scope);
|
ScopeProvider.instance.set(scope);
|
||||||
SecurityTokenProvider.instance.set(token);
|
SecurityTokenProvider.instance.set(token);
|
||||||
cache.remove(path);
|
cache.remove(path);
|
||||||
uploadFile(path);
|
uploadFile(path);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int access(String path, int mask) {
|
public int access(String path, int mask) {
|
||||||
|
@ -552,7 +558,7 @@ public class StorageHubFS extends FuseStubFS {
|
||||||
logger.trace("utimens called "+path);
|
logger.trace("utimens called "+path);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
<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="WARN" />
|
||||||
|
<logger name="org.gcube" level="WARN" />
|
||||||
|
|
||||||
|
<root level="WARN">
|
||||||
|
<appender-ref ref="STDOUT" />
|
||||||
|
</root>
|
||||||
|
|
||||||
|
</configuration>
|
Loading…
Reference in New Issue