Coder Social home page Coder Social logo

Comments (12)

kofemann avatar kofemann commented on August 22, 2024 1

I guess, backport to 3.1 is ok, as long as we don't change the behavior. I will try to add a basic implementation that you can enrich if needed.

from oncrpc4j.

kofemann avatar kofemann commented on August 22, 2024 1

The rpcgen is updated as well.

from oncrpc4j.

kofemann avatar kofemann commented on August 22, 2024 1

I will try to publish the jars over the weekend

from oncrpc4j.

kofemann avatar kofemann commented on August 22, 2024 1

The jars should be online.

from oncrpc4j.

kofemann avatar kofemann commented on August 22, 2024

Looks like a reasonable request. However, the OncRpcClient is there just to provide a sensible defaults. If initialization done by the builder, then where is the added value of
OncRpcClient?

  var clnt = new OncRpcSvcBuilder()
          .withoutAutoPublish()
          .withTCP()
          .withClientMode()
          .withWorkerThreadIoStrategy()
          .withSelectorThreadPoolSize(1)
          .withWorkerThreadPoolSize(1)
          .withRpcService(new OncRpcProgram(PROGNUM, PROGVER), upper)
          .withSSLContext(sslClientContext)
          .withServiceName("clnt")
          .build();
  clnt.start();

  RpcTransport t = clnt.connect(svc.getInetSocketAddress(IpProtocolType.TCP));
  clntCall = new RpcCall(PROGNUM, PROGVER, new RpcAuthTypeNone(), t);

The problem with OncRpcSvcBuilder is that it allows to build an invalid service for the client. Maybe a special OncRpcClientBuilder will be a better option, that will take care that internally used OncRpcSvcBuilder built correctly, something like:

  public class OncRpcClient {
     // package only
     OncRpcClient(OncRpcSvc svc) {...}
  }
  
  public class OncRpcClientBuilder {
     
     svcBuilder = new OncRpcSvcBuilder()
           .withClientMode()
           .withoutAutoPublish()
  
     public OncRpcClientBuilder withSelectorThreadPoolSize(int n) {
          svcBuilder.withSelectorThreadPoolSize(1);
          return this;
     }
     
     public OncRpcClient build() {
         return new OncRpcClient(svcBuilder.build());
     }
  }

What do you think?

from oncrpc4j.

harrv avatar harrv commented on August 22, 2024

@kofemann Yes, using a OncRpcClientBuilder does seem better based on the concern you shared. I had attempted to address that in my proposal by setting .withClientMode() on the builder once it was passed to the new constructor, but I'm new to using any of the dCache projects so didn't immediately recognize the other things that are probably server-specific such as auto publish and withRpcService.

If you are willing to make the change that might be better than if I were to do it since you have a good idea of how it needs to be done to make sure users don't end up with an unusable client. If you'd like me to take a stab at it based on your OncRpcClientBuilder idea, let me know and I'll create a PR for mainline following the things you brought up in your post.

Either way though, I'm wondering if you'd be willing to backport it to a version 3.1.2? The project where we're using this is still on Java 8, so we can't go to 3.2 and later quite yet. If that's not possible, I'll probably need to explore taking a fork to 3.1.2 for this.

from oncrpc4j.

harrv avatar harrv commented on August 22, 2024

Thank you!

As long as it gives a way to set both selectorThreadPoolSize and workerThreadPoolSize then I don't think I'll need any other change. The thing that was causing us trouble was when the thread pool size was automatically set based on number of CPU cores.

And just to add, if you decide you'd rather add a constructor that takes those two additional things rather than implement a builder, that would be fine too and is up to you. The idea of using a builder is appealing just in case there is anything else I need to adjust in the future, but I don't currently have a need for anything more than those two additional values.

from oncrpc4j.

kofemann avatar kofemann commented on August 22, 2024

could you check that commit kofemann@42fb509 does what you need

from oncrpc4j.

harrv avatar harrv commented on August 22, 2024

That looks great! I think I would also need a corresponding change to jrpcgen.java in the dumpClient() method beginning at about line 1955.

from oncrpc4j.

harrv avatar harrv commented on August 22, 2024

Thank you very much. That looks good to me.

from oncrpc4j.

harrv avatar harrv commented on August 22, 2024

@kofemann Can I help with any next steps toward a release (and the 3.1 backport we talked about)?

from oncrpc4j.

harrv avatar harrv commented on August 22, 2024

The jars should be online.

Thanks so much for all of your work on that! Using version 3.1.2 now in our project.

from oncrpc4j.

Related Issues (20)

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.