Search in sources :

Example 6 with DistributionConfig

use of org.apache.geode.distributed.internal.DistributionConfig in project geode by apache.

the class CacheManagementDUnitTest method verifyConfigData.

private Map<DistributedMember, DistributionConfig> verifyConfigData() {
    ManagementService service = this.managementTestRule.getManagementService();
    InternalDistributedSystem ids = (InternalDistributedSystem) this.managementTestRule.getCache().getDistributedSystem();
    DistributionConfig config = ids.getConfig();
    MemberMXBean bean = service.getMemberMXBean();
    GemFireProperties data = bean.listGemFireProperties();
    verifyGemFirePropertiesData(config, data);
    Map<DistributedMember, DistributionConfig> configMap = new HashMap<>();
    configMap.put(ids.getDistributedMember(), config);
    return configMap;
}
Also used : DistributionConfig(org.apache.geode.distributed.internal.DistributionConfig) SystemManagementService(org.apache.geode.management.internal.SystemManagementService) HashMap(java.util.HashMap) DistributedMember(org.apache.geode.distributed.DistributedMember) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem)

Example 7 with DistributionConfig

use of org.apache.geode.distributed.internal.DistributionConfig in project geode by apache.

the class CacheManagementDUnitTest method verifyConfigDataRemote.

/**
   * This is to check whether the config data has been propagated to the Managing node properly or
   * not.
   */
private void verifyConfigDataRemote(final Map<DistributedMember, DistributionConfig> configMap) {
    Set<DistributedMember> otherMembers = this.managementTestRule.getOtherNormalMembers();
    for (DistributedMember member : otherMembers) {
        MemberMXBean memberMXBean = awaitMemberMXBeanProxy(member);
        GemFireProperties data = memberMXBean.listGemFireProperties();
        DistributionConfig config = configMap.get(member);
        verifyGemFirePropertiesData(config, data);
    }
}
Also used : DistributionConfig(org.apache.geode.distributed.internal.DistributionConfig) DistributedMember(org.apache.geode.distributed.DistributedMember)

Example 8 with DistributionConfig

use of org.apache.geode.distributed.internal.DistributionConfig in project geode by apache.

the class CacheManagementDUnitTest method testGemFireConfigData.

@Test
public void testGemFireConfigData() throws Exception {
    this.managementTestRule.createMembers();
    this.managementTestRule.createManagers();
    Map<DistributedMember, DistributionConfig> configMap = new HashMap<>();
    for (VM memberVM : this.memberVMs) {
        Map<DistributedMember, DistributionConfig> configMapMember = memberVM.invoke(() -> verifyConfigData());
        configMap.putAll(configMapMember);
    }
    this.managerVM.invoke(() -> verifyConfigDataRemote(configMap));
}
Also used : DistributionConfig(org.apache.geode.distributed.internal.DistributionConfig) HashMap(java.util.HashMap) VM(org.apache.geode.test.dunit.VM) DistributedMember(org.apache.geode.distributed.DistributedMember) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 9 with DistributionConfig

use of org.apache.geode.distributed.internal.DistributionConfig in project geode by apache.

the class ConfigCommandsDUnitTest method testAlterRuntimeConfigOnAllMembers.

@Test
public void testAlterRuntimeConfigOnAllMembers() throws Exception {
    final String member1 = "VM1";
    final String controller = "controller";
    String controllerDirectory = this.temporaryFolder.newFolder(controller).getAbsolutePath();
    String controllerStatFilePath = new File(controllerDirectory, "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();
    Host.getHost(0).getVM(1).invoke(new SerializableRunnable() {

        public void run() {
            Properties localProps = new Properties();
            localProps.setProperty(NAME, member1);
            getSystem(localProps);
            Cache cache = getCache();
        }
    });
    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
    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, controllerStatFilePath);
    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("#SB Result\n");
    getLogWriter().info(resultString);
    assertEquals(true, cmdResult.getStatus().equals(Status.OK));
    assertEquals(LogWriterImpl.INFO_LEVEL, config.getLogLevel());
    assertEquals(50, config.getLogFileSizeLimit());
    assertEquals(49, config.getArchiveFileSizeLimit());
    assertEquals(32, config.getArchiveDiskSpaceLimit());
    assertEquals(2000, config.getStatisticSampleRate());
    assertEquals("stat.gfs", config.getStatisticArchiveFile().getName());
    assertEquals(true, config.getStatisticSamplingEnabled());
    assertEquals(10, config.getLogDiskSpaceLimit());
    // Validate the changes in the vm1
    Host.getHost(0).getVM(1).invoke(new SerializableRunnable() {

        public void run() {
            GemFireCacheImpl cacheVM1 = (GemFireCacheImpl) getCache();
            DistributionConfig configVM1 = cacheVM1.getSystem().getConfig();
            assertEquals(LogWriterImpl.INFO_LEVEL, configVM1.getLogLevel());
            assertEquals(50, configVM1.getLogFileSizeLimit());
            assertEquals(49, configVM1.getArchiveFileSizeLimit());
            assertEquals(32, configVM1.getArchiveDiskSpaceLimit());
            assertEquals(2000, configVM1.getStatisticSampleRate());
            assertEquals("stat.gfs", configVM1.getStatisticArchiveFile().getName());
            assertEquals(true, configVM1.getStatisticSamplingEnabled());
            assertEquals(10, configVM1.getLogDiskSpaceLimit());
        }
    });
}
Also used : DistributionConfig(org.apache.geode.distributed.internal.DistributionConfig) CommandStringBuilder(org.apache.geode.management.internal.cli.util.CommandStringBuilder) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) GemFireCacheImpl(org.apache.geode.internal.cache.GemFireCacheImpl) Properties(java.util.Properties) File(java.io.File) Cache(org.apache.geode.cache.Cache) 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 10 with DistributionConfig

use of org.apache.geode.distributed.internal.DistributionConfig in project geode by apache.

the class ConfigCommandsDUnitTest method testDescribeConfig.

@Test
public void testDescribeConfig() throws Exception {
    setUpJmxManagerOnVm0ThenConnect(null);
    final String controllerName = "Member2";
    /*
     * Create properties for the controller VM
     */
    final Properties localProps = new Properties();
    localProps.setProperty(MCAST_PORT, "0");
    localProps.setProperty(LOG_LEVEL, "info");
    localProps.setProperty(STATISTIC_SAMPLING_ENABLED, "true");
    localProps.setProperty(ENABLE_TIME_STATISTICS, "true");
    localProps.setProperty(NAME, controllerName);
    localProps.setProperty(GROUPS, "G1");
    getSystem(localProps);
    Cache cache = getCache();
    int[] ports = getRandomAvailableTCPPorts(1);
    CacheServer cs = getCache().addCacheServer();
    cs.setPort(ports[0]);
    cs.setMaxThreads(10);
    cs.setMaxConnections(9);
    cs.start();
    try {
        RuntimeMXBean runtimeBean = ManagementFactory.getRuntimeMXBean();
        List<String> jvmArgs = runtimeBean.getInputArguments();
        getLogWriter().info("#SB Actual JVM Args : ");
        for (String jvmArg : jvmArgs) {
            getLogWriter().info("#SB JVM " + jvmArg);
        }
        InternalDistributedSystem system = (InternalDistributedSystem) cache.getDistributedSystem();
        DistributionConfig config = system.getConfig();
        config.setArchiveFileSizeLimit(1000);
        String command = CliStrings.DESCRIBE_CONFIG + " --member=" + controllerName;
        CommandProcessor cmdProcessor = new CommandProcessor();
        cmdProcessor.createCommandStatement(command, Collections.EMPTY_MAP).process();
        CommandResult cmdResult = executeCommand(command);
        String resultStr = commandResultToString(cmdResult);
        getLogWriter().info("#SB Hiding the defaults\n" + resultStr);
        assertEquals(true, cmdResult.getStatus().equals(Status.OK));
        assertEquals(true, resultStr.contains("G1"));
        assertEquals(true, resultStr.contains(controllerName));
        assertEquals(true, resultStr.contains(ARCHIVE_FILE_SIZE_LIMIT));
        assertEquals(true, !resultStr.contains("copy-on-read"));
        cmdResult = executeCommand(command + " --" + CliStrings.DESCRIBE_CONFIG__HIDE__DEFAULTS + "=false");
        resultStr = commandResultToString(cmdResult);
        getLogWriter().info("#SB No hiding of defaults\n" + resultStr);
        assertEquals(true, cmdResult.getStatus().equals(Status.OK));
        assertEquals(true, resultStr.contains("is-server"));
        assertEquals(true, resultStr.contains(controllerName));
        assertEquals(true, resultStr.contains("copy-on-read"));
    } finally {
        cs.stop();
    }
}
Also used : DistributionConfig(org.apache.geode.distributed.internal.DistributionConfig) CacheServer(org.apache.geode.cache.server.CacheServer) CommandProcessor(org.apache.geode.management.internal.cli.remote.CommandProcessor) RuntimeMXBean(java.lang.management.RuntimeMXBean) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) Properties(java.util.Properties) Cache(org.apache.geode.cache.Cache) 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)

Aggregations

DistributionConfig (org.apache.geode.distributed.internal.DistributionConfig)45 InternalDistributedSystem (org.apache.geode.distributed.internal.InternalDistributedSystem)19 Properties (java.util.Properties)17 File (java.io.File)14 Test (org.junit.Test)14 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)12 LogWriterLogger (org.apache.geode.internal.logging.log4j.LogWriterLogger)9 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)9 WaitCriterion (org.apache.geode.test.dunit.WaitCriterion)8 FileInputStream (java.io.FileInputStream)7 IOException (java.io.IOException)7 FastLogger (org.apache.geode.internal.logging.log4j.FastLogger)7 Logger (org.apache.logging.log4j.Logger)7 DistributionConfigImpl (org.apache.geode.distributed.internal.DistributionConfigImpl)5 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)5 UnknownHostException (java.net.UnknownHostException)4 Cache (org.apache.geode.cache.Cache)4 GemFireCacheImpl (org.apache.geode.internal.cache.GemFireCacheImpl)4 InternalCache (org.apache.geode.internal.cache.InternalCache)4 CommandResult (org.apache.geode.management.internal.cli.result.CommandResult)4