[infinispan-commits] Infinispan SVN: r2039 - in trunk: cachestore/cloud/src/integrationtest/java/org/infinispan/loaders/cloud and 22 other directories.
infinispan-commits at lists.jboss.org
infinispan-commits at lists.jboss.org
Thu Jul 15 11:33:11 EDT 2010
Author: manik.surtani at jboss.com
Date: 2010-07-15 11:33:09 -0400 (Thu, 15 Jul 2010)
New Revision: 2039
Added:
trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/ConfigurationProperties.java
trunk/core/src/main/java/org/infinispan/util/LegacyKeySupportSystemProperties.java
trunk/core/src/main/java/org/infinispan/util/LegacyKeySupportTypedProperties.java
Modified:
trunk/cachestore/cloud/README.txt
trunk/cachestore/cloud/pom.xml
trunk/cachestore/cloud/src/integrationtest/java/org/infinispan/loaders/cloud/CloudCacheStoreFunctionalIntegrationTest.java
trunk/cachestore/cloud/src/integrationtest/java/org/infinispan/loaders/cloud/CloudCacheStoreIntegrationTest.java
trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/TableManipulationTest.java
trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/mixed/JdbcMixedCacheStoreTest.java
trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreTest2.java
trunk/cachestore/jdbc/src/test/java/org/infinispan/test/fwk/UnitTestDatabaseManager.java
trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/RemoteCacheManager.java
trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/consistenthash/ConsistentHashFactory.java
trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/TransportFactory.java
trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/tcp/TcpTransportFactory.java
trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/ClientConnectionPoolingTest.java
trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/ConsistentHashFactoryTest.java
trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/RemoteCacheManagerTest.java
trunk/core/src/test/java/org/infinispan/test/fwk/JGroupsConfigBuilder.java
trunk/core/src/test/java/org/infinispan/test/fwk/TestCacheManagerFactory.java
trunk/core/src/test/java/org/infinispan/test/fwk/TransactionSetup.java
trunk/demos/ec2/src/main/java/org/infinispan/ec2demo/InfluenzaDataLoader.java
trunk/demos/gridfs-webdav/src/main/java/org/infinispan/demos/gridfs/CacheManagerHolder.java
trunk/demos/gridfs-webdav/src/main/webapp/WEB-INF/web.xml
trunk/demos/gui/src/main/java/org/infinispan/demo/InfinispanDemo.form
trunk/demos/gui/src/main/java/org/infinispan/demo/InfinispanDemo.java
trunk/jopr-plugin/src/main/resources/META-INF/rhq-plugin.xml
trunk/server/core/src/main/scala/org/infinispan/server/core/AbstractProtocolServer.scala
trunk/server/core/src/main/scala/org/infinispan/server/core/Main.scala
trunk/server/rest/src/main/scala/org/infinispan/rest/StartupListener.scala
trunk/server/rest/src/main/webapp/WEB-INF/web.xml
trunk/server/rest/src/test/scala/org/infinispan/rest/ServerInstance.scala
trunk/server/websocket/src/main/java/org/infinispan/server/websocket/WebSocketServer.java
Log:
[ISPN-534] (Standardise keys used for System properties, .properties and Properties entries)
Modified: trunk/cachestore/cloud/README.txt
===================================================================
--- trunk/cachestore/cloud/README.txt 2010-07-15 13:16:27 UTC (rev 2038)
+++ trunk/cachestore/cloud/README.txt 2010-07-15 15:33:09 UTC (rev 2039)
@@ -1,3 +1,3 @@
- mvn -Pintegration test -Dinfinispan.jclouds.username=$S3_USER -Dinfinispan.jclouds.password=$S3_PWD -Dinfinispan.jclouds.service=s3
- mvn -Pintegration test -Dinfinispan.jclouds.username=$RACKSPACE_USER -Dinfinispan.jclouds.password=$RACKSPACE_PWD -Dinfinispan.jclouds.service=cloudfiles
- mvn -Pintegration test -Dinfinispan.jclouds.username=$AZURE_USER -Dinfinispan.jclouds.password=$AZURE_PWD -Dinfinispan.jclouds.service=azureblob
+ mvn -Pintegration test -Dinfinispan.test.jclouds.username=$S3_USER -Dinfinispan.test.jclouds.password=$S3_PWD -Dinfinispan.test.jclouds.service=s3
+ mvn -Pintegration test -Dinfinispan.test.jclouds.username=$RACKSPACE_USER -Dinfinispan.test.jclouds.password=$RACKSPACE_PWD -Dinfinispan.test.jclouds.service=cloudfiles
+ mvn -Pintegration test -Dinfinispan.test.jclouds.username=$AZURE_USER -Dinfinispan.test.jclouds.password=$AZURE_PWD -Dinfinispan.test.jclouds.service=azureblob
Modified: trunk/cachestore/cloud/pom.xml
===================================================================
--- trunk/cachestore/cloud/pom.xml 2010-07-15 13:16:27 UTC (rev 2038)
+++ trunk/cachestore/cloud/pom.xml 2010-07-15 15:33:09 UTC (rev 2039)
@@ -90,16 +90,16 @@
<parallel>false</parallel>
<systemProperties>
<property>
- <name>infinispan.jclouds.username</name>
- <value>${infinispan.jclouds.username}</value>
+ <name>infinispan.test.jclouds.username</name>
+ <value>${infinispan.test.jclouds.username}</value>
</property>
<property>
- <name>infinispan.jclouds.password</name>
- <value>${infinispan.jclouds.password}</value>
+ <name>infinispan.test.jclouds.password</name>
+ <value>${infinispan.test.jclouds.password}</value>
</property>
<property>
- <name>infinispan.jclouds.service</name>
- <value>${infinispan.jclouds.service}</value>
+ <name>infinispan.test.jclouds.service</name>
+ <value>${infinispan.test.jclouds.service}</value>
</property>
</systemProperties>
</configuration>
Modified: trunk/cachestore/cloud/src/integrationtest/java/org/infinispan/loaders/cloud/CloudCacheStoreFunctionalIntegrationTest.java
===================================================================
--- trunk/cachestore/cloud/src/integrationtest/java/org/infinispan/loaders/cloud/CloudCacheStoreFunctionalIntegrationTest.java 2010-07-15 13:16:27 UTC (rev 2038)
+++ trunk/cachestore/cloud/src/integrationtest/java/org/infinispan/loaders/cloud/CloudCacheStoreFunctionalIntegrationTest.java 2010-07-15 15:33:09 UTC (rev 2039)
@@ -43,12 +43,12 @@
private String secretKey;
private String cs;
- private static final String sysUsername = System.getProperty("infinispan.jclouds.username");
- private static final String sysPassword = System.getProperty("infinispan.jclouds.password");
- private static final String sysService = System.getProperty("infinispan.jclouds.service");
+ private static final String sysUsername = System.getProperty("infinispan.test.jclouds.username");
+ private static final String sysPassword = System.getProperty("infinispan.test.jclouds.password");
+ private static final String sysService = System.getProperty("infinispan.test.jclouds.service");
@BeforeTest
- @Parameters({"infinispan.jclouds.username", "infinispan.jclouds.password", "infinispan.jclouds.service"})
+ @Parameters({"infinispan.test.jclouds.username", "infinispan.test.jclouds.password", "infinispan.test.jclouds.service"})
protected void setUpClient(@Optional String JcloudsUsername,
@Optional String JcloudsPassword,
@Optional String JcloudsService) throws Exception {
Modified: trunk/cachestore/cloud/src/integrationtest/java/org/infinispan/loaders/cloud/CloudCacheStoreIntegrationTest.java
===================================================================
--- trunk/cachestore/cloud/src/integrationtest/java/org/infinispan/loaders/cloud/CloudCacheStoreIntegrationTest.java 2010-07-15 13:16:27 UTC (rev 2038)
+++ trunk/cachestore/cloud/src/integrationtest/java/org/infinispan/loaders/cloud/CloudCacheStoreIntegrationTest.java 2010-07-15 15:33:09 UTC (rev 2039)
@@ -47,12 +47,12 @@
private String secretKey;
private String service;
- private static final String sysUsername = System.getProperty("infinispan.jclouds.username");
- private static final String sysPassword = System.getProperty("infinispan.jclouds.password");
- private static final String sysService = System.getProperty("infinispan.jclouds.service");
+ private static final String sysUsername = System.getProperty("infinispan.test.jclouds.username");
+ private static final String sysPassword = System.getProperty("infinispan.test.jclouds.password");
+ private static final String sysService = System.getProperty("infinispan.test.jclouds.service");
@BeforeTest
- @Parameters({"infinispan.jclouds.username", "infinispan.jclouds.password", "infinispan.jclouds.service"})
+ @Parameters({"infinispan.test.jclouds.username", "infinispan.test.jclouds.password", "infinispan.test.jclouds.service"})
protected void setUpClient(@Optional String JcloudsUsername,
@Optional String JcloudsPassword,
@Optional String JcloudsService) throws Exception {
Modified: trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/TableManipulationTest.java
===================================================================
--- trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/TableManipulationTest.java 2010-07-15 13:16:27 UTC (rev 2038)
+++ trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/TableManipulationTest.java 2010-07-15 15:33:09 UTC (rev 2039)
@@ -58,7 +58,6 @@
@AfterTest
public void closeConnection() throws SQLException {
connection.close();
- UnitTestDatabaseManager.shutdownInMemoryDatabase(cfg);
}
public void testInsufficientConfigParams() throws Exception {
Modified: trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/mixed/JdbcMixedCacheStoreTest.java
===================================================================
--- trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/mixed/JdbcMixedCacheStoreTest.java 2010-07-15 13:16:27 UTC (rev 2038)
+++ trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/mixed/JdbcMixedCacheStoreTest.java 2010-07-15 15:33:09 UTC (rev 2039)
@@ -89,7 +89,6 @@
@AfterTest
public void destroyStore() throws CacheLoaderException {
cacheStore.stop();
- UnitTestDatabaseManager.shutdownInMemoryDatabase(cfc);
}
public void testMixedStore() throws Exception {
Modified: trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreTest2.java
===================================================================
--- trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreTest2.java 2010-07-15 13:16:27 UTC (rev 2038)
+++ trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreTest2.java 2010-07-15 15:33:09 UTC (rev 2039)
@@ -80,7 +80,6 @@
@AfterTest
public void destroyStore() throws CacheLoaderException {
cacheStore.stop();
- UnitTestDatabaseManager.shutdownInMemoryDatabase(cfc);
}
/**
Modified: trunk/cachestore/jdbc/src/test/java/org/infinispan/test/fwk/UnitTestDatabaseManager.java
===================================================================
--- trunk/cachestore/jdbc/src/test/java/org/infinispan/test/fwk/UnitTestDatabaseManager.java 2010-07-15 13:16:27 UTC (rev 2038)
+++ trunk/cachestore/jdbc/src/test/java/org/infinispan/test/fwk/UnitTestDatabaseManager.java 2010-07-15 15:33:09 UTC (rev 2039)
@@ -50,7 +50,7 @@
private static final ConnectionFactoryConfig realConfig = new ConnectionFactoryConfig();
private static AtomicInteger userIndex = new AtomicInteger(0);
- private static final String DB_TYPE = System.getProperty("infinispan.jdbc", "H2");
+ private static final String DB_TYPE = System.getProperty("infinispan.test.jdbc.db", "H2");
private static final String H2_DRIVER = org.h2.Driver.class.getName();
static {
@@ -100,38 +100,6 @@
}
}
- public static void shutdownInMemoryDatabase(ConnectionFactoryConfig config) {
-
-
-// Connection conn = null;
-// Statement st = null;
-// try {
-// String shutDownConnection = getShutdownUrl(config);
-// String url = config.getConnectionUrl();
-// assert url != null;
-// try {
-// conn = DriverManager.getConnection(shutDownConnection);
-// } catch (SQLException e) {
-// //expected
-// }
-//// st = conn.createStatement();
-//// st.execute("SHUTDOWN");
-// }
-// catch (Throwable e) {
-// throw new IllegalStateException(e);
-// }
-// finally {
-//// try {
-////// conn.close();
-////// st.close();
-//// }
-//// catch (SQLException e) {
-//// e.printStackTrace();
-//// }
-// }
-
- }
-
public static String getDatabaseName(Properties prop) {
StringTokenizer tokenizer = new StringTokenizer(prop.getProperty("cache.jdbc.url"), ":");
tokenizer.nextToken();
Modified: trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/RemoteCacheManager.java
===================================================================
--- trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/RemoteCacheManager.java 2010-07-15 13:16:27 UTC (rev 2038)
+++ trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/RemoteCacheManager.java 2010-07-15 15:33:09 UTC (rev 2039)
@@ -1,16 +1,14 @@
package org.infinispan.client.hotrod;
import org.infinispan.client.hotrod.exceptions.HotRodClientException;
+import org.infinispan.client.hotrod.impl.ConfigurationProperties;
import org.infinispan.client.hotrod.impl.async.DefaultAsyncExecutorFactory;
import org.infinispan.client.hotrod.impl.operations.OperationsFactory;
import org.infinispan.client.hotrod.impl.RemoteCacheImpl;
import org.infinispan.client.hotrod.impl.transport.TransportFactory;
-import org.infinispan.client.hotrod.impl.transport.tcp.TcpTransportFactory;
import org.infinispan.executors.ExecutorFactory;
import org.infinispan.manager.CacheContainer;
import org.infinispan.marshall.Marshaller;
-import org.infinispan.marshall.jboss.GenericJBossMarshaller;
-import org.infinispan.util.TypedProperties;
import org.infinispan.util.logging.Log;
import org.infinispan.util.logging.LogFactory;
@@ -18,12 +16,10 @@
import java.io.InputStream;
import java.net.InetSocketAddress;
import java.net.URL;
+import java.util.Collection;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Map;
import java.util.Properties;
-import java.util.Set;
-import java.util.StringTokenizer;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.atomic.AtomicInteger;
import static org.infinispan.util.Util.getInstance;
@@ -134,19 +130,7 @@
public static final String HOTROD_CLIENT_PROPERTIES = "hotrod-client.properties";
- public static final String CONF_HOTROD_SERVERS = "hotrod-servers";
-
- public static final String OVERRIDE_HOTROD_SERVERS = "infinispan.hotrod.client.servers";
-
- private static final String KEY_SIZE = "marshaller.default-array-size.key";
-
- private static final String VALUE_SIZE = "marshaller.default-array-size.value";
-
- private static final int DEFAULT_KEY_SIZE = 64;
- private static final int DEFAULT_VALUE_SIZE = 512;
-
-
- private TypedProperties props;
+ private ConfigurationProperties config;
private TransportFactory transportFactory;
private Marshaller marshaller;
private boolean started = false;
@@ -175,15 +159,15 @@
/**
* Same as {@link org.infinispan.client.hotrod.RemoteCacheManager#RemoteCacheManager(Marshaller, java.util.Properties, boolean)} with start = true.
*/
- public RemoteCacheManager(Marshaller hotRodMarshaller, Properties props) {
- this(hotRodMarshaller, props, false);
+ public RemoteCacheManager(Marshaller marshaller, Properties props) {
+ this(marshaller, props, false);
}
/**
* Build a cache manager based on supplied properties.
*/
public RemoteCacheManager(Properties props, boolean start) {
- this.props = TypedProperties.toTypedProperties(props);
+ this.config = new ConfigurationProperties(props);
if (start) start();
}
@@ -207,7 +191,7 @@
InputStream stream = loader.getResourceAsStream(HOTROD_CLIENT_PROPERTIES);
if (stream == null) {
log.warn("Could not find '" + HOTROD_CLIENT_PROPERTIES + "' file in classpath, using defaults.");
- props = new TypedProperties();
+ config = new ConfigurationProperties();
} else {
loadFromStream(stream);
}
@@ -227,8 +211,7 @@
* @param start weather or not to start the RemoteCacheManager.
*/
public RemoteCacheManager(String host, int port, boolean start) {
- props = new TypedProperties();
- props.put(TransportFactory.CONF_HOTROD_SERVERS, host + ":" + port);
+ config = new ConfigurationProperties(host + ":" + port);
if (start) start();
}
@@ -244,8 +227,7 @@
* server.
*/
public RemoteCacheManager(String servers, boolean start) {
- props = new TypedProperties();
- props.put(TransportFactory.CONF_HOTROD_SERVERS, servers);
+ config = new ConfigurationProperties(servers);
if (start) start();
}
@@ -302,34 +284,21 @@
@Override
public void start() {
- String factory = props.getProperty("transport-factory");
- if (factory == null) {
- factory = TcpTransportFactory.class.getName();
- log.info("'transport-factory' factory not specified, using " + factory);
- }
+ String factory = config.getTransportFactory();
transportFactory = (TransportFactory) getInstance(factory);
- String servers = props.getProperty(CONF_HOTROD_SERVERS);
- transportFactory.start(props, getStaticConfiguredServers(servers), topologyId);
+ Collection<InetSocketAddress> servers = config.getServerList();
+ transportFactory.start(config, servers, topologyId);
if (marshaller == null) {
- String marshaller = props.getProperty("marshaller");
- if (marshaller == null) {
- marshaller = GenericJBossMarshaller.class.getName();
- log.info("'marshaller' not specified, using " + marshaller);
- }
- setMarshaller((Marshaller) getInstance(marshaller));
+ String marshallerName = config.getMarshaller();
+ setMarshaller((Marshaller) getInstance(marshallerName));
}
- String asyncExecutorClass = DefaultAsyncExecutorFactory.class.getName();
- if (props.contains("asyn-executor-factory")) {
- asyncExecutorClass = props.getProperty("asyn-executor-factory");
- }
+ String asyncExecutorClass = config.getAsyncExecutorFactory();
ExecutorFactory executorFactory = (ExecutorFactory) getInstance(asyncExecutorClass);
- asyncExecutorService = executorFactory.getExecutor(props);
+ asyncExecutorService = executorFactory.getExecutor(config.getProperties());
+ forceReturnValueDefault = config.getForceReturnValues();
- if (props.get("force-return-value") != null && props.get("force-return-value").equals("true")) {
- forceReturnValueDefault = true;
- }
synchronized (cacheName2RemoteCache) {
for (RemoteCacheImpl remoteCache : cacheName2RemoteCache.values()) {
startRemoteCache(remoteCache);
@@ -351,12 +320,13 @@
}
private void loadFromStream(InputStream stream) {
- props = new TypedProperties();
+ Properties properties = new Properties();
try {
- props.load(stream);
+ properties.load(stream);
} catch (IOException e) {
throw new HotRodClientException("Issues configuring from client hotrod-client.properties", e);
}
+ config = new ConfigurationProperties(properties);
}
private <K, V> RemoteCache<K, V> createRemoteCache(String cacheName, boolean forceReturnValue) {
@@ -374,40 +344,9 @@
private <K, V> void startRemoteCache(RemoteCacheImpl<K, V> result) {
OperationsFactory operationsFactory = new OperationsFactory(transportFactory, result.getName(), topologyId, forceReturnValueDefault);
- result.init(marshaller, asyncExecutorService, operationsFactory, props.getIntProperty(KEY_SIZE, DEFAULT_KEY_SIZE),
- props.getIntProperty(VALUE_SIZE, DEFAULT_VALUE_SIZE));
+ result.init(marshaller, asyncExecutorService, operationsFactory, config.getKeySizeEstimate(), config.getValueSizeEstimate());
}
- private Set<InetSocketAddress> getStaticConfiguredServers(String servers) {
- Set<InetSocketAddress> serverAddresses = new HashSet<InetSocketAddress>();
- if (servers == null) {
- servers = System.getProperty(OVERRIDE_HOTROD_SERVERS);
- if (servers != null) {
- log.info("Overwriting default server properties (-D" + OVERRIDE_HOTROD_SERVERS + ") with " + servers);
- } else {
- servers = "127.0.0.1:11311";
- }
- log.info("'hotrod-servers' property not specified in config, using " + servers);
- }
- StringTokenizer tokenizer = new StringTokenizer(servers, ";");
- while (tokenizer.hasMoreTokens()) {
- String server = tokenizer.nextToken();
- String[] serverDef = tokenizeServer(server);
- String serverHost = serverDef[0];
- int serverPort = Integer.parseInt(serverDef[1]);
- serverAddresses.add(new InetSocketAddress(serverHost, serverPort));
- }
- if (serverAddresses.isEmpty()) {
- throw new IllegalStateException("No hot-rod servers specified!");
- }
- return serverAddresses;
- }
-
- private String[] tokenizeServer(String server) {
- StringTokenizer t = new StringTokenizer(server, ":");
- return new String[]{t.nextToken(), t.nextToken()};
- }
-
private void setMarshaller(Marshaller marshaller) {
this.marshaller = marshaller;
}
Added: trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/ConfigurationProperties.java
===================================================================
--- trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/ConfigurationProperties.java (rev 0)
+++ trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/ConfigurationProperties.java 2010-07-15 15:33:09 UTC (rev 2039)
@@ -0,0 +1,116 @@
+package org.infinispan.client.hotrod.impl;
+
+import org.infinispan.client.hotrod.impl.async.DefaultAsyncExecutorFactory;
+import org.infinispan.client.hotrod.impl.transport.tcp.RoundRobinBalancingStrategy;
+import org.infinispan.client.hotrod.impl.transport.tcp.TcpTransportFactory;
+import org.infinispan.marshall.jboss.GenericJBossMarshaller;
+import org.infinispan.util.TypedProperties;
+
+import java.net.InetSocketAddress;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+/**
+ * Encpasulate all config properties here
+ *
+ * @author Manik Surtani
+ * @version 4.1
+ */
+public class ConfigurationProperties {
+ public static final String TRANSPORT_FACTORY = "infinispan.client.hotrod.transport_factory";
+ public static final String SERVER_LIST = "infinispan.client.hotrod.server_list";
+ public static final String MARSHALLER = "infinispan.client.hotrod.marshaller";
+ public static final String ASYNC_EXECUTOR_FACTORY = "infinispan.client.hotrod.async_executor_factory";
+ public static final String DEFAULT_EXECUTOR_FACTORY_POOL_SIZE = "infinispan.client.hotrod.default_executor_factory.pool_size";
+ public static final String TCP_NO_DELAY = "infinispan.client.hotrod.tcp_no_delay";
+ public static final String PING_ON_STARTUP = "infinispan.client.hotrod.ping_on_startup";
+ public static final String REQUEST_BALANCING_STRATEGY = "infinispan.client.hotrod.request_balancing_strategy";
+ public static final String KEY_SIZE_ESTIMATE = "infinispan.client.hotrod.key_size_estimate";
+ public static final String VALUE_SIZE_ESTIMATE = "infinispan.client.hotrod.value_size_estimate";
+ public static final String FORCE_RETURN_VALUES = "infinispan.client.hotrod.force_return_values";
+ public static final String HASH_FUNCTION_PREFIX = "infinispan.client.hotrod.hash_function_impl";
+
+ // defaults
+
+ private static final int DEFAULT_KEY_SIZE = 64;
+ private static final int DEFAULT_VALUE_SIZE = 512;
+
+ private final TypedProperties props;
+
+ public ConfigurationProperties() {
+ this.props = new TypedProperties();
+ }
+
+ public ConfigurationProperties(String serverList) {
+ this();
+ props.setProperty(SERVER_LIST, serverList);
+ }
+
+ public ConfigurationProperties(Properties props) {
+ this.props = props == null ? new TypedProperties() : TypedProperties.toTypedProperties(props);
+ }
+
+ public String getTransportFactory() {
+ return props.getProperty(TRANSPORT_FACTORY, TcpTransportFactory.class.getName());
+ }
+
+ public Collection<InetSocketAddress> getServerList() {
+ Set<InetSocketAddress> addresses = new HashSet<InetSocketAddress>();
+ String servers = props.getProperty(SERVER_LIST, "127.0.0.1:11311");
+ for (String server: servers.split(";")) {
+ String[] components = server.trim().split(":");
+ String host = components[0];
+ int port = 11311;
+ if (components.length > 1) port = Integer.parseInt(components[1]);
+ addresses.add(new InetSocketAddress(host, port));
+ }
+
+ if (addresses.isEmpty()) throw new IllegalStateException("No Hot Rod servers specified!");
+
+ return addresses;
+ }
+
+ public String getMarshaller() {
+ return props.getProperty(MARSHALLER, GenericJBossMarshaller.class.getName());
+ }
+
+ public String getAsyncExecutorFactory() {
+ return props.getProperty(ASYNC_EXECUTOR_FACTORY, DefaultAsyncExecutorFactory.class.getName());
+ }
+
+ public int getDefaultExecutorFactoryPoolSize() {
+ return 99; // TODO
+ }
+
+ public boolean getTcpNoDelay() {
+ return props.getBooleanProperty(TCP_NO_DELAY, true);
+ }
+
+ public boolean getPingOnStartup() {
+ return props.getBooleanProperty(PING_ON_STARTUP, true);
+ }
+
+ public String getRequestBalancingStrategy() {
+ return props.getProperty(REQUEST_BALANCING_STRATEGY, RoundRobinBalancingStrategy.class.getName());
+ }
+
+ public int getKeySizeEstimate() {
+ return props.getIntProperty(KEY_SIZE_ESTIMATE, DEFAULT_KEY_SIZE);
+ }
+
+ public int getValueSizeEstimate() {
+ return props.getIntProperty(VALUE_SIZE_ESTIMATE, DEFAULT_VALUE_SIZE);
+ }
+
+ public boolean getForceReturnValues() {
+ return props.getBooleanProperty(FORCE_RETURN_VALUES, false);
+ }
+
+ public Properties getProperties() {
+ return props;
+ }
+}
Property changes on: trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/ConfigurationProperties.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/consistenthash/ConsistentHashFactory.java
===================================================================
--- trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/consistenthash/ConsistentHashFactory.java 2010-07-15 13:16:27 UTC (rev 2038)
+++ trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/consistenthash/ConsistentHashFactory.java 2010-07-15 15:33:09 UTC (rev 2039)
@@ -1,6 +1,7 @@
package org.infinispan.client.hotrod.impl.consistenthash;
+import org.infinispan.client.hotrod.impl.ConfigurationProperties;
import org.infinispan.util.Util;
import org.infinispan.util.logging.Log;
import org.infinispan.util.logging.LogFactory;
@@ -10,12 +11,14 @@
import java.util.Map;
import java.util.Properties;
+import static org.infinispan.client.hotrod.impl.ConfigurationProperties.HASH_FUNCTION_PREFIX;
+
/**
* Factory for {@link org.infinispan.client.hotrod.impl.consistenthash.ConsistentHash} function. It will try to look
* into the configuration for consistent hash definitions as follows:
* consistent-hash.[version]=[fully qualified class implementing ConsistentHash]
* e.g.
- * consistent-hash.1=org.infinispan.client.hotrod.impl.consistenthash.ConsitentHashV1
+ * infinispan.client.hotrod.hash_function_impl.1=org.infinispan.client.hotrod.impl.consistenthash.ConsitentHashV1
* <p/>
* If no CH function is defined for a certain version, then it will be defaulted to "org.infinispan.client.hotrod.impl.ConsistentHashV[version]".
* E.g. if the server indicates that in use CH is version 1, and it is not defined within the configuration, it will be defaulted to
@@ -30,13 +33,14 @@
private final Map<Integer, String> version2ConsistentHash = new HashMap<Integer, String>();
- public void init(Properties props) {
- for (String propName : props.stringPropertyNames()) {
- if (propName.indexOf("consistent-hash") >= 0) {
+ public void init(ConfigurationProperties config) {
+
+ for (String propName : config.getProperties().stringPropertyNames()) {
+ if (propName.startsWith(HASH_FUNCTION_PREFIX)) {
if (log.isTraceEnabled()) log.trace("Processing consistent hash: " + propName);
- String versionString = propName.substring("consistent-hash.".length());
+ String versionString = propName.substring((HASH_FUNCTION_PREFIX + ".").length());
int version = Integer.parseInt(versionString);
- String hashFunction = props.getProperty(propName);
+ String hashFunction = config.getProperties().getProperty(propName);
version2ConsistentHash.put(version, hashFunction);
if (log.isTraceEnabled()) {
log.trace("Added consistent hash version " + version + ": " + hashFunction);
@@ -51,6 +55,7 @@
if (log.isTraceEnabled()) log.trace("No hash function configured for version " + version);
hashFunctionClass = ConsistentHashFactory.class.getPackage().getName() + ".ConsistentHashV" + version;
if (log.isTraceEnabled()) log.trace("Trying to use default value: " + hashFunctionClass);
+ version2ConsistentHash.put(version, hashFunctionClass);
}
return (ConsistentHash) Util.getInstance(hashFunctionClass);
}
Modified: trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/TransportFactory.java
===================================================================
--- trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/TransportFactory.java 2010-07-15 13:16:27 UTC (rev 2038)
+++ trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/TransportFactory.java 2010-07-15 15:33:09 UTC (rev 2039)
@@ -1,5 +1,7 @@
package org.infinispan.client.hotrod.impl.transport;
+import org.infinispan.client.hotrod.impl.ConfigurationProperties;
+
import java.net.InetSocketAddress;
import java.util.Collection;
import java.util.LinkedHashMap;
@@ -21,7 +23,7 @@
public void releaseTransport(Transport transport);
- void start(Properties props, Collection<InetSocketAddress> staticConfiguredServers, AtomicInteger topologyId);
+ void start(ConfigurationProperties props, Collection<InetSocketAddress> staticConfiguredServers, AtomicInteger topologyId);
void updateServers(Collection<InetSocketAddress> newServers);
Modified: trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/tcp/TcpTransportFactory.java
===================================================================
--- trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/tcp/TcpTransportFactory.java 2010-07-15 13:16:27 UTC (rev 2038)
+++ trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/tcp/TcpTransportFactory.java 2010-07-15 15:33:09 UTC (rev 2039)
@@ -3,6 +3,7 @@
import net.jcip.annotations.ThreadSafe;
import org.apache.commons.pool.impl.GenericKeyedObjectPool;
import org.infinispan.client.hotrod.exceptions.TransportException;
+import org.infinispan.client.hotrod.impl.ConfigurationProperties;
import org.infinispan.client.hotrod.impl.consistenthash.ConsistentHash;
import org.infinispan.client.hotrod.impl.consistenthash.ConsistentHashFactory;
import org.infinispan.client.hotrod.impl.transport.Transport;
@@ -41,17 +42,14 @@
private final ConsistentHashFactory hashFactory = new ConsistentHashFactory();
@Override
- public void start(Properties props, Collection<InetSocketAddress> staticConfiguredServers, AtomicInteger topologyId) {
- hashFactory.init(props);
- String pingOnStartup = props.getProperty("ping-on-startup");
+ public void start(ConfigurationProperties cfg, Collection<InetSocketAddress> staticConfiguredServers, AtomicInteger topologyId) {
+ hashFactory.init(cfg);
+ boolean pingOnStartup = cfg.getPingOnStartup();
servers = staticConfiguredServers;
- String balancerClass = props.getProperty("request-balancing-strategy", RoundRobinBalancingStrategy.class.getName());
+ String balancerClass = cfg.getRequestBalancingStrategy();
balancer = (RequestBalancingStrategy) Util.getInstance(balancerClass);
- tcpNoDelay = Boolean.valueOf(props.getProperty("tcp-no-delay", "true"));
- if (log.isDebugEnabled()) log.debug("TCP no delay flag value is: {0}", tcpNoDelay);
- boolean skipPingOnStartup = pingOnStartup != null && !Boolean.valueOf(pingOnStartup);
- log.trace("'ping-on-startup' set to " + !skipPingOnStartup);
- PropsKeyedObjectPoolFactory poolFactory = new PropsKeyedObjectPoolFactory(new TransportObjectFactory(this, topologyId, !skipPingOnStartup), props);
+ tcpNoDelay = cfg.getTcpNoDelay();
+ PropsKeyedObjectPoolFactory poolFactory = new PropsKeyedObjectPoolFactory(new TransportObjectFactory(this, topologyId, pingOnStartup), cfg.getProperties());
createAndPreparePool(staticConfiguredServers, poolFactory);
balancer.setServers(servers);
}
Modified: trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/ClientConnectionPoolingTest.java
===================================================================
--- trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/ClientConnectionPoolingTest.java 2010-07-15 13:16:27 UTC (rev 2038)
+++ trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/ClientConnectionPoolingTest.java 2010-07-15 15:33:09 UTC (rev 2039)
@@ -2,6 +2,7 @@
import org.apache.commons.pool.impl.GenericKeyedObjectPool;
import org.infinispan.Cache;
+import org.infinispan.client.hotrod.impl.ConfigurationProperties;
import org.infinispan.client.hotrod.impl.transport.tcp.TcpTransportFactory;
import org.infinispan.commands.VisitableCommand;
import org.infinispan.context.InvocationContext;
@@ -67,7 +68,7 @@
String servers = TestHelper.getServersString(hotRodServer1, hotRodServer2);
Properties hotrodClientConf = new Properties();
- hotrodClientConf.put(RemoteCacheManager.CONF_HOTROD_SERVERS, servers);
+ hotrodClientConf.put(ConfigurationProperties.SERVER_LIST, servers);
hotrodClientConf.put("maxActive", 2);
hotrodClientConf.put("maxTotal", 8);
hotrodClientConf.put("maxIdle", 6);
Modified: trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/ConsistentHashFactoryTest.java
===================================================================
--- trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/ConsistentHashFactoryTest.java 2010-07-15 13:16:27 UTC (rev 2038)
+++ trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/ConsistentHashFactoryTest.java 2010-07-15 15:33:09 UTC (rev 2039)
@@ -1,5 +1,6 @@
package org.infinispan.client.hotrod;
+import org.infinispan.client.hotrod.impl.ConfigurationProperties;
import org.infinispan.client.hotrod.impl.consistenthash.ConsistentHash;
import org.infinispan.client.hotrod.impl.consistenthash.ConsistentHashFactory;
import org.infinispan.client.hotrod.impl.consistenthash.ConsistentHashV1;
@@ -19,9 +20,9 @@
public void testPropertyCorrectlyRead() {
Properties propos = new Properties();
String value = "org.infinispan.client.hotrod.impl.consistenthash.SomeCustomConsitentHashV1";
- propos.put("consistent-hash.1", value);
+ propos.put(ConfigurationProperties.HASH_FUNCTION_PREFIX + ".1", value);
ConsistentHashFactory chf = new ConsistentHashFactory();
- chf.init(propos);
+ chf.init(new ConfigurationProperties(propos));
String s = chf.getVersion2ConsistentHash().get(1);
assert s != null;
assert value.equals(s);
Modified: trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/RemoteCacheManagerTest.java
===================================================================
--- trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/RemoteCacheManagerTest.java 2010-07-15 13:16:27 UTC (rev 2038)
+++ trunk/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/RemoteCacheManagerTest.java 2010-07-15 15:33:09 UTC (rev 2039)
@@ -19,13 +19,11 @@
EmbeddedCacheManager cacheManager = null;
HotRodServer hotrodServer = null;
- private String prevValue;
@Override
protected EmbeddedCacheManager createCacheManager() throws Exception {
cacheManager = TestCacheManagerFactory.createLocalCacheManager();
hotrodServer = TestHelper.startHotRodServer(cacheManager);
- prevValue = System.setProperty(RemoteCacheManager.OVERRIDE_HOTROD_SERVERS, "localhost:" + hotrodServer.getPort());
return cacheManager;
}
@@ -37,11 +35,6 @@
} catch (Exception e) {
e.printStackTrace();
}
- if (prevValue != null) {
- System.setProperty(RemoteCacheManager.OVERRIDE_HOTROD_SERVERS, prevValue);
- } else {
- System.getProperties().remove(RemoteCacheManager.OVERRIDE_HOTROD_SERVERS);
- }
}
public void testNoArgConstructor() {
Added: trunk/core/src/main/java/org/infinispan/util/LegacyKeySupportSystemProperties.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/util/LegacyKeySupportSystemProperties.java (rev 0)
+++ trunk/core/src/main/java/org/infinispan/util/LegacyKeySupportSystemProperties.java 2010-07-15 15:33:09 UTC (rev 2039)
@@ -0,0 +1,42 @@
+package org.infinispan.util;
+
+import org.infinispan.util.logging.Log;
+import org.infinispan.util.logging.LogFactory;
+
+import java.util.Properties;
+
+/**
+ * A wrapper around system properties that supports legacy keys
+ *
+ * @author Manik Surtani
+ * @version 4.1
+ */
+public class LegacyKeySupportSystemProperties {
+
+ private static final Log log = LogFactory.getLog(LegacyKeySupportSystemProperties.class);
+
+ private static void warnLegacy(String oldKey, String newKey) {
+ if (log.isInfoEnabled()) log.info("Could not find value for key {0}, but did find value under deprecated key {1}. Please use {0} as support for {1} will eventually be discontinued.", newKey, oldKey);
+ }
+
+ public static String getProperty(String key, String legacyKey) {
+ String val = System.getProperty(key);
+ if (val == null) {
+ val = System.getProperty(legacyKey);
+ if (val != null) warnLegacy(legacyKey, key);
+ }
+ return val;
+ }
+
+ public static String getProperty(String key, String legacyKey, String defaultValue) {
+ String val = System.getProperty(key);
+ if (val == null) {
+ val = System.getProperty(legacyKey);
+ if (val != null)
+ warnLegacy(legacyKey, key);
+ else
+ val = defaultValue;
+ }
+ return val;
+ }
+}
Property changes on: trunk/core/src/main/java/org/infinispan/util/LegacyKeySupportSystemProperties.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/core/src/main/java/org/infinispan/util/LegacyKeySupportTypedProperties.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/util/LegacyKeySupportTypedProperties.java (rev 0)
+++ trunk/core/src/main/java/org/infinispan/util/LegacyKeySupportTypedProperties.java 2010-07-15 15:33:09 UTC (rev 2039)
@@ -0,0 +1,111 @@
+package org.infinispan.util;
+
+import org.infinispan.util.logging.Log;
+import org.infinispan.util.logging.LogFactory;
+
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * An extension of TypedProperties that has support for legacy keys. Construct this Properties type with mappings
+ * of currently expected keys to their legacy, deprecated counterparts and you will simply have to look up the new,
+ * updated keys and still be able to support the legacy keys, while logging a message that an old key was used.
+ *
+ * @author Manik Surtani
+ * @version 4.1
+ */
+public class LegacyKeySupportTypedProperties extends TypedProperties {
+ private final Map<String, String> legacyKeyMapping;
+ private static final Log log = LogFactory.getLog(LegacyKeySupportTypedProperties.class);
+
+ public LegacyKeySupportTypedProperties(Properties p, Map<String, String> legacyKeyMapping) {
+ super(p);
+ this.legacyKeyMapping = legacyKeyMapping;
+ }
+
+ public LegacyKeySupportTypedProperties(Map<String, String> legacyKeyMapping) {
+ this.legacyKeyMapping = legacyKeyMapping;
+ }
+
+ private void warnLegacy(String oldKey, String newKey) {
+ if (log.isInfoEnabled()) log.info("Could not find value for key {0}, but did find value under deprecated key {1}. Please use {0} as support for {1} will eventually be discontinued.", newKey, oldKey);
+ }
+
+ @Override
+ public String getProperty(String key) {
+ if (containsKey(key))
+ return super.getProperty(key);
+ else {
+ String legacyKey = legacyKeyMapping.get(key);
+ if (legacyKey == null) return null;
+ String val = super.getProperty(legacyKey);
+ if (val != null) warnLegacy(legacyKey, key);
+ return val;
+ }
+ }
+
+ @Override
+ public String getProperty(String key, String defaultValue) {
+ if (containsKey(key))
+ return super.getProperty(key);
+ else {
+ String legacyKey = legacyKeyMapping.get(key);
+ if (legacyKey == null) return defaultValue;
+ String val = super.getProperty(legacyKey);
+ if (val != null) {
+ warnLegacy(legacyKey, key);
+ return val;
+ } else {
+ return defaultValue;
+ }
+ }
+ }
+
+ @Override
+ public int getIntProperty(String key, int defaultValue) {
+ if (containsKey(key))
+ return super.getIntProperty(key, defaultValue);
+ else {
+ String legacyKey = legacyKeyMapping.get(key);
+ if (legacyKey == null) return defaultValue;
+ if (containsKey(legacyKey)) {
+ warnLegacy(legacyKey, key);
+ return super.getIntProperty(legacyKey, defaultValue);
+ } else {
+ return defaultValue;
+ }
+ }
+ }
+
+ @Override
+ public long getLongProperty(String key, long defaultValue) {
+ if (containsKey(key))
+ return super.getLongProperty(key, defaultValue);
+ else {
+ String legacyKey = legacyKeyMapping.get(key);
+ if (legacyKey == null) return defaultValue;
+ if (containsKey(legacyKey)) {
+ warnLegacy(legacyKey, key);
+ return super.getLongProperty(legacyKey, defaultValue);
+ } else {
+ return defaultValue;
+ }
+ }
+ }
+
+ @Override
+ public boolean getBooleanProperty(String key, boolean defaultValue) {
+ if (containsKey(key))
+ return super.getBooleanProperty(key, defaultValue);
+ else {
+ String legacyKey = legacyKeyMapping.get(key);
+ if (legacyKey == null) return defaultValue;
+ if (containsKey(legacyKey)) {
+ warnLegacy(legacyKey, key);
+ return super.getBooleanProperty(legacyKey, defaultValue);
+ } else {
+ return defaultValue;
+ }
+ }
+ }
+}
Property changes on: trunk/core/src/main/java/org/infinispan/util/LegacyKeySupportTypedProperties.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: trunk/core/src/test/java/org/infinispan/test/fwk/JGroupsConfigBuilder.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/test/fwk/JGroupsConfigBuilder.java 2010-07-15 13:16:27 UTC (rev 2038)
+++ trunk/core/src/test/java/org/infinispan/test/fwk/JGroupsConfigBuilder.java 2010-07-15 15:33:09 UTC (rev 2039)
@@ -2,6 +2,7 @@
import org.infinispan.config.parsing.JGroupsStackParser;
import org.infinispan.config.parsing.XmlConfigHelper;
+import org.infinispan.util.LegacyKeySupportSystemProperties;
import org.jgroups.util.Util;
import org.w3c.dom.Element;
@@ -66,7 +67,7 @@
private static final Pattern UDP_MCAST_PORT = Pattern.compile("mcast_port=[^;]*");
static {
- JGROUPS_STACK = System.getProperties().getProperty("protocol.stack", "tcp");
+ JGROUPS_STACK = LegacyKeySupportSystemProperties.getProperty("infinispan.test.jgroups.protocol", "protocol.stack", "tcp");
System.out.println("Transport protocol stack used = " + JGROUPS_STACK);
try {
Modified: trunk/core/src/test/java/org/infinispan/test/fwk/TestCacheManagerFactory.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/test/fwk/TestCacheManagerFactory.java 2010-07-15 13:16:27 UTC (rev 2038)
+++ trunk/core/src/test/java/org/infinispan/test/fwk/TestCacheManagerFactory.java 2010-07-15 15:33:09 UTC (rev 2039)
@@ -8,6 +8,7 @@
import org.infinispan.manager.DefaultCacheManager;
import org.infinispan.manager.EmbeddedCacheManager;
import org.infinispan.remoting.transport.jgroups.JGroupsTransport;
+import org.infinispan.util.LegacyKeySupportSystemProperties;
import org.infinispan.util.Util;
import org.infinispan.util.logging.Log;
import org.infinispan.util.logging.LogFactory;
@@ -31,7 +32,7 @@
private static AtomicInteger jmxDomainPostfix = new AtomicInteger();
- public static final String MARSHALLER = System.getProperties().getProperty("infinispan.marshaller.class");
+ public static final String MARSHALLER = LegacyKeySupportSystemProperties.getProperty("infinispan.test.marshaller.class", "infinispan.marshaller.class");
private static Log log = LogFactory.getLog(TestCacheManagerFactory.class);
private static ThreadLocal<PerThreadCacheManagers> perThreadCacheManagers = new ThreadLocal<PerThreadCacheManagers>() {
Modified: trunk/core/src/test/java/org/infinispan/test/fwk/TransactionSetup.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/test/fwk/TransactionSetup.java 2010-07-15 13:16:27 UTC (rev 2038)
+++ trunk/core/src/test/java/org/infinispan/test/fwk/TransactionSetup.java 2010-07-15 15:33:09 UTC (rev 2039)
@@ -23,6 +23,7 @@
import org.infinispan.transaction.lookup.DummyTransactionManagerLookup;
import org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup;
+import org.infinispan.util.LegacyKeySupportSystemProperties;
import javax.transaction.TransactionManager;
import javax.transaction.UserTransaction;
@@ -43,7 +44,7 @@
TransactionManager getManager();
}
- public static final String JTA = System.getProperty("infinispan.tm");
+ public static final String JTA = LegacyKeySupportSystemProperties.getProperty("infinispan.test.jta.tm", "infinispan.tm");
public static final String JBOSS_TM = "jbosstm";
private static Operations operations;
Modified: trunk/demos/ec2/src/main/java/org/infinispan/ec2demo/InfluenzaDataLoader.java
===================================================================
--- trunk/demos/ec2/src/main/java/org/infinispan/ec2demo/InfluenzaDataLoader.java 2010-07-15 13:16:27 UTC (rev 2038)
+++ trunk/demos/ec2/src/main/java/org/infinispan/ec2demo/InfluenzaDataLoader.java 2010-07-15 15:33:09 UTC (rev 2039)
@@ -6,6 +6,7 @@
import com.martiansoftware.jsap.JSAPResult;
import org.infinispan.Cache;
import org.infinispan.remoting.transport.Address;
+import org.infinispan.util.LegacyKeySupportSystemProperties;
import org.infinispan.util.logging.Log;
import org.infinispan.util.logging.LogFactory;
import org.xml.sax.SAXException;
@@ -30,7 +31,7 @@
private static final Log myLogger = LogFactory.getLog(InfluenzaDataLoader.class);
public void createCache(String configFile) throws IOException {
- String cfgFileName = System.getProperty("infinispan.demo.cfg");
+ String cfgFileName = LegacyKeySupportSystemProperties.getProperty("infinispan.configuration", "infinispan.demo.cfg");
if (cfgFileName == null)
cfgFileName = configFile;
Modified: trunk/demos/gridfs-webdav/src/main/java/org/infinispan/demos/gridfs/CacheManagerHolder.java
===================================================================
--- trunk/demos/gridfs-webdav/src/main/java/org/infinispan/demos/gridfs/CacheManagerHolder.java 2010-07-15 13:16:27 UTC (rev 2038)
+++ trunk/demos/gridfs-webdav/src/main/java/org/infinispan/demos/gridfs/CacheManagerHolder.java 2010-07-15 15:33:09 UTC (rev 2039)
@@ -17,7 +17,7 @@
private static final Log log = LogFactory.getLog(CacheManagerHolder.class);
- private static final String CFG_PROPERTY = "infinispan.gridfs.cfg";
+ private static final String CFG_PROPERTY = "infinispan.config";
private static final String DATA_CACHE_NAME_PROPERTY = "infinispan.gridfs.cache.data";
private static final String METADATA_CACHE_NAME_PROPERTY = "infinispan.gridfs.cache.metadata";
@@ -27,7 +27,7 @@
@Override
public void init(ServletConfig cfg) throws ServletException {
super.init(cfg);
- String cfgFile = System.getProperty(CFG_PROPERTY, cfg.getInitParameter(CFG_PROPERTY));
+ String cfgFile = cfg.getInitParameter(CFG_PROPERTY);
if (cfgFile == null)
cacheContainer = new DefaultCacheManager();
else {
@@ -39,7 +39,7 @@
}
}
- dataCacheName = System.getProperty(DATA_CACHE_NAME_PROPERTY, cfg.getInitParameter(DATA_CACHE_NAME_PROPERTY));
- metadataCacheName = System.getProperty(METADATA_CACHE_NAME_PROPERTY, cfg.getInitParameter(METADATA_CACHE_NAME_PROPERTY));
+ dataCacheName = cfg.getInitParameter(DATA_CACHE_NAME_PROPERTY);
+ metadataCacheName = cfg.getInitParameter(METADATA_CACHE_NAME_PROPERTY);
}
}
Modified: trunk/demos/gridfs-webdav/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/demos/gridfs-webdav/src/main/webapp/WEB-INF/web.xml 2010-07-15 13:16:27 UTC (rev 2038)
+++ trunk/demos/gridfs-webdav/src/main/webapp/WEB-INF/web.xml 2010-07-15 15:33:09 UTC (rev 2039)
@@ -13,19 +13,10 @@
<servlet-name>InitServlet</servlet-name>
<servlet-class>org.infinispan.demos.gridfs.CacheManagerHolder</servlet-class>
- <!--
- All of the values below can be overridden using JVM system properties.
- E.g.,
-
- -Dinfinispan.gridfs.cache.data=some_other_cache
-
- would override the data cache used to 'some_other_cache' as defined in your configuration XML.
- -->
-
<!-- specify your cache configuration file -->
<init-param>
- <param-name>infinispan.gridfs.cfg</param-name>
- <param-value>default.xml</param-value>
+ <param-name>infinispan.configuration</param-name>
+ <param-value>infinispan.xml</param-value>
</init-param>
<!-- specify your data cache name, as defined in your configuration file -->
@@ -109,32 +100,6 @@
<url-pattern>/*</url-pattern>
</servlet-mapping>
- <!-- ================ Security Constraints for Testing =============== -->
-
- <!--
- <security-constraint>
- <web-resource-collection>
- <web-resource-name>The Entire Web Application</web-resource-name>
- <url-pattern>/*</url-pattern>
- </web-resource-collection>
- <auth-constraint>
- <role-name>webdav</role-name>
- </auth-constraint>
- </security-constraint>
-
- <login-config>
- <auth-method>BASIC</auth-method>
- <realm-name>Tomcat Supported Realm</realm-name>
- </login-config>
-
- <security-role>
- <description>
- An example role defined in "conf/tomcat-users.xml"
- </description>
- <role-name>webdav</role-name>
- </security-role>
- -->
-
<welcome-file-list>
<welcome-file />
</welcome-file-list>
Modified: trunk/demos/gui/src/main/java/org/infinispan/demo/InfinispanDemo.form
===================================================================
--- trunk/demos/gui/src/main/java/org/infinispan/demo/InfinispanDemo.form 2010-07-15 13:16:27 UTC (rev 2038)
+++ trunk/demos/gui/src/main/java/org/infinispan/demo/InfinispanDemo.form 2010-07-15 15:33:09 UTC (rev 2039)
@@ -120,7 +120,7 @@
</constraints>
<properties>
<font size="12" style="2"/>
- <text value="Note that you can specify a configuration file to use by passing in -Dinfinispan.demo.cfg=file:/path/to/config.xml"/>
+ <text value="Note that you can specify a configuration file to use by passing in -Dinfinispan.configuration=file:/path/to/config.xml"/>
</properties>
</component>
</children>
Modified: trunk/demos/gui/src/main/java/org/infinispan/demo/InfinispanDemo.java
===================================================================
--- trunk/demos/gui/src/main/java/org/infinispan/demo/InfinispanDemo.java 2010-07-15 13:16:27 UTC (rev 2038)
+++ trunk/demos/gui/src/main/java/org/infinispan/demo/InfinispanDemo.java 2010-07-15 15:33:09 UTC (rev 2039)
@@ -13,6 +13,7 @@
import org.infinispan.notifications.cachemanagerlistener.annotation.ViewChanged;
import org.infinispan.notifications.cachemanagerlistener.event.ViewChangedEvent;
import org.infinispan.remoting.transport.Address;
+import org.infinispan.util.LegacyKeySupportSystemProperties;
import org.infinispan.util.logging.Log;
import org.infinispan.util.logging.LogFactory;
@@ -85,7 +86,7 @@
private CachedDataTableModel cachedDataTableModel;
public static void main(String[] args) {
- String cfgFileName = System.getProperty("infinispan.demo.cfg", "config-samples/gui-demo-cache-config.xml");
+ String cfgFileName = LegacyKeySupportSystemProperties.getProperty("infinispan.configuration", "infinispan.demo.cfg", "config-samples/gui-demo-cache-config.xml");
frame = new JFrame("Infinispan GUI Demo (STOPPED)");
frame.setContentPane(new InfinispanDemo(cfgFileName).panel1);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Modified: trunk/jopr-plugin/src/main/resources/META-INF/rhq-plugin.xml
===================================================================
--- trunk/jopr-plugin/src/main/resources/META-INF/rhq-plugin.xml 2010-07-15 13:16:27 UTC (rev 2038)
+++ trunk/jopr-plugin/src/main/resources/META-INF/rhq-plugin.xml 2010-07-15 15:33:09 UTC (rev 2039)
@@ -61,7 +61,7 @@
>
- <operation name="DeadlockDetectingLockManager.resetStatistics" displayName="[DeadlockDetectingLockManager] Reset statistics" description="Resets statistics gathered by this component">
+ <operation name="Activation.resetStatistics" displayName="[Activation] Reset statistics" description="Resets statistics gathered by this component">
</operation>
<operation name="Passivation.resetStatistics" displayName="[Passivation] Reset statistics" description="Resets statistics gathered by this component">
</operation>
@@ -69,9 +69,9 @@
</operation>
<operation name="Cache.stop" displayName="[Cache] Stops cache." description="Stops the cache.">
</operation>
- <operation name="Statistics.resetStatistics" displayName="[Statistics] Reset Statistics (Statistics)" description="Resets statistics gathered by this component">
+ <operation name="CacheStore.resetStatistics" displayName="[CacheStore] Reset statistics" description="Resets statistics gathered by this component">
</operation>
- <operation name="Activation.resetStatistics" displayName="[Activation] Reset statistics" description="Resets statistics gathered by this component">
+ <operation name="DeadlockDetectingLockManager.resetStatistics" displayName="[DeadlockDetectingLockManager] Reset statistics" description="Resets statistics gathered by this component">
</operation>
<operation name="Transactions.resetStatistics" displayName="[Transactions] Reset Statistics" description="Resets statistics gathered by this component">
</operation>
@@ -80,22 +80,6 @@
<c:simple-property name="enabled" description="Whether statistics should be enabled or disabled (true/false)"/>
</parameters>
</operation>
- <operation name="RpcManager.resetStatistics" displayName="[RpcManager] Reset statistics" description="Resets statistics gathered by this component">
- </operation>
- <operation name="RpcManager.setStatisticsEnabled" displayName="[RpcManager] Enable/disable statistics" description="Enable/disable statistics">
- <parameters>
- <c:simple-property name="enabled" description="Whether statistics should be enabled or disabled (true/false)"/>
- </parameters>
- </operation>
- <operation name="CacheStore.resetStatistics" displayName="[CacheStore] Reset statistics" description="Resets statistics gathered by this component">
- </operation>
- <operation name="Invalidation.resetStatistics" displayName="[Invalidation] Reset statistics" description="Resets statistics gathered by this component">
- </operation>
- <operation name="Invalidation.setStatisticsEnabled" displayName="[Invalidation] Enable/disable statistics" description="Enable/disable statistics">
- <parameters>
- <c:simple-property name="enabled" description="Whether statistics should be enabled or disabled (true/false)"/>
- </parameters>
- </operation>
<operation name="DistributionManager.isAffectedByRehash" displayName="[DistributionManager] Could key be affected by reshah?" description="Determines whether a given key is affected by an ongoing rehash, if any.">
<parameters>
<c:simple-property name="key" description="Key to check"/>
@@ -120,15 +104,45 @@
<c:simple-property name="operationResult" />
</results>
</operation>
+ <operation name="RpcManager.resetStatistics" displayName="[RpcManager] Reset statistics" description="Resets statistics gathered by this component">
+ </operation>
+ <operation name="RpcManager.setStatisticsEnabled" displayName="[RpcManager] Enable/disable statistics" description="Enable/disable statistics">
+ <parameters>
+ <c:simple-property name="enabled" description="Whether statistics should be enabled or disabled (true/false)"/>
+ </parameters>
+ </operation>
<operation name="CacheLoader.resetStatistics" displayName="[CacheLoader] Reset Statistics" description="Resets statistics gathered by this component">
</operation>
+ <operation name="Statistics.resetStatistics" displayName="[Statistics] Reset Statistics (Statistics)" description="Resets statistics gathered by this component">
+ </operation>
+ <operation name="Invalidation.resetStatistics" displayName="[Invalidation] Reset statistics" description="Resets statistics gathered by this component">
+ </operation>
+ <operation name="Invalidation.setStatisticsEnabled" displayName="[Invalidation] Enable/disable statistics" description="Enable/disable statistics">
+ <parameters>
+ <c:simple-property name="enabled" description="Whether statistics should be enabled or disabled (true/false)"/>
+ </parameters>
+ </operation>
+ <metric property="Activation.Activations" displayName="[Activation] Number of cache entries activated" displayType="detail" units="none" dataType="measurement"
+ description="Number of activation events" />
+ <metric property="Activation.CacheLoaderLoads" displayName="[Activation] Number of cache store loads" displayType="detail" units="none" dataType="measurement"
+ description="Number of entries loaded from cache store" />
+ <metric property="Activation.CacheLoaderMisses" displayName="[Activation] Number of cache store load misses" displayType="detail" units="none" dataType="measurement"
+ description="Number of entries that did not exist in cache store" />
+ <metric property="Passivation.Passivations" displayName="[Passivation] Number of cache passivations" displayType="detail" units="none" dataType="measurement"
+ description="Number of passivation events" />
<metric property="LockManager.ConcurrencyLevel" displayName="[LockManager] Concurrency level" displayType="detail" units="none" dataType="trait"
description="The concurrency level that the MVCC Lock Manager has been configured with." />
<metric property="LockManager.NumberOfLocksHeld" displayName="[LockManager] Number of locks held" displayType="detail" units="none" dataType="measurement"
description="The number of exclusive locks that are held." />
<metric property="LockManager.NumberOfLocksAvailable" displayName="[LockManager] Number of locks available" displayType="detail" units="none" dataType="measurement"
description="The number of exclusive locks that are available." />
+ <metric property="Cache.CacheStatus" displayName="[Cache] Cache status" displayType="summary" units="none" dataType="trait"
+ description="Returns the cache status" />
+ <metric property="Cache.CacheName" displayName="[Cache] Cache name" displayType="summary" units="none" dataType="trait"
+ description="Returns the cache name" />
+ <metric property="CacheStore.CacheLoaderStores" displayName="[CacheStore] Number of cache stores" displayType="detail" units="none" dataType="measurement"
+ description="number of cache loader stores" />
<metric property="DeadlockDetectingLockManager.OverlapWithNotDeadlockAwareLockOwners" displayName="[DeadlockDetectingLockManager] Number of unsolvable deadlock situations" displayType="detail" units="none" dataType="measurement"
description="Number of situtations when we try to determine a deadlock and the other lock owner is e.g. a local tx. In this scenario we cannot run the deadlock detection mechanism" />
<metric property="DeadlockDetectingLockManager.LocallyInterruptedTransactions" displayName="[DeadlockDetectingLockManager] Number of interrupted local transactions" displayType="detail" units="none" dataType="measurement"
@@ -145,12 +159,40 @@
description="The number of exclusive locks that are held." />
<metric property="DeadlockDetectingLockManager.NumberOfLocksAvailable" displayName="[DeadlockDetectingLockManager] Number of locks available" displayType="detail" units="none" dataType="measurement"
description="The number of exclusive locks that are available." />
- <metric property="Passivation.Passivations" displayName="[Passivation] Number of cache passivations" displayType="detail" units="none" dataType="measurement"
- description="Number of passivation events" />
- <metric property="Cache.CacheStatus" displayName="[Cache] Cache status" displayType="summary" units="none" dataType="trait"
- description="Returns the cache status" />
- <metric property="Cache.CacheName" displayName="[Cache] Cache name" displayType="summary" units="none" dataType="trait"
- description="Returns the cache name" />
+ <metric property="Transactions.StatisticsEnabled" displayName="[Transactions] Statistics enabled" displayType="detail" units="none" dataType="trait"
+ description="Statistics enabled" />
+ <metric property="Transactions.Prepares" displayName="[Transactions] Prepares" displayType="summary" units="none" dataType="measurement"
+ description="Number of transaction prepares performed since last reset" />
+ <metric property="Transactions.Commits" displayName="[Transactions] Commits" displayType="summary" units="none" dataType="measurement"
+ description="Number of transaction commits performed since last reset" />
+ <metric property="Transactions.Rollbacks" displayName="[Transactions] Rollbacks" displayType="summary" units="none" dataType="measurement"
+ description="Number of transaction rollbacks performed since last reset" />
+ <metric property="DistributionManager.RehashInProgress" displayName="[DistributionManager] Is rehash in progress?" displayType="detail" units="none" dataType="trait"
+ description="Checks whether the node is involved in a rehash." />
+ <metric property="DistributionManager.JoinComplete" displayName="[DistributionManager] Is join completed?" displayType="detail" units="none" dataType="trait"
+ description="If true, the node has successfully joined the grid and is considered to hold state. If false, the join process is still in progress." />
+ <metric property="RpcManager.Members" displayName="[RpcManager] Cluster members" displayType="summary" units="none" dataType="trait"
+ description="List of members in the cluster" />
+ <metric property="RpcManager.StatisticsEnabled" displayName="[RpcManager] Statistics enabled" displayType="detail" units="none" dataType="trait"
+ description="Statistics enabled" />
+ <metric property="RpcManager.ReplicationCount" displayName="[RpcManager] Number of successfull replications" displayType="summary" units="none" dataType="measurement"
+ description="Number of successful replications" />
+ <metric property="RpcManager.ReplicationFailures" displayName="[RpcManager] Number of failed replications" displayType="summary" units="none" dataType="measurement"
+ description="Number of failed replications" />
+ <metric property="RpcManager.NodeAddress" displayName="[RpcManager] Network address" displayType="summary" units="none" dataType="trait"
+ description="The network address associated with this instance" />
+ <metric property="RpcManager.PhysicalAddresses" displayName="[RpcManager] Physical network addresses" displayType="summary" units="none" dataType="trait"
+ description="The physical network addresses associated with this instance" />
+ <metric property="RpcManager.ClusterSize" displayName="[RpcManager] Cluster size" displayType="summary" units="none" dataType="measurement"
+ description="Size of the cluster in number of nodes" />
+ <metric property="RpcManager.SuccessRatioFloatingPoint" displayName="[RpcManager] Successful replication ratio" displayType="summary" units="percentage" dataType="measurement"
+ description="Successful replications as a ratio of total replications in numeric double format" />
+ <metric property="RpcManager.AverageReplicationTime" displayName="[RpcManager] Average time spent in the transport layer" displayType="summary" units="milliseconds" dataType="measurement"
+ description="The average time spent in the transport layer, in milliseconds" />
+ <metric property="CacheLoader.CacheLoaderLoads" displayName="[CacheLoader] Number of cache store loads" displayType="detail" units="none" dataType="measurement"
+ description="Number of entries loaded from cache store" />
+ <metric property="CacheLoader.CacheLoaderMisses" displayName="[CacheLoader] Number of cache store load misses" displayType="detail" units="none" dataType="measurement"
+ description="Number of entries that did not exist in cache store" />
<metric property="Statistics.Hits" displayName="[Statistics] Number of cache hits" displayType="summary" units="none" dataType="measurement"
description="Number of cache attribute hits" />
<metric property="Statistics.Misses" displayName="[Statistics] Number of cache misses" displayType="summary" units="none" dataType="measurement"
@@ -177,52 +219,10 @@
description="Number of seconds since cache started" />
<metric property="Statistics.TimeSinceReset" displayName="[Statistics] Seconds since cache statistics were reset" displayType="summary" units="seconds" dataType="measurement"
description="Number of seconds since the cache statistics were last reset" />
- <metric property="Activation.Activations" displayName="[Activation] Number of cache entries activated" displayType="detail" units="none" dataType="measurement"
- description="Number of activation events" />
- <metric property="Activation.CacheLoaderLoads" displayName="[Activation] Number of cache store loads" displayType="detail" units="none" dataType="measurement"
- description="Number of entries loaded from cache store" />
- <metric property="Activation.CacheLoaderMisses" displayName="[Activation] Number of cache store load misses" displayType="detail" units="none" dataType="measurement"
- description="Number of entries that did not exist in cache store" />
- <metric property="Transactions.StatisticsEnabled" displayName="[Transactions] Statistics enabled" displayType="detail" units="none" dataType="trait"
- description="Statistics enabled" />
- <metric property="Transactions.Prepares" displayName="[Transactions] Prepares" displayType="summary" units="none" dataType="measurement"
- description="Number of transaction prepares performed since last reset" />
- <metric property="Transactions.Commits" displayName="[Transactions] Commits" displayType="summary" units="none" dataType="measurement"
- description="Number of transaction commits performed since last reset" />
- <metric property="Transactions.Rollbacks" displayName="[Transactions] Rollbacks" displayType="summary" units="none" dataType="measurement"
- description="Number of transaction rollbacks performed since last reset" />
- <metric property="RpcManager.Members" displayName="[RpcManager] Cluster members" displayType="summary" units="none" dataType="trait"
- description="List of members in the cluster" />
- <metric property="RpcManager.StatisticsEnabled" displayName="[RpcManager] Statistics enabled" displayType="detail" units="none" dataType="trait"
- description="Statistics enabled" />
- <metric property="RpcManager.ReplicationCount" displayName="[RpcManager] Number of successfull replications" displayType="summary" units="none" dataType="measurement"
- description="Number of successful replications" />
- <metric property="RpcManager.ReplicationFailures" displayName="[RpcManager] Number of failed replications" displayType="summary" units="none" dataType="measurement"
- description="Number of failed replications" />
- <metric property="RpcManager.NodeAddress" displayName="[RpcManager] Network address" displayType="summary" units="none" dataType="trait"
- description="The network address associated with this instance" />
- <metric property="RpcManager.PhysicalAddresses" displayName="[RpcManager] Physical network addresses" displayType="summary" units="none" dataType="trait"
- description="The physical network addresses associated with this instance" />
- <metric property="RpcManager.ClusterSize" displayName="[RpcManager] Cluster size" displayType="summary" units="none" dataType="measurement"
- description="Size of the cluster in number of nodes" />
- <metric property="RpcManager.SuccessRatioFloatingPoint" displayName="[RpcManager] Successful replication ratio" displayType="summary" units="percentage" dataType="measurement"
- description="Successful replications as a ratio of total replications in numeric double format" />
- <metric property="RpcManager.AverageReplicationTime" displayName="[RpcManager] Average time spent in the transport layer" displayType="summary" units="milliseconds" dataType="measurement"
- description="The average time spent in the transport layer, in milliseconds" />
- <metric property="CacheStore.CacheLoaderStores" displayName="[CacheStore] Number of cache stores" displayType="detail" units="none" dataType="measurement"
- description="number of cache loader stores" />
<metric property="Invalidation.StatisticsEnabled" displayName="[Invalidation] Statistics enabled" displayType="detail" units="none" dataType="trait"
description="Statistics enabled" />
<metric property="Invalidation.Invalidations" displayName="[Invalidation] Number of invalidations" displayType="detail" units="none" dataType="measurement"
description="Number of invalidations" />
- <metric property="DistributionManager.RehashInProgress" displayName="[DistributionManager] Is rehash in progress?" displayType="detail" units="none" dataType="trait"
- description="Checks whether the node is involved in a rehash." />
- <metric property="DistributionManager.JoinComplete" displayName="[DistributionManager] Is join completed?" displayType="detail" units="none" dataType="trait"
- description="If true, the node has successfully joined the grid and is considered to hold state. If false, the join process is still in progress." />
- <metric property="CacheLoader.CacheLoaderLoads" displayName="[CacheLoader] Number of cache store loads" displayType="detail" units="none" dataType="measurement"
- description="Number of entries loaded from cache store" />
- <metric property="CacheLoader.CacheLoaderMisses" displayName="[CacheLoader] Number of cache store load misses" displayType="detail" units="none" dataType="measurement"
- description="Number of entries that did not exist in cache store" />
</service>
Modified: trunk/server/core/src/main/scala/org/infinispan/server/core/AbstractProtocolServer.scala
===================================================================
--- trunk/server/core/src/main/scala/org/infinispan/server/core/AbstractProtocolServer.scala 2010-07-15 13:16:27 UTC (rev 2038)
+++ trunk/server/core/src/main/scala/org/infinispan/server/core/AbstractProtocolServer.scala 2010-07-15 15:33:09 UTC (rev 2039)
@@ -14,12 +14,12 @@
* @since 4.1
*/
abstract class AbstractProtocolServer(threadNamePrefix: String) extends ProtocolServer {
- private var host: String = _
- private var port: Int = _
- private var masterThreads: Int = _
- private var workerThreads: Int = _
- private var transport: Transport = _
- private var cacheManager: EmbeddedCacheManager = _
+ protected var host: String = _
+ protected var port: Int = _
+ protected var masterThreads: Int = _
+ protected var workerThreads: Int = _
+ protected var transport: Transport = _
+ protected var cacheManager: EmbeddedCacheManager = _
def start(properties: Properties, cacheManager: EmbeddedCacheManager, defaultPort: Int) {
this.host = properties.getProperty(PROP_KEY_HOST, HOST_DEFAULT)
@@ -62,6 +62,10 @@
// Start default cache
startDefaultCache
val address = new InetSocketAddress(host, port)
+ startTransport(address, idleTimeout, tcpNoDelay, sendBufSize, recvBufSize)
+ }
+
+ def startTransport(address: InetSocketAddress, idleTimeout: Int, tcpNoDelay: Boolean, sendBufSize: Int, recvBufSize: Int) {
val encoder = getEncoder
val nettyEncoder = if (encoder != null) new EncoderAdapter(encoder) else null
transport = new NettyTransport(this, nettyEncoder, address, masterThreads, workerThreads, idleTimeout,
Modified: trunk/server/core/src/main/scala/org/infinispan/server/core/Main.scala
===================================================================
--- trunk/server/core/src/main/scala/org/infinispan/server/core/Main.scala 2010-07-15 13:16:27 UTC (rev 2038)
+++ trunk/server/core/src/main/scala/org/infinispan/server/core/Main.scala 2010-07-15 15:33:09 UTC (rev 2039)
@@ -3,7 +3,6 @@
import scala.collection.JavaConversions._
import scala.collection.mutable
import scala.collection.immutable
-import org.infinispan.util.Util
import java.io.IOException
import java.security.{PrivilegedAction, AccessController}
import java.util.concurrent.{ThreadFactory, ExecutionException, Callable, Executors}
@@ -12,6 +11,7 @@
import org.infinispan.manager.{CacheContainer, DefaultCacheManager}
import java.util.Properties
import org.infinispan.config.GlobalConfiguration.ShutdownHookBehavior
+import org.infinispan.util.{TypedProperties, Util}
/**
* Main class for server startup.
@@ -46,9 +46,8 @@
* information to get the server up and running. Use System
* properties for defaults.
*/
- private val props: Properties = new Properties(System.getProperties)
+ private val props: Properties = new TypedProperties(System.getProperties)
- private var programName: String = _
private var server: ProtocolServer = _
def main(args: Array[String]) {
@@ -81,12 +80,45 @@
// First process the command line to pickup custom props/settings
processCommandLine(args)
+ val properties = new Properties
+
+ val masterThreads = props.getProperty(PROP_KEY_MASTER_THREADS).toInt
+ if (masterThreads < 0)
+ throw new IllegalArgumentException("Master threads can't be lower than 0: " + masterThreads)
+
+ val workerThreads = props.getProperty(PROP_KEY_WORKER_THREADS).toInt
+ if (workerThreads < 0)
+ throw new IllegalArgumentException("Worker threads can't be lower than 0: " + masterThreads)
+
var protocol = props.getProperty(PROP_KEY_PROTOCOL)
if (protocol == null) {
System.err.println("ERROR: Please indicate protocol to run with -r parameter")
showAndExit
}
+ val idleTimeout = props.getProperty(PROP_KEY_IDLE_TIMEOUT).toInt
+ if (idleTimeout < -1)
+ throw new IllegalArgumentException("Idle timeout can't be lower than -1: " + idleTimeout)
+
+ val tcpNoDelay = props.getProperty(PROP_KEY_TCP_NO_DELAY)
+ try {
+ tcpNoDelay.toBoolean
+ } catch {
+ case n: NumberFormatException => {
+ throw new IllegalArgumentException("TCP no delay flag switch must be a boolean: " + tcpNoDelay)
+ }
+ }
+
+ val sendBufSize = props.getProperty(PROP_KEY_SEND_BUF_SIZE).toInt
+ if (sendBufSize < 0) {
+ throw new IllegalArgumentException("Send buffer size can't be lower than 0: " + sendBufSize)
+ }
+
+ val recvBufSize = props.getProperty(PROP_KEY_SEND_BUF_SIZE).toInt
+ if (recvBufSize < 0) {
+ throw new IllegalArgumentException("Send buffer size can't be lower than 0: " + sendBufSize)
+ }
+
// TODO: move class name and protocol number to a resource file under the corresponding project
val clazz = protocol match {
case "memcached" => "org.infinispan.server.memcached.MemcachedServer"
@@ -95,15 +127,33 @@
}
val server = Util.getInstance(clazz).asInstanceOf[ProtocolServer]
+ val port = {
+ if (props.getProperty(PROP_KEY_PORT) == null) {
+ protocol match {
+ case "memcached" => 11211
+ case "hotrod" => 11311
+ case "websocket" => 8181
+ }
+ } else {
+ props.getProperty(PROP_KEY_PORT).toInt
+ }
+ }
+ props.setProperty(PROP_KEY_PORT, port.toString)
+
+ // If no proxy host given, external host defaults to configured host
+ val externalHost = props.getProperty(PROP_KEY_PROXY_HOST, props.getProperty(PROP_KEY_HOST))
+ props.setProperty(PROP_KEY_PROXY_HOST, externalHost)
+ // If no proxy port given, external port defaults to configured port
+ val externalPort = props.getProperty(PROP_KEY_PROXY_PORT, props.getProperty(PROP_KEY_PORT))
+ props.setProperty(PROP_KEY_PROXY_PORT, externalPort)
+
val configFile = props.getProperty(PROP_KEY_CACHE_CONFIG)
val cacheManager = if (configFile == null) new DefaultCacheManager else new DefaultCacheManager(configFile)
- // Servers need a shutdown hook to close down network layer, so there's no need for an extra shutdown hook.
addShutdownHook(new ShutdownHook(server, cacheManager))
server.start(props, cacheManager)
}
private def processCommandLine(args: Array[String]) {
- programName = System.getProperty("program.name", "startServer")
var sopts = "-:hD:Vp:l:m:t:c:r:i:n:s:e:o:x:"
var lopts = Array(
new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h'),
@@ -121,12 +171,12 @@
new LongOpt("proxy_host", LongOpt.REQUIRED_ARGUMENT, null, 'o'),
new LongOpt("proxy_port", LongOpt.REQUIRED_ARGUMENT, null, 'x')
)
- var getopt = new Getopt(programName, args, sopts, lopts)
+ var getopt = new Getopt("startServer", args, sopts, lopts)
var code: Int = 0
while ((({code = getopt.getopt; code})) != -1) {
code match {
case ':' | '?' => System.exit(1)
- case 1 => System.err.println(programName + ": unused non-option argument: " + getopt.getOptarg)
+ case 1 => System.err.println("startServer: unused non-option argument: " + getopt.getOptarg)
case 'h' => showAndExit
case 'V' => {
Version.printFullVersionInformation
@@ -173,7 +223,7 @@
}
private def showAndExit {
- println("usage: " + programName + " [options]")
+ println("usage: startServer [options]")
println
println("options:")
println(" -h, --help Show this help message")
Modified: trunk/server/rest/src/main/scala/org/infinispan/rest/StartupListener.scala
===================================================================
--- trunk/server/rest/src/main/scala/org/infinispan/rest/StartupListener.scala 2010-07-15 13:16:27 UTC (rev 2038)
+++ trunk/server/rest/src/main/scala/org/infinispan/rest/StartupListener.scala 2010-07-15 15:33:09 UTC (rev 2039)
@@ -1,8 +1,9 @@
package org.infinispan.rest
-import javax.servlet.{ServletContextListener, ServletContextEvent}
import org.infinispan.manager.DefaultCacheManager
import scala.collection.JavaConversions._
+import javax.servlet.{ServletConfig, ServletContextListener, ServletContextEvent}
+import javax.servlet.http.HttpServlet
/**
* To init the cache manager. Nice to do this on startup as any config problems will be picked up before any
@@ -12,28 +13,20 @@
* @author Galder Zamarreno
* @since 4.0
*/
-class StartupListener extends ServletContextListener {
- val INFINISPAN_CONF = "infinispan.server.rest.cfg"
+class StartupListener extends HttpServlet {
+ override def init(cfg: ServletConfig) {
+ super.init(cfg)
+ val cfgFile = cfg getInitParameter "infinispan.config"
+ if (cfgFile == null)
+ ManagerInstance.instance = new DefaultCacheManager
+ else {
+ ManagerInstance.instance = new DefaultCacheManager(cfgFile)
+ }
- override def contextInitialized(ev: ServletContextEvent) {
- ManagerInstance.instance = makeCacheManager(ev)
- ManagerInstance.instance.start
-
// Start defined caches to avoid issues with lazily started caches
for (cacheName <- asIterator(ManagerInstance.instance.getCacheNames.iterator))
ManagerInstance.instance.getCache(cacheName)
// Finally, start default cache as well
ManagerInstance.instance.getCache[String, Any]
}
-
- override def contextDestroyed(ev: ServletContextEvent) = ManagerInstance.instance.stop
-
- /** Prefer the system property, but also allow the servlet context to set the path to the config */
- def makeCacheManager(ev: ServletContextEvent) =
- (System.getProperty(INFINISPAN_CONF), ev.getServletContext.getAttribute(INFINISPAN_CONF)) match {
- case (s: String, null) => new DefaultCacheManager(s)
- case (null, s: String) => new DefaultCacheManager(s)
- case _ => new DefaultCacheManager //fall back to LOCAL mode
- }
-
}
\ No newline at end of file
Modified: trunk/server/rest/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/server/rest/src/main/webapp/WEB-INF/web.xml 2010-07-15 13:16:27 UTC (rev 2038)
+++ trunk/server/rest/src/main/webapp/WEB-INF/web.xml 2010-07-15 15:33:09 UTC (rev 2039)
@@ -1,38 +1,47 @@
<?xml version="1.0"?>
-<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
+<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
- <display-name>Infinispan cache REST server</display-name>
+ <display-name>Infinispan cache REST server</display-name>
-
- <context-param>
- <param-name>resteasy.resources</param-name>
- <param-value>org.infinispan.rest.Server</param-value>
- </context-param>
+ <context-param>
+ <param-name>resteasy.resources</param-name>
+ <param-value>org.infinispan.rest.Server</param-value>
+ </context-param>
- <listener>
- <listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
- </listener>
+ <listener>
+ <listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
+ </listener>
- <listener>
- <listener-class>org.infinispan.rest.StartupListener</listener-class>
- </listener>
+ <servlet>
+ <servlet-name>InitServlet</servlet-name>
+ <servlet-class>org.infinispan.rest.StartupListener</servlet-class>
+ <!-- specify your cache configuration file -->
+ <init-param>
+ <param-name>infinispan.configuration</param-name>
+ <param-value>infinispan.xml</param-value>
+ </init-param>
- <servlet>
- <servlet-name>Resteasy</servlet-name>
- <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
- </servlet>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
- <servlet-mapping>
- <servlet-name>Resteasy</servlet-name>
- <url-pattern>/rest/*</url-pattern>
- </servlet-mapping>
+ <servlet>
+ <servlet-name>Resteasy</servlet-name>
+ <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
+ </servlet>
- <welcome-file-list>
- <welcome-file>/index.html</welcome-file>
- </welcome-file-list>
+ <servlet-mapping>
+ <servlet-name>Resteasy</servlet-name>
+ <url-pattern>/rest/*</url-pattern>
+ </servlet-mapping>
+ <welcome-file-list>
+ <welcome-file>/index.html</welcome-file>
+ </welcome-file-list>
+
</web-app>
+
Modified: trunk/server/rest/src/test/scala/org/infinispan/rest/ServerInstance.scala
===================================================================
--- trunk/server/rest/src/test/scala/org/infinispan/rest/ServerInstance.scala 2010-07-15 13:16:27 UTC (rev 2038)
+++ trunk/server/rest/src/test/scala/org/infinispan/rest/ServerInstance.scala 2010-07-15 15:33:09 UTC (rev 2039)
@@ -3,7 +3,7 @@
import org.apache.commons.httpclient.{HttpClient, HttpMethodBase}
import org.jboss.resteasy.plugins.server.servlet.{ResteasyBootstrap, HttpServletDispatcher}
-import org.mortbay.jetty.servlet.Context
+import org.mortbay.jetty.servlet.{ServletHolder, ServletHandler, Context}
/**
*
@@ -19,8 +19,10 @@
val ctx = new Context(server, "/", Context.SESSIONS)
ctx.setInitParams(params)
ctx.addEventListener(new ResteasyBootstrap)
- ctx.addEventListener(new StartupListener)
ctx.addServlet(classOf[HttpServletDispatcher], "/rest/*")
+ val sh = new ServletHolder(classOf[StartupListener])
+ sh setInitOrder 1
+ ctx.addServlet(sh, "/listener/*")
server.setStopAtShutdown(true)
server.start
server
Modified: trunk/server/websocket/src/main/java/org/infinispan/server/websocket/WebSocketServer.java
===================================================================
--- trunk/server/websocket/src/main/java/org/infinispan/server/websocket/WebSocketServer.java 2010-07-15 13:16:27 UTC (rev 2038)
+++ trunk/server/websocket/src/main/java/org/infinispan/server/websocket/WebSocketServer.java 2010-07-15 15:33:09 UTC (rev 2039)
@@ -78,38 +78,38 @@
}
@Override
- public void start(Properties properties, EmbeddedCacheManager cacheManager) {
- if (properties == null)
- properties = new Properties();
+ public void start(Properties p, EmbeddedCacheManager cacheManager) {
+ Properties properties = p == null ? new Properties() : p;
+ super.start(properties, cacheManager, 8181);
+ }
- String host = properties.getProperty("infinispan.server.host", "127.0.0.1");
- int port = Integer.parseInt(properties.getProperty("infinispan.server.port", "8181"));
- int masterThreads = Integer.parseInt(properties.getProperty("infinispan.server.master_threads"));
- int workerThreads = Integer.parseInt(properties.getProperty("infinispan.server.worker_threads"));
-
- InetSocketAddress address = new InetSocketAddress(host, port);
-
+ @Override
+ public void startTransport(InetSocketAddress address, int idleTimeout, boolean tcpNoDelay, int sendBufSize, int recvBufSize) {
Executor masterExecutor =
- masterThreads == 0 ?
+ masterThreads() == 0 ?
Executors.newCachedThreadPool() :
- Executors.newFixedThreadPool(masterThreads);
+ Executors.newFixedThreadPool(masterThreads());
Executor workerExecutor =
- workerThreads == 0 ?
+ workerThreads() == 0 ?
Executors.newCachedThreadPool():
- Executors.newFixedThreadPool(workerThreads);
+ Executors.newFixedThreadPool(workerThreads());
NioServerSocketChannelFactory factory =
- workerThreads == 0 ?
+ workerThreads() == 0 ?
new NioServerSocketChannelFactory(masterExecutor, workerExecutor) :
- new NioServerSocketChannelFactory(masterExecutor, workerExecutor, workerThreads);
+ new NioServerSocketChannelFactory(masterExecutor, workerExecutor, workerThreads());
// Configure the server.
ServerBootstrap bootstrap = new ServerBootstrap(factory);
// Set up the event pipeline factory.
- bootstrap.setPipelineFactory(new WebSocketServerPipelineFactory(cacheManager));
+ bootstrap.setPipelineFactory(new WebSocketServerPipelineFactory(cacheManager()));
// Bind and start to accept incoming connections.
+ bootstrap.setOption("child.tcpNoDelay", tcpNoDelay);
+ if (sendBufSize > 0) bootstrap.setOption("child.sendBufferSize", sendBufSize);
+ if (recvBufSize > 0) bootstrap.setOption("receiveBufferSize", recvBufSize);
+
bootstrap.bind(address);
}
More information about the infinispan-commits
mailing list