PageRenderTime 284ms CodeModel.GetById 49ms app.highlight 170ms RepoModel.GetById 64ms app.codeStats 0ms

/hazelcast/src/main/java/com/hazelcast/impl/management/ClusterServiceCallable.java

https://bitbucket.org/gabral6_gmailcom/hazelcast
Java | 54 lines | 26 code | 9 blank | 19 comment | 0 complexity | a7162f7da35782a5503cb026cb6b979c MD5 | raw file
 1/*
 2 * Copyright (c) 2008-2013, Hazelcast, Inc. All Rights Reserved.
 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
17package com.hazelcast.impl.management;
18
19import com.hazelcast.cluster.ClusterService;
20import com.hazelcast.core.HazelcastInstance;
21import com.hazelcast.core.HazelcastInstanceAware;
22import com.hazelcast.core.Prefix;
23import com.hazelcast.impl.CMap;
24import com.hazelcast.impl.ConcurrentMapManager;
25import com.hazelcast.impl.FactoryImpl;
26
27public abstract class ClusterServiceCallable implements HazelcastInstanceAware {
28
29    protected transient HazelcastInstance hazelcastInstance;
30
31    public void setHazelcastInstance(HazelcastInstance hazelcastInstance) {
32        this.hazelcastInstance = hazelcastInstance;
33    }
34
35    protected ConcurrentMapManager getConcurrentMapManager() {
36        FactoryImpl factory = getFactory();
37        return factory.node.concurrentMapManager;
38    }
39
40    protected ClusterService getClusterService() {
41        FactoryImpl factory = getFactory();
42        return factory.node.clusterService;
43    }
44
45    protected FactoryImpl getFactory() {return (FactoryImpl) hazelcastInstance;}
46
47    /**
48     * ServiceThread-only!
49     * Otherwise will throw an Error!
50     */
51    CMap getCMap(String mapName) {
52        return getConcurrentMapManager().getOrCreateMap(Prefix.MAP + mapName);
53    }
54}