Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename NoopEngine -> NoOpEngine #31398

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import java.util.stream.Stream;

/**
* NoopEngine is an engine implementation that does nothing but the bare minimum
* NoOpEngine is an engine implementation that does nothing but the bare minimum
* required in order to have an engine. All attempts to do something (search,
* index, get), throw {@link UnsupportedOperationException}. This does maintain
* a translog with a deletion policy so that when flushing, no translog is
Expand All @@ -52,7 +52,7 @@
* Directory so that the last commit's user data can be read for the historyUUID
* and last committed segment info.
*/
final class NoopEngine extends Engine {
final class NoOpEngine extends Engine {

private static final Translog.Snapshot EMPTY_TRANSLOG_SNAPSHOT = new Translog.Snapshot() {
@Override
Expand All @@ -79,7 +79,7 @@ public void close() {
private final String historyUUID;
private final SegmentInfos lastCommittedSegmentInfos;

NoopEngine(EngineConfig engineConfig) {
NoOpEngine(EngineConfig engineConfig) {
super(engineConfig);

store.incRef();
Expand Down Expand Up @@ -114,7 +114,7 @@ public void close() {
}
}
}
logger.trace("created new NoopEngine");
logger.trace("created new NoOpEngine");
}

private Translog openTranslog(EngineConfig engineConfig, TranslogDeletionPolicy translogDeletionPolicy,
Expand Down Expand Up @@ -169,32 +169,32 @@ public void trimOperationsFromTranslog(long belowTerm, long aboveSeqNo) throws E

@Override
public IndexResult index(Index index) {
throw new UnsupportedOperationException("indexing is not supported on a noop engine");
throw new UnsupportedOperationException("indexing is not supported on a noOp engine");
}

@Override
public DeleteResult delete(Delete delete) {
throw new UnsupportedOperationException("deletion is not supported on a noop engine");
throw new UnsupportedOperationException("deletion is not supported on a noOp engine");
}

@Override
public NoOpResult noOp(NoOp noOp) {
throw new UnsupportedOperationException("noop is not supported on a noop engine");
throw new UnsupportedOperationException("noOp is not supported on a noOp engine");
}

@Override
public SyncedFlushResult syncFlush(String syncId, CommitId expectedCommitId) throws EngineException {
throw new UnsupportedOperationException("synced flush is not supported on a noop engine");
throw new UnsupportedOperationException("synced flush is not supported on a noOp engine");
}

@Override
public GetResult get(Get get, BiFunction<String, SearcherScope, Searcher> searcherFactory) throws EngineException {
throw new UnsupportedOperationException("gets are not supported on a noop engine");
throw new UnsupportedOperationException("gets are not supported on a noOp engine");
}

@Override
public Searcher acquireSearcher(String source, SearcherScope scope) throws EngineException {
throw new UnsupportedOperationException("searching is not supported on a noop engine");
throw new UnsupportedOperationException("searching is not supported on a noOp engine");
}

@Override
Expand Down Expand Up @@ -278,7 +278,7 @@ public void refresh(String source) throws EngineException {
// Override the refreshNeeded method so that we don't attempt to acquire a searcher checking if we need to refresh
@Override
public boolean refreshNeeded() {
// We never need to refresh a noop engine so always return false
// We never need to refresh a noOp engine so always return false
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.instanceOf;

public class NoopEngineTests extends EngineTestCase {
public class NoOpEngineTests extends EngineTestCase {
private static final IndexSettings INDEX_SETTINGS = IndexSettingsModule.newIndexSettings("index", Settings.EMPTY);

public void testNoopEngine() throws IOException {
engine.close();
final NoopEngine engine = new NoopEngine(noopConfig(INDEX_SETTINGS, store, primaryTranslogDir));
final NoOpEngine engine = new NoOpEngine(noOpConfig(INDEX_SETTINGS, store, primaryTranslogDir));
expectThrows(UnsupportedOperationException.class, () -> engine.index(null));
expectThrows(UnsupportedOperationException.class, () -> engine.delete(null));
expectThrows(UnsupportedOperationException.class, () -> engine.noOp(null));
Expand All @@ -63,11 +63,11 @@ public void testNoopEngine() throws IOException {

public void testTwoNoopEngines() throws IOException {
engine.close();
// It's so noop you can even open two engines for the same store without tripping anything,
// It's so noOp you can even open two engines for the same store without tripping anything,
// this ensures we're not doing any kind of locking on the store or filesystem level in
// the noop engine
final NoopEngine engine1 = new NoopEngine(noopConfig(INDEX_SETTINGS, store, primaryTranslogDir));
final NoopEngine engine2 = new NoopEngine(noopConfig(INDEX_SETTINGS, store, primaryTranslogDir));
// the noOp engine
final NoOpEngine engine1 = new NoOpEngine(noOpConfig(INDEX_SETTINGS, store, primaryTranslogDir));
final NoOpEngine engine2 = new NoOpEngine(noOpConfig(INDEX_SETTINGS, store, primaryTranslogDir));
engine1.close();
engine2.close();
}
Expand Down Expand Up @@ -97,24 +97,24 @@ public void testNoopAfterRegularEngine() throws IOException {
long maxSeqNo = engine.getSeqNoStats(100L).getMaxSeqNo();
engine.close();

final NoopEngine noopEngine = new NoopEngine(noopConfig(INDEX_SETTINGS, store, primaryTranslogDir, tracker));
assertThat(noopEngine.getLocalCheckpoint(), equalTo(localCheckpoint));
assertThat(noopEngine.getSeqNoStats(100L).getMaxSeqNo(), equalTo(maxSeqNo));
try (Engine.IndexCommitRef ref = noopEngine.acquireLastIndexCommit(false)) {
final NoOpEngine noOpEngine = new NoOpEngine(noOpConfig(INDEX_SETTINGS, store, primaryTranslogDir, tracker));
assertThat(noOpEngine.getLocalCheckpoint(), equalTo(localCheckpoint));
assertThat(noOpEngine.getSeqNoStats(100L).getMaxSeqNo(), equalTo(maxSeqNo));
try (Engine.IndexCommitRef ref = noOpEngine.acquireLastIndexCommit(false)) {
try (IndexReader reader = DirectoryReader.open(ref.getIndexCommit())) {
assertThat(reader.numDocs(), equalTo(docs));
}
}
noopEngine.close();
noOpEngine.close();
}

public void testNoopEngineWithInvalidTranslogUUID() throws IOException {
Path newTranslogDir = createTempDir();
// A new translog will have a different UUID than the existing store/noop engine does
// A new translog will have a different UUID than the existing store/noOp engine does
Translog newTranslog = createTranslog(newTranslogDir, () -> 1L);
newTranslog.close();
EngineCreationFailureException e = expectThrows(EngineCreationFailureException.class,
() -> new NoopEngine(noopConfig(INDEX_SETTINGS, store, newTranslogDir)));
() -> new NoOpEngine(noOpConfig(INDEX_SETTINGS, store, newTranslogDir)));
assertThat(e.getCause(), instanceOf(TranslogCorruptedException.class));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -466,11 +466,11 @@ public void onFailedEngine(String reason, @Nullable Exception e) {
return config;
}

protected EngineConfig noopConfig(IndexSettings indexSettings, Store store, Path translogPath) {
return noopConfig(indexSettings, store, translogPath, null);
protected EngineConfig noOpConfig(IndexSettings indexSettings, Store store, Path translogPath) {
return noOpConfig(indexSettings, store, translogPath, null);
}

protected EngineConfig noopConfig(IndexSettings indexSettings, Store store, Path translogPath, LongSupplier globalCheckpointSupplier) {
protected EngineConfig noOpConfig(IndexSettings indexSettings, Store store, Path translogPath, LongSupplier globalCheckpointSupplier) {
return config(indexSettings, store, translogPath, newMergePolicy(), null, null, globalCheckpointSupplier);
}

Expand Down