Search in sources :

Example 36 with DistributionConfig

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

the class GMSMembershipManager method init.

@Override
public void init(Services services) {
    this.services = services;
    Assert.assertTrue(services != null);
    DistributionConfig config = services.getConfig().getDistributionConfig();
    RemoteTransportConfig transport = services.getConfig().getTransport();
    this.membershipCheckTimeout = config.getSecurityPeerMembershipTimeout();
    this.wasReconnectingSystem = transport.getIsReconnectingDS();
    // cache these settings for use in send()
    this.mcastEnabled = transport.isMcastEnabled();
    this.tcpDisabled = transport.isTcpDisabled();
    if (!this.tcpDisabled) {
        dcReceiver = new MyDCReceiver(listener);
    }
    surpriseMemberTimeout = Math.max(20 * DistributionConfig.DEFAULT_MEMBER_TIMEOUT, 20 * config.getMemberTimeout());
    surpriseMemberTimeout = Integer.getInteger(DistributionConfig.GEMFIRE_PREFIX + "surprise-member-timeout", surpriseMemberTimeout).intValue();
}
Also used : DistributionConfig(org.apache.geode.distributed.internal.DistributionConfig) RemoteTransportConfig(org.apache.geode.internal.admin.remote.RemoteTransportConfig)

Example 37 with DistributionConfig

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

the class GMSMembershipManager method start.

@Override
public void start() {
    DistributionConfig config = services.getConfig().getDistributionConfig();
    int dcPort = 0;
    if (!tcpDisabled) {
        directChannel = new DirectChannel(this, dcReceiver, config);
        dcPort = directChannel.getPort();
    }
    services.getMessenger().getMemberID().setDirectChannelPort(dcPort);
}
Also used : DistributionConfig(org.apache.geode.distributed.internal.DistributionConfig) DirectChannel(org.apache.geode.distributed.internal.direct.DirectChannel)

Example 38 with DistributionConfig

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

the class GemFireCacheImpl method requestSharedConfiguration.

/**
   * Request the shared configuration from the locator(s) which have the Cluster config service
   * running
   */
private ConfigurationResponse requestSharedConfiguration() {
    final DistributionConfig config = this.system.getConfig();
    if (!(this.dm instanceof DistributionManager)) {
        return null;
    }
    // do nothing if this vm is/has locator or this is a client
    if (this.dm.getDMType() == DistributionManager.LOCATOR_DM_TYPE || this.isClient || Locator.getLocator() != null) {
        return null;
    }
    // can't simply return null if server is not using shared configuration, since we need to find
    // out
    // if the locator is running in secure mode or not, if yes, then we need to throw an exception
    // if server is not using cluster config
    Map<InternalDistributedMember, Collection<String>> scl = getDistributionManager().getAllHostedLocatorsWithSharedConfiguration();
    // then do not make requests to the locators
    if (scl.isEmpty()) {
        logger.info(LocalizedMessage.create(LocalizedStrings.GemFireCache_NO_LOCATORS_FOUND_WITH_SHARED_CONFIGURATION));
        return null;
    }
    List<String> locatorConnectionStrings = getSharedConfigLocatorConnectionStringList();
    try {
        ConfigurationResponse response = ClusterConfigurationLoader.requestConfigurationFromLocators(this.system.getConfig(), locatorConnectionStrings);
        // log the configuration received from the locator
        logger.info(LocalizedMessage.create(LocalizedStrings.GemFireCache_RECEIVED_SHARED_CONFIGURATION_FROM_LOCATORS));
        logger.info(response.describeConfig());
        Configuration clusterConfig = response.getRequestedConfiguration().get(ClusterConfigurationService.CLUSTER_CONFIG);
        Properties clusterSecProperties = clusterConfig == null ? new Properties() : clusterConfig.getGemfireProperties();
        // If not using shared configuration, return null or throw an exception is locator is secured
        if (!config.getUseSharedConfiguration()) {
            if (clusterSecProperties.containsKey(ConfigurationProperties.SECURITY_MANAGER)) {
                throw new GemFireConfigException(LocalizedStrings.GEMFIRE_CACHE_SECURITY_MISCONFIGURATION_2.toLocalizedString());
            } else {
                logger.info(LocalizedMessage.create(LocalizedStrings.GemFireCache_NOT_USING_SHARED_CONFIGURATION));
                return null;
            }
        }
        Properties serverSecProperties = config.getSecurityProps();
        // check for possible mis-configuration
        if (isMisConfigured(clusterSecProperties, serverSecProperties, ConfigurationProperties.SECURITY_MANAGER) || isMisConfigured(clusterSecProperties, serverSecProperties, ConfigurationProperties.SECURITY_POST_PROCESSOR)) {
            throw new GemFireConfigException(LocalizedStrings.GEMFIRE_CACHE_SECURITY_MISCONFIGURATION.toLocalizedString());
        }
        return response;
    } catch (ClusterConfigurationNotAvailableException e) {
        throw new GemFireConfigException(LocalizedStrings.GemFireCache_SHARED_CONFIGURATION_NOT_AVAILABLE.toLocalizedString(), e);
    } catch (UnknownHostException e) {
        throw new GemFireConfigException(e.getLocalizedMessage(), e);
    }
}
Also used : ConfigurationResponse(org.apache.geode.management.internal.configuration.messages.ConfigurationResponse) Configuration(org.apache.geode.management.internal.configuration.domain.Configuration) UnknownHostException(java.net.UnknownHostException) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) DistributionConfig(org.apache.geode.distributed.internal.DistributionConfig) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) GemFireConfigException(org.apache.geode.GemFireConfigException) Collection(java.util.Collection) ClusterConfigurationNotAvailableException(org.apache.geode.internal.process.ClusterConfigurationNotAvailableException) DistributionManager(org.apache.geode.distributed.internal.DistributionManager)

Example 39 with DistributionConfig

use of org.apache.geode.distributed.internal.DistributionConfig 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 40 with DistributionConfig

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

the class GemFireMemberStatus method initializeDistributedSystem.

protected void initializeDistributedSystem(DistributedSystem distributedSystem) {
    InternalDistributedSystem ids = (InternalDistributedSystem) distributedSystem;
    setMemberId(ids.getMemberId());
    DistributionConfig config = ids.getConfig();
    setMemberName(config.getName());
    setMcastPort(config.getMcastPort());
    setMcastAddress(config.getMcastAddress());
    String bindAddress = config.getBindAddress();
    setBindAddress(bindAddress);
    setLocators(config.getLocators());
    setUpTime(System.currentTimeMillis() - ids.getStartTime());
    try {
        setHostAddress((bindAddress != null && bindAddress.length() > 0) ? InetAddress.getByName(bindAddress) : SocketCreator.getLocalHost());
    } catch (IOException e) {
    /* ignore - leave null host address */
    }
}
Also used : DistributionConfig(org.apache.geode.distributed.internal.DistributionConfig) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) IOException(java.io.IOException)

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