Examples of RemoteFile


Examples of com.googlecode.jrcp.RemoteFile

      System.exit(1);
    }
    final String host = args[0];
    final String user = args[1];
    final String rFile = args[2];
    final RemoteFile remoteFile = new RemoteFile(host, user, rFile);
    if (args.length == 3) {
      // copy remote file to stdout
      remoteFile.copyTo(System.out);
    } else {
      // copy local file to remote file
      final File lFile = new File(args[3]);
      remoteFile.copyFrom(new FileInputStream(lFile), lFile.length());
    }
  }
View Full Code Here

Examples of com.nardoz.restopengov.standalone.models.RemoteFile

    public void handle(String[] args) {

        if(args[1].equals("fetch-url") && args.length > 2) {

            RemoteFile file = new RemoteFile(args[2]);

            if(file.format.toLowerCase().equals("zip")) {
                zipFileFetcher.tell(file);
            } else {
                fileFetcher.tell(file);
View Full Code Here

Examples of com.nardoz.restopengov.standalone.models.RemoteFile

    public void onReceive(Object message) {

        if(message instanceof RemoteFile) {

            RemoteFile zipfile = (RemoteFile) message;

            try {
                URL url = new URL(zipfile.url.toString().replace("https", "http"));
                InputStream stream = url.openStream();

                byte[] buf = new byte[1024];
                ZipInputStream zipinputstream = null;
                ZipEntry entry;
                zipinputstream = new ZipInputStream(stream);

                Integer id = 0;

                while((entry = zipinputstream.getNextEntry()) != null) {

                    id++;

                    Crawler.logger.info("Extracting: " + entry);

                    String format = entry.getName().substring(entry.getName().lastIndexOf('.') + 1);

                    if(!FileReader.handles(format)) {
                        continue;
                    }

                    File tmpFile = new File("tmp/" + entry.getName().replace("/", "-"));
                    FileOutputStream fos = new FileOutputStream(tmpFile);

                    int data;
                    while (0 < (data = zipinputstream.read(buf))){
                        fos.write(buf, 0, data);
                    }

                    fos.close();
                    zipinputstream.closeEntry();

                    Crawler.logger.info("Completed extraction for: " + entry);

                    RemoteFile file = new RemoteFile("file://" + tmpFile.getAbsolutePath());

                    ICSVFetcherResult callback = new ElasticIndexer(client, file.type, file.id + "-" + id);
                    IFormatReader fileReader = FileReader.read(file, callback);

                    if(fileReader != null) {
View Full Code Here

Examples of com.nardoz.restopengov.standalone.models.RemoteFile

    public void onReceive(Object message) {

        if(message instanceof RemoteFile) {

            RemoteFile file = (RemoteFile) message;

            ICSVFetcherResult callback = new ElasticIndexer(client, file.type, file.id);

            try {
View Full Code Here

Examples of io.fathom.cloud.sftp.RemoteFile

            SftpBlobStore.Factory blobStoreFactory;
            String store = nodeData.getStore();
            if (store.startsWith("sftp://")) {
                File path = new File(store.substring(7));
                blobStoreFactory = new SftpBlobStore.Factory(sshConfig, new RemoteFile(path), localCacheDir);
            } else {
                throw new IllegalArgumentException();
            }

            String queue = nodeData.getQueue();
View Full Code Here

Examples of io.fathom.cloud.sftp.RemoteFile

        super(sshConfig);
    }

    @Override
    public void copyImageToRootfs(ImageKey imageId, File rootfsPath) throws IOException {
        RemoteFile imageVolume = getImagePath(imageId);

        List<String> cmd = Lists.newArrayList();
        cmd.add("sudo /sbin/btrfs");
        cmd.add("subvolume");
        cmd.add("snapshot");
        cmd.add(imageVolume.getSshPath().getAbsolutePath());
        cmd.add(rootfsPath.getAbsolutePath());

        SshCommand sshCommand = new SshCommand(sshConfig, Joiner.on(" ").join(cmd));
        sshCommand.run();
    }
View Full Code Here

Examples of io.fathom.cloud.sftp.RemoteFile

            try (RemoteTempFile tar = sftp.buildRemoteTemp()) {
                try (OutputStream os = sftp.writeFile(tar.getSshPath(), WriteMode.Overwrite)) {
                    imageData.copyTo(os);
                }

                RemoteFile tempVolume = getImagePath(tempImageId);

                {
                    String cmd = "sudo btrfs subvolume create " + tempVolume.getSshPath();
                    SshCommand sshCommand = new SshCommand(sshConfig, cmd);
                    sshCommand.run();
                }

                {
                    ShellCommand cmd = ShellCommand.create("/bin/tar");
                    cmd.literal("--numeric-owner");
                    cmd.literal("-f").arg(tar.getSshPath());
                    cmd.literal("-C").arg(tempVolume.getSshPath());
                    cmd.literal("-xz");
                    cmd.useSudo();

                    SshCommand sshCommand = cmd.withSsh(sshConfig);
                    sshCommand.run();
                }

                RemoteFile imageVolume = getImagePath(imageId);
                {
                    String cmd = "sudo btrfs subvolume snapshot -r " + tempVolume.getSshPath() + " "
                            + imageVolume.getSshPath();
                    SshCommand sshCommand = new SshCommand(sshConfig, cmd);
                    sshCommand.run();
                }
            }
        }
View Full Code Here

Examples of io.fathom.cloud.sftp.RemoteFile

            try {
                if (sudo || atomic) {
                    if (atomicTempPath != null) {
                        tempFile = RemoteTempFile.create(sftp, atomicTempPath);
                    } else {
                        tempFile = RemoteTempFile.create(sftp, new RemoteFile(new File("/tmp")));
                    }
                    remoteDest = tempFile.getSshPath();
                }

                try (OutputStream os = sftp.writeFile(remoteDest, WriteMode.Overwrite)) {
                    source.copyTo(os);
                }

                if (chmod != null) {
                    sftp.chmod(remoteDest, chmod);
                }

                // chown and chgrp require CAP_CHOWN / root
                if (chownGroup != null) {
                    sftp.chgrp(remoteDest, chownGroup);
                }

                if (chownUser != null) {
                    sftp.chown(remoteDest, chownUser);
                }

                if (tempFile != null) {
                    if (atomic) {
                        if (sudo) {
                            throw new UnsupportedOperationException("Atomic sudo move not yet implemented");
                        }

                        tempFile.renameTo(new RemoteFile(dest));
                    } else {
                        ShellCommand command = ShellCommand.create("/bin/cp");

                        command.arg(remoteDest);
                        command.arg(dest);
View Full Code Here

Examples of io.fathom.cloud.sftp.RemoteFile

        }
        return new Sftp(sftpChannel, tempDir);
    }

    protected RemoteFile getImagePath(ImageKey imageId) {
        RemoteFile imageDir = getImageBaseDir();
        String name = imageId.getKey() + getImageExtension();
        RemoteFile imageFile = new RemoteFile(imageDir, name);
        return imageFile;
    }
View Full Code Here

Examples of io.fathom.cloud.sftp.RemoteFile

    protected File getVolumePath(VolumeType volumeType, UUID volumeId) {
        return new File("/volumes/" + volumeType.name().toLowerCase() + "/" + volumeId + "/");
    }

    private RemoteFile getImageBaseDir() {
        RemoteFile imageDir = new RemoteFile(new File("/var/fathomcloud/images"));
        return imageDir;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.