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,28 +486,22 @@ public class FileProtector {
|
|||
return null;
|
||||
}
|
||||
|
||||
boolean keepTrying = false;
|
||||
do {
|
||||
keepTrying = false;
|
||||
try {
|
||||
for (final Map.Entry<Long, ReservedFileInfo> entry :
|
||||
reservedFiles.tailMap(fromFile).entrySet()) {
|
||||
fileLoop:
|
||||
for (final Map.Entry<Long, ReservedFileInfo> entry :
|
||||
reservedFiles.tailMap(fromFile).entrySet()) {
|
||||
|
||||
final Long file = entry.getKey();
|
||||
final ReservedFileInfo info = entry.getValue();
|
||||
final Long file = entry.getKey();
|
||||
final ReservedFileInfo info = entry.getValue();
|
||||
|
||||
for (final ProtectedFileSet pfs : protectedFileSets.values()) {
|
||||
if (pfs.isProtected(file, info)) {
|
||||
keepTrying = true;
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
|
||||
reservedFiles.remove(file);
|
||||
return new Pair<>(file, info.size);
|
||||
for (final ProtectedFileSet pfs : protectedFileSets.values()) {
|
||||
if (pfs.isProtected(file, info)) {
|
||||
continue fileLoop;
|
||||
}
|
||||
} catch (Exception e) { /* FALLTHRU */ }
|
||||
} while (keepTrying);
|
||||
}
|
||||
|
||||
reservedFiles.remove(file);
|
||||
return new Pair<>(file, info.size);
|
||||
}
|
||||
|
||||
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,30 +634,25 @@ public class FileProtector {
|
|||
long truncateFile = -1;
|
||||
long deleteBytes = 0;
|
||||
|
||||
fileLoop:
|
||||
for (final Map.Entry<Long, ReservedFileInfo> entry :
|
||||
reservedFiles.entrySet()) {
|
||||
|
||||
boolean keepTrying = false;
|
||||
do {
|
||||
keepTrying = false;
|
||||
try {
|
||||
for (final Map.Entry<Long, ReservedFileInfo> entry :
|
||||
reservedFiles.entrySet()) {
|
||||
final Long file = entry.getKey();
|
||||
final ReservedFileInfo info = entry.getValue();
|
||||
|
||||
final Long file = entry.getKey();
|
||||
final ReservedFileInfo info = entry.getValue();
|
||||
for (final ProtectedFileSet pfs : protectedFileSets.values()) {
|
||||
|
||||
for (final ProtectedFileSet pfs : protectedFileSets.values()) {
|
||||
if (pfs == vlsnIndexRange || !pfs.protectVlsnIndex) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (pfs == vlsnIndexRange || !pfs.protectVlsnIndex) {
|
||||
continue;
|
||||
}
|
||||
if (pfs.isProtected(file, info)) {
|
||||
break fileLoop;
|
||||
}
|
||||
}
|
||||
|
||||
if (pfs.isProtected(file, info)) {
|
||||
keepTrying = true;
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
|
||||
final VLSN lastVlsn = info.endVLSN;
|
||||
final VLSN lastVlsn = info.endVLSN;
|
||||
|
||||
if (!lastVlsn.isNull()) {
|
||||
if (lastVlsn.compareTo(preserveVLSN) > 0) {
|
||||
|
@ -691,11 +665,9 @@ public class FileProtector {
|
|||
deleteBytes += info.size;
|
||||
|
||||
if (deleteBytes >= bytesNeeded) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch(Exception e) { /* FALLTHRU */ }
|
||||
} while (keepTrying);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
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