Copy/move question

Added by Hajnal Akos about 6 years ago

Dear Developers,

I would like to copy/move a file from one server to another, both accessible via gsiftp.
The copy works fine if both the source and target require the same (security) context -
added once to the session.

However, how can I specify different contexts for source and target?

I tried to add two contexts to the same session (I had no idea how JSaga will determine which
context to use), but I got exception.

Maybe this is not the way how it should be used, but I found no documentation on this topic...

Regards,
Akos Hajnal

import org.ogf.saga.context.Context;
import org.ogf.saga.context.ContextFactory;
import org.ogf.saga.namespace.NSEntry;
import org.ogf.saga.namespace.NSFactory;
import org.ogf.saga.session.Session;
import org.ogf.saga.session.SessionFactory;
import org.ogf.saga.url.URL;
import org.ogf.saga.url.URLFactory;

public class Copy {
    public static void main(String[] args) {
        try {
            URL fromUrl = URLFactory.createURL("gsiftp://dpm.hpcc.sztaki.hu:2811/tmp/test.txt");  
            URL toUrl = URLFactory.createURL("gsiftp://grid143.kfki.hu:2811/tmp/test_copy.txt");  

            Session session = SessionFactory.createSession(false);

            Context fromCtx = ContextFactory.createContext("Globus");
            fromCtx.setAttribute(Context.USERPROXY, "D:/Temp/x509up_source");
            fromCtx.setAttribute(Context.CERTREPOSITORY, "D:/Temp/certificates/");
            session.addContext(fromCtx);

            // without it, copy works fine 
            Context toCtx = ContextFactory.createContext("Globus");
            toCtx.setAttribute(Context.USERPROXY, "D:/Temp/x509up_target");
            toCtx.setAttribute(Context.CERTREPOSITORY, "D:/Temp/certificates/");
            session.addContext(toCtx);

            NSEntry file = NSFactory.createNSEntry(session, fromUrl);
            file.copy(toUrl);

        } catch(Exception x) { x.printStackTrace(); }
    }
}

Stacktrace:

[main] WARN  impl.SagaFactoryImpl  - Failed to load engine properties, using defaults [.\etc\jsaga-config.properties (The system cannot find the path specified)]
AuthenticationFailed: Security context class 'fr.in2p3.jsaga.adaptor.security.NoneSecurityCredential' not supported for protocol: gsiftp
    at fr.in2p3.jsaga.engine.factories.ServiceAdaptorFactory.getCredential(ServiceAdaptorFactory.java:75)
    at fr.in2p3.jsaga.engine.factories.DataAdaptorFactory.getDataAdaptorAndConnect(DataAdaptorFactory.java:97)
    at fr.in2p3.jsaga.impl.namespace.AbstractSyncNSFactoryImpl.doCreateNSFileSync(AbstractSyncNSFactoryImpl.java:77)
    at fr.in2p3.jsaga.impl.namespace.AbstractSyncNSFactoryImpl.doCreateNSEntrySync(AbstractSyncNSFactoryImpl.java:51)
    at fr.in2p3.jsaga.impl.namespace.NSFactoryImpl.doCreateNSEntry(NSFactoryImpl.java:35)
    at org.ogf.saga.namespace.NSFactory.createNSEntry(NSFactory.java:222)
    at org.ogf.saga.namespace.NSFactory.createNSEntry(NSFactory.java:161)
    at org.ogf.saga.namespace.NSFactory.createNSEntry(NSFactory.java:277)
    at Copy.main(Copy.java:29)


Replies (3)

RE: Copy/move question - Added by Schwarz Lionel about 6 years ago

Hi Akos,
1. When a session holds two contexts of the same type ("Globus" in your case) for use with two URLs of the same protocol ("gsiftp" in your case), JSaga cannot know which security context to use with each URL.
You have then to specifically indicate which context maps to which GridFTP server. There are several possibilities, but the easiest way to do this is to add a JSaga-specific attribute named "BaseUrlIncludes":

Context fromCtx = ContextFactory.createContext("Globus");
fromCtx.setVectorAttribute("BaseUrlIncludes", new String[]{"gsiftp://dpm.hpcc.sztaki.hu"});
...
Context toCtx = ContextFactory.createContext("Globus");
fromCtx.setVectorAttribute("BaseUrlIncludes", new String[]{"gsiftp://grid143.kfki.hu"});
...

2. In your code, you try to do a third-party transfer (from a GridFTP server to a GridFTP server). Is it a genuine use-case or just a test? Because, JSaga does not support third-party transfers between servers that need different contexts. In this case, JSaga first transfers the source file locally (in streaming mode, not writing to disk) and forwards it to the target server. This may cause traffic issues on the machine that runs JSaga.
I have not checked this in the code, so maybe you can test this first and let me know what you get.

Cheers
Lio

RE: Copy/move question - Added by Hajnal Akos about 6 years ago

Hi Lio,

1. Thanks, with BaseUrlIncludes attribute I can set multiple contexts, and copy works fine.

2. I think it is a real use-case, and at least in the case of gsiftp, we tried to avoid streaming copy at a higher level.
If both servers use the same context, jSaga does indeed third-party transfer?
(In the case of inter-protocol copies, we will have traffic issues...)

Regards,
Akos

RE: Copy/move question - Added by Schwarz Lionel about 6 years ago

Yes if both source and target servers use the same context, the JSaga GridFTP adaptor does a thrird-party transfer.

Regards,
Lio

(1-3/3)