Examples of ZFSFileSystem


Examples of org.jvnet.solaris.libzfs.ZFSFileSystem

            List<ZFSFileSystem> roots = zfs.roots();
            if(roots.isEmpty())
                return false;       // no active ZFS pool

            // if we don't run on a ZFS file system, activate
            ZFSFileSystem hudsonZfs = zfs.getFileSystemByMountPoint(Jenkins.getInstance().getRootDir());
            if(hudsonZfs!=null)
                return false;       // already on ZFS

            // decide what file system we'll create
            ZFSFileSystem pool = roots.get(0);
            prospectiveZfsFileSystemName = computeHudsonFileSystemName(zfs,pool);

            return true;
        } catch (Exception e) {
            LOGGER.log(Level.WARNING, "Failed to detect whether Hudson is on ZFS",e);
View Full Code Here

Examples of org.jvnet.solaris.libzfs.ZFSFileSystem

            public String call() throws IOException {
                PrintStream out = listener.getLogger();

                LibZFS zfs = new LibZFS();
                ZFSFileSystem existing = zfs.getFileSystemByMountPoint(home);
                if(existing!=null) {
                    // no need for migration
                    out.println(home+" is already on ZFS. Doing nothing");
                    return existing.getName();
                }

                String name = computeHudsonFileSystemName(zfs, zfs.roots().get(0));
                out.println("Creating "+name);
                ZFSFileSystem hudson = zfs.create(name, ZFSFileSystem.class);

                // mount temporarily to set the owner right
                File dir = Util.createTempDir();
                hudson.setMountPoint(dir);
                hudson.mount();
                if(LIBC.chown(dir.getPath(),uid,gid)!=0)
                    throw new IOException("Failed to chown "+dir);
                hudson.unmount();

                try {
                    hudson.setProperty("hudson:managed-by","hudson"); // mark this file system as "managed by Hudson"

                    ACLBuilder acl = new ACLBuilder();
                    acl.user(userName).withEverything();
                    hudson.allow(acl);
                } catch (ZFSException e) {
                    // revert the file system creation
                    try {
                        hudson.destory();
                    } catch (Exception _) {
                        // but ignore the error and let the original error thrown
                    }
                    throw e;
                }
                return hudson.getName();
            }
        });
    }
View Full Code Here

Examples of org.jvnet.solaris.libzfs.ZFSFileSystem

        PrintStream out = listener.getLogger();

        File home = Jenkins.getInstance().getRootDir();
        // do the migration
        LibZFS zfs = new LibZFS();
        ZFSFileSystem existing = zfs.getFileSystemByMountPoint(home);
        if(existing!=null) {
            out.println(home+" is already on ZFS. Doing nothing");
            return true;
        }

        File tmpDir = Util.createTempDir();

        // mount a new file system to a temporary location
        out.println("Opening "+target);
        ZFSFileSystem hudson = zfs.open(target, ZFSFileSystem.class);
        hudson.setMountPoint(tmpDir);
        hudson.setProperty("hudson:managed-by","hudson"); // mark this file system as "managed by Hudson"
        hudson.mount();

        // copy all the files
        out.println("Copying all existing data files");
        if(system(home,listener, "/usr/bin/cp","-pR",".", tmpDir.getAbsolutePath())!=0) {
            out.println("Failed to copy "+home+" to "+tmpDir);
            return false;
        }

        // unmount
        out.println("Unmounting "+target);
        hudson.unmount(MountFlags.MS_FORCE);

        // move the original directory to the side
        File backup = new File(home.getPath()+".backup");
        out.println("Moving "+home+" to "+backup);
        if(backup.exists())
            Util.deleteRecursive(backup);
        if(!home.renameTo(backup)) {
            out.println("Failed to move your current data "+home+" out of the way");
        }

        // update the mount point
        out.println("Creating a new mount point at "+home);
        if(!home.mkdir())
            throw new IOException("Failed to create mount point "+home);

        out.println("Mounting "+target);
        hudson.setMountPoint(home);
        hudson.mount();

        out.println("Sharing "+target);
        try {
            hudson.setProperty("sharesmb","on");
            hudson.setProperty("sharenfs","on");
            hudson.share();
        } catch (ZFSException e) {
            listener.error("Failed to share the file systems: "+e.getCode());
        }

        // delete back up
View Full Code Here

Examples of org.jvnet.solaris.libzfs.ZFSFileSystem

    public ZFSProvisioner(Node node) throws IOException, InterruptedException {
        rootDataset = node.getRootPath().act(new FileCallable<String>() {
            private static final long serialVersionUID = -2142349338699797436L;

            public String invoke(File f, VirtualChannel channel) throws IOException {
                ZFSFileSystem fs = libzfs.getFileSystemByMountPoint(f);
                if(fs!=null)    return fs.getName();

                // TODO: for now, only support slaves that are already on ZFS.
                throw new IOException("Not on ZFS");
            }
        });
View Full Code Here

Examples of org.jvnet.solaris.libzfs.ZFSFileSystem

       
        ws.act(new FileCallable<Void>() {
            private static final long serialVersionUID = 2129531727963121198L;

            public Void invoke(File f, VirtualChannel channel) throws IOException {
                ZFSFileSystem fs = libzfs.getFileSystemByMountPoint(f);
                if(fs!=null)    return null;    // already on ZFS

                // nope. create a file system
                String fullName = rootDataset + '/' + name;
                listener.getLogger().println("Creating a ZFS file system "+fullName+" at "+f);
                fs = libzfs.create(fullName, ZFSFileSystem.class);
                fs.setMountPoint(f);
                fs.mount();
                return null;
            }
        });
    }
View Full Code Here

Examples of org.jvnet.solaris.libzfs.ZFSFileSystem

    public void discardWorkspace(AbstractProject<?, ?> project, FilePath ws) throws IOException, InterruptedException {
        ws.act(new FileCallable<Void>() {
            private static final long serialVersionUID = 1916618107019257530L;

            public Void invoke(File f, VirtualChannel channel) throws IOException {
                ZFSFileSystem fs = libzfs.getFileSystemByMountPoint(f);
                if(fs!=null)
                    fs.destory(true);
                return null;
            }
        });
    }
View Full Code Here

Examples of org.jvnet.solaris.libzfs.ZFSFileSystem

    public ZFSProvisioner(Node node) throws IOException, InterruptedException {
        this.node = node;
        rootDataset = node.getRootPath().act(new FileCallable<String>() {
            public String invoke(File f, VirtualChannel channel) throws IOException {
                ZFSFileSystem fs = libzfs.getFileSystemByMountPoint(f);
                if(fs!=null)    return fs.getName();

                // TODO: for now, only support slaves that are already on ZFS.
                throw new IOException("Not on ZFS");
            }
        });
View Full Code Here

Examples of org.jvnet.solaris.libzfs.ZFSFileSystem

    public void prepareWorkspace(AbstractBuild<?,?> build, FilePath ws, final TaskListener listener) throws IOException, InterruptedException {
        final String name = build.getProject().getFullName();
       
        ws.act(new FileCallable<Void>() {
            public Void invoke(File f, VirtualChannel channel) throws IOException {
                ZFSFileSystem fs = libzfs.getFileSystemByMountPoint(f);
                if(fs!=null)    return null;    // already on ZFS

                // nope. create a file system
                String fullName = rootDataset + '/' + name;
                listener.getLogger().println("Creating a ZFS file system "+fullName+" at "+f);
                fs = libzfs.create(fullName, ZFSFileSystem.class);
                fs.setMountPoint(f);
                fs.mount();
                return null;
            }
        });
    }
View Full Code Here

Examples of org.jvnet.solaris.libzfs.ZFSFileSystem

    }

    public void discardWorkspace(AbstractProject<?, ?> project, FilePath ws) throws IOException, InterruptedException {
        ws.act(new FileCallable<Void>() {
            public Void invoke(File f, VirtualChannel channel) throws IOException {
                ZFSFileSystem fs = libzfs.getFileSystemByMountPoint(f);
                if(fs!=null)
                    fs.destory(true);
                return null;
            }
        });
    }
View Full Code Here

Examples of org.jvnet.solaris.libzfs.ZFSFileSystem

            List<ZFSFileSystem> roots = zfs.roots();
            if(roots.isEmpty())
                return false;       // no active ZFS pool

            // if we don't run on a ZFS file system, activate
            ZFSFileSystem hudsonZfs = zfs.getFileSystemByMountPoint(Hudson.getInstance().getRootDir());
            if(hudsonZfs!=null)
                return false;       // already on ZFS

            // decide what file system we'll create
            ZFSFileSystem pool = roots.get(0);
            prospectiveZfsFileSystemName = computeHudsonFileSystemName(zfs,pool);

            return true;
        } catch (Exception e) {
            LOGGER.log(Level.WARNING, "Failed to detect whether Hudson is on ZFS",e);
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.