Skip to content

Instantly share code, notes, and snippets.

View enesakar's full-sized avatar

Enes Akar enesakar

View GitHub Profile
public class Main {
public static void main(String[] args) {
Config cfg = new XmlConfigBuilder().build();
HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(cfg);
IMap<Object, Person> map = instance1.getMap("map");
Person p1 = new Person("mustafa", 25);
p1.props.add("v1");
Person p2 = new Person("ahmet", 45);
/*
* Copyright (c) 2008-2013, Hazelcast, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
package com.hazelcast.monitor;
public interface NearCacheStats extends LocalInstanceStats {
/**
* Returns the creation time of this NearCache on this member
*
* @return creation time of this NearCache on this member
*/
long getCreationTime();
@enesakar
enesakar / gist:9256472
Created February 27, 2014 18:47
c stats
package com.hazelcast.cache;
import com.hazelcast.monitor.NearCacheStats;
public interface CacheStats {
/**
* Returns the total number of entries in the cluster
*
@enesakar
enesakar / gist:9123542
Last active August 29, 2015 13:56
stats example
public static void main(String[] args) throws InterruptedException {
Config cfg = new XmlConfigBuilder().build();
cfg.setProperty("hazelcast.local.localAddress", "127.0.0.1");
cfg.setProperty(GroupProperties.PROP_HEALTH_MONITORING_LEVEL, HealthMonitorLevel.NOISY.toString());
// memory stats will be logged in every 10 seconds
cfg.setProperty(GroupProperties.PROP_HEALTH_MONITORING_DELAY_SECONDS, "10");
String cacheName = "cache";
MemorySize memorySize = new MemorySize(100, MemoryUnit.MEGABYTES);
private static class DefaultOutOfMemoryHandler extends OutOfMemoryHandler {
public void onOutOfMemory(final OutOfMemoryError oom, final HazelcastInstance[] hazelcastInstances) {
for (HazelcastInstance instance : hazelcastInstances) {
if (instance != null) {
Helper.tryCloseConnections(instance);
Helper.tryStopThreads(instance);
Helper.tryShutdown(instance);
}
}
HazelcastInstance instance = Hazelcast.newHazelcastInstance();
Hazelcast.setOutOfMemoryHandler(new OutOfMemoryHandler() {
@Override
public void onOutOfMemory(OutOfMemoryError oom, HazelcastInstance[] hazelcastInstances) {
for (HazelcastInstance hazelcastInstance : hazelcastInstances) {
hazelcastInstance.shutdown();
}
System.err.println("danger!!!");
}
});
public class ClientContinuousQueryTest {
public static void main(String[] args) {
Config config = new Config();
HazelcastInstance instance = Hazelcast.newHazelcastInstance(config);
IMap<Integer,Deal> theMap = instance.getMap("tradeMap");
theMap.put(3, new Deal(3));
ClientConfig clientConfig = new ClientConfig();
@enesakar
enesakar / gist:3002259
Created June 27, 2012 07:41
main mongo
package com.hazelmongo;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.GenericXmlApplicationContext;
import java.util.Map;
public class Main {
package com.hazelmongo;
import java.io.Serializable;
public class User implements Serializable {
private String name;
private int age;
public User(String name, int age) {
this.name = name;