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

https://bitbucket.org/gabral6_gmailcom/hazelcast · Java · 61 lines · 36 code · 10 blank · 15 comment · 5 complexity · ae3fb0328029d26794b67977bf046a0f 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.impl.FactoryImpl;
  18. import com.hazelcast.nio.DataSerializable;
  19. import java.io.DataInput;
  20. import java.io.DataOutput;
  21. import java.io.IOException;
  22. import java.util.concurrent.Callable;
  23. public class ManagementCenterConfigCallable extends ClusterServiceCallable implements Callable<Void>, DataSerializable {
  24. private String newUrl;
  25. private int redoCount = 10;
  26. public ManagementCenterConfigCallable() {
  27. }
  28. public ManagementCenterConfigCallable(String newUrl) {
  29. super();
  30. this.newUrl = newUrl;
  31. }
  32. public Void call() throws Exception {
  33. FactoryImpl factory = (FactoryImpl) hazelcastInstance;
  34. ManagementCenterService service = factory.node.getManagementCenterService();
  35. int count = 0;
  36. while (service == null && count < redoCount) {
  37. Thread.sleep(1000);
  38. count++;
  39. service = factory.node.getManagementCenterService();
  40. }
  41. if(service != null)
  42. service.changeWebServerUrl(newUrl);
  43. return null;
  44. }
  45. public void writeData(DataOutput out) throws IOException {
  46. out.writeUTF(newUrl);
  47. }
  48. public void readData(DataInput in) throws IOException {
  49. newUrl = in.readUTF();
  50. }
  51. }