30
30
import java .util .List ;
31
31
import java .util .Map ;
32
32
33
+ import javax .swing .plaf .basic .BasicTreeUI .TreeToggleAction ;
34
+
35
+ import org .apache .commons .logging .Log ;
36
+ import org .apache .commons .logging .LogFactory ;
37
+
33
38
import eu .stratosphere .nephele .configuration .GlobalConfiguration ;
34
39
import eu .stratosphere .nephele .execution .ExecutionState ;
35
40
import eu .stratosphere .nephele .executiongraph .ExecutionGraph ;
39
44
import eu .stratosphere .nephele .io .channels .AbstractOutputChannel ;
40
45
import eu .stratosphere .nephele .io .channels .ChannelID ;
41
46
import eu .stratosphere .nephele .jobgraph .JobID ;
47
+ import eu .stratosphere .nephele .jobmanager .JobManager ;
42
48
import eu .stratosphere .nephele .jobmanager .scheduler .AbstractScheduler ;
43
49
import eu .stratosphere .nephele .protocols .ChannelLookupProtocol ;
44
50
import eu .stratosphere .nephele .taskmanager .bytebuffered .ConnectionInfoLookupResponse ;
53
59
54
60
public class MulticastManager implements ChannelLookupProtocol {
55
61
62
+ private static final Log LOG = LogFactory .getLog (JobManager .class );
63
+
56
64
// Indicates whether topology information is available and will be used in order to construct
57
65
// the multicast overlay-tree.
58
66
private final boolean topologyaware ;
@@ -111,60 +119,58 @@ public MulticastManager(final AbstractScheduler scheduler) {
111
119
*/
112
120
public synchronized ConnectionInfoLookupResponse lookupConnectionInfo (InstanceConnectionInfo caller , JobID jobID ,
113
121
ChannelID sourceChannelID ) {
114
- System .out .println ("==RECEIVING REQUEST FROM " + caller + " == SOURCE CHANNEL: " + sourceChannelID );
122
+
123
+ LOG .info ("Receiving multicast receiver request from " + caller + " channel ID: " + sourceChannelID );
124
+
115
125
// check, if the tree is already created and cached
116
126
if (this .cachedTrees .containsKey (sourceChannelID )) {
117
- System .out .println ("==RETURNING CACHED ENTRY TO " + caller + " ==" );
118
- System .out .println (cachedTrees .get (sourceChannelID ).getConnectionInfo (caller ));
119
-
127
+ LOG .info ("Replying with cached entry..." );
120
128
return cachedTrees .get (sourceChannelID ).getConnectionInfo (caller );
121
129
} else {
122
130
123
131
// no tree exists - we assume that this is the sending node initiating a multicast
124
132
125
- // first check, if all receivers are up and ready
126
133
if (!checkIfAllTargetVerticesExist (caller , jobID , sourceChannelID )) {
127
- // not all target vertices exist..
128
- System .out .println ("== NOT ALL RECEIVERS FOUND==" );
134
+ LOG .info ("Received multicast request but not all receivers found." );
129
135
return ConnectionInfoLookupResponse .createReceiverNotFound ();
130
136
}
131
137
132
138
if (!checkIfAllTargetVerticesReady (caller , jobID , sourceChannelID )) {
133
- // not all target vertices are ready..
134
- System . out . println ( "== NOT ALL RECEIVERS READY==" );
139
+ LOG . info ( "Received multicast request but not all receivers ready." );
140
+
135
141
return ConnectionInfoLookupResponse .createReceiverNotReady ();
136
142
}
137
143
138
- // receivers up and running.. create tree
144
+ // receivers up and running.. extract tree nodes...
139
145
LinkedList <TreeNode > treenodes = extractTreeNodes (caller , jobID , sourceChannelID , this .randomized );
140
146
141
- // first check, if we want to use a hard-coded tree topology...
147
+ // Do we want to use a hard-coded tree topology?
142
148
if (this .usehardcodedtree ) {
149
+ LOG .info ("Creating a hard-coded tree topology from file: " + hardcodedtreefilepath );
143
150
cachedTrees .put (sourceChannelID , createHardCodedTree (treenodes ));
144
- System .out .println ("==RETURNING ENTRY TO " + caller + " ==" );
145
- System .out .println (cachedTrees .get (sourceChannelID ).getConnectionInfo (caller ));
146
- System .out .println ("==END ENTRY==" );
147
151
return cachedTrees .get (sourceChannelID ).getConnectionInfo (caller );
148
152
}
149
153
150
- // if we want to use penalties, we now load the penalties from the harddisk
154
+ // Do we want to use penalties from a penalty file?
151
155
if (this .usepenalties && this .penaltyfilepath != null ) {
152
- System . out . println ("reading penalty file from: " + this .penaltyfilepath );
156
+ LOG . info ("reading penalty file from: " + this .penaltyfilepath );
153
157
File f = new File (this .penaltyfilepath );
154
158
readPenalitesFromFile (f , treenodes );
155
159
}
156
160
157
161
cachedTrees .put (sourceChannelID , createDefaultTree (treenodes , this .treebranching ));
158
-
159
- System .out .println ("==RETURNING ENTRY TO " + caller + " ==" );
160
- System .out .println (cachedTrees .get (sourceChannelID ).getConnectionInfo (caller ));
161
- System .out .println ("==END ENTRY==" );
162
162
return cachedTrees .get (sourceChannelID ).getConnectionInfo (caller );
163
163
164
164
}
165
165
166
166
}
167
167
168
+ /**
169
+ * Returns and removes the TreeNode which is closest to the given indicator.
170
+ * @param indicator
171
+ * @param nodes
172
+ * @return
173
+ */
168
174
private TreeNode pollClosestNode (TreeNode indicator , LinkedList <TreeNode > nodes ) {
169
175
170
176
TreeNode closestnode = getClosestNode (indicator , nodes );
@@ -175,6 +181,14 @@ private TreeNode pollClosestNode(TreeNode indicator, LinkedList<TreeNode> nodes)
175
181
176
182
}
177
183
184
+ /**
185
+ * Returns the TreeNode which is closest to the given indicator Node. Proximity is determined
186
+ * either using topology-information (if given), penalty information (if given) or it returns
187
+ * the first node in the list.
188
+ * @param indicator
189
+ * @param nodes
190
+ * @return
191
+ */
178
192
private TreeNode getClosestNode (TreeNode indicator , LinkedList <TreeNode > nodes ) {
179
193
180
194
if (indicator == null || !this .topologyaware && !this .usepenalties ) {
@@ -248,6 +262,12 @@ private MulticastForwardingTable createDefaultTree(LinkedList<TreeNode> nodes, i
248
262
249
263
}
250
264
265
+ /**
266
+ * Reads a hard-coded tree topology from file and creates a tree according to the hard-coded
267
+ * topology from the file.
268
+ * @param nodes
269
+ * @return
270
+ */
251
271
private MulticastForwardingTable createHardCodedTree (LinkedList <TreeNode > nodes ) {
252
272
try {
253
273
FileInputStream fstream = new FileInputStream (this .hardcodedtreefilepath );
@@ -346,15 +366,13 @@ private boolean checkIfAllTargetVerticesReady(InstanceConnectionInfo caller, Job
346
366
*/
347
367
private LinkedList <TreeNode > extractTreeNodes (InstanceConnectionInfo source , JobID jobID ,
348
368
ChannelID sourceChannelID , boolean randomize ) {
349
- System . out . println ( "==NO CACHE ENTRY FOUND. CREATING TREE==" );
369
+
350
370
final ExecutionGraph eg = this .scheduler .getExecutionGraphByID (jobID );
351
371
352
372
final AbstractOutputChannel <? extends Record > outputChannel = eg .getOutputChannelByID (sourceChannelID );
353
373
354
374
final OutputGate <? extends Record > broadcastgate = outputChannel .getOutputGate ();
355
375
356
- System .out .println ("Output gate is: " + broadcastgate .toString ());
357
-
358
376
final LinkedList <AbstractOutputChannel <? extends Record >> outputChannels = new LinkedList <AbstractOutputChannel <? extends Record >>();
359
377
360
378
// get all broadcast output channels
@@ -364,7 +382,6 @@ private LinkedList<TreeNode> extractTreeNodes(InstanceConnectionInfo source, Job
364
382
}
365
383
}
366
384
367
- System .out .println ("Number of output channels attached: " + outputChannels .size ());
368
385
369
386
for (AbstractOutputChannel <? extends Record > c : broadcastgate .getOutputChannels ()) {
370
387
System .out .println ("Out channel ID: "
0 commit comments