1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.giraph.conf;
20
21 import io.netty.buffer.ByteBufAllocator;
22 import io.netty.buffer.PooledByteBufAllocator;
23 import io.netty.buffer.UnpooledByteBufAllocator;
24
25 import java.net.InetAddress;
26 import java.net.UnknownHostException;
27
28 import org.apache.giraph.aggregators.AggregatorWriter;
29 import org.apache.giraph.bsp.checkpoints.CheckpointSupportedChecker;
30 import org.apache.giraph.combiner.MessageCombiner;
31 import org.apache.giraph.edge.OutEdges;
32 import org.apache.giraph.edge.ReuseObjectsOutEdges;
33 import org.apache.giraph.factories.ComputationFactory;
34 import org.apache.giraph.factories.VertexValueFactory;
35 import org.apache.giraph.graph.Computation;
36 import org.apache.giraph.graph.MapperObserver;
37 import org.apache.giraph.graph.Vertex;
38 import org.apache.giraph.graph.VertexResolver;
39 import org.apache.giraph.graph.VertexValueCombiner;
40 import org.apache.giraph.io.EdgeInputFormat;
41 import org.apache.giraph.io.EdgeOutputFormat;
42 import org.apache.giraph.io.MappingInputFormat;
43 import org.apache.giraph.io.VertexInputFormat;
44 import org.apache.giraph.io.VertexOutputFormat;
45 import org.apache.giraph.io.filters.EdgeInputFilter;
46 import org.apache.giraph.io.filters.VertexInputFilter;
47 import org.apache.giraph.job.GiraphJobObserver;
48 import org.apache.giraph.job.GiraphJobRetryChecker;
49 import org.apache.giraph.master.MasterCompute;
50 import org.apache.giraph.master.MasterObserver;
51 import org.apache.giraph.partition.GraphPartitionerFactory;
52 import org.apache.giraph.partition.Partition;
53 import org.apache.giraph.partition.ReusesObjectsPartition;
54 import org.apache.giraph.utils.GcObserver;
55 import org.apache.giraph.utils.ReflectionUtils;
56 import org.apache.giraph.worker.WorkerContext;
57 import org.apache.giraph.worker.WorkerObserver;
58 import org.apache.hadoop.conf.Configuration;
59 import org.apache.hadoop.mapreduce.Mapper;
60 import org.apache.hadoop.net.DNS;
61
62
63
64
65
66
67
68
69
70 public class GiraphConfiguration extends Configuration
71 implements GiraphConstants {
72
73 private ByteBufAllocator nettyBufferAllocator = null;
74
75
76
77
78 public GiraphConfiguration() {
79 configureHadoopSecurity();
80 }
81
82
83
84
85
86
87 public GiraphConfiguration(Configuration conf) {
88 super(conf);
89 configureHadoopSecurity();
90 }
91
92
93
94
95
96
97
98 public String getComputationName() {
99 ComputationFactory compFactory = ReflectionUtils.newInstance(
100 getComputationFactoryClass());
101 return compFactory.computationName(this);
102 }
103
104
105
106
107
108
109 public Class<? extends ComputationFactory> getComputationFactoryClass() {
110 return COMPUTATION_FACTORY_CLASS.get(this);
111 }
112
113
114
115
116
117
118 public Class<? extends Computation> getComputationClass() {
119 return COMPUTATION_CLASS.get(this);
120 }
121
122
123
124
125
126
127 public void setComputationClass(
128 Class<? extends Computation> computationClass) {
129 COMPUTATION_CLASS.set(this, computationClass);
130 }
131
132
133
134
135
136
137 public final void setVertexValueFactoryClass(
138 Class<? extends VertexValueFactory> vertexValueFactoryClass) {
139 VERTEX_VALUE_FACTORY_CLASS.set(this, vertexValueFactoryClass);
140 }
141
142
143
144
145
146
147 public void setEdgeInputFilterClass(
148 Class<? extends EdgeInputFilter> edgeFilterClass) {
149 EDGE_INPUT_FILTER_CLASS.set(this, edgeFilterClass);
150 }
151
152
153
154
155
156
157 public void setVertexInputFilterClass(
158 Class<? extends VertexInputFilter> vertexFilterClass) {
159 VERTEX_INPUT_FILTER_CLASS.set(this, vertexFilterClass);
160 }
161
162
163
164
165
166
167 public Class<? extends OutEdges> getOutEdgesClass() {
168 return VERTEX_EDGES_CLASS.get(this);
169 }
170
171
172
173
174
175
176 public final void setOutEdgesClass(
177 Class<? extends OutEdges> outEdgesClass) {
178 VERTEX_EDGES_CLASS.set(this, outEdgesClass);
179 }
180
181
182
183
184
185
186 public final void setVertexClass(Class<? extends Vertex> vertexClass) {
187 VERTEX_CLASS.set(this, vertexClass);
188 }
189
190
191
192
193
194
195
196
197 public final void setInputOutEdgesClass(
198 Class<? extends OutEdges> inputOutEdgesClass) {
199 INPUT_VERTEX_EDGES_CLASS.set(this, inputOutEdgesClass);
200 }
201
202
203
204
205
206
207
208
209
210
211
212
213 public boolean reuseEdgeObjects() {
214 return ReuseObjectsOutEdges.class.isAssignableFrom(
215 getOutEdgesClass());
216 }
217
218
219
220
221
222
223
224
225
226
227 public boolean reuseVertexObjects() {
228 return ReusesObjectsPartition.class.isAssignableFrom(getPartitionClass());
229 }
230
231
232
233
234
235 public Class<? extends Partition> getPartitionClass() {
236 return PARTITION_CLASS.get(this);
237 }
238
239
240
241
242
243
244 public boolean hasVertexInputFormat() {
245 return VERTEX_INPUT_FORMAT_CLASS.get(this) != null;
246 }
247
248
249
250
251
252
253 public void setVertexInputFormatClass(
254 Class<? extends VertexInputFormat> vertexInputFormatClass) {
255 VERTEX_INPUT_FORMAT_CLASS.set(this, vertexInputFormatClass);
256 }
257
258
259
260
261
262
263 public boolean hasEdgeInputFormat() {
264 return EDGE_INPUT_FORMAT_CLASS.get(this) != null;
265 }
266
267
268
269
270
271
272 public void setEdgeInputFormatClass(
273 Class<? extends EdgeInputFormat> edgeInputFormatClass) {
274 EDGE_INPUT_FORMAT_CLASS.set(this, edgeInputFormatClass);
275 }
276
277
278
279
280
281
282 public void setMappingInputFormatClass(
283 Class<? extends MappingInputFormat> mappingInputFormatClass) {
284 MAPPING_INPUT_FORMAT_CLASS.set(this, mappingInputFormatClass);
285 }
286
287
288
289
290
291
292 public final void setMasterComputeClass(
293 Class<? extends MasterCompute> masterComputeClass) {
294 MASTER_COMPUTE_CLASS.set(this, masterComputeClass);
295 }
296
297
298
299
300
301
302 public final void addMasterObserverClass(
303 Class<? extends MasterObserver> masterObserverClass) {
304 MASTER_OBSERVER_CLASSES.add(this, masterObserverClass);
305 }
306
307
308
309
310
311
312 public final void addWorkerObserverClass(
313 Class<? extends WorkerObserver> workerObserverClass) {
314 WORKER_OBSERVER_CLASSES.add(this, workerObserverClass);
315 }
316
317
318
319
320
321
322 public final void addMapperObserverClass(
323 Class<? extends MapperObserver> mapperObserverClass) {
324 MAPPER_OBSERVER_CLASSES.add(this, mapperObserverClass);
325 }
326
327
328
329
330
331
332 public final void addGcObserverClass(
333 Class<? extends GcObserver> gcObserverClass) {
334 GC_OBSERVER_CLASSES.add(this, gcObserverClass);
335 }
336
337
338
339
340
341
342 public Class<? extends GiraphJobObserver> getJobObserverClass() {
343 return JOB_OBSERVER_CLASS.get(this);
344 }
345
346
347
348
349
350
351 public void setJobObserverClass(Class<? extends GiraphJobObserver> klass) {
352 JOB_OBSERVER_CLASS.set(this, klass);
353 }
354
355
356
357
358
359
360 public Class<? extends GiraphJobRetryChecker> getJobRetryCheckerClass() {
361 return JOB_RETRY_CHECKER_CLASS.get(this);
362 }
363
364
365
366
367
368
369 public void setJobRetryCheckerClass(
370 Class<? extends GiraphJobRetryChecker> klass) {
371 JOB_RETRY_CHECKER_CLASS.set(this, klass);
372 }
373
374
375
376
377
378
379 public boolean isJMapHistogramDumpEnabled() {
380 return JMAP_ENABLE.get(this);
381 }
382
383
384
385
386
387
388 public boolean isReactiveJmapHistogramDumpEnabled() {
389 return REACTIVE_JMAP_ENABLE.get(this);
390 }
391
392
393
394
395
396
397
398
399 public final void setClasses(String name, Class<?> xface,
400 Class<?> ... klasses) {
401 String[] klassNames = new String[klasses.length];
402 for (int i = 0; i < klasses.length; ++i) {
403 Class<?> klass = klasses[i];
404 if (!xface.isAssignableFrom(klass)) {
405 throw new RuntimeException(klass + " does not implement " +
406 xface.getName());
407 }
408 klassNames[i] = klasses[i].getName();
409 }
410 setStrings(name, klassNames);
411 }
412
413
414
415
416
417
418 public boolean hasVertexOutputFormat() {
419 return VERTEX_OUTPUT_FORMAT_CLASS.get(this) != null;
420 }
421
422
423
424
425
426
427 public final void setVertexOutputFormatClass(
428 Class<? extends VertexOutputFormat> vertexOutputFormatClass) {
429 VERTEX_OUTPUT_FORMAT_CLASS.set(this, vertexOutputFormatClass);
430 }
431
432
433
434
435
436
437
438 public boolean hasVertexOutputFormatSubdir() {
439 return !VERTEX_OUTPUT_FORMAT_SUBDIR.get(this).isEmpty();
440 }
441
442
443
444
445
446
447 public final void setVertexOutputFormatSubdir(String path) {
448 VERTEX_OUTPUT_FORMAT_SUBDIR.set(this, path);
449 }
450
451
452
453
454
455
456 public final boolean doOutputDuringComputation() {
457 return DO_OUTPUT_DURING_COMPUTATION.get(this);
458 }
459
460
461
462
463
464
465
466 public final void setDoOutputDuringComputation(
467 boolean doOutputDuringComputation) {
468 DO_OUTPUT_DURING_COMPUTATION.set(this, doOutputDuringComputation);
469 }
470
471
472
473
474
475
476 public final boolean vertexOutputFormatThreadSafe() {
477 return VERTEX_OUTPUT_FORMAT_THREAD_SAFE.get(this);
478 }
479
480
481
482
483
484
485
486 public final void setVertexOutputFormatThreadSafe(
487 boolean vertexOutputFormatThreadSafe) {
488 VERTEX_OUTPUT_FORMAT_THREAD_SAFE.set(this, vertexOutputFormatThreadSafe);
489 }
490
491
492
493
494
495
496 public boolean hasEdgeOutputFormat() {
497 return EDGE_OUTPUT_FORMAT_CLASS.get(this) != null;
498 }
499
500
501
502
503
504
505 public final void setEdgeOutputFormatClass(
506 Class<? extends EdgeOutputFormat> edgeOutputFormatClass) {
507 EDGE_OUTPUT_FORMAT_CLASS.set(this, edgeOutputFormatClass);
508 }
509
510
511
512
513
514
515 public boolean hasEdgeOutputFormatSubdir() {
516 return !EDGE_OUTPUT_FORMAT_SUBDIR.get(this).isEmpty();
517 }
518
519
520
521
522
523
524 public final void setEdgeOutputFormatSubdir(String path) {
525 EDGE_OUTPUT_FORMAT_SUBDIR.set(this, path);
526 }
527
528
529
530
531
532
533
534 public final int getNumOutputThreads() {
535 if (!vertexOutputFormatThreadSafe()) {
536 return 1;
537 } else {
538 return NUM_OUTPUT_THREADS.get(this);
539 }
540 }
541
542
543
544
545
546
547
548 public void setNumOutputThreads(int numOutputThreads) {
549 NUM_OUTPUT_THREADS.set(this, numOutputThreads);
550 }
551
552
553
554
555
556
557 public void setMessageCombinerClass(
558 Class<? extends MessageCombiner> messageCombinerClass) {
559 MESSAGE_COMBINER_CLASS.set(this, messageCombinerClass);
560 }
561
562
563
564
565
566
567 public final void setGraphPartitionerFactoryClass(
568 Class<? extends GraphPartitionerFactory> graphPartitionerFactoryClass) {
569 GRAPH_PARTITIONER_FACTORY_CLASS.set(this, graphPartitionerFactoryClass);
570 }
571
572
573
574
575
576
577 public final void setVertexResolverClass(
578 Class<? extends VertexResolver> vertexResolverClass) {
579 VERTEX_RESOLVER_CLASS.set(this, vertexResolverClass);
580 }
581
582
583
584
585
586
587
588 public final boolean getResolverCreateVertexOnMessages() {
589 return RESOLVER_CREATE_VERTEX_ON_MSGS.get(this);
590 }
591
592
593
594
595
596
597 public final void setResolverCreateVertexOnMessages(boolean v) {
598 RESOLVER_CREATE_VERTEX_ON_MSGS.set(this, v);
599 }
600
601
602
603
604
605
606 public final void setVertexValueCombinerClass(
607 Class<? extends VertexValueCombiner> vertexValueCombinerClass) {
608 VERTEX_VALUE_COMBINER_CLASS.set(this, vertexValueCombinerClass);
609 }
610
611
612
613
614
615
616
617 public final void setWorkerContextClass(
618 Class<? extends WorkerContext> workerContextClass) {
619 WORKER_CONTEXT_CLASS.set(this, workerContextClass);
620 }
621
622
623
624
625
626
627
628 public final void setAggregatorWriterClass(
629 Class<? extends AggregatorWriter> aggregatorWriterClass) {
630 AGGREGATOR_WRITER_CLASS.set(this, aggregatorWriterClass);
631 }
632
633
634
635
636
637
638 public final void setPartitionClass(
639 Class<? extends Partition> partitionClass) {
640 PARTITION_CLASS.set(this, partitionClass);
641 }
642
643
644
645
646
647
648
649
650
651
652
653 public final void setWorkerConfiguration(int minWorkers,
654 int maxWorkers,
655 float minPercentResponded) {
656 setInt(MIN_WORKERS, minWorkers);
657 setInt(MAX_WORKERS, maxWorkers);
658 MIN_PERCENT_RESPONDED.set(this, minPercentResponded);
659 }
660
661 public final int getMinWorkers() {
662 return getInt(MIN_WORKERS, -1);
663 }
664
665 public final int getMaxWorkers() {
666 return getInt(MAX_WORKERS, -1);
667 }
668
669 public final float getMinPercentResponded() {
670 return MIN_PERCENT_RESPONDED.get(this);
671 }
672
673
674
675
676
677
678
679 public final int getMaxMappers() {
680 return getMaxWorkers() + (SPLIT_MASTER_WORKER.get(this) ? 1 : 0);
681 }
682
683
684
685
686
687
688
689
690 public final void setZooKeeperConfiguration(String serverList) {
691 ZOOKEEPER_LIST.set(this, serverList);
692 }
693
694
695
696
697
698
699 public final boolean getSplitMasterWorker() {
700 return SPLIT_MASTER_WORKER.get(this);
701 }
702
703
704
705
706
707
708 public Class<? extends MasterObserver>[] getMasterObserverClasses() {
709 return MASTER_OBSERVER_CLASSES.getArray(this);
710 }
711
712
713
714
715
716
717 public Class<? extends WorkerObserver>[] getWorkerObserverClasses() {
718 return WORKER_OBSERVER_CLASSES.getArray(this);
719 }
720
721
722
723
724
725
726 public Class<? extends MapperObserver>[] getMapperObserverClasses() {
727 return MAPPER_OBSERVER_CLASSES.getArray(this);
728 }
729
730
731
732
733
734
735 public Class<? extends GcObserver>[] getGcObserverClasses() {
736 return GC_OBSERVER_CLASSES.getArray(this);
737 }
738
739
740
741
742
743
744 public boolean metricsEnabled() {
745 return METRICS_ENABLE.isTrue(this);
746 }
747
748
749
750
751
752
753 public int getTaskPartition() {
754 return getInt("mapred.task.partition", -1);
755 }
756
757
758
759
760
761
762
763 public boolean isPureYarnJob() {
764 return IS_PURE_YARN_JOB.get(this);
765 }
766
767
768
769
770
771
772
773 public String getYarnLibJars() {
774 return GIRAPH_YARN_LIBJARS.get(this);
775 }
776
777
778
779
780
781
782 public void setYarnLibJars(String jarList) {
783 GIRAPH_YARN_LIBJARS.set(this, jarList);
784 }
785
786
787
788
789
790
791
792 public int getYarnTaskHeapMb() {
793 return GIRAPH_YARN_TASK_HEAP_MB.get(this);
794 }
795
796
797
798
799
800
801
802 public void setYarnTaskHeapMb(int heapMb) {
803 GIRAPH_YARN_TASK_HEAP_MB.set(this, heapMb);
804 }
805
806
807
808
809
810
811 public String getZookeeperList() {
812 return ZOOKEEPER_LIST.get(this);
813 }
814
815
816
817
818
819
820
821
822 public void setZookeeperList(String zkList) {
823 ZOOKEEPER_LIST.set(this, zkList);
824 ZOOKEEPER_IS_EXTERNAL.set(this, false);
825 }
826
827
828
829
830
831
832 public boolean isZookeeperExternal() {
833 return ZOOKEEPER_IS_EXTERNAL.get(this);
834 }
835
836 public String getLocalLevel() {
837 return LOG_LEVEL.get(this);
838 }
839
840
841
842
843
844
845 public boolean useLogThreadLayout() {
846 return LOG_THREAD_LAYOUT.get(this);
847 }
848
849
850
851
852
853
854 public boolean getLocalTestMode() {
855 return LOCAL_TEST_MODE.get(this);
856 }
857
858
859
860
861
862
863 public void setLocalTestMode(boolean flag) {
864 LOCAL_TEST_MODE.set(this, flag);
865 }
866
867 public int getZooKeeperSessionTimeout() {
868 return ZOOKEEPER_SESSION_TIMEOUT.get(this);
869 }
870
871 public int getZookeeperOpsMaxAttempts() {
872 return ZOOKEEPER_OPS_MAX_ATTEMPTS.get(this);
873 }
874
875 public int getZookeeperOpsRetryWaitMsecs() {
876 return ZOOKEEPER_OPS_RETRY_WAIT_MSECS.get(this);
877 }
878
879 public boolean getNettyServerUseExecutionHandler() {
880 return NETTY_SERVER_USE_EXECUTION_HANDLER.get(this);
881 }
882
883 public int getNettyServerThreads() {
884 return NETTY_SERVER_THREADS.get(this);
885 }
886
887 public int getNettyServerExecutionThreads() {
888 return NETTY_SERVER_EXECUTION_THREADS.get(this);
889 }
890
891
892
893
894
895
896
897 public int getNettyServerExecutionConcurrency() {
898 if (getNettyServerUseExecutionHandler()) {
899 return getNettyServerExecutionThreads();
900 } else {
901 return getNettyServerThreads();
902 }
903 }
904
905
906
907
908
909
910 public ByteBufAllocator getNettyAllocator() {
911 if (nettyBufferAllocator == null) {
912 if (NETTY_USE_POOLED_ALLOCATOR.get(this)) {
913 nettyBufferAllocator = new PooledByteBufAllocator(
914 NETTY_USE_DIRECT_MEMORY.get(this));
915 } else {
916
917 nettyBufferAllocator = new UnpooledByteBufAllocator(
918 NETTY_USE_DIRECT_MEMORY.get(this));
919 }
920 }
921 return nettyBufferAllocator;
922 }
923
924 public int getZookeeperConnectionAttempts() {
925 return ZOOKEEPER_CONNECTION_ATTEMPTS.get(this);
926 }
927
928 public int getZooKeeperMinSessionTimeout() {
929 return ZOOKEEPER_MIN_SESSION_TIMEOUT.get(this);
930 }
931
932 public int getZooKeeperMaxSessionTimeout() {
933 return ZOOKEEPER_MAX_SESSION_TIMEOUT.get(this);
934 }
935
936
937
938
939
940
941 public int getMapTasks() {
942 int mapTasks = getInt("mapred.map.tasks", -1);
943 if (mapTasks == -1) {
944 throw new IllegalStateException("getMapTasks: Failed to get the map " +
945 "tasks!");
946 }
947 return mapTasks;
948 }
949
950
951
952
953
954
955 public boolean authenticate() {
956 return AUTHENTICATE.get(this);
957 }
958
959
960
961
962
963
964 public void setNumComputeThreads(int numComputeThreads) {
965 NUM_COMPUTE_THREADS.set(this, numComputeThreads);
966 }
967
968 public int getNumComputeThreads() {
969 return NUM_COMPUTE_THREADS.get(this);
970 }
971
972
973
974
975
976
977 public void setNumInputSplitsThreads(int numInputSplitsThreads) {
978 NUM_INPUT_THREADS.set(this, numInputSplitsThreads);
979 }
980
981 public int getNumInputSplitsThreads() {
982 return NUM_INPUT_THREADS.get(this);
983 }
984
985 public long getInputSplitMaxVertices() {
986 return INPUT_SPLIT_MAX_VERTICES.get(this);
987 }
988
989 public long getInputSplitMaxEdges() {
990 return INPUT_SPLIT_MAX_EDGES.get(this);
991 }
992
993
994
995
996
997
998 public void useUnsafeSerialization(boolean useUnsafeSerialization) {
999 USE_UNSAFE_SERIALIZATION.set(this, useUnsafeSerialization);
1000 }
1001
1002
1003
1004
1005
1006
1007
1008 public void setCheckpointFrequency(int checkpointFrequency) {
1009 CHECKPOINT_FREQUENCY.set(this, checkpointFrequency);
1010 }
1011
1012
1013
1014
1015
1016
1017
1018 public int getCheckpointFrequency() {
1019 return CHECKPOINT_FREQUENCY.get(this);
1020 }
1021
1022
1023
1024
1025
1026
1027 public boolean useCheckpointing() {
1028 return getCheckpointFrequency() != 0;
1029 }
1030
1031
1032
1033
1034
1035
1036
1037
1038 public void setCheckpointSupportedChecker(
1039 Class<? extends CheckpointSupportedChecker> clazz) {
1040 GiraphConstants.CHECKPOINT_SUPPORTED_CHECKER.set(this, clazz);
1041 }
1042
1043
1044
1045
1046
1047
1048 public void setMaxTaskAttempts(int maxTaskAttempts) {
1049 MAX_TASK_ATTEMPTS.set(this, maxTaskAttempts);
1050 }
1051
1052
1053
1054
1055
1056
1057 public int getMaxTaskAttempts() {
1058 return MAX_TASK_ATTEMPTS.get(this);
1059 }
1060
1061
1062
1063
1064
1065
1066 public int getEventWaitMsecs() {
1067 return EVENT_WAIT_MSECS.get(this);
1068 }
1069
1070
1071
1072
1073
1074
1075
1076 public void setEventWaitMsecs(int eventWaitMsecs) {
1077 EVENT_WAIT_MSECS.set(this, eventWaitMsecs);
1078 }
1079
1080
1081
1082
1083
1084
1085
1086
1087 public int getMaxMasterSuperstepWaitMsecs() {
1088 return MAX_MASTER_SUPERSTEP_WAIT_MSECS.get(this);
1089 }
1090
1091 public int getMaxCounterWaitMsecs() {
1092 return MAX_COUNTER_WAIT_MSECS.get(this);
1093 }
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103 public void setMaxMasterSuperstepWaitMsecs(int maxMasterSuperstepWaitMsecs) {
1104 MAX_MASTER_SUPERSTEP_WAIT_MSECS.set(this, maxMasterSuperstepWaitMsecs);
1105 }
1106
1107
1108
1109
1110
1111 public void configureHadoopSecurity() {
1112 String hadoopTokenFilePath = System.getenv("HADOOP_TOKEN_FILE_LOCATION");
1113 if (hadoopTokenFilePath != null) {
1114 set("mapreduce.job.credentials.binary", hadoopTokenFilePath);
1115 }
1116 }
1117
1118
1119
1120
1121
1122
1123 public boolean useInputSplitLocality() {
1124 return USE_INPUT_SPLIT_LOCALITY.get(this);
1125 }
1126
1127
1128
1129
1130
1131
1132
1133 public String getLocalHostname() throws UnknownHostException {
1134 return DNS.getDefaultHost(
1135 GiraphConstants.DNS_INTERFACE.get(this),
1136 GiraphConstants.DNS_NAMESERVER.get(this)).toLowerCase();
1137 }
1138
1139
1140
1141
1142
1143
1144
1145 public String getLocalHostOrIp() throws UnknownHostException {
1146 if (GiraphConstants.PREFER_IP_ADDRESSES.get(this)) {
1147 return InetAddress.getLocalHost().getHostAddress();
1148 }
1149 return getLocalHostname();
1150 }
1151
1152
1153
1154
1155
1156
1157
1158 public void setMaxNumberOfSupersteps(int maxNumberOfSupersteps) {
1159 MAX_NUMBER_OF_SUPERSTEPS.set(this, maxNumberOfSupersteps);
1160 }
1161
1162
1163
1164
1165
1166
1167
1168 public int getMaxNumberOfSupersteps() {
1169 return MAX_NUMBER_OF_SUPERSTEPS.get(this);
1170 }
1171
1172
1173
1174
1175
1176
1177
1178 public String getYourKitOutputDir(Mapper.Context context) {
1179 final String cacheKey = "giraph.yourkit.outputDirCached";
1180 String outputDir = get(cacheKey);
1181 if (outputDir == null) {
1182 outputDir = getStringVars(YOURKIT_OUTPUT_DIR, YOURKIT_OUTPUT_DIR_DEFAULT,
1183 context);
1184 set(cacheKey, outputDir);
1185 }
1186 return outputDir;
1187 }
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200 public String getStringVars(String key, Mapper.Context context) {
1201 return getStringVars(key, null, context);
1202 }
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217 public String getStringVars(String key, String defaultValue,
1218 Mapper.Context context) {
1219 String value = get(key);
1220 if (value == null) {
1221 if (defaultValue == null) {
1222 return null;
1223 }
1224 value = defaultValue;
1225 }
1226 value = value.replace("%JOB_ID%", context.getJobID().toString());
1227 value = value.replace("%TASK_ID%", context.getTaskAttemptID().toString());
1228 value = value.replace("%USER%", get("user.name", "unknown_user"));
1229 return value;
1230 }
1231
1232
1233
1234
1235
1236
1237 public boolean getCreateSourceVertex() {
1238 return CREATE_EDGE_SOURCE_VERTICES.get(this);
1239 }
1240
1241
1242
1243
1244
1245 public void setCreateSourceVertex(boolean createVertex) {
1246 CREATE_EDGE_SOURCE_VERTICES.set(this, createVertex);
1247 }
1248
1249
1250
1251
1252
1253
1254
1255 public int getWaitTaskDoneTimeoutMs() {
1256 return WAIT_TASK_DONE_TIMEOUT_MS.get(this);
1257 }
1258
1259
1260
1261
1262
1263
1264
1265 public void setWaitTaskDoneTimeoutMs(int ms) {
1266 WAIT_TASK_DONE_TIMEOUT_MS.set(this, ms);
1267 }
1268
1269
1270
1271
1272
1273
1274 public boolean trackJobProgressOnClient() {
1275 return TRACK_JOB_PROGRESS_ON_CLIENT.get(this);
1276 }
1277
1278
1279
1280
1281 public int getHdfsFileCreationRetries() {
1282 return HDFS_FILE_CREATION_RETRIES.get(this);
1283 }
1284
1285
1286
1287
1288
1289 public int getHdfsFileCreationRetryWaitMs() {
1290 return HDFS_FILE_CREATION_RETRY_WAIT_MS.get(this);
1291 }
1292 }