Search in sources :

Example 1 with LOG_FILE_SIZE_LIMIT

use of org.apache.geode.distributed.ConfigurationProperties.LOG_FILE_SIZE_LIMIT in project geode by apache.

the class ClusterConfig method verifyServer.

public void verifyServer(MemberVM<Server> serverVM) {
    // verify files exist in filesystem
    Set<String> expectedJarNames = this.getJarNames().stream().collect(toSet());
    String[] actualJarFiles = serverVM.getWorkingDir().list((dir, filename) -> filename.contains(".jar"));
    Set<String> actualJarNames = Stream.of(actualJarFiles).map(jar -> jar.replaceAll("\\.v\\d+\\.jar", ".jar")).collect(toSet());
    // We will end up with extra jars on disk if they are deployed and then undeployed
    assertThat(expectedJarNames).isSubsetOf(actualJarNames);
    // verify config exists in memory
    serverVM.invoke(() -> {
        Cache cache = GemFireCacheImpl.getInstance();
        // TODO: set compare to fail if there are extra regions
        for (String region : this.getRegions()) {
            assertThat(cache.getRegion(region)).isNotNull();
        }
        if (StringUtils.isNotBlank(this.getMaxLogFileSize())) {
            Properties props = cache.getDistributedSystem().getProperties();
            assertThat(props.getProperty(LOG_FILE_SIZE_LIMIT)).isEqualTo(this.getMaxLogFileSize());
        }
        for (String jar : this.getJarNames()) {
            DeployedJar deployedJar = ClassPathLoader.getLatest().getJarDeployer().findDeployedJar(jar);
            assertThat(deployedJar).isNotNull();
            assertThat(Class.forName(nameOfClassContainedInJar(jar), true, new URLClassLoader(new URL[] { deployedJar.getFileURL() }))).isNotNull();
        }
        // If we have extra jars on disk left over from undeploy, make sure they aren't used
        Set<String> undeployedJarNames = new HashSet<>(actualJarNames);
        undeployedJarNames.removeAll(expectedJarNames);
        for (String jar : undeployedJarNames) {
            System.out.println("Verifying undeployed jar: " + jar);
            DeployedJar undeployedJar = ClassPathLoader.getLatest().getJarDeployer().findDeployedJar(jar);
            assertThat(undeployedJar).isNull();
        }
    });
}
Also used : ClassPathLoader(org.apache.geode.internal.ClassPathLoader) StringUtils(org.apache.commons.lang.StringUtils) Arrays(java.util.Arrays) ClusterConfigurationService(org.apache.geode.distributed.internal.ClusterConfigurationService) DeployedJar(org.apache.geode.internal.DeployedJar) Locator(org.apache.geode.test.dunit.rules.Locator) URL(java.net.URL) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Cache(org.apache.geode.cache.Cache) URLClassLoader(java.net.URLClassLoader) Collectors.toSet(java.util.stream.Collectors.toSet) Properties(java.util.Properties) Set(java.util.Set) Server(org.apache.geode.test.dunit.rules.Server) Collectors(java.util.stream.Collectors) File(java.io.File) GemFireCacheImpl(org.apache.geode.internal.cache.GemFireCacheImpl) LocatorServerStartupRule(org.apache.geode.test.dunit.rules.LocatorServerStartupRule) Serializable(java.io.Serializable) List(java.util.List) Stream(java.util.stream.Stream) MemberVM(org.apache.geode.test.dunit.rules.MemberVM) LOG_FILE_SIZE_LIMIT(org.apache.geode.distributed.ConfigurationProperties.LOG_FILE_SIZE_LIMIT) Configuration(org.apache.geode.management.internal.configuration.domain.Configuration) Collections(java.util.Collections) InternalLocator(org.apache.geode.distributed.internal.InternalLocator) DeployedJar(org.apache.geode.internal.DeployedJar) URLClassLoader(java.net.URLClassLoader) Properties(java.util.Properties) URL(java.net.URL) Cache(org.apache.geode.cache.Cache) HashSet(java.util.HashSet)

Aggregations

File (java.io.File)1 Serializable (java.io.Serializable)1 URL (java.net.URL)1 URLClassLoader (java.net.URLClassLoader)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Properties (java.util.Properties)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Collectors.toSet (java.util.stream.Collectors.toSet)1 Stream (java.util.stream.Stream)1 StringUtils (org.apache.commons.lang.StringUtils)1 Cache (org.apache.geode.cache.Cache)1 LOG_FILE_SIZE_LIMIT (org.apache.geode.distributed.ConfigurationProperties.LOG_FILE_SIZE_LIMIT)1 ClusterConfigurationService (org.apache.geode.distributed.internal.ClusterConfigurationService)1 InternalLocator (org.apache.geode.distributed.internal.InternalLocator)1 ClassPathLoader (org.apache.geode.internal.ClassPathLoader)1