Search in sources :

Example 11 with DistributionConfig

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

the class ClientSocketFactoryIntegrationTest method setUp.

@Before
public void setUp() throws Exception {
    System.setProperty(GEMFIRE_PREFIX + "clientSocketFactory", TSocketFactory.class.getName());
    Properties properties = new Properties();
    properties.setProperty(CLUSTER_SSL_ENABLED, "false");
    DistributionConfig distributionConfig = new DistributionConfigImpl(properties);
    SocketCreatorFactory.setDistributionConfig(distributionConfig);
}
Also used : DistributionConfig(org.apache.geode.distributed.internal.DistributionConfig) DistributionConfigImpl(org.apache.geode.distributed.internal.DistributionConfigImpl) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) RestoreSystemProperties(org.junit.contrib.java.lang.system.RestoreSystemProperties) Before(org.junit.Before)

Example 12 with DistributionConfig

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

the class Fakes method cache.

/**
   * A fake cache, which contains a fake distributed system, distribution manager, etc.
   */
public static GemFireCacheImpl cache() {
    GemFireCacheImpl cache = mock(GemFireCacheImpl.class);
    InternalDistributedSystem system = mock(InternalDistributedSystem.class);
    DistributionConfig config = mock(DistributionConfig.class);
    DistributionManager distributionManager = mock(DistributionManager.class);
    CancelCriterion systemCancelCriterion = mock(CancelCriterion.class);
    DSClock clock = mock(DSClock.class);
    LogWriter logger = mock(LogWriter.class);
    Statistics stats = mock(Statistics.class);
    InternalDistributedMember member;
    member = new InternalDistributedMember("localhost", 5555);
    when(config.getCacheXmlFile()).thenReturn(new File(""));
    when(config.getDeployWorkingDir()).thenReturn(new File("."));
    when(cache.getDistributedSystem()).thenReturn(system);
    when(cache.getInternalDistributedSystem()).thenReturn(system);
    when(cache.getSystem()).thenReturn(system);
    when(cache.getMyId()).thenReturn(member);
    when(cache.getDistributionManager()).thenReturn(distributionManager);
    when(cache.getCancelCriterion()).thenReturn(systemCancelCriterion);
    when(cache.getCachePerfStats()).thenReturn(mock(CachePerfStats.class));
    when(system.getDistributedMember()).thenReturn(member);
    when(system.getConfig()).thenReturn(config);
    when(system.getDistributionManager()).thenReturn(distributionManager);
    when(system.getCancelCriterion()).thenReturn(systemCancelCriterion);
    when(system.getClock()).thenReturn(clock);
    when(system.getLogWriter()).thenReturn(logger);
    when(system.createAtomicStatistics(any(), any(), anyLong())).thenReturn(stats);
    when(system.createAtomicStatistics(any(), any())).thenReturn(stats);
    when(distributionManager.getId()).thenReturn(member);
    when(distributionManager.getDistributionManagerId()).thenReturn(member);
    when(distributionManager.getConfig()).thenReturn(config);
    when(distributionManager.getSystem()).thenReturn(system);
    when(distributionManager.getCancelCriterion()).thenReturn(systemCancelCriterion);
    return cache;
}
Also used : DistributionConfig(org.apache.geode.distributed.internal.DistributionConfig) DSClock(org.apache.geode.distributed.internal.DSClock) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) LogWriter(org.apache.geode.LogWriter) CancelCriterion(org.apache.geode.CancelCriterion) CachePerfStats(org.apache.geode.internal.cache.CachePerfStats) GemFireCacheImpl(org.apache.geode.internal.cache.GemFireCacheImpl) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) DistributionManager(org.apache.geode.distributed.internal.DistributionManager) Statistics(org.apache.geode.Statistics) File(java.io.File)

Example 13 with DistributionConfig

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

the class LogWriterFactory method createLogWriterLogger.

/**
   * Creates the log writer for a distributed system based on the system's parsed configuration. The
   * initial banner and messages are also entered into the log by this method.
   * 
   * @param isLoner Whether the distributed system is a loner or not
   * @param isSecure Whether a logger for security related messages has to be created
   * @param config The DistributionConfig for the target distributed system
   * @param logConfig if true log the configuration
   */
public static InternalLogWriter createLogWriterLogger(final boolean isLoner, final boolean isSecure, final LogConfig config, final boolean logConfig) {
    // if isSecurity then use "org.apache.geode.security" else use "org.apache.geode"
    String name = null;
    if (isSecure) {
        name = LogService.SECURITY_LOGGER_NAME;
    } else {
        name = LogService.MAIN_LOGGER_NAME;
    }
    // create the LogWriterLogger
    final LogWriterLogger logger = LogService.createLogWriterLogger(name, config.getName(), isSecure);
    if (isSecure) {
        logger.setLogWriterLevel(((DistributionConfig) config).getSecurityLogLevel());
    } else {
        boolean defaultSource = false;
        if (config instanceof DistributionConfig) {
            ConfigSource source = ((DistributionConfig) config).getConfigSource(LOG_LEVEL);
            if (source == null) {
                defaultSource = true;
            }
        }
        if (!defaultSource) {
            // LOG: fix bug #51709 by not setting if log-level was not specified
            // LOG: let log4j2.xml specify log level which defaults to INFO
            logger.setLogWriterLevel(config.getLogLevel());
        }
    }
    // log the banner
    if (!Boolean.getBoolean(InternalLocator.INHIBIT_DM_BANNER)) {
        if (// avoid filling up logs
        InternalDistributedSystem.getReconnectAttemptCounter() == 0 && // during auto-reconnect
        !// && !isLoner /* do this on a loner to fix bug 35602 */
        isSecure) {
            // LOG:CONFIG:
            logger.info(LogMarker.CONFIG, Banner.getString(null));
        }
    } else {
        logger.debug("skipping banner - " + InternalLocator.INHIBIT_DM_BANNER + " is set to true");
    }
    // log the config
    if (logConfig) {
        if (!isLoner) {
            // LOG:CONFIG: changed from config to info
            logger.info(LogMarker.CONFIG, LocalizedMessage.create(LocalizedStrings.InternalDistributedSystem_STARTUP_CONFIGURATIONN_0, config.toLoggerString()));
        }
    }
    return logger;
}
Also used : ConfigSource(org.apache.geode.internal.ConfigSource) DistributionConfig(org.apache.geode.distributed.internal.DistributionConfig) LogWriterLogger(org.apache.geode.internal.logging.log4j.LogWriterLogger)

Example 14 with DistributionConfig

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

the class PoolImpl method isDurableClient.

public boolean isDurableClient() {
    boolean isDurable = false;
    InternalDistributedSystem system = InternalDistributedSystem.getAnyInstance();
    DistributionConfig config = system.getConfig();
    String durableClientId = config.getDurableClientId();
    isDurable = durableClientId != null && durableClientId.length() > 0;
    return isDurable;
}
Also used : DistributionConfig(org.apache.geode.distributed.internal.DistributionConfig) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem)

Example 15 with DistributionConfig

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

the class BucketAdvisor method waitForNewPrimary.

/**
   * This method was split out from getPrimary() due to bug #40639 and is only intended to be called
   * from within that method.
   * 
   * @see #getPrimary()
   * @return the new primary
   */
private InternalDistributedMember waitForNewPrimary() {
    DM dm = this.regionAdvisor.getDistributionManager();
    DistributionConfig config = dm.getConfig();
    // failure detection period
    long timeout = config.getMemberTimeout() * 3;
    // plus time for a new member to become primary
    timeout += Long.getLong(DistributionConfig.GEMFIRE_PREFIX + "BucketAdvisor.getPrimaryTimeout", 15 * 1000);
    InternalDistributedMember newPrimary = waitForPrimaryMember(timeout);
    return newPrimary;
}
Also used : DistributionConfig(org.apache.geode.distributed.internal.DistributionConfig) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) DM(org.apache.geode.distributed.internal.DM)

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