chennan 8 лет назад
Родитель
Сommit
24c1db22bf

+ 1 - 1
src/main/java/org/es/lu/CommonConfig.java

@@ -10,7 +10,7 @@ public class CommonConfig {
         }
 
         if ("YP".equalsIgnoreCase(clusterKey)) {
-            return false;
+            return true;
         }
         return false;
     }

+ 1 - 1
src/main/java/org/es/lu/ElasticsearchClusterManager.java

@@ -56,7 +56,7 @@ public class ElasticsearchClusterManager {
             for (String indexName : indices) {
                 IndexState indexState = configuredActiveCluster.indexState(indexName);
                 if (indexState.getIndexStatus() != IndexState.IndexStatus.GREEN
-                        && indexState.getIndexStatus() == IndexState.IndexStatus.YELLOW) {
+                        && indexState.getIndexStatus() != IndexState.IndexStatus.YELLOW) {
                     isIndexReadable = false;
                     break;
                 }

+ 6 - 2
src/test/java/org/es/lu/ElasticsearchClusterTest.java

@@ -37,9 +37,13 @@ public class ElasticsearchClusterTest {
     @Test
     public void test_getReadableCluster() throws Exception {
         for (int i = 0; i < 500; i++) {
-            ElasticsearchCluster cluster = clusterManager.getReadableCluster("index");
+            ElasticsearchCluster cluster = clusterManager.getReadableCluster(".custom-dictionary");
+            if (cluster == null) {
+                System.out.println("cluster is null, continue.");
+                TimeUnit.SECONDS.sleep(1);
+                continue;
+            }
             System.out.println(cluster.getClusterKey());
-
             TimeUnit.SECONDS.sleep(1);
         }
     }