Search in sources :

Example 31 with DistributionConfigImpl

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

the class HTTPServiceSSLSupportJUnitTest method testSSLWithDeprecatedClusterSSL_HTTPService.

@Test
public void testSSLWithDeprecatedClusterSSL_HTTPService() throws Exception {
    Properties localProps = new Properties();
    localProps.setProperty(MCAST_PORT, "0");
    localProps.setProperty(CLUSTER_SSL_ENABLED, "true");
    System.setProperty(DistributionConfig.GEMFIRE_PREFIX + "javax.net.ssl.keyStore", jks.getCanonicalPath());
    System.setProperty(DistributionConfig.GEMFIRE_PREFIX + "javax.net.ssl.keyStorePassword", "password");
    localProps.setProperty(CLUSTER_SSL_PROTOCOLS, "SSL");
    localProps.setProperty(CLUSTER_SSL_REQUIRE_AUTHENTICATION, "true");
    System.setProperty(DistributionConfig.GEMFIRE_PREFIX + "javax.net.ssl.trustStore", jks.getCanonicalPath());
    System.setProperty(DistributionConfig.GEMFIRE_PREFIX + "javax.net.ssl.trustStorePassword", "password");
    DistributionConfigImpl config = new DistributionConfigImpl(localProps);
    assertEquals(true, config.getHttpServiceSSLEnabled());
    assertEquals("SSL", config.getHttpServiceSSLProtocols());
    assertEquals(true, config.getHttpServiceSSLRequireAuthentication());
    assertEquals(jks.getCanonicalPath(), config.getHttpServiceSSLProperties().get("javax.net.ssl.keyStore"));
    assertEquals("password", config.getHttpServiceSSLProperties().get("javax.net.ssl.keyStorePassword"));
    // assertIndexDetailsEquals(system.getConfig().getHttpServiceSSLKeyStoreType(),"JKS");
    assertEquals(jks.getCanonicalPath(), config.getHttpServiceSSLProperties().get("javax.net.ssl.trustStore"));
    assertEquals("password", config.getHttpServiceSSLProperties().get("javax.net.ssl.trustStorePassword"));
}
Also used : DistributionConfigImpl(org.apache.geode.distributed.internal.DistributionConfigImpl) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 32 with DistributionConfigImpl

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

the class AdminDistributedSystemFactory method defineDistributedSystem.

/**
   * Defines a "default" distributed system configuration based on VM system properties and the
   * content of <code>gemfire.properties</code>. The
   * {@linkplain DistributedSystemConfig#DEFAULT_REMOTE_COMMAND} default remote command is used.
   *
   * @see DistributedSystem#connect
   */
public static DistributedSystemConfig defineDistributedSystem() {
    DistributionConfig dc = new DistributionConfigImpl(new Properties());
    String remoteCommand = DistributedSystemConfig.DEFAULT_REMOTE_COMMAND;
    return new DistributedSystemConfigImpl(dc, remoteCommand);
}
Also used : DistributionConfig(org.apache.geode.distributed.internal.DistributionConfig) DistributionConfigImpl(org.apache.geode.distributed.internal.DistributionConfigImpl) Properties(java.util.Properties) DistributedSystemConfigImpl(org.apache.geode.admin.internal.DistributedSystemConfigImpl)

Example 33 with DistributionConfigImpl

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

the class LocatorLoadBalancingDUnitTest method testEstimation.

/**
   * Test that the locator will properly estimate the load for servers when it receives connection
   * requests.
   */
@Test
public void testEstimation() throws IOException, ClassNotFoundException {
    Host host = Host.getHost(0);
    VM vm0 = host.getVM(0);
    VM vm1 = host.getVM(1);
    int locatorPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
    String hostName = NetworkUtils.getServerHostName(vm0.getHost());
    vm0.invoke("Start Locator", () -> startLocator(hostName, locatorPort, ""));
    String locators = getLocatorString(host, locatorPort);
    int serverPort = vm1.invoke("Start BridgeServer", () -> startBridgeServer(new String[] { "a", "b" }, locators));
    ServerLoad expectedLoad = new ServerLoad(2 / 800f, 1 / 800.0f, 0f, 1f);
    ServerLocation expectedLocation = new ServerLocation(NetworkUtils.getServerHostName(host), serverPort);
    Map expected = new HashMap();
    expected.put(expectedLocation, expectedLoad);
    SocketCreatorFactory.setDistributionConfig(new DistributionConfigImpl(new Properties()));
    ClientConnectionResponse response;
    response = (ClientConnectionResponse) new TcpClient().requestToServer(InetAddress.getByName(NetworkUtils.getServerHostName(host)), locatorPort, new ClientConnectionRequest(Collections.EMPTY_SET, null), 10000);
    Assert.assertEquals(expectedLocation, response.getServer());
    response = (ClientConnectionResponse) new TcpClient().requestToServer(InetAddress.getByName(NetworkUtils.getServerHostName(host)), locatorPort, new ClientConnectionRequest(Collections.EMPTY_SET, null), 10000, true);
    Assert.assertEquals(expectedLocation, response.getServer());
    // we expect that the connection load load will be 2 * the loadPerConnection
    vm0.invoke("check Locator Load", () -> checkLocatorLoad(expected));
    QueueConnectionResponse response2;
    response2 = (QueueConnectionResponse) new TcpClient().requestToServer(InetAddress.getByName(NetworkUtils.getServerHostName(host)), locatorPort, new QueueConnectionRequest(null, 2, Collections.EMPTY_SET, null, false), 10000, true);
    Assert.assertEquals(Collections.singletonList(expectedLocation), response2.getServers());
    response2 = (QueueConnectionResponse) new TcpClient().requestToServer(InetAddress.getByName(NetworkUtils.getServerHostName(host)), locatorPort, new QueueConnectionRequest(null, 5, Collections.EMPTY_SET, null, false), 10000, true);
    Assert.assertEquals(Collections.singletonList(expectedLocation), response2.getServers());
    // we expect that the queue load will increase by 2
    expectedLoad.setSubscriptionConnectionLoad(2f);
    vm0.invoke("check Locator Load", () -> checkLocatorLoad(expected));
}
Also used : QueueConnectionRequest(org.apache.geode.cache.client.internal.locator.QueueConnectionRequest) ServerLocation(org.apache.geode.distributed.internal.ServerLocation) HashMap(java.util.HashMap) ClientConnectionRequest(org.apache.geode.cache.client.internal.locator.ClientConnectionRequest) Host(org.apache.geode.test.dunit.Host) Properties(java.util.Properties) ServerLoad(org.apache.geode.cache.server.ServerLoad) ClientConnectionResponse(org.apache.geode.cache.client.internal.locator.ClientConnectionResponse) DistributionConfigImpl(org.apache.geode.distributed.internal.DistributionConfigImpl) TcpClient(org.apache.geode.distributed.internal.tcpserver.TcpClient) VM(org.apache.geode.test.dunit.VM) QueueConnectionResponse(org.apache.geode.cache.client.internal.locator.QueueConnectionResponse) HashMap(java.util.HashMap) Map(java.util.Map) ClientServerTest(org.apache.geode.test.junit.categories.ClientServerTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 34 with DistributionConfigImpl

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

the class SSLConfigurationFactoryJUnitTest method getSSLConfigForComponentALL.

@Test
public void getSSLConfigForComponentALL() throws Exception {
    Properties properties = new Properties();
    properties.setProperty(SSL_ENABLED_COMPONENTS, "all");
    properties.setProperty(SSL_KEYSTORE, "someKeyStore");
    properties.setProperty(SSL_KEYSTORE_PASSWORD, "keystorePassword");
    properties.setProperty(SSL_KEYSTORE_TYPE, "JKS");
    properties.setProperty(SSL_TRUSTSTORE, "someKeyStore");
    properties.setProperty(SSL_TRUSTSTORE_PASSWORD, "keystorePassword");
    properties.setProperty(SSL_DEFAULT_ALIAS, "defaultAlias");
    properties.setProperty(SSL_CIPHERS, "any");
    properties.setProperty(SSL_PROTOCOLS, "any");
    DistributionConfigImpl distributionConfig = new DistributionConfigImpl(properties);
    SSLConfigurationFactory.setDistributionConfig(distributionConfig);
    for (SecurableCommunicationChannel securableCommunicationChannel : SecurableCommunicationChannel.values()) {
        assertSSLConfig(properties, SSLConfigurationFactory.getSSLConfigForComponent(securableCommunicationChannel), securableCommunicationChannel, distributionConfig);
    }
}
Also used : DistributionConfigImpl(org.apache.geode.distributed.internal.DistributionConfigImpl) Properties(java.util.Properties) RestoreSystemProperties(org.junit.contrib.java.lang.system.RestoreSystemProperties) SecurableCommunicationChannel(org.apache.geode.internal.security.SecurableCommunicationChannel) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test) MembershipTest(org.apache.geode.test.junit.categories.MembershipTest)

Example 35 with DistributionConfigImpl

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

the class SSLConfigurationFactoryJUnitTest method getSSLConfigWithCommaDelimitedCiphers.

@Test
public void getSSLConfigWithCommaDelimitedCiphers() throws Exception {
    Properties properties = new Properties();
    properties.setProperty(SSL_ENABLED_COMPONENTS, "all");
    properties.setProperty(SSL_KEYSTORE, "someKeyStore");
    properties.setProperty(SSL_KEYSTORE_PASSWORD, "keystorePassword");
    properties.setProperty(SSL_KEYSTORE_TYPE, "JKS");
    properties.setProperty(SSL_TRUSTSTORE, "someKeyStore");
    properties.setProperty(SSL_TRUSTSTORE_PASSWORD, "keystorePassword");
    properties.setProperty(SSL_DEFAULT_ALIAS, "defaultAlias");
    properties.setProperty(SSL_CIPHERS, "Cipher1,Cipher2");
    properties.setProperty(SSL_PROTOCOLS, "any");
    DistributionConfigImpl distributionConfig = new DistributionConfigImpl(properties);
    SSLConfigurationFactory.setDistributionConfig(distributionConfig);
    for (SecurableCommunicationChannel securableCommunicationChannel : SecurableCommunicationChannel.values()) {
        assertSSLConfig(properties, SSLConfigurationFactory.getSSLConfigForComponent(securableCommunicationChannel), securableCommunicationChannel, distributionConfig);
    }
}
Also used : DistributionConfigImpl(org.apache.geode.distributed.internal.DistributionConfigImpl) Properties(java.util.Properties) RestoreSystemProperties(org.junit.contrib.java.lang.system.RestoreSystemProperties) SecurableCommunicationChannel(org.apache.geode.internal.security.SecurableCommunicationChannel) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test) MembershipTest(org.apache.geode.test.junit.categories.MembershipTest)

Aggregations

DistributionConfigImpl (org.apache.geode.distributed.internal.DistributionConfigImpl)61 Properties (java.util.Properties)59 Test (org.junit.Test)50 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)45 UnitTest (org.apache.geode.test.junit.categories.UnitTest)26 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)23 SecurityTest (org.apache.geode.test.junit.categories.SecurityTest)20 RestoreSystemProperties (org.junit.contrib.java.lang.system.RestoreSystemProperties)11 MembershipTest (org.apache.geode.test.junit.categories.MembershipTest)10 File (java.io.File)6 SecurableCommunicationChannel (org.apache.geode.internal.security.SecurableCommunicationChannel)6 DistributionConfig (org.apache.geode.distributed.internal.DistributionConfig)5 ServiceConfig (org.apache.geode.distributed.internal.membership.gms.ServiceConfig)4 Services (org.apache.geode.distributed.internal.membership.gms.Services)4 RemoteTransportConfig (org.apache.geode.internal.admin.remote.RemoteTransportConfig)4 Before (org.junit.Before)3 Map (java.util.Map)2 LogWriter (org.apache.geode.LogWriter)2 Cache (org.apache.geode.cache.Cache)2 InternalDistributedSystem (org.apache.geode.distributed.internal.InternalDistributedSystem)2