Skip to content

Commit

Permalink
Merge pull request #114 from ldbc/exception-handling
Browse files Browse the repository at this point in the history
Throw RuntimeExceptions to fail as early as possible
  • Loading branch information
szarnyasg authored Feb 5, 2020
2 parents 4e0fa45 + 753a414 commit e6213b5
Show file tree
Hide file tree
Showing 34 changed files with 45 additions and 52 deletions.
1 change: 0 additions & 1 deletion src/main/java/ldbc/snb/datagen/LdbcDatagen.java
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,6 @@ public static void main(String[] args) throws Exception {
} catch (Exception e) {
System.err.println("Error during execution");
System.err.println(e.getMessage());
e.printStackTrace();
throw e;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private void load(String fileName) {
}
dictionary.close();
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private void load(String fileName) {
}
dictionary.close();
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private void load(String fileName) {
}
emailDictionary.close();
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private void load(String mappingFileName, String baseIPdir) {
ipZoneFile.close();
}
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ private void load(String fileName) {
}
dictionary.close();
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void extractSurNames() {
surnameDictionary.close();
System.out.println("Done ... " + totalSurNames + " surnames were extracted ");
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}

Expand Down Expand Up @@ -140,7 +140,7 @@ public void extractGivenNames() {
givennameDictionary.close();
System.out.println("Done ... " + totalGivenNames + " given names were extracted ");
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ private void readCities(String fileName) {
}
dictionary.close();
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}

Expand Down Expand Up @@ -331,7 +331,7 @@ private void readCountries(String fileName) {
cumulativeDistribution = new Float[temporalCumulative.size()];
cumulativeDistribution = temporalCumulative.toArray(cumulativeDistribution);
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}

Expand Down Expand Up @@ -372,7 +372,7 @@ private void readContinents(String fileName) {
}
dictionary.close();
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private void load(String fileName) {
}
dicPopularPlace.close();
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ private void load(String tagsFileName, String popularTagByCountryFileName, Strin

dictionary.close();
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ldbc/snb/datagen/dictionary/TagMatrix.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private void load(String tagMatrixFileName) {
}
dictionary.close();
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private void load(String fileName) {
}
dictionary.close();
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private void load(String fileName) {
}
dicAllInstitutes.close();
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private void load(String fileName) {
}
agentFile.close();
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,9 @@ public List<Bucket> getBuckets(Configuration conf) {
reader.close();
return Bucket.bucketizeHistogram(histogram, 1000);
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ public void loadFBBuckets() {
}
fbDataReader.close();
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ private void generateActivity(Person person, List<Person> block) throws Assertio
} catch (AssertionError e) {
System.out.println("Assertion error when generating activity!");
System.out.println(e.getMessage());
e.printStackTrace();
throw e;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public void generateKnows(List<Person> persons, int seed, List<Float> percentage
}
reader.close();
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
}

p[0] = 0.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ protected void setup(Context context) {
.newInstance();
} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
throw new RuntimeException(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ protected void setup(Context context) {

} catch (Exception e) {
System.err.println(e.getMessage());
e.printStackTrace();
throw new RuntimeException(e);
}
}

Expand Down Expand Up @@ -148,7 +148,6 @@ protected void cleanup(Context context) {
personFactors_.close();
friends_.close();
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
dynamicActivitySerializer_.close();
Expand Down Expand Up @@ -217,7 +216,7 @@ public void run(String inputFileName) throws AssertionError, Exception {
fs.delete(new Path(conf.get("ldbc.snb.datagen.serializer.hadoopDir") + "/aux"), true);
} catch (IOException e) {
System.err.println(e.getMessage());
e.printStackTrace();
throw new RuntimeException(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void map(LongWritable key, Text value, Context context)
} catch (Exception e) {
System.err.println("Error when setting key setter");
System.err.println(e.getMessage());
e.printStackTrace();
throw new RuntimeException(e);
}

int threadId = Integer.parseInt(value.toString());
Expand Down Expand Up @@ -135,7 +135,7 @@ private static void writeToOutputFile(String filename, int numMaps, Configuratio
output.write((new String(i + "\n").getBytes()));
output.close();
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ public void setup(Context context) {
keySetter = (HadoopFileKeyChanger.KeySetter) Class.forName(className).newInstance();
} catch (ClassNotFoundException e) {
System.out.print(e.getMessage());
e.printStackTrace();
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
System.out.print(e.getMessage());
e.printStackTrace();
throw new RuntimeException(e);
} catch (InstantiationException e) {
System.out.print(e.getMessage());
e.printStackTrace();
throw new RuntimeException(e);
}
}

Expand Down Expand Up @@ -194,7 +194,7 @@ public void setup(Context context) {
}
} catch (IOException e) {
System.err.println(e.getMessage());
e.printStackTrace();
throw new RuntimeException(e);
}

counters[0] = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected void setup(Context context) {
.newInstance();
} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
throw new RuntimeException(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ public void setup(Context context) {
keySetter = (HadoopFileKeyChanger.KeySetter) Class.forName(className).newInstance();
} catch (ClassNotFoundException e) {
System.out.print(e.getMessage());
e.printStackTrace();
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
System.out.print(e.getMessage());
e.printStackTrace();
throw new RuntimeException(e);
} catch (InstantiationException e) {
System.out.print(e.getMessage());
e.printStackTrace();
throw new RuntimeException(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected void setup(Context context) {
}
} catch (Exception e) {
System.err.println(e.getMessage());
e.printStackTrace();
throw new RuntimeException(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ protected void setup(Context context) {
}
} catch (Exception e) {
System.err.println(e.getMessage());
e.printStackTrace();
throw new RuntimeException(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void run() throws Exception {
}
} catch (Exception e) {
System.err.println(e.getMessage());
e.printStackTrace();
throw new RuntimeException(e);
}

exportPlaces();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ protected void setup(Context context) {
}
} catch (Exception e) {
System.err.println(e.getMessage());
e.printStackTrace();
throw new RuntimeException(e);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/ldbc/snb/datagen/hadoop/writer/HdfsWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void write(String entry) {
currentPartition = ++currentPartition % numPartitions;
} catch (IOException e) {
System.out.println("Cannot write to output file ");
e.printStackTrace();
throw new RuntimeException(e);
}
}

Expand All @@ -92,7 +92,7 @@ public void writeAllPartitions(String entry) {
}
} catch (IOException e) {
System.out.println("Cannot write to output file ");
e.printStackTrace();
throw new RuntimeException(e);
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/ldbc/snb/datagen/util/ConfigParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,7 @@ public static Configuration readConfig(Configuration conf, InputStream paramStre
}
} catch (Exception e) {
System.err.println(e.getMessage());
e.printStackTrace();
System.exit(-1);
throw new RuntimeException(e);
}
return conf;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ldbc/snb/datagen/util/Distribution.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void initialize() {
++index;
}
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ldbc/snb/datagen/util/DistributionKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void initialize() {
}

} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}

Expand Down
Loading

0 comments on commit e6213b5

Please sign in to comment.