geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From johndam...@apache.org
Subject geronimo-safeguard git commit: GERONIMO-6583 - Adding bulkhead support.
Date Sat, 28 Oct 2017 04:12:44 GMT
Repository: geronimo-safeguard
Updated Branches:
  refs/heads/master 75d1acdf9 -> 964551d17


GERONIMO-6583 - Adding bulkhead support.

With this change all duration checking is done in nanos (this is only checked in the bulkhead part of the TCK for some reason)


Project: http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/repo
Commit: http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/commit/964551d1
Tree: http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/tree/964551d1
Diff: http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/diff/964551d1

Branch: refs/heads/master
Commit: 964551d17f1ff3b1743c41d7cc629b8397f56557
Parents: 75d1acd
Author: John D. Ament <johndament@apache.org>
Authored: Sat Oct 28 00:12:39 2017 -0400
Committer: John D. Ament <johndament@apache.org>
Committed: Sat Oct 28 00:12:39 2017 -0400

----------------------------------------------------------------------
 .../apache/safeguard/api/ExecutionManager.java  |   3 +
 .../apache/safeguard/api/bulkhead/Bulkhead.java |  32 ++++++
 .../safeguard/api/bulkhead/BulkheadBuilder.java |  30 +++++
 .../api/bulkhead/BulkheadDefinition.java        |  28 +++++
 .../safeguard/api/bulkhead/BulkheadManager.java |  25 +++++
 .../safeguard/exception/AsyncException.java     |   2 +-
 .../safeguard/exception/SafeguardException.java |  40 +++++++
 .../impl/FailsafeExecutionManager.java          |  12 +-
 .../impl/bulkhead/BulkheadBuilderImpl.java      |  62 +++++++++++
 .../impl/bulkhead/BulkheadDefinitionImpl.java   |  49 +++++++++
 .../impl/bulkhead/BulkheadManagerImpl.java      |  51 +++++++++
 .../impl/bulkhead/SemaphoreBulkhead.java        |  65 +++++++++++
 .../impl/bulkhead/ThreadPoolBulkhead.java       | 110 +++++++++++++++++++
 .../safeguard/impl/cdi/SafeguardExtension.java  |   4 +-
 .../impl/cdi/SafeguardInterceptor.java          |   6 +-
 .../FailsafeCircuitBreakerBuilder.java          |   2 +-
 .../AsyncTimeoutExecutionPlan.java              |   2 +-
 .../executionPlans/BulkheadExecutionPlan.java   |  50 +++++++++
 .../executionPlans/ExecutionPlanFactory.java    |  70 +++++++++---
 .../executionPlans/TimeoutWrappedCallable.java  |   2 +-
 .../impl/retry/FailsafeRetryBuilder.java        |   6 +-
 safeguard-tck-tests/pom.xml                     |   5 -
 .../safeguard/ft/tck/ArchiveAppender.java       |   2 +-
 23 files changed, 625 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/blob/964551d1/safeguard-api/src/main/java/org/apache/safeguard/api/ExecutionManager.java
----------------------------------------------------------------------
diff --git a/safeguard-api/src/main/java/org/apache/safeguard/api/ExecutionManager.java b/safeguard-api/src/main/java/org/apache/safeguard/api/ExecutionManager.java
index 86a69c8..bcd372d 100644
--- a/safeguard-api/src/main/java/org/apache/safeguard/api/ExecutionManager.java
+++ b/safeguard-api/src/main/java/org/apache/safeguard/api/ExecutionManager.java
@@ -19,6 +19,7 @@
 
 package org.apache.safeguard.api;
 
+import org.apache.safeguard.api.bulkhead.BulkheadManager;
 import org.apache.safeguard.api.circuitbreaker.CircuitBreakerManager;
 import org.apache.safeguard.api.retry.RetryManager;
 
@@ -30,4 +31,6 @@ public interface ExecutionManager {
     CircuitBreakerManager getCircuitBreakerManager();
 
     RetryManager getRetryManager();
+
+    BulkheadManager getBulkheadManager();
 }

http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/blob/964551d1/safeguard-api/src/main/java/org/apache/safeguard/api/bulkhead/Bulkhead.java
----------------------------------------------------------------------
diff --git a/safeguard-api/src/main/java/org/apache/safeguard/api/bulkhead/Bulkhead.java b/safeguard-api/src/main/java/org/apache/safeguard/api/bulkhead/Bulkhead.java
new file mode 100644
index 0000000..5675a6d
--- /dev/null
+++ b/safeguard-api/src/main/java/org/apache/safeguard/api/bulkhead/Bulkhead.java
@@ -0,0 +1,32 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.safeguard.api.bulkhead;
+
+import java.util.concurrent.Callable;
+
+public interface Bulkhead {
+    BulkheadDefinition getBulkheadDefinition();
+
+    int getCurrentQueueDepth();
+
+    int getCurrentExecutions();
+
+    <T> T execute(Callable<T> callable);
+}

http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/blob/964551d1/safeguard-api/src/main/java/org/apache/safeguard/api/bulkhead/BulkheadBuilder.java
----------------------------------------------------------------------
diff --git a/safeguard-api/src/main/java/org/apache/safeguard/api/bulkhead/BulkheadBuilder.java b/safeguard-api/src/main/java/org/apache/safeguard/api/bulkhead/BulkheadBuilder.java
new file mode 100644
index 0000000..19f7bdc
--- /dev/null
+++ b/safeguard-api/src/main/java/org/apache/safeguard/api/bulkhead/BulkheadBuilder.java
@@ -0,0 +1,30 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.safeguard.api.bulkhead;
+
+public interface BulkheadBuilder {
+    BulkheadBuilder withMaxConcurrency(int maxConcurrency);
+
+    BulkheadBuilder withMaxWaiting(int overflowCapacity);
+
+    BulkheadBuilder asynchronous();
+
+    BulkheadDefinition build();
+}

http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/blob/964551d1/safeguard-api/src/main/java/org/apache/safeguard/api/bulkhead/BulkheadDefinition.java
----------------------------------------------------------------------
diff --git a/safeguard-api/src/main/java/org/apache/safeguard/api/bulkhead/BulkheadDefinition.java b/safeguard-api/src/main/java/org/apache/safeguard/api/bulkhead/BulkheadDefinition.java
new file mode 100644
index 0000000..bb7e942
--- /dev/null
+++ b/safeguard-api/src/main/java/org/apache/safeguard/api/bulkhead/BulkheadDefinition.java
@@ -0,0 +1,28 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.safeguard.api.bulkhead;
+
+public interface BulkheadDefinition {
+    int getMaxConcurrentExecutions();
+
+    int getMaxWaitingExecutions();
+
+    boolean isAsynchronous();
+}

http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/blob/964551d1/safeguard-api/src/main/java/org/apache/safeguard/api/bulkhead/BulkheadManager.java
----------------------------------------------------------------------
diff --git a/safeguard-api/src/main/java/org/apache/safeguard/api/bulkhead/BulkheadManager.java b/safeguard-api/src/main/java/org/apache/safeguard/api/bulkhead/BulkheadManager.java
new file mode 100644
index 0000000..3b155ad
--- /dev/null
+++ b/safeguard-api/src/main/java/org/apache/safeguard/api/bulkhead/BulkheadManager.java
@@ -0,0 +1,25 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.safeguard.api.bulkhead;
+
+public interface BulkheadManager {
+    BulkheadBuilder newBulkheadBuilder(String name);
+    Bulkhead getBulkhead(String name);
+}

http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/blob/964551d1/safeguard-api/src/main/java/org/apache/safeguard/exception/AsyncException.java
----------------------------------------------------------------------
diff --git a/safeguard-api/src/main/java/org/apache/safeguard/exception/AsyncException.java b/safeguard-api/src/main/java/org/apache/safeguard/exception/AsyncException.java
index 08be3a8..f21cf28 100644
--- a/safeguard-api/src/main/java/org/apache/safeguard/exception/AsyncException.java
+++ b/safeguard-api/src/main/java/org/apache/safeguard/exception/AsyncException.java
@@ -19,7 +19,7 @@
 
 package org.apache.safeguard.exception;
 
-public class AsyncException extends RuntimeException {
+public class AsyncException extends SafeguardException {
     public AsyncException(Exception e) {
         super(e);
     }

http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/blob/964551d1/safeguard-api/src/main/java/org/apache/safeguard/exception/SafeguardException.java
----------------------------------------------------------------------
diff --git a/safeguard-api/src/main/java/org/apache/safeguard/exception/SafeguardException.java b/safeguard-api/src/main/java/org/apache/safeguard/exception/SafeguardException.java
new file mode 100644
index 0000000..a8991e1
--- /dev/null
+++ b/safeguard-api/src/main/java/org/apache/safeguard/exception/SafeguardException.java
@@ -0,0 +1,40 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.safeguard.exception;
+
+import org.eclipse.microprofile.faulttolerance.exceptions.FaultToleranceException;
+
+public class SafeguardException extends FaultToleranceException{
+    public SafeguardException() {
+    }
+
+    public SafeguardException(String message) {
+        super(message);
+    }
+
+    public SafeguardException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public SafeguardException(Throwable cause) {
+        super(cause);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/blob/964551d1/safeguard-impl/src/main/java/org/apache/safeguard/impl/FailsafeExecutionManager.java
----------------------------------------------------------------------
diff --git a/safeguard-impl/src/main/java/org/apache/safeguard/impl/FailsafeExecutionManager.java b/safeguard-impl/src/main/java/org/apache/safeguard/impl/FailsafeExecutionManager.java
index 4424d06..eab9231 100644
--- a/safeguard-impl/src/main/java/org/apache/safeguard/impl/FailsafeExecutionManager.java
+++ b/safeguard-impl/src/main/java/org/apache/safeguard/impl/FailsafeExecutionManager.java
@@ -20,6 +20,8 @@
 package org.apache.safeguard.impl;
 
 import org.apache.safeguard.api.ExecutionManager;
+import org.apache.safeguard.api.bulkhead.BulkheadManager;
+import org.apache.safeguard.impl.bulkhead.BulkheadManagerImpl;
 import org.apache.safeguard.impl.circuitbreaker.FailsafeCircuitBreakerManager;
 import org.apache.safeguard.impl.executionPlans.ExecutionPlanFactory;
 import org.apache.safeguard.impl.retry.FailsafeRetryManager;
@@ -32,6 +34,7 @@ import java.util.concurrent.Callable;
 
 @Vetoed
 public class FailsafeExecutionManager implements ExecutionManager {
+    private BulkheadManagerImpl bulkheadManager;
     private FailsafeCircuitBreakerManager circuitBreakerManager;
     private FailsafeRetryManager retryManager;
     private ExecutionPlanFactory executionPlanFactory;
@@ -39,7 +42,9 @@ public class FailsafeExecutionManager implements ExecutionManager {
     public FailsafeExecutionManager() {
         this.circuitBreakerManager = new FailsafeCircuitBreakerManager();
         this.retryManager = new FailsafeRetryManager();
-        this.executionPlanFactory = new ExecutionPlanFactory(this.circuitBreakerManager, this.retryManager);
+        this.bulkheadManager = new BulkheadManagerImpl();
+        this.executionPlanFactory = new ExecutionPlanFactory(this.circuitBreakerManager, this.retryManager,
+                this.bulkheadManager);
     }
 
     public Object execute(InvocationContext invocationContext) {
@@ -74,4 +79,9 @@ public class FailsafeExecutionManager implements ExecutionManager {
         return retryManager;
     }
 
+    @Override
+    public BulkheadManager getBulkheadManager() {
+        return bulkheadManager;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/blob/964551d1/safeguard-impl/src/main/java/org/apache/safeguard/impl/bulkhead/BulkheadBuilderImpl.java
----------------------------------------------------------------------
diff --git a/safeguard-impl/src/main/java/org/apache/safeguard/impl/bulkhead/BulkheadBuilderImpl.java b/safeguard-impl/src/main/java/org/apache/safeguard/impl/bulkhead/BulkheadBuilderImpl.java
new file mode 100644
index 0000000..825c576
--- /dev/null
+++ b/safeguard-impl/src/main/java/org/apache/safeguard/impl/bulkhead/BulkheadBuilderImpl.java
@@ -0,0 +1,62 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.safeguard.impl.bulkhead;
+
+import org.apache.safeguard.api.bulkhead.BulkheadBuilder;
+import org.apache.safeguard.api.bulkhead.BulkheadDefinition;
+
+public class BulkheadBuilderImpl implements BulkheadBuilder{
+    private final String name;
+    private final BulkheadManagerImpl bulkheadManager;
+    private int maxWaitingExecutions;
+    private int maxConcurrentExecutions;
+    private boolean asynchronous = false;
+
+    BulkheadBuilderImpl(String name, BulkheadManagerImpl bulkheadManager) {
+        this.name = name;
+        this.bulkheadManager = bulkheadManager;
+    }
+
+    @Override
+    public BulkheadBuilder withMaxConcurrency(int maxConcurrency) {
+        this.maxConcurrentExecutions = maxConcurrency;
+        return this;
+    }
+
+    @Override
+    public BulkheadBuilder withMaxWaiting(int overflowCapacity) {
+        this.maxWaitingExecutions = overflowCapacity;
+        return this;
+    }
+
+    @Override
+    public BulkheadBuilder asynchronous() {
+        this.asynchronous = true;
+        return this;
+    }
+
+    @Override
+    public BulkheadDefinition build() {
+        BulkheadDefinitionImpl definition = new BulkheadDefinitionImpl(maxConcurrentExecutions, maxWaitingExecutions, asynchronous);
+        bulkheadManager.register(name, definition);
+        return definition;
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/blob/964551d1/safeguard-impl/src/main/java/org/apache/safeguard/impl/bulkhead/BulkheadDefinitionImpl.java
----------------------------------------------------------------------
diff --git a/safeguard-impl/src/main/java/org/apache/safeguard/impl/bulkhead/BulkheadDefinitionImpl.java b/safeguard-impl/src/main/java/org/apache/safeguard/impl/bulkhead/BulkheadDefinitionImpl.java
new file mode 100644
index 0000000..7c30c13
--- /dev/null
+++ b/safeguard-impl/src/main/java/org/apache/safeguard/impl/bulkhead/BulkheadDefinitionImpl.java
@@ -0,0 +1,49 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.safeguard.impl.bulkhead;
+
+import org.apache.safeguard.api.bulkhead.BulkheadDefinition;
+
+public class BulkheadDefinitionImpl implements BulkheadDefinition{
+    private final int maxConcurrentExecutions;
+    private final int maxWaitingExecutions;
+    private final boolean asynchronous;
+
+    public BulkheadDefinitionImpl(int maxConcurrentExecutions, int maxWaitingExecutions, boolean asynchronous) {
+        this.maxConcurrentExecutions = maxConcurrentExecutions;
+        this.maxWaitingExecutions = maxWaitingExecutions;
+        this.asynchronous = asynchronous;
+    }
+
+    @Override
+    public int getMaxConcurrentExecutions() {
+        return maxConcurrentExecutions;
+    }
+
+    @Override
+    public int getMaxWaitingExecutions() {
+        return maxWaitingExecutions;
+    }
+
+    @Override
+    public boolean isAsynchronous() {
+        return asynchronous;
+    }
+}

http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/blob/964551d1/safeguard-impl/src/main/java/org/apache/safeguard/impl/bulkhead/BulkheadManagerImpl.java
----------------------------------------------------------------------
diff --git a/safeguard-impl/src/main/java/org/apache/safeguard/impl/bulkhead/BulkheadManagerImpl.java b/safeguard-impl/src/main/java/org/apache/safeguard/impl/bulkhead/BulkheadManagerImpl.java
new file mode 100644
index 0000000..9794bd7
--- /dev/null
+++ b/safeguard-impl/src/main/java/org/apache/safeguard/impl/bulkhead/BulkheadManagerImpl.java
@@ -0,0 +1,51 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.safeguard.impl.bulkhead;
+
+import org.apache.safeguard.api.bulkhead.Bulkhead;
+import org.apache.safeguard.api.bulkhead.BulkheadBuilder;
+import org.apache.safeguard.api.bulkhead.BulkheadManager;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class BulkheadManagerImpl implements BulkheadManager{
+    private Map<String, Bulkhead> bulkheads = new HashMap<>();;
+    @Override
+    public BulkheadBuilder newBulkheadBuilder(String name) {
+        return new BulkheadBuilderImpl(name, this);
+    }
+
+    @Override
+    public Bulkhead getBulkhead(String name) {
+        return bulkheads.get(name);
+    }
+
+    void register(String name, BulkheadDefinitionImpl bulkheadDefinition) {
+        Bulkhead bulkhead;
+        if (bulkheadDefinition.isAsynchronous()) {
+            bulkhead = new ThreadPoolBulkhead(bulkheadDefinition);
+        }
+        else {
+            bulkhead = new SemaphoreBulkhead(bulkheadDefinition);
+        }
+        bulkheads.put(name, bulkhead);
+    }
+}

http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/blob/964551d1/safeguard-impl/src/main/java/org/apache/safeguard/impl/bulkhead/SemaphoreBulkhead.java
----------------------------------------------------------------------
diff --git a/safeguard-impl/src/main/java/org/apache/safeguard/impl/bulkhead/SemaphoreBulkhead.java b/safeguard-impl/src/main/java/org/apache/safeguard/impl/bulkhead/SemaphoreBulkhead.java
new file mode 100644
index 0000000..83c940c
--- /dev/null
+++ b/safeguard-impl/src/main/java/org/apache/safeguard/impl/bulkhead/SemaphoreBulkhead.java
@@ -0,0 +1,65 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.safeguard.impl.bulkhead;
+
+import org.apache.safeguard.api.bulkhead.Bulkhead;
+import org.apache.safeguard.api.bulkhead.BulkheadDefinition;
+import org.apache.safeguard.exception.SafeguardException;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.Semaphore;
+
+public class SemaphoreBulkhead implements Bulkhead {
+    private final Semaphore semaphore;
+    private final BulkheadDefinition bulkheadDefinition;
+
+    public SemaphoreBulkhead(BulkheadDefinition bulkheadDefinition) {
+        this.semaphore = new Semaphore(bulkheadDefinition.getMaxConcurrentExecutions(), true);
+        this.bulkheadDefinition = bulkheadDefinition;
+    }
+
+    @Override
+    public BulkheadDefinition getBulkheadDefinition() {
+        return this.bulkheadDefinition;
+    }
+
+    @Override
+    public int getCurrentQueueDepth() {
+        return semaphore.getQueueLength();
+    }
+
+    @Override
+    public int getCurrentExecutions() {
+        return bulkheadDefinition.getMaxConcurrentExecutions() - semaphore.availablePermits();
+    }
+
+    @Override
+    public <T> T execute(Callable<T> callable) {
+        try {
+            String name = Thread.currentThread().getName();
+            this.semaphore.acquire();
+            return callable.call();
+        } catch (Exception e) {
+            throw new SafeguardException(e);
+        } finally {
+            this.semaphore.release();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/blob/964551d1/safeguard-impl/src/main/java/org/apache/safeguard/impl/bulkhead/ThreadPoolBulkhead.java
----------------------------------------------------------------------
diff --git a/safeguard-impl/src/main/java/org/apache/safeguard/impl/bulkhead/ThreadPoolBulkhead.java b/safeguard-impl/src/main/java/org/apache/safeguard/impl/bulkhead/ThreadPoolBulkhead.java
new file mode 100644
index 0000000..1372175
--- /dev/null
+++ b/safeguard-impl/src/main/java/org/apache/safeguard/impl/bulkhead/ThreadPoolBulkhead.java
@@ -0,0 +1,110 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.safeguard.impl.bulkhead;
+
+import org.apache.safeguard.api.bulkhead.Bulkhead;
+import org.apache.safeguard.api.bulkhead.BulkheadDefinition;
+import org.eclipse.microprofile.faulttolerance.exceptions.BulkheadException;
+
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.RejectedExecutionException;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+public class ThreadPoolBulkhead implements Bulkhead {
+    private final BulkheadDefinition bulkheadDefinition;
+    private final BlockingQueue<Runnable> workQueue;
+    private final ThreadPoolExecutor threadPoolExecutor;
+
+    public ThreadPoolBulkhead(BulkheadDefinition bulkheadDefinition) {
+        this.bulkheadDefinition = bulkheadDefinition;
+        this.workQueue = new LinkedBlockingQueue<>(bulkheadDefinition.getMaxWaitingExecutions());
+        this.threadPoolExecutor = new ThreadPoolExecutor(
+                bulkheadDefinition.getMaxConcurrentExecutions(),
+                bulkheadDefinition.getMaxConcurrentExecutions(),
+                0L, TimeUnit.MILLISECONDS,
+                workQueue,
+                Executors.defaultThreadFactory());
+    }
+
+    @Override
+    public BulkheadDefinition getBulkheadDefinition() {
+        return bulkheadDefinition;
+    }
+
+    @Override
+    public int getCurrentQueueDepth() {
+        return workQueue.size();
+    }
+
+    @Override
+    public int getCurrentExecutions() {
+        return threadPoolExecutor.getActiveCount();
+    }
+
+    @Override
+    public <T> T execute(Callable<T> callable) {
+        try {
+            return (T)new DelegatingFuture<T>((Future<Future<T>>) threadPoolExecutor.submit(callable));
+        } catch (RejectedExecutionException e) {
+            throw new BulkheadException(e);
+        }
+    }
+
+    private class DelegatingFuture<R> implements Future<R>{
+
+        private final Future<Future<R>> child;
+
+        public DelegatingFuture(Future<Future<R>> child) {
+            this.child = child;
+        }
+
+        @Override
+        public boolean cancel(boolean mayInterruptIfRunning) {
+            return child.cancel(mayInterruptIfRunning);
+        }
+
+        @Override
+        public boolean isCancelled() {
+            return child.isCancelled();
+        }
+
+        @Override
+        public boolean isDone() {
+            return child.isDone();
+        }
+
+        @Override
+        public R get() throws InterruptedException, ExecutionException {
+            return child.get().get();
+        }
+
+        @Override
+        public R get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
+            return child.get().get(timeout, unit);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/blob/964551d1/safeguard-impl/src/main/java/org/apache/safeguard/impl/cdi/SafeguardExtension.java
----------------------------------------------------------------------
diff --git a/safeguard-impl/src/main/java/org/apache/safeguard/impl/cdi/SafeguardExtension.java b/safeguard-impl/src/main/java/org/apache/safeguard/impl/cdi/SafeguardExtension.java
index c826255..c532914 100644
--- a/safeguard-impl/src/main/java/org/apache/safeguard/impl/cdi/SafeguardExtension.java
+++ b/safeguard-impl/src/main/java/org/apache/safeguard/impl/cdi/SafeguardExtension.java
@@ -20,6 +20,7 @@
 package org.apache.safeguard.impl.cdi;
 
 import org.apache.safeguard.api.SafeguardEnabled;
+import org.eclipse.microprofile.faulttolerance.Bulkhead;
 import org.eclipse.microprofile.faulttolerance.CircuitBreaker;
 import org.eclipse.microprofile.faulttolerance.Retry;
 import org.eclipse.microprofile.faulttolerance.Timeout;
@@ -41,7 +42,8 @@ import java.util.Set;
 import static org.apache.safeguard.api.SafeguardEnabled.INSTANCE;
 
 public class SafeguardExtension implements Extension {
-    public void findFaultTolerantBeans(@Observes @WithAnnotations({Retry.class, CircuitBreaker.class, Timeout.class})
+    public void findFaultTolerantBeans(@Observes @WithAnnotations({Retry.class, CircuitBreaker.class, Timeout.class,
+            Bulkhead.class})
                                                ProcessAnnotatedType<?> pat) {
         if (!pat.getAnnotatedType().isAnnotationPresent(SafeguardEnabled.class)) {
             pat.setAnnotatedType(new SafeguardAnnotatedTypeWrapper(pat.getAnnotatedType()));

http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/blob/964551d1/safeguard-impl/src/main/java/org/apache/safeguard/impl/cdi/SafeguardInterceptor.java
----------------------------------------------------------------------
diff --git a/safeguard-impl/src/main/java/org/apache/safeguard/impl/cdi/SafeguardInterceptor.java b/safeguard-impl/src/main/java/org/apache/safeguard/impl/cdi/SafeguardInterceptor.java
index d3bd604..4b986e9 100644
--- a/safeguard-impl/src/main/java/org/apache/safeguard/impl/cdi/SafeguardInterceptor.java
+++ b/safeguard-impl/src/main/java/org/apache/safeguard/impl/cdi/SafeguardInterceptor.java
@@ -22,7 +22,9 @@ package org.apache.safeguard.impl.cdi;
 import org.apache.safeguard.api.SafeguardEnabled;
 import org.apache.safeguard.impl.FailsafeExecutionManager;
 import org.apache.safeguard.impl.util.AnnotationUtil;
+import org.eclipse.microprofile.faulttolerance.Bulkhead;
 import org.eclipse.microprofile.faulttolerance.CircuitBreaker;
+import org.eclipse.microprofile.faulttolerance.Fallback;
 import org.eclipse.microprofile.faulttolerance.Retry;
 import org.eclipse.microprofile.faulttolerance.Timeout;
 
@@ -55,6 +57,8 @@ public class SafeguardInterceptor {
     private boolean isMethodSafeguarded(Method method) {
         return AnnotationUtil.getAnnotation(method, Retry.class) != null ||
                 AnnotationUtil.getAnnotation(method, CircuitBreaker.class) != null ||
-                AnnotationUtil.getAnnotation(method, Timeout.class) != null;
+                AnnotationUtil.getAnnotation(method, Timeout.class) != null ||
+                AnnotationUtil.getAnnotation(method, Fallback.class) != null ||
+                AnnotationUtil.getAnnotation(method, Bulkhead.class) != null;
     }
 }

http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/blob/964551d1/safeguard-impl/src/main/java/org/apache/safeguard/impl/circuitbreaker/FailsafeCircuitBreakerBuilder.java
----------------------------------------------------------------------
diff --git a/safeguard-impl/src/main/java/org/apache/safeguard/impl/circuitbreaker/FailsafeCircuitBreakerBuilder.java b/safeguard-impl/src/main/java/org/apache/safeguard/impl/circuitbreaker/FailsafeCircuitBreakerBuilder.java
index 1431a35..7fa71f1 100644
--- a/safeguard-impl/src/main/java/org/apache/safeguard/impl/circuitbreaker/FailsafeCircuitBreakerBuilder.java
+++ b/safeguard-impl/src/main/java/org/apache/safeguard/impl/circuitbreaker/FailsafeCircuitBreakerBuilder.java
@@ -44,7 +44,7 @@ public class FailsafeCircuitBreakerBuilder implements CircuitBreakerBuilder {
 
     @Override
     public FailsafeCircuitBreakerBuilder withDelay(Duration delay) {
-        circuitBreaker.withDelay(delay.toMillis(), TimeUnit.MILLISECONDS);
+        circuitBreaker.withDelay(delay.toNanos(), TimeUnit.NANOSECONDS);
         return this;
     }
 

http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/blob/964551d1/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/AsyncTimeoutExecutionPlan.java
----------------------------------------------------------------------
diff --git a/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/AsyncTimeoutExecutionPlan.java b/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/AsyncTimeoutExecutionPlan.java
index 97c76b3..1c3cd50 100644
--- a/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/AsyncTimeoutExecutionPlan.java
+++ b/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/AsyncTimeoutExecutionPlan.java
@@ -41,7 +41,7 @@ class AsyncTimeoutExecutionPlan implements ExecutionPlan {
     public <T> T execute(Callable<T> callable, InvocationContext invocationContext) {
         Future<T> future = executorService.submit(callable);
         try {
-            return future.get(timeout.toMillis(), TimeUnit.MILLISECONDS);
+            return future.get(timeout.toNanos(), TimeUnit.NANOSECONDS);
         } catch (ExecutionException e) {
             if(e.getCause() != null && e.getCause() instanceof RuntimeException) {
                 throw (RuntimeException)e.getCause();

http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/blob/964551d1/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/BulkheadExecutionPlan.java
----------------------------------------------------------------------
diff --git a/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/BulkheadExecutionPlan.java b/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/BulkheadExecutionPlan.java
new file mode 100644
index 0000000..6553636
--- /dev/null
+++ b/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/BulkheadExecutionPlan.java
@@ -0,0 +1,50 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.safeguard.impl.executionPlans;
+
+import org.apache.safeguard.api.bulkhead.Bulkhead;
+import org.apache.safeguard.exception.SafeguardException;
+
+import javax.interceptor.InvocationContext;
+import java.util.concurrent.Callable;
+
+public class BulkheadExecutionPlan implements ExecutionPlan{
+    private final Bulkhead bulkhead;
+    private ExecutionPlan child;
+
+    BulkheadExecutionPlan(Bulkhead bulkhead) {
+        this.bulkhead = bulkhead;
+    }
+
+    void setChild(ExecutionPlan child) {
+        this.child = child;
+    }
+
+    @Override
+    public <T> T execute(Callable<T> callable, InvocationContext invocationContext) {
+        if(bulkhead != null && child != null) {
+            return child.execute(() -> bulkhead.execute(callable), invocationContext);
+        } else if(child != null) {
+            return child.execute(callable, invocationContext);
+        } else {
+            throw new SafeguardException("Neither bulkhead nor child specified");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/blob/964551d1/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/ExecutionPlanFactory.java
----------------------------------------------------------------------
diff --git a/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/ExecutionPlanFactory.java b/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/ExecutionPlanFactory.java
index 2d829eb..c6515d1 100644
--- a/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/ExecutionPlanFactory.java
+++ b/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/ExecutionPlanFactory.java
@@ -19,6 +19,9 @@
 
 package org.apache.safeguard.impl.executionPlans;
 
+import org.apache.safeguard.api.bulkhead.Bulkhead;
+import org.apache.safeguard.api.bulkhead.BulkheadBuilder;
+import org.apache.safeguard.api.bulkhead.BulkheadManager;
 import org.apache.safeguard.impl.circuitbreaker.FailsafeCircuitBreaker;
 import org.apache.safeguard.impl.circuitbreaker.FailsafeCircuitBreakerBuilder;
 import org.apache.safeguard.impl.circuitbreaker.FailsafeCircuitBreakerManager;
@@ -26,7 +29,6 @@ import org.apache.safeguard.impl.fallback.FallbackRunner;
 import org.apache.safeguard.impl.retry.FailsafeRetryBuilder;
 import org.apache.safeguard.impl.retry.FailsafeRetryDefinition;
 import org.apache.safeguard.impl.retry.FailsafeRetryManager;
-import org.apache.safeguard.impl.util.AnnotationUtil;
 import org.apache.safeguard.impl.util.NamingUtil;
 import org.eclipse.microprofile.config.Config;
 import org.eclipse.microprofile.config.ConfigProvider;
@@ -38,23 +40,28 @@ import org.eclipse.microprofile.faulttolerance.Timeout;
 
 import java.lang.reflect.Method;
 import java.time.Duration;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.Executors;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import static org.apache.safeguard.impl.executionPlans.MicroprofileAnnotationMapper.mapCircuitBreaker;
 import static org.apache.safeguard.impl.executionPlans.MicroprofileAnnotationMapper.mapRetry;
+import static org.apache.safeguard.impl.util.AnnotationUtil.getAnnotation;
 
 public class ExecutionPlanFactory {
     private final FailsafeCircuitBreakerManager circuitBreakerManager;
     private final FailsafeRetryManager retryManager;
-    private Map<String, ExecutionPlan> executionPlanMap = new HashMap<>();
+    private final BulkheadManager bulkheadManager;
+    private ConcurrentMap<String, ExecutionPlan> executionPlanMap = new ConcurrentHashMap<>();
     private final boolean enableAllMicroProfileFeatures;
 
-    public ExecutionPlanFactory(FailsafeCircuitBreakerManager circuitBreakerManager, FailsafeRetryManager retryManager) {
+    public ExecutionPlanFactory(FailsafeCircuitBreakerManager circuitBreakerManager,
+                                FailsafeRetryManager retryManager,
+                                BulkheadManager bulkheadManager) {
         this.circuitBreakerManager = circuitBreakerManager;
         this.retryManager = retryManager;
+        this.bulkheadManager = bulkheadManager;
         this.enableAllMicroProfileFeatures = this.enableNonFallbacksForMicroProfile();
     }
 
@@ -73,34 +80,44 @@ public class ExecutionPlanFactory {
     public ExecutionPlan locateExecutionPlan(Method method) {
         final String name = NamingUtil.createName(method);
         return executionPlanMap.computeIfAbsent(name, key -> {
-            FailsafeCircuitBreaker circuitBreaker = circuitBreakerManager.getCircuitBreaker(key);
+            FailsafeCircuitBreaker circuitBreaker = circuitBreakerManager.getCircuitBreaker(name);
             if (circuitBreaker == null) {
                 circuitBreaker = createCBDefinition(name, method);
             }
-            FailsafeRetryDefinition retryDefinition = retryManager.getRetryDefinition(key);
+            FailsafeRetryDefinition retryDefinition = retryManager.getRetryDefinition(name);
             if (retryDefinition == null) {
                 retryDefinition = createDefinition(name, method);
             }
+            Bulkhead bulkhead = bulkheadManager.getBulkhead(name);
+            if (bulkhead == null) {
+                bulkhead = createBulkhead(name, method);
+            }
             boolean isAsync = isAsync(method);
             Duration timeout = readTimeout(method);
             FallbackRunner fallbackRunner = this.createFallback(method);
             if(this.enableAllMicroProfileFeatures) {
+                BulkheadExecutionPlan parent = new BulkheadExecutionPlan(bulkhead);
                 if (circuitBreaker == null && retryDefinition == null && isAsync) {
                     if (timeout == null) {
-                        return new AsyncOnlyExecutionPlan(null);
+                        parent.setChild(new AsyncOnlyExecutionPlan(null));
                     } else {
-                        return new AsyncTimeoutExecutionPlan(timeout, Executors.newFixedThreadPool(5));
+                        parent.setChild(new AsyncTimeoutExecutionPlan(timeout, Executors.newFixedThreadPool(5)));
                     }
                 } else if (circuitBreaker == null && retryDefinition == null && timeout != null) {
                     // then its just timeout
-                    return new AsyncTimeoutExecutionPlan(timeout, Executors.newFixedThreadPool(5));
+                    parent.setChild(new AsyncTimeoutExecutionPlan(timeout, Executors.newFixedThreadPool(5)));
                 } else {
                     if (isAsync || timeout != null) {
-                        return new AsyncFailsafeExecutionPlan(retryDefinition, circuitBreaker, fallbackRunner, Executors.newScheduledThreadPool(5), timeout);
+                        parent.setChild(new AsyncFailsafeExecutionPlan(retryDefinition, circuitBreaker, fallbackRunner, Executors.newScheduledThreadPool(5), timeout));;
+                    } else if(circuitBreaker == null && retryDefinition == null && fallbackRunner == null) {
+                        parent.setChild(new BasicExecutionPlan());
+                    } else if(circuitBreaker == null && retryDefinition == null) {
+                        parent.setChild(new FallbackOnlyExecutionPlan(fallbackRunner));
                     } else {
-                        return new SyncFailsafeExecutionPlan(retryDefinition, circuitBreaker, fallbackRunner);
+                        parent.setChild(new SyncFailsafeExecutionPlan(retryDefinition, circuitBreaker, fallbackRunner));
                     }
                 }
+                return parent;
             }else {
                 if(fallbackRunner == null) {
                     return new BasicExecutionPlan();
@@ -109,6 +126,7 @@ public class ExecutionPlanFactory {
                     return new FallbackOnlyExecutionPlan(fallbackRunner);
                 }
             }
+
         });
     }
 
@@ -126,7 +144,7 @@ public class ExecutionPlanFactory {
     }
 
     private FailsafeRetryDefinition createDefinition(String name, Method method) {
-        Retry retry = AnnotationUtil.getAnnotation(method, Retry.class);
+        Retry retry = getAnnotation(method, Retry.class);
         if (retry == null) {
             return null;
         }
@@ -135,7 +153,7 @@ public class ExecutionPlanFactory {
     }
 
     private FailsafeCircuitBreaker createCBDefinition(String name, Method method) {
-        CircuitBreaker circuitBreaker = AnnotationUtil.getAnnotation(method, CircuitBreaker.class);
+        CircuitBreaker circuitBreaker = getAnnotation(method, CircuitBreaker.class);
         if (circuitBreaker == null) {
             return null;
         }
@@ -143,8 +161,25 @@ public class ExecutionPlanFactory {
         return new FailsafeCircuitBreaker(mapCircuitBreaker(circuitBreaker, circuitBreakerBuilder));
     }
 
+    private Bulkhead createBulkhead(String name, Method method) {
+        org.eclipse.microprofile.faulttolerance.Bulkhead annotation = getAnnotation(method,
+                org.eclipse.microprofile.faulttolerance.Bulkhead.class);
+        if (annotation == null) {
+            return null;
+        }
+        boolean async = getAnnotation(method, Asynchronous.class) != null;
+        BulkheadBuilder bulkheadBuilder = this.bulkheadManager.newBulkheadBuilder(name)
+                .withMaxWaiting(annotation.waitingTaskQueue())
+                .withMaxConcurrency(annotation.value());
+        if(async) {
+            bulkheadBuilder.asynchronous();
+        }
+        bulkheadBuilder.build();
+        return bulkheadManager.getBulkhead(name);
+    }
+
     private FallbackRunner createFallback(Method method) {
-        Fallback fallback = AnnotationUtil.getAnnotation(method, Fallback.class);
+        Fallback fallback = getAnnotation(method, Fallback.class);
         if(fallback == null) {
             return null;
         }
@@ -153,11 +188,12 @@ public class ExecutionPlanFactory {
     }
 
     private boolean isAsync(Method method) {
-        return AnnotationUtil.getAnnotation(method, Asynchronous.class) != null;
+        return getAnnotation(method, Asynchronous.class) != null &&
+                getAnnotation(method, org.eclipse.microprofile.faulttolerance.Bulkhead.class) == null;
     }
 
     private Duration readTimeout(Method method) {
-        Timeout timeout = AnnotationUtil.getAnnotation(method, Timeout.class);
+        Timeout timeout = getAnnotation(method, Timeout.class);
         if(timeout == null) {
             return null;
         }

http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/blob/964551d1/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/TimeoutWrappedCallable.java
----------------------------------------------------------------------
diff --git a/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/TimeoutWrappedCallable.java b/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/TimeoutWrappedCallable.java
index cf80558..31a9fec 100644
--- a/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/TimeoutWrappedCallable.java
+++ b/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/TimeoutWrappedCallable.java
@@ -51,7 +51,7 @@ class TimeoutWrappedCallable<T> implements Callable<T> {
             throw new CircuitBreakerOpenException();
         }
         ScheduledFuture<?> scheduledFuture = executorService.schedule(new TimerRunnable(Thread.currentThread(), this),
-                timeout.toMillis(), TimeUnit.MILLISECONDS);
+                timeout.toNanos(), TimeUnit.NANOSECONDS);
 
         T result;
         try {

http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/blob/964551d1/safeguard-impl/src/main/java/org/apache/safeguard/impl/retry/FailsafeRetryBuilder.java
----------------------------------------------------------------------
diff --git a/safeguard-impl/src/main/java/org/apache/safeguard/impl/retry/FailsafeRetryBuilder.java b/safeguard-impl/src/main/java/org/apache/safeguard/impl/retry/FailsafeRetryBuilder.java
index 2cf7f07..b6fdba7 100644
--- a/safeguard-impl/src/main/java/org/apache/safeguard/impl/retry/FailsafeRetryBuilder.java
+++ b/safeguard-impl/src/main/java/org/apache/safeguard/impl/retry/FailsafeRetryBuilder.java
@@ -50,19 +50,19 @@ public class FailsafeRetryBuilder implements RetryBuilder{
 
     @Override
     public FailsafeRetryBuilder withDelay(Duration delay) {
-        retryPolicy.withDelay(delay.toMillis(), TimeUnit.MILLISECONDS);
+        retryPolicy.withDelay(delay.toNanos(), TimeUnit.NANOSECONDS);
         return this;
     }
 
     @Override
     public FailsafeRetryBuilder withMaxDuration(Duration maxDuration) {
-        retryPolicy.withMaxDuration(maxDuration.toMillis(), TimeUnit.MILLISECONDS);
+        retryPolicy.withMaxDuration(maxDuration.toNanos(), TimeUnit.NANOSECONDS);
         return this;
     }
 
     @Override
     public FailsafeRetryBuilder withJitter(Duration jitter) {
-        retryPolicy.withJitter(jitter.toMillis(), TimeUnit.MILLISECONDS);
+        retryPolicy.withJitter(jitter.toNanos(), TimeUnit.NANOSECONDS);
         return this;
     }
 

http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/blob/964551d1/safeguard-tck-tests/pom.xml
----------------------------------------------------------------------
diff --git a/safeguard-tck-tests/pom.xml b/safeguard-tck-tests/pom.xml
index dd51f13..1ec0c6b 100644
--- a/safeguard-tck-tests/pom.xml
+++ b/safeguard-tck-tests/pom.xml
@@ -72,11 +72,6 @@
                     </dependenciesToScan>
                     <excludes>
                         <exclude>org.eclipse.microprofile.fault.tolerance.tck.ConfigTest</exclude>
-                        <exclude>org.eclipse.microprofile.fault.tolerance.tck.bulkhead.BulkheadAsynchRetryTest</exclude>
-                        <exclude>org.eclipse.microprofile.fault.tolerance.tck.bulkhead.BulkheadAsynchTest</exclude>
-                        <exclude>org.eclipse.microprofile.fault.tolerance.tck.bulkhead.BulkheadFutureTest</exclude>
-                        <exclude>org.eclipse.microprofile.fault.tolerance.tck.bulkhead.BulkheadSynchRetryTest</exclude>
-                        <exclude>org.eclipse.microprofile.fault.tolerance.tck.bulkhead.BulkheadSynchTest</exclude>
                         <exclude>org.eclipse.microprofile.fault.tolerance.tck.illegalConfig.IncompatibleFallbackMethodTest</exclude>
                         <exclude>org.eclipse.microprofile.fault.tolerance.tck.illegalConfig.IncompatibleFallbackMethodWithArgsTest</exclude>
                         <exclude>org.eclipse.microprofile.fault.tolerance.tck.illegalConfig.IncompatibleFallbackTest</exclude>

http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/blob/964551d1/safeguard-tck-tests/src/test/java/org/apache/safeguard/ft/tck/ArchiveAppender.java
----------------------------------------------------------------------
diff --git a/safeguard-tck-tests/src/test/java/org/apache/safeguard/ft/tck/ArchiveAppender.java b/safeguard-tck-tests/src/test/java/org/apache/safeguard/ft/tck/ArchiveAppender.java
index afbd1dd..4a50bba 100644
--- a/safeguard-tck-tests/src/test/java/org/apache/safeguard/ft/tck/ArchiveAppender.java
+++ b/safeguard-tck-tests/src/test/java/org/apache/safeguard/ft/tck/ArchiveAppender.java
@@ -34,7 +34,7 @@ import org.jboss.shrinkwrap.api.spec.WebArchive;
 import javax.enterprise.inject.spi.Extension;
 
 public class ArchiveAppender implements ApplicationArchiveProcessor {
-    private static final StringAsset BEANS_XML = new StringAsset("<beans version=\"1.1\" bean-discovery-mode=\"annotated\"/>");
+    private static final StringAsset BEANS_XML = new StringAsset("<beans version=\"1.1\" bean-discovery-mode=\"all\"/>");
 
     @Override
     public void process(Archive<?> archive, TestClass testClass) {


Mime
View raw message