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

https://bitbucket.org/gabral6_gmailcom/hazelcast · Java · 63 lines · 38 code · 10 blank · 15 comment · 0 complexity · 9ac95339610311187b71ad023dc8cfbd 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.config.MapConfig;
  18. import com.hazelcast.core.HazelcastInstanceAware;
  19. import com.hazelcast.impl.CMap;
  20. import com.hazelcast.impl.Processable;
  21. import com.hazelcast.nio.DataSerializable;
  22. import java.io.DataInput;
  23. import java.io.DataOutput;
  24. import java.io.IOException;
  25. import java.util.concurrent.Callable;
  26. import java.util.concurrent.atomic.AtomicReference;
  27. public class GetMapConfigCallable extends ClusterServiceCallable implements Callable<MapConfig>, HazelcastInstanceAware, DataSerializable {
  28. private static final long serialVersionUID = -3496139512682608428L;
  29. protected String mapName;
  30. public GetMapConfigCallable() {
  31. }
  32. public GetMapConfigCallable(String mapName) {
  33. super();
  34. this.mapName = mapName;
  35. }
  36. public MapConfig call() throws Exception {
  37. final AtomicReference<MapConfig> ref = new AtomicReference<MapConfig>();
  38. getClusterService().enqueueAndWait(new Processable() {
  39. public void process() {
  40. final CMap cmap = getCMap(mapName);
  41. MapConfig cfg = cmap.getRuntimeConfig();
  42. ref.set(cfg);
  43. }
  44. }, 5);
  45. return ref.get();
  46. }
  47. public void writeData(DataOutput out) throws IOException {
  48. out.writeUTF(mapName);
  49. }
  50. public void readData(DataInput in) throws IOException {
  51. mapName = in.readUTF();
  52. }
  53. }