MinfreespaceFilter extends Filter { public void process(ScoreChart scorechart, User user, InetAddress source, char direction, InodeHandleInterface file, RemoteSlave sourceSlave) { for (Iterator<ScoreChart.SlaveScore> iter = scorechart.getSlaveScores().iterator(); iter.hasNext(); ) { ScoreChart.SlaveScore score = iter.next(); long df; try { df = score.getRSlave().getSlaveStatusAvailable().getDiskSpaceAvailable(); if (df < _minfreespace) { if (_multiplier == 0) { iter.remove(); } else { score.addScore(-(long) ((_minfreespace - df) * _multiplier)); } } } catch (SlaveUnavailableException e) { iter.remove(); } } } MinfreespaceFilter(int i, Properties p); void process(ScoreChart scorechart, User user, InetAddress source,
                        char direction, InodeHandleInterface file, RemoteSlave sourceSlave);  }
@Test public void testSimple() throws ObjectNotFoundException, NoAvailableSlaveException { Properties p = new Properties(); p.put("1.multiplier", "1"); p.put("1.minfreespace", "100MB"); SlaveStatus s = new SlaveStatus(new DiskStatus(Bytes.parseBytes("50MB"), Bytes.parseBytes("100GB")), 0, 0, 0, 0, 0, 0); RemoteSlave[] rslaves = { new RemoteSlaveTesting("slave1", Collections.emptyList(), s) }; ScoreChart sc = new ScoreChart(Arrays.asList(rslaves)); Filter f = new MinfreespaceFilter(1, p); f.process(sc, null, null, Transfer.TRANSFER_SENDING_DOWNLOAD, null, null); assertEquals(Bytes.parseBytes("-50MB"), sc.getScoreForSlave(rslaves[0]).getScore()); }