Re: [VOTE] Release ActiveMQ-CPP v3.9.5

2019-01-28 Thread Jean-Baptiste Onofré
+1

Checked the signature and legal.

Regards
JB

On 28/01/2019 17:35, Timothy Bish wrote:
> New vote open for ActiveMQ-CPP v3.9.5
> 
> This is a new patch release of the ActiveMQ-CPP client with an
> additional configuration option to allow for timing out connect attempts
> when the remote fails to respond.  There is also a fix for a potential
> memory leak during SSL handshake processing.
> 
> The source bundles for this release can be found here:
> https://dist.apache.org/repos/dist/dev/activemq/activemq-cpp/3.9.5/
> 
> The Wiki page for the release is here:
> http://activemq.apache.org/cms/activemq-cpp-395-release.html
> 
> The list of issues fixed in this release is available here:
> https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12311207=12339670
> 
> 
> 
> Please cast your votes:
> 
> [ ] +1 Release the source as Apache ActiveMQ-CPP 3.9.5
> [ ] -1 (provide specific comments)
> 

-- 
Jean-Baptiste Onofré
jbono...@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com


[GitHub] franz1981 commented on issue #2523: ARTEMIS-1977 ASYNCIO can reduce sys-calls to retrieve I/O events

2019-01-28 Thread GitBox
franz1981 commented on issue #2523: ARTEMIS-1977 ASYNCIO can reduce sys-calls 
to retrieve I/O events
URL: https://github.com/apache/activemq-artemis/pull/2523#issuecomment-458418530
 
 
   @michaelandrepearce @clebertsuconic 
   Today I will talk with some of the kernel guys that has written libAIO: I've 
taken a deep look to 
https://elixir.bootlin.com/linux/latest/source/fs/aio.c#L1148 and seems that 
for x86 I could avoid any hardware barriers.
   `lfence,sfence` are hw barriers needed just when used among non-temporal 
stores ie that won't use the caches, while temporal x86 stores are guaranteed 
to not being reordered by the processor.
   I need to cross-compile the 32 bit version accordly, many thanks to super- 
@orpiske  for his help!


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] jbertram opened a new pull request #2527: NO-JIRA add logging to LegacyLDAPSecuritySettingPlugin

2019-01-28 Thread GitBox
jbertram opened a new pull request #2527: NO-JIRA add logging to 
LegacyLDAPSecuritySettingPlugin
URL: https://github.com/apache/activemq-artemis/pull/2527
 
 
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[ANNOUNCE] ActiveMQ Artemis 2.6.4 Released

2019-01-28 Thread Clebert Suconic
I'm pleased to announce the release of ActiveMQ Artemis 2.6.4.


Downloads are now available at:
http://activemq.apache.org/artemis/download.html


For a complete list of updates:
http://activemq.apache.org/artemis/release-notes-2.6.4.html


As usual it contains a handful of bug fixes and other improvements.


Many thanks for all the contributors to this release.


[GitHub] clebertsuconic commented on issue #2526: ARTEMIS-2238 Enhancement to queueQuery on producer

2019-01-28 Thread GitBox
clebertsuconic commented on issue #2526: ARTEMIS-2238 Enhancement to queueQuery 
on producer
URL: https://github.com/apache/activemq-artemis/pull/2526#issuecomment-458227689
 
 
   I'm using a PR to 2.6.x so I can run the CI before merging.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] clebertsuconic opened a new pull request #2526: ARTEMIS-2238 Enhancement to queueQuery on producer

2019-01-28 Thread GitBox
clebertsuconic opened a new pull request #2526: ARTEMIS-2238 Enhancement to 
queueQuery on producer
URL: https://github.com/apache/activemq-artemis/pull/2526
 
 
   this is a squash of the following master fixes
   (squashed commit 0f905224e7cd9f71729ebd8434cdde44e396fd0c)
   (squashed commit 33f56c81bdefa3492f722a67b5282b527545886c)
   (squashed commit e595b7ca169c0eaa3c5ebd10d102e4252685d201)


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


Re: [VOTE] Release ActiveMQ-CPP v3.9.5

2019-01-28 Thread Timothy Bish
+1

* Validated signatures a checksums
* Checked for license and notice files
* Built from source on Mint 18.3 and ran unit tests and integration tests
with 5.x build


On Mon, Jan 28, 2019 at 11:35 AM Timothy Bish  wrote:

> New vote open for ActiveMQ-CPP v3.9.5
>
> This is a new patch release of the ActiveMQ-CPP client with an additional
> configuration option to allow for timing out connect attempts when the
> remote fails to respond.  There is also a fix for a potential memory leak
> during SSL handshake processing.
>
> The source bundles for this release can be found here:
> https://dist.apache.org/repos/dist/dev/activemq/activemq-cpp/3.9.5/
>
> The Wiki page for the release is here:
> http://activemq.apache.org/cms/activemq-cpp-395-release.html
>
> The list of issues fixed in this release is available here:
>
> https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12311207=12339670
> 
>
> Please cast your votes:
>
> [ ] +1 Release the source as Apache ActiveMQ-CPP 3.9.5
> [ ] -1 (provide specific comments)
>
> --
> Tim Bish
>
>

-- 
--
Tim Bish


[GitHub] michaelandrepearce opened a new pull request #2525: ARTEMIS-2241 Support direct deliver for InVMAcceptors

2019-01-28 Thread GitBox
michaelandrepearce opened a new pull request #2525: ARTEMIS-2241 Support direct 
deliver for InVMAcceptors
URL: https://github.com/apache/activemq-artemis/pull/2525
 
 
   Push isDirectDeliver method from netty impl, to the Connection interface
   Add support to InVMConnection for isDirectDeliver flag and ability to set 
via config, defaulting to false, to keep current default behavior. 
   Extend DirectDeliverTest to check InVM as well.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[VOTE] Release ActiveMQ-CPP v3.9.5

2019-01-28 Thread Timothy Bish

New vote open for ActiveMQ-CPP v3.9.5

This is a new patch release of the ActiveMQ-CPP client with an 
additional configuration option to allow for timing out connect attempts 
when the remote fails to respond.  There is also a fix for a potential 
memory leak during SSL handshake processing.


The source bundles for this release can be found here:
https://dist.apache.org/repos/dist/dev/activemq/activemq-cpp/3.9.5/

The Wiki page for the release is here:
http://activemq.apache.org/cms/activemq-cpp-395-release.html

The list of issues fixed in this release is available here:
https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12311207=12339670 



Please cast your votes:

[ ] +1 Release the source as Apache ActiveMQ-CPP 3.9.5
[ ] -1 (provide specific comments)

--
Tim Bish



[GitHub] asfgit merged pull request #2520: ARTEMIS-2238 Enhancement to queueQuery on producer

2019-01-28 Thread GitBox
asfgit merged pull request #2520: ARTEMIS-2238 Enhancement to queueQuery on 
producer
URL: https://github.com/apache/activemq-artemis/pull/2520
 
 
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] michaelandrepearce commented on issue #2520: ARTEMIS-2238 Enhancement to queueQuery on producer

2019-01-28 Thread GitBox
michaelandrepearce commented on issue #2520: ARTEMIS-2238 Enhancement to 
queueQuery on producer
URL: https://github.com/apache/activemq-artemis/pull/2520#issuecomment-458132624
 
 
   @clebertsuconic merged, thanks as always for the contribution.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] franz1981 commented on a change in pull request #2524: ARTEMIS-2240 ActiveMQThreadPoolExecutor should use LinkedTransferQueue

2019-01-28 Thread GitBox
franz1981 commented on a change in pull request #2524: ARTEMIS-2240 
ActiveMQThreadPoolExecutor should use LinkedTransferQueue
URL: https://github.com/apache/activemq-artemis/pull/2524#discussion_r251404035
 
 

 ##
 File path: 
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ActiveMQThreadPoolExecutor.java
 ##
 @@ -29,125 +30,58 @@
  * and will be removed after idling for a specified keep time.
  * But in contrast to a standard cached executor, tasks are queued if the
  * maximum pool size if reached, instead of rejected.
- *
- * This is achieved by using a specialized blocking queue, which checks the
- * state of the associated executor in the offer method to decide whether to
- * queue a task or have the executor create another thread.
- *
- * Since the thread pool's execute method is reentrant, more than one caller
- * could try to offer a task into the queue. There is a small chance that
- * (a few) more threads are created as it should be limited by max pool size.
- * To allow for such a case not to reject a task, the underlying thread pool
- * executor is not limited. Only the offer method checks the configured limit.
  */
 public class ActiveMQThreadPoolExecutor extends ThreadPoolExecutor {
 
-   @SuppressWarnings("serial")
-   private static class ThreadPoolQueue extends LinkedBlockingQueue {
+   /**
+* The default rejected execution handler
+*/
+   private static final RejectedExecutionHandler defaultHandler = new 
AbortPolicy();
 
-  private ActiveMQThreadPoolExecutor executor = null;
+   // Handler executed when a task is submitted and a new thread cannot be 
created (because maxSize was reached)
+   // It queues the task on the executors's queue (using the add() method, see 
ThreadPoolQueue class below)
+   private static class QueueExecutionHandler implements 
RejectedExecutionHandler {
 
-  // keep track of the difference between the number of idle threads and
-  // the number of queued tasks. If the delta is > 0, we have more
-  // idle threads than queued tasks and can add more tasks into the queue.
-  // The delta is incremented if a thread becomes idle or if a task is 
taken from the queue.
-  // The delta is decremented if a thread leaves idle state or if a task 
is added to the queue.
-  private static final AtomicIntegerFieldUpdater 
DELTA_UPDATER = AtomicIntegerFieldUpdater.newUpdater(ThreadPoolQueue.class, 
"threadTaskDelta");
-  private volatile int threadTaskDelta = 0;
+  private final RejectedExecutionHandler handler;
 
-  public void setExecutor(ActiveMQThreadPoolExecutor executor) {
- this.executor = executor;
+  private QueueExecutionHandler(RejectedExecutionHandler handler) {
+ Objects.requireNonNull(handler);
+ this.handler = handler;
   }
 
   @Override
-  public boolean offer(Runnable runnable) {
- boolean retval = false;
-
- if (threadTaskDelta > 0 || (executor.getPoolSize() >= 
executor.getMaximumPoolSize())) {
-// A new task will be added to the queue if the maximum number of 
threads has been reached
-// or if the delta is > 0, which means that there are enough idle 
threads.
-
-retval = super.offer(runnable);
-
-// Only decrement the delta if the task has actually been added to 
the queue
-if (retval)
-   DELTA_UPDATER.decrementAndGet(this);
+  public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
+ if (executor.isShutdown() || !executor.getQueue().add(r)) {
+handler.rejectedExecution(r, executor);
  }
-
- return retval;
   }
+   }
 
-  @Override
-  public Runnable take() throws InterruptedException {
- // Increment the delta as a thread becomes idle
- // by waiting for a task to take from the queue
- DELTA_UPDATER.incrementAndGet(this);
-
-
- Runnable runnable = null;
+   // A specialized LinkedBlockingQueue that takes new elements by calling 
add() but not offer()
 
 Review comment:
   @michaelandrepearce No worries Michael: I can ask @clebertsuconic 
super-charged machine as well to run a test with it :P
   The primary concerns/motivation of this PR are:
   
   - better scalability (ReentrantLock of LinkedBlockingQueue makes me 
super-sad!!) without sacrificing low number, but fast pairs connected
   - reduction of code complexity


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] michaelandrepearce commented on a change in pull request #2517: [ARTEMIS-2171]: ThreadPoolExecutor leak under SM due to lack of privileged block.

2019-01-28 Thread GitBox
michaelandrepearce commented on a change in pull request #2517: [ARTEMIS-2171]: 
ThreadPoolExecutor leak under SM due to lack of privileged block.
URL: https://github.com/apache/activemq-artemis/pull/2517#discussion_r251403621
 
 

 ##
 File path: 
artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/NetworkHealthCheck.java
 ##
 @@ -157,7 +157,12 @@ public NetworkHealthCheck parseURIList(String 
addressList) {
 
@Override
protected ActiveMQThreadFactory getThreadFactory() {
-  return new ActiveMQThreadFactory("NetworkChecker", "Network-Checker-", 
false, getThisClassLoader());
 
 Review comment:
   @ehsavoie can you close this PR then? And the Jira you opened.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] michaelandrepearce commented on a change in pull request #2524: ARTEMIS-2240 ActiveMQThreadPoolExecutor should use LinkedTransferQueue

2019-01-28 Thread GitBox
michaelandrepearce commented on a change in pull request #2524: ARTEMIS-2240 
ActiveMQThreadPoolExecutor should use LinkedTransferQueue
URL: https://github.com/apache/activemq-artemis/pull/2524#discussion_r251401890
 
 

 ##
 File path: 
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ActiveMQThreadPoolExecutor.java
 ##
 @@ -29,125 +30,58 @@
  * and will be removed after idling for a specified keep time.
  * But in contrast to a standard cached executor, tasks are queued if the
  * maximum pool size if reached, instead of rejected.
- *
- * This is achieved by using a specialized blocking queue, which checks the
- * state of the associated executor in the offer method to decide whether to
- * queue a task or have the executor create another thread.
- *
- * Since the thread pool's execute method is reentrant, more than one caller
- * could try to offer a task into the queue. There is a small chance that
- * (a few) more threads are created as it should be limited by max pool size.
- * To allow for such a case not to reject a task, the underlying thread pool
- * executor is not limited. Only the offer method checks the configured limit.
  */
 public class ActiveMQThreadPoolExecutor extends ThreadPoolExecutor {
 
-   @SuppressWarnings("serial")
-   private static class ThreadPoolQueue extends LinkedBlockingQueue {
+   /**
+* The default rejected execution handler
+*/
+   private static final RejectedExecutionHandler defaultHandler = new 
AbortPolicy();
 
-  private ActiveMQThreadPoolExecutor executor = null;
+   // Handler executed when a task is submitted and a new thread cannot be 
created (because maxSize was reached)
+   // It queues the task on the executors's queue (using the add() method, see 
ThreadPoolQueue class below)
+   private static class QueueExecutionHandler implements 
RejectedExecutionHandler {
 
-  // keep track of the difference between the number of idle threads and
-  // the number of queued tasks. If the delta is > 0, we have more
-  // idle threads than queued tasks and can add more tasks into the queue.
-  // The delta is incremented if a thread becomes idle or if a task is 
taken from the queue.
-  // The delta is decremented if a thread leaves idle state or if a task 
is added to the queue.
-  private static final AtomicIntegerFieldUpdater 
DELTA_UPDATER = AtomicIntegerFieldUpdater.newUpdater(ThreadPoolQueue.class, 
"threadTaskDelta");
-  private volatile int threadTaskDelta = 0;
+  private final RejectedExecutionHandler handler;
 
-  public void setExecutor(ActiveMQThreadPoolExecutor executor) {
- this.executor = executor;
+  private QueueExecutionHandler(RejectedExecutionHandler handler) {
+ Objects.requireNonNull(handler);
+ this.handler = handler;
   }
 
   @Override
-  public boolean offer(Runnable runnable) {
- boolean retval = false;
-
- if (threadTaskDelta > 0 || (executor.getPoolSize() >= 
executor.getMaximumPoolSize())) {
-// A new task will be added to the queue if the maximum number of 
threads has been reached
-// or if the delta is > 0, which means that there are enough idle 
threads.
-
-retval = super.offer(runnable);
-
-// Only decrement the delta if the task has actually been added to 
the queue
-if (retval)
-   DELTA_UPDATER.decrementAndGet(this);
+  public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
+ if (executor.isShutdown() || !executor.getQueue().add(r)) {
+handler.rejectedExecution(r, executor);
  }
-
- return retval;
   }
+   }
 
-  @Override
-  public Runnable take() throws InterruptedException {
- // Increment the delta as a thread becomes idle
- // by waiting for a task to take from the queue
- DELTA_UPDATER.incrementAndGet(this);
-
-
- Runnable runnable = null;
+   // A specialized LinkedBlockingQueue that takes new elements by calling 
add() but not offer()
 
 Review comment:
   I did but i didnt capture results. It was a bit better than your commit 1 we 
are talking micros here, for the use case i was checking for. If you need 
results, ill have to try do later in the week, busy week again.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] michaelandrepearce commented on a change in pull request #2524: ARTEMIS-2240 ActiveMQThreadPoolExecutor should use LinkedTransferQueue

2019-01-28 Thread GitBox
michaelandrepearce commented on a change in pull request #2524: ARTEMIS-2240 
ActiveMQThreadPoolExecutor should use LinkedTransferQueue
URL: https://github.com/apache/activemq-artemis/pull/2524#discussion_r251401890
 
 

 ##
 File path: 
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ActiveMQThreadPoolExecutor.java
 ##
 @@ -29,125 +30,58 @@
  * and will be removed after idling for a specified keep time.
  * But in contrast to a standard cached executor, tasks are queued if the
  * maximum pool size if reached, instead of rejected.
- *
- * This is achieved by using a specialized blocking queue, which checks the
- * state of the associated executor in the offer method to decide whether to
- * queue a task or have the executor create another thread.
- *
- * Since the thread pool's execute method is reentrant, more than one caller
- * could try to offer a task into the queue. There is a small chance that
- * (a few) more threads are created as it should be limited by max pool size.
- * To allow for such a case not to reject a task, the underlying thread pool
- * executor is not limited. Only the offer method checks the configured limit.
  */
 public class ActiveMQThreadPoolExecutor extends ThreadPoolExecutor {
 
-   @SuppressWarnings("serial")
-   private static class ThreadPoolQueue extends LinkedBlockingQueue {
+   /**
+* The default rejected execution handler
+*/
+   private static final RejectedExecutionHandler defaultHandler = new 
AbortPolicy();
 
-  private ActiveMQThreadPoolExecutor executor = null;
+   // Handler executed when a task is submitted and a new thread cannot be 
created (because maxSize was reached)
+   // It queues the task on the executors's queue (using the add() method, see 
ThreadPoolQueue class below)
+   private static class QueueExecutionHandler implements 
RejectedExecutionHandler {
 
-  // keep track of the difference between the number of idle threads and
-  // the number of queued tasks. If the delta is > 0, we have more
-  // idle threads than queued tasks and can add more tasks into the queue.
-  // The delta is incremented if a thread becomes idle or if a task is 
taken from the queue.
-  // The delta is decremented if a thread leaves idle state or if a task 
is added to the queue.
-  private static final AtomicIntegerFieldUpdater 
DELTA_UPDATER = AtomicIntegerFieldUpdater.newUpdater(ThreadPoolQueue.class, 
"threadTaskDelta");
-  private volatile int threadTaskDelta = 0;
+  private final RejectedExecutionHandler handler;
 
-  public void setExecutor(ActiveMQThreadPoolExecutor executor) {
- this.executor = executor;
+  private QueueExecutionHandler(RejectedExecutionHandler handler) {
+ Objects.requireNonNull(handler);
+ this.handler = handler;
   }
 
   @Override
-  public boolean offer(Runnable runnable) {
- boolean retval = false;
-
- if (threadTaskDelta > 0 || (executor.getPoolSize() >= 
executor.getMaximumPoolSize())) {
-// A new task will be added to the queue if the maximum number of 
threads has been reached
-// or if the delta is > 0, which means that there are enough idle 
threads.
-
-retval = super.offer(runnable);
-
-// Only decrement the delta if the task has actually been added to 
the queue
-if (retval)
-   DELTA_UPDATER.decrementAndGet(this);
+  public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
+ if (executor.isShutdown() || !executor.getQueue().add(r)) {
+handler.rejectedExecution(r, executor);
  }
-
- return retval;
   }
+   }
 
-  @Override
-  public Runnable take() throws InterruptedException {
- // Increment the delta as a thread becomes idle
- // by waiting for a task to take from the queue
- DELTA_UPDATER.incrementAndGet(this);
-
-
- Runnable runnable = null;
+   // A specialized LinkedBlockingQueue that takes new elements by calling 
add() but not offer()
 
 Review comment:
   I did but i didnt capture results. It was a bit better than your commit 1, 
for the use case i was checking for. If you need results, ill have to try do 
later in the week, busy week again.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] franz1981 commented on a change in pull request #2524: ARTEMIS-2240 ActiveMQThreadPoolExecutor should use LinkedTransferQueue

2019-01-28 Thread GitBox
franz1981 commented on a change in pull request #2524: ARTEMIS-2240 
ActiveMQThreadPoolExecutor should use LinkedTransferQueue
URL: https://github.com/apache/activemq-artemis/pull/2524#discussion_r251396219
 
 

 ##
 File path: 
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ActiveMQThreadPoolExecutor.java
 ##
 @@ -29,125 +30,58 @@
  * and will be removed after idling for a specified keep time.
  * But in contrast to a standard cached executor, tasks are queued if the
  * maximum pool size if reached, instead of rejected.
- *
- * This is achieved by using a specialized blocking queue, which checks the
- * state of the associated executor in the offer method to decide whether to
- * queue a task or have the executor create another thread.
- *
- * Since the thread pool's execute method is reentrant, more than one caller
- * could try to offer a task into the queue. There is a small chance that
- * (a few) more threads are created as it should be limited by max pool size.
- * To allow for such a case not to reject a task, the underlying thread pool
- * executor is not limited. Only the offer method checks the configured limit.
  */
 public class ActiveMQThreadPoolExecutor extends ThreadPoolExecutor {
 
-   @SuppressWarnings("serial")
-   private static class ThreadPoolQueue extends LinkedBlockingQueue {
+   /**
+* The default rejected execution handler
+*/
+   private static final RejectedExecutionHandler defaultHandler = new 
AbortPolicy();
 
-  private ActiveMQThreadPoolExecutor executor = null;
+   // Handler executed when a task is submitted and a new thread cannot be 
created (because maxSize was reached)
+   // It queues the task on the executors's queue (using the add() method, see 
ThreadPoolQueue class below)
+   private static class QueueExecutionHandler implements 
RejectedExecutionHandler {
 
-  // keep track of the difference between the number of idle threads and
-  // the number of queued tasks. If the delta is > 0, we have more
-  // idle threads than queued tasks and can add more tasks into the queue.
-  // The delta is incremented if a thread becomes idle or if a task is 
taken from the queue.
-  // The delta is decremented if a thread leaves idle state or if a task 
is added to the queue.
-  private static final AtomicIntegerFieldUpdater 
DELTA_UPDATER = AtomicIntegerFieldUpdater.newUpdater(ThreadPoolQueue.class, 
"threadTaskDelta");
-  private volatile int threadTaskDelta = 0;
+  private final RejectedExecutionHandler handler;
 
-  public void setExecutor(ActiveMQThreadPoolExecutor executor) {
- this.executor = executor;
+  private QueueExecutionHandler(RejectedExecutionHandler handler) {
+ Objects.requireNonNull(handler);
+ this.handler = handler;
   }
 
   @Override
-  public boolean offer(Runnable runnable) {
- boolean retval = false;
-
- if (threadTaskDelta > 0 || (executor.getPoolSize() >= 
executor.getMaximumPoolSize())) {
-// A new task will be added to the queue if the maximum number of 
threads has been reached
-// or if the delta is > 0, which means that there are enough idle 
threads.
-
-retval = super.offer(runnable);
-
-// Only decrement the delta if the task has actually been added to 
the queue
-if (retval)
-   DELTA_UPDATER.decrementAndGet(this);
+  public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
+ if (executor.isShutdown() || !executor.getQueue().add(r)) {
+handler.rejectedExecution(r, executor);
  }
-
- return retval;
   }
+   }
 
-  @Override
-  public Runnable take() throws InterruptedException {
- // Increment the delta as a thread becomes idle
- // by waiting for a task to take from the queue
- DELTA_UPDATER.incrementAndGet(this);
-
-
- Runnable runnable = null;
+   // A specialized LinkedBlockingQueue that takes new elements by calling 
add() but not offer()
 
 Review comment:
   True: just a qq...have you tried this new impl too?
   I've just run a simple load and it seems the best of the 3, but you 
know...I'm not quite trusty of my box :)


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] michaelandrepearce commented on a change in pull request #2524: ARTEMIS-2240 ActiveMQThreadPoolExecutor should use LinkedTransferQueue

2019-01-28 Thread GitBox
michaelandrepearce commented on a change in pull request #2524: ARTEMIS-2240 
ActiveMQThreadPoolExecutor should use LinkedTransferQueue
URL: https://github.com/apache/activemq-artemis/pull/2524#discussion_r251395045
 
 

 ##
 File path: 
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ActiveMQThreadPoolExecutor.java
 ##
 @@ -29,125 +30,58 @@
  * and will be removed after idling for a specified keep time.
  * But in contrast to a standard cached executor, tasks are queued if the
  * maximum pool size if reached, instead of rejected.
- *
- * This is achieved by using a specialized blocking queue, which checks the
- * state of the associated executor in the offer method to decide whether to
- * queue a task or have the executor create another thread.
- *
- * Since the thread pool's execute method is reentrant, more than one caller
- * could try to offer a task into the queue. There is a small chance that
- * (a few) more threads are created as it should be limited by max pool size.
- * To allow for such a case not to reject a task, the underlying thread pool
- * executor is not limited. Only the offer method checks the configured limit.
  */
 public class ActiveMQThreadPoolExecutor extends ThreadPoolExecutor {
 
-   @SuppressWarnings("serial")
-   private static class ThreadPoolQueue extends LinkedBlockingQueue {
+   /**
+* The default rejected execution handler
+*/
+   private static final RejectedExecutionHandler defaultHandler = new 
AbortPolicy();
 
-  private ActiveMQThreadPoolExecutor executor = null;
+   // Handler executed when a task is submitted and a new thread cannot be 
created (because maxSize was reached)
+   // It queues the task on the executors's queue (using the add() method, see 
ThreadPoolQueue class below)
+   private static class QueueExecutionHandler implements 
RejectedExecutionHandler {
 
-  // keep track of the difference between the number of idle threads and
-  // the number of queued tasks. If the delta is > 0, we have more
-  // idle threads than queued tasks and can add more tasks into the queue.
-  // The delta is incremented if a thread becomes idle or if a task is 
taken from the queue.
-  // The delta is decremented if a thread leaves idle state or if a task 
is added to the queue.
-  private static final AtomicIntegerFieldUpdater 
DELTA_UPDATER = AtomicIntegerFieldUpdater.newUpdater(ThreadPoolQueue.class, 
"threadTaskDelta");
-  private volatile int threadTaskDelta = 0;
+  private final RejectedExecutionHandler handler;
 
-  public void setExecutor(ActiveMQThreadPoolExecutor executor) {
- this.executor = executor;
+  private QueueExecutionHandler(RejectedExecutionHandler handler) {
+ Objects.requireNonNull(handler);
+ this.handler = handler;
   }
 
   @Override
-  public boolean offer(Runnable runnable) {
- boolean retval = false;
-
- if (threadTaskDelta > 0 || (executor.getPoolSize() >= 
executor.getMaximumPoolSize())) {
-// A new task will be added to the queue if the maximum number of 
threads has been reached
-// or if the delta is > 0, which means that there are enough idle 
threads.
-
-retval = super.offer(runnable);
-
-// Only decrement the delta if the task has actually been added to 
the queue
-if (retval)
-   DELTA_UPDATER.decrementAndGet(this);
+  public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
+ if (executor.isShutdown() || !executor.getQueue().add(r)) {
+handler.rejectedExecution(r, executor);
  }
-
- return retval;
   }
+   }
 
-  @Override
-  public Runnable take() throws InterruptedException {
- // Increment the delta as a thread becomes idle
- // by waiting for a task to take from the queue
- DELTA_UPDATER.incrementAndGet(this);
-
-
- Runnable runnable = null;
+   // A specialized LinkedBlockingQueue that takes new elements by calling 
add() but not offer()
 
 Review comment:
   Well then we remove the current doc at least. The doc atm != the code 


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] franz1981 commented on a change in pull request #2524: ARTEMIS-2240 ActiveMQThreadPoolExecutor should use LinkedTransferQueue

2019-01-28 Thread GitBox
franz1981 commented on a change in pull request #2524: ARTEMIS-2240 
ActiveMQThreadPoolExecutor should use LinkedTransferQueue
URL: https://github.com/apache/activemq-artemis/pull/2524#discussion_r251325505
 
 

 ##
 File path: 
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ActiveMQThreadPoolExecutor.java
 ##
 @@ -29,125 +30,58 @@
  * and will be removed after idling for a specified keep time.
  * But in contrast to a standard cached executor, tasks are queued if the
  * maximum pool size if reached, instead of rejected.
- *
- * This is achieved by using a specialized blocking queue, which checks the
- * state of the associated executor in the offer method to decide whether to
- * queue a task or have the executor create another thread.
- *
- * Since the thread pool's execute method is reentrant, more than one caller
- * could try to offer a task into the queue. There is a small chance that
- * (a few) more threads are created as it should be limited by max pool size.
- * To allow for such a case not to reject a task, the underlying thread pool
- * executor is not limited. Only the offer method checks the configured limit.
  */
 public class ActiveMQThreadPoolExecutor extends ThreadPoolExecutor {
 
-   @SuppressWarnings("serial")
-   private static class ThreadPoolQueue extends LinkedBlockingQueue {
+   /**
+* The default rejected execution handler
+*/
+   private static final RejectedExecutionHandler defaultHandler = new 
AbortPolicy();
 
-  private ActiveMQThreadPoolExecutor executor = null;
+   // Handler executed when a task is submitted and a new thread cannot be 
created (because maxSize was reached)
+   // It queues the task on the executors's queue (using the add() method, see 
ThreadPoolQueue class below)
+   private static class QueueExecutionHandler implements 
RejectedExecutionHandler {
 
-  // keep track of the difference between the number of idle threads and
-  // the number of queued tasks. If the delta is > 0, we have more
-  // idle threads than queued tasks and can add more tasks into the queue.
-  // The delta is incremented if a thread becomes idle or if a task is 
taken from the queue.
-  // The delta is decremented if a thread leaves idle state or if a task 
is added to the queue.
-  private static final AtomicIntegerFieldUpdater 
DELTA_UPDATER = AtomicIntegerFieldUpdater.newUpdater(ThreadPoolQueue.class, 
"threadTaskDelta");
-  private volatile int threadTaskDelta = 0;
+  private final RejectedExecutionHandler handler;
 
-  public void setExecutor(ActiveMQThreadPoolExecutor executor) {
- this.executor = executor;
+  private QueueExecutionHandler(RejectedExecutionHandler handler) {
+ Objects.requireNonNull(handler);
+ this.handler = handler;
   }
 
   @Override
-  public boolean offer(Runnable runnable) {
- boolean retval = false;
-
- if (threadTaskDelta > 0 || (executor.getPoolSize() >= 
executor.getMaximumPoolSize())) {
-// A new task will be added to the queue if the maximum number of 
threads has been reached
-// or if the delta is > 0, which means that there are enough idle 
threads.
-
-retval = super.offer(runnable);
-
-// Only decrement the delta if the task has actually been added to 
the queue
-if (retval)
-   DELTA_UPDATER.decrementAndGet(this);
+  public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
+ if (executor.isShutdown() || !executor.getQueue().add(r)) {
+handler.rejectedExecution(r, executor);
  }
-
- return retval;
   }
+   }
 
-  @Override
-  public Runnable take() throws InterruptedException {
- // Increment the delta as a thread becomes idle
- // by waiting for a task to take from the queue
- DELTA_UPDATER.incrementAndGet(this);
-
-
- Runnable runnable = null;
+   // A specialized LinkedBlockingQueue that takes new elements by calling 
add() but not offer()
 
 Review comment:
   I don't know bud, just looking at the doc of `tryTransfert` is very clear 
(for a concurrent q doc obviously :P).
   But If you feel that adding some doc could help I will add some for sure 
:+1: 


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] michaelandrepearce commented on a change in pull request #2524: ARTEMIS-2240 ActiveMQThreadPoolExecutor should use LinkedTransferQueue

2019-01-28 Thread GitBox
michaelandrepearce commented on a change in pull request #2524: ARTEMIS-2240 
ActiveMQThreadPoolExecutor should use LinkedTransferQueue
URL: https://github.com/apache/activemq-artemis/pull/2524#discussion_r251322362
 
 

 ##
 File path: 
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ActiveMQThreadPoolExecutor.java
 ##
 @@ -29,125 +30,58 @@
  * and will be removed after idling for a specified keep time.
  * But in contrast to a standard cached executor, tasks are queued if the
  * maximum pool size if reached, instead of rejected.
- *
- * This is achieved by using a specialized blocking queue, which checks the
- * state of the associated executor in the offer method to decide whether to
- * queue a task or have the executor create another thread.
- *
- * Since the thread pool's execute method is reentrant, more than one caller
- * could try to offer a task into the queue. There is a small chance that
- * (a few) more threads are created as it should be limited by max pool size.
- * To allow for such a case not to reject a task, the underlying thread pool
- * executor is not limited. Only the offer method checks the configured limit.
  */
 public class ActiveMQThreadPoolExecutor extends ThreadPoolExecutor {
 
-   @SuppressWarnings("serial")
-   private static class ThreadPoolQueue extends LinkedBlockingQueue {
+   /**
+* The default rejected execution handler
+*/
+   private static final RejectedExecutionHandler defaultHandler = new 
AbortPolicy();
 
-  private ActiveMQThreadPoolExecutor executor = null;
+   // Handler executed when a task is submitted and a new thread cannot be 
created (because maxSize was reached)
+   // It queues the task on the executors's queue (using the add() method, see 
ThreadPoolQueue class below)
+   private static class QueueExecutionHandler implements 
RejectedExecutionHandler {
 
-  // keep track of the difference between the number of idle threads and
-  // the number of queued tasks. If the delta is > 0, we have more
-  // idle threads than queued tasks and can add more tasks into the queue.
-  // The delta is incremented if a thread becomes idle or if a task is 
taken from the queue.
-  // The delta is decremented if a thread leaves idle state or if a task 
is added to the queue.
-  private static final AtomicIntegerFieldUpdater 
DELTA_UPDATER = AtomicIntegerFieldUpdater.newUpdater(ThreadPoolQueue.class, 
"threadTaskDelta");
-  private volatile int threadTaskDelta = 0;
+  private final RejectedExecutionHandler handler;
 
-  public void setExecutor(ActiveMQThreadPoolExecutor executor) {
- this.executor = executor;
+  private QueueExecutionHandler(RejectedExecutionHandler handler) {
+ Objects.requireNonNull(handler);
+ this.handler = handler;
   }
 
   @Override
-  public boolean offer(Runnable runnable) {
- boolean retval = false;
-
- if (threadTaskDelta > 0 || (executor.getPoolSize() >= 
executor.getMaximumPoolSize())) {
-// A new task will be added to the queue if the maximum number of 
threads has been reached
-// or if the delta is > 0, which means that there are enough idle 
threads.
-
-retval = super.offer(runnable);
-
-// Only decrement the delta if the task has actually been added to 
the queue
-if (retval)
-   DELTA_UPDATER.decrementAndGet(this);
+  public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
+ if (executor.isShutdown() || !executor.getQueue().add(r)) {
+handler.rejectedExecution(r, executor);
  }
-
- return retval;
   }
+   }
 
-  @Override
-  public Runnable take() throws InterruptedException {
- // Increment the delta as a thread becomes idle
- // by waiting for a task to take from the queue
- DELTA_UPDATER.incrementAndGet(this);
-
-
- Runnable runnable = null;
+   // A specialized LinkedBlockingQueue that takes new elements by calling 
add() but not offer()
 
 Review comment:
   Need to change this, sorry in my example i was doing quickly, so comments 
etc left unchanged.
   
   Maybe
   
   --
   
   A specialized LinkedTransderQueue that takes new elements on offer, by 
trying to transfer if if idle thread by calling tryTransfer(), calling add() 
will force the queue to take a new element.
   
   This is to force the ThreadPoolExecutor to offer successfully when an idle 
thread exists, but otherwise create new threads and never queue.
   
   
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] michaelandrepearce commented on a change in pull request #2524: ARTEMIS-2240 ActiveMQThreadPoolExecutor should use LinkedTransferQueue

2019-01-28 Thread GitBox
michaelandrepearce commented on a change in pull request #2524: ARTEMIS-2240 
ActiveMQThreadPoolExecutor should use LinkedTransferQueue
URL: https://github.com/apache/activemq-artemis/pull/2524#discussion_r251322362
 
 

 ##
 File path: 
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ActiveMQThreadPoolExecutor.java
 ##
 @@ -29,125 +30,58 @@
  * and will be removed after idling for a specified keep time.
  * But in contrast to a standard cached executor, tasks are queued if the
  * maximum pool size if reached, instead of rejected.
- *
- * This is achieved by using a specialized blocking queue, which checks the
- * state of the associated executor in the offer method to decide whether to
- * queue a task or have the executor create another thread.
- *
- * Since the thread pool's execute method is reentrant, more than one caller
- * could try to offer a task into the queue. There is a small chance that
- * (a few) more threads are created as it should be limited by max pool size.
- * To allow for such a case not to reject a task, the underlying thread pool
- * executor is not limited. Only the offer method checks the configured limit.
  */
 public class ActiveMQThreadPoolExecutor extends ThreadPoolExecutor {
 
-   @SuppressWarnings("serial")
-   private static class ThreadPoolQueue extends LinkedBlockingQueue {
+   /**
+* The default rejected execution handler
+*/
+   private static final RejectedExecutionHandler defaultHandler = new 
AbortPolicy();
 
-  private ActiveMQThreadPoolExecutor executor = null;
+   // Handler executed when a task is submitted and a new thread cannot be 
created (because maxSize was reached)
+   // It queues the task on the executors's queue (using the add() method, see 
ThreadPoolQueue class below)
+   private static class QueueExecutionHandler implements 
RejectedExecutionHandler {
 
-  // keep track of the difference between the number of idle threads and
-  // the number of queued tasks. If the delta is > 0, we have more
-  // idle threads than queued tasks and can add more tasks into the queue.
-  // The delta is incremented if a thread becomes idle or if a task is 
taken from the queue.
-  // The delta is decremented if a thread leaves idle state or if a task 
is added to the queue.
-  private static final AtomicIntegerFieldUpdater 
DELTA_UPDATER = AtomicIntegerFieldUpdater.newUpdater(ThreadPoolQueue.class, 
"threadTaskDelta");
-  private volatile int threadTaskDelta = 0;
+  private final RejectedExecutionHandler handler;
 
-  public void setExecutor(ActiveMQThreadPoolExecutor executor) {
- this.executor = executor;
+  private QueueExecutionHandler(RejectedExecutionHandler handler) {
+ Objects.requireNonNull(handler);
+ this.handler = handler;
   }
 
   @Override
-  public boolean offer(Runnable runnable) {
- boolean retval = false;
-
- if (threadTaskDelta > 0 || (executor.getPoolSize() >= 
executor.getMaximumPoolSize())) {
-// A new task will be added to the queue if the maximum number of 
threads has been reached
-// or if the delta is > 0, which means that there are enough idle 
threads.
-
-retval = super.offer(runnable);
-
-// Only decrement the delta if the task has actually been added to 
the queue
-if (retval)
-   DELTA_UPDATER.decrementAndGet(this);
+  public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
+ if (executor.isShutdown() || !executor.getQueue().add(r)) {
+handler.rejectedExecution(r, executor);
  }
-
- return retval;
   }
+   }
 
-  @Override
-  public Runnable take() throws InterruptedException {
- // Increment the delta as a thread becomes idle
- // by waiting for a task to take from the queue
- DELTA_UPDATER.incrementAndGet(this);
-
-
- Runnable runnable = null;
+   // A specialized LinkedBlockingQueue that takes new elements by calling 
add() but not offer()
 
 Review comment:
   Need to change this, sorry in my example i was doing quickly, so comments 
etc left unchanged.
   
   Maybe
   
   --
   
   A specialized LinkedTransderQueue that takes new elements on offer, by 
trying to transfer if if idle thread by calling tryTransfer(), calling add() 
will force the queue to take a new element.
   
   This is to force the ThreadPoolExecutor to offer successfully when an idle 
thread exists, but otherwise create new threads and never queue.
   --
   
   
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] franz1981 commented on issue #2524: ARTEMIS-2240 ActiveMQThreadPoolExecutor should use LinkedTransferQueue

2019-01-28 Thread GitBox
franz1981 commented on issue #2524: ARTEMIS-2240 ActiveMQThreadPoolExecutor 
should use LinkedTransferQueue
URL: https://github.com/apache/activemq-artemis/pull/2524#issuecomment-458042571
 
 
   @michaelandrepearce I'm very happy (I hope that perf are nice as well), 
because it makes much more simple to understand what the code does now


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] michaelandrepearce commented on a change in pull request #2524: ARTEMIS-2240 ActiveMQThreadPoolExecutor should use LinkedTransferQueue

2019-01-28 Thread GitBox
michaelandrepearce commented on a change in pull request #2524: ARTEMIS-2240 
ActiveMQThreadPoolExecutor should use LinkedTransferQueue
URL: https://github.com/apache/activemq-artemis/pull/2524#discussion_r251320704
 
 

 ##
 File path: 
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ActiveMQThreadPoolExecutor.java
 ##
 @@ -29,125 +29,57 @@
  * and will be removed after idling for a specified keep time.
  * But in contrast to a standard cached executor, tasks are queued if the
  * maximum pool size if reached, instead of rejected.
- *
- * This is achieved by using a specialized blocking queue, which checks the
- * state of the associated executor in the offer method to decide whether to
- * queue a task or have the executor create another thread.
- *
- * Since the thread pool's execute method is reentrant, more than one caller
- * could try to offer a task into the queue. There is a small chance that
- * (a few) more threads are created as it should be limited by max pool size.
- * To allow for such a case not to reject a task, the underlying thread pool
- * executor is not limited. Only the offer method checks the configured limit.
  */
 public class ActiveMQThreadPoolExecutor extends ThreadPoolExecutor {
 
-   @SuppressWarnings("serial")
-   private static class ThreadPoolQueue extends LinkedBlockingQueue {
+   /**
+* The default rejected execution handler
+*/
+   private static final RejectedExecutionHandler defaultHandler = new 
AbortPolicy();
 
-  private ActiveMQThreadPoolExecutor executor = null;
+   // Handler executed when a task is submitted and a new thread cannot be 
created (because maxSize was reached)
+   // It queues the task on the executors's queue (using the add() method, see 
ThreadPoolQueue class below)
+   private static class QueueExecutionHandler implements 
RejectedExecutionHandler {
 
-  // keep track of the difference between the number of idle threads and
-  // the number of queued tasks. If the delta is > 0, we have more
-  // idle threads than queued tasks and can add more tasks into the queue.
-  // The delta is incremented if a thread becomes idle or if a task is 
taken from the queue.
-  // The delta is decremented if a thread leaves idle state or if a task 
is added to the queue.
-  private static final AtomicIntegerFieldUpdater 
DELTA_UPDATER = AtomicIntegerFieldUpdater.newUpdater(ThreadPoolQueue.class, 
"threadTaskDelta");
-  private volatile int threadTaskDelta = 0;
+  private final RejectedExecutionHandler handler;
 
-  public void setExecutor(ActiveMQThreadPoolExecutor executor) {
- this.executor = executor;
+  private QueueExecutionHandler(RejectedExecutionHandler handler) {
+ this.handler = handler;
 
 Review comment:
   Add 
   
   if (handler == null)
   throw new NullPointerException();


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] franz1981 commented on issue #2524: ARTEMIS-2240 ActiveMQThreadPoolExecutor should use LinkedTransferQueue

2019-01-28 Thread GitBox
franz1981 commented on issue #2524: ARTEMIS-2240 ActiveMQThreadPoolExecutor 
should use LinkedTransferQueue
URL: https://github.com/apache/activemq-artemis/pull/2524#issuecomment-458041944
 
 
   @michaelandrepearce nice catch!! 
   you've already measured with your box how the last version is performing?
   I've run the same bench I'm using and it seems really great: hopefully will 
scale a lot better too :+1: 


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] michaelandrepearce edited a comment on issue #2524: ARTEMIS-2240 ActiveMQThreadPoolExecutor should use LinkedTransferQueue

2019-01-28 Thread GitBox
michaelandrepearce edited a comment on issue #2524: ARTEMIS-2240 
ActiveMQThreadPoolExecutor should use LinkedTransferQueue
URL: https://github.com/apache/activemq-artemis/pull/2524#issuecomment-458039733
 
 
   @franz1981 a slight improvement, i spotted old master wasn't honoring the 
pre 2.4 original behaviour of on shutdown, rejection would then use default 
policy of the executor (AbortPolicy) which would throw rejection exception. a 
simple correction.
   
   -->

   ```
   /*
* ActiveMQThreadPoolExecutor: a special ThreadPoolExecutor that combines
* the benefits of a cached executor and a fixed size executor.
* Similar to a cached executor, threads exceeding the core size are only 
created on demand,
* and will be removed after idling for a specified keep time.
* But in contrast to a standard cached executor, tasks are queued if the
* maximum pool size if reached, instead of rejected.
*/
   public class ActiveMQThreadPoolExecutor extends ThreadPoolExecutor {
   
  /**
   * The default rejected execution handler
   */
  private static final RejectedExecutionHandler defaultHandler = new 
AbortPolicy();
   
  // Handler executed when a task is submitted and a new thread cannot be 
created (because maxSize was reached)
  // It queues the task on the executors's queue (using the add() method, 
see ThreadPoolQueue class below)
  private static class QueueExecutionHandler implements 
RejectedExecutionHandler {
   
 private final RejectedExecutionHandler handler;
   
 private QueueExecutionHandler(RejectedExecutionHandler handler) {
if (handler == null)
   throw new NullPointerException();
this.handler = handler;
 }
   
 @Override
 public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) 
{
if (executor.isShutdown() || !executor.getQueue().add(r)) {
   handler.rejectedExecution(r, executor);
}
 }
  }
   
   
  // A specialized LinkedBlockingQueue that takes new elements by calling 
add() but not offer()
  // This is to force the ThreadPoolExecutor to always create new threads 
and never queue
  private static class ThreadPoolQueue extends 
LinkedTransferQueue {
   
 @Override
 public boolean offer(Runnable runnable) {
return tryTransfer(runnable);
 }
   
 @Override
 public boolean add(Runnable runnable) {
return super.offer( runnable );
 }
  }
   
  public ActiveMQThreadPoolExecutor(int coreSize, int maxSize, long keep, 
TimeUnit keepUnits, ThreadFactory factory) {
 this(coreSize, maxSize, keep, keepUnits, factory, defaultHandler);
  }
   
  public ActiveMQThreadPoolExecutor(int coreSize, int maxSize, long keep, 
TimeUnit keepUnits, ThreadFactory factory, RejectedExecutionHandler handler) {
 super(coreSize, maxSize, keep, keepUnits, new ThreadPoolQueue(), 
factory, new QueueExecutionHandler(handler));
  }
   }
   
   ```


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] michaelandrepearce commented on issue #2524: ARTEMIS-2240 ActiveMQThreadPoolExecutor should use LinkedTransferQueue

2019-01-28 Thread GitBox
michaelandrepearce commented on issue #2524: ARTEMIS-2240 
ActiveMQThreadPoolExecutor should use LinkedTransferQueue
URL: https://github.com/apache/activemq-artemis/pull/2524#issuecomment-458039733
 
 
   @franz1981 a slight improvement, i spotted old master wasn't honoring the 
pre 2.4 original behaviour of on shutdown, rejection would then use default 
policy of the executor (AbortPolicy) which would throw rejection exception. a 
simple correction.
   
   -->

   ```
   /*
* ActiveMQThreadPoolExecutor: a special ThreadPoolExecutor that combines
* the benefits of a cached executor and a fixed size executor.
* Similar to a cached executor, threads exceeding the core size are only 
created on demand,
* and will be removed after idling for a specified keep time.
* But in contrast to a standard cached executor, tasks are queued if the
* maximum pool size if reached, instead of rejected.
*/
   public class ActiveMQThreadPoolExecutor extends ThreadPoolExecutor {
   
  /**
   * The default rejected execution handler
   */
  private static final RejectedExecutionHandler defaultHandler = new 
AbortPolicy();
   
  // Handler executed when a task is submitted and a new thread cannot be 
created (because maxSize was reached)
  // It queues the task on the executors's queue (using the add() method, 
see ThreadPoolQueue class below)
  private static class QueueExecutionHandler implements 
RejectedExecutionHandler {
   
 private final RejectedExecutionHandler handler;
   
 private QueueExecutionHandler(RejectedExecutionHandler handler) {
this.handler = handler;
 }
   
 @Override
 public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) 
{
if (executor.isShutdown() || !executor.getQueue().add(r)) {
   handler.rejectedExecution(r, executor);
}
 }
  }
   
   
  // A specialized LinkedBlockingQueue that takes new elements by calling 
add() but not offer()
  // This is to force the ThreadPoolExecutor to always create new threads 
and never queue
  private static class ThreadPoolQueue extends 
LinkedTransferQueue {
   
 @Override
 public boolean offer(Runnable runnable) {
return tryTransfer(runnable);
 }
   
 @Override
 public boolean add(Runnable runnable) {
return super.offer( runnable );
 }
  }
   
  public ActiveMQThreadPoolExecutor(int coreSize, int maxSize, long keep, 
TimeUnit keepUnits, ThreadFactory factory) {
 this(coreSize, maxSize, keep, keepUnits, factory, defaultHandler);
  }
   
  public ActiveMQThreadPoolExecutor(int coreSize, int maxSize, long keep, 
TimeUnit keepUnits, ThreadFactory factory, RejectedExecutionHandler handler) {
 super(coreSize, maxSize, keep, keepUnits, new ThreadPoolQueue(), 
factory, new QueueExecutionHandler(handler));
  }
   }
   
   ```


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] franz1981 commented on issue #2524: ARTEMIS-2240 ActiveMQThreadPoolExecutor should use LinkedTransferQueue

2019-01-28 Thread GitBox
franz1981 commented on issue #2524: ARTEMIS-2240 ActiveMQThreadPoolExecutor 
should use LinkedTransferQueue
URL: https://github.com/apache/activemq-artemis/pull/2524#issuecomment-458038880
 
 
   Thanks @michaelandrepearce to have looked into this, I will change it 
accordingly to the last comment (nice simple and effective, I like it!) and 
left the PR here for @clebertsuconic :)


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] michaelandrepearce edited a comment on issue #2524: ARTEMIS-2240 ActiveMQThreadPoolExecutor should use LinkedTransferQueue

2019-01-28 Thread GitBox
michaelandrepearce edited a comment on issue #2524: ARTEMIS-2240 
ActiveMQThreadPoolExecutor should use LinkedTransferQueue
URL: https://github.com/apache/activemq-artemis/pull/2524#issuecomment-458033744
 
 
   I am see a perf gain, in commit 1, i see if anything (its a micro second 
here or there) negative on commit 2.
   
   I actually found something positive though, if you take the master version 
that we recently reverted as it kept adding new threads, vs trying to see if a 
thread was idle.
   
   Change it to LinkedTransferQueue and then in the offer section, which it was 
just returning false and the core perf issue with it. And instead use your 
tryTransfer(runnable) which is available with switching to LinkedTransferQueue, 
this actually seems to be really good, as in it now will send a runnable to a 
idle thread fixing the original issue, (via tryTransfer) but also becomes quite 
lock less (not 100% because of underlying executor but...), a simpler code, 
which i guess what it was trying to achieve.
   
   sample:
   
   
   ```
   /*
* ActiveMQThreadPoolExecutor: a special ThreadPoolExecutor that combines
* the benefits of a cached executor and a fixed size executor.
* Similar to a cached executor, threads exceeding the core size are only 
created on demand,
* and will be removed after idling for a specified keep time.
* But in contrast to a standard cached executor, tasks are queued if the
* maximum pool size if reached, instead of rejected.
*/
   public class ActiveMQThreadPoolExecutor extends ThreadPoolExecutor {
   
  // Handler executed when a task is submitted and a new thread cannot be 
created (because maxSize was reached)
  // It queues the task on the executors's queue (using the add() method, 
see ThreadPoolQueue class below)
  private static final RejectedExecutionHandler QUEUE_EXECUTION_HANDLER = 
(r, e) -> {
 if (!e.isShutdown()) {
e.getQueue().add(r);
 }
  };
   
  // A specialized LinkedBlockingQueue that takes new elements by calling 
add() but not offer()
  // This is to force the ThreadPoolExecutor to always create new threads 
and never queue
  private static class ThreadPoolQueue extends 
LinkedTransferQueue {
   
 @Override
 public boolean offer(Runnable runnable) {
return tryTransfer(runnable);
 }
   
 @Override
 public boolean add(Runnable runnable) {
return super.offer( runnable );
 }
  }
   
  public ActiveMQThreadPoolExecutor(int coreSize, int maxSize, long keep, 
TimeUnit keepUnits, ThreadFactory factory) {
 super( coreSize, maxSize, keep, keepUnits, new ThreadPoolQueue(), 
factory, QUEUE_EXECUTION_HANDLER );
  }
   }
   
   
   ```


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] michaelandrepearce edited a comment on issue #2524: ARTEMIS-2240 ActiveMQThreadPoolExecutor should use LinkedTransferQueue

2019-01-28 Thread GitBox
michaelandrepearce edited a comment on issue #2524: ARTEMIS-2240 
ActiveMQThreadPoolExecutor should use LinkedTransferQueue
URL: https://github.com/apache/activemq-artemis/pull/2524#issuecomment-458033744
 
 
   I am see a perf gain, in commit 1, i see if anything (its a micro second 
here or there) negative on commit 2.
   
   I actually found something positive though, if you take the master version 
that we recently reverted as it kept adding new threads, vs trying to see if a 
thread was idle.
   
   Change it to LinkedTransferQueue and then in the offer section, which it was 
just returning false and the core perf issue with it. And instead use your 
tryTransfer(runnable) which is available with switching to LinkedTransferQueue, 
this actually seems to be really good, as in it now will send a runnable to a 
idle thread fixing the original issue, (via tryTransfer) but also becomes very 
lock less, a simpler code, which i guess what it was trying to achieve.
   
   sample:
   
   
   ```
   /*
* ActiveMQThreadPoolExecutor: a special ThreadPoolExecutor that combines
* the benefits of a cached executor and a fixed size executor.
* Similar to a cached executor, threads exceeding the core size are only 
created on demand,
* and will be removed after idling for a specified keep time.
* But in contrast to a standard cached executor, tasks are queued if the
* maximum pool size if reached, instead of rejected.
*/
   public class ActiveMQThreadPoolExecutor extends ThreadPoolExecutor {
   
  // Handler executed when a task is submitted and a new thread cannot be 
created (because maxSize was reached)
  // It queues the task on the executors's queue (using the add() method, 
see ThreadPoolQueue class below)
  private static final RejectedExecutionHandler QUEUE_EXECUTION_HANDLER = 
(r, e) -> {
 if (!e.isShutdown()) {
e.getQueue().add(r);
 }
  };
   
  // A specialized LinkedBlockingQueue that takes new elements by calling 
add() but not offer()
  // This is to force the ThreadPoolExecutor to always create new threads 
and never queue
  private static class ThreadPoolQueue extends 
LinkedTransferQueue {
   
 @Override
 public boolean offer(Runnable runnable) {
return tryTransfer(runnable);
 }
   
 @Override
 public boolean add(Runnable runnable) {
return super.offer( runnable );
 }
  }
   
  public ActiveMQThreadPoolExecutor(int coreSize, int maxSize, long keep, 
TimeUnit keepUnits, ThreadFactory factory) {
 super( coreSize, maxSize, keep, keepUnits, new ThreadPoolQueue(), 
factory, QUEUE_EXECUTION_HANDLER );
  }
   }
   
   
   ```


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] michaelandrepearce commented on issue #2524: ARTEMIS-2240 ActiveMQThreadPoolExecutor should use LinkedTransferQueue

2019-01-28 Thread GitBox
michaelandrepearce commented on issue #2524: ARTEMIS-2240 
ActiveMQThreadPoolExecutor should use LinkedTransferQueue
URL: https://github.com/apache/activemq-artemis/pull/2524#issuecomment-458033744
 
 
   I am see a perf gain, in commit 1, i see if anything (its a micro second 
here or there) negative on commit 2.
   
   I actually found something positive though, if you take the master version 
that we recently reverted as it kept adding new threads, vs trying to see if a 
thread was idle.
   
   Change it to LinkedTransferQueue and then in the offer section, which it was 
just returning false and the core perf issue with it. And instead use your 
tryTransfer(runnable) which is available with switching to LinkedTransferQueue, 
this actually seems to be really good, as in it now will send a runnable to a 
idle thread, (e.g. tryTransfer) but also becomes very lock less, a simpler 
code, which i guess what it was trying to achieve.
   
   sample:
   
   
   ```
   /*
* ActiveMQThreadPoolExecutor: a special ThreadPoolExecutor that combines
* the benefits of a cached executor and a fixed size executor.
* Similar to a cached executor, threads exceeding the core size are only 
created on demand,
* and will be removed after idling for a specified keep time.
* But in contrast to a standard cached executor, tasks are queued if the
* maximum pool size if reached, instead of rejected.
*/
   public class ActiveMQThreadPoolExecutor extends ThreadPoolExecutor {
   
  // Handler executed when a task is submitted and a new thread cannot be 
created (because maxSize was reached)
  // It queues the task on the executors's queue (using the add() method, 
see ThreadPoolQueue class below)
  private static final RejectedExecutionHandler QUEUE_EXECUTION_HANDLER = 
(r, e) -> {
 if (!e.isShutdown()) {
e.getQueue().add(r);
 }
  };
   
  // A specialized LinkedBlockingQueue that takes new elements by calling 
add() but not offer()
  // This is to force the ThreadPoolExecutor to always create new threads 
and never queue
  private static class ThreadPoolQueue extends 
LinkedTransferQueue {
   
 @Override
 public boolean offer(Runnable runnable) {
return tryTransfer(runnable);
 }
   
 @Override
 public boolean add(Runnable runnable) {
return super.offer( runnable );
 }
  }
   
  public ActiveMQThreadPoolExecutor(int coreSize, int maxSize, long keep, 
TimeUnit keepUnits, ThreadFactory factory) {
 super( coreSize, maxSize, keep, keepUnits, new ThreadPoolQueue(), 
factory, QUEUE_EXECUTION_HANDLER );
  }
   }
   
   
   ```


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services