HDFSLockedOutputStream createHDFSLockedOutputStream() throws IOException {
        try {
            if (outputPaths == null || outputPaths.length == 0) {
                throw new IOException("No output paths have been set");
            }

            // Get a path to use.
            String path;
            if (outputPaths.length == 1) {
                path = outputPaths[0];
            } else {
                // Choose one of the output paths at random.
                path = outputPaths[(int) Math.round(Math.random() * (outputPaths.length - 1))];
            }

            // Replace some of the path elements with system variables.
            path = pathCreator.replaceAll(path);

            // Make sure we can create this path.
            final Path file = createCleanPath(path);

            return getHDFSLockedOutputStream(file);

        } catch (final IOException e) {
            throw e;
        } catch (final RuntimeException e) {
            throw new IOException(e.getMessage(), e);
        }
    }
Creates an output stream for a file on an Hadoop Distributed File System
<p>
TODO Need to add in proper security so it can connect to a secured
(kerberos?) cluster
stroom-pipeline/src/main/java/stroom/pipeline/writer/HDFSFileAppender.java