geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [7/7] geode git commit: Revert DataCommandsFunction
Date Tue, 25 Jul 2017 21:44:59 GMT
Revert DataCommandsFunction


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

Branch: refs/heads/feature/GEODE-3299
Commit: 7956fb4249b4e9de8c189babeeecfebfcbd40a5c
Parents: 54e628f
Author: Kirk Lund <klund@apache.org>
Authored: Tue Jul 25 14:36:43 2017 -0700
Committer: Kirk Lund <klund@apache.org>
Committed: Tue Jul 25 14:38:57 2017 -0700

----------------------------------------------------------------------
 .../internal/cli/commands/DataCommands.java     |   4 +-
 .../cli/functions/DataCommandFunction.java      | 228 +++++++++----------
 .../functions/DataCommandFunctionJUnitTest.java |   6 +-
 3 files changed, 117 insertions(+), 121 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/7956fb42/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DataCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DataCommands.java
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DataCommands.java
index 4dd04cf..69daca6 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DataCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DataCommands.java
@@ -966,8 +966,8 @@ public class DataCommands implements GfshCommand {
             false);
       }
     } else {
-      dataResult =
-          getfn.get(null, key, keyClass, regionPath, loadOnCacheMiss, cache.getSecurityService());
+      dataResult = getfn.get(null, key, keyClass, valueClass, regionPath, loadOnCacheMiss,
+          cache.getSecurityService());
     }
     dataResult.setKeyClass(keyClass);
     if (valueClass != null) {

http://git-wip-us.apache.org/repos/asf/geode/blob/7956fb42/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DataCommandFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DataCommandFunction.java
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DataCommandFunction.java
index afad0d7..96f8815 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DataCommandFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/DataCommandFunction.java
@@ -14,8 +14,10 @@
  */
 package org.apache.geode.management.internal.cli.functions;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -24,11 +26,13 @@ import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.logging.log4j.Logger;
+import org.apache.shiro.subject.Subject;
 import org.json.JSONArray;
 
+import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.DataPolicy;
 import org.apache.geode.cache.Region;
-import org.apache.geode.cache.execute.Function;
+import org.apache.geode.cache.execute.FunctionAdapter;
 import org.apache.geode.cache.execute.FunctionContext;
 import org.apache.geode.cache.partition.PartitionRegionHelper;
 import org.apache.geode.cache.query.FunctionDomainException;
@@ -65,23 +69,52 @@ import org.apache.geode.pdx.PdxInstance;
 /**
  * @since GemFire 7.0
  */
-public class DataCommandFunction implements Function, InternalEntity {
-  private static final long serialVersionUID = 1L;
+public class DataCommandFunction extends FunctionAdapter implements InternalEntity {
   private static final Logger logger = LogService.getLogger();
 
+  private static final long serialVersionUID = 1L;
+
+  private boolean optimizeForWrite = false;
+
   private static final int NESTED_JSON_LENGTH = 20;
 
-  private transient InternalCache cache;
+  @Override
+  public String getId() {
+    return DataCommandFunction.class.getName();
+  }
+
+  @Override
+  public boolean hasResult() {
+    return true;
+  }
+
+  @Override
+
+  public boolean isHA() {
+    return false;
+  }
+
+  /**
+   * Read only function
+   */
+  @Override
+  public boolean optimizeForWrite() {
+    return optimizeForWrite;
+  }
+
+  public void setOptimizeForWrite(boolean optimizeForWrite) {
+    this.optimizeForWrite = optimizeForWrite;
+  }
 
   @Override
-  public void execute(final FunctionContext functionContext) {
+  public void execute(FunctionContext functionContext) {
     try {
-      cache = (InternalCache) functionContext.getCache();
+      InternalCache cache = getCache();
       DataCommandRequest request = (DataCommandRequest) functionContext.getArguments();
       if (logger.isDebugEnabled()) {
-        logger.debug("Executing function : \n{}\n on member {}", request, cache.getMyId());
+        logger.debug("Executing function : \n{}\n on member {}", request,
+            System.getProperty("memberName"));
       }
-
       DataCommandResult result = null;
       if (request.isGet()) {
         result = get(request, cache.getSecurityService());
@@ -94,34 +127,22 @@ public class DataCommandFunction implements Function, InternalEntity
{
       } else if (request.isSelect()) {
         result = select(request);
       }
-
       if (logger.isDebugEnabled()) {
         logger.debug("Result is {}", result);
       }
       functionContext.getResultSender().lastResult(result);
-
     } catch (Exception e) {
       logger.info("Exception occurred:", e);
       functionContext.getResultSender().sendException(e);
     }
   }
 
-  @Override
-  public boolean hasResult() {
-    return true;
-  }
 
-  @Override
-  public boolean optimizeForWrite() {
-    return false;
+  private InternalCache getCache() {
+    return (InternalCache) CacheFactory.getAnyInstance();
   }
 
-  @Override
-  public boolean isHA() {
-    return false;
-  }
-
-  private DataCommandResult remove(final DataCommandRequest request) {
+  public DataCommandResult remove(DataCommandRequest request) {
     String key = request.getKey();
     String keyClass = request.getKeyClass();
     String regionName = request.getRegionName();
@@ -129,26 +150,26 @@ public class DataCommandFunction implements Function, InternalEntity
{
     return remove(key, keyClass, regionName, removeAllKeys);
   }
 
-  private DataCommandResult get(final DataCommandRequest request,
-      final SecurityService securityService) {
+  public DataCommandResult get(DataCommandRequest request, SecurityService securityService)
{
     String key = request.getKey();
     String keyClass = request.getKeyClass();
     String valueClass = request.getValueClass();
     String regionName = request.getRegionName();
     Boolean loadOnCacheMiss = request.isLoadOnCacheMiss();
-    return get(request.getPrincipal(), key, keyClass, regionName, loadOnCacheMiss, securityService);
+    return get(request.getPrincipal(), key, keyClass, valueClass, regionName, loadOnCacheMiss,
+        securityService);
   }
 
-  private DataCommandResult locateEntry(final DataCommandRequest request) {
+  public DataCommandResult locateEntry(DataCommandRequest request) {
     String key = request.getKey();
     String keyClass = request.getKeyClass();
     String valueClass = request.getValueClass();
     String regionName = request.getRegionName();
     boolean recursive = request.isRecursive();
-    return locateEntry(key, keyClass, regionName, recursive);
+    return locateEntry(key, keyClass, valueClass, regionName, recursive);
   }
 
-  private DataCommandResult put(final DataCommandRequest request) {
+  public DataCommandResult put(DataCommandRequest request) {
     String key = request.getKey();
     String value = request.getValue();
     boolean putIfAbsent = request.isPutIfAbsent();
@@ -158,12 +179,30 @@ public class DataCommandFunction implements Function, InternalEntity
{
     return put(key, value, putIfAbsent, keyClass, valueClass, regionName);
   }
 
-  DataCommandResult select(final DataCommandRequest request) {
+  public DataCommandResult select(DataCommandRequest request) {
     String query = request.getQuery();
     return select(request.getPrincipal(), query);
   }
 
-  private DataCommandResult select(final Object principal, final String queryString) {
+  /**
+   * To catch trace output
+   */
+  public static class WrappedIndexTrackingQueryObserver extends IndexTrackingQueryObserver
{
+
+    @Override
+    public void reset() {
+      // NOOP
+    }
+
+    public void reset2() {
+      super.reset();
+    }
+  }
+
+  @SuppressWarnings("rawtypes")
+  private DataCommandResult select(Object principal, String queryString) {
+
+    InternalCache cache = getCache();
     AtomicInteger nestedObjectCount = new AtomicInteger(0);
     if (StringUtils.isEmpty(queryString)) {
       return DataCommandResult.createSelectInfoResult(null, null, -1, null,
@@ -172,9 +211,8 @@ public class DataCommandFunction implements Function, InternalEntity {
 
     QueryService qs = cache.getQueryService();
 
-    // TODO : Find out if is this optimized use. Can you have something equivalent of parsed
+    // TODO : Find out if is this optimised use. Can you have something equivalent of parsed
     // queries with names where name can be retrieved to avoid parsing every-time
-
     Query query = qs.newQuery(queryString);
     DefaultQuery tracedQuery = (DefaultQuery) query;
     WrappedIndexTrackingQueryObserver queryObserver = null;
@@ -189,18 +227,15 @@ public class DataCommandFunction implements Function, InternalEntity
{
 
     try {
       Object results = query.execute();
-
       if (tracedQuery.isTraced()) {
-        queryVerboseMsg = getLogMessage(queryObserver, startTime);
+        queryVerboseMsg = getLogMessage(queryObserver, startTime, queryString);
         queryObserver.reset2();
       }
-
       if (results instanceof SelectResults) {
         select_SelectResults((SelectResults) results, principal, list, nestedObjectCount);
       } else {
         select_NonSelectResults(results, list);
       }
-
       return DataCommandResult.createSelectResult(queryString, list, queryVerboseMsg, null,
null,
           true);
 
@@ -209,7 +244,6 @@ public class DataCommandFunction implements Function, InternalEntity {
       logger.warn(e.getMessage(), e);
       return DataCommandResult.createSelectResult(queryString, null, queryVerboseMsg, e,
           e.getMessage(), false);
-
     } finally {
       if (queryObserver != null) {
         QueryObserverHolder.reset();
@@ -217,76 +251,65 @@ public class DataCommandFunction implements Function, InternalEntity
{
     }
   }
 
-  private void select_NonSelectResults(final Object results, final List<SelectResultRow>
list) {
+  private void select_NonSelectResults(Object results, List<SelectResultRow> list)
{
     if (logger.isDebugEnabled()) {
       logger.debug("BeanResults : Bean Results class is {}", results.getClass());
     }
     String str = toJson(results);
     GfJsonObject jsonBean;
-
     try {
       jsonBean = new GfJsonObject(str);
-
     } catch (GfJsonException e) {
       logger.info("Exception occurred:", e);
       jsonBean = new GfJsonObject();
-
       try {
         jsonBean.put("msg", e.getMessage());
       } catch (GfJsonException e1) {
         logger.warn("Ignored GfJsonException:", e1);
       }
     }
-
     if (logger.isDebugEnabled()) {
       logger.debug("BeanResults : Adding bean json string : {}", jsonBean);
     }
     list.add(new SelectResultRow(DataCommandResult.ROW_TYPE_BEAN, jsonBean.toString()));
   }
 
-  private void select_SelectResults(final SelectResults selectResults, final Object principal,
-      final List<SelectResultRow> list, final AtomicInteger nestedObjectCount)
-      throws GfJsonException {
+  private void select_SelectResults(SelectResults selectResults, Object principal,
+      List<SelectResultRow> list, AtomicInteger nestedObjectCount) throws GfJsonException
{
     for (Object object : selectResults) {
       // Post processing
-      object = cache.getSecurityService().postProcess(principal, null, null, object, false);
+      object = getCache().getSecurityService().postProcess(principal, null, null, object,
false);
 
       if (object instanceof Struct) {
         StructImpl impl = (StructImpl) object;
-        GfJsonObject jsonStruct = getJSONForStruct(impl);
+        GfJsonObject jsonStruct = getJSONForStruct(impl, nestedObjectCount);
         if (logger.isDebugEnabled()) {
           logger.debug("SelectResults : Adding select json string : {}", jsonStruct);
         }
         list.add(
             new SelectResultRow(DataCommandResult.ROW_TYPE_STRUCT_RESULT, jsonStruct.toString()));
-
       } else if (JsonUtil.isPrimitiveOrWrapper(object.getClass())) {
         if (logger.isDebugEnabled()) {
           logger.debug("SelectResults : Adding select primitive : {}", object);
         }
         list.add(new SelectResultRow(DataCommandResult.ROW_TYPE_PRIMITIVE, object));
-
       } else {
         if (logger.isDebugEnabled()) {
           logger.debug("SelectResults : Bean Results class is {}", object.getClass());
         }
         String str = toJson(object);
         GfJsonObject jsonBean;
-
         try {
           jsonBean = new GfJsonObject(str);
-
         } catch (GfJsonException e) {
           logger.error(e.getMessage(), e);
           jsonBean = new GfJsonObject();
-
           try {
             jsonBean.put("msg", e.getMessage());
           } catch (GfJsonException e1) {
             logger.warn("Ignored GfJsonException:", e1);
           }
         }
-
         if (logger.isDebugEnabled()) {
           logger.debug("SelectResults : Adding bean json string : {}", jsonBean);
         }
@@ -295,7 +318,7 @@ public class DataCommandFunction implements Function, InternalEntity {
     }
   }
 
-  private String toJson(final Object object) {
+  private String toJson(Object object) {
     if (object instanceof Undefined) {
       return "{\"Value\":\"UNDEFINED\"}";
     } else if (object instanceof PdxInstance) {
@@ -305,21 +328,18 @@ public class DataCommandFunction implements Function, InternalEntity
{
     }
   }
 
-  private GfJsonObject getJSONForStruct(final StructImpl impl) throws GfJsonException {
+  private GfJsonObject getJSONForStruct(StructImpl impl, AtomicInteger ai) throws GfJsonException
{
     String fields[] = impl.getFieldNames();
     Object[] values = impl.getFieldValues();
     GfJsonObject jsonObject = new GfJsonObject();
-
     for (int i = 0; i < fields.length; i++) {
       Object value = values[i];
-
       if (value != null) {
         if (JsonUtil.isPrimitiveOrWrapper(value.getClass())) {
           jsonObject.put(fields[i], value);
         } else {
           jsonObject.put(fields[i], toJson(value));
         }
-
       } else {
         jsonObject.put(fields[i], "null");
       }
@@ -327,8 +347,12 @@ public class DataCommandFunction implements Function, InternalEntity
{
     return jsonObject;
   }
 
-  public DataCommandResult remove(final String key, final String keyClass, final String regionName,
-      final String removeAllKeys) {
+  @SuppressWarnings({"rawtypes"})
+  public DataCommandResult remove(String key, String keyClass, String regionName,
+      String removeAllKeys) {
+
+    InternalCache cache = getCache();
+
     if (StringUtils.isEmpty(regionName)) {
       return DataCommandResult.createRemoveResult(key, null, null,
           CliStrings.REMOVE__MSG__REGIONNAME_EMPTY, false);
@@ -343,7 +367,6 @@ public class DataCommandFunction implements Function, InternalEntity {
     if (region == null) {
       return DataCommandResult.createRemoveInfoResult(key, null, null,
           CliStrings.format(CliStrings.REMOVE__MSG__REGION_NOT_FOUND, regionName), false);
-
     } else {
       if (removeAllKeys == null) {
         Object keyObject;
@@ -374,7 +397,6 @@ public class DataCommandFunction implements Function, InternalEntity {
           return DataCommandResult.createRemoveInfoResult(key, null, null,
               CliStrings.REMOVE__MSG__KEY_NOT_FOUND_REGION, false);
         }
-
       } else {
         DataPolicy policy = region.getAttributes().getDataPolicy();
         if (!policy.withPartitioning()) {
@@ -392,9 +414,11 @@ public class DataCommandFunction implements Function, InternalEntity
{
     }
   }
 
-  public DataCommandResult get(final Object principal, final String key, final String keyClass,
-      final String regionName, final Boolean loadOnCacheMiss,
-      final SecurityService securityService) {
+  @SuppressWarnings({"rawtypes"})
+  public DataCommandResult get(Object principal, String key, String keyClass, String valueClass,
+      String regionName, Boolean loadOnCacheMiss, SecurityService securityService) {
+
+    InternalCache cache = getCache();
 
     if (StringUtils.isEmpty(regionName)) {
       return DataCommandResult.createGetResult(key, null, null,
@@ -414,7 +438,6 @@ public class DataCommandFunction implements Function, InternalEntity {
       }
       return DataCommandResult.createGetResult(key, null, null,
           CliStrings.format(CliStrings.GET__MSG__REGION_NOT_FOUND, regionName), false);
-
     } else {
       Object keyObject;
       try {
@@ -429,7 +452,6 @@ public class DataCommandFunction implements Function, InternalEntity {
 
       // TODO determine whether the following conditional logic (assigned to 'doGet') is
safer or
       // necessary
-
       boolean doGet = Boolean.TRUE.equals(loadOnCacheMiss);
 
       if (doGet || region.containsKey(keyObject)) {
@@ -455,7 +477,6 @@ public class DataCommandFunction implements Function, InternalEntity {
         } else {
           return DataCommandResult.createGetResult(key, array[1], null, null, false);
         }
-
       } else {
         if (logger.isDebugEnabled()) {
           logger.debug("Key is not present in the region {}", regionName);
@@ -466,8 +487,11 @@ public class DataCommandFunction implements Function, InternalEntity
{
     }
   }
 
-  DataCommandResult locateEntry(final String key, final String keyClass, final String regionPath,
-      final boolean recursive) {
+  @SuppressWarnings({"unchecked", "rawtypes"})
+  public DataCommandResult locateEntry(String key, String keyClass, String valueClass,
+      String regionPath, boolean recursive) {
+
+    InternalCache cache = getCache();
 
     if (StringUtils.isEmpty(regionPath)) {
       return DataCommandResult.createLocateEntryResult(key, null, null,
@@ -489,7 +513,6 @@ public class DataCommandFunction implements Function, InternalEntity {
           listOfRegionsStartingWithRegionPath.add(targetRegion);
         }
       }
-
       if (listOfRegionsStartingWithRegionPath.size() == 0) {
         if (logger.isDebugEnabled()) {
           logger.debug("Region Not Found - {}", regionPath);
@@ -497,7 +520,6 @@ public class DataCommandFunction implements Function, InternalEntity {
         return DataCommandResult.createLocateEntryResult(key, null, null,
             CliStrings.format(CliStrings.REMOVE__MSG__REGION_NOT_FOUND, regionPath), false);
       }
-
     } else {
       Region region = cache.getRegion(regionPath);
       if (region == null) {
@@ -514,12 +536,10 @@ public class DataCommandFunction implements Function, InternalEntity
{
     Object keyObject;
     try {
       keyObject = getClassObject(key, keyClass);
-
     } catch (ClassNotFoundException e) {
       logger.error(e.getMessage(), e);
       return DataCommandResult.createLocateEntryResult(key, null, null,
           "ClassNotFoundException " + keyClass, false);
-
     } catch (IllegalArgumentException e) {
       logger.error(e.getMessage(), e);
       return DataCommandResult.createLocateEntryResult(key, null, null,
@@ -554,7 +574,6 @@ public class DataCommandFunction implements Function, InternalEntity {
           return DataCommandResult.createLocateEntryInfoResult(key, null, null,
               CliStrings.LOCATE_ENTRY__MSG__KEY_NOT_FOUND_REGION, false);
         }
-
       } else {
         if (region.containsKey(keyObject)) {
           value = region.get(keyObject);
@@ -584,8 +603,9 @@ public class DataCommandFunction implements Function, InternalEntity {
     }
   }
 
-  public DataCommandResult put(final String key, final String value, final boolean putIfAbsent,
-      final String keyClass, final String valueClass, final String regionName) {
+  @SuppressWarnings({"rawtypes"})
+  public DataCommandResult put(String key, String value, boolean putIfAbsent, String keyClass,
+      String valueClass, String regionName) {
 
     if (StringUtils.isEmpty(regionName)) {
       return DataCommandResult.createPutResult(key, null, null,
@@ -602,15 +622,14 @@ public class DataCommandFunction implements Function, InternalEntity
{
           false);
     }
 
+    InternalCache cache = getCache();
     Region region = cache.getRegion(regionName);
     if (region == null) {
       return DataCommandResult.createPutResult(key, null, null,
           CliStrings.format(CliStrings.PUT__MSG__REGION_NOT_FOUND, regionName), false);
-
     } else {
       Object keyObject;
       Object valueObject;
-
       try {
         keyObject = getClassObject(key, keyClass);
       } catch (ClassNotFoundException e) {
@@ -627,14 +646,12 @@ public class DataCommandFunction implements Function, InternalEntity
{
         return DataCommandResult.createPutResult(key, null, null,
             "ClassNotFoundException " + valueClass, false);
       }
-
       Object returnValue;
       if (putIfAbsent && region.containsKey(keyObject)) {
         returnValue = region.get(keyObject);
       } else {
         returnValue = region.put(keyObject, valueObject);
       }
-
       Object array[] = getJSONForNonPrimitiveObject(returnValue);
       DataCommandResult result = DataCommandResult.createPutResult(key, array[1], null, null,
true);
       if (array[0] != null) {
@@ -644,7 +661,8 @@ public class DataCommandFunction implements Function, InternalEntity {
     }
   }
 
-  private Object getClassObject(final String string, final String klassString)
+  @SuppressWarnings({"rawtypes", "unchecked"})
+  private Object getClassObject(String string, String klassString)
       throws ClassNotFoundException, IllegalArgumentException {
     if (StringUtils.isEmpty(klassString)) {
       return string;
@@ -673,7 +691,6 @@ public class DataCommandFunction implements Function, InternalEntity {
           return Float.parseFloat(string);
         }
         return null;
-
       } catch (NumberFormatException e) {
         throw new IllegalArgumentException(
             "Failed to convert input key to " + klassString + " Msg : " + e.getMessage());
@@ -683,33 +700,30 @@ public class DataCommandFunction implements Function, InternalEntity
{
     return getObjectFromJson(string, klass);
   }
 
-  private static Object[] getJSONForNonPrimitiveObject(final Object obj) {
+  @SuppressWarnings({"rawtypes"})
+  public static Object[] getJSONForNonPrimitiveObject(Object obj) {
     Object[] array = new Object[2];
     if (obj == null) {
       array[0] = null;
       array[1] = "<NULL>";
       return array;
-
     } else {
       array[0] = obj.getClass().getCanonicalName();
       Class klass = obj.getClass();
-
       if (JsonUtil.isPrimitiveOrWrapper(klass)) {
         array[1] = obj;
-
       } else if (obj instanceof PdxInstance) {
         String str = pdxToJson((PdxInstance) obj);
         array[1] = str;
-
       } else {
         GfJsonObject object = new GfJsonObject(obj, true);
         Iterator keysIterator = object.keys();
         while (keysIterator.hasNext()) {
           String key = (String) keysIterator.next();
           Object value = object.get(key);
-
           if (GfJsonObject.isJSONKind(value)) {
             GfJsonObject jsonVal = new GfJsonObject(value);
+            // System.out.println("Re-wrote inner object");
             try {
               if (jsonVal.has("type-class")) {
                 object.put(key, jsonVal.get("type-class"));
@@ -720,7 +734,6 @@ public class DataCommandFunction implements Function, InternalEntity {
             } catch (GfJsonException e) {
               throw new RuntimeException(e);
             }
-
           } else if (value instanceof JSONArray) {
             // Its a collection either a set or list
             try {
@@ -737,7 +750,7 @@ public class DataCommandFunction implements Function, InternalEntity {
     }
   }
 
-  private static String pdxToJson(final PdxInstance obj) {
+  private static String pdxToJson(PdxInstance obj) {
     if (obj != null) {
       try {
         GfJsonObject json = new GfJsonObject();
@@ -752,7 +765,6 @@ public class DataCommandFunction implements Function, InternalEntity {
           }
         }
         return json.toString();
-
       } catch (GfJsonException e) {
         return null;
       }
@@ -760,7 +772,7 @@ public class DataCommandFunction implements Function, InternalEntity {
     return null;
   }
 
-  private static <V> V getObjectFromJson(final String json, final Class<V> klass)
{
+  public static <V> V getObjectFromJson(String json, Class<V> klass) {
     String newString = json.replaceAll("'", "\"");
     if (newString.charAt(0) == '(') {
       int len = newString.length();
@@ -771,6 +783,7 @@ public class DataCommandFunction implements Function, InternalEntity {
     return JsonUtil.jsonToObject(newString, klass);
   }
 
+
   /**
    * Returns a sorted list of all region full paths found in the specified cache.
    * 
@@ -778,8 +791,9 @@ public class DataCommandFunction implements Function, InternalEntity {
    * @param recursive recursive search for sub-regions
    * @return Returns a sorted list of all region paths defined in the distributed system.
    */
-  private static List getAllRegionPaths(final InternalCache cache, final boolean recursive)
{
-    List list = new ArrayList();
+  @SuppressWarnings({"rawtypes", "unchecked"})
+  public static List getAllRegionPaths(InternalCache cache, boolean recursive) {
+    ArrayList list = new ArrayList();
     if (cache == null) {
       return list;
     }
@@ -803,7 +817,7 @@ public class DataCommandFunction implements Function, InternalEntity {
     return list;
   }
 
-  private static String getLogMessage(final QueryObserver observer, final long startTime)
{
+  public static String getLogMessage(QueryObserver observer, long startTime, String query)
{
     String usedIndexesString = null;
     float time = 0.0f;
 
@@ -815,11 +829,10 @@ public class DataCommandFunction implements Function, InternalEntity
{
       IndexTrackingQueryObserver indexObserver = (IndexTrackingQueryObserver) observer;
       Map usedIndexes = indexObserver.getUsedIndexes();
       indexObserver.reset();
-      StringBuilder buf = new StringBuilder();
+      StringBuffer buf = new StringBuffer();
       buf.append(" indexesUsed(");
       buf.append(usedIndexes.size());
       buf.append(")");
-
       if (usedIndexes.size() > 0) {
         buf.append(":");
         for (Iterator itr = usedIndexes.entrySet().iterator(); itr.hasNext();) {
@@ -830,9 +843,7 @@ public class DataCommandFunction implements Function, InternalEntity {
           }
         }
       }
-
       usedIndexesString = buf.toString();
-
     } else if (DefaultQuery.QUERY_VERBOSE) {
       usedIndexesString = " indexesUsed(NA due to other observer in the way: "
           + observer.getClass().getName() + ")";
@@ -842,19 +853,4 @@ public class DataCommandFunction implements Function, InternalEntity
{
         usedIndexesString != null ? usedIndexesString : "");
   }
 
-  /**
-   * To catch trace output
-   */
-  public static class WrappedIndexTrackingQueryObserver extends IndexTrackingQueryObserver
{
-
-    @Override
-    public void reset() {
-      // NOOP
-    }
-
-    void reset2() {
-      super.reset();
-    }
-  }
-
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/7956fb42/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/DataCommandFunctionJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/DataCommandFunctionJUnitTest.java
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/DataCommandFunctionJUnitTest.java
index c25ef23..5323258 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/DataCommandFunctionJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/DataCommandFunctionJUnitTest.java
@@ -102,7 +102,7 @@ public class DataCommandFunctionJUnitTest {
     DataCommandFunction dataCmdFn = new DataCommandFunction();
 
     DataCommandResult result = dataCmdFn.locateEntry("{'cheese': 'key_1'}",
-        StringCheese.class.getName(), PARTITIONED_REGION, false);
+        StringCheese.class.getName(), String.class.getName(), PARTITIONED_REGION, false);
 
     assertNotNull(result);
     result.aggregate(null);
@@ -114,8 +114,8 @@ public class DataCommandFunctionJUnitTest {
   public void testLocateKeyIsString() throws Exception {
     DataCommandFunction dataCmdFn = new DataCommandFunction();
 
-    DataCommandResult result =
-        dataCmdFn.locateEntry("key_2", String.class.getName(), PARTITIONED_REGION, false);
+    DataCommandResult result = dataCmdFn.locateEntry("key_2", String.class.getName(),
+        String.class.getName(), PARTITIONED_REGION, false);
 
     assertNotNull(result);
     result.aggregate(null);


Mime
View raw message