throw UnsupportedOperationException on write operations in ShadowEngine

This commit is contained in:
Lee Hinman 2015-02-13 16:25:34 -07:00
parent 740c28dd9e
commit 2ae80f9689
2 changed files with 16 additions and 11 deletions

View file

@ -102,26 +102,22 @@ public class ShadowEngine extends Engine {
@Override @Override
public void create(Create create) throws EngineException { public void create(Create create) throws EngineException {
// no-op throw new UnsupportedOperationException("create operation not allowed on shadow engine");
logger.trace("skipping CREATE on shadow engine");
} }
@Override @Override
public void index(Index index) throws EngineException { public void index(Index index) throws EngineException {
// no-op throw new UnsupportedOperationException("index operation not allowed on shadow engine");
logger.trace("skipping INDEX on shadow engine");
} }
@Override @Override
public void delete(Delete delete) throws EngineException { public void delete(Delete delete) throws EngineException {
// no-op throw new UnsupportedOperationException("delete operation not allowed on shadow engine");
logger.trace("skipping DELETE on shadow engine");
} }
@Override @Override
public void delete(DeleteByQuery delete) throws EngineException { public void delete(DeleteByQuery delete) throws EngineException {
// no-op throw new UnsupportedOperationException("delete-by-query operation not allowed on shadow engine");
logger.trace("skipping DELETE-BY-QUERY on shadow engine");
} }
@Override @Override

View file

@ -475,7 +475,10 @@ public class ShadowEngineTests extends ElasticsearchLuceneTestCase {
ParseContext.Document document = testDocumentWithTextField(); ParseContext.Document document = testDocumentWithTextField();
document.add(new Field(SourceFieldMapper.NAME, B_1.toBytes(), SourceFieldMapper.Defaults.FIELD_TYPE)); document.add(new Field(SourceFieldMapper.NAME, B_1.toBytes(), SourceFieldMapper.Defaults.FIELD_TYPE));
ParsedDocument doc = testParsedDocument("1", "1", "test", null, -1, -1, document, B_1, false); ParsedDocument doc = testParsedDocument("1", "1", "test", null, -1, -1, document, B_1, false);
try {
replicaEngine.create(new Engine.Create(null, newUid("1"), doc)); replicaEngine.create(new Engine.Create(null, newUid("1"), doc));
fail("should have thrown an exception");
} catch (UnsupportedOperationException e) {}
replicaEngine.refresh("test"); replicaEngine.refresh("test");
// its not there... // its not there...
@ -491,7 +494,10 @@ public class ShadowEngineTests extends ElasticsearchLuceneTestCase {
document = testDocument(); document = testDocument();
document.add(new TextField("value", "test1", Field.Store.YES)); document.add(new TextField("value", "test1", Field.Store.YES));
doc = testParsedDocument("1", "1", "test", null, -1, -1, document, B_1, false); doc = testParsedDocument("1", "1", "test", null, -1, -1, document, B_1, false);
try {
replicaEngine.index(new Engine.Index(null, newUid("1"), doc)); replicaEngine.index(new Engine.Index(null, newUid("1"), doc));
fail("should have thrown an exception");
} catch (UnsupportedOperationException e) {}
replicaEngine.refresh("test"); replicaEngine.refresh("test");
// its still not there... // its still not there...
@ -524,7 +530,10 @@ public class ShadowEngineTests extends ElasticsearchLuceneTestCase {
getResult.release(); getResult.release();
// try to delete it on the replica // try to delete it on the replica
try {
replicaEngine.delete(new Engine.Delete("test", "1", newUid("1"))); replicaEngine.delete(new Engine.Delete("test", "1", newUid("1")));
fail("should have thrown an exception");
} catch (UnsupportedOperationException e) {}
replicaEngine.flush(); replicaEngine.flush();
replicaEngine.refresh("test"); replicaEngine.refresh("test");
primaryEngine.refresh("test"); primaryEngine.refresh("test");