geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jensde...@apache.org
Subject [33/50] [abbrv] incubator-geode git commit: Merge branch 'develop' into feature/GEODE-17
Date Thu, 25 Feb 2016 20:27:21 GMT
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5c01d5f4/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/PDXCommands.java
----------------------------------------------------------------------
diff --cc geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/PDXCommands.java
index 0000000,820518b..234ce9c
mode 000000,100644..100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/PDXCommands.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/PDXCommands.java
@@@ -1,0 -1,286 +1,291 @@@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one or more
+  * contributor license agreements.  See the NOTICE file distributed with
+  * this work for additional information regarding copyright ownership.
+  * The ASF licenses this file to You under the Apache License, Version 2.0
+  * (the "License"); you may not use this file except in compliance with
+  * the License.  You may obtain a copy of the License at
+  *
+  *      http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+ package com.gemstone.gemfire.management.internal.cli.commands;
+ 
+ import java.io.ByteArrayOutputStream;
+ import java.io.File;
+ import java.io.PrintStream;
+ import java.io.PrintWriter;
+ import java.io.StringWriter;
+ import java.util.Arrays;
+ import java.util.Collection;
+ 
+ import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
+ import org.springframework.shell.core.annotation.CliCommand;
+ import org.springframework.shell.core.annotation.CliOption;
+ 
+ import com.gemstone.gemfire.internal.cache.CacheConfig;
+ import com.gemstone.gemfire.internal.cache.DiskStoreImpl;
+ import com.gemstone.gemfire.internal.cache.xmlcache.CacheCreation;
+ import com.gemstone.gemfire.internal.cache.xmlcache.CacheXml;
+ import com.gemstone.gemfire.internal.cache.xmlcache.CacheXmlGenerator;
+ import com.gemstone.gemfire.management.cli.CliMetaData;
+ import com.gemstone.gemfire.management.cli.Result;
+ import com.gemstone.gemfire.management.internal.cli.CliUtil;
+ import com.gemstone.gemfire.management.internal.cli.i18n.CliStrings;
+ import com.gemstone.gemfire.management.internal.cli.result.InfoResultData;
+ import com.gemstone.gemfire.management.internal.cli.result.ResultBuilder;
+ import com.gemstone.gemfire.management.internal.configuration.SharedConfigurationWriter;
+ import com.gemstone.gemfire.management.internal.configuration.domain.XmlEntity;
++import com.gemstone.gemfire.management.internal.security.Resource;
++import com.gemstone.gemfire.management.internal.security.ResourceConstants;
++import com.gemstone.gemfire.management.internal.security.ResourceOperation;
+ import com.gemstone.gemfire.pdx.ReflectionBasedAutoSerializer;
+ import com.gemstone.gemfire.pdx.internal.EnumInfo;
+ import com.gemstone.gemfire.pdx.internal.PdxType;
+ 
+ public class PDXCommands extends AbstractCommandsSupport{
+ 
+ 
+   @CliCommand (value = CliStrings.CONFIGURE_PDX, help = CliStrings.CONFIGURE_PDX__HELP)
+   @CliMetaData (relatedTopic = CliStrings.TOPIC_GEMFIRE_REGION, writesToSharedConfiguration = true)
++  @ResourceOperation( resource=Resource.DISTRIBUTED_SYSTEM, operation=ResourceConstants.CONFIGURE_PDX)
+   public Result configurePDX( 
+       @CliOption (key = CliStrings.CONFIGURE_PDX__READ__SERIALIZED,
+       unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
+       help = CliStrings.CONFIGURE_PDX__READ__SERIALIZED__HELP) 
+       Boolean readSerialized,
+ 
+       @CliOption (key = CliStrings.CONFIGURE_PDX__IGNORE__UNREAD_FIELDS,
+       unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
+       help = CliStrings.CONFIGURE_PDX__IGNORE__UNREAD_FIELDS__HELP) 
+       Boolean ignoreUnreadFields,
+ 
+       @CliOption (key = CliStrings.CONFIGURE_PDX__DISKSTORE,
+       unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
+       specifiedDefaultValue = "",
+       help = CliStrings.CONFIGURE_PDX__DISKSTORE__HELP)
+       String diskStore, 
+ 
+       @CliMetaData (valueSeparator = ",")
+       @CliOption (key = CliStrings.CONFIGURE_PDX__AUTO__SERIALIZER__CLASSES,
+       unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
+       specifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
+       help = CliStrings.CONFIGURE_PDX__AUTO__SERIALIZER__CLASSES__HELP)
+       String[] patterns,
+ 
+ 
+       @CliMetaData (valueSeparator = ",")
+       @CliOption (key = CliStrings.CONFIGURE_PDX__PORTABLE__AUTO__SERIALIZER__CLASSES,
+       unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
+       specifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
+       help = CliStrings.CONFIGURE_PDX__PORTABLE__AUTO__SERIALIZER__CLASSES__HELP)
+       String[] portablePatterns){
+     Result result = null;
+ 
+     try {
+       InfoResultData ird  = ResultBuilder.createInfoResultData();
+       CacheCreation cache = new CacheCreation(true);
+ 
+       if ((portablePatterns != null && portablePatterns.length > 0) && (patterns != null && patterns.length > 0)) {
+         return ResultBuilder.createUserErrorResult(CliStrings.CONFIGURE_PDX__ERROR__MESSAGE);
+       }
+       if (CliUtil.getAllNormalMembers(CliUtil.getCacheIfExists()).isEmpty()) {
+         ird.addLine(CliStrings.CONFIGURE_PDX__NORMAL__MEMBERS__WARNING);
+       }
+       //Set persistent and the disk-store
+       if (diskStore != null) {
+         cache.setPdxPersistent(true);
+         ird.addLine(CliStrings.CONFIGURE_PDX__PERSISTENT + " = " + cache.getPdxPersistent());
+         if (!diskStore.equals("")) {
+           cache.setPdxDiskStore(diskStore);
+           ird.addLine(CliStrings.CONFIGURE_PDX__DISKSTORE + " = " + cache.getPdxDiskStore());
+         } else {
+           ird.addLine(CliStrings.CONFIGURE_PDX__DISKSTORE + " = " + "DEFAULT");
+         }
+       } else {
+         cache.setPdxPersistent(CacheConfig.DEFAULT_PDX_PERSISTENT);
+         ird.addLine(CliStrings.CONFIGURE_PDX__PERSISTENT + " = " + cache.getPdxPersistent());
+       }
+ 
+       //Set read-serialized
+       if (readSerialized != null) {
+         cache.setPdxReadSerialized(readSerialized);
+       } else {
+         cache.setPdxReadSerialized(CacheConfig.DEFAULT_PDX_READ_SERIALIZED);
+       }
+       ird.addLine(CliStrings.CONFIGURE_PDX__READ__SERIALIZED + " = " + cache.getPdxReadSerialized());
+ 
+ 
+       //Set ingoreUnreadFields
+       if (ignoreUnreadFields != null) {
+         cache.setPdxIgnoreUnreadFields(ignoreUnreadFields);
+       } else {
+         cache.setPdxIgnoreUnreadFields(CacheConfig.DEFAULT_PDX_IGNORE_UNREAD_FIELDS);
+       }
+       ird.addLine(CliStrings.CONFIGURE_PDX__IGNORE__UNREAD_FIELDS + " = " + cache.getPdxIgnoreUnreadFields());
+ 
+ 
+       if (portablePatterns != null) {
+         ReflectionBasedAutoSerializer autoSerializer =  new ReflectionBasedAutoSerializer(portablePatterns);
+         cache.setPdxSerializer(autoSerializer);
+         ird.addLine("PDX Serializer " + cache.getPdxSerializer().getClass().getName());
+         ird.addLine("Portable classes " + Arrays.toString(portablePatterns));
+       } 
+ 
+       if (patterns!=null) {
+         ReflectionBasedAutoSerializer nonPortableAutoSerializer =  new ReflectionBasedAutoSerializer(true, patterns);
+         cache.setPdxSerializer(nonPortableAutoSerializer);
+         ird.addLine("PDX Serializer : " + cache.getPdxSerializer().getClass().getName());
+         ird.addLine("Non portable classes :" + Arrays.toString(patterns));
+       }
+ 
+       final StringWriter stringWriter = new StringWriter();
+       final PrintWriter printWriter = new PrintWriter(stringWriter);
+       CacheXmlGenerator.generate(cache, printWriter, true, false, false);
+       printWriter.close();
+       String xmlDefinition = stringWriter.toString();
+       // TODO jbarrett - shouldn't this use the same loadXmlDefinition that other constructors use?
+       XmlEntity xmlEntity = XmlEntity.builder().withType(CacheXml.PDX).withConfig(xmlDefinition).build();
+ 
+ 
+       SharedConfigurationWriter scWriter = new SharedConfigurationWriter();
+       boolean commandPersisted = scWriter.addXmlEntity(xmlEntity, null);
+ 
+       result = ResultBuilder.buildResult(ird);
+       result.setCommandPersisted(commandPersisted);
+     } catch (Exception e) {
+       return ResultBuilder.createGemFireErrorResult(e.getMessage());
+     }
+ 
+     return result;
+   }
+ 
+   @CliAvailabilityIndicator({CliStrings.CONFIGURE_PDX})
+   public boolean isRegionCommandAvailable() {
+     if (!CliUtil.isGfshVM()) {
+       return true;
+     }
+     return (getGfsh() != null && getGfsh().isConnectedAndReady());
+   }
+ 
+   @CliCommand (value = CliStrings.PDX_RENAME, help = CliStrings.PDX_RENAME__HELP)
+   @CliMetaData(shellOnly=true, relatedTopic={CliStrings.TOPIC_GEMFIRE_DISKSTORE})
++  @ResourceOperation( resource=Resource.DISTRIBUTED_SYSTEM, operation=ResourceConstants.RENAME_PDX)
+   public Result pdxRename( 
+       @CliOption (key = CliStrings.PDX_RENAME_OLD,
+       mandatory=true,
+       help = CliStrings.PDX_RENAME_OLD__HELP) 
+       String oldClassName,
+ 
+       @CliOption (key = CliStrings.PDX_RENAME_NEW,
+       mandatory=true,
+       help = CliStrings.PDX_RENAME_NEW__HELP) 
+       String newClassName,
+ 
+       @CliOption (key = CliStrings.PDX_DISKSTORE,
+       mandatory=true,
+       help = CliStrings.PDX_DISKSTORE__HELP)
+       String diskStore, 
+ 
+       @CliOption (key = CliStrings.PDX_DISKDIR,
+       mandatory=true,
+       help = CliStrings.PDX_DISKDIR__HELP)
+       @CliMetaData (valueSeparator = ",")
+       String[] diskDirs){
+     
+     try {
+       final File[] dirs = new File[diskDirs.length];
+       for (int i = 0; i < diskDirs.length; i++) {
+         dirs[i] = new File((diskDirs[i]));
+       }
+       
+       Collection<Object> results = DiskStoreImpl.pdxRename(diskStore, dirs, oldClassName, newClassName);
+       
+       if(results.isEmpty()) {
+         return ResultBuilder.createGemFireErrorResult(CliStrings.format(CliStrings.PDX_RENAME__EMPTY));
+       }
+       
+       ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+       PrintStream printStream = new PrintStream(outputStream);
+       for(Object p : results) {
+         if(p instanceof PdxType) {
+           ((PdxType)p).toStream(printStream, false);
+         } else {
+           ((EnumInfo)p).toStream(printStream);
+         }
+       }
+       String resultString = CliStrings.format(CliStrings.PDX_RENAME__SUCCESS, outputStream.toString());
+       return ResultBuilder.createInfoResult(resultString.toString());
+ 
+     } catch (Exception e) {
+       return ResultBuilder.createGemFireErrorResult(CliStrings.format(CliStrings.PDX_RENAME__ERROR, e.getMessage()));
+     }
+     
+   }
+   
+   // The pdx delete-field command has been disabled until it has native client support.
+ //  @CliCommand (value = CliStrings.PDX_DELETE_FIELD, help = CliStrings.PDX_DELETE_FIELD__HELP)
+ //  @CliMetaData(shellOnly=true, relatedTopic={CliStrings.TOPIC_GEMFIRE_DISKSTORE})
+ //  public Result pdxDeleteField( 
+ //      @CliOption (key = CliStrings.PDX_CLASS,
+ //      mandatory=true,
+ //      help = CliStrings.PDX_CLASS__HELP) 
+ //      String className,
+ //
+ //      @CliOption (key = CliStrings.PDX_FIELD,
+ //      mandatory=true,
+ //      help = CliStrings.PDX_FIELD__HELP) 
+ //      String fieldName,
+ //      
+ //      @CliOption (key = CliStrings.PDX_DISKSTORE,
+ //      mandatory=true,
+ //      help = CliStrings.PDX_DISKSTORE__HELP)
+ //      String diskStore, 
+ //
+ //      @CliOption (key = CliStrings.PDX_DISKDIR,
+ //      mandatory=true,
+ //      help = CliStrings.PDX_DISKDIR__HELP)
+ //      @CliMetaData (valueSeparator = ",")
+ //      String[] diskDirs){
+ //    
+ //    try {
+ //      final File[] dirs = new File[diskDirs.length];
+ //      for (int i = 0; i < diskDirs.length; i++) {
+ //        dirs[i] = new File((diskDirs[i]));
+ //      }
+ //      
+ //      Collection<PdxType> results = DiskStoreImpl.pdxDeleteField(diskStore, dirs, className, fieldName);
+ //      
+ //      if(results.isEmpty()) {
+ //        return ResultBuilder.createGemFireErrorResult(CliStrings.format(CliStrings.PDX_DELETE__EMPTY));
+ //      }
+ //      
+ //      ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ //      PrintStream printStream = new PrintStream(outputStream);
+ //      for(PdxType p : results) {
+ //        p.toStream(printStream, false);
+ //      }
+ //      String resultString = CliStrings.format(CliStrings.PDX_DELETE_FIELD__SUCCESS, outputStream.toString());
+ //      return ResultBuilder.createInfoResult(resultString);
+ //
+ //    } catch (Exception e) {
+ //      return ResultBuilder.createGemFireErrorResult(CliStrings.format(CliStrings.PDX_DELETE_FIELD__ERROR, e.getMessage()));
+ //    }
+ //
+ //  }
+ //  
+ //  @CliAvailabilityIndicator({CliStrings.PDX_DELETE_FIELD})
+ //  public boolean pdxDeleteFieldCommandsAvailable() {
+ //    return true;
+ //  }
+   
+   @CliAvailabilityIndicator({CliStrings.PDX_RENAME})
+   public boolean pdxRenameCommandsAvailable() {
+     return true;
+   }
+ }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5c01d5f4/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/QueueCommands.java
----------------------------------------------------------------------
diff --cc geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/QueueCommands.java
index 0000000,f594c39..52d230e
mode 000000,100644..100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/QueueCommands.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/QueueCommands.java
@@@ -1,0 -1,281 +1,286 @@@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one or more
+  * contributor license agreements.  See the NOTICE file distributed with
+  * this work for additional information regarding copyright ownership.
+  * The ASF licenses this file to You under the Apache License, Version 2.0
+  * (the "License"); you may not use this file except in compliance with
+  * the License.  You may obtain a copy of the License at
+  *
+  *      http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+ package com.gemstone.gemfire.management.internal.cli.commands;
+ 
+ import java.util.List;
+ import java.util.Map;
+ import java.util.Properties;
+ import java.util.Set;
+ 
+ import org.springframework.shell.core.CommandMarker;
+ import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
+ import org.springframework.shell.core.annotation.CliCommand;
+ import org.springframework.shell.core.annotation.CliOption;
+ 
+ import com.gemstone.gemfire.SystemFailure;
+ import com.gemstone.gemfire.cache.execute.ResultCollector;
+ import com.gemstone.gemfire.distributed.DistributedMember;
+ import com.gemstone.gemfire.management.cli.CliMetaData;
+ import com.gemstone.gemfire.management.cli.ConverterHint;
+ import com.gemstone.gemfire.management.cli.Result;
+ import com.gemstone.gemfire.management.cli.Result.Status;
+ import com.gemstone.gemfire.management.internal.cli.CliUtil;
+ import com.gemstone.gemfire.management.internal.cli.domain.AsyncEventQueueDetails;
+ import com.gemstone.gemfire.management.internal.cli.functions.CliFunctionResult;
+ import com.gemstone.gemfire.management.internal.cli.functions.CreateAsyncEventQueueFunction;
+ import com.gemstone.gemfire.management.internal.cli.functions.ListAsyncEventQueuesFunction;
+ import com.gemstone.gemfire.management.internal.cli.i18n.CliStrings;
+ import com.gemstone.gemfire.management.internal.cli.result.CommandResultException;
+ import com.gemstone.gemfire.management.internal.cli.result.ResultBuilder;
+ import com.gemstone.gemfire.management.internal.cli.result.TabularResultData;
+ import com.gemstone.gemfire.management.internal.cli.shell.Gfsh;
+ import com.gemstone.gemfire.management.internal.configuration.SharedConfigurationWriter;
+ import com.gemstone.gemfire.management.internal.configuration.domain.XmlEntity;
++import com.gemstone.gemfire.management.internal.security.Resource;
++import com.gemstone.gemfire.management.internal.security.ResourceConstants;
++import com.gemstone.gemfire.management.internal.security.ResourceOperation;
+ 
+ /**
+  * The QueueCommands class encapsulates all GemFire Queue commands in Gfsh.
+  * </p>
+  * @author David Hoots
+  * 
+  * @since 8.0
+  */
+ public class QueueCommands implements CommandMarker {
+   private Gfsh getGfsh() {
+     return Gfsh.getCurrentInstance();
+   }
+ 
+   @CliCommand(value = CliStrings.CREATE_ASYNC_EVENT_QUEUE, help = CliStrings.CREATE_ASYNC_EVENT_QUEUE__HELP)
+   @CliMetaData(writesToSharedConfiguration = true)
++  @ResourceOperation( resource=Resource.DISTRIBUTED_SYSTEM, operation=ResourceConstants.CREATE_AEQ)
+   public Result createAsyncEventQueue(
+       @CliOption(key = CliStrings.CREATE_ASYNC_EVENT_QUEUE__ID, 
+                  mandatory = true,
+                  help = CliStrings.CREATE_ASYNC_EVENT_QUEUE__ID__HELP)
+       String id,
+       @CliOption(key = CliStrings.CREATE_ASYNC_EVENT_QUEUE__GROUP, 
+                  unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, 
+                  optionContext = ConverterHint.MEMBERGROUP,
+                  help = CliStrings.CREATE_ASYNC_EVENT_QUEUE__GROUP__HELP)
+       String[] groups,
+       @CliOption(key = CliStrings.CREATE_ASYNC_EVENT_QUEUE__PARALLEL, 
+                  unspecifiedDefaultValue = "false",
+                  specifiedDefaultValue = "true",
+                  help = CliStrings.CREATE_ASYNC_EVENT_QUEUE__PARALLEL__HELP) 
+       Boolean parallel,
+       @CliOption(key = CliStrings.CREATE_ASYNC_EVENT_QUEUE__ENABLEBATCHCONFLATION,
+                  unspecifiedDefaultValue = "false",
+                  specifiedDefaultValue = "true",
+                  help = CliStrings.CREATE_ASYNC_EVENT_QUEUE__ENABLEBATCHCONFLATION__HELP) 
+       Boolean enableBatchConflation,
+       @CliOption(key = CliStrings.CREATE_ASYNC_EVENT_QUEUE__BATCH_SIZE, 
+                  unspecifiedDefaultValue = "100", 
+                  help = CliStrings.CREATE_ASYNC_EVENT_QUEUE__BATCH_SIZE__HELP)
+       int batchSize,
+       @CliOption(key = CliStrings.CREATE_ASYNC_EVENT_QUEUE__BATCHTIMEINTERVAL,
+                  unspecifiedDefaultValue = "1000", 
+                  help = CliStrings.CREATE_ASYNC_EVENT_QUEUE__BATCHTIMEINTERVAL__HELP) 
+       int batchTimeInterval,
+       @CliOption(key = CliStrings.CREATE_ASYNC_EVENT_QUEUE__PERSISTENT, 
+                  unspecifiedDefaultValue = "false",
+                  specifiedDefaultValue = "true",
+                  help = CliStrings.CREATE_ASYNC_EVENT_QUEUE__PERSISTENT__HELP)
+       boolean persistent,
+       @CliOption(key = CliStrings.CREATE_ASYNC_EVENT_QUEUE__DISK_STORE, 
+                  unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, 
+                  help = CliStrings.CREATE_ASYNC_EVENT_QUEUE__DISK_STORE__HELP)
+       String diskStore,
+       @CliOption(key = CliStrings.CREATE_ASYNC_EVENT_QUEUE__DISKSYNCHRONOUS,
+                  unspecifiedDefaultValue = "true",
+                  specifiedDefaultValue = "true",
+                  help = CliStrings.CREATE_ASYNC_EVENT_QUEUE__DISKSYNCHRONOUS__HELP) 
+       Boolean diskSynchronous,
+       @CliOption(key = CliStrings.CREATE_ASYNC_EVENT_QUEUE__MAXIMUM_QUEUE_MEMORY,
+                  unspecifiedDefaultValue = "100", 
+                  help = CliStrings.CREATE_ASYNC_EVENT_QUEUE__MAXIMUM_QUEUE_MEMORY__HELP)
+       int maxQueueMemory,
+       @CliOption(key = CliStrings.CREATE_ASYNC_EVENT_QUEUE__DISPATCHERTHREADS,
+                  unspecifiedDefaultValue = "1",
+                  help = CliStrings.CREATE_ASYNC_EVENT_QUEUE__DISPATCHERTHREADS__HELP) 
+       Integer dispatcherThreads,
+       @CliOption(key = CliStrings.CREATE_ASYNC_EVENT_QUEUE__ORDERPOLICY,
+                  unspecifiedDefaultValue = "KEY",
+                  help = CliStrings.CREATE_ASYNC_EVENT_QUEUE__ORDERPOLICY__HELP) 
+       String orderPolicy,
+       @CliOption(key = CliStrings.CREATE_ASYNC_EVENT_QUEUE__GATEWAYEVENTFILTER, 
+                  help = CliStrings.CREATE_ASYNC_EVENT_QUEUE__GATEWAYEVENTFILTER__HELP)
+       @CliMetaData (valueSeparator = ",") 
+       String[] gatewayEventFilters,
+       @CliOption(key = CliStrings.CREATE_ASYNC_EVENT_QUEUE__SUBSTITUTION_FILTER, 
+                  help = CliStrings.CREATE_ASYNC_EVENT_QUEUE__SUBSTITUTION_FILTER__HELP)
+       String gatewaySubstitutionListener,
+       @CliOption(key = CliStrings.CREATE_ASYNC_EVENT_QUEUE__LISTENER,
+                  mandatory = true,
+                  help = CliStrings.CREATE_ASYNC_EVENT_QUEUE__LISTENER__HELP)
+       String listener,
+       @CliOption(key = CliStrings.CREATE_ASYNC_EVENT_QUEUE__LISTENER_PARAM_AND_VALUE, 
+                  help = CliStrings.CREATE_ASYNC_EVENT_QUEUE__LISTENER_PARAM_AND_VALUE__HELP,
+                  optionContext=ConverterHint.STRING_DISABLER)
+       @CliMetaData (valueSeparator = ",")
+       String[] listenerParamsAndValues) {
+ 
+     Properties listenerProperties = new Properties();
+ 
+     try {
+       if (listenerParamsAndValues != null) {
+         for (int i = 0; i < listenerParamsAndValues.length; i++) {
+           final int hashPosition = listenerParamsAndValues[i].indexOf('#');
+           if (hashPosition == -1) {
+             listenerProperties.put(listenerParamsAndValues[i], "");
+           } else {
+             listenerProperties.put(listenerParamsAndValues[i].substring(0, hashPosition), listenerParamsAndValues[i]
+                 .substring(hashPosition + 1));
+           }
+         }
+       }
+ 
+       TabularResultData tabularData = ResultBuilder.createTabularResultData();
+       boolean accumulatedData = false;
+ 
+       Set<DistributedMember> targetMembers;
+       try {
+         targetMembers = CliUtil.findAllMatchingMembers(groups, null);
+       } catch (CommandResultException crex) {
+         return crex.getResult();
+       }
+ 
+       ResultCollector<?, ?> rc = CliUtil.executeFunction(new CreateAsyncEventQueueFunction(), new Object[] { id, parallel, enableBatchConflation, batchSize,batchTimeInterval,
+           persistent, diskStore, diskSynchronous, maxQueueMemory, dispatcherThreads, orderPolicy, gatewayEventFilters, gatewaySubstitutionListener, listener, listenerProperties }, targetMembers);
+       List<CliFunctionResult> results = CliFunctionResult.cleanResults((List<?>) rc.getResult());
+ 
+       XmlEntity xmlEntity = null;
+       for (CliFunctionResult result : results) {
+         if (result.getThrowable() != null) {
+           tabularData.accumulate("Member", result.getMemberIdOrName());
+           tabularData.accumulate("Result", "ERROR: " + result.getThrowable().getClass().getName() + ": "
+               + result.getThrowable().getMessage());
+           accumulatedData = true;
+           tabularData.setStatus(Status.ERROR);
+         } else if (result.isSuccessful()) {
+           tabularData.accumulate("Member", result.getMemberIdOrName());
+           tabularData.accumulate("Result", result.getMessage());
+           accumulatedData = true;
+           
+           if (xmlEntity == null) {
+             xmlEntity = result.getXmlEntity();
+           }
+         }
+       }
+ 
+       if (!accumulatedData) {
+         return ResultBuilder.createInfoResult("Unable to create async event queue(s).");
+       }
+       
+       Result result = ResultBuilder.buildResult(tabularData);
+       if (xmlEntity != null) {
+         result.setCommandPersisted((new SharedConfigurationWriter()).addXmlEntity(xmlEntity, groups));
+       }
+       return result;
+     } catch (VirtualMachineError e) {
+       SystemFailure.initiateFailure(e);
+       throw e;
+     } catch (Throwable th) {
+       SystemFailure.checkFailure();
+       return ResultBuilder.createGemFireErrorResult(CliStrings.format(
+           CliStrings.CREATE_ASYNC_EVENT_QUEUE__ERROR_WHILE_CREATING_REASON_0, new Object[] { th.getMessage() }));
+     }
+   }
+ 
+   @CliCommand(value = CliStrings.LIST_ASYNC_EVENT_QUEUES, help = CliStrings.LIST_ASYNC_EVENT_QUEUES__HELP)
++  @ResourceOperation( resource=Resource.DISTRIBUTED_SYSTEM, operation=ResourceConstants.LIST_DS)
+   public Result listAsyncEventQueues() {
+     try {
+       TabularResultData tabularData = ResultBuilder.createTabularResultData();
+       boolean accumulatedData = false;
+ 
+       Set<DistributedMember> targetMembers;
+       try {
+         targetMembers = CliUtil.findAllMatchingMembers((String) null, (String) null);
+       } catch (CommandResultException crex) {
+         return crex.getResult();
+       }
+ 
+       ResultCollector<?, ?> rc = CliUtil.executeFunction(new ListAsyncEventQueuesFunction(), new Object[] {}, targetMembers);
+       List<CliFunctionResult> results = CliFunctionResult.cleanResults((List<?>) rc.getResult());
+ 
+       for (CliFunctionResult result : results) {
+         if (result.getThrowable() != null) {
+           tabularData.accumulate("Member", result.getMemberIdOrName());
+           tabularData.accumulate("Result", "ERROR: " + result.getThrowable().getClass().getName() + ": "
+               + result.getThrowable().getMessage());
+           accumulatedData = true;
+           tabularData.setStatus(Status.ERROR);
+         } else {
+           AsyncEventQueueDetails[] details = (AsyncEventQueueDetails[]) result.getSerializables();
+           for (int i = 0; i < details.length; i++) {
+             tabularData.accumulate("Member", result.getMemberIdOrName());
+             tabularData.accumulate("ID", details[i].getId());
+             tabularData.accumulate("Batch Size", details[i].getBatchSize());
+             tabularData.accumulate("Persistent", details[i].isPersistent());
+             tabularData.accumulate("Disk Store", details[i].getDiskStoreName());
+             tabularData.accumulate("Max Memory", details[i].getMaxQueueMemory());
+ 
+             Properties listenerProperties = details[i].getListenerProperties();
+             if (listenerProperties == null || listenerProperties.size() == 0) {
+               tabularData.accumulate("Listener", details[i].getListener());
+             } else {
+               StringBuilder propsStringBuilder = new StringBuilder();
+               propsStringBuilder.append('(');
+               boolean firstProperty = true;
+               for (Map.Entry<Object, Object> property : listenerProperties.entrySet()) {
+                 if (!firstProperty) {
+                   propsStringBuilder.append(',');
+                 } else {
+                   firstProperty = false;
+                 }
+                 propsStringBuilder.append(property.getKey()).append('=').append(property.getValue());
+               }
+               propsStringBuilder.append(')');
+               
+               tabularData.accumulate("Listener", details[i].getListener() + propsStringBuilder.toString());
+             }
+             accumulatedData = true;
+           }
+         }
+       }
+ 
+       if (!accumulatedData) {
+         return ResultBuilder.createInfoResult(CliStrings.LIST_ASYNC_EVENT_QUEUES__NO_QUEUES_FOUND_MESSAGE);
+       }
+ 
+       return ResultBuilder.buildResult(tabularData);
+     } catch (VirtualMachineError e) {
+       SystemFailure.initiateFailure(e);
+       throw e;
+     } catch (Throwable th) {
+       SystemFailure.checkFailure();
+       return ResultBuilder.createGemFireErrorResult(CliStrings.format(
+           CliStrings.LIST_ASYNC_EVENT_QUEUES__ERROR_WHILE_LISTING_REASON_0, new Object[] { th.getMessage() }));
+     }
+   }
+ 
+   @CliAvailabilityIndicator({ CliStrings.CREATE_ASYNC_EVENT_QUEUE, CliStrings.LIST_ASYNC_EVENT_QUEUES })
+   public boolean queueCommandsAvailable() {
+     boolean isAvailable = true;
+     if (CliUtil.isGfshVM()) {
+       isAvailable = getGfsh() != null && getGfsh().isConnectedAndReady();
+     }
+     return isAvailable;
+   }
+ }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5c01d5f4/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/RegionCommands.java
----------------------------------------------------------------------
diff --cc geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/RegionCommands.java
index 0000000,1c972a5..aace536
mode 000000,100644..100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/RegionCommands.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/RegionCommands.java
@@@ -1,0 -1,493 +1,498 @@@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one or more
+  * contributor license agreements.  See the NOTICE file distributed with
+  * this work for additional information regarding copyright ownership.
+  * The ASF licenses this file to You under the Apache License, Version 2.0
+  * (the "License"); you may not use this file except in compliance with
+  * the License.  You may obtain a copy of the License at
+  *
+  *      http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+ package com.gemstone.gemfire.management.internal.cli.commands;
+ 
+ import java.util.ArrayList;
+ import java.util.Iterator;
+ import java.util.LinkedHashSet;
+ import java.util.List;
+ import java.util.Map;
+ import java.util.Set;
+ import java.util.TreeSet;
+ 
+ import org.springframework.shell.core.CommandMarker;
+ import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
+ import org.springframework.shell.core.annotation.CliCommand;
+ import org.springframework.shell.core.annotation.CliOption;
+ 
+ import com.gemstone.gemfire.cache.Cache;
+ import com.gemstone.gemfire.cache.CacheFactory;
+ import com.gemstone.gemfire.cache.Region;
+ import com.gemstone.gemfire.cache.execute.FunctionInvocationTargetException;
+ import com.gemstone.gemfire.cache.execute.ResultCollector;
+ import com.gemstone.gemfire.distributed.DistributedMember;
+ import com.gemstone.gemfire.management.cli.CliMetaData;
+ import com.gemstone.gemfire.management.cli.ConverterHint;
+ import com.gemstone.gemfire.management.cli.Result;
+ import com.gemstone.gemfire.management.internal.cli.CliUtil;
+ import com.gemstone.gemfire.management.internal.cli.LogWrapper;
+ import com.gemstone.gemfire.management.internal.cli.domain.FixedPartitionAttributesInfo;
+ import com.gemstone.gemfire.management.internal.cli.domain.RegionDescription;
+ import com.gemstone.gemfire.management.internal.cli.domain.RegionDescriptionPerMember;
+ import com.gemstone.gemfire.management.internal.cli.domain.RegionInformation;
+ import com.gemstone.gemfire.management.internal.cli.functions.GetRegionDescriptionFunction;
+ import com.gemstone.gemfire.management.internal.cli.functions.GetRegionsFunction;
+ import com.gemstone.gemfire.management.internal.cli.i18n.CliStrings;
+ import com.gemstone.gemfire.management.internal.cli.result.CommandResultException;
+ import com.gemstone.gemfire.management.internal.cli.result.CompositeResultData;
+ import com.gemstone.gemfire.management.internal.cli.result.CompositeResultData.SectionResultData;
+ import com.gemstone.gemfire.management.internal.cli.result.ResultBuilder;
+ import com.gemstone.gemfire.management.internal.cli.result.TabularResultData;
+ import com.gemstone.gemfire.management.internal.cli.shell.Gfsh;
+ import com.gemstone.gemfire.management.internal.cli.util.RegionAttributesNames;
++import com.gemstone.gemfire.management.internal.security.Resource;
++import com.gemstone.gemfire.management.internal.security.ResourceConstants;
++import com.gemstone.gemfire.management.internal.security.ResourceOperation;
+ 
+ /***
+  * Class containing implementation of commands based on region:
+  * <ul>
+  * <li>list region
+  * <li>describe region
+  * </ul>
+  * 
+  * @author Sourabh Bansod
+  * @since 7.0
+  */
+ public class RegionCommands implements CommandMarker {
+   private Gfsh getGfsh() {
+     return Gfsh.getCurrentInstance();
+   }
+ 
+   private static final GetRegionsFunction getRegionsFunction = new GetRegionsFunction();
+   private static final GetRegionDescriptionFunction getRegionDescription = new GetRegionDescriptionFunction();
+ 
+   @CliCommand(value = { CliStrings.LIST_REGION }, help = CliStrings.LIST_REGION__HELP)
+   @CliMetaData(shellOnly = false, relatedTopic = CliStrings.TOPIC_GEMFIRE_REGION)
++  @ResourceOperation( resource=Resource.DISTRIBUTED_SYSTEM, operation=ResourceConstants.LIST_DS)
+   public Result listRegion(
+       @CliOption(key = { CliStrings.LIST_REGION__GROUP },
+       optionContext = ConverterHint.MEMBERGROUP,
+       help = CliStrings.LIST_REGION__GROUP__HELP)
+       String group,
+       @CliOption(key = { CliStrings.LIST_REGION__MEMBER },
+       optionContext = ConverterHint.MEMBERIDNAME,
+       help = CliStrings.LIST_REGION__MEMBER__HELP)
+       String memberNameOrId) {
+     
+     
+     Result result = null;
+     try {
+       Set<RegionInformation> regionInfoSet = new LinkedHashSet<RegionInformation>();
+       ResultCollector<?, ?> rc = null;
+ 
+       Set<DistributedMember> targetMembers;
+       try {
+         targetMembers = CliUtil.findAllMatchingMembers(group, memberNameOrId);
+       } catch (CommandResultException crex) {
+         return crex.getResult();
+       }
+ 
+       TabularResultData resultData = ResultBuilder.createTabularResultData();
+       rc = CliUtil.executeFunction(getRegionsFunction, null, targetMembers);
+ 
+       ArrayList<?> resultList = (ArrayList<?>) rc.getResult();
+ 
+       if (resultList != null) {
+         Iterator<?> iters = resultList.iterator();
+ 
+         while (iters.hasNext()) {
+           Object resultObj = iters.next();
+ 
+           if (resultObj != null) {
+             if (resultObj instanceof Object[]) {
+               Object[] resultObjectArray = (Object[]) resultObj;
+               for (Object regionInfo : resultObjectArray) {
+                 if (regionInfo instanceof RegionInformation) {
+                   regionInfoSet.add((RegionInformation) regionInfo);
+                 }
+               }
+             }
+           }
+         }
+ 
+         Set<String> regionNames = new TreeSet<String>();
+ 
+         for (RegionInformation regionInfo : regionInfoSet) {
+           regionNames.add(regionInfo.getName());
+           Set<String> subRegionNames = regionInfo.getSubRegionNames();
+ 
+           for (String subRegionName : subRegionNames) {
+             regionNames.add(subRegionName);
+           }
+         }
+ 
+         for (String regionName : regionNames) {
+           resultData.accumulate("List of regions", regionName);
+         }
+ 
+         if (!regionNames.isEmpty()) {
+           result = ResultBuilder.buildResult(resultData);
+ 
+         } else {
+           result = ResultBuilder.createInfoResult(CliStrings.LIST_REGION__MSG__NOT_FOUND);
+         }
+       }
+     } catch (FunctionInvocationTargetException e) {
+       result = ResultBuilder.createGemFireErrorResult(CliStrings.format(CliStrings.COULD_NOT_EXECUTE_COMMAND_TRY_AGAIN, CliStrings.LIST_REGION));
+     }
+     catch (Exception e) {
+       result = ResultBuilder.createGemFireErrorResult(CliStrings.LIST_REGION__MSG__ERROR + " : " + e.getMessage());
+     }
+     return result;
+   }
+ 
+   @CliCommand(value = { CliStrings.DESCRIBE_REGION }, help = CliStrings.DESCRIBE_REGION__HELP)
+   @CliMetaData(shellOnly = false, relatedTopic = { CliStrings.TOPIC_GEMFIRE_REGION, CliStrings.TOPIC_GEMFIRE_CONFIG } )
++  @ResourceOperation( resource=Resource.DISTRIBUTED_SYSTEM, operation=ResourceConstants.LIST_DS)
+   public Result describeRegion(
+       @CliOption(key = CliStrings.DESCRIBE_REGION__NAME,
+       optionContext = ConverterHint.REGIONPATH,
+       help = CliStrings.DESCRIBE_REGION__NAME__HELP,
+       mandatory = true)
+       String regionName) {
+ 
+     Result result = null;
+     try {
+       
+       if (regionName == null || regionName.isEmpty()) {
+         return ResultBuilder.createUserErrorResult("Please provide a region name");
+       }
+       
+       if (regionName.equals(Region.SEPARATOR)) {
+         return ResultBuilder.createUserErrorResult(CliStrings.INVALID_REGION_NAME);
+       }
+ 
+       Cache cache = CacheFactory.getAnyInstance();
+       ResultCollector <?, ?> rc = CliUtil.executeFunction(getRegionDescription, regionName, CliUtil.getAllMembers(cache));
+ 
+       List<?> resultList = (List<?>) rc.getResult();
+ 
+       // The returned result could be a region description with per member and /or single local region
+       Object[] results = resultList.toArray();
+       List<RegionDescription> regionDescriptionList = new ArrayList<RegionDescription>();
+ 
+       for (int i = 0; i < results.length; i++) {
+ 
+         if (results[i] instanceof RegionDescriptionPerMember) {
+           RegionDescriptionPerMember regionDescPerMember = (RegionDescriptionPerMember) results[i];
+ 
+           if (regionDescPerMember != null) {
+             RegionDescription regionDescription = new RegionDescription();
+             regionDescription.add(regionDescPerMember);
+ 
+             for (int j = i + 1; j < results.length; j++) {
+               if (results[j] != null && results[j] instanceof RegionDescriptionPerMember) {
+                 RegionDescriptionPerMember preyRegionDescPerMember = (RegionDescriptionPerMember) results[j];
+                 if (regionDescription.add(preyRegionDescPerMember)) {
+                   results[j] = null;
+                 }
+               }
+             }
+             regionDescriptionList.add(regionDescription);
+           }
+         } else if (results[i] instanceof Throwable) {
+           Throwable t = (Throwable) results[i];
+           LogWrapper.getInstance().info(t.getMessage(), t);
+         }
+       }
+ 
+       if (regionDescriptionList.isEmpty()) {
+         return ResultBuilder.createUserErrorResult(CliStrings.format(CliStrings.REGION_NOT_FOUND, regionName));
+       }
+ 
+       CompositeResultData crd = ResultBuilder.createCompositeResultData();
+       Iterator<RegionDescription> iters = regionDescriptionList.iterator();
+ 
+       while (iters.hasNext()) {
+         RegionDescription regionDescription = iters.next();
+         
+         //No point in displaying the scope for PR's 
+         if (regionDescription.isPartition()) {
+           regionDescription.getCndRegionAttributes().remove(RegionAttributesNames.SCOPE);
+         } else {
+           String scope = regionDescription.getCndRegionAttributes().get(RegionAttributesNames.SCOPE);
+           if (scope != null) {
+             scope = scope.toLowerCase().replace('_', '-');
+             regionDescription.getCndRegionAttributes().put(RegionAttributesNames.SCOPE, scope);
+           }
+         }
+         SectionResultData regionSection = crd.addSection();
+         regionSection.addSeparator('-');
+         regionSection.addData("Name", regionDescription.getName());
+ 
+         String dataPolicy = regionDescription.getDataPolicy().toString().toLowerCase().replace('_', ' ');
+         regionSection.addData("Data Policy", dataPolicy);
+ 
+         String memberType = "";
+ 
+         if (regionDescription.isAccessor()) {
+           memberType = CliStrings.DESCRIBE_REGION__ACCESSOR__MEMBER;
+         } else {
+           memberType = CliStrings.DESCRIBE_REGION__HOSTING__MEMBER;
+         }
+         regionSection.addData(memberType, CliUtil.convertStringSetToString(regionDescription.getHostingMembers(), '\n'));
+         regionSection.addSeparator('.');
+ 
+         TabularResultData commonNonDefaultAttrTable = regionSection.addSection().addTable();
+ 
+         commonNonDefaultAttrTable.setHeader(CliStrings.format(CliStrings.DESCRIBE_REGION__NONDEFAULT__COMMONATTRIBUTES__HEADER, memberType));
+         // Common Non Default Region Attributes
+         Map<String, String> cndRegionAttrsMap = regionDescription.getCndRegionAttributes();
+ 
+         // Common Non Default Eviction Attributes
+         Map<String, String> cndEvictionAttrsMap = regionDescription.getCndEvictionAttributes();
+ 
+         // Common Non Default Partition Attributes
+         Map<String, String> cndPartitionAttrsMap = regionDescription.getCndPartitionAttributes();
+ 
+         writeCommonAttributesToTable(commonNonDefaultAttrTable, CliStrings.DESCRIBE_REGION__ATTRIBUTE__TYPE__REGION, cndRegionAttrsMap);
+         writeCommonAttributesToTable(commonNonDefaultAttrTable, CliStrings.DESCRIBE_REGION__ATTRIBUTE__TYPE__EVICTION, cndEvictionAttrsMap);
+         writeCommonAttributesToTable(commonNonDefaultAttrTable, CliStrings.DESCRIBE_REGION__ATTRIBUTE__TYPE__PARTITION, cndPartitionAttrsMap);
+ 
+         // Member-wise non default Attributes
+         Map<String, RegionDescriptionPerMember> regDescPerMemberMap = regionDescription.getRegionDescriptionPerMemberMap();
+         Set<String> members = regDescPerMemberMap.keySet();
+ 
+         TabularResultData table = regionSection.addSection().addTable();
+         //table.setHeader(CliStrings.format(CliStrings.DESCRIBE_REGION__NONDEFAULT__PERMEMBERATTRIBUTES__HEADER, memberType));
+ 
+         boolean setHeader = false; 
+         for (String member : members) {
+           RegionDescriptionPerMember regDescPerMem = regDescPerMemberMap.get(member);
+           Map<String, String> ndRa = regDescPerMem.getNonDefaultRegionAttributes();
+           Map<String, String> ndEa = regDescPerMem.getNonDefaultEvictionAttributes();
+           Map<String, String> ndPa = regDescPerMem.getNonDefaultPartitionAttributes();
+ 
+           // Get all the member-specific non-default attributes by removing the common keys
+           ndRa.keySet().removeAll(cndRegionAttrsMap.keySet());
+           ndEa.keySet().removeAll(cndEvictionAttrsMap.keySet());
+           ndPa.keySet().removeAll(cndPartitionAttrsMap.keySet());
+           
+           //Scope is not valid for PR's
+           if (regionDescription.isPartition()) {
+             if (ndRa.get(RegionAttributesNames.SCOPE) != null) {
+               ndRa.remove(RegionAttributesNames.SCOPE);
+             }
+           }
+           
+           List<FixedPartitionAttributesInfo> fpaList = regDescPerMem.getFixedPartitionAttributes();
+ 
+           if (!(ndRa.isEmpty() && ndEa.isEmpty() && ndPa.isEmpty()) || fpaList != null) {
+             setHeader = true;
+             boolean memberNameAdded = false;
+             memberNameAdded = writeAttributesToTable(table, CliStrings.DESCRIBE_REGION__ATTRIBUTE__TYPE__REGION, ndRa, member, memberNameAdded);
+             memberNameAdded = writeAttributesToTable(table, CliStrings.DESCRIBE_REGION__ATTRIBUTE__TYPE__EVICTION, ndEa, member, memberNameAdded);
+             memberNameAdded = writeAttributesToTable(table, CliStrings.DESCRIBE_REGION__ATTRIBUTE__TYPE__PARTITION, ndPa, member, memberNameAdded);
+ 
+             writeFixedPartitionAttributesToTable(table, "", fpaList, member, memberNameAdded);
+             //Fix for #46767 
+             //writeAttributeToTable(table, "", "", "", "");
+           }
+         }
+ 
+         if (setHeader == true) {
+           table.setHeader(CliStrings.format(CliStrings.DESCRIBE_REGION__NONDEFAULT__PERMEMBERATTRIBUTES__HEADER, memberType));
+         }
+       }
+ 
+       result = ResultBuilder.buildResult(crd);
+     } catch (FunctionInvocationTargetException e) {
+       result = ResultBuilder.createGemFireErrorResult(CliStrings.format(CliStrings.COULD_NOT_EXECUTE_COMMAND_TRY_AGAIN, CliStrings.DESCRIBE_REGION));
+     }
+     catch (Exception e) {
+       String errorMessage = CliStrings.format(CliStrings.EXCEPTION_CLASS_AND_MESSAGE, e.getClass().getName(), e.getMessage());
+       result = ResultBuilder.createGemFireErrorResult(errorMessage);
+     }
+     return result;
+   }
+ 
+   private void writeCommonAttributesToTable(TabularResultData table, String attributeType, Map<String, String> attributesMap) {
+     if (!attributesMap.isEmpty()) {
+       Set<String> attributes = attributesMap.keySet();
+       boolean isTypeAdded = false;
+       final String blank = "";
+ 
+       Iterator<String> iters = attributes.iterator();
+ 
+       while (iters.hasNext()) {
+         String attributeName = iters.next();
+         String attributeValue = attributesMap.get(attributeName);
+         String type, memName;
+ 
+         if (!isTypeAdded) {
+           type = attributeType;
+           isTypeAdded = true;
+         } else {
+           type = blank;
+         }
+         writeCommonAttributeToTable(table, type, attributeName, attributeValue);
+       }
+     }
+   }
+ 
+   private boolean writeFixedPartitionAttributesToTable(TabularResultData table, String attributeType,
+       List<FixedPartitionAttributesInfo> fpaList, String member, boolean isMemberNameAdded) {
+ 
+     if (fpaList != null) {
+       boolean isTypeAdded = false;
+       final String blank = "";
+ 
+       Iterator<FixedPartitionAttributesInfo> fpaIter = fpaList.iterator();
+       String type, memName;
+ 
+       while (fpaIter.hasNext()) {
+         FixedPartitionAttributesInfo fpa = fpaIter.next();
+         StringBuilder fpaBuilder = new StringBuilder();
+         fpaBuilder.append(fpa.getPartitionName());
+         fpaBuilder.append(',');
+ 
+         if (fpa.isPrimary()) {
+           fpaBuilder.append("Primary");
+         } else {
+           fpaBuilder.append("Secondary");
+         }
+         fpaBuilder.append(',');
+         fpaBuilder.append(fpa.getNumBuckets());
+ 
+         if (!isTypeAdded) {
+           type = attributeType;
+           isTypeAdded = true;
+         } else {
+           type = blank;
+         }
+ 
+         if (!isMemberNameAdded) {
+           memName = member;
+           isMemberNameAdded = true;
+         } else {
+           memName = blank;
+         }
+ 
+         writeAttributeToTable(table, memName, type, "Fixed Partition", fpaBuilder.toString());
+       }
+     }
+ 
+     return isMemberNameAdded;
+   }
+ 
+   private boolean writeAttributesToTable(TabularResultData table, String attributeType, Map<String, String> attributesMap,
+       String member, boolean isMemberNameAdded) {
+     if (!attributesMap.isEmpty()) {
+       Set<String> attributes = attributesMap.keySet();
+       boolean isTypeAdded = false;
+       final String blank = "";
+ 
+       Iterator<String> iters = attributes.iterator();
+ 
+       while (iters.hasNext()) {
+         String attributeName = iters.next();
+         String attributeValue = attributesMap.get(attributeName);
+         String type, memName;
+         
+         if (!isTypeAdded) {
+           type = attributeType;
+           isTypeAdded = true;
+         } else {
+           type = blank;
+         }
+ 
+         if (!isMemberNameAdded) {
+           memName = member;
+           isMemberNameAdded = true;
+         } else {
+           memName = blank;
+         }
+ 
+         writeAttributeToTable(table, memName, type, attributeName, attributeValue);
+       }
+     }
+ 
+     return isMemberNameAdded;
+   }
+   
+   public void writeAttributeToTable(TabularResultData table, String member, String attributeType, String attributeName,
+       String attributeValue) {
+     
+     final String blank = "";
+     if (attributeValue != null) {
+     //Tokenize the attributeValue
+     String[] attributeValues = attributeValue.split(",");
+     boolean isFirstValue = true;
+     
+     for (String value : attributeValues) {
+       if (isFirstValue) {
+         table.accumulate(CliStrings.DESCRIBE_REGION__MEMBER, member);
+         table.accumulate(CliStrings.DESCRIBE_REGION__ATTRIBUTE__TYPE, attributeType);
+         table.accumulate(CliStrings.DESCRIBE_REGION__ATTRIBUTE__NAME, attributeName);
+         table.accumulate(CliStrings.DESCRIBE_REGION__ATTRIBUTE__VALUE, value);
+         isFirstValue = false;
+       } else {
+         table.accumulate(CliStrings.DESCRIBE_REGION__MEMBER, blank);
+         table.accumulate(CliStrings.DESCRIBE_REGION__ATTRIBUTE__TYPE, blank);
+         table.accumulate(CliStrings.DESCRIBE_REGION__ATTRIBUTE__NAME, blank);
+         table.accumulate(CliStrings.DESCRIBE_REGION__ATTRIBUTE__VALUE, value);
+       }
+     }
+    }
+   }
+   
+   
+   private void writeCommonAttributeToTable(TabularResultData table, String attributeType, String attributeName,
+       String attributeValue) {
+     final String blank = "";
+     
+     if (attributeValue != null) {
+       String[] attributeValues = attributeValue.split(",");
+       boolean isFirstValue = true;
+       for (String value : attributeValues) {
+         if (isFirstValue) {
+           isFirstValue = false;
+           table.accumulate(CliStrings.DESCRIBE_REGION__ATTRIBUTE__TYPE, attributeType);
+           table.accumulate(CliStrings.DESCRIBE_REGION__ATTRIBUTE__NAME, attributeName);
+           table.accumulate(CliStrings.DESCRIBE_REGION__ATTRIBUTE__VALUE, value);
+         } else {
+           table.accumulate(CliStrings.DESCRIBE_REGION__ATTRIBUTE__TYPE, blank);
+           table.accumulate(CliStrings.DESCRIBE_REGION__ATTRIBUTE__NAME, blank);
+           table.accumulate(CliStrings.DESCRIBE_REGION__ATTRIBUTE__VALUE, value);
+         }
+       }
+      
+     }
+   }
+ 
+   public void addChildSection(SectionResultData parentSection, Map<String, String> map, String header) {
+     if (!map.isEmpty()) {
+       Set<String> attributes = map.keySet();
+       SectionResultData section = parentSection.addSection();
+       section.setHeader(header);
+       for (String attribute : attributes) {
+         section.addData(attribute, map.get(attribute));
+       }
+     }
+   }
+ 
+   @CliAvailabilityIndicator({ CliStrings.LIST_REGION, CliStrings.DESCRIBE_REGION })
+   public boolean isRegionCommandAvailable() {
+     boolean isAvailable = true; // always available on server
+     if (CliUtil.isGfshVM()) { // in gfsh check if connected //TODO - Abhishek: make this better
+       isAvailable = getGfsh() != null && getGfsh().isConnectedAndReady();
+     }
+     return isAvailable;
+   }
+ 
+ }


Mime
View raw message