You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by up...@apache.org on 2015/09/10 01:59:19 UTC
[36/50] [abbrv] incubator-geode git commit: GEODE-287: Remove old
gfsh code
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/49d99d4e/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/ls.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/ls.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/ls.java
deleted file mode 100644
index 298d048..0000000
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/ls.java
+++ /dev/null
@@ -1,584 +0,0 @@
-package com.gemstone.gemfire.internal.tools.gfsh.app.commands;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import com.gemstone.gemfire.cache.CacheStatistics;
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.internal.tools.gfsh.aggregator.AggregateResults;
-import com.gemstone.gemfire.internal.tools.gfsh.app.CommandExecutable;
-import com.gemstone.gemfire.internal.tools.gfsh.app.Gfsh;
-import com.gemstone.gemfire.internal.tools.gfsh.app.Nextable;
-import com.gemstone.gemfire.internal.tools.gfsh.app.aggregator.functions.util.LocalRegionInfoFunction;
-import com.gemstone.gemfire.internal.tools.gfsh.app.cache.data.ListMessage;
-import com.gemstone.gemfire.internal.tools.gfsh.app.cache.data.MapMessage;
-import com.gemstone.gemfire.internal.tools.gfsh.app.cache.data.Mappable;
-import com.gemstone.gemfire.internal.tools.gfsh.app.command.task.QueryResults;
-import com.gemstone.gemfire.internal.tools.gfsh.app.command.task.QueryTask;
-import com.gemstone.gemfire.internal.tools.gfsh.app.function.GfshData;
-import com.gemstone.gemfire.internal.tools.gfsh.app.function.GfshFunction;
-import com.gemstone.gemfire.internal.tools.gfsh.app.util.PrintUtil;
-import com.gemstone.gemfire.internal.tools.gfsh.command.CommandResults;
-import com.gemstone.gemfire.internal.tools.gfsh.util.RegionUtil;
-
-public class ls implements CommandExecutable, Nextable
-{
- private static final String HIDDEN_REGION_NAME_PREFIX = "_"; // 1 underscore
-
- private static final int TYPE_LOCAL_REGION = 0;
- private static final int TYPE_REMOTE_REGION = 1;
- public final static int TYPE_REMOTE_KEYS = 2;
-
- private Gfsh gfsh;
- private Region localRegion;
- private Iterator localRegionIterator;
- private List localKeyList;
- private int lastRowPrinted = 0;
-
- public ls(Gfsh gfsh)
- {
- this.gfsh = gfsh;
- gfsh.addEnumCommand("ls -e");
- gfsh.addEnumCommand("ls -k");
- gfsh.addEnumCommand("ls -s");
- }
-
- public void help()
- {
- gfsh.println("ls [-a|-c|-e|-k|-m|-p|-r|-s] [region path] | [-?]");
- gfsh.println(" List subregions or region entries in the current path or in the");
- gfsh.println(" specified path. If no option specified, then it lists all region");
- gfsh.println(" names except the hidden region names. A hidden region name begins");
- gfsh.println(" with the prefix " + HIDDEN_REGION_NAME_PREFIX + " (1 underscore).");
- gfsh.println(" -a List all regions. This option lists all regions including the region");
- gfsh.println(" names that begin with the prefix " + HIDDEN_REGION_NAME_PREFIX);
- gfsh.println(" (1 underscore).");
- gfsh.println(" -c List cache server information.");
- gfsh.println(" -e List local entries up to the fetch size.");
- gfsh.println(" -k List server keys up to the fetch size. The keys are enumerated. Use");
- gfsh.println(" the key numbers to get values using the 'get -k' command.");
- gfsh.println(" If partitioned region, then it displays the entries in only the");
- gfsh.println(" connected server's local dataset due to the potentially large size");
- gfsh.println(" of the partitioned region.");
- gfsh.println(" -m List region info of all peer members.");
- gfsh.println(" -p List the local data set of the partitioned region entries in the");
- gfsh.println(" server up to the fetch size. If the region is not a partitioned");
- gfsh.println(" region then print the region entries (same as 'ls -s' in that case.)");
- gfsh.println(" -r Recursively list all sub-region paths.");
- gfsh.println(" -s List server entries up to the fetch size. If partitioned region,");
- gfsh.println(" then it displays the entries in only the connected server's local");
- gfsh.println(" dataset due to the potentially large size of the partitioned region.");
-
- gfsh.println();
- }
-
- public void execute(String command) throws Exception
- {
- if (command.startsWith("ls -?")) {
- help();
- return;
- }
-
- // reset
- localKeyList = null;
-
- if (command.startsWith("ls -a")) {
- ls_a(command);
- } else if (command.startsWith("ls -c")) {
- ls_c(command);
- } else if (command.startsWith("ls -e")) {
- ls_e(command);
- } else if (command.startsWith("ls -k")) {
- ls_k(command);
- } else if (command.startsWith("ls -m")) {
- ls_m(command);
- } else if (command.startsWith("ls -r")) {
- ls_r(command);
- } else if (command.startsWith("ls -s")) {
- ls_s(command);
- } else if (command.startsWith("ls -p")) {
- ls_p(command);
- } else if (command.startsWith("ls")) {
- ls(command);
- }
- }
-
- private void ls_a(String command) throws Exception
- {
- LinkedList<String> list = new LinkedList<String>();
- Gfsh.parseCommand(command, list);
- String regionPath;
- if (list.size() == 2) {
- regionPath = gfsh.getCurrentPath();
- } else {
- regionPath = (String) list.get(2);
- if(!isRegionArgValid(regionPath)){
- return;
- }
- }
- listRegions(regionPath, true);
- }
-
- private void ls_c(String command) throws Exception
- {
-
- String regionPath = retrievePath(command);
-
- if (regionPath.equals("/")) {
- gfsh.println("Error: invalid region \"/\". Change to a valid region or specify the region path, i.e. ls -c /foo");
- return;
- }
-
- if(!isRegionArgValid(regionPath)){
- return;
- }
- regionPath = gfsh.getFullPath(regionPath, gfsh.getCurrentPath());
-
- long startTime = System.currentTimeMillis();
- List<AggregateResults> results = (List<AggregateResults>)gfsh.getAggregator().aggregate(new GfshFunction(command, regionPath, null), gfsh.getAggregateRegionPath());
- long stopTime = System.currentTimeMillis();
-
- for (AggregateResults aggregateResults : results) {
- GfshData data = (GfshData)aggregateResults.getDataObject();
- ListMessage message = (ListMessage)data.getDataObject();
- gfsh.println("--------------------------------------");
- gfsh.println("MemberId = " + data.getMemberInfo().getMemberId());
- gfsh.println("MemberName = " + data.getMemberInfo().getMemberName());
- gfsh.println("Host = " + data.getMemberInfo().getHost());
- gfsh.println("Pid = " + data.getMemberInfo().getPid());
- gfsh.println();
- Mappable mappables[] = message.getAllMappables();
- for (int i = 0; i < mappables.length; i++) {
- Set<String> keySet = mappables[i].getKeys();
- List<String> keyList = new ArrayList<String>(keySet);
- java.util.Collections.sort(keyList);
- for (String key : keyList) {
- Object value = mappables[i].getValue(key);
- gfsh.println(" " + key + " = " + value);
- }
- gfsh.println();
- }
- gfsh.println("--------------------------------------");
- gfsh.println();
- }
- if (gfsh.isShowTime()) {
- gfsh.println("elapsed (msec): " + (stopTime - startTime));
- }
- }
-
- private void ls_m(String command) throws Exception
- {
- String regionPath = retrievePath(command);
-
- if (regionPath.equals("/")) {
- gfsh.println("Error: invalid region \"/\". Change to a valid region or specify the region path, i.e. ls -a /foo");
- return;
- }
-
- if(!isRegionArgValid(regionPath)){
- return;
- }
-
- regionPath = gfsh.getFullPath(regionPath, gfsh.getCurrentPath());
-
- long startTime = System.currentTimeMillis();
- List<Mappable> resultList = (List<Mappable>)gfsh.getAggregator().aggregate(new LocalRegionInfoFunction(regionPath), gfsh.getAggregateRegionPath());
- long stopTime = System.currentTimeMillis();
-
- // First, set the member list in gfsh. This call sorts the list by member id.
- // The member list is kept by gfsh for commands like 'pr' that need to
- // lookup member ids.
- resultList = gfsh.setMemberList(resultList);
-
- boolean isPR = false;
- int totalRegionSize = 0;
- for (int i = 0; i < resultList.size(); i++) {
- MapMessage info = (MapMessage)resultList.get(i);
- try {
- if (info.getByte("Code") == AggregateResults.CODE_ERROR) {
- gfsh.println("Error: " + info.getString("CodeMessage"));
- return;
- }
- } catch (Exception ex) {
- // ignore
- }
- isPR = info.getBoolean("IsPR");
- if (isPR) {
- totalRegionSize += info.getInt("RegionSize");
- }
- }
-
- PrintUtil.printMappableList(resultList);
- if (isPR) {
- gfsh.println("Total Region Size: " + totalRegionSize);
- }
- if (gfsh.isShowTime()) {
- gfsh.println("elapsed (msec): " + (stopTime - startTime));
- }
- }
-
- private void ls_k(String command) throws Exception
- {
- String regionPath = retrievePath(command);
-
- if (regionPath.equals("/")) {
- gfsh.println("Error: invalid region \"/\". Change to a valid region or specify the region path, i.e. ls -k /foo");
- return;
- }
-
- if(!isRegionArgValid(regionPath)){
- return;
- }
-
- regionPath = gfsh.getFullPath(regionPath, gfsh.getCurrentPath());
-
- // ---------- Get keys using select ----------------
-// // get keys from the server
-// // ls -k
-// select s = (select)gfsh.getCommand("select");
-// // get the keys but limit it to 1000
-// localKeyList = s.getRemoteKeys(regionPath, 1000);
- // -------------------------------------------------
-
- // ---------- Get keys using function (QueryTask) -------------
- localKeyList = listRegionKeys(regionPath, true, true);
- // ------------------------------------------------------------
-
-
- gfsh.setLsKeyList(localKeyList);
- next n = (next)gfsh.getCommand("next");
- n.setCommand(getClass().getSimpleName(), TYPE_REMOTE_KEYS);
-
- }
-
- private void ls_r(String command) throws Exception
- {
- String regionPath = retrievePath(command);
-
- String regionPaths[];
- if (regionPath.equals("/")) {
- regionPaths = RegionUtil.getAllRegionPaths(gfsh.getCache(), true);
- } else {
- if(!isRegionArgValid(regionPath)){
- return;
- }
- regionPath = gfsh.getFullPath(regionPath, gfsh.getCurrentPath());
- Region<?, ?> region = RegionUtil.getLocalRegion(regionPath);
- regionPaths = RegionUtil.getAllRegionPaths(region, true);
- }
-
- for (int i = 0; i < regionPaths.length; i++) {
- gfsh.println(regionPaths[i]);
- }
- }
-
- private void ls_s(String command) throws Exception
- {
- String regionPath = retrievePath(command);
-
- if (regionPath.equals("/")) {
- gfsh.println("Error: invalid region \"/\". Change to a valid region or specify the region path, i.e. ls -k /foo");
- return;
- }
-
- if(!isRegionArgValid(regionPath)){
- return;
- }
- // Show only the local dataset entries if it's a partitioned regions
- listRegionEntries(regionPath, true, true);
- }
-
- private void ls_p(String command) throws Exception
- {
- String regionPath = retrievePath(command);
-
- if (regionPath.equals("/")) {
- gfsh.println("Error: invalid region \"/\". Change to a valid region or specify the region path, i.e. ls -k /foo");
- return;
- }
- if(!isRegionArgValid(regionPath)){
- return;
- }
- listRegionEntries(regionPath, true, true);
- }
-
- private void ls(String command) throws Exception
- {
- LinkedList list = new LinkedList();
- gfsh.parseCommand(command, list);
- String path;
- if (list.size() == 1) {
- path = gfsh.getCurrentPath();
- } else {
- path = (String) list.get(1);
- }
-
- listRegions(path, false);
- }
-
- private void listRegions(String path, boolean listAllRegions) throws Exception
- {
- Region region = null;
- Set regionSet;
- if (path.equals("/")) {
- regionSet = gfsh.getCache().rootRegions();
- } else {
- path = gfsh.getFullPath(path, gfsh.getCurrentPath());
- region = gfsh.getCache().getRegion(path);
- if (region == null) {
- gfsh.println("Error: Region undefined. Invalid path: " + path + ". Use absolute path.");
- return;
- }
- regionSet = region.subregions(false);
- }
-
- if (regionSet.size() == 0) {
- gfsh.println("Subregions: none");
- } else {
- gfsh.println("Subregions:");
- }
- List regionList = new ArrayList();
- for (Iterator itr = regionSet.iterator(); itr.hasNext();) {
- Region rgn = (Region) itr.next();
- String name = rgn.getName();
- if (listAllRegions == false && name.startsWith(HIDDEN_REGION_NAME_PREFIX)) {
- continue;
- }
- regionList.add(name);
- }
- Collections.sort(regionList);
- for (Iterator<String> itr = regionList.iterator(); itr.hasNext();) {
- String name = itr.next();
- for (Iterator itr2 = regionSet.iterator(); itr2.hasNext();) {
- Region rgn = (Region) itr2.next();
- String regionName = rgn.getName();
- if (name.equals(regionName)) {
- gfsh.println(" " + name);
- if (rgn.getAttributes().getStatisticsEnabled()) {
- CacheStatistics stats = rgn.getStatistics();
- gfsh.println(" " + stats);
- }
- break;
- }
- }
- }
- gfsh.println();
- }
-
- public List listRegionKeys(String regionPath, boolean nextEnabled, boolean isPRLocalData) throws Exception
- {
- regionPath = gfsh.getFullPath(regionPath, gfsh.getCurrentPath());
-
- // get keys from the server
- // ls -k
- boolean keysOnly = true;
- long startTime = System.currentTimeMillis();
- CommandResults cr = gfsh.getCommandClient().execute(new QueryTask(regionPath, gfsh.getFetchSize(), nextEnabled, isPRLocalData, keysOnly));
- long stopTime = System.currentTimeMillis();
- if (cr.getCode() == QueryTask.ERROR_QUERY) {
- gfsh.println(cr.getCodeMessage());
- return null;
- }
- QueryResults results = (QueryResults) cr.getDataObject();
- if (results == null) {
- gfsh.println("No results");
- return null;
- }
-
- if (regionPath == null) {
- localKeyList = null;
- lastRowPrinted = 0;
- }
- List keyList = localKeyList;
- if (keyList == null) {
- localKeyList = keyList = new ArrayList();
- }
- List list = (List)results.getResults();
- if (gfsh.isShowResults()) {
- lastRowPrinted = PrintUtil.printList(list, 0, 1, list.size(), results.getActualSize(), keyList);
- } else {
- gfsh.println(" Fetch size: " + gfsh.getFetchSize());
- gfsh.println(" Returned: " + list.size() + "/" + results.getActualSize());
- }
- if (results.isPR()) {
- gfsh.println("Partitioned region local dataset retrieval. The actual size maybe larger.");
- }
-
- if (gfsh.isShowTime()) {
- gfsh.println("elapsed (msec): " + (stopTime - startTime));
- }
-
- gfsh.setLsKeyList(keyList);
- next n = (next)gfsh.getCommand("next");
- n.setCommand(getClass().getSimpleName(), TYPE_REMOTE_REGION);
- return keyList;
- }
-
- public List listRegionEntries(String regionPath, boolean nextEnabled, boolean isPRLocalData) throws Exception
- {
- regionPath = gfsh.getFullPath(regionPath, gfsh.getCurrentPath());
-
- // get entries from the server
- // ls -s
- long startTime = System.currentTimeMillis();
- CommandResults cr = gfsh.getCommandClient().execute(new QueryTask(regionPath, gfsh.getFetchSize(), nextEnabled, isPRLocalData));
- long stopTime = System.currentTimeMillis();
- if (cr.getCode() == QueryTask.ERROR_QUERY) {
- gfsh.println(cr.getCodeMessage());
- return null;
- }
- QueryResults results = (QueryResults) cr.getDataObject();
- if (results == null) {
- gfsh.println("No results");
- return null;
- }
-
- if (regionPath == null) {
- localKeyList = null;
- lastRowPrinted = 0;
- }
- List keyList = localKeyList;
- if (keyList == null) {
- localKeyList = keyList = new ArrayList();
- }
- Map map = (Map)results.getResults();
- if (gfsh.isShowResults()) {
- lastRowPrinted = PrintUtil.printEntries(map, 0, 1, map.size(), results.getActualSize(), keyList);
- } else {
- gfsh.println(" Fetch size: " + gfsh.getFetchSize());
- gfsh.println(" Returned: " + map.size() + "/" + results.getActualSize());
- }
- if (results.isPR()) {
- gfsh.println("Partitioned region local dataset retrieval. The actual size maybe larger.");
- }
-
- if (gfsh.isShowTime()) {
- gfsh.println("elapsed (msec): " + (stopTime - startTime));
- }
-
- gfsh.setLsKeyList(keyList);
- next n = (next)gfsh.getCommand("next");
- n.setCommand(getClass().getSimpleName(), TYPE_REMOTE_REGION);
- return keyList;
- }
-
- public List next(Object userData) throws Exception
- {
- int nexType = (Integer)userData;
- if (nexType == TYPE_LOCAL_REGION) {
- if (localRegion == null) {
- return null;
- }
- int rowsPrinted = PrintUtil.printEntries(localRegion, localRegionIterator, lastRowPrinted, lastRowPrinted+1, gfsh.getFetchSize(), localKeyList);
- lastRowPrinted = lastRowPrinted + rowsPrinted;
- } else if (nexType == TYPE_REMOTE_REGION) {
- CommandResults cr = gfsh.getCommandClient().execute(new QueryTask(null, gfsh.getFetchSize(), true));
- QueryResults results = (QueryResults)cr.getDataObject();
- Map map = (Map)results.getResults();
- if (map != null) {
- int rowsPrinted;
- rowsPrinted = PrintUtil.printEntries(map, lastRowPrinted, lastRowPrinted+1, map.size(), results.getActualSize(), localKeyList);
- if (results.isPR()) {
- gfsh.println("Partitioned region local dataset retrieval. The actual size maybe larger.");
- }
- lastRowPrinted = lastRowPrinted + rowsPrinted;
- }
-
- } else if (nexType == TYPE_REMOTE_KEYS) {
-
- // ---------- Get keys using select ----------------
-// select s = (select)gfsh.getCommand("select");
-// List list = s.select(null, true);
- // -------------------------------------------------
-
- // ---------- Get keys using function (QueryTask) -------------
- CommandResults cr = gfsh.getCommandClient().execute(new QueryTask(null, gfsh.getFetchSize(), true));
- QueryResults results = (QueryResults)cr.getDataObject();
- List list = (List)results.getResults();
- if (list != null) {
- int rowsPrinted;
- rowsPrinted = PrintUtil.printList(list, lastRowPrinted, lastRowPrinted+1, list.size(), results.getActualSize(), localKeyList);
- if (results.isPR()) {
- gfsh.println("Partitioned region local dataset retrieval. The actual size maybe larger.");
- }
- lastRowPrinted = lastRowPrinted + rowsPrinted;
- }
- // ------------------------------------------------------------
-
- if (localKeyList == null) {
- localKeyList = list;
- } else if (list != null) {
- localKeyList.addAll(list);
- }
- }
- next n = (next)gfsh.getCommand("next");
- n.setCommand(getClass().getSimpleName(), nexType);
-
- return null;
- }
-
- private void ls_e(String command) throws Exception
- {
- String regionPath = retrievePath(command);
-
- localRegion = null;
- if (!regionPath.equals("/")) {
- if(!isRegionArgValid(regionPath)){
- return;
- }
- regionPath = gfsh.getFullPath(regionPath, gfsh.getCurrentPath());
- localRegion = gfsh.getCache().getRegion(regionPath);
- localKeyList = new ArrayList();
- localRegionIterator = localRegion.entrySet().iterator();
- lastRowPrinted = PrintUtil.printEntries(localRegion, localRegionIterator, 0, 1, gfsh.getFetchSize(), localKeyList);
- gfsh.setLsKeyList(localKeyList);
-
- next n = (next)gfsh.getCommand("next");
- n.setCommand(getClass().getSimpleName(), TYPE_LOCAL_REGION);
- gfsh.println();
- }
- }
-
- private boolean isOption(Object object) {
- Pattern pattern = Pattern.compile("^-[acmkrspe]");
- Matcher matcher = pattern.matcher(object.toString());
- if(matcher.matches()){
- return true;
- } else {
- return false;
- }
- }
-
- private boolean isRegionArgValid(String regionPath){
- String fullRegionPath = gfsh.getFullPath(regionPath, gfsh.getCurrentPath());
- Region<?, ?> region = RegionUtil.getLocalRegion(fullRegionPath);
- if (region == null) {
- if(isOption(regionPath)){
- gfsh.println("Error: ls does not support mulitple options");
- }else{
- gfsh.println("Error: region does not exist - " + regionPath);
- }
- return false;
- }
- return true;
- }
-
- private String retrievePath(String command){
- LinkedList<String> list = new LinkedList<String>();
- Gfsh.parseCommand(command, list);
- String regionPath;
- if (list.size() == 2) {
- regionPath = gfsh.getCurrentPath();
- } else {
- regionPath = (String) list.get(2);
- }
- return regionPath;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/49d99d4e/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/mkdir.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/mkdir.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/mkdir.java
deleted file mode 100644
index 1db7b05..0000000
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/mkdir.java
+++ /dev/null
@@ -1,253 +0,0 @@
-package com.gemstone.gemfire.internal.tools.gfsh.app.commands;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import com.gemstone.gemfire.cache.Cache;
-import com.gemstone.gemfire.cache.DataPolicy;
-import com.gemstone.gemfire.cache.ExpirationAction;
-import com.gemstone.gemfire.cache.ExpirationAttributes;
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.cache.Scope;
-import com.gemstone.gemfire.internal.tools.gfsh.app.CommandExecutable;
-import com.gemstone.gemfire.internal.tools.gfsh.app.Gfsh;
-import com.gemstone.gemfire.internal.tools.gfsh.app.aggregator.functions.util.RegionCreateFunction;
-import com.gemstone.gemfire.internal.tools.gfsh.app.command.task.RegionCreateTask;
-import com.gemstone.gemfire.internal.tools.gfsh.app.command.task.data.MemberInfo;
-import com.gemstone.gemfire.internal.tools.gfsh.app.command.task.data.RegionAttributeInfo;
-import com.gemstone.gemfire.internal.tools.gfsh.command.CommandResults;
-import com.gemstone.gemfire.internal.tools.gfsh.util.RegionUtil;
-
-public class mkdir implements CommandExecutable
-{
- private Gfsh gfsh;
-
- public mkdir(Gfsh gfsh)
- {
- this.gfsh = gfsh;
- }
-
- public void help()
- {
- gfsh.println("mkdir [-g|-s] | [-?] <region path> [<attributes>]");
- gfsh.println(" [data-policy=");
- gfsh.println(" Create a region remotely and/or locally (local only by default). The region path can be");
- gfsh.println(" absolute or relative.");
- gfsh.println(" -g Create a region for all peers.");
- gfsh.println(" -s Create a region for the connected server only.");
- gfsh.println(" Region attributes:");
- gfsh.println(" " + RegionAttributeInfo.CONCURRENCY_LEVEL + "=<integer [16]>");
- gfsh.println(" " + RegionAttributeInfo.DATA_POLICY + "=" + getDataPolicyValues() + " [" + DataPolicy.NORMAL.toString().toLowerCase().replace('_', '-') + "]");
- gfsh.println(" " + RegionAttributeInfo.EARLY_ACK + "=" + getTrueFalseValues() + " [false]");
- gfsh.println(" " + RegionAttributeInfo.ENABLE_ASYNC_CONFLATION + "=" + getTrueFalseValues() + " [false]");
- gfsh.println(" " + RegionAttributeInfo.ENABLE_GATEWAY + "=" + getTrueFalseValues() + " [false]");
- gfsh.println(" " + RegionAttributeInfo.ENABLE_SUBSCRIPTION_CONFLATION + "=" + getTrueFalseValues() + " [false]");
- gfsh.println(" " + RegionAttributeInfo.HUB_ID + "=<string>");
- gfsh.println(" " + RegionAttributeInfo.IGNORE_JTA + "=" + getTrueFalseValues() + " [false]");
- gfsh.println(" " + RegionAttributeInfo.INDEX_UPDATE_TYPE + "=" + getIndexUpdateTypeValues() + " [asynchronous]");
- gfsh.println(" " + RegionAttributeInfo.INITIAL_CAPACITY + "=<integer> [16]");
- gfsh.println(" " + RegionAttributeInfo.IS_LOCK_GRANTOR + "=" + getTrueFalseValues() + " [false]");
- gfsh.println(" " + RegionAttributeInfo.LOAD_FACTOR + "=<float> [0.75]");
- gfsh.println(" " + RegionAttributeInfo.MULTICAST_ENABLED + "=" + getTrueFalseValues() + " [false]");
- gfsh.println(" " + RegionAttributeInfo.PUBLISHER + "=" + getTrueFalseValues() + " [false]");
- gfsh.println(" " + RegionAttributeInfo.STATISTICS_ENABLED + "=" + getTrueFalseValues() + " [false]");
- gfsh.println(" " + RegionAttributeInfo.SCOPE + "=" + getScopeValues() + " [" + Scope.DISTRIBUTED_NO_ACK.toString().toLowerCase().replace('_', '-') + "]");
- gfsh.println(" Partition attributes:");
- gfsh.println(" " + RegionAttributeInfo.LOCAL_MAX_MEMORY + "=<MB [90% of local heap]>");
- gfsh.println(" " + RegionAttributeInfo.REDUNDANT_COPIES + "=<integer [0]>");
- gfsh.println(" " + RegionAttributeInfo.TOTAL_MAX_MEMORY + "=<MB>");
- gfsh.println(" " + RegionAttributeInfo.TOTAL_NUM_BUCKETS + "=<integer [113]>");
- gfsh.println(" Region attribute elements:");
- gfsh.println(" " + RegionAttributeInfo.ENTRY_IDLE_TIME_ACTION + "=" + getExpirationValues() + " [" + ExpirationAttributes.DEFAULT.getAction().toString().toLowerCase().replace('_', '-') + "]>");
- gfsh.println(" " + RegionAttributeInfo.ENTRY_IDLE_TIME_TIMEOUT + "=<integer [" + ExpirationAttributes.DEFAULT.getTimeout() + "]>");
- gfsh.println(" " + RegionAttributeInfo.ENTRY_TIME_TO_LIVE_ACTION + "=" + getExpirationValues() + " [" + ExpirationAttributes.DEFAULT.getAction().toString().toLowerCase().replace('_', '-') + "]>");
- gfsh.println(" " + RegionAttributeInfo.ENTRY_TIME_TO_LIVE_TIMEOUT + "=<integer [" + ExpirationAttributes.DEFAULT.getTimeout() + "]>");
- gfsh.println(" " + RegionAttributeInfo.REGION_IDLE_TIME_ACTION + "=" + getExpirationValues() + " [" + ExpirationAttributes.DEFAULT.getAction().toString().toLowerCase().replace('_', '-') + "]>");
- gfsh.println(" " + RegionAttributeInfo.REGION_IDLE_TIME_TIMEOUT + "=<integer [" + ExpirationAttributes.DEFAULT.getTimeout() + "]>");
- gfsh.println(" " + RegionAttributeInfo.REGION_TIME_TO_LIVE_ACTION + "=" + getExpirationValues() + " [" + ExpirationAttributes.DEFAULT.getAction().toString().toLowerCase().replace('_', '-') + "]>");
- gfsh.println(" " + RegionAttributeInfo.REGION_TIME_TO_LIVE_TIMEOUT + "=<integer [" + ExpirationAttributes.DEFAULT.getTimeout() + "]>");
- gfsh.println();
- }
-
- public void execute(String command) throws Exception
- {
- if (command.startsWith("mkdir -?")) {
- help();
- } else if (command.startsWith("mkdir -g")) {
- mkdir_g(command);
- } else if (command.startsWith("mkdir -s")) {
- mkdir_s(command);
- } else {
- mkdir_local(command);
- }
- }
-
- private RegionAttributeInfo parseAttributes(String attributes) throws Exception
- {
- if (attributes == null) {
- return null;
- }
- attributes = attributes.trim();
- if (attributes.length() == 0) {
- return null;
- }
- RegionAttributeInfo attributeInfo = new RegionAttributeInfo();
- String split[] = attributes.split(" ");
- for (int i = 0; i < split.length; i++) {
- String pair[] = split[i].split("=");
- attributeInfo.setAttribute(pair[0], pair[1]);
- }
- return attributeInfo;
- }
-
- private void mkdir_g(String command) throws Exception
- {
- LinkedList list = new LinkedList();
- gfsh.parseCommand(command, list);
- String fullPath;
- String attributes;
- RegionAttributeInfo attributeInfo = null;
- if (list.size() == 2) {
- fullPath = gfsh.getCurrentPath();
- } else {
- String regionPath = (String) list.get(2);
- String currentPath = gfsh.getCurrentPath();
- fullPath = gfsh.getFullPath(regionPath, currentPath);
- attributes = "";
- for (int i = 3; i < list.size(); i++) {
- attributes += list.get(i) + " ";
- }
- attributeInfo = parseAttributes(attributes);
- }
-
- if (fullPath.equals(gfsh.getCurrentPath())) {
- gfsh.println("Error: must define region path: mkdir [-g] <regionPath>");
- } else {
- // create for the entire peers
- List<CommandResults> resultList = (List)gfsh.getAggregator().aggregate(new RegionCreateFunction(new RegionCreateTask(fullPath, attributeInfo)), gfsh.getAggregateRegionPath());
- int i = 1;
- for (CommandResults commandResults : resultList) {
- MemberInfo memberInfo = (MemberInfo)commandResults.getDataObject();
- gfsh.print(i + ". " + memberInfo.getMemberName() + "(" + memberInfo.getMemberId() + ")" + ": ");
- if (commandResults.getCode() == RegionCreateTask.SUCCESS_CREATED) {
- Region region;
- if (gfsh.isLocator()) {
- region = RegionUtil.getRegion(fullPath, Scope.LOCAL, DataPolicy.NORMAL, gfsh.getPool(), false);
- } else {
- region = RegionUtil.getRegion(fullPath, Scope.LOCAL, DataPolicy.NORMAL, gfsh.getEndpoints());
- }
- gfsh.println("region created: " + region.getFullPath());
- } else {
- gfsh.println("error - " + commandResults.getCodeMessage());
- }
- i++;
- }
- }
- }
-
- private void mkdir_s(String command) throws Exception
- {
- LinkedList list = new LinkedList();
- gfsh.parseCommand(command, list);
- String regionPath = "";
- String attributes;
- RegionAttributeInfo attributeInfo = null;
- if (list.size() == 2) {
- regionPath = gfsh.getCurrentPath();
- } else {
- if (!"/".equals(gfsh.getCurrentPath())) {
- regionPath = gfsh.getCurrentPath();
- }
- regionPath = regionPath + "/" + (String) list.get(2);
- attributes = "";
- for (int i = 3; i < list.size(); i++) {
- attributes += list.get(i) + " ";
- }
- attributeInfo = parseAttributes(attributes);
- }
-
- if (regionPath.equals(gfsh.getCurrentPath())) {
- gfsh.println("Error: must define region path: mkdir [-s] <regionPath>");
- } else {
- // create for the server only
- CommandResults commandResults = gfsh.getCommandClient().execute(new RegionCreateTask(regionPath, attributeInfo));
- MemberInfo memberInfo = (MemberInfo)commandResults.getDataObject();
- gfsh.print(memberInfo.getMemberName() + "(" + memberInfo.getMemberId() + ")" + ": ");
- if (commandResults.getCode() == RegionCreateTask.SUCCESS_CREATED) {
- Region region = RegionUtil.getRegion(regionPath, Scope.LOCAL, DataPolicy.NORMAL, null);
- gfsh.println("region created: " + region.getFullPath());
- } else {
- gfsh.println("error - " + commandResults.getCodeMessage());
- }
- }
- }
-
- private void mkdir_local(String command) throws Exception
- {
- int index = command.indexOf(" ");
- if (index == -1) {
- gfsh.println("Current region: " + gfsh.getCurrentPath());
- } else {
- Cache cache = gfsh.getCache();
- Region region;
- String newPath = command.substring(index).trim();
- String fullPath = gfsh.getFullPath(newPath, gfsh.getCurrentPath());
- if (fullPath == null) {
- gfsh.println("Error: region path must be provided. mkdir <regionPath>");
- } else {
- // absolute path
- region = cache.getRegion(fullPath);
- if (region != null) {
- gfsh.println("Region already exists: " + region.getFullPath());
- return;
- }
- if (gfsh.isLocator()) {
- region = RegionUtil.getRegion(fullPath, Scope.LOCAL, DataPolicy.NORMAL, gfsh.getPool(), false);
- } else {
- region = RegionUtil.getRegion(fullPath, Scope.LOCAL, DataPolicy.NORMAL, gfsh.getEndpoints());
- }
- gfsh.println("Region created: " + region.getFullPath());
- }
- }
- }
-
-
- private static String getDataPolicyValues()
- {
- String all = DataPolicy.EMPTY + "|" +
- DataPolicy.NORMAL + "|" +
- DataPolicy.PARTITION + "|" +
- DataPolicy.PERSISTENT_REPLICATE + "|" +
- DataPolicy.PRELOADED + "|" +
- DataPolicy.REPLICATE;
- return all.toLowerCase().replace('_', '-');
- }
-
- private static String getScopeValues()
- {
- String all = Scope.DISTRIBUTED_NO_ACK + "|" +
- Scope.DISTRIBUTED_ACK + "|" +
- Scope.GLOBAL + "|" +
- Scope.LOCAL;
- return all.toLowerCase().replace('_', '-');
- }
-
- private static String getTrueFalseValues()
- {
- return "true|false";
- }
-
- private static String getIndexUpdateTypeValues()
- {
- return "asynchronous|synchronous";
- }
-
- private static String getExpirationValues()
- {
- String all = ExpirationAction.DESTROY + "|" +
- ExpirationAction.INVALIDATE + "|" +
- ExpirationAction.LOCAL_DESTROY + "|" +
- ExpirationAction.LOCAL_INVALIDATE;
- return all.toLowerCase().replace('_', '-');
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/49d99d4e/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/next.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/next.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/next.java
deleted file mode 100644
index 5fb23ab..0000000
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/next.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package com.gemstone.gemfire.internal.tools.gfsh.app.commands;
-
-import java.util.List;
-
-import com.gemstone.gemfire.internal.tools.gfsh.app.CommandExecutable;
-import com.gemstone.gemfire.internal.tools.gfsh.app.Gfsh;
-import com.gemstone.gemfire.internal.tools.gfsh.app.Nextable;
-
-public class next implements CommandExecutable
-{
- private Gfsh gfsh;
- private String command;
- private Object userData;
-
- public next(Gfsh gfsh)
- {
- this.gfsh = gfsh;
- }
-
- public void help()
- {
- gfsh.println("next | n [-?]");
- gfsh.println(" Fetch the next set of query results.");
- gfsh.println();
- }
-
- public void execute(String command) throws Exception
- {
- if (command.startsWith("next -?")) {
- help();
- } else {
- next();
- }
- }
-
- public void setCommand(String command, Object userData)
- {
- this.command = command;
- this.userData = userData;
- }
-
- public void setCommand(String command)
- {
- setCommand(command, null);
- }
-
- public String getCommand()
- {
- return command;
- }
-
- public Object getUserData()
- {
- return userData;
- }
-
- public List next() throws Exception
- {
- Nextable nextable = (Nextable)gfsh.getCommand(command);
- return nextable.next(userData);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/49d99d4e/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/optional/look.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/optional/look.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/optional/look.java
deleted file mode 100644
index 7d1ec35..0000000
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/optional/look.java
+++ /dev/null
@@ -1,166 +0,0 @@
-package com.gemstone.gemfire.internal.tools.gfsh.app.commands.optional;
-
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import com.gemstone.gemfire.internal.tools.gfsh.app.CommandExecutable;
-import com.gemstone.gemfire.internal.tools.gfsh.app.Gfsh;
-import com.gemstone.gemfire.internal.tools.gfsh.app.Nextable;
-import com.gemstone.gemfire.internal.tools.gfsh.app.cache.index.IndexInfo;
-import com.gemstone.gemfire.internal.tools.gfsh.app.cache.index.LookupService;
-import com.gemstone.gemfire.internal.tools.gfsh.app.commands.next;
-import com.gemstone.gemfire.internal.tools.gfsh.app.util.PrintUtil;
-
-public class look implements CommandExecutable, Nextable
-{
- private static LookupService lookupService;
-
- private Gfsh gfsh;
-
- public look(Gfsh gfsh)
- {
- this.gfsh = gfsh;
- gfsh.addEnumCommand("look");
- }
-
- public void help()
- {
- gfsh.println("look [-i] | [-?] | [<query predicate>]");
- gfsh.println(" Execute the compound key lookup service. This command requires");
- gfsh.println(" the server to configure the gfcommand addon component,");
- gfsh.println(" com.gemstone.gemfire.internal.tools.gfsh.cache.index.IndexBuilder");
- gfsh.println(" <query predicate>: field=val1 and field2='val1'");
- gfsh.println(" and field3=to_date('<date>', '<format>'");
- gfsh.println(" Primitives: no quotes");
- gfsh.println(" String: 'string value' (single quotes)");
- gfsh.println(" java.util.Date: to_date('<date>', '<format'>, i.e.,");
- gfsh.println(" to_date('10/18/2008', 'MM/dd/yyyy'");
- gfsh.println(" -k Retrieve keys only. Values are not returned.");
- gfsh.println(" -i Print compound key index information.");
- gfsh.println();
- }
-
- public void execute(String command) throws Exception
- {
- if (command.startsWith("look -?")) {
- help();
- } else if (command.startsWith("look -i")) {
- look_i(command);
- } else if (command.startsWith("look")) {
- look(command);
- }
- }
-
- private LookupService getLookupService()
- {
- if (lookupService == null) {
- lookupService = new LookupService(gfsh.getCommandClient());
- }
- return lookupService;
- }
-
- private void look(String command) throws Exception
- {
- if (gfsh.getCurrentRegion() == null) {
- gfsh.println("Error: Region undefined. Use 'cd' to change region first before executing this command.");
- return;
- }
-
- LinkedList list = new LinkedList();
- gfsh.parseCommand(command, list);
-
- boolean keysOnly = false;
- String input = null;
- for (int i = 1; i < list.size(); i++) {
- String token = (String)list.get(i);
- if (token.equals("-k")) {
- keysOnly = true;
- } else {
- input = token;
- }
- }
-
- if (input == null) {
- gfsh.println("Error: look requires query predicate");
- } else {
- Object key = null;
- if (keysOnly) {
- key = gfsh.getQueryKey(list, 2);
- } else {
- key = gfsh.getQueryKey(list, 1);
- }
-
- long startTime = 0;
- long stopTime = 0;
- ArrayList keyList = new ArrayList();
- LookupService lookup = getLookupService();
- if (keysOnly) {
- startTime = System.currentTimeMillis();
- Set set = lookup.keySet(gfsh.getCurrentPath(), key);
- stopTime = System.currentTimeMillis();
- if (gfsh.isShowResults()) {
- PrintUtil.printSet(set, gfsh.getFetchSize(), keyList);
- } else {
- gfsh.println("Fetch size: " + gfsh.getFetchSize());
- gfsh.println(" Results: " + set.size() +
- ", Returned: " + set.size() + "/" + set.size());
- }
- } else {
- startTime = System.currentTimeMillis();
- Map map = lookup.entryMap(gfsh.getCurrentPath(), key);
- stopTime = System.currentTimeMillis();
-
- if (gfsh.isShowResults()) {
- PrintUtil.printEntries(map, gfsh.getFetchSize(), keyList);
- } else {
- gfsh.println("Fetch size: " + gfsh.getFetchSize());
- gfsh.println(" Results: " + map.size() +
- ", Returned: " + map.size() + "/" + map.size());
- }
- }
- gfsh.setLsKeyList(keyList);
- if (gfsh.isShowTime()) {
- gfsh.println("elapsed (msec): " + (stopTime - startTime));
- }
- next n = (next)gfsh.getCommand("next");
- n.setCommand(getClass().getSimpleName());
- }
- }
-
- private void look_i(String command) throws Exception
- {
- if (gfsh.getCurrentRegion() == null) {
- gfsh.println("Error: Region undefined. Use 'cd' to change region first before executing this command.");
- return;
- }
-
- // look -i
- LookupService lookup = getLookupService();
- IndexInfo[] indexInfoArray = lookup.getIndexInfoArray(gfsh.getCurrentPath());
- if (indexInfoArray == null) {
- System.out.println("No index info available for " + gfsh.getCurrentPath());
- } else {
- for (int i = 0; i < indexInfoArray.length; i++) {
- IndexInfo indexInfo = indexInfoArray[i];
- System.out.println((i + 1) + ". IndexInfo:");
- System.out.println(" indexListSize = " + indexInfo.indexListSize);
- System.out.println(" indexMapSize = " + indexInfo.indexMapSize);
- System.out.println(" minSetSize = " + indexInfo.minSetSize);
- System.out.println(" maxSetSize = " + indexInfo.maxSetSize);
- System.out.println(" minSetQueryKey = " + indexInfo.minSetQueryKey);
- System.out.println(" maxSetQueryKey = " + indexInfo.maxSetQueryKey);
- System.out.println();
- }
- }
- }
-
- // Next not supported
- public List next(Object userData) throws Exception
- {
- gfsh.println("The command next is not supported for look.");
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/49d99d4e/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/optional/perf.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/optional/perf.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/optional/perf.java
deleted file mode 100644
index 7e43361..0000000
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/optional/perf.java
+++ /dev/null
@@ -1,150 +0,0 @@
-package com.gemstone.gemfire.internal.tools.gfsh.app.commands.optional;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.internal.tools.gfsh.app.CommandExecutable;
-import com.gemstone.gemfire.internal.tools.gfsh.app.Gfsh;
-
-public class perf implements CommandExecutable
-{
- private static final String HIDDEN_REGION_NAME_PREFIX = "_"; // 1 underscore
-
- private Gfsh gfsh;
-// Findbugs - unused fields
-// private Region localRegion;
-// private Iterator localRegionIterator;
-// private List localKeyList;
-// private int lastRowPrinted = 0;
-
- public perf(Gfsh gfsh)
- {
- this.gfsh = gfsh;
- }
-
- public void help()
- {
- gfsh.println("perf [-threads <count>]");
- gfsh.println(" [-payload <size>]");
- gfsh.println(" [-type put|get|delete|putall|getall|deleteall <batch size>]");
- gfsh.println(" [-input random|sequence");
- gfsh.println(" [-size <total entry size or count>");
- gfsh.println(" [-key int|long|string|<class name>");
- gfsh.println(" [-loop <count>]");
- gfsh.println(" [-interval <count>]");
- gfsh.println(" [<region path>]");
- gfsh.println(" [-?]");
- gfsh.println(" Measure throughput rates and \"put\" latency.");
- gfsh.println(" -threads <count> The number of threads to concurrently put data into");
- gfsh.println(" the fabric. Default: 1");
- gfsh.println(" -payload <size> The payliod size in bytes. Perf puts byte arrays of the");
- gfsh.println(" specified size into the fabric. Default: 100 bytes.");
- gfsh.println(" -type put|get|delete|putall|getall|deleteall <batch size>");
- gfsh.println(" The operation type. <batch size> is for '*all' only. Default: put");
- gfsh.println(" -input The input type. 'random' selects keys randomly from the range of");
- gfsh.println(" <total entry size>. 'sequnce' sequntial keys from 1 to <total entry size");
- gfsh.println(" and repeats until the loop count is exhausted. Default: random");
- gfsh.println(" -size The total size of the cache. This option is only for '-type put'");
- gfsh.println(" and '-type putall'.");
- gfsh.println(" -key int|long|string|<class name> The key type. The keys of the type");
- gfsh.println(" int or long are numerical values incremented in the loop. The keys");
- gfsh.println(" of type string are String values formed by the prefix and the numerical");
- gfsh.println(" values that are incremented in the loop. The default prefix is \"key\".");
- gfsh.println(" The keys of type <class name> are supplied by the class that implements");
- gfsh.println(" the com.gemstone.gemfire.addons.gfsh.data.PerfKey interface. The class");
- gfsh.println(" implements getKey(int keyNum) which returns a Serializable or preferrably");
- gfsh.println(" DataSerializable object.");
- gfsh.println(" -loop <count> The number of iterations per thread. Each thread invokes");
- gfsh.println(" put() or putAll() per iteration. Default: 10000");
- gfsh.println(" -inteval <count> The display interval. Each thread prints the average");
- gfsh.println(" throughput and latency after each interval interation count. Default: 1000");
- gfsh.println(" <region path> The region to put data into. Default: current region.");
- gfsh.println(" Default: perf -threads 1 -payload 100 -type put -input random -size 10000 -loop 10000 -interval 1000 ./");
-
- gfsh.println();
- }
-
- public void execute(String command) throws Exception
- {
- if (command.startsWith("perf -?")) {
- help();
- return;
- }
-
- perf(command);
- }
-
- private void perf(String command) throws Exception
- {
- LinkedList<String> list = new LinkedList();
- gfsh.parseCommand(command, list);
-
- int threadCount = 1;
- int payloadSize = 100;
- int putAllSize = 1;
- int loopCount = 10000;
- int interval = 1000;
- String regionPath = null;
-
- int listSize = list.size();
- for (int i = 1; i < listSize; i++) {
- String arg = list.get(i);
- if (arg.equals("-threads")) {
- i++;
- if (i >= listSize) {
- gfsh.println("Error: '-threads' requires <count>");
- return;
- }
- threadCount = Integer.parseInt(list.get(i));
- } else if (arg.equals("-payload")) {
- i++;
- if (i >= listSize) {
- gfsh.println("Error: '-payload' requires <size>");
- return;
- }
- payloadSize = Integer.parseInt(list.get(i));
- } else if (arg.equals("-putall")) {
- i++;
- if (i >= listSize) {
- gfsh.println("Error: '-putall' requires <batch size>");
- return;
- }
- putAllSize = Integer.parseInt(list.get(i));
- } else if (arg.equals("-loop")) {
- i++;
- if (i >= listSize) {
- gfsh.println("Error: '-loop' requires <count>");
- return;
- }
- loopCount = Integer.parseInt(list.get(i));
- } else if (arg.equals("-interval")) {
- i++;
- if (i >= listSize) {
- gfsh.println("Error: '-interval' requires <count>");
- return;
- }
- interval = Integer.parseInt(list.get(i));
- } else {
- regionPath = list.get(i);
- }
- }
- if (regionPath == null) {
- regionPath = gfsh.getCurrentPath();
- }
-
- benchmark(threadCount, payloadSize, putAllSize, loopCount, interval, regionPath);
- }
-
- private void benchmark(int threadCount,
- int payloadSize,
- int putAllSize,
- int loopCount,
- int interval,
- String regionPath)
- {
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/49d99d4e/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/pr.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/pr.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/pr.java
deleted file mode 100644
index d2d8551..0000000
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/pr.java
+++ /dev/null
@@ -1,209 +0,0 @@
-package com.gemstone.gemfire.internal.tools.gfsh.app.commands;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import com.gemstone.gemfire.cache.query.SelectResults;
-import com.gemstone.gemfire.internal.tools.gfsh.aggregator.AggregateResults;
-import com.gemstone.gemfire.internal.tools.gfsh.app.CommandExecutable;
-import com.gemstone.gemfire.internal.tools.gfsh.app.Gfsh;
-import com.gemstone.gemfire.internal.tools.gfsh.app.aggregator.Aggregator;
-import com.gemstone.gemfire.internal.tools.gfsh.app.cache.data.Mappable;
-import com.gemstone.gemfire.internal.tools.gfsh.app.command.task.QueryResults;
-import com.gemstone.gemfire.internal.tools.gfsh.app.command.task.QueryTask;
-import com.gemstone.gemfire.internal.tools.gfsh.app.command.task.data.MemberInfo;
-import com.gemstone.gemfire.internal.tools.gfsh.app.function.GfshData;
-import com.gemstone.gemfire.internal.tools.gfsh.app.function.GfshFunction;
-import com.gemstone.gemfire.internal.tools.gfsh.app.util.PrintUtil;
-import com.gemstone.gemfire.internal.tools.gfsh.command.CommandResults;
-
-public class pr implements CommandExecutable
-{
- private Gfsh gfsh;
-
- public pr(Gfsh gfsh)
- {
- this.gfsh = gfsh;
- }
-
- public void help()
- {
- gfsh.println("pr -b | -?");
-// gfsh.println("pr [-k <member number> | -m <member id>] select <tuples where ...> | -?");
-// gfsh.println(" Execute the specified query in the optionally specified member.");
-// gfsh.println(" The query is executed on the local dataset of the member");
-// gfsh.println(" if the '-m' or '-k' option is specified.");
-// gfsh.println(" -k <member number> Execute the query on the specified member identified");
-// gfsh.println(" by the member number. The member numbers are the row numbers shown");
-// gfsh.println(" in the member list displayed by executing 'size -m' or 'ls -m'.");
-// gfsh.println(" Note that the query is executed on the local");
-// gfsh.println(" dataset of the member if this options is specified.");
-// gfsh.println(" -m <member id> Execute the query on the specified member identified");
-// gfsh.println(" the member id. The member Ids can be obtained by executing");
-// gfsh.println(" 'size -m' or 'ls -m'. Note that the query is executed on the local");
-// gfsh.println(" data set of the member if this options is specified.");
- gfsh.println(" -b Display partitioned region bucket information");
-
- gfsh.println();
- }
-
- private void usage()
- {
-// gfsh.println("pr [-k <member number> | -m <member id>] select <tuples where ...> | -?");
- gfsh.println("pr -b | -?");
- }
-
- public void execute(String command) throws Exception
- {
- LinkedList<String> list = new LinkedList();
- gfsh.parseCommand(command, list);
- if (list.size() < 2) {
- usage();
- return;
- }
- if (list.contains("-?")) {
- help();
- } else if (command.contains("-b")) {
- pr_b(command);
- } else {
- String queryString = command;
-
- pr(command, true);
- }
- }
-
- private void pr_b(String command) throws Exception
- {
- String regionPath = gfsh.getCurrentPath();
-
- Aggregator aggregator = gfsh.getAggregator();
- long startTime = System.currentTimeMillis();
- List<AggregateResults> results = (List<AggregateResults>) gfsh.getAggregator().aggregate(
- new GfshFunction("pr", regionPath, new Object[] { "-b" }), gfsh.getAggregateRegionPath());
- long stopTime = System.currentTimeMillis();
-
- int primaryBucketCount = 0;
- int redundantBucketCount = 0;
- int totalNumBuckets = 0;
- int i = 0;
- for (AggregateResults aggregateResults : results) {
- GfshData data = (GfshData) aggregateResults.getDataObject();
- totalNumBuckets = (Integer)data.getUserData();
-// if (aggregateResults.getCode() == AggregateResults.CODE_ERROR) {
-// gfsh.println("Error: " + aggregateResults.getCodeMessage());
-// if (gfsh.isDebug() && aggregateResults.getException() != null) {
-// aggregateResults.getException().printStackTrace();
-// }
-// break;
-// }
- Object value = data.getDataObject();
- if (value != null) {
-
-// if (simulate) {
-// columnName = "Simulated Stats";
-// } else {
-// columnName = "Rebalanced Stats";
-// }
- MemberInfo memberInfo = data.getMemberInfo();
- Map map = (Map) value;
-// Map primaryMap = (Map)map.get("Primary");
- List<Mappable> primaryList = (List<Mappable>)map.get("Primary");
- i++;
-// gfsh.println(i + ". " + memberInfo.getMemberName() + " (" + memberInfo.getMemberId() + ")");
- gfsh.println(i + ". Primary Buckets - " + memberInfo.getMemberName() + " (" + memberInfo.getMemberId() + ")");
- PrintUtil.printMappableList(primaryList, "BucketId");
- gfsh.println();
-// Map redundantMap = (Map)map.get("Redundant");
- List<Mappable> redundantList = (List<Mappable>)map.get("Redundant");
- gfsh.println(i + ". Redundant Buckets - " + memberInfo.getMemberName() + " (" + memberInfo.getMemberId() + ")");
- PrintUtil.printMappableList(redundantList, "BucketId");
- gfsh.println();
-
- primaryBucketCount += primaryList.size();
- redundantBucketCount += redundantList.size();
- }
- }
- gfsh.println();
- gfsh.println(" Primary Bucket Count: " + primaryBucketCount);
- gfsh.println(" Redundant Bucket Count: " + redundantBucketCount);
- gfsh.println("total-num-buckets (max): " + totalNumBuckets);
-
- gfsh.println();
-
- if (gfsh.isShowTime()) {
- gfsh.println("elapsed (msec): " + (stopTime - startTime));
- }
- }
-
- private void printMappableList(MemberInfo memberInfo, List<Mappable> list, int row) throws Exception
- {
- String columnName = "Bucket";
- if (list != null) {
- gfsh.println(row + ". " + memberInfo.getMemberName() + " (" + memberInfo.getMemberId() + ")");
- PrintUtil.printMappableList(list);
- gfsh.println();
- }
- }
-
-// private void printMap(MemberInfo memberInfo, Map map, int row) throws Exception
-// {
-// String columnName = "Bucket";
-// Set<Map.Entry> entrySet = map.entrySet();
-// if (map != null && map.size() > 0) {
-// gfsh.println(row + ". " + memberInfo.getMemberName() + " (" + memberInfo.getMemberId() + ")");
-// PrintUtil.printEntries(map, map.size(), null, columnName, "Value", false, gfsh.isShowResults());
-// gfsh.println();
-// }
-// }
-
- public List getRemoteKeys(String regionPath) throws Exception
- {
- List list = pr("select e.key from " + regionPath + ".entries e", true);
- return list;
- }
-
- public List pr(String queryString, boolean nextEnabled) throws Exception
- {
- long startTime = System.currentTimeMillis();
- CommandResults cr = gfsh.getCommandClient().execute(new QueryTask(queryString, gfsh.getFetchSize(), nextEnabled, true));
- long stopTime = System.currentTimeMillis();
- if (cr.getCode() == QueryTask.ERROR_QUERY) {
- gfsh.println(cr.getCodeMessage());
- return null;
- }
- QueryResults results = (QueryResults) cr.getDataObject();
- if (results == null) {
- gfsh.println("No results");
- return null;
- }
-
- List list = null;
- Object obj = results.getResults();
- if (obj instanceof SelectResults) {
- SelectResults sr = (SelectResults) results.getResults();
- list = sr.asList();
- int startRowNum = results.getReturnedSize() - sr.size() + 1;
- if (gfsh.isShowResults()) {
- int rowsPrinted = PrintUtil.printSelectResults(sr, 0, startRowNum, sr.size());
- gfsh.println("Fetch size: " + gfsh.getFetchSize());
- gfsh.println(" Results: " + sr.size()
- + ", Returned: " + results.getReturnedSize() + "/" + results.getActualSize());
- next n = (next)gfsh.getCommand("next");
-
- // route the next command to select, which has the display routine
- n.setCommand("select");
- } else {
- gfsh.println("Fetch size: " + gfsh.getFetchSize());
- gfsh.println(" Results: " + sr.size() +
- ", Returned: " + results.getReturnedSize() + "/" + results.getActualSize());
- }
- } else {
- gfsh.println("Results: " + obj);
- }
- if (gfsh.isShowTime()) {
- gfsh.println("elapsed (msec): " + (stopTime - startTime));
- }
- return list;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/49d99d4e/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/property.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/property.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/property.java
deleted file mode 100644
index 4ad167c..0000000
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/property.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package com.gemstone.gemfire.internal.tools.gfsh.app.commands;
-
-import java.util.ArrayList;
-
-import com.gemstone.gemfire.internal.tools.gfsh.app.CommandExecutable;
-import com.gemstone.gemfire.internal.tools.gfsh.app.Gfsh;
-
-public class property implements CommandExecutable
-{
- private Gfsh gfsh;
-
- public property(Gfsh gfsh)
- {
- this.gfsh = gfsh;
- }
-
- public void help()
- {
- gfsh.println("property [<key>[=<value>]] | [-u <key>] | [?] ");
- gfsh.println(" Sets the property that can be used using ${key},");
- gfsh.println(" which gfsh expands with the matching value.");
- gfsh.println();
- gfsh.println(" -u <key> This option unsets (removes) the property.");
- gfsh.println(" 'property <key>=' (with no value) also removes the");
- gfsh.println(" property (key).");
- gfsh.println();
- }
-
- public void execute(String command) throws Exception
- {
- if (command.startsWith("property -?")) {
- help();
- } else if (command.startsWith("property -u")) {
- property_u(command);
- } else {
- property(command);
- }
- }
-
- private void property_u(String command)
- {
- ArrayList<String> list = new ArrayList();
- gfsh.parseCommand(command, list);
- if (list.size() < 3) {
- return;
- }
-
- String key = list.get(2);
- gfsh.setProperty(key, null);
- }
-
- private void property(String command)
- {
- ArrayList<String> list = new ArrayList();
- gfsh.parseCommand(command, list);
- if (list.size() == 1) {
- // list all properties
- gfsh.printProperties();
- gfsh.println();
- return;
- }
-
- String prop = "";
- for (int i = 1; i < list.size(); i++) {
- prop += list.get(i) + " ";
- }
- prop = prop.trim();
- int index = prop.indexOf("=");
-
- if (index == -1) {
- // show the property value
- String key = list.get(1);
- String value = gfsh.getProperty(key);
- gfsh.println(key + "=" + value);
- } else {
-
- String key = prop.substring(0, index);
- String value = prop.substring(index+1);
-
- gfsh.setProperty(key, value);
- }
-
- gfsh.println();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/49d99d4e/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/put.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/put.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/put.java
deleted file mode 100644
index 22d550b..0000000
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/put.java
+++ /dev/null
@@ -1,490 +0,0 @@
-package com.gemstone.gemfire.internal.tools.gfsh.app.commands;
-
-import java.lang.reflect.Method;
-import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.internal.tools.gfsh.app.CommandExecutable;
-import com.gemstone.gemfire.internal.tools.gfsh.app.Gfsh;
-import com.gemstone.gemfire.internal.tools.gfsh.app.misc.util.ReflectionUtil;
-import com.gemstone.gemfire.internal.tools.gfsh.app.util.ObjectUtil;
-import com.gemstone.gemfire.internal.tools.gfsh.app.util.PrintUtil;
-
-public class put implements CommandExecutable
-{
- private Gfsh gfsh;
-
- public put(Gfsh gfsh)
- {
- this.gfsh = gfsh;
- }
-
- public void help()
- {
- gfsh.println("put [-k] [-v] | [-?] (<key1>,<value1>)(<key2>,<value2>)...");
- gfsh.println("put (<key1>,<value1>)(<key2>,<value2>)...");
- gfsh.println("put -k (<key num1>,<value1>)(<key num2>,<value2>)...");
- gfsh.println("put -v (<key1>,<value num1>)(<key2>,<value num2>)...");
- gfsh.println("put -k -v (<key num1>,<value num1>)(<key num2>,<value num2>)...");
- gfsh.println(" Put entries in both local and remote regions.");
- gfsh.println(" All changes will be reflected in the server(s) also.");
- gfsh.println(" Keys are enumerated when one of the following commands");
- gfsh.println(" is executed: " + gfsh.getEnumCommands());
- gfsh.println();
- gfsh.println(" <key> and <value> support primitive, String, and java.util.Date");
- gfsh.println(" types. These types must be specifed with special tags as follows:");
- gfsh.println(" <decimal>b|B - Byte (e.g., 1b)");
- gfsh.println(" <decimal>c|C - Character (e.g., 1c)");
- gfsh.println(" <decimal>s|S - Short (e.g., 12s)");
- gfsh.println(" <decimal>i|I - Integer (e.g., 15 or 15i)");
- gfsh.println(" <decimal>l|L - Long (e.g., 20l)");
- gfsh.println(" <decimal>f|F - Float (e.g., 15.5 or 15.5f)");
- gfsh.println(" <decimal>d|D - Double (e.g., 20.0d)");
- gfsh.println(" '<string with \\ delimiter>' (e.g., '\\'Wow!\\'!' Hello, world')");
- gfsh.println(" to_date('<date string>', '<simple date format>')");
- gfsh.println(" (e.g., to_date('04/10/2009', 'MM/dd/yyyy')");
- gfsh.println();
- gfsh.println(" If a suffix letter is not specifed then it is read as Integer");
- gfsh.println(" unless the decimal point or the letter 'e' or 'E' is specified,");
- gfsh.println(" in which case, it is read as Double. Note that if the <key> or");
- gfsh.println(" <value> class is used then a suffix letter is *not* required.");
- gfsh.println();
- gfsh.println(" <key> The key class defined by the 'key' command is used");
- gfsh.println(" to construct the key object.");
- gfsh.println(" <value> The value class defined by the 'value' command is used");
- gfsh.println(" to construct the value object.");
- gfsh.println(" The <key> and <value> objects are created using the following");
- gfsh.println(" format:");
- gfsh.println(" <property name1>=<property value1> and ");
- gfsh.println(" <property name2>=<property value2> and ...");
- gfsh.println();
- gfsh.println(" -k Put enumerated keys. If this option is not specified, then");
- gfsh.println(" <key> is expected.");
- gfsh.println(" -v Put enumerated values. If this option is not specified, then");
- gfsh.println(" <value> is expected.");
- gfsh.println();
- gfsh.println(" Examples:");
- gfsh.println(" put (15L, to_date('04/10/2009', 'MM/dd/yyyy')");
- gfsh.println(" put ('GEMSTONE', Price=125.50 and Date=to_date('04/09/2009',\\");
- gfsh.println(" 'MM/dd/yyyy')");
- gfsh.println(" put -k -v (1, 5) - puts the enum key 1 with the enum 5 value");
- gfsh.println();
- }
-
- public void execute(String command) throws Exception
- {
- if (command.startsWith("put -?")) {
- help();
- } else {
- put(command);
- }
- }
-
- private void put(String command) throws Exception
- {
- LinkedList<String> list = new LinkedList();
- gfsh.parseCommand(command, list);
-
- boolean keyEnumerated = false;
- boolean valueEnumerated = false;
-
- String val;
- int keyIndex = 0;
-
- for (int i = 1; i < list.size(); i++) {
- val = list.get(i);
- if (val.equals("-k")) {
- keyEnumerated = true;
- } else if (val.equals("-v")) {
- valueEnumerated = true;
- } else {
- keyIndex = i;
- break;
- }
- }
-
- Region region = gfsh.getCurrentRegion();
- String numbers;
- Object key;
-
- if (region != null) {
- Map map = getEntryMap(list, keyEnumerated, valueEnumerated,
- keyIndex);
- region.putAll(map);
- PrintUtil.printEntries(region, map.keySet(), null);
- } else {
- gfsh.println("Error: Please 'cd' to the required region to perform put.");
- }
- }
-
- /**
- * Returns the index of the enclosed parenthesis, i.e., ')'.
- * @param buffer
- * @param startIndex
- * @return the index of the enclosed parenthesis
- */
- private int getEnclosingParenthesis(StringBuffer buffer, int startIndex)
- {
- int enclosedIndex = -1;
- int parenCount = 0;
- boolean inQuote = false;
- // to_date('04/09/2009', 'MM/dd/yyyy')
- for (int i = startIndex; i < buffer.length(); i++) {
- char c = buffer.charAt(i);
- if (c == '(') {
- if (inQuote == false) {
- parenCount++;
- }
- } else if (c == ')') {
- if (inQuote == false) {
- parenCount--;
- }
- if (parenCount == 0) {
- enclosedIndex = i;
- break;
- }
- } else if (c == '\'') {
- inQuote = !inQuote;
- }
- }
- return enclosedIndex;
- }
-
- private Map getEntryMap(List<String> list, boolean keyEnumerated, boolean valueEnumerated, int startIndex) throws Exception
- {
- String pairs = "";
- for (int i = startIndex; i < list.size(); i++) {
- pairs += list.get(i) + " ";
- }
-
- Map<String, Method> keySetterMap = ReflectionUtil.getAllSettersMap(gfsh.getQueryKeyClass());
- Map<String, Method> valueSetterMap = ReflectionUtil.getAllSettersMap(gfsh.getValueClass());
- Region region = gfsh.getCurrentRegion();
-
- // (x='1,2,3' and y='2',a='hello, world' and b='test')
- HashMap map = new HashMap();
- StringBuffer buffer = new StringBuffer(pairs);
- boolean keySearch = false;
- boolean fieldSearch = false;
- boolean openQuote = false;
- boolean delimiter = false;
- boolean quoted = false;
- boolean openParen = false;
- String fieldString = "";
- String valueString = "";
- String and = "";
-
- Object key = null;
- Object value = null;
- for (int i = 0; i < buffer.length(); i++) {
- char c = buffer.charAt(i);
- if (c == '(') {
- if (openQuote == false) {
-
- String function = null;
- String functionCall = null;
- String functionString = null;
- if (valueString.length() > 0) {
- functionString = valueString;
- } else if (fieldString.length() > 0) {
- functionString = fieldString;
- }
- if (functionString != null) {
-
- // it's a function
-
- // get enclosed parenthesis
- int enclosedIndex = getEnclosingParenthesis(buffer, i);
-
- function = functionString.toLowerCase();
- if (enclosedIndex == -1) {
- throw new ParseException("Malformed function call: " + function, i);
- }
-
- functionCall = function + buffer.substring(i, enclosedIndex+1);
- if (gfsh.isDebug()) {
- gfsh.println("functionCall = |" + functionCall + "|");
- }
- i = enclosedIndex;
- }
- if (functionCall != null) {
- if (valueString.length() > 0) {
- valueString = functionCall;
- } else if (fieldString.length() > 0) {
- fieldString = functionCall;
- }
-
- } else {
- key = null;
- value = null;
- keySearch = true;
- fieldSearch = true;
- fieldString = "";
- valueString = "";
- }
-
- quoted = false;
-
- continue;
- }
-
- } else if (c == '=') {
- if (keySearch && key == null && keyEnumerated == false) {
- if (gfsh.getQueryKeyClass() == null) {
- throw new ClassNotFoundException("Undefined key class. Use the 'key' command to set the class name");
- }
- key = gfsh.getQueryKeyClass().newInstance();
- }
- if (keySearch == false && value == null && valueEnumerated == false) {
- if (gfsh.getValueClass() == null) {
- throw new ClassNotFoundException("Undefined value class. Use the 'value' command to set the class name");
- }
- value = gfsh.getValueClass().newInstance();
- }
- fieldSearch = false;
- continue;
- } else if (c == ')') {
- if (openQuote == false) {
- if (gfsh.isDebug()) {
- gfsh.println("v: field = " + fieldString);
- gfsh.println("v: value = " + valueString);
- gfsh.println();
- }
- if (valueEnumerated) {
- Object k = gfsh.getKeyFromKeyList(Integer.parseInt(fieldString));
- if (k == null) {
- gfsh.println("Error: value not found in the cache for the key number " + fieldString);
- gfsh.println(" run 'key -l' to view the enumerated keys.");
- map.clear();
- break;
- }
- value = region.get(k);
- if (key == null) {
- gfsh.println("Error: value not in the cache - " + fieldString);
- map.clear();
- break;
- }
- if (gfsh.isDebug()) {
- gfsh.println("k = " + k);
- gfsh.println("key = " + key);
- gfsh.println("value = " + value);
- }
- } else {
- if (valueString.length() == 0) {
- // primitive
- value = ObjectUtil.getPrimitive(gfsh, fieldString, quoted);
- } else {
- updateObject(valueSetterMap, value, fieldString, valueString);
- }
- }
-
- map.put(key, value);
-
- fieldSearch = true;
- quoted = false;
- fieldString = "";
- valueString = "";
- key = null;
- and = "";
- continue;
- }
- } else if (c == '\\') {
- // ignore and treat the next character as a character
- delimiter = true;
- continue;
- } else if (c == '\'') {
- if (delimiter) {
- delimiter = false;
- } else {
- if (openQuote) {
- quoted = true;
- }
- openQuote = !openQuote;
- continue;
- }
- } else if (c == ' ') {
- if (openQuote == false) {
- boolean andExpected = false;
- if (keySearch) {
- if (gfsh.isDebug()) {
- gfsh.println("k: field = " + fieldString);
- gfsh.println("k: value = " + valueString);
- gfsh.println();
- }
- if (fieldString.length() > 0) {
- updateObject(keySetterMap, key, fieldString, valueString);
- andExpected = true;
- }
- } else {
- if (gfsh.isDebug()) {
- gfsh.println("v: field = " + fieldString);
- gfsh.println("v: value = " + valueString);
- gfsh.println();
- }
- if (fieldString.length() > 0) {
- updateObject(valueSetterMap, value, fieldString, valueString);
- andExpected = true;
- }
- }
-
- if (andExpected) {
- and = "";
- int index = -1;
- for (int j = i; j < buffer.length(); j++) {
- and += buffer.charAt(j);
- and = and.trim().toLowerCase();
- if (and.equals("and")) {
- index = j;
- break;
- } else if (and.length() > 3) {
- break;
- }
- }
- if (index != -1) {
- i = index;
- }
- }
-
- fieldSearch = true;
- fieldString = "";
- valueString = "";
- and = "";
- quoted = false;
- continue;
- }
- }
-
- if (c == ',') {
-
- // if ',' is not enclosed in quotes...
- if (openQuote == false) {
-
- fieldString = fieldString.trim();
- valueString = valueString.trim();
-
- // end of key
- if (gfsh.isDebug()) {
- gfsh.println("k: field = " + fieldString);
- gfsh.println("k: value = " + valueString);
- gfsh.println();
- }
-
- if (keySearch) {
- if (keyEnumerated) {
- key = gfsh.getKeyFromKeyList(Integer.parseInt(fieldString));
- if (key == null) {
- gfsh.println("Error: value not found in the cache for the key number " + fieldString);
- gfsh.println(" run 'key -l' to view the enumerated keys.");
- map.clear();
- break;
- }
- } else {
- if (valueString.length() == 0) {
- key = ObjectUtil.getPrimitive(gfsh, fieldString, quoted);
- } else {
- updateObject(keySetterMap, key, fieldString, valueString);
- }
- }
- } else {
-
- if (valueEnumerated) {
- Object k = gfsh.getKeyFromKeyList(Integer.parseInt(fieldString));
- value = region.get(k);
- if (value == null) {
- gfsh.println("Error: undefined value num " + fieldString);
- map.clear();
- break;
- }
- } else {
- if (valueString.length() == 0) {
- value = ObjectUtil.getPrimitive(gfsh, fieldString, quoted);
- } else {
-
- updateObject(valueSetterMap, value, fieldString, valueString);
- }
- }
-
- }
-
- fieldSearch = true;
- keySearch = false;
- quoted = false;
- fieldString = "";
- valueString = "";
- and = "";
- continue;
- }
- }
-
- if (fieldSearch) {
- fieldString += c;
- } else if (quoted == false) {
- valueString += c;
- }
- }
-
- return map;
- }
-
- private Object getFunctionValue(String functionCall) throws ParseException
- {
- if (functionCall.startsWith("to_date")) {
- return gfsh.getDate(functionCall);
- }
- return null;
- }
-
- private void updateObject(Map<String, Method> setterMap, Object obj, String field, String value) throws Exception
- {
- String setterMethodName = "set" + field.trim();
- Method setterMethod = setterMap.get(setterMethodName);
- if (setterMethod == null) {
- return;
- }
-
- Class types[] = setterMethod.getParameterTypes();
- Class arg = types[0];
- if (arg == byte.class || arg == Byte.class) {
- setterMethod.invoke(obj, Byte.parseByte(value));
- } else if (arg == char.class || arg == Character.class) {
- setterMethod.invoke(obj, value.charAt(0));
- } else if (arg == short.class || arg == Short.class) {
- setterMethod.invoke(obj, Short.parseShort(value));
- } else if (arg == int.class || arg == Integer.class) {
- setterMethod.invoke(obj, Integer.parseInt(value));
- } else if (arg == long.class || arg == Long.class) {
- setterMethod.invoke(obj, Long.parseLong(value));
- } else if (arg == float.class || arg == Float.class) {
- setterMethod.invoke(obj, Float.parseFloat(value));
- } else if (arg == double.class || arg == Double.class) {
- setterMethod.invoke(obj, Double.parseDouble(value));
- } else if (arg == Date.class) {
- Date date = gfsh.getDate(value);
- if (date == null) {
- gfsh.println(" Unable to parse date.");
- } else {
- setterMethod.invoke(obj, date);
- }
- } else if (arg == String.class) {
- setterMethod.invoke(obj, value);
- } else {
- gfsh.println(" Unsupported type: " + setterMethod.getName() + "(" + arg.getName() + ")");
- return;
- }
- }
-
- public static void main(String[] args) throws Exception
- {
- String command = "put (x=123 and y='2' and z=123, a='hello, world' and b=12)(x='abc' and y='de' and z=456, a='test1' and b=99')";
- ArrayList list = new ArrayList();
- Gfsh gfsh = new Gfsh(new String[0]);
- put p = new put(gfsh);
- p.getEntryMap(list, false, false, 1);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/49d99d4e/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/pwd.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/pwd.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/pwd.java
deleted file mode 100644
index 862aa63..0000000
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/pwd.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.gemstone.gemfire.internal.tools.gfsh.app.commands;
-
-import com.gemstone.gemfire.internal.tools.gfsh.app.CommandExecutable;
-import com.gemstone.gemfire.internal.tools.gfsh.app.Gfsh;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-
-public class pwd implements CommandExecutable
-{
- private Gfsh gfsh;
-
- public pwd(Gfsh gfsh)
- {
- this.gfsh = gfsh;
- }
-
- public void help()
- {
- gfsh.println("pwd [-?]");
- gfsh.println(" Display the current region path.");
- gfsh.println();
- }
-
- public void execute(String command) throws Exception
- {
- if (command.startsWith("pwd -?")) {
- help();
- } else {
- pwd();
- }
- }
-
- @SuppressFBWarnings(value="NM_METHOD_CONSTRUCTOR_CONFUSION",justification="This is method and not constructor")
- private void pwd()
- {
- gfsh.println(gfsh.getCurrentPath());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/49d99d4e/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/rebalance.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/rebalance.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/rebalance.java
deleted file mode 100644
index 1afca99..0000000
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/rebalance.java
+++ /dev/null
@@ -1,186 +0,0 @@
-package com.gemstone.gemfire.internal.tools.gfsh.app.commands;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import com.gemstone.gemfire.internal.tools.gfsh.aggregator.AggregateResults;
-import com.gemstone.gemfire.internal.tools.gfsh.app.CommandExecutable;
-import com.gemstone.gemfire.internal.tools.gfsh.app.Gfsh;
-import com.gemstone.gemfire.internal.tools.gfsh.app.aggregator.Aggregator;
-import com.gemstone.gemfire.internal.tools.gfsh.app.command.task.data.MemberInfo;
-import com.gemstone.gemfire.internal.tools.gfsh.app.function.GfshData;
-import com.gemstone.gemfire.internal.tools.gfsh.app.function.GfshFunction;
-import com.gemstone.gemfire.internal.tools.gfsh.app.util.PrintUtil;
-
-public class rebalance implements CommandExecutable
-{
- private Gfsh gfsh;
-
- public rebalance(Gfsh gfsh)
- {
- this.gfsh = gfsh;
- }
-
- public void help()
- {
-// gfsh.println("rebalance -k <member number> | -m <member id> [-s|-r] | [-?]");
- gfsh.println("rebalance -m <member id> [-s|-r] [-t <timeout in msec>] | [-?]");
- gfsh.println(" Rebalance partition regions held by the specified member.");
- gfsh.println(" By default, gfsh immediately returns after the rebalance command");
- gfsh.println(" execution. To determine the completion of rebalancing, excute");
- gfsh.println(" 'size -m' or 'pr -b'. To wait for the rebalancing to complete,");
- gfsh.println(" supply the '-t' option with the timeout interval in msec.");
-// gfsh.println(" -k <member number> Rebalance the specified member identified");
-// gfsh.println(" by the member number. The member numbers are the row numbers shown");
-// gfsh.println(" in the member list displayed by executing 'size -m' or 'ls -m'.");
- gfsh.println(" -m <member id> Execute the rebalance command on the specified member.");
- gfsh.println(" The member Ids can be obtained by executing 'size -m' or 'ls -m'.");
- gfsh.println(" -s Simulate rebalancing. Actual rebalancing is NOT performed.");
- gfsh.println(" -r Rebalance. Actual rebalancing is performed.");
- gfsh.println(" -t <timeout in msec> Timeout rebalbancing after the specified");
- gfsh.println(" time interval. Rebalancing will continue but gfsh will");
- gfsh.println(" timeout upon reaching the specified time interval. This option");
- gfsh.println(" must be used with the '-r' option. It has no effect with other");
- gfsh.println(" options.");
- }
-
- public void execute(String command) throws Exception
- {
- if (command.startsWith("rebalance -?")) {
- help();
- } else {
- rebalance(command);
- }
- }
-
- private Object getKeyFromInput(List list, int index) throws Exception
- {
- String input = (String) list.get(index);
- Object key = null;
- if (input.startsWith("'")) {
- int lastIndex = -1;
- if (input.endsWith("'") == false) {
- lastIndex = input.length();
- } else {
- lastIndex = input.lastIndexOf("'");
- }
- if (lastIndex <= 1) {
- gfsh.println("Error: Invalid key. Empty string not allowed.");
- return null;
- }
- key = input.substring(1, lastIndex); // lastIndex exclusive
- } else {
- key = gfsh.getQueryKey(list, index);
- }
- return key;
- }
-
- private void rebalance(String command) throws Exception
- {
- LinkedList<String> list = new LinkedList();
- gfsh.parseCommand(command, list);
- if (list.size() < 2) {
- gfsh.println("Error: 'rebalance' requries a key number or member id");
- return;
- }
-
- String regionPath = gfsh.getCurrentPath();
- boolean simulate = true;
- Object key = null;
- String memberId = null;
- long timeout = 0;
- for (int i = 1; i < list.size(); i++) {
- String token = list.get(i);
- if (token.equals("-k")) {
- if (i + 1 >= list.size()) {
- gfsh.println("Error: '-k' requires key number");
- return;
- }
- int keyNum = Integer.parseInt((String) list.get(++i));
- key = gfsh.getKeyFromKeyList(keyNum);
-
- } else if (token.equals("-m")) {
- if (i + 1 >= list.size()) {
- gfsh.println("Error: '-m' requires member Id");
- return;
- }
- memberId = (String) list.get(++i);
- } else if (token.equals("-s")) {
- simulate = true;
- } else if (token.equals("-r")) {
- simulate = false;
- } else if (token.equals("-t")) {
- if (i + 1 >= list.size()) {
- gfsh.println("Error: '-t' requires a timeout value");
- return;
- }
- timeout = Integer.parseInt(list.get(++i));
- }
- }
-
- if (key == null && memberId == null) {
- gfsh.println("Error: member Id not defined.");
- return;
- }
-
-
- // Execute rebalance
- executeRebalance(regionPath, memberId, simulate, timeout);
- }
-
- private void executeRebalance(String regionPath, String memberId, boolean simulate, long timeout) throws Exception
- {
- String currentPath = gfsh.getCurrentPath();
- String fullPath = gfsh.getFullPath(regionPath, currentPath);
-
- Aggregator aggregator = gfsh.getAggregator();
- long startTime = System.currentTimeMillis();
- List<AggregateResults> results = (List<AggregateResults>) gfsh.getAggregator().aggregate(
- new GfshFunction("rebalance", regionPath, new Object[] { memberId, simulate, timeout }), gfsh.getAggregateRegionPath());
- long stopTime = System.currentTimeMillis();
-
- int i = 0;
- for (AggregateResults aggregateResults : results) {
- GfshData data = (GfshData) aggregateResults.getDataObject();
-// if (aggregateResults.getCode() == AggregateResults.CODE_ERROR) {
-// gfsh.println("Error: " + aggregateResults.getCodeMessage());
-// if (gfsh.isDebug() && aggregateResults.getException() != null) {
-// aggregateResults.getException().printStackTrace();
-// }
-// break;
-// }
- MemberInfo memberInfo = data.getMemberInfo();
- Object value = data.getDataObject();
- if (value != null) {
- String columnName;
- if (simulate) {
- columnName = "Simulated Stats";
- } else {
- columnName = "Rebalanced Stats";
- }
-
- Map map = (Map) value;
- Set<Map.Entry> entrySet = map.entrySet();
- if (map != null && map.size() > 0) {
- i++;
- gfsh.println(i + ". " + memberInfo.getMemberName() + " (" + memberInfo.getMemberId() + ")");
- PrintUtil.printEntries(map, map.size(), null, columnName, "Value", false, gfsh.isShowResults());
- gfsh.println();
- }
- } else if (memberId.equals(memberInfo.getMemberId())) {
- if (simulate == false) {
- gfsh.println("Reblancing has been completed or is being performed by " + memberInfo.getMemberName() + " (" + memberInfo.getMemberId() + ")");
- gfsh.println("Use 'size -m' or 'pr -b' to view rebalance completion.");
- gfsh.println();
- }
- }
- }
- gfsh.println();
- if (gfsh.isShowTime()) {
- gfsh.println("elapsed (msec): " + (stopTime - startTime));
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/49d99d4e/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/refresh.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/refresh.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/refresh.java
deleted file mode 100644
index 9185b4b..0000000
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tools/gfsh/app/commands/refresh.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package com.gemstone.gemfire.internal.tools.gfsh.app.commands;
-
-import com.gemstone.gemfire.cache.DataPolicy;
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.cache.Scope;
-import com.gemstone.gemfire.internal.tools.gfsh.app.CommandExecutable;
-import com.gemstone.gemfire.internal.tools.gfsh.app.Gfsh;
-import com.gemstone.gemfire.internal.tools.gfsh.app.command.task.RegionPathTask;
-import com.gemstone.gemfire.internal.tools.gfsh.command.CommandResults;
-import com.gemstone.gemfire.internal.tools.gfsh.util.RegionUtil;
-
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-
-public class refresh implements CommandExecutable
-{
- private Gfsh gfsh;
-
- public refresh(Gfsh gfsh)
- {
- this.gfsh = gfsh;
- }
-
- public void help()
- {
- gfsh.println("refresh [-?]");
- gfsh.println(" Refresh the entire local cache. It fetches region");
- gfsh.println(" information from all servers and updates local regions.");
- gfsh.println(" It creates new regions found in the servers in the local VM.");
- gfsh.println();
- }
-
- public void execute(String command) throws Exception
- {
- if (command.startsWith("refresh -?")) {
- help();
- } else {
- refresh();
- }
- }
-
- @SuppressFBWarnings(value="NM_METHOD_CONSTRUCTOR_CONFUSION",justification="This is method and not constructor")
- private void refresh()
- {
- if (gfsh.isConnected() == false) {
- gfsh.println("Error: gfsh is not connected to a server. Use the 'connect' command to connect first. aborting refresh");
- }
-
- CommandResults results = gfsh.getCommandClient().execute(new RegionPathTask(false, true));
- String[] regionPaths = (String[]) results.getDataObject();
- if (regionPaths != null) {
- Region region;
- for (int i = 0; i < regionPaths.length; i++) {
- if (gfsh.isLocator()) {
- region = RegionUtil.getRegion(regionPaths[i], Scope.LOCAL, DataPolicy.NORMAL, gfsh.getPool(), false);
- } else {
- region = RegionUtil.getRegion(regionPaths[i], Scope.LOCAL, DataPolicy.NORMAL, gfsh.getEndpoints());
- }
-// if (region != null) {
-// region.setUserAttribute(regionInfo);
-// }
- }
- gfsh.println("refreshed");
- }
-
- gfsh.refreshAggregatorRegion();
- }
-}