View Javadoc
1   /*
2    * Copyright 2016 The Lannister Project
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package net.anyflow.lannister.cluster;
17  
18  import java.util.Set;
19  
20  public class HazelcastMap<K, V> implements Map<K, V> {
21  
22  	private com.hazelcast.core.IMap<K, V> engine;
23  
24  	public HazelcastMap(String name) {
25  		engine = Hazelcast.INSTANCE.getMap(name);
26  	}
27  
28  	@Override
29  	public void put(K key, V value) {
30  		engine.set(key, value);
31  	}
32  
33  	@Override
34  	public V get(K key) {
35  		return engine.get(key);
36  	}
37  
38  	@Override
39  	public V remove(K key) {
40  		return engine.remove(key);
41  	}
42  
43  	@Override
44  	public int size() {
45  		return engine.size();
46  	}
47  
48  	@Override
49  	public void dispose() {
50  		engine.destroy();
51  	}
52  
53  	@Override
54  	public boolean containsKey(K key) {
55  		return engine.containsKey(key);
56  	}
57  
58  	@Override
59  	public Set<K> keySet() {
60  		return engine.keySet();
61  	}
62  }