Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
VerboseByteStructMessageWrite |
|
| 1.5;1.5 |
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.utils; | |
20 | ||
21 | import java.io.DataOutput; | |
22 | import java.io.IOException; | |
23 | ||
24 | import org.apache.hadoop.io.Writable; | |
25 | import org.apache.hadoop.io.WritableComparable; | |
26 | ||
27 | /** Verbose Error mesage for ByteArray based messages */ | |
28 | public class VerboseByteStructMessageWrite { | |
29 | /** | |
30 | * Private Constructor | |
31 | */ | |
32 | 0 | private VerboseByteStructMessageWrite() { |
33 | 0 | } |
34 | ||
35 | /** | |
36 | * verboseWriteCurrentMessage | |
37 | * de-serialize, then write messages | |
38 | * | |
39 | * @param iterator iterator | |
40 | * @param out DataOutput | |
41 | * @param <I> vertexId | |
42 | * @param <M> message | |
43 | * @throws IOException | |
44 | * @throws RuntimeException | |
45 | */ | |
46 | public static <I extends WritableComparable, M extends Writable> | |
47 | void verboseWriteCurrentMessage( | |
48 | VertexIdMessageIterator<I, M> iterator, | |
49 | DataOutput out | |
50 | ) throws IOException { | |
51 | 0 | verboseWriteCurrentMessage( |
52 | 0 | iterator.getCurrentVertexId(), iterator.getCurrentMessage(), out); |
53 | 0 | } |
54 | ||
55 | /** | |
56 | * verboseWriteCurrentMessage | |
57 | * de-serialize, then write messages | |
58 | * | |
59 | * @param vertexId vertexId | |
60 | * @param message message | |
61 | * @param out DataOutput | |
62 | * @param <I> vertexId | |
63 | * @param <M> message | |
64 | * @throws IOException | |
65 | * @throws RuntimeException | |
66 | */ | |
67 | public static <I extends WritableComparable, M extends Writable> | |
68 | void verboseWriteCurrentMessage( | |
69 | I vertexId, | |
70 | M message, | |
71 | DataOutput out | |
72 | ) throws IOException { | |
73 | try { | |
74 | 0 | message.write(out); |
75 | 0 | } catch (NegativeArraySizeException e) { |
76 | 0 | handleNegativeArraySize(vertexId); |
77 | 0 | } |
78 | 0 | } |
79 | ||
80 | /** | |
81 | * message to present on NegativeArraySizeException | |
82 | * | |
83 | * @param vertexId vertexId | |
84 | * @param <I> vertexId type | |
85 | */ | |
86 | public static <I extends WritableComparable> | |
87 | void handleNegativeArraySize(I vertexId) { | |
88 | 0 | throw new RuntimeException("The number of bytes sent to vertex " + |
89 | vertexId + " exceeded the max capacity of its buffer. Please consider" + | |
90 | " setting giraph.useBigDataIOForMessages to true. You can do" + | |
91 | " this by adding the following option to your command line:" + | |
92 | " -Dgiraph.useBigDataIOForMessages=true." + | |
93 | " If there are super-vertices in the graph that receive many messages," + | |
94 | " setting this option will remove that limit"); | |
95 | } | |
96 | } |