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

https://bitbucket.org/gabral6_gmailcom/hazelcast · Java · 61 lines · 35 code · 11 blank · 15 comment · 0 complexity · f2774f990c53ddfd92e5c57d3424112b 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.impl.CMap;
  19. import com.hazelcast.impl.Processable;
  20. import java.io.DataInput;
  21. import java.io.DataOutput;
  22. import java.io.IOException;
  23. public class UpdateMapConfigCallable extends GetMapConfigCallable {
  24. private static final long serialVersionUID = -7634684790969633350L;
  25. private MapConfig mapConfig;
  26. public UpdateMapConfigCallable() {
  27. }
  28. public UpdateMapConfigCallable(String mapName, MapConfig mapConfig) {
  29. super(mapName);
  30. this.mapConfig = mapConfig;
  31. }
  32. public MapConfig call() throws Exception {
  33. getClusterService().enqueueAndReturn(new Processable() {
  34. public void process() {
  35. final CMap cmap = getCMap(mapName);
  36. cmap.setRuntimeConfig(mapConfig);
  37. }
  38. });
  39. return null;
  40. }
  41. public void writeData(DataOutput out) throws IOException {
  42. super.writeData(out);
  43. mapConfig.writeData(out);
  44. }
  45. public void readData(DataInput in) throws IOException {
  46. super.readData(in);
  47. mapConfig = new MapConfig();
  48. mapConfig.readData(in);
  49. }
  50. }