This commit is contained in:
Greg Burd 2019-07-29 11:28:26 -04:00
parent 3a1c374088
commit 85f2c790f4
4 changed files with 41 additions and 67 deletions

View file

@ -404,7 +404,7 @@ public class FileProtector {
final ReservedFileInfo info = new ReservedFileInfo(size, endVLSN); final ReservedFileInfo info = new ReservedFileInfo(size, endVLSN);
final ReservedFileInfo prevInfo = reservedFiles.put(file, info); 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; return null;
} }
boolean keepTrying = false; fileLoop:
do {
keepTrying = false;
try {
for (final Map.Entry<Long, ReservedFileInfo> entry : for (final Map.Entry<Long, ReservedFileInfo> entry :
reservedFiles.tailMap(fromFile).entrySet()) { reservedFiles.tailMap(fromFile).entrySet()) {
@ -498,16 +495,13 @@ public class FileProtector {
for (final ProtectedFileSet pfs : protectedFileSets.values()) { for (final ProtectedFileSet pfs : protectedFileSets.values()) {
if (pfs.isProtected(file, info)) { if (pfs.isProtected(file, info)) {
keepTrying = true; continue fileLoop;
throw new Exception();
} }
} }
reservedFiles.remove(file); reservedFiles.remove(file);
return new Pair<>(file, info.size); return new Pair<>(file, info.size);
} }
} catch (Exception e) { /* FALLTHRU */ }
} while (keepTrying);
return null; return null;
} }
@ -583,21 +577,6 @@ public class FileProtector {
isProtected = true; 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( protectedSizeMap.compute(
pfs.getName(), pfs.getName(),
(k, v) -> ((v != null) ? v : 0) + info.size); (k, v) -> ((v != null) ? v : 0) + info.size);
@ -655,11 +634,7 @@ public class FileProtector {
long truncateFile = -1; long truncateFile = -1;
long deleteBytes = 0; long deleteBytes = 0;
fileLoop:
boolean keepTrying = false;
do {
keepTrying = false;
try {
for (final Map.Entry<Long, ReservedFileInfo> entry : for (final Map.Entry<Long, ReservedFileInfo> entry :
reservedFiles.entrySet()) { reservedFiles.entrySet()) {
@ -673,8 +648,7 @@ public class FileProtector {
} }
if (pfs.isProtected(file, info)) { if (pfs.isProtected(file, info)) {
keepTrying = true; break fileLoop;
throw new Exception();
} }
} }
@ -694,8 +668,6 @@ public class FileProtector {
break; break;
} }
} }
} catch(Exception e) { /* FALLTHRU */ }
} while (keepTrying);
return truncateVLSN.isNull() ? null : return truncateVLSN.isNull() ? null :
new Pair<>(truncateVLSN, truncateFile); new Pair<>(truncateVLSN, truncateFile);

View file

@ -136,8 +136,8 @@ public class CronScheduleParser {
} }
private void assertDelay() { private void assertDelay() {
if (delay < 0) assert delay >= 0 :
throw new AssertionError("Delay is: " + delay + "; interval is: " + interval); "Delay is: " + delay + "; interval is: " + interval;
} }
private void parser(final String cronSchedule) { private void parser(final String cronSchedule) {

View file

@ -78,7 +78,7 @@ public abstract class MapStat<T, C extends MapStatComponent<T, C>>
* @param key the key * @param key the key
*/ */
public synchronized void removeStat(String key) { public synchronized void removeStat(String key) {
if (key == null) throw new AssertionError(); assert key != null;
statMap.remove(key); statMap.remove(key);
} }

View file

@ -99,8 +99,8 @@ public class StatGroup implements Serializable {
*/ */
void register(Stat<?> oneStat) { void register(Stat<?> oneStat) {
Stat<?> prev = stats.put(oneStat.getDefinition(), oneStat); Stat<?> prev = stats.put(oneStat.getDefinition(), oneStat);
if ((prev != null)) throw new AssertionError("prev = " + prev + " oneStat=" + assert (prev == null) : "prev = " + prev + " oneStat=" +
oneStat.getDefinition()); oneStat.getDefinition();
} }
/** /**
@ -236,8 +236,9 @@ public class StatGroup implements Serializable {
} else if (s instanceof AtomicIntStat) { } else if (s instanceof AtomicIntStat) {
retval = ((AtomicIntStat) s).get(); retval = ((AtomicIntStat) s).get();
} else { } else {
throw new AssertionError("Internal error calling getInt with" + assert false : "Internal error calling getInt with" +
" unexpected stat type: " + s.getClass().getName()); " unexpected stat type: " + s.getClass().getName();
retval = 0;
} }
return retval; return retval;
} }
@ -258,7 +259,8 @@ public class StatGroup implements Serializable {
} else if (s instanceof IntegralLongAvgStat) { } else if (s instanceof IntegralLongAvgStat) {
retval = ((IntegralLongAvgStat)s).get().compute(); retval = ((IntegralLongAvgStat)s).get().compute();
} else { } else {
throw new AssertionError("Internal error calling getLong() with " + "unknown stat type."); assert false: "Internal error calling getLong() with "+
"unknown stat type.";
} }
return retval; return retval;
} }