01: /*
02: * This file is part of DrFTPD, Distributed FTP Daemon.
03: *
04: * DrFTPD is free software; you can redistribute it and/or modify
05: * it under the terms of the GNU General Public License as published by
06: * the Free Software Foundation; either version 2 of the License, or
07: * (at your option) any later version.
08: *
09: * DrFTPD is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: * GNU General Public License for more details.
13: *
14: * You should have received a copy of the GNU General Public License
15: * along with DrFTPD; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */
18: package org.drftpd.mirroring.archivetypes;
19:
20: import java.util.ArrayList;
21: import java.util.HashSet;
22: import java.util.Iterator;
23: import java.util.Properties;
24:
25: import net.sf.drftpd.mirroring.Job;
26:
27: import org.apache.log4j.Logger;
28: import org.drftpd.PropertyHelper;
29: import org.drftpd.master.RemoteSlave;
30: import org.drftpd.mirroring.ArchiveType;
31: import org.drftpd.plugins.Archive;
32: import org.drftpd.remotefile.LinkedRemoteFileInterface;
33: import org.drftpd.sections.SectionInterface;
34:
35: /**
36: * @author zubov
37: * @version $Id: MoveReleaseToMostFreeSlaves.java 1398 2006-01-14 20:54:51Z zubov $
38: */
39: public class MoveReleaseToMostFreeSlaves extends ArchiveType {
40: private static final Logger logger = Logger
41: .getLogger(MoveReleaseToMostFreeSlaves.class);
42:
43: public MoveReleaseToMostFreeSlaves(Archive archive,
44: SectionInterface section, Properties props) {
45: super (archive, section, props);
46:
47: if (_numOfSlaves < 1) {
48: throw new IllegalArgumentException(
49: "numOfSlaves has to be > 0 for section "
50: + section.getName());
51: }
52: }
53:
54: public HashSet<RemoteSlave> findDestinationSlaves() {
55: HashSet<RemoteSlave> set = _parent.getGlobalContext()
56: .getSlaveManager().findSlavesBySpace(_numOfSlaves,
57: new HashSet(), false);
58:
59: if (set.isEmpty()) {
60: return null;
61: }
62:
63: return set;
64: }
65:
66: /**
67: * Returns true if this directory is Archived by this ArchiveType's definition
68: */
69: protected boolean isArchivedDir(LinkedRemoteFileInterface lrf)
70: throws IncompleteDirectoryException, OfflineSlaveException {
71: return isArchivedToXSlaves(lrf, _numOfSlaves);
72: }
73:
74: public String toString() {
75: return "MoveReleaseToMostFreeSlaves=[directory=["
76: + getDirectory().getPath() + "]dest=["
77: + outputSlaves(getRSlaves()) + "]numOfSlaves=["
78: + _numOfSlaves + "]]";
79: }
80: }
|