WIP
This commit is contained in:
parent
3a1c374088
commit
85f2c790f4
4 changed files with 41 additions and 67 deletions
|
@ -404,7 +404,7 @@ public class FileProtector {
|
|||
|
||||
final ReservedFileInfo info = new ReservedFileInfo(size, endVLSN);
|
||||
final ReservedFileInfo prevInfo = reservedFiles.put(file, info);
|
||||
if (prevInfo != null) throw new AssertionError();
|
||||
assert prevInfo == null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -486,10 +486,7 @@ public class FileProtector {
|
|||
return null;
|
||||
}
|
||||
|
||||
boolean keepTrying = false;
|
||||
do {
|
||||
keepTrying = false;
|
||||
try {
|
||||
fileLoop:
|
||||
for (final Map.Entry<Long, ReservedFileInfo> entry :
|
||||
reservedFiles.tailMap(fromFile).entrySet()) {
|
||||
|
||||
|
@ -498,16 +495,13 @@ public class FileProtector {
|
|||
|
||||
for (final ProtectedFileSet pfs : protectedFileSets.values()) {
|
||||
if (pfs.isProtected(file, info)) {
|
||||
keepTrying = true;
|
||||
throw new Exception();
|
||||
continue fileLoop;
|
||||
}
|
||||
}
|
||||
|
||||
reservedFiles.remove(file);
|
||||
return new Pair<>(file, info.size);
|
||||
}
|
||||
} catch (Exception e) { /* FALLTHRU */ }
|
||||
} while (keepTrying);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@ -583,21 +577,6 @@ public class FileProtector {
|
|||
|
||||
isProtected = true;
|
||||
|
||||
/*
|
||||
BiFunction<String, Long, Long> fn = new BiFunction<String, Long, Long>() {
|
||||
@Override
|
||||
public Long apply(String k, Long v) {
|
||||
Long r = 0L;
|
||||
if (v != null) {
|
||||
r = v + info.size;
|
||||
} else {
|
||||
r = info.size;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
};
|
||||
protectedSizeMap.compute(pfs.getName(), fn); // (k, v) -> ((v != null) ? v : 0) + info.size);
|
||||
*/
|
||||
protectedSizeMap.compute(
|
||||
pfs.getName(),
|
||||
(k, v) -> ((v != null) ? v : 0) + info.size);
|
||||
|
@ -655,11 +634,7 @@ public class FileProtector {
|
|||
long truncateFile = -1;
|
||||
long deleteBytes = 0;
|
||||
|
||||
|
||||
boolean keepTrying = false;
|
||||
do {
|
||||
keepTrying = false;
|
||||
try {
|
||||
fileLoop:
|
||||
for (final Map.Entry<Long, ReservedFileInfo> entry :
|
||||
reservedFiles.entrySet()) {
|
||||
|
||||
|
@ -673,8 +648,7 @@ public class FileProtector {
|
|||
}
|
||||
|
||||
if (pfs.isProtected(file, info)) {
|
||||
keepTrying = true;
|
||||
throw new Exception();
|
||||
break fileLoop;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -694,8 +668,6 @@ public class FileProtector {
|
|||
break;
|
||||
}
|
||||
}
|
||||
} catch(Exception e) { /* FALLTHRU */ }
|
||||
} while (keepTrying);
|
||||
|
||||
return truncateVLSN.isNull() ? null :
|
||||
new Pair<>(truncateVLSN, truncateFile);
|
||||
|
|
|
@ -136,8 +136,8 @@ public class CronScheduleParser {
|
|||
}
|
||||
|
||||
private void assertDelay() {
|
||||
if (delay < 0)
|
||||
throw new AssertionError("Delay is: " + delay + "; interval is: " + interval);
|
||||
assert delay >= 0 :
|
||||
"Delay is: " + delay + "; interval is: " + interval;
|
||||
}
|
||||
|
||||
private void parser(final String cronSchedule) {
|
||||
|
|
|
@ -78,7 +78,7 @@ public abstract class MapStat<T, C extends MapStatComponent<T, C>>
|
|||
* @param key the key
|
||||
*/
|
||||
public synchronized void removeStat(String key) {
|
||||
if (key == null) throw new AssertionError();
|
||||
assert key != null;
|
||||
statMap.remove(key);
|
||||
}
|
||||
|
||||
|
|
|
@ -99,8 +99,8 @@ public class StatGroup implements Serializable {
|
|||
*/
|
||||
void register(Stat<?> oneStat) {
|
||||
Stat<?> prev = stats.put(oneStat.getDefinition(), oneStat);
|
||||
if ((prev != null)) throw new AssertionError("prev = " + prev + " oneStat=" +
|
||||
oneStat.getDefinition());
|
||||
assert (prev == null) : "prev = " + prev + " oneStat=" +
|
||||
oneStat.getDefinition();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -236,8 +236,9 @@ public class StatGroup implements Serializable {
|
|||
} else if (s instanceof AtomicIntStat) {
|
||||
retval = ((AtomicIntStat) s).get();
|
||||
} else {
|
||||
throw new AssertionError("Internal error calling getInt with" +
|
||||
" unexpected stat type: " + s.getClass().getName());
|
||||
assert false : "Internal error calling getInt with" +
|
||||
" unexpected stat type: " + s.getClass().getName();
|
||||
retval = 0;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
@ -258,7 +259,8 @@ public class StatGroup implements Serializable {
|
|||
} else if (s instanceof IntegralLongAvgStat) {
|
||||
retval = ((IntegralLongAvgStat)s).get().compute();
|
||||
} else {
|
||||
throw new AssertionError("Internal error calling getLong() with " + "unknown stat type.");
|
||||
assert false: "Internal error calling getLong() with "+
|
||||
"unknown stat type.";
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue