ImportClusterConfigurationCommand extends GfshCommand { Set<DistributedMember> findMembers(String group) { Set<DistributedMember> serversInGroup; if (ConfigurationPersistenceService.CLUSTER_CONFIG.equals(group)) { serversInGroup = getAllNormalMembers(); } else { serversInGroup = findMembers(new String[] {group}, null); } return serversInGroup; }  @CliCommand(value = {CliStrings.IMPORT_SHARED_CONFIG}, help = CliStrings.IMPORT_SHARED_CONFIG__HELP) @CliMetaData( interceptor = "org.apache.geode.management.internal.cli.commands.ImportClusterConfigurationCommand$ImportInterceptor", isFileUploaded = true, relatedTopic = {CliStrings.TOPIC_GEODE_CONFIG}) @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE) ResultModel importSharedConfig(
      @CliOption(key = CliStrings.GROUP,
          specifiedDefaultValue = ConfigurationPersistenceService.CLUSTER_CONFIG,
          unspecifiedDefaultValue = ConfigurationPersistenceService.CLUSTER_CONFIG) String group,
      @CliOption(key = XML_FILE) String xmlFile,
      @CliOption(key = ACTION, help = ACTION_HELP, unspecifiedDefaultValue = "APPLY") Action action,
      @CliOption(key = {CliStrings.IMPORT_SHARED_CONFIG__ZIP},
          help = CliStrings.IMPORT_SHARED_CONFIG__ZIP__HELP) String zip); static final Logger logger; static final String XML_FILE; static final String ACTION; static final String ACTION_HELP; }
@Test public void existingMembersWithoutStaging() { doReturn(Collections.singleton(mock(DistributedMember.class))).when(command).findMembers(any()); when(ccService.hasXmlConfiguration()).thenReturn(true); gfsh.executeAndAssertThat(command, commandWithFile).statusIsError() .containsOutput("Can not configure servers that are already configured"); }
@Test public void existingMembersWithBounce() { doReturn(Collections.singleton(mock(DistributedMember.class))).when(command).findMembers(any()); when(ccService.hasXmlConfiguration()).thenReturn(true); gfsh.executeAndAssertThat(command, commandWithFile + "--action=APPLY").statusIsError() .containsOutput("Can not configure servers that are already configured"); }
@Test public void existingMembersWithIgnore() { doReturn(Collections.singleton(mock(DistributedMember.class))).when(command).findMembers(any()); when(ccService.getConfiguration(any())).thenReturn(configuration); gfsh.executeAndAssertThat(command, commandWithFile + "--action=STAGE").statusIsSuccess() .containsOutput("Successfully set the 'cluster' configuration to the content of") .containsOutput("Existing servers are not affected with this configuration change"); }