private boolean determineIfSSLEnabledForSSLComponent(final DistributionConfig distributionConfig, final SecurableCommunicationChannel sslEnabledComponent) { if (ArrayUtils.contains(distributionConfig.getSecurableCommunicationChannels(), SecurableCommunicationChannel.ALL)) { return true; } return ArrayUtils.contains(distributionConfig.getSecurableCommunicationChannels(), sslEnabledComponent); }
name = other.getName(); tcpPort = other.getTcpPort(); mcastPort = other.getMcastPort(); mcastTtl = other.getMcastTtl(); socketLeaseTime = other.getSocketLeaseTime(); socketBufferSize = other.getSocketBufferSize(); conserveSockets = other.getConserveSockets(); roles = other.getRoles(); mcastAddress = other.getMcastAddress(); bindAddress = other.getBindAddress(); serverBindAddress = other.getServerBindAddress(); locators = ((DistributionConfigImpl) other).locators; locatorWaitTime = other.getLocatorWaitTime(); remoteLocators = other.getRemoteLocators(); startLocator = other.getStartLocator(); startLocatorPort = ((DistributionConfigImpl) other).startLocatorPort; deployWorkingDir = other.getDeployWorkingDir(); logFile = other.getLogFile(); logLevel = other.getLogLevel(); statisticSamplingEnabled = other.getStatisticSamplingEnabled(); threadMonitorEnabled = other.getThreadMonitorEnabled(); threadMonitorInterval = other.getThreadMonitorInterval(); threadMonitorTimeLimit = other.getThreadMonitorTimeLimit(); statisticSampleRate = other.getStatisticSampleRate(); statisticArchiveFile = other.getStatisticArchiveFile(); ackWaitThreshold = other.getAckWaitThreshold(); ackForceDisconnectThreshold = other.getAckSevereAlertThreshold(); cacheXmlFile = other.getCacheXmlFile(); archiveDiskSpaceLimit = other.getArchiveDiskSpaceLimit();
@Override public Throwable generateCreationStack(final DistributionConfig config) { StringBuilder sb = new StringBuilder(); String[] validAttributeNames = config.getAttributeNames(); for (String attName : validAttributeNames) { Object actualAtt = config.getAttributeObject(attName); String actualAttStr = actualAtt.toString(); sb.append(" "); sb.append(attName); sb.append("=\""); if (actualAtt.getClass().isArray()) { actualAttStr = InternalDistributedSystem.arrayToString(actualAtt); } sb.append(actualAttStr); sb.append("\""); sb.append("\n"); } return new Throwable( "Creating distributed system with the following configuration:\n" + sb.toString()); } });
/** * Constructs an internal system config given an existing one. * * @param dc an existing system configuration. */ public DistributionConfigSnapshot(DistributionConfig dc) { super(dc); modifiable = new HashSet(20); String[] attNames = dc.getAttributeNames(); for (int i = 0; i < attNames.length; i++) { if (dc.isAttributeModifiable(attNames[i])) { modifiable.add(attNames[i]); } } }
this.mcastAddress = InetAddressUtil.toString(distConfig.getMcastAddress()); this.mcastPort = distConfig.getMcastPort(); this.locators = distConfig.getLocators(); this.membershipPortRange = getMembershipPortRangeString(distConfig.getMembershipPortRange()); this.systemName = distConfig.getName(); this.sslEnabled = distConfig.getClusterSSLEnabled(); this.sslCiphers = distConfig.getClusterSSLCiphers(); this.sslProtocols = distConfig.getClusterSSLProtocols(); this.sslAuthenticationRequired = distConfig.getClusterSSLRequireAuthentication(); this.logFile = distConfig.getLogFile().getPath(); this.logLevel = LogWriterImpl.levelToString(distConfig.getLogLevel()); this.logDiskSpaceLimit = distConfig.getLogDiskSpaceLimit(); this.logFileSizeLimit = distConfig.getLogFileSizeLimit(); basicSetBindAddress(distConfig.getBindAddress()); this.tcpPort = distConfig.getTcpPort(); this.disableTcp = distConfig.getDisableTcp(); this.serverBindAddress = distConfig.getServerBindAddress(); this.enableNetworkPartitionDetection = distConfig.getEnableNetworkPartitionDetection(); this.memberTimeout = distConfig.getMemberTimeout(); this.refreshInterval = DistributedSystemConfig.DEFAULT_REFRESH_INTERVAL; this.gfSecurityProperties = (Properties) distConfig.getSSLProperties().clone();
gemFirePropertyData.setMemberName(config.getName()); gemFirePropertyData.setMemberGroups(memberGroups); gemFirePropertyData.setMcastPort(config.getMcastPort()); gemFirePropertyData.setMcastAddress(config.getMcastAddress().getHostAddress()); gemFirePropertyData.setBindAddress(config.getBindAddress()); gemFirePropertyData.setTcpPort(config.getTcpPort()); gemFirePropertyData.setCacheXMLFile(config.getCacheXmlFile().getAbsolutePath()); gemFirePropertyData.setConfigFile(configFile); gemFirePropertyData.setMcastTTL(config.getMcastTtl()); gemFirePropertyData.setServerBindAddress(config.getServerBindAddress()); gemFirePropertyData.setLocators(config.getLocators()); gemFirePropertyData.setStartLocator(config.getStartLocator()); gemFirePropertyData.setLogFile(config.getLogFile().getAbsolutePath()); gemFirePropertyData.setLogLevel(config.getLogLevel()); gemFirePropertyData.setStatisticSamplingEnabled(config.getStatisticSamplingEnabled()); gemFirePropertyData.setStatisticArchiveFile(config.getStatisticArchiveFile().getAbsolutePath()); gemFirePropertyData.setIncludeFile(includeFile); gemFirePropertyData.setAckWaitThreshold(config.getAckWaitThreshold()); gemFirePropertyData.setAckSevereAlertThreshold(config.getAckSevereAlertThreshold()); gemFirePropertyData.setArchiveFileSizeLimit(config.getArchiveFileSizeLimit()); gemFirePropertyData.setArchiveDiskSpaceLimit(config.getArchiveDiskSpaceLimit()); gemFirePropertyData.setLogFileSizeLimit(config.getLogFileSizeLimit()); gemFirePropertyData.setLogDiskSpaceLimit(config.getLogDiskSpaceLimit()); gemFirePropertyData.setClusterSSLEnabled(config.getClusterSSLEnabled());
if (config.getBindAddress() == null) { this.bindAddress = DistributionConfig.DEFAULT_BIND_ADDRESS; } else { this.bindAddress = config.getBindAddress(); this.tcpPort = config.getTcpPort(); this.membershipPortRange = getMembershipPortRangeString(config.getMembershipPortRange()); this.sslConfig = new SSLConfig(); String initialHosts = config.getLocators(); if (initialHosts == null) { initialHosts = ""; if (config.getMcastPort() > 0) { this.mcastId = new DistributionLocatorId(config.getMcastAddress(), config.getMcastPort(), config.getBindAddress(), this.sslConfig); this.mcastEnabled = true; } else { this.tcpDisabled = config.getDisableTcp(); this.disableAutoReconnect = config.getDisableAutoReconnect();
SSLConfig sslConfig = createSSLConfig(distributionConfig, sslEnabledComponent); SecurableCommunicationChannel[] sslEnabledComponents = distributionConfig.getSecurableCommunicationChannels(); if (sslEnabledComponents.length == 0) { sslConfig = configureLegacyClusterSSL(distributionConfig, sslConfig); sslConfig = setAliasForComponent(sslConfig, distributionConfig.getClusterSSLAlias()); } else { sslConfig = configureLegacyClusterSSL(distributionConfig, sslConfig); sslConfig = setAliasForComponent(sslConfig, distributionConfig.getLocatorSSLAlias()); sslConfig = setAliasForComponent(sslConfig, distributionConfig.getServerSSLAlias()); } else { sslConfig = configureLegacyServerSSL(distributionConfig, sslConfig); sslConfig = setAliasForComponent(sslConfig, distributionConfig.getGatewaySSLAlias()); } else { sslConfig = configureLegacyGatewaySSL(distributionConfig, sslConfig); sslConfig = setAliasForComponent(sslConfig, distributionConfig.getHTTPServiceSSLAlias()); sslConfig.setRequireAuth(distributionConfig.getSSLWebRequireAuthentication()); } else { sslConfig = configureLegacyHttpServiceSSL(distributionConfig, sslConfig); sslConfig = setAliasForComponent(sslConfig, distributionConfig.getJMXSSLAlias()); } else { sslConfig = configureLegacyJMXSSL(distributionConfig, sslConfig);
if (dc.getMcastPort() != 0 && StringUtils.isBlank(dc.getLocators()) && StringUtils.isBlank(dc.getStartLocator())) { throw new GemFireConfigException("Multicast cannot be configured for a non-distributed cache." + " Please configure the locator services for this cache using " + LOCATORS + " or " services.getMessenger().addHandler(NetworkPartitionMessage.class, this); int ackCollectionTimeout = dc.getMemberTimeout() * 2 * 12437 / 10000; if (ackCollectionTimeout < 1500) { ackCollectionTimeout = 1500; services.getConfig().getDistributionConfig().getEnableNetworkPartitionDetection(); String bindAddr = dconfig.getBindAddress(); locators = GMSUtil.parseLocators(dconfig.getLocators(), bindAddr); if (logger.isDebugEnabled()) { logger.debug("Parsed locators are {}", locators);
String serverBindAddress = config.getServerBindAddress(); MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean(); memberInfo.setGroups(config.getGroups()); memberInfo.setLogFilePath(config.getLogFile().getCanonicalPath()); memberInfo.setStatArchiveFilePath(config.getStatisticArchiveFile().getCanonicalPath()); memberInfo.setWorkingDirPath(System.getProperty("user.dir")); memberInfo.setCacheXmlFilePath(config.getCacheXmlFile().getCanonicalPath()); memberInfo.setLocators(config.getLocators()); memberInfo.setServerBindAddress(serverBindAddress); memberInfo.setOffHeapMemorySize(config.getOffHeapMemorySize());
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 */} }
SecurityServiceFactory.create(this.system.getConfig().getSecurityProps(), cacheConfig); this.system.setSecurityService(this.securityService); } else { boolean disableJmx = systemConfig.getDisableJmx(); if (disableJmx) { logger.info("Running with JMX disabled."); CachePerfStats.enableClockStats = this.system.getConfig().getEnableTimeStatistics(); if (XML_PARAMETERIZATION_ENABLED) { Properties userProps = this.system.getConfig().getUserDefinedProps(); if (userProps != null && !userProps.isEmpty()) { this.resolver = new CacheXmlPropertyResolver(false, this.diskMonitor = new DiskStoreMonitor(systemConfig.getLogFile()); httpService = new HttpService(systemConfig.getHttpServiceBindAddress(), systemConfig.getHttpServicePort(), SSLConfigurationFactory .getSSLConfigForComponent(systemConfig, SecurableCommunicationChannel.WEB));
boolean isBindAddress = dc.getBindAddress() != null; try { int port = Integer.getInteger("tcpServerPort", 0).intValue(); if (port == 0) { port = dc.getTcpPort(); props.setProperty("p2p.shareSockets", String.valueOf(dc.getConserveSockets())); if (dc.getSocketBufferSize() != DistributionConfig.DEFAULT_SOCKET_BUFFER_SIZE) { props.setProperty("p2p.tcpBufferSize", String.valueOf(dc.getSocketBufferSize())); props.setProperty("p2p.idleConnectionTimeout", String.valueOf(dc.getSocketLeaseTime())); int[] range = dc.getMembershipPortRange(); props.setProperty("membership_port_range_start", "" + range[0]); props.setProperty("membership_port_range_end", "" + range[1]);
InternalDistributedSystem system = mock(InternalDistributedSystem.class); DistributionConfig config = mock(DistributionConfig.class); when(config.getSecurableCommunicationChannels()) .thenReturn(new SecurableCommunicationChannel[] {SecurableCommunicationChannel.ALL}); ClusterDistributionManager distributionManager = mock(ClusterDistributionManager.class); member = new InternalDistributedMember("localhost", 5555); when(config.getCacheXmlFile()).thenReturn(new File("")); when(config.getDeployWorkingDir()).thenReturn(new File("."));
if (this.config.getHttpServicePort() == 0) { setStatusMessage(managerBean, "Embedded HTTP server configured not to start (http-service-port=0) or (jmx-manager-http-port=0)"); String pwFile = this.config.getJmxManagerPasswordFile(); if (securityService.isIntegratedSecurity() || StringUtils.isNotBlank(pwFile)) { System.setProperty("spring.profiles.active", "pulse.authentication.gemfire"); if (agentUtil.isAnyWarFileAvailable(adminRestWar, pulseWar)) { final String bindAddress = this.config.getHttpServiceBindAddress(); final int port = this.config.getHttpServicePort(); System.setProperty(PULSE_HOST_PROP, "" + config.getJmxManagerBindAddress()); System.setProperty(PULSE_PORT_PROP, "" + config.getJmxManagerPort());
public void startLocator() { try { // this will start a jmx manager and admin rest service by default locator = (InternalLocator) startLocatorAndDS(memberPort, null, properties); } catch (IOException e) { throw new UncheckedIOException(e); } // memberPort is by default zero, which translates to "randomly select an available port," // which is why it is updated here after being specified above. memberPort = locator.getPort(); DistributionConfig config = locator.getConfig(); jmxPort = config.getJmxManagerPort(); httpPort = config.getHttpServicePort(); if (config.getEnableClusterConfiguration()) { await() .untilAsserted(() -> assertTrue(locator.isSharedConfigurationRunning())); } }
final long msAW = this.owner.getDM().getConfig().getAckWaitThreshold() * 1000L; final long msSA = this.owner.getDM().getConfig().getAckSevereAlertThreshold() * 1000L; ackTimeoutTask = new SystemTimer.SystemTimerTask() { @Override
@Test public void putThrowsIOExceptionOnMissingRegion() throws Exception { thrown.expect(IOException.class); // Mocks with minimal implementation to ensure code path through PutMessage.toData EntryEventImpl mockEvent = mock(EntryEventImpl.class); when(mockEvent.isPossibleDuplicate()).thenReturn(false); when(mockEvent.getEventId()).thenReturn(mock(EventID.class)); when(mockEvent.getOperation()).thenReturn(Operation.UPDATE); when(mockEvent.getDeltaBytes()).thenReturn(new byte[] {}); DistributionConfig mockDistributionConfig = mock(DistributionConfig.class); when(mockDistributionConfig.getDeltaPropagation()).thenReturn(true); InternalDistributedSystem mockInternalDistributedSystem = mock(InternalDistributedSystem.class); when(mockInternalDistributedSystem.getConfig()).thenReturn(mockDistributionConfig); // Construct a put with minimum configuration needed to reach region check. PutMessage put = new PutMessage(new HashSet(), false, UNKNOWN_REGION, null, mockEvent, 0, false, false, null, false); put.setSendDelta(true); put.setInternalDs(mockInternalDistributedSystem); put.toData(new DataOutputStream(new ByteArrayOutputStream())); } }
/** * Return the time in sec to wait before sending an alert while waiting for ack replies. Note that * the ack wait threshold may change at runtime, so we have to consult the system every time. */ protected int getAckWaitThreshold() { return this.system.getConfig().getAckWaitThreshold(); }
public static String getBindAddressForHttpService(DistributionConfig config) { String bindAddress = config.getHttpServiceBindAddress(); if (StringUtils.isNotBlank(bindAddress)) return bindAddress; bindAddress = config.getServerBindAddress(); if (StringUtils.isNotBlank(bindAddress)) return bindAddress; bindAddress = config.getBindAddress(); if (StringUtils.isNotBlank(bindAddress)) return bindAddress; try { bindAddress = SocketCreator.getLocalHost().getHostAddress(); logger.info("RestAgent.getBindAddressForHttpService.localhost: " + SocketCreator.getLocalHost().getHostAddress()); } catch (UnknownHostException e) { logger.error("LocalHost could not be found.", e); } return bindAddress; }