Search in sources :

Example 1 with VRL

use of nl.uva.vlet.vrl.VRL in project lobcder by skoulouzis.

the class TestWebWAVFS method deletePhysicalData.

private void deletePhysicalData(Set<PDRIDesc> pdris) throws VlException {
    String endpoint = "";
    for (PDRIDesc p : pdris) {
        VFSClient cli = getVFSClient(p.resourceUrl, p.username, p.password);
        if (p.resourceUrl.startsWith("/")) {
            endpoint = "file:///" + p.resourceUrl;
        } else {
            endpoint = p.resourceUrl;
        }
        VRL vrl = new VRL(endpoint).append("LOBCDER-REPLICA-vTEST").append(p.name);
        // VRL vrl = new VRL(endpoint).append(p.name);
        System.err.println("Deleting: " + vrl);
        cli.openLocation(vrl).delete();
    }
}
Also used : VRL(nl.uva.vlet.vrl.VRL) VFSClient(nl.uva.vlet.vfs.VFSClient) PDRIDesc(nl.uva.cs.lobcder.tests.TestREST.PDRIDesc)

Example 2 with VRL

use of nl.uva.vlet.vrl.VRL in project lobcder by skoulouzis.

the class VPDRI method replicate.

@Override
public void replicate(PDRI source) throws IOException {
    try {
        VRL sourceVRL = new VRL(source.getURI());
        String sourceScheme = sourceVRL.getScheme();
        String desteScheme = vrl.getScheme();
        Logger.getLogger(VPDRI.class.getName()).log(Level.INFO, "Start replicating {0} to {1}", new Object[] { source.getURI(), getURI() });
        double start = System.currentTimeMillis();
        if (!vfsClient.existsDir(vrl.getParent())) {
            VDir remoteDir = vfsClient.mkdirs(vrl.getParent(), true);
        }
        if (desteScheme.equals("swift") && sourceScheme.equals("file") || desteScheme.startsWith("webdav") && sourceScheme.equals("file")) {
            upload(source);
        } else {
            VFile destFile = getVfsClient().createFile(vrl, true);
            VFile sourceFile = getVfsClient().openFile(sourceVRL);
            getVfsClient().copy(sourceFile, destFile);
        }
        // putData(source.getData());
        double elapsed = System.currentTimeMillis() - start;
        double speed = ((source.getLength() * 8.0) * 1000.0) / (elapsed * 1000.0);
        Stats stats = new Stats();
        stats.setSource(source.getHost());
        stats.setDestination(getHost());
        stats.setSpeed(speed);
        stats.setSize(getLength());
        try {
            setSpeed(stats);
        } catch (JAXBException ex) {
            Logger.getLogger(VPDRI.class.getName()).log(Level.WARNING, null, ex);
        }
        String msg = "Source: " + source.getHost() + " Destination: " + vrl.getScheme() + "://" + getHost() + " Replication_Speed: " + speed + " Kbites/sec Repl_Size: " + (getLength()) + " bytes";
        Logger.getLogger(VPDRI.class.getName()).log(Level.INFO, msg);
    // getAsyncDelete(getVfsClient(), vrl).run();
    } catch (VlException ex) {
        throw new IOException(ex);
    }
}
Also used : VRL(nl.uva.vlet.vrl.VRL) JAXBException(javax.xml.bind.JAXBException) Stats(nl.uva.cs.lobcder.rest.wrappers.Stats) VlException(nl.uva.vlet.exception.VlException)

Example 3 with VRL

use of nl.uva.vlet.vrl.VRL in project lobcder by skoulouzis.

the class GetTask method getVFSClient.

private VFSClient getVFSClient(String vrl, String username, String password) throws VlException {
    VFSClient vfsClient = new VFSClient();
    VRSContext context = vfsClient.getVRSContext();
    // Bug in sftp: We have to put the username in the url
    ServerInfo info = context.getServerInfoFor(new VRL(vrl), true);
    String authScheme = info.getAuthScheme();
    if (StringUtil.equals(authScheme, ServerInfo.GSI_AUTH)) {
        // Use the username and password to get access to MyProxy
        GridProxy proxy = new GridProxy(context);
        String pr = context.getProxyAsString();
        context.setGridProxy(proxy);
    }
    if (StringUtil.equals(authScheme, ServerInfo.PASSWORD_AUTH) || StringUtil.equals(authScheme, ServerInfo.PASSWORD_OR_PASSPHRASE_AUTH) || StringUtil.equals(authScheme, ServerInfo.PASSPHRASE_AUTH)) {
        // String username = storageSite.getCredential().getStorageSiteUsername();
        if (username == null) {
            throw new NullPointerException("Username is null!");
        }
        info.setUsername(username);
        // String password = storageSite.getCredential().getStorageSitePassword();
        if (password == null) {
            throw new NullPointerException("password is null!");
        }
        info.setPassword(password);
    }
    info.setAttribute(ServerInfo.ATTR_DEFAULT_YES_NO_ANSWER, true);
    info.setAttribute("sshKnownHostsFile", System.getProperty("user.home") + "/.ssh/known_hosts");
    info.store();
    return vfsClient;
}
Also used : VRSContext(nl.uva.vlet.vrs.VRSContext) VRL(nl.uva.vlet.vrl.VRL) VFSClient(nl.uva.vlet.vfs.VFSClient) ServerInfo(nl.uva.vlet.vrs.ServerInfo) GridProxy(nl.uva.vlet.util.cog.GridProxy)

Example 4 with VRL

use of nl.uva.vlet.vrl.VRL in project lobcder by skoulouzis.

the class TestWebWAVFS method getVFSClient.

private VFSClient getVFSClient(String vrl, String username, String password) throws VlException {
    VFSClient vfsClient = new VFSClient();
    VRSContext context = vfsClient.getVRSContext();
    // Bug in sftp: We have to put the username in the url
    ServerInfo info = context.getServerInfoFor(new VRL(vrl), true);
    String authScheme = info.getAuthScheme();
    if (StringUtil.equals(authScheme, ServerInfo.GSI_AUTH)) {
        // copyVomsAndCerts();
        GridProxy gridProxy = null;
        if (gridProxy == null) {
            // context.setProperty("grid.proxy.location", Constants.PROXY_FILE);
            // Default to $HOME/.globus
            context.setProperty("grid.certificate.location", Global.getUserHome() + "/.globus");
            String vo = username;
            context.setProperty("grid.proxy.voName", vo);
            context.setProperty("grid.proxy.lifetime", "200");
            // gridProxy = GridProxy.loadFrom(context, proxyFile);
            gridProxy = context.getGridProxy();
            if (gridProxy.isValid() == false) {
                gridProxy.setEnableVOMS(true);
                gridProxy.setDefaultVOName(vo);
                gridProxy.createWithPassword(password);
                if (gridProxy.isValid() == false) {
                    throw new VlException("Created Proxy is not Valid!");
                }
            // gridProxy.saveProxyTo(Constants.PROXY_FILE);
            }
        }
    }
    if (StringUtil.equals(authScheme, ServerInfo.PASSWORD_AUTH) || StringUtil.equals(authScheme, ServerInfo.PASSWORD_OR_PASSPHRASE_AUTH) || StringUtil.equals(authScheme, ServerInfo.PASSPHRASE_AUTH)) {
        // String username = storageSite.getCredential().getStorageSiteUsername();
        if (username == null) {
            throw new NullPointerException("Username is null!");
        }
        info.setUsername(username);
        // String password = storageSite.getCredential().getStorageSitePassword();
        if (password == null) {
            throw new NullPointerException("password is null!");
        }
        info.setPassword(password);
    }
    info.setAttribute(ServerInfo.ATTR_DEFAULT_YES_NO_ANSWER, true);
    // if(getVrl().getScheme().equals(VRS.SFTP_SCHEME)){
    // patch for bug with ssh driver
    info.setAttribute("sshKnownHostsFile", System.getProperty("user.home") + "/.ssh/known_hosts");
    // }
    // context.setProperty("chunk.upload", doChunked);
    // info.setAttribute(new VAttribute("chunk.upload", true));
    info.store();
    return vfsClient;
}
Also used : VRSContext(nl.uva.vlet.vrs.VRSContext) VRL(nl.uva.vlet.vrl.VRL) VFSClient(nl.uva.vlet.vfs.VFSClient) ServerInfo(nl.uva.vlet.vrs.ServerInfo) GridProxy(nl.uva.vlet.util.cog.GridProxy) VlException(nl.uva.vlet.exception.VlException)

Example 5 with VRL

use of nl.uva.vlet.vrl.VRL in project lobcder by skoulouzis.

the class WebDAVTest method getVFSClient.

private VFSClient getVFSClient(String vrl, String username, String password) throws VlException {
    VFSClient vfsClient = new VFSClient();
    VRSContext context = vfsClient.getVRSContext();
    // Bug in sftp: We have to put the username in the url
    ServerInfo info = context.getServerInfoFor(new VRL(vrl), true);
    String authScheme = info.getAuthScheme();
    if (StringUtil.equals(authScheme, ServerInfo.GSI_AUTH)) {
        // Use the username and password to get access to MyProxy
        GridProxy proxy = new GridProxy(context);
        String pr = context.getProxyAsString();
        context.setGridProxy(proxy);
    }
    if (StringUtil.equals(authScheme, ServerInfo.PASSWORD_AUTH) || StringUtil.equals(authScheme, ServerInfo.PASSWORD_OR_PASSPHRASE_AUTH) || StringUtil.equals(authScheme, ServerInfo.PASSPHRASE_AUTH)) {
        // String username = storageSite.getCredential().getStorageSiteUsername();
        if (username == null) {
            throw new NullPointerException("Username is null!");
        }
        info.setUsername(username);
        // String password = storageSite.getCredential().getStorageSitePassword();
        if (password == null) {
            throw new NullPointerException("password is null!");
        }
        info.setPassword(password);
    }
    info.setAttribute(ServerInfo.ATTR_DEFAULT_YES_NO_ANSWER, true);
    // if(getVrl().getScheme().equals(VRS.SFTP_SCHEME)){
    // patch for bug with ssh driver
    info.setAttribute("sshKnownHostsFile", System.getProperty("user.home") + "/.ssh/known_hosts");
    // }
    info.store();
    return vfsClient;
}
Also used : VRSContext(nl.uva.vlet.vrs.VRSContext) VRL(nl.uva.vlet.vrl.VRL) VFSClient(nl.uva.vlet.vfs.VFSClient) ServerInfo(nl.uva.vlet.vrs.ServerInfo) GridProxy(nl.uva.vlet.util.cog.GridProxy)

Aggregations

VRL (nl.uva.vlet.vrl.VRL)11 LogicalData (nl.uva.cs.lobcder.resources.LogicalData)4 VlException (nl.uva.vlet.exception.VlException)4 VFSClient (nl.uva.vlet.vfs.VFSClient)4 GridProxy (nl.uva.vlet.util.cog.GridProxy)3 VFile (nl.uva.vlet.vfs.VFile)3 ServerInfo (nl.uva.vlet.vrs.ServerInfo)3 VRSContext (nl.uva.vlet.vrs.VRSContext)3 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)2 InvalidKeyException (java.security.InvalidKeyException)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 NoSuchPaddingException (javax.crypto.NoSuchPaddingException)2 JAXBException (javax.xml.bind.JAXBException)2 VRLSyntaxException (nl.uva.vlet.exception.VRLSyntaxException)2 VNode (nl.uva.vlet.vrs.VNode)2 java.io (java.io)1 UnknownHostException (java.net.UnknownHostException)1 CertificateException (java.security.cert.CertificateException)1