lucene4: replace IndexCommit.getVersion() with IndexCommit.getGeneration()

This commit is contained in:
Igor Motov 2012-10-31 22:51:19 -04:00 committed by Shay Banon
parent 787b7a3900
commit daf347e67e
4 changed files with 7 additions and 7 deletions

View File

@ -132,10 +132,10 @@ public class SnapshotDeletionPolicy extends AbstractIndexShardComponent implemen
* Helper method to snapshot a give commit. * Helper method to snapshot a give commit.
*/ */
private SnapshotIndexCommit snapshot(SnapshotIndexCommit commit) throws IOException { private SnapshotIndexCommit snapshot(SnapshotIndexCommit commit) throws IOException {
SnapshotHolder snapshotHolder = snapshots.get(commit.getVersion()); SnapshotHolder snapshotHolder = snapshots.get(commit.getGeneration());
if (snapshotHolder == null) { if (snapshotHolder == null) {
snapshotHolder = new SnapshotHolder(0); snapshotHolder = new SnapshotHolder(0);
snapshots.put(commit.getVersion(), snapshotHolder); snapshots.put(commit.getGeneration(), snapshotHolder);
} }
snapshotHolder.counter++; snapshotHolder.counter++;
return new OneTimeReleaseSnapshotIndexCommit(this, commit); return new OneTimeReleaseSnapshotIndexCommit(this, commit);

View File

@ -58,7 +58,7 @@ public class SnapshotIndexCommit extends IndexCommitDelegate implements Releasab
* actually released. * actually released.
*/ */
public boolean release() { public boolean release() {
return deletionPolicy.release(getVersion()); return deletionPolicy.release(getGeneration());
} }
/** /**
@ -67,7 +67,7 @@ public class SnapshotIndexCommit extends IndexCommitDelegate implements Releasab
*/ */
@Override @Override
public void delete() { public void delete() {
if (!deletionPolicy.isHeld(getVersion())) { if (!deletionPolicy.isHeld(getGeneration())) {
delegate.delete(); delegate.delete();
} }
} }

View File

@ -103,7 +103,7 @@ public interface IndexShardGateway extends IndexShardComponent, CloseableIndexCo
* Indicates that the index has changed from the latest snapshot. * Indicates that the index has changed from the latest snapshot.
*/ */
public boolean indexChanged() { public boolean indexChanged() {
return lastIndexVersion != indexCommit.getVersion(); return lastIndexVersion != indexCommit.getGeneration();
} }
/** /**

View File

@ -265,13 +265,13 @@ public class IndexShardGatewayService extends AbstractIndexShardComponent implem
SnapshotStatus snapshotStatus = indexShard.snapshot(new Engine.SnapshotHandler<SnapshotStatus>() { SnapshotStatus snapshotStatus = indexShard.snapshot(new Engine.SnapshotHandler<SnapshotStatus>() {
@Override @Override
public SnapshotStatus snapshot(SnapshotIndexCommit snapshotIndexCommit, Translog.Snapshot translogSnapshot) throws EngineException { public SnapshotStatus snapshot(SnapshotIndexCommit snapshotIndexCommit, Translog.Snapshot translogSnapshot) throws EngineException {
if (lastIndexVersion != snapshotIndexCommit.getVersion() || lastTranslogId != translogSnapshot.translogId() || lastTranslogLength < translogSnapshot.length()) { if (lastIndexVersion != snapshotIndexCommit.getGeneration() || lastTranslogId != translogSnapshot.translogId() || lastTranslogLength < translogSnapshot.length()) {
logger.debug("snapshot ({}) to {} ...", reason, shardGateway); logger.debug("snapshot ({}) to {} ...", reason, shardGateway);
SnapshotStatus snapshotStatus = SnapshotStatus snapshotStatus =
shardGateway.snapshot(new IndexShardGateway.Snapshot(snapshotIndexCommit, translogSnapshot, lastIndexVersion, lastTranslogId, lastTranslogLength, lastTotalTranslogOperations)); shardGateway.snapshot(new IndexShardGateway.Snapshot(snapshotIndexCommit, translogSnapshot, lastIndexVersion, lastTranslogId, lastTranslogLength, lastTotalTranslogOperations));
lastIndexVersion = snapshotIndexCommit.getVersion(); lastIndexVersion = snapshotIndexCommit.getGeneration();
lastTranslogId = translogSnapshot.translogId(); lastTranslogId = translogSnapshot.translogId();
lastTranslogLength = translogSnapshot.length(); lastTranslogLength = translogSnapshot.length();
lastTotalTranslogOperations = translogSnapshot.estimatedTotalOperations(); lastTotalTranslogOperations = translogSnapshot.estimatedTotalOperations();