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...

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("gsi");  
            URL toUrl = URLFactory.createURL("gsi");  

            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/");

            // 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/");

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

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


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

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[]{"gsi"});
Context toCtx = ContextFactory.createContext("Globus");
fromCtx.setVectorAttribute("BaseUrlIncludes", new String[]{"gsi"});

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.


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...)


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.