use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.
the class LuceneCommandsSecurityDUnitTest method getSearchIndexCommand.
private String getSearchIndexCommand() throws Exception {
CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_SEARCH_INDEX);
csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
csb.addOption(LuceneCliStrings.LUCENE_SEARCH_INDEX__QUERY_STRING, "field1:value1");
csb.addOption(LuceneCliStrings.LUCENE_SEARCH_INDEX__DEFAULT_FIELD, "field1");
return csb.toString();
}
use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.
the class LuceneCommandsSecurityDUnitTest method getCreateRegionCommand.
private String getCreateRegionCommand() throws Exception {
CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_REGION);
csb.addOption(CliStrings.CREATE_REGION__REGION, REGION_NAME);
csb.addOption(CliStrings.CREATE_REGION__REGIONSHORTCUT, RegionShortcut.PARTITION_REDUNDANT.name());
return csb.toString();
}
use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.
the class ConfigCommandsDUnitTest method testAlterRuntimeConfig.
@Test
public void testAlterRuntimeConfig() throws Exception {
final String controller = "controller";
String directory = this.temporaryFolder.newFolder(controller).getAbsolutePath();
String statFilePath = new File(directory, "stat.gfs").getAbsolutePath();
setUpJmxManagerOnVm0ThenConnect(null);
Properties localProps = new Properties();
localProps.setProperty(NAME, controller);
localProps.setProperty(LOG_LEVEL, "error");
getSystem(localProps);
final GemFireCacheImpl cache = (GemFireCacheImpl) getCache();
final DistributionConfig config = cache.getSystem().getConfig();
CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__MEMBER, controller);
csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__LOG__LEVEL, "info");
csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__LOG__FILE__SIZE__LIMIT, "50");
csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__ARCHIVE__DISK__SPACE__LIMIT, "32");
csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__ARCHIVE__FILE__SIZE__LIMIT, "49");
csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__SAMPLE__RATE, "2000");
csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__ARCHIVE__FILE, statFilePath);
csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__SAMPLING__ENABLED, "true");
csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__LOG__DISK__SPACE__LIMIT, "10");
CommandResult cmdResult = executeCommand(csb.getCommandString());
String resultString = commandResultToString(cmdResult);
getLogWriter().info("Result\n");
getLogWriter().info(resultString);
assertEquals(true, cmdResult.getStatus().equals(Status.OK));
assertEquals(LogWriterImpl.INFO_LEVEL, config.getLogLevel());
assertEquals(50, config.getLogFileSizeLimit());
assertEquals(32, config.getArchiveDiskSpaceLimit());
assertEquals(2000, config.getStatisticSampleRate());
assertEquals("stat.gfs", config.getStatisticArchiveFile().getName());
assertEquals(true, config.getStatisticSamplingEnabled());
assertEquals(10, config.getLogDiskSpaceLimit());
CommandProcessor commandProcessor = new CommandProcessor();
Result result = commandProcessor.createCommandStatement("alter runtime", Collections.EMPTY_MAP).process();
}
use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.
the class CreateAlterDestroyRegionCommandsDUnitTest method testAlterRegionResetCacheListeners.
// GEODE-3018
@Category(FlakyTest.class)
@Test
public void testAlterRegionResetCacheListeners() throws IOException {
setUpJmxManagerOnVm0ThenConnect(null);
CommandResult cmdResult = executeCommand(CliStrings.LIST_REGION);
assertEquals(Result.Status.OK, cmdResult.getStatus());
assertTrue(commandResultToString(cmdResult).contains("No Regions Found"));
Host.getHost(0).getVM(0).invoke(() -> {
Cache cache = getCache();
cache.createRegionFactory(RegionShortcut.PARTITION).setStatisticsEnabled(true).create(alterRegionName);
});
this.alterVm1 = Host.getHost(0).getVM(1);
this.alterVm1Name = "VM" + this.alterVm1.getPid();
this.alterVm1.invoke(() -> {
Properties localProps = new Properties();
localProps.setProperty(NAME, alterVm1Name);
localProps.setProperty(GROUPS, "Group1");
getSystem(localProps);
Cache cache = getCache();
// Setup queues and gateway senders to be used by all tests
cache.createRegionFactory(RegionShortcut.PARTITION).setStatisticsEnabled(true).create(alterRegionName);
});
this.alterVm2 = Host.getHost(0).getVM(2);
this.alterVm2Name = "VM" + this.alterVm2.getPid();
this.alterVm2.invoke(() -> {
Properties localProps = new Properties();
localProps.setProperty(NAME, alterVm2Name);
localProps.setProperty(GROUPS, "Group1,Group2");
getSystem(localProps);
Cache cache = getCache();
cache.createRegionFactory(RegionShortcut.PARTITION).setStatisticsEnabled(true).create(alterRegionName);
});
deployJarFilesForRegionAlter();
CommandStringBuilder commandStringBuilder = new CommandStringBuilder(CliStrings.ALTER_REGION);
commandStringBuilder.addOption(CliStrings.ALTER_REGION__REGION, "/" + this.alterRegionName);
commandStringBuilder.addOption(CliStrings.ALTER_REGION__CACHELISTENER, "com.cadrdunit.RegionAlterCacheListenerA,com.cadrdunit.RegionAlterCacheListenerB,com.cadrdunit.RegionAlterCacheListenerC");
cmdResult = executeCommand(commandStringBuilder.toString());
assertEquals(Result.Status.OK, cmdResult.getStatus());
String stringResult = commandResultToString(cmdResult);
assertEquals(5, countLinesInString(stringResult, false));
assertEquals(false, stringResult.contains("ERROR"));
assertTrue(stringContainsLine(stringResult, this.alterVm1Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
assertTrue(stringContainsLine(stringResult, this.alterVm2Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
this.alterVm1.invoke(() -> {
RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
assertEquals(3, attributes.getCacheListeners().length);
assertEquals("com.cadrdunit.RegionAlterCacheListenerA", attributes.getCacheListeners()[0].getClass().getName());
assertEquals("com.cadrdunit.RegionAlterCacheListenerB", attributes.getCacheListeners()[1].getClass().getName());
assertEquals("com.cadrdunit.RegionAlterCacheListenerC", attributes.getCacheListeners()[2].getClass().getName());
});
// Add 1 back to each of the sets
commandStringBuilder = new CommandStringBuilder(CliStrings.ALTER_REGION);
commandStringBuilder.addOption(CliStrings.ALTER_REGION__REGION, "/" + this.alterRegionName);
commandStringBuilder.addOption(CliStrings.ALTER_REGION__GROUP, "Group1");
commandStringBuilder.addOption(CliStrings.ALTER_REGION__CACHELISTENER, "''");
cmdResult = executeCommand(commandStringBuilder.toString());
assertEquals(Result.Status.OK, cmdResult.getStatus());
stringResult = commandResultToString(cmdResult);
assertEquals(4, countLinesInString(stringResult, false));
assertEquals(false, stringResult.contains("ERROR"));
assertTrue(stringContainsLine(stringResult, this.alterVm1Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
assertTrue(stringContainsLine(stringResult, this.alterVm2Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
this.alterVm1.invoke(() -> {
RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
assertEquals(0, attributes.getCacheListeners().length);
});
}
use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.
the class CreateAlterDestroyRegionCommandsDUnitTest method testCreateRegionWithInvalidPartitionResolver.
@Test
public void testCreateRegionWithInvalidPartitionResolver() {
setUpJmxManagerOnVm0ThenConnect(null);
VM vm = Host.getHost(0).getVM(1);
// Create a cache in vm 1
vm.invoke(() -> {
assertNotNull(getCache());
});
// Create a region with an unrecognized compressor
CommandStringBuilder commandStringBuilder = new CommandStringBuilder(CliStrings.CREATE_REGION);
commandStringBuilder.addOption(CliStrings.CREATE_REGION__REGION, "testCreateRegionWithInvalidPartitionResolver");
commandStringBuilder.addOption(CliStrings.CREATE_REGION__REGIONSHORTCUT, "PARTITION");
commandStringBuilder.addOption(CliStrings.CREATE_REGION__PARTITION_RESOLVER, "a.b.c.d");
CommandResult cmdResult = executeCommand(commandStringBuilder.toString());
assertEquals(Result.Status.ERROR, cmdResult.getStatus());
// Assert that our region was not created
vm.invoke(() -> {
Region region = getCache().getRegion("testCreateRegionWithInvalidPartitionResolver");
assertNull(region);
});
}
Aggregations