CVS update: JGroups/src/org/jgroups/util Util.java
"Bela Ban" <[email protected]> Fri, 17 Sep 2010 11:50:07 +0000
| Newsgroups | gmane.comp.java.javagroups.cvs |
|---|---|
| Message-ID | <[email protected]> |
User: belaban
Date: 10/09/17 11:50:07
Modified: src/org/jgroups/util Util.java
Log:
ns
Revision Changes Path
1.273 +39 -1 JGroups/src/org/jgroups/util/Util.java
Index: Util.java
===================================================================
RCS file: /cvsroot/javagroups/JGroups/src/org/jgroups/util/Util.java,v
retrieving revision 1.272
retrieving revision 1.273
diff -u -r1.272 -r1.273
--- Util.java 18 Aug 2010 07:43:48 -0000 1.272
+++ Util.java 17 Sep 2010 11:50:07 -0000 1.273
@@ -28,6 +28,8 @@
import java.security.MessageDigest;
import java.text.NumberFormat;
import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
@@ -35,7 +37,7 @@
/**
* Collection of various utility routines that can not be assigned to other classes.
* @author Bela Ban
- * @version $Id: Util.java,v 1.272 2010/08/18 07:43:48 belaban Exp $
+ * @version $Id: Util.java,v 1.273 2010/09/17 11:50:07 belaban Exp $
*/
public class Util {
@@ -66,6 +68,11 @@
private static Pattern METHOD_NAME_TO_ATTR_NAME_PATTERN=Pattern.compile("[A-Z]+");
private static Pattern ATTR_NAME_TO_METHOD_NAME_PATTERN=Pattern.compile("_.");
+
+ protected static int CCHM_INITIAL_CAPACITY=16;
+ protected static float CCHM_LOAD_FACTOR=0.75f;
+ protected static int CCHM_CONCURRENCY_LEVEL=16;
+
/**
* Global thread group to which all (most!) JGroups threads belong
*/
@@ -111,6 +118,24 @@
if(ip_stack_type == StackType.Unknown)
ip_stack_type=StackType.IPv6;
+
+ try {
+ String cchm_initial_capacity=System.getProperty(Global.CCHM_INITIAL_CAPACITY);
+ if(cchm_initial_capacity != null)
+ CCHM_INITIAL_CAPACITY=Integer.valueOf(cchm_initial_capacity);
+ } catch(SecurityException ex) {}
+
+ try {
+ String cchm_load_factor=System.getProperty(Global.CCHM_LOAD_FACTOR);
+ if(cchm_load_factor != null)
+ CCHM_LOAD_FACTOR=Float.valueOf(cchm_load_factor);
+ } catch(SecurityException ex) {}
+
+ try {
+ String cchm_concurrency_level=System.getProperty(Global.CCHM_CONCURRENCY_LEVEL);
+ if(cchm_concurrency_level != null)
+ CCHM_CONCURRENCY_LEVEL=Integer.valueOf(cchm_concurrency_level);
+ } catch(SecurityException ex) {}
}
@@ -2852,6 +2877,19 @@
}
+ public static <K,V> ConcurrentMap<K,V> createConcurrentMap(int initial_capacity, float load_factor, int concurrency_level) {
+ return new ConcurrentHashMap<K,V>(initial_capacity, load_factor, concurrency_level);
+ }
+
+ public static <K,V> ConcurrentMap<K,V> createConcurrentMap(int initial_capacity) {
+ return new ConcurrentHashMap<K,V>(initial_capacity);
+ }
+
+ public static <K,V> ConcurrentMap<K,V> createConcurrentMap() {
+ return new ConcurrentHashMap<K,V>(CCHM_INITIAL_CAPACITY, CCHM_LOAD_FACTOR, CCHM_CONCURRENCY_LEVEL);
+ }
+
+
/** Finds first available port starting at start_port and returns server socket */
public static ServerSocket createServerSocket(SocketFactory factory, String service_name, int start_port) {
ServerSocket ret=null;
------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev