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);
}
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;
}
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;
}
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;
}
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;
}
Aggregations