/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. package com.hazelcast.impl.management;
  17. import com.hazelcast.cluster.ClusterService;
  18. import com.hazelcast.core.HazelcastInstance;
  19. import com.hazelcast.core.HazelcastInstanceAware;
  20. import com.hazelcast.core.Prefix;
  21. import com.hazelcast.impl.CMap;
  22. import com.hazelcast.impl.ConcurrentMapManager;
  23. import com.hazelcast.impl.FactoryImpl;
  24. public abstract class ClusterServiceCallable implements HazelcastInstanceAware {
  25. protected transient HazelcastInstance hazelcastInstance;
  26. public void setHazelcastInstance(HazelcastInstance hazelcastInstance) {
  27. this.hazelcastInstance = hazelcastInstance;
  28. }
  29. protected ConcurrentMapManager getConcurrentMapManager() {
  30. FactoryImpl factory = getFactory();
  31. return factory.node.concurrentMapManager;
  32. }
  33. protected ClusterService getClusterService() {
  34. FactoryImpl factory = getFactory();
  35. return factory.node.clusterService;
  36. }
  37. protected FactoryImpl getFactory() {return (FactoryImpl) hazelcastInstance;}
  38. /**
  39. * ServiceThread-only!
  40. * Otherwise will throw an Error!
  41. */
  42. CMap getCMap(String mapName) {
  43. return getConcurrentMapManager().getOrCreateMap(Prefix.MAP + mapName);
  44. }
  45. }