Moved ResolveHostname to general utils as a static function
This commit is contained in:
parent
ccec0b4d73
commit
7bf006278d
|
|
@ -46,7 +46,6 @@ import org.simpleframework.xml.stream.Format;
|
||||||
import org.simpleframework.xml.stream.HyphenStyle;
|
import org.simpleframework.xml.stream.HyphenStyle;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.InetAddress;
|
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
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) {
|
public void postReport(PhoneHomeOption type) {
|
||||||
logger.debug("Posting report of type " + type);
|
logger.debug("Posting report of type " + type);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
|
@ -325,7 +308,7 @@ public class GATKRunReport {
|
||||||
|
|
||||||
private void postReportToAWSS3() {
|
private void postReportToAWSS3() {
|
||||||
// modifying example code from http://jets3t.s3.amazonaws.com/toolkit/code-samples.html
|
// 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("./"));
|
File localFile = postReportToLocalDisk(new File("./"));
|
||||||
logger.debug("Generating GATK report to AWS S3 based on local file " + localFile);
|
logger.debug("Generating GATK report to AWS S3 based on local file " + localFile);
|
||||||
if ( localFile != null ) { // we succeeded in creating the local file
|
if ( localFile != null ) { // we succeeded in creating the local file
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ import net.sf.samtools.util.StringUtil;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.broadinstitute.sting.utils.collections.Pair;
|
import org.broadinstitute.sting.utils.collections.Pair;
|
||||||
|
|
||||||
|
import java.net.InetAddress;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -633,4 +634,20 @@ public class Utils {
|
||||||
public static boolean isFlagSet(int value, int flag) {
|
public static boolean isFlagSet(int value, int flag) {
|
||||||
return ((value & flag) == 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
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue