Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PAYARA-3468 MP FT 2.0 update #3911

Merged
merged 32 commits into from
May 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
9872370
PAYARA-3468 fixed: consider global override
jbee Mar 29, 2019
5c48af8
PAYARA-3468 update to API and TCK 2.0
jbee Apr 1, 2019
4f520b7
Merge branch 'master' into PAYARA-3468-MP-FT-2.0
jbee Apr 3, 2019
fdda096
PAYARA-3468 decoupling, merge to single interceptor, added policies f…
jbee Apr 8, 2019
be16c14
PAYARA-3468 TCK passes
jbee Apr 11, 2019
ef8dbdb
PAYARA-3468 TCK bulkhead, circuit breaker, config, disableEnv and fal…
jbee Apr 16, 2019
e41d816
PAYARA-3468 more TCK tests as unit tests that cannot run, more unifor…
jbee Apr 16, 2019
f13a746
PAYARA-3468 FIXED policy per target method (not only method)
jbee Apr 17, 2019
f5a20c3
PAYARA-3468 added metrics (mostly correct), fixed Future fault behaviour
jbee Apr 17, 2019
09bb6db
PAYARA-3468 metrics TCK tests pass - rename
jbee Apr 17, 2019
b7a7105
PAYARA-3468 config and metrics as service factories, extracted servic…
jbee Apr 18, 2019
e4c6244
PAYARA-3468 added tracing and logging, fixed bulkhead metric rejected…
jbee Apr 18, 2019
77dc3d4
PAYARA-3468 removed obsolete interceptors and validators, added javad…
jbee Apr 18, 2019
cf64a57
PAYARA-3468 interceptor priority via config; cleanup and rename
jbee Apr 19, 2019
d3bf29b
PAYARA-3468 added async tracing, javadoc and copyright headers
jbee Apr 22, 2019
0df07f6
PAYARA-3468 more javadoc
jbee Apr 22, 2019
6271fde
PAYARA-3468 added tests for config overrides
jbee Apr 22, 2019
d3cc6b1
PAYARA-3468 added tests for config override - all different value typ…
jbee Apr 22, 2019
49b70ea
PAYARA-3468 added test for configuration override priorities
jbee Apr 22, 2019
90b0ae5
PAYARA-3468 added tests for config enabled scope
jbee Apr 22, 2019
24ca2e9
PAYARA-3468 fixed: async Future exception handling; added async excep…
jbee Apr 23, 2019
1f461c1
PAYARA-3468 added more tests for async error handling
jbee Apr 23, 2019
fdec8f7
PAYARA-3468 added javadoc
jbee Apr 23, 2019
013c0e6
PAYARA-3468 added tests for fallback basic behaviour
jbee Apr 24, 2019
039b471
PAYARA-3468 added basic correctness test for Bulkhead
jbee Apr 25, 2019
6216b29
PAYARA-3468 added basic correctness test for circuit breaker
jbee Apr 25, 2019
2c6a16b
PAYARA-3468 corrected typo in method name
jbee Apr 29, 2019
0243816
PAYARA-3468 added stress test with multiple concurrent callers
jbee Apr 29, 2019
34b11d3
Indenting
Pandrex247 Apr 30, 2019
7b579aa
Typo in method names
Pandrex247 Apr 30, 2019
2ce3836
PAYARA-3468 added hamcrest to dependency management
jbee May 1, 2019
ab18255
Merge branch 'PAYARA-3468-MP-FT-2.0' of github.com:jbee/Payara into P…
jbee May 1, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,9 @@
<artifactId>javaee-api</artifactId>
<version>${javaee.api.version}</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2019 Payara Foundation and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://github.com/payara/Payara/blob/master/LICENSE.txt
* See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at glassfish/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* The Payara Foundation designates this particular file as subject to the "Classpath"
* exception as provided by the Payara Foundation in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
package fish.payara.microprofile.faulttolerance;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.time.temporal.ChronoUnit;

import org.eclipse.microprofile.faulttolerance.Bulkhead;
import org.eclipse.microprofile.faulttolerance.CircuitBreaker;
import org.eclipse.microprofile.faulttolerance.Fallback;
import org.eclipse.microprofile.faulttolerance.FallbackHandler;
import org.eclipse.microprofile.faulttolerance.Retry;
import org.eclipse.microprofile.faulttolerance.Timeout;

/**
* Encapsulates all properties extracted from FT annotations and the {@link org.eclipse.microprofile.config.Config} so
* that the processing can be declared independent of the actual resolution mechanism.
*
* A configuration is bound to a specific invocation context which is not an argument to each of the provided methods
* but passed to the implementation upon construction. For another invocation another configuration instance is bound.
*
* @author Jan Bernitt
*/
@FunctionalInterface
public interface FaultToleranceConfig {

/**
* @return A {@link FaultToleranceConfig} that behaves as stated by the present FT annotations. {@link Method}
* annotations take precedence over the {@link Class} level annotations.
*/
static FaultToleranceConfig asAnnotated(Class<?> target, Method method) {
return new FaultToleranceConfig() {
@Override
public <A extends Annotation> A getAnnotation(Class<A> annotationType) {
A annotation = method.getAnnotation(annotationType);
return annotation != null ? annotation : target.getAnnotation(annotationType);
}
};
}

/**
* Returns the value of the given annotation type for the invocation context was bound to upon construction.
*
* @param annotationType type to lookup
* @return the annotation of the given type if present or {@code null} otherwise
*/
<A extends Annotation> A getAnnotation(Class<A> annotationType);

/*
* General
*/

/**
* Check global generic annotation switch.
*
* @return true if (in addition to {@link Fallback}, which is always enabled) the other FT annotations are as well
* (default). Mostly used to disable these which will not disable {@link Fallback}.
*/
default boolean isNonFallbackEnabled() {
return true;
}

/**
* Check global annotation specific annotation switch.
*
* @param annotationType the annotation type to check
* @return true if the given annotation type is globally enabled, false if it is globally disabled
*/
default boolean isEnabled(Class<? extends Annotation> annotationType) {
return true;
}

/**
* Check for global metrics switch.
*
* @return true if metrics are enabled, false otherwise.
*/
default boolean isMetricsEnabled() {
return true;
}

/**
* @see #getAnnotation(Class)
*/
default boolean isAnnotationPresent(Class<? extends Annotation> annotationType) {
return getAnnotation(annotationType) != null;
}


/*
* @Retry
*/

default int maxRetries(Retry annotation) {
return annotation.maxRetries();
}

default long delay(Retry annotation) {
return annotation.delay();
}

default ChronoUnit delayUnit(Retry annotation) {
return annotation.delayUnit();
}

default long maxDuration(Retry annotation) {
return annotation.maxDuration();
}

default ChronoUnit durationUnit(Retry annotation) {
return annotation.durationUnit();
}

default long jitter(Retry annotation) {
return annotation.jitter();
}

default ChronoUnit jitterDelayUnit(Retry annotation) {
return annotation.jitterDelayUnit();
}

default Class<? extends Throwable>[] retryOn(Retry annotation) {
return annotation.retryOn();
}

default Class<? extends Throwable>[] abortOn(Retry annotation) {
return annotation.abortOn();
}


/*
* @CircuitBreaker
*/

default Class<? extends Throwable>[] failOn(CircuitBreaker annotation) {
return annotation.failOn();
}

default long delay(CircuitBreaker annotation) {
return annotation.delay();
}

default ChronoUnit delayUnit(CircuitBreaker annotation) {
return annotation.delayUnit();
}

default int requestVolumeThreshold(CircuitBreaker annotation) {
return annotation.requestVolumeThreshold();
}

default double failureRatio(CircuitBreaker annotation) {
return annotation.failureRatio();
}

default int successThreshold(CircuitBreaker annotation) {
return annotation.successThreshold();
}


/*
* @Bulkhead
*/

default int value(Bulkhead annotation) {
return annotation.value();
}

default int waitingTaskQueue(Bulkhead annotation) {
return annotation.waitingTaskQueue();
}


/*
* @Timeout
*/

default long value(Timeout annotation) {
return annotation.value();
}

default ChronoUnit unit(Timeout annotation) {
return annotation.unit();
}


/*
* @Fallback
*/

default Class<? extends FallbackHandler<?>> value(Fallback annotation) {
return annotation.value();
}

default String fallbackMethod(Fallback annotation) {
return annotation.fallbackMethod();
}
}
Loading