public static UserGroupInformation buildRemoteUser(final Optional<String> runAsUser) {
        final String user = runAsUser.orElseGet(() -> {
            try {
                return UserGroupInformation.getCurrentUser().getUserName();
            } catch (final IOException e) {
                throw new UncheckedIOException(e);
            }
        });

        // userGroupInformation =
        // UserGroupInformation.createProxyUser(runAsUser,
        // UserGroupInformation.getLoginUser());
        return UserGroupInformation.createRemoteUser(user);

    }
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