From 7bf006278dc94a5498c9343b406eac4730c055de Mon Sep 17 00:00:00 2001 From: Mark DePristo Date: Sun, 28 Aug 2011 12:04:16 -0400 Subject: [PATCH] Moved ResolveHostname to general utils as a static function --- .../sting/gatk/phonehome/GATKRunReport.java | 19 +------------------ .../org/broadinstitute/sting/utils/Utils.java | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/public/java/src/org/broadinstitute/sting/gatk/phonehome/GATKRunReport.java b/public/java/src/org/broadinstitute/sting/gatk/phonehome/GATKRunReport.java index acee1a6a3..4d94130a8 100644 --- a/public/java/src/org/broadinstitute/sting/gatk/phonehome/GATKRunReport.java +++ b/public/java/src/org/broadinstitute/sting/gatk/phonehome/GATKRunReport.java @@ -46,7 +46,6 @@ import org.simpleframework.xml.stream.Format; import org.simpleframework.xml.stream.HyphenStyle; import java.io.*; -import java.net.InetAddress; import java.security.NoSuchAlgorithmException; import java.text.DateFormat; import java.text.SimpleDateFormat; @@ -230,22 +229,6 @@ public class GATKRunReport { } - /** - * Helper utility that calls into the InetAddress system to resolve the hostname. If this fails, - * unresolvable gets returned instead. - * - * @return - */ - private String resolveHostname() { - try { - return InetAddress.getLocalHost().getCanonicalHostName(); - } - catch (java.net.UnknownHostException uhe) { // [beware typo in code sample -dmw] - return "unresolvable"; - // handle exception - } - } - public void postReport(PhoneHomeOption type) { logger.debug("Posting report of type " + type); switch (type) { @@ -325,7 +308,7 @@ public class GATKRunReport { private void postReportToAWSS3() { // modifying example code from http://jets3t.s3.amazonaws.com/toolkit/code-samples.html - this.hostName = resolveHostname(); // we want to fill in the host name + this.hostName = Utils.resolveHostname(); // we want to fill in the host name File localFile = postReportToLocalDisk(new File("./")); logger.debug("Generating GATK report to AWS S3 based on local file " + localFile); if ( localFile != null ) { // we succeeded in creating the local file diff --git a/public/java/src/org/broadinstitute/sting/utils/Utils.java b/public/java/src/org/broadinstitute/sting/utils/Utils.java index 015e5d6f6..f6edb319f 100755 --- a/public/java/src/org/broadinstitute/sting/utils/Utils.java +++ b/public/java/src/org/broadinstitute/sting/utils/Utils.java @@ -29,6 +29,7 @@ import net.sf.samtools.util.StringUtil; import org.apache.log4j.Logger; import org.broadinstitute.sting.utils.collections.Pair; +import java.net.InetAddress; import java.util.*; /** @@ -633,4 +634,20 @@ public class Utils { public static boolean isFlagSet(int value, int flag) { return ((value & flag) == flag); } + + /** + * Helper utility that calls into the InetAddress system to resolve the hostname. If this fails, + * unresolvable gets returned instead. + * + * @return + */ + public static final String resolveHostname() { + try { + return InetAddress.getLocalHost().getCanonicalHostName(); + } + catch (java.net.UnknownHostException uhe) { // [beware typo in code sample -dmw] + return "unresolvable"; + // handle exception + } + } }