com.hazelcast.config.properties.PropertyDefinition Java Examples

The following examples show how to use com.hazelcast.config.properties.PropertyDefinition. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KubernetesConfig.java    From hazelcast-kubernetes with Apache License 2.0 6 votes vote down vote up
private String getNamespaceWithFallbacks(Map<String, Comparable> properties,
                                         String kubernetesSystemPrefix,
                                         PropertyDefinition propertyDefinition) {
    String namespace = getOrNull(properties, kubernetesSystemPrefix, propertyDefinition);

    if (namespace == null) {
        namespace = System.getenv("KUBERNETES_NAMESPACE");
    }

    if (namespace == null) {
        namespace = System.getenv("OPENSHIFT_BUILD_NAMESPACE");
    }

    if (namespace == null) {
        namespace = readNamespace();
    }

    return namespace;
}
 
Example #2
Source File: KubernetesConfig.java    From hazelcast-kubernetes with Apache License 2.0 6 votes vote down vote up
private <T extends Comparable> T getOrDefault(Map<String, Comparable> properties, String prefix,
                                              PropertyDefinition property, T defaultValue) {
    if (property == null) {
        return defaultValue;
    }

    Comparable value = readProperty(prefix, property);
    if (value == null) {
        value = properties.get(property.key());
    }

    if (value == null) {
        return defaultValue;
    }

    return (T) value;
}
 
Example #3
Source File: KubernetesConfig.java    From hazelcast-kubernetes with Apache License 2.0 6 votes vote down vote up
private Comparable readProperty(String prefix, PropertyDefinition property) {
    if (prefix != null) {
        String p = getProperty(prefix, property);
        String v = System.getProperty(p);
        if (StringUtil.isNullOrEmpty(v)) {
            v = System.getenv(p);
            if (StringUtil.isNullOrEmpty(v)) {
                v = System.getenv(cIdentifierLike(p));
            }
        }

        if (!StringUtil.isNullOrEmpty(v)) {
            return property.typeConverter().convert(v);
        }
    }
    return null;
}
 
Example #4
Source File: KubernetesConfig.java    From hazelcast-kubernetes with Apache License 2.0 5 votes vote down vote up
private String getProperty(String prefix, PropertyDefinition property) {
    StringBuilder sb = new StringBuilder(prefix);
    if (prefix.charAt(prefix.length() - 1) != '.') {
        sb.append('.');
    }
    return sb.append(property.key()).toString();
}
 
Example #5
Source File: HazelcastKubernetesDiscoveryStrategyFactoryTest.java    From hazelcast-kubernetes with Apache License 2.0 5 votes vote down vote up
@Test
public void checkProperties() {
    HazelcastKubernetesDiscoveryStrategyFactory factory = new HazelcastKubernetesDiscoveryStrategyFactory();
    Collection<PropertyDefinition> propertyDefinitions = factory.getConfigurationProperties();
    assertTrue(propertyDefinitions.contains(KubernetesProperties.SERVICE_DNS));
    assertTrue(propertyDefinitions.contains(KubernetesProperties.SERVICE_PORT));
}
 
Example #6
Source File: DockerSwarmDiscoveryStrategyFactory.java    From hazelcast-docker-swarm-discovery-spi with Apache License 2.0 4 votes vote down vote up
public Collection<PropertyDefinition> getConfigurationProperties() {
    return PROPERTIES;
}
 
Example #7
Source File: DockerDNSRRDiscoveryStrategyFactory.java    From hazelcast-docker-swarm-discovery-spi with Apache License 2.0 4 votes vote down vote up
@Override
public Collection<PropertyDefinition> getConfigurationProperties() {
    return DockerDNSRRDiscoveryConfiguration.PROPERTIES;
}
 
Example #8
Source File: ConsulDiscoveryStrategyFactory.java    From hazelcast-consul-discovery-spi with Apache License 2.0 4 votes vote down vote up
public Collection<PropertyDefinition> getConfigurationProperties() {
	return PROPERTIES;
}
 
Example #9
Source File: KubernetesProperties.java    From hazelcast-kubernetes with Apache License 2.0 4 votes vote down vote up
private static PropertyDefinition property(String key, TypeConverter typeConverter) {
    return new SimplePropertyDefinition(key, true, typeConverter);
}
 
Example #10
Source File: HazelcastKubernetesDiscoveryStrategyFactory.java    From hazelcast-kubernetes with Apache License 2.0 4 votes vote down vote up
public Collection<PropertyDefinition> getConfigurationProperties() {
    return PROPERTY_DEFINITIONS;
}
 
Example #11
Source File: KubernetesConfig.java    From hazelcast-kubernetes with Apache License 2.0 4 votes vote down vote up
private <T extends Comparable> T getOrNull(Map<String, Comparable> properties, String prefix, PropertyDefinition property) {
    return getOrDefault(properties, prefix, property, null);
}