/** * Sets a property with given name to the specified value. The property is only set if the value is not null. * * @param name the name of the property to set. * @param value the value to set the property to. * @return a reference to this {@link PropertiesBuilder}. * @see #setProperty(String, String) */ public PropertiesBuilder setProperty(String name, Object value) { return value != null ? setProperty(name, value.toString()) : this; }
@Override protected Properties toGemFireProperties(Map<String, Object> annotationAttributes) { PropertiesBuilder gemfireProperties = PropertiesBuilder.create(); gemfireProperties.setPropertyIfNotDefault("log-disk-space-limit", resolveProperty(loggingProperty("log-disk-space-limit"), (Integer) annotationAttributes.get("logDiskSpaceLimit")), DEFAULT_LOG_DISK_SPACE_LIMIT); gemfireProperties.setProperty("log-file", resolveProperty(loggingProperty("log-file"), (String) annotationAttributes.get("logFile"))); gemfireProperties.setPropertyIfNotDefault("log-file-size-limit", resolveProperty(loggingProperty("log-file-size-limit"), (Integer) annotationAttributes.get("logFileSizeLimit")), DEFAULT_LOG_FILE_SIZE_LIMIT); gemfireProperties.setPropertyIfNotDefault("log-level", resolveProperty(loggingProperty("level"), (String) annotationAttributes.get("logLevel")), DEFAULT_LOG_LEVEL); return gemfireProperties.build(); } }
/** * Sets a property with given name to the specified value. The property is only set if the value is not null. * * @param name the name of the property to set. * @param value the value to set the property to. * @return a reference to this {@link PropertiesBuilder}. * @see #setProperty(String, String) */ public PropertiesBuilder setProperty(String name, Object value) { return value != null ? setProperty(name, value.toString()) : this; }
@Override protected Properties toGemFireProperties(Map<String, Object> annotationAttributes) { PropertiesBuilder gemfireProperties = PropertiesBuilder.create(); gemfireProperties.setPropertyIfNotDefault("log-disk-space-limit", resolveProperty(loggingProperty("log-disk-space-limit"), (Integer) annotationAttributes.get("logDiskSpaceLimit")), DEFAULT_LOG_DISK_SPACE_LIMIT); gemfireProperties.setProperty("log-file", resolveProperty(loggingProperty("log-file"), (String) annotationAttributes.get("logFile"))); gemfireProperties.setPropertyIfNotDefault("log-file-size-limit", resolveProperty(loggingProperty("log-file-size-limit"), (Integer) annotationAttributes.get("logFileSizeLimit")), DEFAULT_LOG_FILE_SIZE_LIMIT); gemfireProperties.setPropertyIfNotDefault("log-level", resolveProperty(loggingProperty("level"), (String) annotationAttributes.get("logLevel")), DEFAULT_LOG_LEVEL); return gemfireProperties.build(); } }
/** * Sets the named property to the given {@literal value} if the {@literal defaultValue} is not null * and {@literal value} is not equal to {@literal defaultValue}. * * @param <T> Class type of the property value. * @param name name of the property to set. * @param value value to set for the property. * @param defaultValue default value of the property to compare with the given value * when determining whether to set the property. * @return a reference to this {@link PropertiesBuilder}. * @see #setProperty(String, Object) */ public <T> PropertiesBuilder setPropertyIfNotDefault(String name, Object value, T defaultValue) { return defaultValue == null || !defaultValue.equals(value) ? setProperty(name, value) : this; }
gemfireProperties.setProperty("statistic-sampling-enabled", resolveProperty(statsProperty("sampling-enabled"), true)); (Integer) annotationAttributes.get("archiveDiskSpaceLimit")), DEFAULT_ARCHIVE_DISK_SPACE_LIMIT); gemfireProperties.setProperty("statistic-archive-file", resolveProperty(statsProperty("archive-file"), (String) annotationAttributes.get("archiveFile"))); (Integer) annotationAttributes.get("archiveFileSizeLimit")), DEFAULT_ARCHIVE_FILE_SIZE_LIMIT); gemfireProperties.setProperty("enable-time-statistics", resolveProperty(statsProperty("enable-time-statistics"), Boolean.TRUE.equals(annotationAttributes.get("enableTimeStatistics"))));
/** * Sets the named property to the given {@literal value} if the {@literal defaultValue} is not null * and {@literal value} is not equal to {@literal defaultValue}. * * @param <T> Class type of the property value. * @param name name of the property to set. * @param value value to set for the property. * @param defaultValue default value of the property to compare with the given value * when determining whether to set the property. * @return a reference to this {@link PropertiesBuilder}. * @see #setProperty(String, Object) */ public <T> PropertiesBuilder setPropertyIfNotDefault(String name, Object value, T defaultValue) { return defaultValue == null || !defaultValue.equals(value) ? setProperty(name, value) : this; }
/** * Sets the named property to the given array of object values. The property is only set * if the array of object value is not null or empty. * * @param name name of the property to set. * @param values array of object values used as the property's value. * @return a reference to this {@link PropertiesBuilder} * @see org.springframework.util.StringUtils#arrayToCommaDelimitedString(Object[]) * @see #setProperty(String, String) */ public PropertiesBuilder setProperty(String name, Object[] values) { return !ObjectUtils.isEmpty(values) ? setProperty(name, StringUtils.arrayToCommaDelimitedString(values)) : this; }
/** * Sets the named property to the given array of object values. The property is only set * if the array of object value is not null or empty. * * @param name name of the property to set. * @param values array of object values used as the property's value. * @return a reference to this {@link PropertiesBuilder} * @see org.springframework.util.StringUtils#arrayToCommaDelimitedString(Object[]) * @see #setProperty(String, String) */ public PropertiesBuilder setProperty(String name, Object[] values) { return !ObjectUtils.isEmpty(values) ? setProperty(name, StringUtils.arrayToCommaDelimitedString(values)) : this; }
private void configureComponentCertificateAliases(AnnotationAttributes annotationAttributes, PropertiesBuilder gemfireProperties) { AnnotationAttributes[] componentCertificateAliases = annotationAttributes.getAnnotationArray("componentCertificateAliases"); Arrays.stream(componentCertificateAliases).forEach(aliasAttributes -> { EnableSsl.Component component = aliasAttributes.getEnum("component"); String alias = aliasAttributes.getString("alias"); gemfireProperties.setProperty(String.format("ssl-%s-alias", component), alias); }); Arrays.stream(EnableSsl.Component.values()).forEach(component -> { String propertyNameSuffix = String.format("certificate.alias.%s", component); Optional.ofNullable(resolveProperty(sslProperty(propertyNameSuffix), "")) .filter(StringUtils::hasText) .ifPresent(alias -> gemfireProperties.setProperty(String.format("ssl-%s-alias", component), StringUtils.trimWhitespace(alias))); }); } }
/** * Converts the App Starter properties into Geode native SSL properties * @param sslProperties App starter properties. * @return Returns the geode native SSL properties. */ private Properties toGeodeSslProperties(GemfireSslProperties sslProperties) { PropertiesBuilder pb = new PropertiesBuilder(); // locator - SSL communication with and between locators // server - SSL communication between clients and servers pb.setProperty("ssl-enabled-components", "server,locator"); pb.setProperty("ssl-keystore", this.resolveRemoteStore(sslProperties.getKeystoreUri(), sslProperties.getUserHomeDirectory(), GemfireSslProperties.LOCAL_KEYSTORE_FILE_NAME)); pb.setProperty("ssl-keystore-password", sslProperties.getSslKeystorePassword()); pb.setProperty("ssl-keystore-type", sslProperties.getKeystoreType()); pb.setProperty("ssl-truststore", this.resolveRemoteStore(sslProperties.getTruststoreUri(), sslProperties.getUserHomeDirectory(), GemfireSslProperties.LOCAL_TRUSTSTORE_FILE_NAME)); pb.setProperty("ssl-truststore-password", sslProperties.getSslTruststorePassword()); pb.setProperty("ssl-truststore-type", sslProperties.getTruststoreType()); pb.setProperty("ssl-ciphers", sslProperties.getCiphers()); return pb.build(); }
private void configureComponentCertificateAliases(AnnotationAttributes annotationAttributes, PropertiesBuilder gemfireProperties) { AnnotationAttributes[] componentCertificateAliases = annotationAttributes.getAnnotationArray("componentCertificateAliases"); Arrays.stream(componentCertificateAliases).forEach(aliasAttributes -> { EnableSsl.Component component = aliasAttributes.getEnum("component"); String alias = aliasAttributes.getString("alias"); gemfireProperties.setProperty(String.format("ssl-%s-alias", component), alias); }); Arrays.stream(EnableSsl.Component.values()).forEach(component -> { String propertyNameSuffix = String.format("certificate.alias.%s", component); Optional.ofNullable(resolveProperty(sslProperty(propertyNameSuffix), "")) .filter(StringUtils::hasText) .ifPresent(alias -> gemfireProperties.setProperty(String.format("ssl-%s-alias", component), StringUtils.trimWhitespace(alias))); }); } }
@Override protected Properties toGemFireProperties(Map<String, Object> annotationAttributes) { return Optional.ofNullable(resolveProperty(redisServiceProperty("enabled"), Boolean.TRUE)) .filter(Boolean.TRUE::equals) .map(enabled -> PropertiesBuilder.create() .setProperty("redis-bind-address", resolveProperty(redisServiceProperty("bind-address"), (String) annotationAttributes.get("bindAddress"))) .setProperty("redis-port", resolvePort(resolveProperty(redisServiceProperty("port"), (Integer) annotationAttributes.get("port")), DEFAULT_REDIS_PORT)) .build() ).orElseGet(Properties::new); } }
@Override protected Properties toGemFireProperties(Map<String, Object> annotationAttributes) { return Optional.ofNullable(resolveProperty(redisServiceProperty("enabled"), Boolean.TRUE)) .filter(Boolean.TRUE::equals) .map(enabled -> PropertiesBuilder.create() .setProperty("redis-bind-address", resolveProperty(redisServiceProperty("bind-address"), (String) annotationAttributes.get("bindAddress"))) .setProperty("redis-port", resolvePort(resolveProperty(redisServiceProperty("port"), (Integer) annotationAttributes.get("port")), DEFAULT_REDIS_PORT)) .build() ).orElseGet(Properties::new); } }
@Override protected Properties toGemFireProperties(Map<String, Object> annotationAttributes) { return PropertiesBuilder.create() .setProperty("off-heap-memory-size", resolveProperty(cacheOffHeapProperty("memory-size"), (String) annotationAttributes.get("memorySize"))) .build(); }
@Override protected Properties toGemFireProperties(Map<String, Object> annotationAttributes) { return Optional.of(resolveProperty(memcachedServiceProperty("enabled"), Boolean.TRUE)) .filter(Boolean.TRUE::equals) .map(enabled -> PropertiesBuilder.create() .setProperty("memcached-port", resolvePort(resolveProperty(memcachedServiceProperty("port"), (Integer) annotationAttributes.get("port")), DEFAULT_MEMCACHED_SERVER_PORT)) .setProperty("memcached-protocol", resolveProperty(memcachedServiceProperty("protocol"), EnableMemcachedServer.MemcachedProtocol.class, (EnableMemcachedServer.MemcachedProtocol) annotationAttributes.get("protocol"))) .build() ).orElseGet(Properties::new); } }
@Override protected Properties toGemFireProperties(Map<String, Object> annotationAttributes) { return PropertiesBuilder.create() .setProperty("off-heap-memory-size", resolveProperty(cacheOffHeapProperty("memory-size"), (String) annotationAttributes.get("memorySize"))) .build(); }
@Override protected Properties toGemFireProperties(Map<String, Object> annotationAttributes) { return Optional.of(resolveProperty(memcachedServiceProperty("enabled"), Boolean.TRUE)) .filter(Boolean.TRUE::equals) .map(enabled -> PropertiesBuilder.create() .setProperty("memcached-port", resolvePort(resolveProperty(memcachedServiceProperty("port"), (Integer) annotationAttributes.get("port")), DEFAULT_MEMCACHED_SERVER_PORT)) .setProperty("memcached-protocol", resolveProperty(memcachedServiceProperty("protocol"), EnableMemcachedServer.MemcachedProtocol.class, (EnableMemcachedServer.MemcachedProtocol) annotationAttributes.get("protocol"))) .build() ).orElseGet(Properties::new); } }
@Override protected Properties toGemFireProperties(Map<String, Object> annotationAttributes) { return Optional.of(resolveProperty(locatorProperty("enabled"), Boolean.TRUE)) .filter(Boolean.TRUE::equals) .map(enabled -> { String host = resolveHost(resolveProperty(locatorProperty("host"), (String) annotationAttributes.get("host"))); int port = resolvePort(resolveProperty(locatorProperty("port"), (Integer) annotationAttributes.get("port")), DEFAULT_LOCATOR_PORT); return PropertiesBuilder.create() .setProperty(START_LOCATOR_GEMFIRE_PROPERTY_NAME, String.format("%s[%d]", host, port)) .build(); }).orElseGet(Properties::new); } }
@Override protected Properties toGemFireProperties(Map<String, Object> annotationAttributes) { return Optional.of(resolveProperty(locatorProperty("enabled"), Boolean.TRUE)) .filter(Boolean.TRUE::equals) .map(enabled -> { String host = resolveHost(resolveProperty(locatorProperty("host"), (String) annotationAttributes.get("host"))); int port = resolvePort(resolveProperty(locatorProperty("port"), (Integer) annotationAttributes.get("port")), DEFAULT_LOCATOR_PORT); return PropertiesBuilder.create() .setProperty(START_LOCATOR_GEMFIRE_PROPERTY_NAME, String.format("%s[%d]", host, port)) .build(); }).orElseGet(Properties::new); } }