private int addOperation(FileOperation op) throws IOException { trace("op " + op); checkError(); notAppliedList.add(op); long now = op.getTime(); for (int i = 0; i < notAppliedList.size() - 1; i++) { FileOperation old = notAppliedList.get(i); boolean applyOld = false; // String reason = ""; if (old.getTime() + 45000 < now) { // reason = "old"; applyOld = true; } else if (old.overlaps(op)) { // reason = "overlap"; applyOld = true; } else if (file.getRandom().nextInt(100) < 10) { // reason = "random"; applyOld = true; } if (applyOld) { trace("op apply " + op); old.apply(base); notAppliedList.remove(i); i--; } } return op.apply(readBase); }
@Override public String toString() { return file.getScheme() + ":" + file.toString(); }
private void checkError() throws IOException { if (closed) { throw new IOException("Closed"); } file.checkError(); }