Package com.sun.enterprise.ee.synchronization.inventory

Examples of com.sun.enterprise.ee.synchronization.inventory.InventoryMgr


                _logger.fine("Inspecting Directory: " + dir);

                File root = new File(dir);

                if (root.isDirectory()) {
                    InventoryMgr mgr = new InventoryMgr(root);
                    //List l = mgr.getAuditInventory();
                    List l = mgr.getInventory();
                    if (l != null) {
                        int length = l.size();
                        for (int j=0; j<length; j++) {
                            localList.add( tDir+File.separator+l.get(j) );
                        }
View Full Code Here


    /**
     * Prunes this directory.
     */
    void prune() {

        InventoryMgr mgr = null;
        if ((_root == null) || (!_root.exists())
                || (_trash == null) || (_crList == null)) {
            return;
        }

        try {
            mgr = new InventoryMgr(_root);

            if (_crList.size() == 0) {
                _logger.log(Level.FINE,
                    "Found empty inventory list from central repository for: "
                    + _root.getPath());
            }

            // converts the inventories to sorted array
            String[] cr = InventoryMgr.transformInventory(_crList);

            // inventory of the cache directory
            List inventory = mgr.getInventory();
            Iterator iter = inventory.iterator();
            while (iter.hasNext()) {
                String f = (String) iter.next();

                // file is not present in central repository
                if (isACandidate(f, cr)) {
                    File file = new File(_root, f);
                    FileHandler handler  = new FileHandler(file, _trash);
                    handler.remove();

                    // remove empty directory
                    File parent = file.getParentFile();
                    String[] children = parent.list();
                    if (children.length == 0) {
                        FileHandler dHandler = new FileHandler(parent, _trash);
                        dHandler.remove();
                    }
                }
            }

        } catch (Exception e) {
            // ignore
        } finally {
            if (mgr != null) {
                try {
                    mgr.removeInventoryFile();
                    mgr.removeGCTargetFile();
                } catch (Exception e) { }
            }
        }
    }
View Full Code Here

    {
        if (_logger.getLevel() == Level.FINE)
        {
            try
            {
                InventoryMgr newMgr = new InventoryMgr(dout);
                List newList = newMgr.getInventory();

                // inventory of the backup dir
                InventoryMgr backupMgr = new InventoryMgr(din);
                List dstList = backupMgr.getInventory();

                // diff between backup and newly synchronized files
                List diffList = backupMgr.getInventoryDiff(dstList, newList);

                // saves the inventory of backup, new synchronized files
                // and their diff
                newMgr.saveAuditList(dstList, "backup_"+suffix);
                newMgr.saveAuditList(newList, "new_"+suffix);
View Full Code Here

        try {
            if (req.isGCEnabled()) {
                String serverName = req.getServerName();
                File f = req.getFile();
                InventoryMgr mgr = new InventoryMgr(f);

                // inventory list for this directory
                List crList = mgr.getInventory();

                // re-sets the inventory with central repository inventory
                // this had client inventory
                if (crList != null) {
                    req.setInventory(crList);
View Full Code Here

        requests[0].setServerName("server");
        requests[0].setBaseDirectory("/tmp/rpct/");
        requests[0].setMetaFileName("/tmp/");
        requests[0].setGCEnabled(true);

        InventoryMgr mgr = new InventoryMgr(new File("."));
        requests[0].setInventory(mgr.getInventory());

        Zipper z = new Zipper(null, 0L);
        z.setBaseDirectory(".");
        byte[] b = z.createZipBytesFromDirectory(".");
View Full Code Here

     * Moves files at random from one dir to another.
     *
     * @throws IOException  if an i/o error
     */
    public void move() throws IOException {
        InventoryMgr mgr = new InventoryMgr(_backupDir);
        List files = mgr.getInventory();

        Iterator iter = files.iterator();
        while (iter.hasNext()) {
            String name = (String) iter.next();
            File from = new File(_backupDir, name);
View Full Code Here

            File f2 = rf.nextFile();
            assertTrue( f2.exists() );
            System.out.println("File: " + f2.getPath());

            // saves inentory
            InventoryMgr iMgr = new InventoryMgr(root);
            List inventory = iMgr.getInventory();

            // sets up GC removal list
            List gcTarget = new ArrayList();
            String file = null;
            for (int i=0; i<inventory.size(); i++) {
                String t = (String) inventory.get(i);
                File tFile = new File(root, t);
                if (tFile.getPath().equals(f1.getPath())) {
                    file = t;
                    if (testCR) {
                        // remove from the CR
                        // inventory.set(i, t+"-TARGET");
                        inventory.remove(i);
                    }
                    break;
                }
            }
            assertTrue(file != null);
            assertTrue(f1.getPath().endsWith(file));
            gcTarget.add(file);
            iMgr.saveGCTargetList(gcTarget);

            // sets up CR inventory
            iMgr.saveInventory(inventory);

            // updated inventory list
            List uInventory = iMgr.getInventory();
            assertTrue(uInventory.size() > 1);

            // updates the time stamp
            System.out.println("Attempting to remove file: " + f1.getPath());
            assertTrue(f1.exists());
View Full Code Here

            SynchronizationMemento m = new SynchronizationMemento(res);

            // populate the dir
            RandomDirTree tree = new RandomDirTree(tmpName);
            tree.populate(true);
            InventoryMgr iMgr = new InventoryMgr(tmpFile);
            List inventory = iMgr.getInventory();

            System.out.println("Number of files in directory [" +tmpName+ "]: "
                + inventory.size());

            // saves a snapshot in memento
            m.saveState();

            // populates the new dir
            RandomFileMover mover =
                new RandomFileMover(getBackupFile(tmpFile),tmpFile,copyEnabled);
            mover.move();
            List moved = mover.getMoveList();
            List copied = mover.getCopyList();

            System.out.println("Number of files moved to directory ["
                + getBackupFile(tmpFile) + "]: " + moved.size());
       
            System.out.println("Number of files copied to directory ["
                + getBackupFile(tmpFile) + "]: " + copied.size());
       
            // merges the two trees
            m.commit();

            List newInventory = iMgr.getInventory();

            System.out.println("Number of files in directory ["
                + tmpFile + "]: " + newInventory.size());

            assertEquals(inventory.size(), newInventory.size());
View Full Code Here

TOP

Related Classes of com.sun.enterprise.ee.synchronization.inventory.InventoryMgr

Copyright © 2018 www.massapicom. 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.