fix start error issue
This commit is contained in:
parent
ccba3d5b3d
commit
45bfd06b9b
|
|
@ -32,6 +32,8 @@ public class EsConfig {
|
|||
}
|
||||
|
||||
public enum IndexInitMode {
|
||||
auto, forced, manual
|
||||
AUTO,
|
||||
FORCED,
|
||||
MANUAL
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,12 +17,12 @@ public enum IndexCreator {
|
|||
private Logger logger = LogManager.getFormatterLogger(IndexCreator.class);
|
||||
|
||||
public void create() {
|
||||
if (!EsConfig.IndexInitMode.manual.equals(EsConfig.Es.Index.Initialize.mode)) {
|
||||
if (!EsConfig.IndexInitMode.MANUAL.equals(EsConfig.Es.Index.Initialize.mode)) {
|
||||
Set<AbstractIndex> indexSet = loadIndex();
|
||||
for (AbstractIndex index : indexSet) {
|
||||
boolean isExists = index.isExists();
|
||||
if (isExists) {
|
||||
if (EsConfig.IndexInitMode.forced.equals(EsConfig.Es.Index.Initialize.mode)) {
|
||||
if (EsConfig.IndexInitMode.FORCED.equals(EsConfig.Es.Index.Initialize.mode)) {
|
||||
index.deleteIndex();
|
||||
index.createIndex();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ public class IndexCreatorTestCase {
|
|||
|
||||
@Test
|
||||
public void testCreateOptionManual() throws Exception {
|
||||
EsConfig.Es.Index.Initialize.mode = EsConfig.IndexInitMode.manual;
|
||||
EsConfig.Es.Index.Initialize.mode = EsConfig.IndexInitMode.MANUAL;
|
||||
indexCreator.create();
|
||||
Mockito.verify(testIndex, Mockito.never()).createIndex();
|
||||
Mockito.verify(testIndex, Mockito.never()).deleteIndex();
|
||||
|
|
@ -73,7 +73,7 @@ public class IndexCreatorTestCase {
|
|||
|
||||
@Test
|
||||
public void testCreateOptionForcedIndexIsExists() throws Exception {
|
||||
EsConfig.Es.Index.Initialize.mode = EsConfig.IndexInitMode.forced;
|
||||
EsConfig.Es.Index.Initialize.mode = EsConfig.IndexInitMode.FORCED;
|
||||
when(testIndex.isExists()).thenReturn(true);
|
||||
indexCreator.create();
|
||||
Mockito.verify(testIndex).createIndex();
|
||||
|
|
@ -82,7 +82,7 @@ public class IndexCreatorTestCase {
|
|||
|
||||
@Test
|
||||
public void testCreateOptionForcedIndexNotExists() throws Exception {
|
||||
EsConfig.Es.Index.Initialize.mode = EsConfig.IndexInitMode.forced;
|
||||
EsConfig.Es.Index.Initialize.mode = EsConfig.IndexInitMode.FORCED;
|
||||
when(testIndex.isExists()).thenReturn(false);
|
||||
indexCreator.create();
|
||||
Mockito.verify(testIndex).createIndex();
|
||||
|
|
@ -91,7 +91,7 @@ public class IndexCreatorTestCase {
|
|||
|
||||
@Test
|
||||
public void testCreateOptionAutoIndexNotExists() throws Exception {
|
||||
EsConfig.Es.Index.Initialize.mode = EsConfig.IndexInitMode.auto;
|
||||
EsConfig.Es.Index.Initialize.mode = EsConfig.IndexInitMode.AUTO;
|
||||
when(testIndex.isExists()).thenReturn(false);
|
||||
indexCreator.create();
|
||||
Mockito.verify(testIndex).createIndex();
|
||||
|
|
@ -100,7 +100,7 @@ public class IndexCreatorTestCase {
|
|||
|
||||
@Test
|
||||
public void testCreateOptionAutoIndexExists() throws Exception {
|
||||
EsConfig.Es.Index.Initialize.mode = EsConfig.IndexInitMode.auto;
|
||||
EsConfig.Es.Index.Initialize.mode = EsConfig.IndexInitMode.AUTO;
|
||||
when(testIndex.isExists()).thenReturn(true);
|
||||
indexCreator.create();
|
||||
Mockito.verify(testIndex, Mockito.never()).createIndex();
|
||||
|
|
|
|||
Loading…
Reference in New Issue