geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [34/50] [abbrv] geode git commit: GEODE-2273: Server name is displayed in lucene index stats.
Date Fri, 20 Jan 2017 22:53:30 GMT
GEODE-2273: Server name is displayed in lucene index stats.

	* In gfsh while listing Lucene index stats, it will now display where the indexes are hosted.


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/edae4abf
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/edae4abf
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/edae4abf

Branch: refs/heads/feature/GEODE-1930-2
Commit: edae4abf4def82fd3827a1bd0b7b688b2145294a
Parents: d43910d
Author: nabarun <nnag@pivotal.io>
Authored: Thu Jan 5 15:28:36 2017 -0800
Committer: nabarun <nnag@pivotal.io>
Committed: Wed Jan 18 12:11:35 2017 -0800

----------------------------------------------------------------------
 .../internal/cli/LuceneIndexCommands.java       |  1 +
 .../lucene/internal/cli/LuceneIndexDetails.java | 17 +++++++---
 .../functions/LuceneDescribeIndexFunction.java  |  9 ++----
 .../cli/functions/LuceneListIndexFunction.java  |  6 ++--
 .../cli/LuceneIndexCommandsJUnitTest.java       | 33 +++++++++++---------
 .../LuceneDescribeIndexFunctionJUnitTest.java   |  8 ++---
 .../LuceneListIndexFunctionJUnitTest.java       |  6 ++--
 7 files changed, 42 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/edae4abf/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java
b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java
index 6a5a1e0..8f5a3d6 100755
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java
@@ -131,6 +131,7 @@ public class LuceneIndexCommands extends AbstractCommandsSupport {
       for (final LuceneIndexDetails indexDetails : indexDetailsList) {
         indexData.accumulate("Index Name", indexDetails.getIndexName());
         indexData.accumulate("Region Path", indexDetails.getRegionPath());
+        indexData.accumulate("Server Name", indexDetails.getServerName());
         indexData.accumulate("Indexed Fields", indexDetails.getSearchableFieldNamesString());
         indexData.accumulate("Field Analyzer", indexDetails.getFieldAnalyzersString());
         indexData.accumulate("Status",

http://git-wip-us.apache.org/repos/asf/geode/blob/edae4abf/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexDetails.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexDetails.java
b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexDetails.java
index cc96df2..02a19a1 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexDetails.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexDetails.java
@@ -21,6 +21,8 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Map.Entry;
 
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.lucene.internal.LuceneIndexCreationProfile;
 import org.apache.geode.cache.lucene.internal.LuceneIndexImpl;
 import org.apache.geode.cache.lucene.internal.LuceneIndexStats;
@@ -31,6 +33,7 @@ public class LuceneIndexDetails implements Comparable<LuceneIndexDetails>,
Seria
   private static final long serialVersionUID = 1L;
   private final String indexName;
   private final String regionPath;
+  private final String serverName;
   private final String[] searchableFieldNames;
   private Map<String, String> fieldAnalyzers = null;
   private final Map<String, Integer> indexStats;
@@ -38,23 +41,24 @@ public class LuceneIndexDetails implements Comparable<LuceneIndexDetails>,
Seria
 
   public LuceneIndexDetails(final String indexName, final String regionPath,
       final String[] searchableFieldNames, final Map<String, Analyzer> fieldAnalyzers,
-      LuceneIndexStats indexStats, boolean initialized) {
+      LuceneIndexStats indexStats, boolean initialized, final String serverName) {
     this.indexName = indexName;
     this.regionPath = regionPath;
+    this.serverName = serverName;
     this.searchableFieldNames = searchableFieldNames;
     this.fieldAnalyzers = getFieldAnalyzerStrings(fieldAnalyzers);
     this.indexStats = getIndexStatsMap(indexStats);
     this.initialized = initialized;
   }
 
-  public LuceneIndexDetails(LuceneIndexImpl index) {
+  public LuceneIndexDetails(LuceneIndexImpl index, final String serverName) {
     this(index.getName(), index.getRegionPath(), index.getFieldNames(), index.getFieldAnalyzers(),
-        index.getIndexStats(), true);
+        index.getIndexStats(), true, serverName);
   }
 
-  public LuceneIndexDetails(LuceneIndexCreationProfile indexProfile) {
+  public LuceneIndexDetails(LuceneIndexCreationProfile indexProfile, final String serverName)
{
     this(indexProfile.getIndexName(), indexProfile.getRegionPath(), indexProfile.getFieldNames(),
-        null, null, false);
+        null, null, false, serverName);
     this.fieldAnalyzers = getFieldAnalyzerStringsFromProfile(indexProfile.getFieldAnalyzers());
   }
 
@@ -157,4 +161,7 @@ public class LuceneIndexDetails implements Comparable<LuceneIndexDetails>,
Seria
         : compare(getRegionPath(), indexDetails.getRegionPath()));
   }
 
+  public String getServerName() {
+    return serverName;
+  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/edae4abf/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneDescribeIndexFunction.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneDescribeIndexFunction.java
b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneDescribeIndexFunction.java
index 0ec5b4d..9788c4a 100755
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneDescribeIndexFunction.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneDescribeIndexFunction.java
@@ -15,15 +15,11 @@
 
 package org.apache.geode.cache.lucene.internal.cli.functions;
 
-import java.util.HashSet;
-import java.util.Set;
-
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.execute.FunctionAdapter;
 import org.apache.geode.cache.execute.FunctionContext;
 import org.apache.geode.cache.lucene.LuceneIndex;
-import org.apache.geode.cache.lucene.LuceneService;
 import org.apache.geode.cache.lucene.LuceneServiceProvider;
 import org.apache.geode.cache.lucene.internal.LuceneIndexCreationProfile;
 import org.apache.geode.cache.lucene.internal.LuceneIndexImpl;
@@ -60,15 +56,16 @@ public class LuceneDescribeIndexFunction extends FunctionAdapter implements
Inte
     LuceneIndexDetails result = null;
 
     final Cache cache = getCache();
+    final String serverName = cache.getDistributedSystem().getDistributedMember().getName();
     final LuceneIndexInfo indexInfo = (LuceneIndexInfo) context.getArguments();
     LuceneServiceImpl service = (LuceneServiceImpl) LuceneServiceProvider.get(cache);
     LuceneIndex index = service.getIndex(indexInfo.getIndexName(), indexInfo.getRegionPath());
     LuceneIndexCreationProfile profile =
         service.getDefinedIndex(indexInfo.getIndexName(), indexInfo.getRegionPath());
     if (index != null) {
-      result = new LuceneIndexDetails((LuceneIndexImpl) index);
+      result = new LuceneIndexDetails((LuceneIndexImpl) index, serverName);
     } else if (profile != null) {
-      result = new LuceneIndexDetails(profile);
+      result = new LuceneIndexDetails(profile, serverName);
     }
     context.getResultSender().lastResult(result);
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/edae4abf/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneListIndexFunction.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneListIndexFunction.java
b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneListIndexFunction.java
index 8732bba..033b162 100755
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneListIndexFunction.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneListIndexFunction.java
@@ -23,7 +23,6 @@ import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.execute.FunctionAdapter;
 import org.apache.geode.cache.execute.FunctionContext;
 import org.apache.geode.cache.lucene.LuceneIndex;
-import org.apache.geode.cache.lucene.LuceneService;
 import org.apache.geode.cache.lucene.LuceneServiceProvider;
 import org.apache.geode.cache.lucene.internal.LuceneIndexCreationProfile;
 import org.apache.geode.cache.lucene.internal.LuceneIndexImpl;
@@ -57,13 +56,14 @@ public class LuceneListIndexFunction extends FunctionAdapter implements
Internal
   public void execute(final FunctionContext context) {
     final Set<LuceneIndexDetails> indexDetailsSet = new HashSet<>();
     final Cache cache = getCache();
+    final String serverName = cache.getDistributedSystem().getDistributedMember().getName();
     LuceneServiceImpl service = (LuceneServiceImpl) LuceneServiceProvider.get(cache);
     for (LuceneIndex index : service.getAllIndexes()) {
-      indexDetailsSet.add(new LuceneIndexDetails((LuceneIndexImpl) index));
+      indexDetailsSet.add(new LuceneIndexDetails((LuceneIndexImpl) index, serverName));
     }
 
     for (LuceneIndexCreationProfile profile : service.getAllDefinedIndexes()) {
-      indexDetailsSet.add(new LuceneIndexDetails(profile));
+      indexDetailsSet.add(new LuceneIndexDetails(profile, serverName));
     }
     context.getResultSender().lastResult(indexDetailsSet);
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/edae4abf/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsJUnitTest.java
b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsJUnitTest.java
index dbb80dc..6ddef9e 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsJUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsJUnitTest.java
@@ -48,7 +48,6 @@ import org.apache.geode.internal.util.CollectionUtils;
 import org.apache.geode.management.cli.Result.Status;
 import org.apache.geode.management.internal.cli.functions.CliFunctionResult;
 import org.apache.geode.management.internal.cli.result.CommandResult;
-import org.apache.geode.management.internal.cli.result.CommandResultException;
 import org.apache.geode.management.internal.cli.result.ResultBuilder;
 import org.apache.geode.management.internal.cli.result.TabularResultData;
 import org.apache.geode.management.internal.cli.shell.Gfsh;
@@ -76,6 +75,7 @@ public class LuceneIndexCommandsJUnitTest {
   public void testListIndexWithoutStats() {
 
     final Cache mockCache = mock(Cache.class, "Cache");
+    final String serverName = "mockServer";
     final AbstractExecution mockFunctionExecutor =
         mock(AbstractExecution.class, "Function Executor");
     final ResultCollector mockResultCollector = mock(ResultCollector.class, "ResultCollector");
@@ -85,12 +85,12 @@ public class LuceneIndexCommandsJUnitTest {
     fieldAnalyzers.put("field1", new StandardAnalyzer());
     fieldAnalyzers.put("field2", new KeywordAnalyzer());
     fieldAnalyzers.put("field3", null);
-    final LuceneIndexDetails indexDetails1 =
-        createIndexDetails("memberFive", "/Employees", searchableFields, fieldAnalyzers,
true);
-    final LuceneIndexDetails indexDetails2 =
-        createIndexDetails("memberSix", "/Employees", searchableFields, fieldAnalyzers, false);
-    final LuceneIndexDetails indexDetails3 =
-        createIndexDetails("memberTen", "/Employees", searchableFields, fieldAnalyzers, true);
+    final LuceneIndexDetails indexDetails1 = createIndexDetails("memberFive", "/Employees",
+        searchableFields, fieldAnalyzers, true, serverName);
+    final LuceneIndexDetails indexDetails2 = createIndexDetails("memberSix", "/Employees",
+        searchableFields, fieldAnalyzers, false, serverName);
+    final LuceneIndexDetails indexDetails3 = createIndexDetails("memberTen", "/Employees",
+        searchableFields, fieldAnalyzers, true, serverName);
 
     final List<Set<LuceneIndexDetails>> results = new ArrayList<>();
 
@@ -124,6 +124,7 @@ public class LuceneIndexCommandsJUnitTest {
   public void testListIndexWithStats() {
 
     final Cache mockCache = mock(Cache.class, "Cache");
+    final String serverName = "mockServer";
     final AbstractExecution mockFunctionExecutor =
         mock(AbstractExecution.class, "Function Executor");
     final ResultCollector mockResultCollector = mock(ResultCollector.class, "ResultCollector");
@@ -136,11 +137,11 @@ public class LuceneIndexCommandsJUnitTest {
     fieldAnalyzers.put("field2", new KeywordAnalyzer());
     fieldAnalyzers.put("field3", null);
     final LuceneIndexDetails indexDetails1 = createIndexDetails("memberFive", "/Employees",
-        searchableFields, fieldAnalyzers, mockIndexStats1, true);
+        searchableFields, fieldAnalyzers, mockIndexStats1, true, serverName);
     final LuceneIndexDetails indexDetails2 = createIndexDetails("memberSix", "/Employees",
-        searchableFields, fieldAnalyzers, mockIndexStats2, true);
+        searchableFields, fieldAnalyzers, mockIndexStats2, true, serverName);
     final LuceneIndexDetails indexDetails3 = createIndexDetails("memberTen", "/Employees",
-        searchableFields, fieldAnalyzers, mockIndexStats3, true);
+        searchableFields, fieldAnalyzers, mockIndexStats3, true, serverName);
 
     final List<Set<LuceneIndexDetails>> results = new ArrayList<>();
 
@@ -206,6 +207,7 @@ public class LuceneIndexCommandsJUnitTest {
   public void testDescribeIndex() throws Exception {
 
     final Cache mockCache = mock(Cache.class, "Cache");
+    final String serverName = "mockServer";
     final ResultCollector mockResultCollector = mock(ResultCollector.class, "ResultCollector");
     final LuceneIndexCommands commands = spy(createIndexCommands(mockCache, null));
 
@@ -217,7 +219,7 @@ public class LuceneIndexCommandsJUnitTest {
     final LuceneIndexStats mockIndexStats = getMockIndexStats(1, 10, 5, 1);
     final List<LuceneIndexDetails> indexDetails = new ArrayList<>();
     indexDetails.add(createIndexDetails("memberFive", "/Employees", searchableFields,
-        fieldAnalyzers, mockIndexStats, true));
+        fieldAnalyzers, mockIndexStats, true, serverName));
 
     doReturn(mockResultCollector).when(commands).executeFunctionOnGroups(
         isA(LuceneDescribeIndexFunction.class), any(), any(LuceneIndexInfo.class));
@@ -439,15 +441,16 @@ public class LuceneIndexCommandsJUnitTest {
 
   private LuceneIndexDetails createIndexDetails(final String indexName, final String regionPath,
       final String[] searchableFields, final Map<String, Analyzer> fieldAnalyzers,
-      LuceneIndexStats indexStats, boolean status) {
+      LuceneIndexStats indexStats, boolean status, final String serverName) {
     return new LuceneIndexDetails(indexName, regionPath, searchableFields, fieldAnalyzers,
-        indexStats, status);
+        indexStats, status, serverName);
   }
 
   private LuceneIndexDetails createIndexDetails(final String indexName, final String regionPath,
-      final String[] searchableFields, final Map<String, Analyzer> fieldAnalyzers,
boolean status) {
+      final String[] searchableFields, final Map<String, Analyzer> fieldAnalyzers,
boolean status,
+      final String serverName) {
     return new LuceneIndexDetails(indexName, regionPath, searchableFields, fieldAnalyzers,
null,
-        status);
+        status, serverName);
   }
 
   private LuceneSearchResults createQueryResults(final String key, final String value,

http://git-wip-us.apache.org/repos/asf/geode/blob/edae4abf/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneDescribeIndexFunctionJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneDescribeIndexFunctionJUnitTest.java
b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneDescribeIndexFunctionJUnitTest.java
index 7330e2c..35e28ea 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneDescribeIndexFunctionJUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneDescribeIndexFunctionJUnitTest.java
@@ -17,15 +17,11 @@ package org.apache.geode.cache.lucene.internal.cli.functions;
 import static org.junit.Assert.*;
 import static org.mockito.Mockito.*;
 
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
 
 import org.apache.geode.cache.execute.FunctionContext;
 import org.apache.geode.cache.execute.ResultSender;
-import org.apache.geode.cache.lucene.LuceneIndex;
 import org.apache.geode.cache.lucene.internal.InternalLuceneService;
 import org.apache.geode.cache.lucene.internal.LuceneIndexImpl;
 import org.apache.geode.cache.lucene.internal.LuceneServiceImpl;
@@ -41,7 +37,6 @@ import org.apache.lucene.analysis.standard.StandardAnalyzer;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 import org.mockito.ArgumentCaptor;
-import org.mockito.Mockito;
 
 @Category(UnitTest.class)
 
@@ -51,6 +46,7 @@ public class LuceneDescribeIndexFunctionJUnitTest {
   @SuppressWarnings("unchecked")
   public void testExecute() throws Throwable {
     GemFireCacheImpl cache = Fakes.cache();
+    final String serverName = "mockServer";
     LuceneServiceImpl service = mock(LuceneServiceImpl.class);
     when(cache.getService(InternalLuceneService.class)).thenReturn(service);
     FunctionContext context = mock(FunctionContext.class);
@@ -69,7 +65,7 @@ public class LuceneDescribeIndexFunctionJUnitTest {
         ArgumentCaptor.forClass(LuceneIndexDetails.class);
     verify(resultSender).lastResult(resultCaptor.capture());
     LuceneIndexDetails result = resultCaptor.getValue();
-    LuceneIndexDetails expected = new LuceneIndexDetails(index1);
+    LuceneIndexDetails expected = new LuceneIndexDetails(index1, "mockServer");
 
     assertEquals(expected.getIndexName(), result.getIndexName());
     assertEquals(expected.getRegionPath(), result.getRegionPath());

http://git-wip-us.apache.org/repos/asf/geode/blob/edae4abf/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneListIndexFunctionJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneListIndexFunctionJUnitTest.java
b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneListIndexFunctionJUnitTest.java
index 3adc030..2d282a3 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneListIndexFunctionJUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneListIndexFunctionJUnitTest.java
@@ -19,7 +19,6 @@ import static org.mockito.Mockito.*;
 
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 import java.util.TreeSet;
@@ -51,6 +50,7 @@ public class LuceneListIndexFunctionJUnitTest {
   @SuppressWarnings("unchecked")
   public void testExecute() throws Throwable {
     GemFireCacheImpl cache = Fakes.cache();
+    final String serverName = "mockServer";
     LuceneServiceImpl service = mock(LuceneServiceImpl.class);
     when(cache.getService(InternalLuceneService.class)).thenReturn(service);
 
@@ -62,8 +62,8 @@ public class LuceneListIndexFunctionJUnitTest {
     LuceneIndexImpl index2 = getMockLuceneIndex("index2");
 
     TreeSet expectedResult = new TreeSet();
-    expectedResult.add(new LuceneIndexDetails(index1));
-    expectedResult.add(new LuceneIndexDetails(index2));
+    expectedResult.add(new LuceneIndexDetails(index1, serverName));
+    expectedResult.add(new LuceneIndexDetails(index2, serverName));
 
     ArrayList<LuceneIndex> allIndexes = new ArrayList();
     allIndexes.add(index1);


Mime
View raw message