tyrus
  1. tyrus
  2. TYRUS-200

[client] Provide facility for thread factory (worker & selector thread)

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0
    • Fix Version/s: 1.1
    • Component/s: None
    • Labels:
      None

      Description

      From the developer's angle, perhaps they would like to see ExecutorService rather than Grizzly thread pool (even though grizzly's threadpool seems to offer more options) . For e.g.

      ClientManager client = ClientManager.createClient();
      client.getProperties().put("...", Executors.newFixedThreadPool(5));

      I also prefer passing Map to ClientManager.createClient(Map<String, ?> props) so that changing properties after client is created would mean subtle behavioral changes.

        Issue Links

          Activity

          Hide
          Pavel Bucek added a comment -

          Fixed in the trunk.

          Now you can set worker and selector ThreadPoolConfig used by grizzly container when creating Tyrus client. Following sample only sets ThreadFactory, but there are many more options which you can modify (pool size, memory management, queues, ..)

                      ClientManager client = ClientManager.createClient();
          
                      client.getProperties().put(GrizzlyClientSocket.WORKER_THREAD_POOL_CONFIG, ThreadPoolConfig.defaultConfig().setThreadFactory(new ThreadFactory() {
                          @Override
                          public Thread newThread(Runnable r) {
                              // ...
                          }
                      }));
          
                      client.getProperties().put(GrizzlyClientSocket.SELECTOR_THREAD_POOL_CONFIG, ThreadPoolConfig.defaultConfig().setThreadFactory(new ThreadFactory() {
                          @Override
                          public Thread newThread(Runnable r) {
                              // ...
                          }
                      }));
          
          
                      client.connectToServer(/*...*/);

          See ThreadPoolConfig javadoc for more details: https://grizzly.java.net/docs/2.3/apidocs/org/glassfish/grizzly/threadpool/ThreadPoolConfig.html

          feel free to comment/reopen if this solution is not sufficient for your usecase.

          Show
          Pavel Bucek added a comment - Fixed in the trunk. Now you can set worker and selector ThreadPoolConfig used by grizzly container when creating Tyrus client. Following sample only sets ThreadFactory, but there are many more options which you can modify (pool size, memory management, queues, ..) ClientManager client = ClientManager.createClient(); client.getProperties().put(GrizzlyClientSocket.WORKER_THREAD_POOL_CONFIG, ThreadPoolConfig.defaultConfig().setThreadFactory( new ThreadFactory() { @Override public Thread newThread( Runnable r) { // ... } })); client.getProperties().put(GrizzlyClientSocket.SELECTOR_THREAD_POOL_CONFIG, ThreadPoolConfig.defaultConfig().setThreadFactory( new ThreadFactory() { @Override public Thread newThread( Runnable r) { // ... } })); client.connectToServer(/*...*/); See ThreadPoolConfig javadoc for more details: https://grizzly.java.net/docs/2.3/apidocs/org/glassfish/grizzly/threadpool/ThreadPoolConfig.html feel free to comment/reopen if this solution is not sufficient for your usecase.

            People

            • Assignee:
              Pavel Bucek
              Reporter:
              Pavel Bucek
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: