Skip to content

Commit 3d41e0c

Browse files
committed
Thrown and captured exceptions upon a job failing
1 parent f9ebdcb commit 3d41e0c

10 files changed

+41
-12
lines changed

src/main/java/ldbc/snb/datagen/generator/LDBCDatagen.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,9 @@ public int runGenerateJob(Configuration conf) throws Exception {
237237
return 0;
238238
}
239239

240-
public static void main(String[] args) throws Exception {
240+
public static void main(String[] args) /*throws Exception*/ {
241241

242+
try {
242243
Configuration conf = ConfigParser.initialize();
243244
ConfigParser.readConfig(conf,"./src/main/resources/params.ini");
244245
//ConfigParser.readConfig(conf,args[0]);
@@ -257,6 +258,11 @@ public static void main(String[] args) throws Exception {
257258
// Create input text file in HDFS
258259
LDBCDatagen datagen = new LDBCDatagen();
259260
LDBCDatagen.init(conf);
260-
datagen.runGenerateJob(conf);
261+
datagen.runGenerateJob(conf);
262+
}catch(Exception e ) {
263+
System.err.println("Error during execution");
264+
System.err.println(e.getMessage());
265+
System.exit(1);
266+
}
261267
}
262268
}

src/main/java/ldbc/snb/datagen/hadoop/HadoopFileKeyChanger.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ public void run( String inputFileName, String outputFileName ) throws Exception
7878
job.setJarByClass(V);
7979
job.setInputFormatClass(SequenceFileInputFormat.class);
8080
job.setOutputFormatClass(SequenceFileOutputFormat.class);
81-
job.waitForCompletion(true);
81+
if(!job.waitForCompletion(true)){
82+
throw new Exception();
83+
}
8284
}
8385
}

src/main/java/ldbc/snb/datagen/hadoop/HadoopFileRanker.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,9 @@ public void run( String inputFileName, String outputFileName ) throws Exception
155155
TotalOrderPartitioner.setPartitionFile(jobSort.getConfiguration(), new Path(inputFileName + "_partition.lst"));
156156
InputSampler.writePartitionFile(jobSort, sampler);
157157
jobSort.setPartitionerClass(TotalOrderPartitioner.class);
158-
jobSort.waitForCompletion(true);
158+
if(!jobSort.waitForCompletion(true)){
159+
throw new Exception();
160+
}
159161

160162
/** Second Job to assign the rank to each element.**/
161163
Job jobRank = Job.getInstance(conf, "Sorting "+inputFileName);
@@ -173,7 +175,9 @@ public void run( String inputFileName, String outputFileName ) throws Exception
173175
jobRank.setInputFormatClass(SequenceFileInputFormat.class);
174176
jobRank.setOutputFormatClass(SequenceFileOutputFormat.class);
175177
jobRank.setPartitionerClass(HadoopFileRankerPartitioner.class);
176-
jobRank.waitForCompletion(true);
178+
if(!jobRank.waitForCompletion(true)) {
179+
throw new Exception();
180+
}
177181

178182
try{
179183
FileSystem fs = FileSystem.get(conf);

src/main/java/ldbc/snb/datagen/hadoop/HadoopFileSorter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ public void run( String inputFileName, String outputFileName ) throws Exception
5858
TotalOrderPartitioner.setPartitionFile(job.getConfiguration(),new Path(inputFileName+"_partition.lst"));
5959
InputSampler.writePartitionFile(job, sampler);
6060
job.setPartitionerClass(TotalOrderPartitioner.class);
61-
job.waitForCompletion(true);
61+
if(!job.waitForCompletion(true)) {
62+
throw new Exception();
63+
}
6264
}
6365
}

src/main/java/ldbc/snb/datagen/hadoop/HadoopKnowsGenerator.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ public void run( String inputFileName, String outputFileName ) throws Exception
113113

114114
System.out.println("Generating knows relations");
115115
start = System.currentTimeMillis();
116-
job.waitForCompletion(true);
116+
if(!job.waitForCompletion(true) ){
117+
throw new Exception();
118+
}
117119
System.out.println("... Time to generate knows relations: "+ (System.currentTimeMillis() - start)+" ms");
118120

119121
fs.delete(new Path(rankedFileName), true);

src/main/java/ldbc/snb/datagen/hadoop/HadoopPersonActivityGenerator.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ public void run( String inputFileName ) throws Exception {
132132

133133
FileInputFormat.setInputPaths(job, new Path(rankedFileName));
134134
FileOutputFormat.setOutputPath(job, new Path(conf.get("ldbc.snb.datagen.serializer.hadoopDir")+"/aux"));
135-
job.waitForCompletion(true);
135+
if(!job.waitForCompletion(true)) {
136+
throw new Exception();
137+
}
136138

137139
try{
138140
fs.delete(new Path(rankedFileName), true);

src/main/java/ldbc/snb/datagen/hadoop/HadoopPersonGenerator.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ public void run( String outputFileName, String postKeySetterName ) throws Except
133133
job.setOutputFormatClass(SequenceFileOutputFormat.class);
134134
FileInputFormat.setInputPaths(job, new Path(tempFile));
135135
FileOutputFormat.setOutputPath(job, new Path(outputFileName));
136-
job.waitForCompletion(true);
136+
if(!job.waitForCompletion(true)) {
137+
throw new Exception();
138+
}
137139
}
138140
}

src/main/java/ldbc/snb/datagen/hadoop/HadoopPersonSerializer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ public void run( String inputFileName ) throws Exception {
103103

104104
FileInputFormat.setInputPaths(job, new Path(rankedFileName));
105105
FileOutputFormat.setOutputPath(job, new Path(conf.get("ldbc.snb.datagen.serializer.hadoopDir")+"/aux"));
106-
job.waitForCompletion(true);
106+
if(!job.waitForCompletion(true)) {
107+
throw new Exception();
108+
}
107109

108110

109111
try{

src/main/java/ldbc/snb/datagen/hadoop/HadoopUpdateStreamSerializer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ public void run( String inputFileName, int reducer, int partition, String type )
9292

9393
FileInputFormat.setInputPaths(job, new Path(inputFileName));
9494
FileOutputFormat.setOutputPath(job, new Path(conf.get("ldbc.snb.datagen.serializer.hadoopDir")+"/aux"));
95-
job.waitForCompletion(true);
95+
if(!job.waitForCompletion(true)) {
96+
throw new Exception();
97+
}
9698

9799

98100
try{

tools/extractDegrees.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@
1717
edgesPerPerson[int(edge[0])]+=1
1818
else:
1919
edgesPerPerson[int(edge[0])]=1
20-
numEdges+=1
20+
21+
if int(edge[1]) in edgesPerPerson:
22+
edgesPerPerson[int(edge[1])]+=1
23+
else:
24+
edgesPerPerson[int(edge[1])]=1
25+
numEdges+=2
2126
index+=1
2227
knowsFile.close()
2328

0 commit comments

Comments
 (0)