Giter VIP home page Giter VIP logo

oncrpc4j's Introduction

ONCRPC4J

Latest release

This is a part of dCache.ORG's NFSv4.1 work.

Technically, this is not a fork of Remote Tea RPC library, but formally it is as we was inspired by Remote Tea RPC and took lot of ideas from it including xdr language parser. The goal to be able to use stubs generated by Remote Tea (no need to rewrite existing RPC servers) with minimal changes.

The library supports IPv6, RPCSEC_GSS and compliant with rfc1831 and rfc2203.

There are several options how to use ONCRPC4J in your application

Embedding service into an application

package me.mypackage;

import org.dcache.oncrpc4j.rpc.OncRpcException;
import org.dcache.oncrpc4j.rpc.RpcDispatchable;
import org.dcache.oncrpc4j.rpc.RpcCall;
import org.dcache.oncrpc4j.xdr.XdrVoid;

public class Svcd {

    private static final int DEFAULT_PORT = 1717;
    private static final int PROG_NUMBER = 111017;
    private static final int PROG_VERS = 1;

    public static void main(String[] args) throws Exception {

        int port = DEFAULT_PORT;

        RpcDispatchable dummy = new RpcDispatchable() {

            @Override
            public void dispatchOncRpcCall(RpcCall call)
                          throws OncRpcException, IOException {
                call.reply(XdrVoid.XDR_VOID);
            }
        };

        OncRpcSvc service = new OncRpcSvcBuilder()
                .withTCP()
                .withAutoPublish()
                .withPort(port)
                .withSameThreadIoStrategy()
                .withRpcService(new OncRpcProgram(PROG_NUMBER, PROG_VERS), dummy)
                .build();
        service.start();
    }
}

or as a spring bean

package me.mypackage;

import org.dcache.oncrpc4j.rpc.OncRpcException;
import org.dcache.oncrpc4j.rpc.RpcDispatchable;
import org.dcache.oncrpc4j.rpc.RpcCall;
import org.dcache.oncrpc4j.xdr.XdrVoid;
import java.io.IOException;

public class Svcd implements RpcDispatchable {

    @Override
    public void dispatchOncRpcCall(RpcCall call)
                throws OncRpcException, IOException {
        call.reply(XdrVoid.XDR_VOID);
    }
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

    <bean id="my-rpc-svc" class="me.mypackage.Svcd">
        <description>My RPC service</description>
    </bean>

     <bean id="my-rpc" class="org.dcache.oncrpc4j.rpc.OncRpcProgram">
        <description>My RPC program number</description>
        <constructor-arg index="0" value="1110001" />
        <constructor-arg index="1" value="1" />
    </bean>

    <bean id="rpcsvc-builder" class="org.dcache.oncrpc4j.rpc.OncRpcSvcFactoryBean">
        <description>Onc RPC service builder</description>
        <property name="port" value="1717"/>
        <property name="useTCP" value="true"/>
        <property name="rpcServices">
            <map>
                <entry key-ref="my-rpc" value-ref="my-rpc-svc"/>
            </map>
        </property>

    </bean>

    <bean id="oncrpcsvc" class="org.dcache.oncrpc4j.rpc.OncRpcSvc" init-method="start" destroy-method="stop">
        <description>My RPC service</description>
        <constructor-arg ref="rpcsvc-builder"/>
    </bean>
</beans>

Notice, that included SpringRunner will try to instantiate and run bean with id oncrpcsvc.

java -cp $CLASSPATH org.dcache.oncrpc4j.spring.SpringRunner svc.xml

Migration from ONCRPC4J-2.x

With version 3.0.0 a new package schema is introduced. As the change is not backward compatible with older version some minimal code changes are required.

Removed methods

org.dcache.utils.Bytes#{fromHexString|toHexString} methods are removed in favour of com.google.common.io.BaseEncoding.

Renamed packages

org.dcache.utils => org.dcache.oncrpc4j.util org.dcache.utils.net => org.dcache.oncrpc4j.rpc.net org.dcache.xdr split into org.dcache.oncrpc4j.rpc, org.dcache.oncrpc4j.xdr and org.dcache.oncrpc4j.grizzly

Renamed classes

org.dcache.utils.Opaque => into org.dcache.oncrpc4j.XdrOpaque org.dcache.xdr.XdrTransport => into org.dcache.oncrpc4j.rpc.RpcTransport org.dcache.xdr.GrizzlyXdrTransport => into org.dcache.oncrpc4j.grizzly.GrizzlyRpcTransport

Removed classes

org.dcache.xdr.XdrBuffer is removed. Use org.dcache.oncrpc4j.xdr.Xdr.

Behavior change

The Xdr#xdrEncodeByteBuffer changed to not flip provided byte buffer. As a result, the Xdr#xdrEncodeByteBuffer will encode data in the buffer from buffers current position up to the limit:

ButeByffer buffer = ...;
Xdr xdr = ...;

buffer.put(...);
buffer.flip();
xdr.xdrEncodeByteBuffer(buffer);

Using RPCGEN to generate client and server stubs

Assume a service which calculates a the length of a string. It provides a single remote call strlen which takes a string as an argument ans returns it's length. Let describe that procedure according XDR language specification:

/* strlen.x */
program STRLEN {
    version STRLENVERS {
        int strlen(string) = 1;
    } = 1;
} = 117;

Here we define STRLEN program number to be 117 and version number 1. Now we can generate stub files for client and server:

java -jar oncrpc4j-rpcgen.jar -c StrlenClient strlen.x

Simply extend this class and implement abstract methods:

//StrlenSvcImpl.java
import org.dcache.oncrpc4j.rpc.*;
import org.dcache.oncrpc4j.xdr.*;

public class StrlenSvcImpl extends strlenServerStub {

   public int strlen_1(RpcCall call$, String arg) {
       return arg.length();
   }
}

Now it's ready to be complied and deployed as standalone or Spring application:

// StrlenServerApp.java
// standalone application example
import org.dcache.oncrpc4j.rpc.*;
import org.dcache.oncrpc4j.xdr.*;

public class StrlenServerApp {

    static final int DEFAULT_PORT = 1717;

    public static void main(String[] args) throws Exception {

        OncRpcSvc service = new OncRpcSvcBuilder()
                .withTCP()
                .withAutoPublish()
                .withPort(DEFAULT_PORT)
                .withSameThreadIoStrategy()
                .withRpcService(new OncRpcProgram(strlen.STRLEN, strlen.STRLENVERS), new StrlenSvcImpl())
                .build();
        service.start();
        System.in.read();
    }
}

In addition, a client will be generated as well which can be used as:

// StrlenClientApp.java
import java.net.InetAddress;
import org.dcache.oncrpc4j.rpc.*;
import org.dcache.oncrpc4j.xdr.*;

public class StrlenClientApp {

    static final int DEFAULT_PORT = 1717;

    public static void main(String[] args) throws Exception {
        InetAddress address = InetAddress.getByName(args[0]);

        StrlenClient client = new StrlenClient(address, DEFAULT_PORT,
                strlen.STRLEN,
                strlen.STRLENVERS,
                IpProtocolType.TCP);
        System.out.println("Length of " + args[1] + " = " + client.strlen_1(args[1]));
        client.shutdown();
    }
}

Your RPC client and server are ready!

Use ONCRPC4J in your project

As maven dependency

<dependency>
    <groupId>org.dcache</groupId>
    <artifactId>oncrpc4j-core</artifactId>
    <version>3.0.2</version>
</dependency>

<repositories>
    <repository>
        <id>dcache-snapshots</id>
        <name>dCache.ORG maven repository</name>
        <url>https://download.dcache.org/nexus/content/repositories/releases</url>
        <layout>default</layout>
    </repository>
</repositories>

Accessing client subject inside RPC service

In some situation, OncRpcSvc can internally call other services which require client subject to be set in the context of the current thread. We use standard Java's Subject.doAs() mechanism to inject user subject into processing thread. As a result, the user subject can be extracted from AccessControlContext.

// SomeService.java
import javax.security.auth.Subject;
import java.security.AccessController;

public class SomeService {
    public void doSomeTask() {
        Subject subject = Subject.getSubject(AccessController.getContext());
        // start using subject
    }
}

// SubjectAvareSvcImpl.java
public class SubjectAvareSvcImpl implements RpcDispatchable {
    @Override
    public void dispatchOncRpcCall(RpcCall call)
                throws OncRpcException, IOException {
        externalService.doSomeTask();
        call.reply(XdrVoid.XDR_VOID);
    }
}

To avoid unnecessary overhead, subject propagation is not enabled by default:

OncRpcSvc service = new OncRpcSvcBuilder()
        .withTCP()
        .withAutoPublish()
        .withSameThreadIoStrategy()
        .withRpcService(... , new SubjectAvareSvcImpl())
        .withSubjectPropagation()
        .build();

Enabling JMX based monitoring

oncrpc4j uses Grizzly NIO framework which comes with it's own JMX monitoring capabilities. To enable it just add grizzly-framework-monitoring jar with it's dependencies into the application's classpath. See Grizzly framework dependencies for the instructions.

Usage with JDK 9 module system

With the provided stable automatic module name org.dcache.oncrpc4j, oncrpc4j can be used in modular java9 application:

module com.foo.bar {
    requires org.dcache.oncrpc4j;
}

RPC-over-TLS

oncrpc4j supports rpc-over-tls IETF activity. The goal of the project is to protect in-transit Remote Procedure Call messages with TLS. To enable RPC-over-TLS:

SSLContext sslServerContext = ...;

svc = new OncRpcSvcBuilder()
    .withTCP()
    ....
    .withSSLContext(sslServerContext)
    .withStartTLS()
    .withServiceName("svc")
    .build();
svc.start();

or, if special SSLParameters configuration is required, like cipher types, then:

SSLContext sslServerContext = ...;
SSLParameters parameters = ...;

svc = new OncRpcSvcBuilder()
    .withTCP()
    ....
    .withSSLContext(sslServerContext)
    .withSSLParameters(parameters)
    .withStartTLS()
    .withServiceName("svc")
    .build();
svc.start();

How to contribute

oncrpc4j uses the linux kernel model of using git not only a source repository, but also as a way to track contributions and copyrights.

Each submitted patch must have a "Signed-off-by" line. Patches without this line will not be accepted.

The sign-off is a simple line at the end of the explanation for the patch, which certifies that you wrote it or otherwise have the right to pass it on as an open-source patch. The rules are pretty simple: if you can certify the below:

Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

then you just add a line saying ( git commit -s )

Signed-off-by: Random J Developer <[email protected]>

using your real name (sorry, no pseudonyms or anonymous contributions.)

oncrpc4j's People

Contributors

artmk avatar dependabot[bot] avatar jimsermersheim avatar jlleitschuh avatar kofemann avatar mharj avatar paulmillar avatar pepijnve avatar radai-rosenblatt avatar rumpelstiltzkin avatar skoopys avatar tstoner1 avatar ylusine avatar zalmen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

oncrpc4j's Issues

BigInteger invocation error for non-valued xdr enums (e.g. enum colors { RED, ORANGE, GREEN })

The following xdr definition triggers a NumberFormatException in jrpcgen.translateConstant :

enum colors { RED, ORANGE, GREEN };

Call resolves to new BigInteger("0+1+1",8) where the string "0+1+1" is not a valid number representation.

Remark : When the definition has only two elements (such as enum colors { RED, ORANGE}), there is no error as the call resolves to new BigInteger("0+1",8) where "0+1" is a valid octal representation...

Charset parameter for getting/setting string values?

I know that NFSv4 has standardized on UTF-8 for encoding/decoding xdr strings. However, NFSv3 does not have that standard. (See RFC1813 section 3.2.5.)

I used jrpcgen to generate a mount3 client and am using that client to read the list of exported paths and mount them. (Then I use a nfs3 client to do some other unrelated stuff.) The problem I'm having is that some of the export paths on a customer server (a Windows Server) are encoded with ISO-8859-1. (I don't know what the coding is in advance, but I have since discovered the encoding.) When I get the exports using the jrpcgen-generated mount3 client, all string values (like path) are decoded with UTF-8, so if that isn't the correct encoding I get a string that can have one or more "replacement characters" for the characters that couldn't be decoded as UTF-8. When that happens no exception is thrown, so I don't know that there is anything wrong until I try to use that path string to mount the export path. At that point, the string with the replacement char in it is encoded back to a byte array by the XdrEncoder but does not match the exported path on the server so I get an error.

Even if an exception were thrown when one or more characters can't be decoded using UTF-8, there appears to be no mechanism for me to attempt to decode a string with a different Charset.

One workaround I've found is to modify the xdr file that I generate the client from and change the dirpath typedef from string to opaque. That allows me to get and set any dirpath values at a byte array rather than a string and puts the responsibility for decoding to String and encoding back to byte array in my program code.

That's not ideal though, because various components of our product (some of them not even Java) all need to do RPC things and prefer to share the same xdr definitions.

I don't know enough about the internal workings of OncRpc4J to know what an ideal solution would look like, but maybe this can be the start of a discussion about it?

My workaround code is based on some Python code used elsewhere in our product that first tries to decode strings with 'utf-8' and if a UnicodeDecodeError is raised it will then try to decode with 'latin-1'. That function then returns a both the decoded string and the char encoding that successfully decoded it as a tuple. But as I said above, in order to even be able to do that I need to first change the typedef from string to opaque, and that's not ideal.

Have others run into this issue? How have they handled it? Thanks.

How to get Port of the registered program

Hi,

***This is a query and not an issue. ***
I am trying to call RPC in UNIX server, but before actual call in need to look for the port of the program from portmap using program id and version number.

I have tested string Length program, and rpcinfo is giving below details :

program version netid address service owner
100000 4 tcp6 ::.0.111 portmapper superuser
100000 3 tcp6 ::.0.111 portmapper superuser
100000 4 udp6 ::.0.111 portmapper superuser
100000 3 udp6 ::.0.111 portmapper superuser
100000 4 tcp 0.0.0.0.0.111 portmapper superuser
100000 3 tcp 0.0.0.0.0.111 portmapper superuser
100000 2 tcp 0.0.0.0.0.111 portmapper superuser
100000 4 udp 0.0.0.0.0.111 portmapper superuser
100000 3 udp 0.0.0.0.0.111 portmapper superuser
100000 2 udp 0.0.0.0.0.111 portmapper superuser
100000 4 local /run/rpcbind.sock portmapper superuser
100000 3 local /run/rpcbind.sock portmapper superuser
117 1 tcp 0:0:0:0:0:0:0:0.7.127 - unknown
117 1 tcp6 0:0:0:0:0:0:0:0.7.127 - unknown

The program is registered with ID 177 and Version 1, But how can i determine the port grammatically.

I have gone through the code and found a class GenericPortmapClient and tried to get the dump.Still i am not getting the port of the program. I have used port 1919 while running server application.

Regards
Taslim Alam

Asynchronous processing

Despite oncrpc4j API looks perfectly asynchronous I've failed utterly trying to send responses in a separate thread. Unfortunately I don't have the stack trace at hand, but just out of curiosity: is it a known problem?

License question

Hi, I see that oncrpc4j says it is subject to the LGPL license, but it has a dependency on org.dcache.common:dcache-auth which contains source (such as DesiredRole.java) that is under AGPL. I believe that means oncrpc4j must also be licensed under AGPL.

Is there a way to break this dependency, so oncrpc4j can be cleanly under LGPL?

Can't register program on IBM AIX 5.1

Hello,

I am trying write a ONCRPC program on IBM AIX 5.1. First, I tested it on my windows 7 desktop and worked, but when I run it on IBM AIX 5.1, the program can't be registered to portmap service. The log listed below:


09:43:33.828 [WrapperSimpleAppMain] INFO com.csc.dl.rpc.server.Runner - Starting program...
09:43:33.860 [WrapperSimpleAppMain] INFO com.csc.dl.rpc.server.Runner - Start RPC Server @ Program: 9999
09:44:51.460 [WrapperSimpleAppMain] INFO com.csc.dl.rpc.server.Runner - Starting program...
09:44:51.498 [WrapperSimpleAppMain] INFO com.csc.dl.rpc.server.Runner - Start RPC Server @ Program: 9999
09:44:52.077 [WrapperSimpleAppMain] DEBUG c.c.d.rpc.helpers.EnvironmentHelper - Get env property by IP: test
09:44:54.542 [WrapperSimpleAppMain] INFO com.csc.dl.rpc.server.Limiter - Load threshold data
09:45:00.221 [WrapperSimpleAppMain] INFO org.dcache.xdr.OncRpcSvc - Registering new program [9999:1] : com.csc.dl.rpc.server.Applic
ation@a8bf6e6e
09:45:00.553 [WrapperSimpleAppMain] DEBUG o.d.xdr.portmap.RpcbindV4Client - portmap pina
0mpmppcbindV4Cli59 [WrapperSimpleAppMain] DEBUG org.dcache.xdr.ReplyQueue - Registering key 1
09:45:00.582 [WrapperSimpleAppMain] DEBUG org.dcache.xdr.ReplyQueue - query key 1 with timeout
09:45:00.593 [Grizzly-kernel(1) SelectorRunner] DEBUG org.dcache.xdr.ReplyQueue - updating key 1
09:45:00.596 [WrapperSimpleAppMain] DEBUG o.d.xdr.portmap.RpcbindV4Client - portmap unset port: prog: 9999 vers: 1, owner: root
09:45:00.601 [WrapperSimpleAppMain] DEBUG org.dcache.xdr.ReplyQueue - Registering key 2
09:45:00.603 [WrapperSimpleAppMain] DEBUG org.dcache.xdr.ReplyQueue - query key 2 with timeout
09:45:00.605 [Grizzly-kernel(1) SelectorRunner] DEBUG org.dcache.xdr.ReplyQueue - updating key 2
09:45:00.628 [WrapperSimpleAppMain] DEBUG o.d.xdr.portmap.RpcbindV4Client - portmap ping
09:45:00.629 [WrapperSimpleAppMain] DEBUG org.dcache.xdr.ReplyQueue - Registering key 3
09:45:00.631 [WrapperSimpleAppMain] DEBUG org.dcache.xdr.ReplyQueue - query key 3 with timeout
09:45:00.633 [Grizzly-kernel(1) SelectorRunner] DEBUG org.dcache.xdr.ReplyQueue - updating key 3
09:45:00.636 [WrapperSimpleAppMain] DEBUG o.d.xdr.portmap.RpcbindV4Client - portmap set port: prog: 9999 vers: 1, netid: udp addr: 0
:0:0:0:0:0:0:0.117.48, owner: root
09:45:00.638 [WrapperSimpleAppMain] DEBUG org.dcache.xdr.ReplyQueue - Registering key 4
09:45:00.639 [WrapperSimpleAppMain] DEBUG org.dcache.xdr.ReplyQueue - query key 4 with timeout
09:45:00.641 [Grizzly-kernel(1) SelectorRunner] DEBUG org.dcache.xdr.ReplyQueue - updating key 4
09:45:00.642 [WrapperSimpleAppMain] INFO com.csc.dl.rpc.server.Application - RPC Server started.


Can you provide any suggestion?
Thank you.

null handling for opaque (byte[]) data

if you leave an opaque value null, you get something like this:

java.lang.NullPointerException
    at org.dcache.xdr.Xdr.xdrEncodeDynamicOpaque(Xdr.java:554)
    at org.dcache.oncrpc4j.rpcgen.Value.xdrEncode(Value.java:33)
    at org.dcache.xdr.RpcCall.acceptedReply(RpcCall.java:238)
    at org.dcache.xdr.RpcCall.reply(RpcCall.java:225)

im not sure if anything can be done, since the specs (rfcs 1014, 1832 and 4056) dont say anything about nulls. and variable-length fields are encoded starting with the length as an unsigned number ...

im opening this just to verify that this should be treated as user error.

Failure downloading artifacts

Failed to read artifact descriptor for org.dcache:oncrpc4j-core:jar:3.0.1: Could not transfer artifact org.dcache:oncrpc4j-core:pom:3.0.1 from/to dcache releases (https://download.dcache.org/nexus/content/repositories/releases): Failed to transfer file: https://download.dcache.org/nexus/content/repositories/releases/org/dcache/oncrpc4j-core/3.0.1/oncrpc4j-core-3.0.1.pom. Return code is: 500 , ReasonPhrase:javax.servlet.ServletException: com.orientechnologies.orient.core.exception.OStorageException: Error in data flush background thread, please restart database and send full stack trace inside of bug report

Portmap issue?

When checking portmapper from Linux I see something strange on service list

# rpcinfo -p 10.10.10.20
   program vers proto   port  service
    100004    1   udp  51014  ypserv
    100004    24294967295  64916  ypserv
    100004    2   udp  51014  ypserv
    100000    2   tcp    111  portmapper
    100007    2   tcp  64833  ypbind
    100004    14294967295  64916  ypserv
    100004    2   tcp  64916  ypserv
    100004    1   tcp  64916  ypserv
    100000    2   udp    111  portmapper
    100007    2   udp  51010  ypbind
    100007    24294967295  64833  ypbind

Also command fails to connect to actual services

# rpcinfo -u 10.10.10.20 ypserv 1
rpcinfo: RPC: Remote system error
program 100004 version 1 is not available

Code is just simple stub classes running on Windows NetBeans

public class YpService {
    private final static int RPC_YPPROG = 100004;
    private final static int RPC_YPBIND = 100007;

    public static void main(String[] args) {
        new OncRpcEmbeddedPortmap(); 
        YpBindProg ypBind = new YpBindProg();
        YpProg ypProg = new YpProg();
        OncRpcSvc ypBindService = new OncRpcSvcBuilder()
                .withUDP()
                .withTCP()
                .withAutoPublish()
                .withSameThreadIoStrategy()
                .withRpcService(new OncRpcProgram(RPC_YPBIND, 2),ypBind)
                .build();
        OncRpcSvc ypService = new OncRpcSvcBuilder()
                .withUDP()
                .withTCP()
                .withAutoPublish()
                .withSameThreadIoStrategy()
                .withRpcService(new OncRpcProgram(RPC_YPPROG, 1),ypProg)
                .withRpcService(new OncRpcProgram(RPC_YPPROG, 2),ypProg)
                .build();       
        try {
            ypBindService.start();
            ypService.start();
            System.in.read();
        } catch (IOException ex) {
            Logger.getLogger(YpService.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

Libs are
core-2.5.3
guava-19.0
grizzly-framework-2.3.25
(slf4+auth deps)

make generated client code implement Closeable

generated code already has this:

public void shutdown() throws IOException {
   rpcClient.close();
}

just rename to close, make class implement Closeable, and now its try-with-resources compatible

Owner name unspecified

Hi ,
I am not able to set the owner name for rpc service ..I already set the value for owner field in portmapper client .but when I type the rpcinfo .
It is showing the service owner as unspecified.do you have any suggestions. I changed to portmapper v4.but there is no use

add a fat-jar artifact of oncrpc4j-core + dependencies for use as an rpcbind server

this is useful for developers working on OSs where there's no native portmap service to be found (windows) or the existing rpcbind server is dysfunctional (mac osx).

given a "fat jar" it would be relatively easy to run a portmap server by issuing:

java -cp fat.jar org.dcache.xdr.portmap.OncRpcbindServer

which is also easier to use in service definition files.

Reagrding connection open time

Hi,
I have a multiple threads are calling the rpc server .in the code you gave the constructor .when I pass the parameters like port number , version , tcp .it is establishing connection with rpc server . But threads are making multiple call to rpc server .I don't want to open multiple connections .how can I hold the connection . Two threads need to open the one connection with
rpc server and post the data to server.is there any methods I need to call from your code ?? .thanks in advance

Multiple version numbers of rpc program on different Linux machines

Hi kofemann,
I have a c++ rpc server .I want to generate different version numbers for that c++ rpc server from java ..can I use rpcsvc class .is it possible from your code?
Example :
Program number : 10007
But multiple versions(1, 2,3,4 up to 32 versions ) on different machine address( 4 IP address)
For the same c++ rpc server programme.
100007 1 tcp 38903 c++rpc
100007 2 tcp 60872 c++rpc
100007. 3 tcp 60987 c++rpc
Please give me your suggestion regarding this .
svc = new OncRpcSvcBuilder()
.withoutAutoPublish()
.withTCP()
.withMinPort(1)
.withMaxport(60000)
.withWorkerThreadIoStrategy()
.withBindAddress("127.0.0.1")
.withSelectorThreadPoolSize(1)
.withWorkerThreadPoolSize(1)
.withRpcService(new OncRpcProgram(PROGNUM, PROGVER), echo)
.withServiceName("c++rpc")
.build();
svc.start()
Here Program version(1to 32),IP address(1 to 4) I need to pass it differently??. And I want to do the same the process on different address like ip address1, ip address2 ,ip address3, ip address 4.. is it possible . I tried with above code and changed the bind address.what is the use of withbindaddress()? but it is throwing bind exception ..am run it on Windows but I pass the parameters in withbindaddress(Linux machine ip adderess1). I checked etc/hosts in Linux .I gave the localhost address from that file .still it is throwing bind exception. But when I gave the local address of Windows .it is registering the portmapper in Windows .please give me your suggestions regarding this

Could ONCRPC4J be embedded in an existing server?

Hello. In my project (Electronic Access Control) we are looking to replace an old ONCRPC implementation in the server with something new. But we still need ONCRPC to be compatible with existing door controller hardware. Our old implementation has the feature to embed the ONCRPC server in an existing server by creating the ONCRPC server with an input- and an output stream. Our solution is built that way because we have several protocols talking on the same server port.

So my question is can ONCRPC4J be embedded some way? Prefferably using asynchronous channels.

Regards, Oscar Lantz

Portmapper : owner unspecified when dumping rpcbs ...

A call through GenericPortmapClient to client.dump agains a fresh OncRpcbindServer instance returns
the following :
prog: 100000, vers: 2, netid: tcp, addr: 0.0.0.0.0.111, owner: unspecified
prog: 100000, vers: 2, netid: udp, addr: 0.0.0.0.0.111, owner: unspecified

here owner is "unspecified" while it is initialized to "superuser" in OncRpcbindServer constructor

add support for RPC over TLS

RPC protocol support various security flavors that provide data integrity and protection. However TLS based security is widely used outside of RPC. There is a low priority activity in IETF to adopt TLS as RPC transport. Oncrpc4j based on grizzly framework, thus adding TLS support should be easy.

make code for suitable for java9 module subsystem

Java9 module subsystem expects that a package exists only in a single jar file. This is in general true for oncrpc4j. However a better package names will makes no sense:

org.dcache.oncrpc4j
org.dcache.oncrpc4j.rpc
org.dcache.oncrpc4j.xdr
org.dcache.oncrpc4j.net

Xdr#xdrEncodeByteBuffer flips input buffer before using it

Xdr#xdrEncodeByteBuffer calls Buffer#flip on the input parameter before using it. This is rather surprising since Buffer based APIs normally use the position and limit of a Buffer to communicate which range of data should be used. Calling flip on the buffer makes it impossible to use any other position than 0.
Is this intentional or a bug?

handle 16 groups limit with AUTH_SYS

AUTH_SYS is limited to 16 groups, however many deployments require more that 16 groups support. This is typically handled by discovering users membership information based only on provided uid and querying an external service for missing information.

Is Windows' RPC Endpoint Mapper supported?

Hi, I'm very new to RPC. I am trying to convert some old Sun RPC code to Java in order to run on Windows. I was wondering if the Windows Portmapper service (RPC endpoint mapper) is supported by oncrpc4j or do I need to run your Java portmapdaemon?

Sorry for creating an issue for this question, as there is no way for me to message you via GitHub.

Expose a constructor for OncRpcClient that takes a OncRpcSvcBuilder

I have a need to supply a threadPoolSize to the OncRpcSvcBuilder's withSelectorThreadPoolSize method for generated clients.

Is there already a way? If not, I'm happy to provide a PR. I see that in the past that's been done by adding additional constructors to OncRpcClient.java. Maybe the most recent time was for PR 53?

Before I give you a PR, I wanted to ask, would it be useful to have a OncRpcClient constructor that takes an instance of OncRpcSvcBuilder so that we wouldn't need additional constructors every time we wanted to pass in a parameter that isn't already exposed? For example, I only need to limit the size of the selectorThreadPool but maybe someone else would need to limit the size of the workerThreadPool next month and would need to go through this process again. If one of the constructors took a OncRpcSvcBuilder then it could also make sure that everything that is needed for a client is set, like .withClientMode() and .withPort(localPort), but otherwise allow the end user to construct the client service with everything else allowed by the builder.

I'm thinking in my PR I'd leave all of the existing constructors alone (so it would be backward compatible with existing code) but change the one that all of the other's call, making it look like this:

public OncRpcClient(InetSocketAddress socketAddress, int protocol, int localPort, IoStrategy ioStrategy, String serviceName) {
    this(socketAddress, localPort, new OncRpcSvcBuilder()
            .withIpProtocolType(protocol)
            .withIoStrategy(ioStrategy)
            .withServiceName(serviceName));
}

and then I'd add this one (called by the one above, but could also be used directly by end users who need it like me):

public OncRpcClient(InetSocketAddress socketAddress, int localPort, OncRpcSvcBuilder builder) {
    _socketAddress = socketAddress;
    _rpcsvc = (builder == null ? new OncRpcSvcBuilder() : builder)
            .withClientMode()
            .withPort(localPort)
            .build();
}

I wanted to vet that idea with you before I do the work of committing a PR. It seems like it would prevent additional future churn just to expose additional things that the builder already provides.

Thanks for your help and input.

RpcDispatcher does not document user exceptions thrown of dispatchOncRpcCall

try {
   program.dispatchOncRpcCall(call);
} catch (RpcException e) {
   call.reject(e.getStatus(), e.getRpcReply());
   _log.warn("Failed to process RPC request: {}", e.getMessage());
} catch (OncRpcException e) {
   call.failRpcGarbage();
   _log.warn("Failed to process RPC request: {}", e.getMessage());
} catch (IOException e) {
   call.failRpcGarbage();
   _log.warn("Failed to process RPC request: {}", e.getMessage());
}

any user exceptions (like NPEs) thrown out of dispatchOncRpcCall() are not caught, and not logged.
this makes tracking down bugs in user code more difficult

Version number of rpc server

Hi,
I am running multiple rpc process on the server . Multiple threads are sending request to server .each thread need to identify server process .To establish the connection with rpc . In the code you mentioned one constructor .it will take the parameters port number , version, tcp ,program number . Port number I can able to get using portmapperclient object . How can I get the program version number .because each thread need to access the separate server process .
Thanks

OncRpcSvc constructor builds transports with hard-coded same-thread-io-strategy, rather than the one specified.

I was monitoring my rpc service via jmx and noticed the io-strategy was set to same-thread. That seemed strange since I requested leader-follower in my code. I started examining oncrpc4j source code and noticed that the nio transport builders are hard-coding same-thread strategy rather than using the one configured by the oncrpcsrv builder:

        IoStrategy ioStrategy = builder.getIoStrategy();
        String serviceName = builder.getServiceName();
        ThreadPoolConfig selectorPoolConfig = getSelectorPoolCfg(ioStrategy,
                serviceName,
                builder.getSelectorThreadPoolSize());

        if ((protocol & IpProtocolType.TCP) != 0) {
            final TCPNIOTransport tcpTransport = TCPNIOTransportBuilder
                    .newInstance()
                    .setReuseAddress(true)
                    .setIOStrategy(SameThreadIOStrategy.getInstance())
                    .setSelectorThreadPoolConfig(selectorPoolConfig)
                    .setSelectorRunnersCount(selectorPoolConfig.getMaxPoolSize())
                    .build();
            _transports.add(tcpTransport);
        }

        if ((protocol & IpProtocolType.UDP) != 0) {
            final UDPNIOTransport udpTransport = UDPNIOTransportBuilder
                    .newInstance()
                    .setReuseAddress(true)
                    .setIOStrategy(SameThreadIOStrategy.getInstance())
                    .setSelectorThreadPoolConfig(selectorPoolConfig)
                    .setSelectorRunnersCount(selectorPoolConfig.getMaxPoolSize())
                    .build();
            _transports.add(udpTransport);
        }

Is this intentional?

It seems the specified io-strategy is only used to set the size of the thread pool.

Regarding jrpcgen

Hi,
I mentioned the char [] array in .x file
Using rpcgen it is parsing as char array
But jrpcgen generating byte [] array in Java class . Is there any issue ? .
I have a c++ server
Java as client side which uses oncrpc .
When I converted the hexa string to byte array from Java and send to c++ .it is printing all zeros .

Jrpcgen is throwing error while generating server and client stubs

.x file ..when I create the function without arguments ..
It is throwing syntax error ..
But when I create the function with argument.
It is working properly .
Is there any solution .??
Because I have c++ code which is running on sever .I want to make the call to that functions ..c++ code contain the functions without parameters .

Port number

		assertTrue( portmapClient.getPort(OncRpcPortmap.PORTMAP_PROGRAMM, OncRpcPortmap.PORTMAP_V2, "tcp").equals("127.0.0.1.0.111") ); // check port

What is the port number here 0.111
Please let me know what is the format it is giving

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.