Created
February 27, 2014 12:25
-
-
Save cazacugmihai/9249123 to your computer and use it in GitHub Desktop.
hazelcast - issue #1688
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// start with: groovy -Djava.util.logging.config.file=logging.properties hazelcast.groovy | |
@GrabResolver(name='hazelcast', root='https://oss.sonatype.org/content/repositories/snapshots', m2Compatible=true) | |
@Grab('com.hazelcast:hazelcast:3.1.6') | |
import com.hazelcast.config.Config | |
import com.hazelcast.core.Hazelcast | |
import com.hazelcast.core.HazelcastInstance | |
import java.util.concurrent.ConcurrentMap | |
import static com.hazelcast.config.PartitionGroupConfig.MemberGroupType.HOST_AWARE | |
import static com.hazelcast.instance.GroupProperties.* | |
import static java.util.concurrent.TimeUnit.SECONDS | |
Config commonSetup() { | |
new Config().with { | |
//.setProperty(PROP_HEALTH_MONITORING_LEVEL, 'NOISY') | |
//.setProperty(PROP_INITIAL_MIN_CLUSTER_SIZE, '2') | |
setProperty(PROP_VERSION_CHECK_ENABLED, 'false') | |
setProperty(PROP_MC_URL_CHANGE_ENABLED, 'false') | |
setProperty(PROP_MEMCACHE_ENABLED, 'false') | |
setProperty(PROP_REST_ENABLED, 'false') | |
setProperty(PROP_MAX_NO_HEARTBEAT_SECONDS, '5') | |
setProperty(PROP_WAIT_SECONDS_BEFORE_JOIN, '0') | |
//.setProperty(PROP_MAX_NO_MASTER_CONFIRMATION_SECONDS, '5') | |
// managementCenterConfig | |
// .setEnabled(true) | |
// .setUrl('http://172.28.124.252:8080/mancenter-3.1.5') | |
groupConfig | |
.setName('sessions') | |
.setPassword('sessionsX') | |
partitionGroupConfig | |
.setEnabled(true) | |
.setGroupType(HOST_AWARE) | |
getMapConfig('sessions') | |
//.setReadBackupData(true) | |
//.setMaxIdleSeconds(60*60) | |
//.setBackupCount(0) | |
//.setAsyncBackupCount(1) | |
/* | |
config.getMapConfig('sessions') | |
.setBackupCount(1) | |
.setNearCacheConfig( | |
new NearCacheConfig() | |
.setTimeToLiveSeconds(60)) | |
*/ | |
return it | |
} | |
} | |
Config multicastSetup() { | |
println 'multicast setup' | |
commonSetup().with { | |
networkConfig.join.multicastConfig | |
.setMulticastGroup('239.252.3.253') | |
.setMulticastPort(4446) | |
networkConfig.interfaces | |
.setEnabled(true) | |
.addInterface('172.28.124.*') | |
return it | |
} | |
} | |
Config tcpIpSetup() { | |
println 'tcp setup' | |
commonSetup().with { | |
networkConfig.interfaces | |
.setEnabled(true) | |
.addInterface('172.28.124.*') | |
networkConfig.join.with { | |
multicastConfig.enabled = false | |
tcpIpConfig | |
.setEnabled(true) | |
.setRequiredMember(null) | |
.addMember('172.28.124.252') | |
.addMember('172.28.124.242') | |
} | |
return it | |
} | |
} | |
Config config = (args && args[0] == 'tcp') ? tcpIpSetup() : multicastSetup() | |
HazelcastInstance h = Hazelcast.newHazelcastInstance(config) | |
ConcurrentMap<String, Object> map = h.getMap('sessions') | |
def readLine = { String label -> System.console().readLine(label).trim() } | |
while (true) { | |
[ | |
'\nMenu', | |
'-------', | |
'1. Put', | |
'2. Get', | |
'3. Remove', | |
'0. Quit' | |
].each { println it } | |
try { | |
switch (readLine('Your option: ')) { | |
case '0': | |
println 'Bye!' | |
h.shutdown() | |
System.exit 0 | |
case '1': | |
String key = readLine('key: ') | |
String val = readLine('val: ') | |
map.putAsync(key, val).get(5, SECONDS) | |
break | |
case '2': | |
String key = readLine('key: ') | |
String val = map.getAsync(key).get(5, SECONDS) | |
println val | |
break | |
case '3': | |
String key = readLine('key: ') | |
map.removeAsync(key).get(5, SECONDS) | |
break | |
} | |
} catch (e) { | |
println "Error: $e.message" | |
e.printStackTrace() | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################################ | |
# Default Logging Configuration File | |
# | |
# You can use a different file by specifying a filename | |
# with the java.util.logging.config.file system property. | |
# For example java -Djava.util.logging.config.file=myfile | |
############################################################ | |
############################################################ | |
# Global properties | |
############################################################ | |
# "handlers" specifies a comma separated list of log Handler | |
# classes. These handlers will be installed during VM startup. | |
# Note that these classes must be on the system classpath. | |
# By default we only configure a ConsoleHandler, which will only | |
# show messages at the INFO and above levels. | |
handlers= java.util.logging.ConsoleHandler | |
# To also add the FileHandler, use the following line instead. | |
#handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler | |
# Default global logging level. | |
# This specifies which kinds of events are logged across | |
# all loggers. For any given facility this global level | |
# can be overriden by a facility specific level | |
# Note that the ConsoleHandler also has a separate level | |
# setting to limit messages printed to the console. | |
.level= SEVERE | |
############################################################ | |
# Handler specific properties. | |
# Describes specific configuration info for Handlers. | |
############################################################ | |
# default file output is in user's home directory. | |
java.util.logging.FileHandler.pattern = %h/java%u.log | |
java.util.logging.FileHandler.limit = 50000 | |
java.util.logging.FileHandler.count = 1 | |
java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter | |
# Limit the message that are printed on the console to INFO and above. | |
java.util.logging.ConsoleHandler.level = SEVERE | |
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter | |
# Example to customize the SimpleFormatter output format | |
# to print one-line log message like this: | |
# <level>: <log message> [<date/time>] | |
# | |
# java.util.logging.SimpleFormatter.format=%4$s: %5$s [%1$tc]%n | |
############################################################ | |
# Facility specific properties. | |
# Provides extra control for each logger. | |
############################################################ | |
# For example, set the com.xyz.foo logger to only log SEVERE | |
# messages: | |
com.hazelcast.level = SEVERE | |
com.hazelcast.health.monitoring.level= SEVERE | |
hazelcast.health.monitoring.level= SEVERE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment