Example usage for org.apache.commons.vfs.provider GenericFileName getPort

List of usage examples for org.apache.commons.vfs.provider GenericFileName getPort

Introduction

In this page you can find the example usage for org.apache.commons.vfs.provider GenericFileName getPort.

Prototype

public int getPort() 

Source Link

Document

Returns the port part of this name.

Usage

From source file:org.pentaho.di.ui.vfs.hadoopvfsfilechooserdialog.HadoopVfsFileChooserDialog.java

private void initializeConnectionPanel() {
    if (initialFile != null && initialFile.getName().getScheme().equals(HadoopSpoonPlugin.HDFS_SCHEME)) {
        // populate the server and port fields
        try {/*from   ww  w .ja  v  a  2  s.c  o m*/
            GenericFileName genericFileName = (GenericFileName) initialFile.getFileSystem().getRoot().getName();
            wUrl.setText(genericFileName.getHostName());
            wPort.setText(String.valueOf(genericFileName.getPort()));
            wUserID.setText(genericFileName.getUserName() == null ? "" : genericFileName.getUserName()); //$NON-NLS-1$
            wPassword.setText(genericFileName.getPassword() == null ? "" : genericFileName.getPassword()); //$NON-NLS-1$
        } catch (FileSystemException fse) {
            showMessageAndLog(BaseMessages.getString(PKG, "HadoopVfsFileChooserDialog.error"),
                    BaseMessages.getString(PKG, "HadoopVfsFileChooserDialog.FileSystem.error"),
                    fse.getMessage());
        }
    }

    handleConnectionButton();
}

From source file:org.pentaho.hdfs.vfs.HDFSFileSystem.java

public org.apache.hadoop.fs.FileSystem getHDFSFileSystem() throws FileSystemException {
    if (mockHdfs != null) {
        return mockHdfs;
    }/*from www . ja  v a  2s.  co m*/
    if (hdfs == null) {
        Configuration conf = new Configuration();
        GenericFileName genericFileName = (GenericFileName) getRootName();
        StringBuffer urlBuffer = new StringBuffer("hdfs://");
        urlBuffer.append(genericFileName.getHostName());
        int port = genericFileName.getPort();
        if (port >= 0) {
            urlBuffer.append(":");
            urlBuffer.append(port);
        }
        String url = urlBuffer.toString();
        conf.set("fs.default.name", url);

        String replication = System.getProperty("dfs.replication", "3");
        conf.set("dfs.replication", replication);

        if (genericFileName.getUserName() != null && !"".equals(genericFileName.getUserName())) {
            conf.set("hadoop.job.ugi", genericFileName.getUserName() + ", " + genericFileName.getPassword());
        }
        setFileSystemOptions(getFileSystemOptions(), conf);
        try {
            hdfs = org.apache.hadoop.fs.FileSystem.get(conf);
        } catch (Throwable t) {
            throw new FileSystemException("Could not getHDFSFileSystem() for " + url, t);
        }
    }
    return hdfs;
}

From source file:org.pentaho.hdfs.vfs.MapRFileSystem.java

@Override
public org.apache.hadoop.fs.FileSystem getHDFSFileSystem() throws FileSystemException {
    if (fs == null) {
        Configuration conf = new Configuration();
        conf.set("fs.maprfs.impl", MapRFileProvider.FS_MAPR_IMPL);

        GenericFileName rootName = (GenericFileName) getRootName();
        String url = rootName.getScheme() + "://" + rootName.getHostName().trim();
        if (rootName.getPort() != MapRFileNameParser.DEFAULT_PORT) {
            url += ":" + rootName.getPort();
        }/* www.j a v  a2 s . c o m*/
        url += "/";
        conf.set("fs.default.name", url);
        setFileSystemOptions(getFileSystemOptions(), conf);
        try {
            fs = org.apache.hadoop.fs.FileSystem.get(conf);
        } catch (Throwable t) {
            throw new FileSystemException("Could not get MapR FileSystem for " + url, t);
        }
    }
    return fs;
}

From source file:plugin.games.data.trans.step.hadoopfileoutput.HadoopVfsFileChooserDialog.java

private void initializeConnectionPanel() {
    if (initialFile != null && initialFile instanceof HDFSFileObject) {
        // populate the server and port fields
        try {//from   w w  w. j  av a2 s. c  o m
            GenericFileName genericFileName = (GenericFileName) initialFile.getFileSystem().getRoot().getName();
            wUrl.setText(genericFileName.getHostName());
            wPort.setText(String.valueOf(genericFileName.getPort()));
            wUserID.setText(genericFileName.getUserName() == null ? "" : genericFileName.getUserName()); //$NON-NLS-1$
            wPassword.setText(genericFileName.getPassword() == null ? "" : genericFileName.getPassword()); //$NON-NLS-1$
        } catch (FileSystemException fse) {
            showMessageAndLog("HadoopVfsFileChooserDialog.error", "HadoopVfsFileChooserDialog.FileSystem.error",
                    fse.getMessage());
        }
    }

    handleConnectionButton();
}