Skip to content

Instantly share code, notes, and snippets.

View gurbuzali's full-sized avatar
🏠
Working from home

Ali Gurbuz gurbuzali

🏠
Working from home
View GitHub Profile
import com.hazelcast.config.Config;
import com.hazelcast.config.MapConfig;
import com.hazelcast.config.MapStoreConfig;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.IMap;
import com.hazelcast.core.MapStore;
import java.util.Collection;
import java.util.HashSet;
@gurbuzali
gurbuzali / map-store-factory-example
Created October 14, 2014 08:30
msp store factory example
public static void main(String args[]) throws Exception {
MapStoreFactory factory = new MapStoreFactory() {
@Override
public MapLoader newMapStore(String mapName, Properties properties) {
return new BasicMapStore(mapName);
}
};
final Config config = new Config();
MapConfig mapConfig = config.getMapConfig("default");
MapStoreConfig mapStoreConfig = new MapStoreConfig();
Config config = new Config();
OffHeapMemoryConfig memoryConfig = config.getOffHeapMemoryConfig();
memoryConfig.setEnabled(true);
memoryConfig.setSize(new MemorySize(512, MemoryUnit.MEGABYTES));
config.setLicenseKey("LICENSE");
SecurityConfig securityConfig = config.getSecurityConfig();
securityConfig.setEnabled(true);
final PermissionConfig permissionConfig = new PermissionConfig();
permissionConfig.setType(PermissionConfig.PermissionType.ALL);
permissionConfig.setName("*");
@gurbuzali
gurbuzali / paging-predicate-test
Created November 20, 2014 08:21
paging-predicate-test
static void testPagingPredicate() {
HazelcastInstance instance = Hazelcast.newHazelcastInstance();
IMap<Object, Object> map = instance.getMap("map");
for (int i = 0; i < 20; i++) {
map.put(i, i);
}
PagingPredicate pagingPredicate = getPagingPredicate(0, 10, null);
Collection<Object> values = map.values(pagingPredicate);
@gurbuzali
gurbuzali / queue-memory-limit
Created January 7, 2015 19:26
queue memory limit
public static void main(String[] args) {
Config config = new Config();
QueueConfig queueConfig = config.getQueueConfig("q");
QueueStoreConfig queueStoreConfig = new QueueStoreConfig();
queueStoreConfig.setEnabled(true);
queueStoreConfig.setProperty("memory-limit", "10");
queueStoreConfig.setStoreImplementation(new QueueStore() {
@gurbuzali
gurbuzali / map-name
Created February 26, 2015 09:08
map-name
public class GurbuzTest {
public static void main(String[] args) {
Config config = new Config();
MapConfig mapConfig = new MapConfig();
mapConfig.setName("query.archive.*");
MapStoreConfig mapStoreConfig = new MapStoreConfig();
mapStoreConfig.setEnabled(true).setFactoryImplementation(new MyFac());
mapConfig.setMapStoreConfig(mapStoreConfig);
config.addMapConfig(mapConfig);
HazelcastInstance instance = Hazelcast.newHazelcastInstance(config);
package compile;
import com.hazelcast.config.Config;
import com.hazelcast.core.EntryAdapter;
import com.hazelcast.core.EntryEvent;
import com.hazelcast.core.EntryListener;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.IMap;
import com.hazelcast.core.MapEvent;
/*
* Copyright (c) 2008-2015, 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
/*
* Copyright (c) 2008-2015, 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
/*
* Copyright (c) 2008-2015, 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