Skip to content

Commit

Permalink
Rename NoopEngine -> NoOpEngine
Browse files Browse the repository at this point in the history
In elastic#31163 (comment)
Jason requested renaming NoopEngine to NoOpEngine. This commit renames the class
and relevant parts.

Relates to elastic#31141
  • Loading branch information
dakrone committed Jun 18, 2018
1 parent 1c4d8a0 commit f86f71d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
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
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));
}
}
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

0 comments on commit f86f71d

Please sign in to comment.