Package org.acplt.oncrpc

Examples of org.acplt.oncrpc.OncRpcClient


        }

        // create the client
        // We create the client with a buffer with lenght equals witn MAX_DATA +
        // 424 ( max header length)
        OncRpcClient client = null;
        if (protocol == Protocol.UDP) {
            client = new OncRpcUdpClient(host, NFS_PROGRAM, NFS_VERSION, port, MAX_DATA + HEADER_DATA);
        } else if (protocol == Protocol.TCP) {
            client = new OncRpcTcpClient(host, NFS_PROGRAM, NFS_VERSION, port, MAX_DATA + HEADER_DATA);
        } else {
            // TODO Do something
        }
        client.setTimeout(10000);
        if (uid != -1 && gid != -1) {
            client.setAuth(new OncRpcClientAuthUnix("test", uid, gid));
        }
        return client;
    }
View Full Code Here


        }
    }

    private void call(final int functionId, final XdrAble parameter, final XdrAble result)
        throws NFS2Exception, IOException {
        OncRpcClient client = null;
        int countCall = 0;
        while (true) {
            try {
                countCall++;
                client = getRpcClient();
                if (result == XdrVoid.XDR_VOID) {
                    client.call(functionId, parameter, result);
                } else {
                    ResultWithCode nfsResult = new ResultWithCode(result);
                    client.call(functionId, parameter, nfsResult);
                    if (nfsResult.getResultCode() != ResultCode.NFS_OK) {
                        throw new NFS2Exception(nfsResult.getResultCode());
                    }
                }
                break;
            } catch (Exception e) {
                if (client != null) {
                    try {
                        client.close();
                    } catch (OncRpcException e1) {
                        // Ignore this
                    }
                    client = null;
                }
View Full Code Here

        this.gid = gid;
        rpcClientPool = new LinkedList<OncRpcClient>();
    }

    private OncRpcClient createRpcClient() throws OncRpcException, IOException {
        OncRpcClient client =
                OncRpcClient.newOncRpcClient(host, MOUNT_CODE, MOUNT_VERSION,
                        protocol == Protocol.UDP ? OncRpcProtocols.ONCRPC_UDP
                                : OncRpcProtocols.ONCRPC_TCP);
        client.setTimeout(10000);
        if (uid != -1 && gid != -1) {
            client.setAuth(new OncRpcClientAuthUnix("test", uid, gid));
        }
        return client;
    }
View Full Code Here

    }

    private void call(final int functionId, final XdrAble parameter, final XdrAble result)
        throws MountException, IOException {
        int countCall = 0;
        OncRpcClient client = null;

        while (true) {
            try {
                countCall++;
                client = getRpcClient();
                client.call(functionId, parameter, result);
                break;
            } catch (Exception e) {
                // if we receive an exception we will close the client and next
                // time we will use another rpc client
                if (client != null) {
                    try {
                        client.close();
                    } catch (OncRpcException e1) {
                        // Ignore this
                    }
                    client = null;
                }
View Full Code Here

TOP

Related Classes of org.acplt.oncrpc.OncRpcClient

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.