PageRenderTime 9ms CodeModel.GetById 1ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/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
17package com.hazelcast.impl.management;
18
19import com.hazelcast.config.MapConfig;
20import com.hazelcast.impl.CMap;
21import com.hazelcast.impl.Processable;
22
23import java.io.DataInput;
24import java.io.DataOutput;
25import java.io.IOException;
26
27public class UpdateMapConfigCallable extends GetMapConfigCallable {
28
29    private static final long serialVersionUID = -7634684790969633350L;
30
31    private MapConfig mapConfig;
32
33    public UpdateMapConfigCallable() {
34    }
35
36    public UpdateMapConfigCallable(String mapName, MapConfig mapConfig) {
37        super(mapName);
38        this.mapConfig = mapConfig;
39    }
40
41    public MapConfig call() throws Exception {
42        getClusterService().enqueueAndReturn(new Processable() {
43            public void process() {
44                final CMap cmap = getCMap(mapName);
45                cmap.setRuntimeConfig(mapConfig);
46            }
47        });
48        return null;
49    }
50
51    public void writeData(DataOutput out) throws IOException {
52        super.writeData(out);
53        mapConfig.writeData(out);
54    }
55
56    public void readData(DataInput in) throws IOException {
57        super.readData(in);
58        mapConfig = new MapConfig();
59        mapConfig.readData(in);
60    }
61}