PageRenderTime 24ms CodeModel.GetById 16ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

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