|
From: <vh...@us...> - 2013-03-28 15:41:33
|
Revision: 16182
http://unicore.svn.sourceforge.net/unicore/?rev=16182&view=rev
Author: vhuber
Date: 2013-03-28 15:41:24 +0000 (Thu, 28 Mar 2013)
Log Message:
-----------
Browse DataView: File Transfer between UNICORE Storages implemented (!!!)
Modified Paths:
--------------
unicore-portal/trunk/grid.core/src/main/java/eu/unicore/portal/grid/core/data/u6/U6DataEndpoint.java
Modified: unicore-portal/trunk/grid.core/src/main/java/eu/unicore/portal/grid/core/data/u6/U6DataEndpoint.java
===================================================================
--- unicore-portal/trunk/grid.core/src/main/java/eu/unicore/portal/grid/core/data/u6/U6DataEndpoint.java 2013-03-28 15:10:04 UTC (rev 16181)
+++ unicore-portal/trunk/grid.core/src/main/java/eu/unicore/portal/grid/core/data/u6/U6DataEndpoint.java 2013-03-28 15:41:24 UTC (rev 16182)
@@ -6,15 +6,20 @@
import java.io.IOException;
import java.net.URI;
+import org.apache.commons.httpclient.URIException;
import org.apache.commons.vfs2.FileName;
+import org.apache.commons.vfs2.FileObject;
+import org.apache.commons.vfs2.FileSystem;
import org.unigrids.services.atomic.types.ProtocolType;
import de.fzj.unicore.uas.client.StorageClient;
+import de.fzj.unicore.uas.client.TransferControllerClient;
import eu.unicore.portal.core.data.DataEndpoint;
import eu.unicore.portal.core.data.GenericDataEndpoint;
import eu.unicore.portal.core.threads.IProgressMonitor;
import eu.unicore.portal.core.threads.ProgressUtils;
+import eu.unicore.portal.grid.core.utils.URIUtils;
/**
* Implementation of a data endpoint based on Unicore storages.
@@ -59,7 +64,7 @@
return (U6StorageFileObject)super.getVFSRoot();
}
- public StorageClient getSMS() throws IOException{
+ public StorageClient getStorageClient() throws IOException{
return getVFSRoot().getFileSystem().getStorageClient();
}
@@ -75,7 +80,7 @@
private String[] getSupportedProtocols(){
try{
- ProtocolType.Enum[]protocols=getSMS().getSupportedProtocols();
+ ProtocolType.Enum[] protocols = getStorageClient().getSupportedProtocols();
String[]res=new String[protocols.length];
for(int i=0; i<protocols.length;i++){
res[i]=protocols[i].toString();
@@ -89,13 +94,31 @@
@Override
public void pullDataFrom(DataEndpoint other, String protocol,
FileName source, FileName target, IProgressMonitor progress) {
- //progress = ProgressUtils.getNonNullMonitorFor(progress);
+ progress = ProgressUtils.getNonNullMonitorFor(progress);
try {
- String sourcePath = source.getPathDecoded();
- Object destinationURL = getAddressForPulling(protocol, target);
- System.out.println("Sending file '"+sourcePath+"' to "+destinationURL);
+
+ String srcRoot = getVFSRoot().getURL().toString();
+ String srcPath = source.getPath();
+ String src = srcPath;
+ System.out.println("src: "+src);
+
+ String dest = (String)getAddressForPulling(protocol, target);
+ System.out.println("dest: "+dest);
+
+
+ System.out.println("Sending file '"+src+"' to "+dest);
// TODO sending of file
- //getSMS().sendFile(sourcePath, destinationURL.toString());
+ TransferControllerClient c = getStorageClient().sendFile(src, dest);
+ System.out.println("Connection status: "+c.getConnectionStatus()+ "Bytes to transfer: "+c.getSize());
+ if (c.getSize() >= 0 && c.checkConnection(3000))
+ {
+ while(!c.isComplete() && !c.hasFailed()) {
+ System.out.println("Status:"+c.getStatusSummary()+" transfered_bytes: "+c.getTransferredBytes()+" of "+c.getSize()+" Transfer_rate:"+c.getRate());
+ progress.setProgress(c.getTransferredBytes()/c.getSize());
+ Thread.sleep(1000);
+ }
+ System.out.println("Status:"+c.getStatus()+" transfered byte: "+c.getTransferredBytes());
+ }
} catch (Exception e) {
// TODO Auto-generated catch block
@@ -104,16 +127,27 @@
finally
{
if (progress != null) {
+ System.out.println("Cancel progress");
progress.cancel();
+ System.out.println("Progress done");
progress.done();
}
}
}
+ /**
+ * Construct the destination address for file transfer (protocol:https://....)
+ */
@Override
public Object getAddressForPulling(String protocol, FileName file) {
- // TODO Auto-generated method stub
- return protocol+"://"+file.getURI();
+
+ String uri = file.getURI().toString();
+ int index = uri.indexOf(":");
+ if (index != -1) {
+ uri = protocol + ":" + "https" + uri.substring(index);
+ return uri;
+ }
+ return null;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|