From 45bfd06b9bc3055cdfb3c7b2ee8d19671cbd4304 Mon Sep 17 00:00:00 2001 From: zhangxin Date: Thu, 13 Apr 2017 09:49:01 +0800 Subject: [PATCH] fix start error issue --- .../skywalking/collector/worker/config/EsConfig.java | 4 +++- .../collector/worker/storage/IndexCreator.java | 4 ++-- .../collector/worker/storage/IndexCreatorTestCase.java | 10 +++++----- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/skywalking-collector/skywalking-collector-worker/src/main/java/com/a/eye/skywalking/collector/worker/config/EsConfig.java b/skywalking-collector/skywalking-collector-worker/src/main/java/com/a/eye/skywalking/collector/worker/config/EsConfig.java index ae6ffb4af..dae5f3f5c 100644 --- a/skywalking-collector/skywalking-collector-worker/src/main/java/com/a/eye/skywalking/collector/worker/config/EsConfig.java +++ b/skywalking-collector/skywalking-collector-worker/src/main/java/com/a/eye/skywalking/collector/worker/config/EsConfig.java @@ -32,6 +32,8 @@ public class EsConfig { } public enum IndexInitMode { - auto, forced, manual + AUTO, + FORCED, + MANUAL } } diff --git a/skywalking-collector/skywalking-collector-worker/src/main/java/com/a/eye/skywalking/collector/worker/storage/IndexCreator.java b/skywalking-collector/skywalking-collector-worker/src/main/java/com/a/eye/skywalking/collector/worker/storage/IndexCreator.java index 973ea1ee0..562ee0bdf 100644 --- a/skywalking-collector/skywalking-collector-worker/src/main/java/com/a/eye/skywalking/collector/worker/storage/IndexCreator.java +++ b/skywalking-collector/skywalking-collector-worker/src/main/java/com/a/eye/skywalking/collector/worker/storage/IndexCreator.java @@ -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 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(); } diff --git a/skywalking-collector/skywalking-collector-worker/src/test/java/com/a/eye/skywalking/collector/worker/storage/IndexCreatorTestCase.java b/skywalking-collector/skywalking-collector-worker/src/test/java/com/a/eye/skywalking/collector/worker/storage/IndexCreatorTestCase.java index 52eaf2c1c..cd17746c1 100644 --- a/skywalking-collector/skywalking-collector-worker/src/test/java/com/a/eye/skywalking/collector/worker/storage/IndexCreatorTestCase.java +++ b/skywalking-collector/skywalking-collector-worker/src/test/java/com/a/eye/skywalking/collector/worker/storage/IndexCreatorTestCase.java @@ -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();