Package org.acplt.oncrpc

Examples of org.acplt.oncrpc.OncRpcPortmapClient


        rpcClientPool = new LinkedList<OncRpcClient>();
    }

    private OncRpcClient createRpcClient() throws OncRpcException, IOException {
        // invoke portmap
        OncRpcPortmapClient portmap = new OncRpcPortmapClient(host);
        int port;
        try {
            port = portmap.getPort(NFS_PROGRAM, NFS_VERSION,
                            protocol == Protocol.UDP ? OncRpcProtocols.ONCRPC_UDP
                                    : OncRpcProtocols.ONCRPC_TCP);
        } finally {
            portmap.close();
        }

        // create the client
        // We create the client with a buffer with lenght equals witn MAX_DATA +
        // 424 ( max header length)
View Full Code Here


    public static void main(String[] args) throws Exception {
        new RpcInfoCommand().execute(args);
    }
   
    public void execute() {
        OncRpcPortmapClient client = null;
        String hostname = argHost.getValue();
        PrintWriter out = getOutput().getPrintWriter();
        PrintWriter err = getError().getPrintWriter();
        try {
            InetAddress host = InetAddress.getByName(hostname);
            client = new OncRpcPortmapClient(host, OncRpcProtocols.ONCRPC_UDP);

            OncRpcServerIdent[] servers = client.listServers();

            out.printf(fmt_list_serv, str_program, str_version, str_protocol, str_port, str_name);
            out.println();

            for (OncRpcServerIdent server : servers) {
                out.printf(fmt_list_serv, server.program, server.version,
                    server.protocol == 6 ? str_tcp : str_udp,
                    server.port, getName(server.program));
                out.println();
            }
        } catch (OncRpcException e) {
            err.format(err_call, hostname);
            exit(1);
        } catch (UnknownHostException e) {
            err.format(err_host, hostname);
            exit(1);
        } catch (IOException e) {
            err.format(err_connect, hostname);
            exit(1);
        } finally {
            if (client != null) {
                try {
                    client.close();
                } catch (OncRpcException e) {
                    // Ignore exception on close
                }
            }
        }
View Full Code Here

    /**
     * @see java.net.URLStreamHandler#openConnection(java.net.URL)
     */
    protected URLConnection openConnection(URL url) throws IOException {
        OncRpcPortmapClient client = null;
        int version = 0;
        try {
            client = new OncRpcPortmapClient(
                    InetAddress.getByName(url.getHost()), OncRpcProtocols.ONCRPC_TCP);
            OncRpcServerIdent[] servers = client.listServers();
            for (OncRpcServerIdent server : servers) {
                if (server.program == 100003 && server.version > version) {
                    version = server.version;
                }
            }
        } catch (OncRpcException e) {
            throw new IOException(e);
        } finally {
            if (client != null) {
                try {
                    client.close();
                } catch (Exception e) {
                    // ignore
                }
            }
        }
View Full Code Here

TOP

Related Classes of org.acplt.oncrpc.OncRpcPortmapClient

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.