This project has retired. For details please refer to its Attic page.
PartitionOwner xref
View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  package org.apache.giraph.partition;
20  
21  import org.apache.giraph.worker.WorkerInfo;
22  import org.apache.hadoop.io.Writable;
23  
24  import java.io.DataInput;
25  import java.io.DataOutput;
26  import java.io.IOException;
27  import java.util.Map;
28  
29  /**
30   * Metadata about ownership of a partition.
31   */
32  public interface PartitionOwner extends Writable {
33    /**
34     * Get the partition id that maps to the relevant {@link Partition} object
35     *
36     * @return Partition id
37     */
38    int getPartitionId();
39  
40    /**
41     * Get the worker information that is currently responsible for
42     * the partition id.
43     *
44     * @return Owning worker information.
45     */
46    WorkerInfo getWorkerInfo();
47  
48    /**
49     * Set the current worker info.
50     *
51     * @param workerInfo Worker info responsible for partition
52     */
53    void setWorkerInfo(WorkerInfo workerInfo);
54  
55    /**
56     * Get the worker information that was previously responsible for the
57     * partition id.
58     *
59     * @return Owning worker information or null if no previous worker info.
60     */
61    WorkerInfo getPreviousWorkerInfo();
62  
63    /**
64     * Set the previous worker info.
65     *
66     * @param workerInfo Worker info that was previously responsible for the
67     *        partition.
68     */
69    void setPreviousWorkerInfo(WorkerInfo workerInfo);
70  
71    /**
72     * Write to the output, but don't serialize the whole WorkerInfo,
73     * instead use just the task id
74     *
75     * @param output Output to write to
76     * @throws IOException
77     */
78    void writeWithWorkerIds(DataOutput output) throws IOException;
79  
80    /**
81     * A match for writeWithWorkerIds method - for WorkerInfos it will read
82     * just task ids from input and then find the matching WorkerInfo in the
83     * provided map and set it
84     *
85     * @param input Input to read from
86     * @param workerInfoMap Map from task id to WorkerInfo
87     * @throws IOException
88     */
89    void readFieldsWithWorkerIds(DataInput input,
90        Map<Integer, WorkerInfo> workerInfoMap) throws IOException;
91  }