Search in sources :

Example 11 with CommandProcessor

use of org.apache.geode.management.internal.cli.remote.CommandProcessor 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();
}
Also used : DistributionConfig(org.apache.geode.distributed.internal.DistributionConfig) CommandStringBuilder(org.apache.geode.management.internal.cli.util.CommandStringBuilder) GemFireCacheImpl(org.apache.geode.internal.cache.GemFireCacheImpl) CommandProcessor(org.apache.geode.management.internal.cli.remote.CommandProcessor) Properties(java.util.Properties) File(java.io.File) CommandResult(org.apache.geode.management.internal.cli.result.CommandResult) Result(org.apache.geode.management.cli.Result) CommandResult(org.apache.geode.management.internal.cli.result.CommandResult) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test)

Example 12 with CommandProcessor

use of org.apache.geode.management.internal.cli.remote.CommandProcessor in project geode by apache.

the class ShowMetricsDUnitTest method testShowMetricsRegion.

@Test
public void testShowMetricsRegion() throws InterruptedException {
    systemSetUp();
    final String regionName = "REGION1";
    SerializableCallable showMetricCmd = new SerializableCallable() {

        @Override
        public Object call() throws Exception {
            WaitCriterion wc = createMBeanWaitCriterion(2, regionName, null, 0);
            waitForCriterion(wc, 5000, 500, true);
            CommandProcessor commandProcessor = new CommandProcessor();
            Result result = commandProcessor.createCommandStatement("show metrics --region=REGION1", Collections.EMPTY_MAP).process();
            String resultAsString = commandResultToString((CommandResult) result);
            assertEquals(resultAsString, true, result.getStatus().equals(Status.OK));
            return resultAsString;
        }
    };
    // Invoke the command in the Manager VM
    final VM managerVm = Host.getHost(0).getVM(0);
    Object managerResultObj = managerVm.invoke(showMetricCmd);
    String managerResult = (String) managerResultObj;
    getLogWriter().info("#SB Manager");
    getLogWriter().info(managerResult);
}
Also used : CommandProcessor(org.apache.geode.management.internal.cli.remote.CommandProcessor) Result(org.apache.geode.management.cli.Result) CommandResult(org.apache.geode.management.internal.cli.result.CommandResult) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 13 with CommandProcessor

use of org.apache.geode.management.internal.cli.remote.CommandProcessor in project geode by apache.

the class ShowMetricsDUnitTest method testShowMetricsRegionFromMemberWithCategories.

@Test
public void testShowMetricsRegionFromMemberWithCategories() throws ClassNotFoundException, IOException, InterruptedException {
    systemSetUp();
    Cache cache = getCache();
    final DistributedMember distributedMember = cache.getDistributedSystem().getDistributedMember();
    final String exportFileName = "regionOnAMemberReport.csv";
    final String regionName = "REGION1";
    SerializableCallable showMetricCmd = new SerializableCallable() {

        @Override
        public Object call() throws Exception {
            WaitCriterion wc = createMBeanWaitCriterion(4, regionName, distributedMember, 0);
            waitForCriterion(wc, 5000, 500, true);
            CommandProcessor commandProcessor = new CommandProcessor();
            Result result = commandProcessor.createCommandStatement("show metrics --region=" + regionName + " --member=" + distributedMember.getName() + " --file=" + exportFileName + " --categories=region,eviction", Collections.EMPTY_MAP).process();
            String resultAsString = commandResultToString((CommandResult) result);
            assertEquals(resultAsString, true, result.getStatus().equals(Status.OK));
            assertTrue(result.hasIncomingFiles());
            result.saveIncomingFiles(null);
            File file = new File(exportFileName);
            file.deleteOnExit();
            assertTrue(file.exists());
            file.delete();
            return resultAsString;
        }
    };
    // Invoke the command in the Manager VM
    final VM managerVm = Host.getHost(0).getVM(0);
    Object managerResultObj = managerVm.invoke(showMetricCmd);
    String managerResult = (String) managerResultObj;
    getLogWriter().info("#SB Manager");
    getLogWriter().info(managerResult);
}
Also used : DistributedMember(org.apache.geode.distributed.DistributedMember) CommandProcessor(org.apache.geode.management.internal.cli.remote.CommandProcessor) File(java.io.File) Cache(org.apache.geode.cache.Cache) Result(org.apache.geode.management.cli.Result) CommandResult(org.apache.geode.management.internal.cli.result.CommandResult) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Aggregations

CommandProcessor (org.apache.geode.management.internal.cli.remote.CommandProcessor)13 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)13 Test (org.junit.Test)13 Result (org.apache.geode.management.cli.Result)12 File (java.io.File)7 CommandResult (org.apache.geode.management.internal.cli.result.CommandResult)7 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)7 Cache (org.apache.geode.cache.Cache)5 Properties (java.util.Properties)4 DistributedMember (org.apache.geode.distributed.DistributedMember)4 CommandStringBuilder (org.apache.geode.management.internal.cli.util.CommandStringBuilder)4 CacheServer (org.apache.geode.cache.server.CacheServer)2 DistributionConfig (org.apache.geode.distributed.internal.DistributionConfig)2 GemFireCacheImpl (org.apache.geode.internal.cache.GemFireCacheImpl)2 IOException (java.io.IOException)1 RuntimeMXBean (java.lang.management.RuntimeMXBean)1 Region (org.apache.geode.cache.Region)1 RegionFactory (org.apache.geode.cache.RegionFactory)1 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)1 Locator (org.apache.geode.distributed.Locator)1