PageRenderTime 21ms CodeModel.GetById 10ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

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