1 package org.jgroups;
2 
3 import org.jgroups.conf.ClassConfigurator;
4 import org.jgroups.protocols.SCOPE;
5 import org.jgroups.util.UUID;
6 
7 /**
8  * Globals used by JGroups packages.
9  *
10  * @author Bela Ban Mar 29, 2004
11  */
12 public class Global {
13     public static final int BYTE_SIZE   = Byte.SIZE    / 8; // 1
14     public static final int SHORT_SIZE  = Short.SIZE   / 8; // 2
15     public static final int INT_SIZE    = Integer.SIZE / 8; // 4
16     public static final int LONG_SIZE   = Long.SIZE    / 8; // 8
17     public static final int DOUBLE_SIZE = Double.SIZE  / 8; // 8;
18     public static final int FLOAT_SIZE  = Float.SIZE   / 8; // 4;
19 
20     public static final Object NULL=new Object();
21     public static final Address NULL_ADDR=new UUID();
22 
23     public static final short SCOPE_ID=ClassConfigurator.getProtocolId(SCOPE.class);
24 
25     public static final String IPv4="java.net.preferIPv4Stack";
26     public static final String IPv6="java.net.preferIPv6Addresses";
27 
28     public static final String NON_LOOPBACK_ADDRESS="NON_LOOPBACK_ADDRESS";
29 
30 
31     public static final String BIND_ADDR="jgroups.bind_addr";
32     public static final String BIND_ADDR_OLD="bind.address";
33     public static final String BIND_INTERFACE="jgroups.bind_interface";
34     public static final String IGNORE_BIND_ADDRESS_PROPERTY="jgroups.ignore.bind_addr";
35     public static final String IGNORE_BIND_ADDRESS_PROPERTY_OLD="ignore.bind.address";
36 
37     public static final String TCPPING_INITIAL_HOSTS="jgroups.tcpping.initial_hosts";
38 
39     public static final String UDP_MCAST_ADDR="jgroups.udp.mcast_addr";
40     public static final String UDP_MCAST_PORT="jgroups.udp.mcast_port";
41     public static final String UDP_IP_TTL="jgroups.udp.ip_ttl";
42 
43     public static final String MPING_MCAST_ADDR="jgroups.mping.mcast_addr";
44     public static final String MPING_MCAST_PORT="jgroups.mping.mcast_port";
45     public static final String MPING_IP_TTL="jgroups.mping.ip_ttl";
46 
47     public static final String BPING_BIND_PORT="jgroups.bping.bind_port";
48 
49     public static final String STOMP_BIND_ADDR="jgroups.stomp.bind_addr";
50     public static final String STOMP_ENDPOINT_ADDR="jgroups.stomp.endpoint_addr";
51 
52     public static final String MAGIC_NUMBER_FILE="jgroups.conf.magic_number_file";
53     public static final String PROTOCOL_ID_FILE="jgroups.conf.protocol_id_file";
54     public static final String RESOLVE_DNS="jgroups.resolve_dns";
55     public static final String PRINT_UUIDS="jgroups.print_uuids";
56     public static final String UUID_CACHE_MAX_ELEMENTS="jgroups.uuid_cache.max_elements";
57     public static final String UUID_CACHE_MAX_AGE="jgroups.uuid_cache.max_age";
58 
59     public static final String IPV6_MCAST_PREFIX="jgroups.ipmcast.prefix";
60 
61     public static final String TIMER_NUM_THREADS="jgroups.timer.num_threads";
62 
63     public static final String MUX_ENABLED="jgroups.mux.enabled";
64     public static final String MUX_MIN_THREADS="jgroups.mux.min_threads";
65     public static final String MUX_MAX_THREADS="jgroups.mux.max_threads";
66     public static final String MUX_KEEPALIVE="jgroups.mux.keepalive_time";
67 
68     public static final String USE_JDK_LOGGER="jgroups.use.jdk_logger"; // forces use of the JDK logger
69     public static final String CUSTOM_LOG_FACTORY="jgroups.logging.log_factory_class";
70 
71     public static final long   DEFAULT_FIRST_UNICAST_SEQNO = 1;
72 
73     /** First ID assigned for building blocks (defined in jg-protocols.xml) */
74     public static final short  BLOCKS_START_ID=200;
75 
76     public static final String SINGLETON_NAME="singleton_name";
77 
78     public static final long   THREADPOOL_SHUTDOWN_WAIT_TIME=3000;
79     public static final long   THREAD_SHUTDOWN_WAIT_TIME=300;
80     public static final String DUMMY="dummy-";
81 
82     public static final String PREFIX="org.jgroups.protocols.";
83 
84     public static final String XML_VALIDATION="jgroups.xml.validation";
85 
86     // for TestNG
87     public static final String FUNCTIONAL="functional";
88     public static final String TIME_SENSITIVE="time-sensitive";
89     public static final String STACK_DEPENDENT="stack-dependent";
90     public static final String STACK_INDEPENDENT="stack-independent";
91     public static final String GOSSIP_ROUTER="gossip-router";
92     public static final String FLUSH="flush";
93     public static final String INITIAL_MCAST_ADDR="INITIAL_MCAST_ADDR";
94     public static final String INITIAL_MCAST_PORT="INITIAL_MCAST_PORT";
95     public static final String INITIAL_TCP_PORT="INITIAL_TCP_PORT";
96 
97     public static final String UDP_MCAST_SOCK="jgroups.udp.mcast_sock";
98     public static final String UDP_UCAST_SOCK="jgroups.udp.unicast_sock";
99     public static final String TCP_SRV_SOCK="jgroups.tcp.srv_sock";
100     public static final String TUNNEL_UCAST_SOCK="jgroups.tunnel.ucast_sock";
101     public static final String MPING_MCAST_SOCK="jgroups.mping.mcast_sock";
102     public static final String BPING_SOCK="jgroups.bping.sock";
103     public static final String TP_DIAG_MCAST_SOCK="jgroups.tp.diag.mcast_sock";
104     public static final String STREAMING_STATE_TRANSFER_SERVER_SOCK="jgroups.streaming_state_transfer.srv_sock";
105     public static final String FD_SOCK_SRV_SOCK="jgroups.fd_sock.srv_sock";
106     public static final String BSH_SRV_SOCK="jgroups.bsh.srv_sock";
107     public static final String STOMP_SRV_SOCK="jgroups.stomp.srv_sock";
108 
109     public static final String CCHM_INITIAL_CAPACITY="cchm.initial_capacity";
110     public static final String CCHM_LOAD_FACTOR="cchm.load_factor";
111     public static final String CCHM_CONCURRENCY_LEVEL="cchm.concurrency_level";
112 
113     public static final int IPV4_SIZE=4;
114     public static final int IPV6_SIZE=16;
115 
116 
117     public static final int SMALL_CLUSTER_SIZE=10;
118     public static final int NORMAL_CLUSTER_SIZE=20;
119     public static final int BIG_CLUSTER_SIZE=100;
120 
121 
122 
getPropertyAsBoolean(String property, boolean defaultValue)123     public static boolean getPropertyAsBoolean(String property, boolean defaultValue) {
124         boolean result = defaultValue;
125         try{
126             String tmp = System.getProperty(property);
127             if(tmp != null)
128                 result = Boolean.parseBoolean(tmp);
129         }
130         catch(Throwable t) {
131         }
132         return result;
133     }
134 
getPropertyAsLong(String property, long defaultValue)135     public static long getPropertyAsLong(String property, long defaultValue) {
136         long result = defaultValue;
137         try{
138             String tmp = System.getProperty(property);
139             if(tmp != null)
140                 result = Long.parseLong(tmp);
141         }
142         catch(Throwable t){
143         }
144         return result;
145     }
146 
getPropertyAsInteger(String property, int defaultValue)147     public static int getPropertyAsInteger(String property, int defaultValue) {
148         int result = defaultValue;
149         try{
150             String tmp = System.getProperty(property);
151             if(tmp != null)
152                 result = Integer.parseInt(tmp);
153         }
154         catch(Throwable t){
155         }
156         return result;
157     }
158 }
159