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

/hazelcast/src/main/java/com/hazelcast/impl/partition/PartitionStateProcessable.java

https://bitbucket.org/gabral6_gmailcom/hazelcast
Java | 60 lines | 35 code | 10 blank | 15 comment | 0 complexity | 713a36b5e67f89aab0da60cc597cbd4f 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.partition;
18
19import com.hazelcast.cluster.AbstractRemotelyProcessable;
20import com.hazelcast.cluster.MemberInfo;
21import com.hazelcast.impl.PartitionManager;
22import com.hazelcast.nio.Connection;
23
24import java.io.DataInput;
25import java.io.DataOutput;
26import java.io.IOException;
27import java.util.Collection;
28
29public class PartitionStateProcessable extends AbstractRemotelyProcessable {
30    private PartitionRuntimeState partitionState;
31
32    public PartitionStateProcessable(final Collection<MemberInfo> memberInfos,
33                                     final PartitionInfo[] partitions,
34                                     final long masterTime, int version) {
35        partitionState = new PartitionRuntimeState(memberInfos, partitions, masterTime, version);
36    }
37
38    public PartitionStateProcessable() {
39    }
40
41    public void process() {
42        PartitionManager partitionManager = node.concurrentMapManager.getPartitionManager();
43        partitionManager.setPartitionRuntimeState(partitionState);
44    }
45
46    public void readData(DataInput in) throws IOException {
47        partitionState = new PartitionRuntimeState();
48        partitionState.readData(in);
49    }
50
51    public void writeData(DataOutput out) throws IOException {
52        partitionState.writeData(out);
53    }
54
55    @Override
56    public void setConnection(final Connection conn) {
57        super.setConnection(conn);
58        partitionState.setConnection(conn);
59    }
60}