/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. package com.hazelcast.impl.partition;
  17. import com.hazelcast.cluster.AbstractRemotelyProcessable;
  18. import com.hazelcast.cluster.MemberInfo;
  19. import com.hazelcast.impl.PartitionManager;
  20. import com.hazelcast.nio.Connection;
  21. import java.io.DataInput;
  22. import java.io.DataOutput;
  23. import java.io.IOException;
  24. import java.util.Collection;
  25. public class PartitionStateProcessable extends AbstractRemotelyProcessable {
  26. private PartitionRuntimeState partitionState;
  27. public PartitionStateProcessable(final Collection<MemberInfo> memberInfos,
  28. final PartitionInfo[] partitions,
  29. final long masterTime, int version) {
  30. partitionState = new PartitionRuntimeState(memberInfos, partitions, masterTime, version);
  31. }
  32. public PartitionStateProcessable() {
  33. }
  34. public void process() {
  35. PartitionManager partitionManager = node.concurrentMapManager.getPartitionManager();
  36. partitionManager.setPartitionRuntimeState(partitionState);
  37. }
  38. public void readData(DataInput in) throws IOException {
  39. partitionState = new PartitionRuntimeState();
  40. partitionState.readData(in);
  41. }
  42. public void writeData(DataOutput out) throws IOException {
  43. partitionState.writeData(out);
  44. }
  45. @Override
  46. public void setConnection(final Connection conn) {
  47. super.setConnection(conn);
  48. partitionState.setConnection(conn);
  49. }
  50. }