diff --git a/src/main/java/com/marklogic/contentpump/InputType.java b/src/main/java/com/marklogic/contentpump/InputType.java index c22fe12d9..82d3e97d1 100644 --- a/src/main/java/com/marklogic/contentpump/InputType.java +++ b/src/main/java/com/marklogic/contentpump/InputType.java @@ -249,6 +249,10 @@ public void applyConfigOptions(Configuration conf, CommandLine cmdline) ContentSource cs; String[] outputHosts = conf.getStrings(MarkLogicConstants.OUTPUT_HOST); + if (outputHosts == null || outputHosts.length == 0) { + throw new IllegalArgumentException(MarkLogicConstants.OUTPUT_HOST + + " is not specified."); + } int hostIdx = 0; while (hostIdx < outputHosts.length) { try { diff --git a/src/main/java/com/marklogic/contentpump/RDFReader.java b/src/main/java/com/marklogic/contentpump/RDFReader.java index 51facf1e2..c2cd0d09a 100644 --- a/src/main/java/com/marklogic/contentpump/RDFReader.java +++ b/src/main/java/com/marklogic/contentpump/RDFReader.java @@ -546,8 +546,13 @@ public void initExistingMapPerms() throws IOException { ResultSequence result = null; ContentSource cs; try { + String[] hosts = conf.getStrings(MarkLogicConstants.OUTPUT_HOST); + if (hosts == null || hosts.length == 0) { + throw new IllegalArgumentException(MarkLogicConstants.OUTPUT_HOST + + " is not specified."); + } cs = InternalUtilities.getOutputContentSource(conf, - conf.getStrings(MarkLogicConstants.OUTPUT_HOST)[0]); + hosts[0]); session = cs.newSession(); RequestOptions options = new RequestOptions(); options.setDefaultXQueryVersion("1.0-ml"); diff --git a/src/main/java/com/marklogic/contentpump/ThreadManager.java b/src/main/java/com/marklogic/contentpump/ThreadManager.java index e1c097d07..87498633f 100644 --- a/src/main/java/com/marklogic/contentpump/ThreadManager.java +++ b/src/main/java/com/marklogic/contentpump/ThreadManager.java @@ -548,6 +548,12 @@ public void run() { boolean isRetryable = false; pollingRetry = 0; pollingSleepTime = MIN_SLEEP_TIME; + String[] hosts = conf.getStrings(MarkLogicConstants.OUTPUT_HOST); + if (hosts == null || hosts.length == 0) { + LOG.error(MarkLogicConstants.OUTPUT_HOST + " is not specified."); + job.setJobState(JobStatus.State.FAILED); + return; + } // Poll server max threads while (pollingRetry < MAX_RETRIES) { if (pollingRetry > 0) { @@ -555,7 +561,6 @@ public void run() { LOG.debug("Retrying querying available server max threads."); } } - String[] hosts = conf.getStrings(MarkLogicConstants.OUTPUT_HOST); for (String host : hosts) { try { ContentSource cs = InternalUtilities. diff --git a/src/main/java/com/marklogic/contentpump/TransformOutputFormat.java b/src/main/java/com/marklogic/contentpump/TransformOutputFormat.java index a7f8b20ae..9c49df25e 100644 --- a/src/main/java/com/marklogic/contentpump/TransformOutputFormat.java +++ b/src/main/java/com/marklogic/contentpump/TransformOutputFormat.java @@ -75,6 +75,10 @@ private LinkedMapWritable getMimetypesMap() throws IOException { return mimetypeMap; } String[] hosts = conf.getStrings(OUTPUT_HOST); + if (hosts == null || hosts.length == 0) { + throw new IllegalArgumentException(OUTPUT_HOST + + " is not specified."); + } Session session = null; ResultSequence result = null; diff --git a/src/main/java/com/marklogic/contentpump/utilities/PermissionUtil.java b/src/main/java/com/marklogic/contentpump/utilities/PermissionUtil.java index 976c5f62e..f5ade4050 100644 --- a/src/main/java/com/marklogic/contentpump/utilities/PermissionUtil.java +++ b/src/main/java/com/marklogic/contentpump/utilities/PermissionUtil.java @@ -79,8 +79,13 @@ public static List getDefaultPermissions(Configuration conf, ResultSequence result = null; ContentSource cs; try { + String[] hosts = conf.getStrings(MarkLogicConstants.OUTPUT_HOST); + if (hosts == null || hosts.length == 0) { + throw new IllegalArgumentException(MarkLogicConstants.OUTPUT_HOST + + " is not specified."); + } cs = InternalUtilities.getOutputContentSource(conf, - conf.getStrings(MarkLogicConstants.OUTPUT_HOST)[0]); + hosts[0]); session = cs.newSession(); RequestOptions options = new RequestOptions(); diff --git a/src/main/java/com/marklogic/mapreduce/ContentOutputFormat.java b/src/main/java/com/marklogic/mapreduce/ContentOutputFormat.java index 9a9500307..26a5fd7f5 100644 --- a/src/main/java/com/marklogic/mapreduce/ContentOutputFormat.java +++ b/src/main/java/com/marklogic/mapreduce/ContentOutputFormat.java @@ -224,6 +224,10 @@ public void checkOutputSpecs( TextArrayWritable hostArray = null; if (restrictHosts) { String[] outputHosts = conf.getStrings(OUTPUT_HOST); + if (outputHosts == null || outputHosts.length == 0) { + throw new IllegalArgumentException(OUTPUT_HOST + + " is not specified."); + } hostArray = new TextArrayWritable(outputHosts); } else { String outputHost = cs.getConnectionProvider().getHostName(); diff --git a/src/main/java/com/marklogic/mapreduce/utilities/InternalUtilities.java b/src/main/java/com/marklogic/mapreduce/utilities/InternalUtilities.java index b2a66f23e..ba637077e 100644 --- a/src/main/java/com/marklogic/mapreduce/utilities/InternalUtilities.java +++ b/src/main/java/com/marklogic/mapreduce/utilities/InternalUtilities.java @@ -104,13 +104,12 @@ public class InternalUtilities implements MarkLogicConstants { */ public static ContentSource getInputContentSource(Configuration conf) throws URISyntaxException, XccConfigException, IOException { - String host = conf.getStrings(INPUT_HOST)[0]; - if (host == null || host.isEmpty()) { + String[] hosts = conf.getStrings(INPUT_HOST); + if (hosts == null || hosts.length == 0) { throw new IllegalArgumentException(INPUT_HOST + " is not specified."); } - - return getInputContentSource(conf, host); + return getInputContentSource(conf, hosts[0]); } /**