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 package org.apache.giraph.conf;
19
20 import org.apache.giraph.combiner.MessageCombiner;
21 import org.apache.giraph.comm.messages.MessageEncodeAndStoreType;
22 import org.apache.giraph.factories.MessageValueFactory;
23 import org.apache.hadoop.io.Writable;
24 import org.apache.hadoop.io.WritableComparable;
25
26 /**
27 * Interface for containing all items that define message being sent,
28 * including it's value factory and combiner.
29 *
30 * @param <I>
31 * @param <M>
32 */
33 public interface MessageClasses
34 <I extends WritableComparable, M extends Writable> extends Writable {
35 /**
36 * Get message class
37 * @return message class
38 */
39 Class<M> getMessageClass();
40
41 /**
42 * Create new instance of MessageValueFactory
43 * @param conf Configuration
44 * @return message value factory
45 */
46 MessageValueFactory<M> createMessageValueFactory(
47 ImmutableClassesGiraphConfiguration conf);
48
49 /**
50 * Create new instance of MessageCombiner
51 * @param conf Configuration
52 * @return message combiner
53 */
54 MessageCombiner<? super I, M> createMessageCombiner(
55 ImmutableClassesGiraphConfiguration
56 <I, ? extends Writable, ? extends Writable> conf);
57
58 /**
59 * Has message combiner been specified
60 * @return has message combiner been specified
61 */
62 boolean useMessageCombiner();
63
64 /**
65 * Get MessageEncodeAndStoreType
66 * @return message encode and store type
67 */
68 MessageEncodeAndStoreType getMessageEncodeAndStoreType();
69
70 /**
71 * Creates a fresh copy of this object,
72 * to be used and changed for new superstep.
73 * (that should be independent from the previous one)
74 *
75 * @return message classes
76 */
77 MessageClasses<I, M> createCopyForNewSuperstep();
78
79 /**
80 * Verify if types are internally consistent
81 *
82 * @param conf Configuration
83 */
84 void verifyConsistent(ImmutableClassesGiraphConfiguration conf);
85
86 /**
87 * Whether to completely ignore existing vertices,
88 * and just process messages
89 *
90 * @return ignoreExistingVertices
91 */
92 boolean ignoreExistingVertices();
93 }