Skip to content

Commit

Permalink
Merge pull request #6021 from Donnerbart/cleanupGroupProperties
Browse files Browse the repository at this point in the history
Cleanup of GroupProperties
  • Loading branch information
Donnerbart committed Sep 4, 2015
2 parents 3b4567d + 22c8fdd commit 26b9144
Show file tree
Hide file tree
Showing 139 changed files with 1,706 additions and 1,542 deletions.
Expand Up @@ -27,6 +27,7 @@
import com.hazelcast.config.SocketInterceptorConfig;
import com.hazelcast.config.matcher.MatchingPointConfigPatternMatcher;
import com.hazelcast.core.ManagedContext;
import com.hazelcast.instance.HazelcastProperty;
import com.hazelcast.logging.ILogger;
import com.hazelcast.logging.Logger;
import com.hazelcast.security.Credentials;
Expand Down Expand Up @@ -117,7 +118,7 @@ public void setConfigPatternMatcher(ConfigPatternMatcher configPatternMatcher) {
}

/**
* Gets a property already set or from system properties if not exists.
* Gets a named property already set or from system properties if not exists.
*
* @param name property name
* @return value of the property
Expand All @@ -128,7 +129,7 @@ public String getProperty(String name) {
}

/**
* Sets the value of a named property
* Sets the value of a named property.
*
* @param name property name
* @param value value of the property
Expand All @@ -140,6 +141,28 @@ public ClientConfig setProperty(String name, String value) {
return this;
}

/**
* Gets a {@link HazelcastProperty} already set or from system properties if not exists.
*
* @param property {@link HazelcastProperty} to get
* @return value of the property
*/
public String getProperty(HazelcastProperty property) {
return getProperty(property.getName());
}

/**
* Sets the value of a {@link HazelcastProperty}.
*
* @param property {@link HazelcastProperty} to set
* @param value value of the property
* @return configured {@link com.hazelcast.client.config.ClientConfig} for chaining
* @see {@link com.hazelcast.client.config.ClientProperties} for properties that is used to configure client
*/
public ClientConfig setProperty(HazelcastProperty property, String value) {
return setProperty(property.getName(), value);
}

/**
* Gets {@link java.util.Properties} object
*
Expand Down
Expand Up @@ -25,7 +25,7 @@
import com.hazelcast.config.SerializationConfig;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.PartitioningStrategy;
import com.hazelcast.instance.GroupProperties;
import com.hazelcast.instance.GroupProperty;
import com.hazelcast.logging.ILogger;
import com.hazelcast.logging.Logger;
import com.hazelcast.map.impl.MapService;
Expand All @@ -52,7 +52,6 @@ public void beforeStart(HazelcastClientInstanceImpl client) {

@Override
public void afterStart(HazelcastClientInstanceImpl client) {

}

public SerializationService createSerializationService() {
Expand Down Expand Up @@ -80,7 +79,7 @@ public SerializationService createSerializationService() {
}

protected PartitioningStrategy getPartitioningStrategy(ClassLoader configClassLoader) throws Exception {
String partitioningStrategyClassName = System.getProperty(GroupProperties.PROP_PARTITIONING_STRATEGY_CLASS);
String partitioningStrategyClassName = GroupProperty.PARTITIONING_STRATEGY_CLASS.getSystemProperty();
if (partitioningStrategyClassName != null && partitioningStrategyClassName.length() > 0) {
return ClassLoaderUtil.newInstance(configClassLoader, partitioningStrategyClassName);
} else {
Expand Down Expand Up @@ -115,5 +114,4 @@ public NearCacheManager createNearCacheManager() {
// Currently "DefaultNearCacheManager" is enough.
return new DefaultNearCacheManager();
}

}
Expand Up @@ -28,7 +28,7 @@
import com.hazelcast.core.IMap;
import com.hazelcast.core.LifecycleEvent;
import com.hazelcast.core.LifecycleListener;
import com.hazelcast.instance.GroupProperties;
import com.hazelcast.instance.GroupProperty;
import com.hazelcast.test.AssertTask;
import com.hazelcast.test.HazelcastParallelClassRunner;
import com.hazelcast.test.HazelcastTestSupport;
Expand Down Expand Up @@ -293,7 +293,7 @@ public void testClientListenerForBothNodes() {
@Test
public void testClientListenerDisconnected() throws InterruptedException {
Config config = new Config();
config.setProperty(GroupProperties.PROP_IO_THREAD_COUNT, "1");
config.setProperty(GroupProperty.IO_THREAD_COUNT, "1");

final HazelcastInstance hz = hazelcastFactory.newHazelcastInstance(config);
final HazelcastInstance hz2 = hazelcastFactory.newHazelcastInstance(config);
Expand Down
Expand Up @@ -9,7 +9,7 @@
import com.hazelcast.core.IMap;
import com.hazelcast.core.LifecycleEvent;
import com.hazelcast.core.LifecycleListener;
import com.hazelcast.instance.GroupProperties;
import com.hazelcast.instance.GroupProperty;
import com.hazelcast.test.AssertTask;
import com.hazelcast.test.HazelcastParallelClassRunner;
import com.hazelcast.test.HazelcastTestSupport;
Expand Down Expand Up @@ -40,8 +40,8 @@ public void cleanup() {
@Test
public void testClientListeners_InSplitBrain() throws Throwable {
Config config = new Config();
config.setProperty(GroupProperties.PROP_MERGE_FIRST_RUN_DELAY_SECONDS, "5");
config.setProperty(GroupProperties.PROP_MERGE_NEXT_RUN_DELAY_SECONDS, "5");
config.setProperty(GroupProperty.MERGE_FIRST_RUN_DELAY_SECONDS, "5");
config.setProperty(GroupProperty.MERGE_NEXT_RUN_DELAY_SECONDS, "5");
HazelcastInstance h1 = Hazelcast.newHazelcastInstance(config);
HazelcastInstance h2 = Hazelcast.newHazelcastInstance(config);

Expand Down
Expand Up @@ -20,7 +20,7 @@
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.IMap;
import com.hazelcast.instance.GroupProperties;
import com.hazelcast.instance.GroupProperty;
import org.junit.Ignore;

import java.util.Random;
Expand All @@ -32,7 +32,7 @@
public class SimpleMapTestFromClient {

static {
System.setProperty(GroupProperties.PROP_WAIT_SECONDS_BEFORE_JOIN, "0");
GroupProperty.WAIT_SECONDS_BEFORE_JOIN.setSystemProperty("0");
System.setProperty("java.net.preferIPv4Stack", "true");
System.setProperty("hazelcast.local.localAddress", "127.0.0.1");
System.setProperty("hazelcast.version.check.enabled", "false");
Expand Down
Expand Up @@ -20,7 +20,7 @@
import com.hazelcast.config.Config;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.ILock;
import com.hazelcast.instance.GroupProperties;
import com.hazelcast.instance.GroupProperty;
import com.hazelcast.test.AssertTask;
import com.hazelcast.test.HazelcastParallelClassRunner;
import com.hazelcast.test.HazelcastTestSupport;
Expand Down Expand Up @@ -284,7 +284,7 @@ public void run() throws Exception {
@Test
public void testMaxLockLeaseTime() {
Config config = new Config();
config.setProperty(GroupProperties.PROP_LOCK_MAX_LEASE_TIME_SECONDS, "1");
config.setProperty(GroupProperty.LOCK_MAX_LEASE_TIME_SECONDS, "1");

factory.newHazelcastInstance(config);

Expand All @@ -304,7 +304,7 @@ public void run() throws Exception {
@Test(expected = IllegalArgumentException.class)
public void testLockFail_whenGreaterThanMaxLeaseTimeUsed() {
Config config = new Config();
config.setProperty(GroupProperties.PROP_LOCK_MAX_LEASE_TIME_SECONDS, "1");
config.setProperty(GroupProperty.LOCK_MAX_LEASE_TIME_SECONDS, "1");

factory.newHazelcastInstance(config);

Expand Down
Expand Up @@ -10,6 +10,7 @@
import com.hazelcast.core.IMap;
import com.hazelcast.core.MapLoader;
import com.hazelcast.core.MapStore;
import com.hazelcast.instance.GroupProperty;
import com.hazelcast.map.ReachedMaxSizeException;
import com.hazelcast.test.AssertTask;
import com.hazelcast.test.HazelcastParallelClassRunner;
Expand Down Expand Up @@ -320,10 +321,9 @@ public Set<Object> loadAllKeys() {
}

private int getMaxCapacity(HazelcastInstance node) {
return getNode(node).getNodeEngine().getGroupProperties().MAP_WRITE_BEHIND_QUEUE_CAPACITY.getInteger();
return getNode(node).getNodeEngine().getGroupProperties().getInteger(GroupProperty.MAP_WRITE_BEHIND_QUEUE_CAPACITY);
}


@Test
public void testIssue3023_testWithSubStringMapNames() throws Exception {
String mapNameWithStore = "MapStore*";
Expand Down
Expand Up @@ -6,7 +6,7 @@
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.IMap;
import com.hazelcast.core.TransactionalMap;
import com.hazelcast.instance.GroupProperties;
import com.hazelcast.instance.GroupProperty;
import com.hazelcast.map.QueryResultSizeExceededException;
import com.hazelcast.map.impl.QueryResultSizeLimiter;
import com.hazelcast.query.TruePredicate;
Expand Down Expand Up @@ -148,9 +148,9 @@ private void internalSetUpClient(int partitionCount, int clusterSize, int limit,

private Config createConfig(int partitionCount, int limit, int preCheckTrigger) {
Config config = new Config();
config.setProperty(GroupProperties.PROP_PARTITION_COUNT, String.valueOf(partitionCount));
config.setProperty(GroupProperties.PROP_QUERY_RESULT_SIZE_LIMIT, String.valueOf(limit));
config.setProperty(GroupProperties.PROP_QUERY_MAX_LOCAL_PARTITION_LIMIT_FOR_PRE_CHECK, String.valueOf(preCheckTrigger));
config.setProperty(GroupProperty.PARTITION_COUNT, String.valueOf(partitionCount));
config.setProperty(GroupProperty.QUERY_RESULT_SIZE_LIMIT, String.valueOf(limit));
config.setProperty(GroupProperty.QUERY_MAX_LOCAL_PARTITION_LIMIT_FOR_PRE_CHECK, String.valueOf(preCheckTrigger));
return config;
}

Expand Down
Expand Up @@ -27,6 +27,7 @@
import com.hazelcast.config.SocketInterceptorConfig;
import com.hazelcast.config.matcher.MatchingPointConfigPatternMatcher;
import com.hazelcast.core.ManagedContext;
import com.hazelcast.instance.HazelcastProperty;
import com.hazelcast.logging.ILogger;
import com.hazelcast.logging.Logger;
import com.hazelcast.security.Credentials;
Expand Down Expand Up @@ -116,7 +117,7 @@ public void setConfigPatternMatcher(ConfigPatternMatcher configPatternMatcher) {
}

/**
* Gets a property already set or from system properties if not exists.
* Gets a named property already set or from system properties if not exists.
*
* @param name property name
* @return value of the property
Expand All @@ -127,7 +128,7 @@ public String getProperty(String name) {
}

/**
* Sets the value of a named property
* Sets the value of a named property.
*
* @param name property name
* @param value value of the property
Expand All @@ -139,6 +140,28 @@ public ClientConfig setProperty(String name, String value) {
return this;
}

/**
* Gets a {@link HazelcastProperty} already set or from system properties if not exists.
*
* @param property {@link HazelcastProperty} to get
* @return value of the property
*/
public String getProperty(HazelcastProperty property) {
return getProperty(property.getName());
}

/**
* Sets the value of a {@link HazelcastProperty}.
*
* @param property {@link HazelcastProperty} to set
* @param value value of the property
* @return configured {@link com.hazelcast.client.config.ClientConfig} for chaining
* @see {@link com.hazelcast.client.config.ClientProperties} for properties that is used to configure client
*/
public ClientConfig setProperty(HazelcastProperty property, String value) {
return setProperty(property.getName(), value);
}

/**
* Gets {@link java.util.Properties} object
*
Expand Down
Expand Up @@ -25,7 +25,7 @@
import com.hazelcast.config.SerializationConfig;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.PartitioningStrategy;
import com.hazelcast.instance.GroupProperties;
import com.hazelcast.instance.GroupProperty;
import com.hazelcast.logging.ILogger;
import com.hazelcast.logging.Logger;
import com.hazelcast.map.impl.MapService;
Expand Down Expand Up @@ -80,7 +80,7 @@ public SerializationService createSerializationService() {
}

protected PartitioningStrategy getPartitioningStrategy(ClassLoader configClassLoader) throws Exception {
String partitioningStrategyClassName = System.getProperty(GroupProperties.PROP_PARTITIONING_STRATEGY_CLASS);
String partitioningStrategyClassName = GroupProperty.PARTITIONING_STRATEGY_CLASS.getSystemProperty();
if (partitioningStrategyClassName != null && partitioningStrategyClassName.length() > 0) {
return ClassLoaderUtil.newInstance(configClassLoader, partitioningStrategyClassName);
} else {
Expand Down
Expand Up @@ -28,7 +28,7 @@
import com.hazelcast.core.IMap;
import com.hazelcast.core.LifecycleEvent;
import com.hazelcast.core.LifecycleListener;
import com.hazelcast.instance.GroupProperties;
import com.hazelcast.instance.GroupProperty;
import com.hazelcast.test.AssertTask;
import com.hazelcast.test.HazelcastParallelClassRunner;
import com.hazelcast.test.HazelcastTestSupport;
Expand Down Expand Up @@ -293,7 +293,7 @@ public void testClientListenerForBothNodes() {
@Test
public void testClientListenerDisconnected() throws InterruptedException {
Config config = new Config();
config.setProperty(GroupProperties.PROP_IO_THREAD_COUNT, "1");
config.setProperty(GroupProperty.IO_THREAD_COUNT, "1");

final HazelcastInstance hz = hazelcastFactory.newHazelcastInstance(config);
final HazelcastInstance hz2 = hazelcastFactory.newHazelcastInstance(config);
Expand Down
Expand Up @@ -9,7 +9,7 @@
import com.hazelcast.core.IMap;
import com.hazelcast.core.LifecycleEvent;
import com.hazelcast.core.LifecycleListener;
import com.hazelcast.instance.GroupProperties;
import com.hazelcast.instance.GroupProperty;
import com.hazelcast.test.AssertTask;
import com.hazelcast.test.HazelcastParallelClassRunner;
import com.hazelcast.test.HazelcastTestSupport;
Expand Down Expand Up @@ -40,8 +40,8 @@ public void cleanup() {
@Test
public void testClientListeners_InSplitBrain() throws Throwable {
Config config = new Config();
config.setProperty(GroupProperties.PROP_MERGE_FIRST_RUN_DELAY_SECONDS, "5");
config.setProperty(GroupProperties.PROP_MERGE_NEXT_RUN_DELAY_SECONDS, "5");
config.setProperty(GroupProperty.MERGE_FIRST_RUN_DELAY_SECONDS, "5");
config.setProperty(GroupProperty.MERGE_NEXT_RUN_DELAY_SECONDS, "5");
HazelcastInstance h1 = Hazelcast.newHazelcastInstance(config);
HazelcastInstance h2 = Hazelcast.newHazelcastInstance(config);

Expand Down
Expand Up @@ -20,7 +20,7 @@
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.IMap;
import com.hazelcast.instance.GroupProperties;
import com.hazelcast.instance.GroupProperty;
import org.junit.Ignore;

import java.util.Random;
Expand All @@ -32,7 +32,7 @@
public class SimpleMapTestFromClient {

static {
System.setProperty(GroupProperties.PROP_WAIT_SECONDS_BEFORE_JOIN, "0");
GroupProperty.WAIT_SECONDS_BEFORE_JOIN.setSystemProperty("0");
System.setProperty("java.net.preferIPv4Stack", "true");
System.setProperty("hazelcast.local.localAddress", "127.0.0.1");
System.setProperty("hazelcast.version.check.enabled", "false");
Expand Down
Expand Up @@ -20,7 +20,7 @@
import com.hazelcast.config.Config;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.instance.GroupProperties;
import com.hazelcast.instance.GroupProperty;
import com.hazelcast.instance.Node;
import com.hazelcast.nio.tcp.nonblocking.NonBlockingSocketReader;
import com.hazelcast.nio.tcp.TcpIpConnection;
Expand Down Expand Up @@ -73,8 +73,8 @@ public void testClientBufferSize_ExplicitOverride() {
int sendBufferSizeKB = 4;

Config config = new Config();
config.setProperty(GroupProperties.PROP_SOCKET_CLIENT_RECEIVE_BUFFER_SIZE, Integer.toString(receiveBufferSizeKB));
config.setProperty(GroupProperties.PROP_SOCKET_CLIENT_SEND_BUFFER_SIZE, Integer.toString(sendBufferSizeKB));
config.setProperty(GroupProperty.SOCKET_CLIENT_RECEIVE_BUFFER_SIZE, Integer.toString(receiveBufferSizeKB));
config.setProperty(GroupProperty.SOCKET_CLIENT_SEND_BUFFER_SIZE, Integer.toString(sendBufferSizeKB));

HazelcastInstance server = Hazelcast.newHazelcastInstance(config);
HazelcastInstance client = HazelcastClient.newHazelcastClient();
Expand All @@ -89,12 +89,12 @@ public void testClientBufferSize_ExplicitOverride() {

private int getDefaultSendBufferSize(HazelcastInstance instance) {
Node node = getNode(instance);
return node.getGroupProperties().SOCKET_SEND_BUFFER_SIZE.getInteger() * 1024;
return node.getGroupProperties().getInteger(GroupProperty.SOCKET_SEND_BUFFER_SIZE) * 1024;
}

private int getDefaultReceiverBufferSize(HazelcastInstance instance) {
Node node = getNode(instance);
return node.getGroupProperties().SOCKET_RECEIVE_BUFFER_SIZE.getInteger() * 1024;
return node.getGroupProperties().getInteger(GroupProperty.SOCKET_RECEIVE_BUFFER_SIZE) * 1024;
}

private TcpIpConnection getClientConnection(HazelcastInstance server) {
Expand Down

0 comments on commit 26b9144

Please sign in to comment.