# 펜스 메서드가 돌려주는 값과 그 javadoc /** * Unfenced: the engine's lock exposes no monotonic token. * *
Reported honestly rather than synthesised from a local counter, which would look like
* fencing and protect nothing — a per-process counter says nothing about what another process
* acquired. The runner refuses resumable migrations under an unfenced lease for exactly this
* reason.
*/
@Override
public long fence() {
return UNFENCED;
}
# 실행자의 진입점이 지나는 세 관문
Objects.requireNonNull(context, "context");
if (!lock.held()) {
throw MongoOperationRejectedException.of(
"migration.lock",
"the migration lease is not held; only one runner may apply changes at a time");
}
migrations.forEach(this::validate);
if (lock.fence() == MongoMigrationLock.UNFENCED) {
// An unfenced lease cannot tell a live runner from a stalled one that is about to wake up.
// Refused rather than downgraded: the alternative is a certification that says "one runner at
// a time" and a mechanism that cannot show it.
throw MongoOperationRejectedException.of(
"migration.fence",
"this migration lease exposes no fencing token, so a stalled runner cannot be excluded;"
+ " use a fenced lease or run the migration inside a maintenance window with the"
+ " application stopped");
}
return migrations.stream()
# 그 파일에서 리스의 펜스를 읽는 곳 전수
80: migrations.forEach(this::validate);
82: if (lock.fence() == MongoMigrationLock.UNFENCED) {
93: return migrations.stream()
154: result.resumePoint().ifPresent(checkpoint -> ledger.saveCheckpoint(checkpoint, lock.fence()));
157: migration.id(), migration.checksum(), context.operator(), clock.instant(), lock.fence());
# 154행이 넘기는 곳과 157행이 넘기는 곳이 그 값을 다루는 방식
93: requireCurrentFence(fence, "ledger entry for " + migrationId.value());
120: requireCurrentFence(fence, "checkpoint for " + checkpoint.migrationId().value());
177: private static void requireCurrentFence(long fence, String what) {
if (fence == MongoMigrationLock.UNFENCED) {
throw MongoOperationRejectedException.of(
"migration.fence",
"refusing to write the "
# 마이그레이션이 재개 가능한지 실행 전에 알 수 있는가
17: MongoMigrationId id();
20: MongoMigrationChecksum checksum();
23: MongoMigrationPrecondition precondition();
26: MongoMigrationResult execute(MongoMigrationContext context);
29: MongoMigrationPostcondition postcondition();
# 이 잠금 어댑터가 나오는 곳 전수
test/java/dev/caskeleton/adapter/outbound/mongo/migration/flamingock/FlamingockMongoMigrationAdapterTest.java:58: assertThatThrownBy(() -> new FlamingockLockAdapter(() -> false, extension -> {}, () -> {}))
test/java/dev/caskeleton/adapter/outbound/mongo/migration/flamingock/FlamingockMongoMigrationAdapterTest.java:65: FlamingockLockAdapter lock =
test/java/dev/caskeleton/adapter/outbound/mongo/migration/flamingock/FlamingockMongoMigrationAdapterTest.java:66: new FlamingockLockAdapter(() -> true, extension -> {}, () -> released.set(true));
main/java/dev/caskeleton/adapter/outbound/mongo/migration/flamingock/FlamingockLockAdapter.java:17:public final class FlamingockLockAdapter implements MongoMigrationLock {
main/java/dev/caskeleton/adapter/outbound/mongo/migration/flamingock/FlamingockLockAdapter.java:25: public FlamingockLockAdapter(
# 실행자와 원장과 잠금을 프로덕션에서 참조하는 곳
(없음)
# 마이그레이션을 적용하는 진입점 전수
test/java/dev/caskeleton/adapter/outbound/mongo/migration/MongoMigrationLaneTest.java:81: List