resolving conflicts
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/0d82e5ee Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/0d82e5ee Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/0d82e5ee Branch: refs/heads/master Commit: 0d82e5ee422fd1280e402008dd809e87a211d083 Parents: fcdaefe 0866dbe Author: ivanjunckes <[email protected]> Authored: Thu Dec 27 12:06:13 2018 -0200 Committer: ivanjunckes <[email protected]> Committed: Thu Dec 27 12:06:13 2018 -0200 ---------------------------------------------------------------------- .../arquillian/tests/filter/AllFilterTest.java | 1 - .../tests/realm/CdiLazyRealmTOMEE1490Test.java | 4 +- arquillian/arquillian-tomee-tests/pom.xml | 39 ++ .../org/apache/openejb/ClassLoaderUtil.java | 12 +- .../java/org/apache/openejb/MethodSpec.java | 4 +- .../main/java/org/apache/openejb/OpenEJB.java | 12 +- .../org/apache/openejb/OpenEjbContainer.java | 7 +- .../openejb/assembler/classic/Assembler.java | 18 +- .../openejb/assembler/classic/EjbResolver.java | 6 +- .../classic/InterceptorBindingBuilder.java | 6 +- .../classic/MethodConcurrencyBuilder.java | 4 +- .../assembler/classic/MethodInfoUtil.java | 10 +- .../classic/MethodTransactionBuilder.java | 2 +- .../java/org/apache/openejb/cdi/CdiScanner.java | 12 +- .../openejb/cdi/OptimizedLoaderService.java | 2 +- .../classloader/ClassLoaderConfigurer.java | 7 +- .../openejb/config/AnnotationDeployer.java | 18 +- .../org/apache/openejb/config/AppValidator.java | 40 +- .../org/apache/openejb/config/AutoConfig.java | 30 +- .../apache/openejb/config/DeploymentLoader.java | 9 +- .../apache/openejb/config/NewLoaderLogic.java | 22 +- .../config/OpenEJBDeploymentManager.java | 3 +- .../config/PersistenceUnitLinkResolver.java | 7 +- .../apache/openejb/config/ReadDescriptors.java | 4 +- .../apache/openejb/config/SunConversion.java | 4 +- .../openejb/config/WebappAggregatedArchive.java | 6 +- .../openejb/config/rules/CheckClassLoading.java | 2 +- .../rules/CheckIncorrectPropertyNames.java | 5 +- .../openejb/config/rules/CheckMethods.java | 40 +- .../config/rules/CheckRestMethodArePublic.java | 8 +- .../openejb/config/sys/WikiGenerator.java | 2 +- .../openejb/core/CoreContainerSystem.java | 6 +- .../openejb/core/NoSuchObjectException.java | 8 +- .../apache/openejb/core/TempClassLoader.java | 2 +- .../apache/openejb/core/cmp/cmp2/CmrSet.java | 3 +- .../openejb/core/cmp/cmp2/SetValuedCmr.java | 4 +- .../core/entity/EntityEjbHomeHandler.java | 4 +- .../openejb/core/ivm/naming/NameNode.java | 6 +- .../openejb/core/mdb/MdbInstanceManager.java | 7 +- .../core/security/AbstractSecurityService.java | 7 +- .../security/jaas/PropertiesLoginModule.java | 4 +- .../jaas/UsernamePasswordCallbackHandler.java | 3 +- .../openejb/core/stateful/SimpleCache.java | 6 +- .../TransactionRolledbackException.java | 8 +- .../core/webservices/HandlerResolverImpl.java | 5 +- .../webservices/PortAddressRegistryImpl.java | 18 +- .../math/stat/descriptive/moment/Variance.java | 4 +- .../apache/openejb/monitoring/ManagedMBean.java | 4 +- .../openejb/resource/AutoConnectionTracker.java | 12 +- .../jdbc/pool/PoolDataSourceCreator.java | 8 +- .../apache/openejb/threads/task/CUCallable.java | 7 +- .../org/apache/openejb/threads/task/CUTask.java | 7 +- .../java/org/apache/openejb/util/Base64.java | 16 +- .../java/org/apache/openejb/util/ConfUtils.java | 2 +- .../openejb/util/IntrospectionSupport.java | 23 +- .../openejb/util/JavaSecurityManagers.java | 7 +- .../org/apache/openejb/util/LinkResolver.java | 6 +- .../java/org/apache/openejb/util/Logger.java | 7 +- .../org/apache/openejb/util/URISupport.java | 14 +- .../java/org/apache/openejb/util/UrlCache.java | 6 +- .../openejb/web/LightweightWebAppBuilder.java | 12 +- .../org/apache/openejb/DependencyVisitor.java | 10 +- .../InterceptorBindingInfoComparatorTest.java | 4 +- .../MethodTransactionInfoComparatorTest.java | 2 +- .../openejb/core/ivm/naming/IvmContextTest.java | 6 +- .../openejb/core/timer/GetAllTimersTest.java | 2 +- .../MultiThreadedManagedDataSourceTest.java | 7 +- .../threads/ManagedExecutorServiceTest.java | 7 +- .../apache/openejb/util/UrlComparatorTest.java | 4 +- .../apache/openejb/jee/AssemblyDescriptor.java | 6 +- .../main/java/org/apache/openejb/jee/Beans.java | 6 +- .../apache/openejb/jee/oejb3/EjbDeployment.java | 7 +- .../openejb/jee/oejb3/PropertiesAdapter.java | 2 +- .../openejb/loader/BasicURLClassPath.java | 6 + .../apache/openejb/loader/ClassPathFactory.java | 1 + .../org/apache/openejb/loader/Embedder.java | 2 +- .../org/apache/openejb/loader/FileUtils.java | 5 +- .../java/org/apache/openejb/loader/Files.java | 26 +- .../main/java/org/apache/openejb/loader/IO.java | 13 +- .../org/apache/openejb/loader/JarLocation.java | 1 - .../openejb/loader/LoaderRuntimeException.java | 1 + .../apache/openejb/loader/OpenEJBInstance.java | 2 +- .../java/org/apache/openejb/loader/Options.java | 7 +- .../apache/openejb/loader/SystemInstance.java | 30 +- .../apache/openejb/loader/TomcatClassPath.java | 2 +- .../apache/openejb/loader/WebAppClassPath.java | 1 + .../java/org/apache/openejb/loader/Zips.java | 1 + .../provisining/ProvisioningResolverAware.java | 1 + .../openejb/observer/ObserverManager.java | 46 +-- .../org/apache/openejb/loader/FilesTest.java | 23 +- .../apache/openejb/observer/EventSpeedTest.java | 6 +- .../openejb/observer/ObserverFeaturesTest.java | 4 +- .../openejb/observer/ObserverListTest.java | 2 +- docs/admin/cluster/index.adoc | 11 - docs/docs.adoc | 2 +- .../README.md | 1 + .../cdi-alternative-and-stereotypes/README.md | 1 + examples/cdi-events/README.md | 1 + examples/cdi-session-scope/README.md | 122 ++++++ .../executor/ManagedScheduledService.java | 53 ++- .../superbiz/executor/ThreadFactoryService.java | 84 +++- .../executor/ManagedScheduledServiceTest.java | 11 +- .../executor/ThreadFactoryServiceTest.java | 59 ++- .../dynamic-proxy-to-access-mbean/README.md | 2 +- examples/jpa-hibernate/README.md | 15 +- examples/moviefun-rest/README.md | 404 +++++++++++++++++++ examples/mp-custom-healthcheck/README.adoc | 146 +++++++ examples/mp-custom-healthcheck/pom.xml | 94 +++++ .../java/org/superbiz/WeatherApiStatus.java | 52 +++ .../main/java/org/superbiz/WeatherEndpoint.java | 45 +++ .../java/org/superbiz/WeatherException.java | 27 ++ .../main/java/org/superbiz/WeatherGateway.java | 63 +++ .../org/superbiz/WeatherServiceHealthCheck.java | 48 +++ .../src/main/resources/beans.xml | 7 + .../org/superbiz/test/WeatherServiceTest.java | 124 ++++++ .../src/test/resources/arquillian.xml | 29 ++ examples/mp-faulttolerance-fallback/README.adoc | 121 ++++++ examples/mp-faulttolerance-fallback/pom.xml | 107 +++++ .../rest/WeatherDayStatusFallbackHandler.java | 34 ++ .../org/superbiz/rest/WeatherException.java | 20 + .../java/org/superbiz/rest/WeatherService.java | 60 +++ .../org/superbiz/rest/WeatherServiceTest.java | 74 ++++ .../src/test/resources/arquillian.xml | 30 ++ .../src/test/resources/beans.xml | 7 + examples/mp-faulttolerance-retry/README.adoc | 4 +- examples/mp-metrics-counted/README.md | 0 examples/mp-metrics-metered/README.md | 130 ++++++ examples/mp-opentracing-traced/README.adoc | 64 +++ examples/multi-jpa-provider-testing/README.md | 281 +++++++++++++ examples/mvc-cxf/README.adoc | 24 ++ examples/mvc-cxf/README.md | 23 -- examples/mvc-resteasy/README.adoc | 23 ++ examples/mvc-resteasy/pom.xml | 143 +++++++ .../java/org/superbiz/mvc/MVCApplication.java | 22 + .../java/org/superbiz/mvc/TomeeController.java | 38 ++ .../src/main/resources/META-INF/beans.xml | 23 ++ .../src/main/webapp/WEB-INF/views/hello.jsp | 28 ++ .../src/main/webapp/WEB-INF/web.xml | 28 ++ examples/mvc-resteasy/src/main/webapp/index.jsp | 28 ++ .../src/test/java/org/superbiz/mvc/MVCTest.java | 74 ++++ .../src/test/resources/arquillian.xml | 31 ++ examples/persistence-fragment/README.md | 6 +- examples/pojo-webservice/README.md | 273 +++++++++++++ examples/polling-parent/README.md | 1 + examples/pom.xml | 3 + examples/simple-cdi-interceptor/README.md | 1 + examples/websocket-tls-basic-auth/README.md | 1 + .../META-INF/org.apache.openejb.extension | 1 - owasp-dc-suppression.xml | 80 ++++ pom.xml | 61 ++- .../apache/openejb/server/rest/RESTService.java | 7 +- .../apache-tomee/src/main/resources/service.bat | 2 +- tomee/tomee-plume-webapp/pom.xml | 3 +- tomee/tomee-plus-webapp/pom.xml | 3 +- 154 files changed, 3454 insertions(+), 621 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tomee/blob/0d82e5ee/examples/mp-faulttolerance-retry/README.adoc ---------------------------------------------------------------------- diff --cc examples/mp-faulttolerance-retry/README.adoc index 8f40268,0000000..f43d06a mode 100644,000000..100644 --- a/examples/mp-faulttolerance-retry/README.adoc +++ b/examples/mp-faulttolerance-retry/README.adoc @@@ -1,256 -1,0 +1,256 @@@ +:index-group: MicroProfile +:jbake-type: page +:jbake-status: published - ++~~~~~~ +# Microprofile Fault Tolerance - Retry policy + +This is an example of how to use +Microprofile @Retry in TomEE. + +== Retry Feature + +Microprofile Fault Tolerance has a feature called Retry that can be used +to recover an operation from failure, invoking the same operation again +until it reaches its stopping criteria. + +The Retry policy allows to configure : + +* *maxRetries*: the maximum retries +* *delay*: delays between each retry +* *delayUnit*: the delay unit +* *maxDuration*: maximum duration to perform the retry for. +* *durationUnit*: duration unit +* *jitter:* the random vary of retry delays +* *jitterDelayUnit:* the jitter unit +* *retryOn:* specify the failures to retry on +* *abortOn:* specify the failures to abort on + +To use this feature you can annotate a class and/or a method with the +@Retry annotation. Check the +http://download.eclipse.org/microprofile/microprofile-fault-tolerance-1.1/microprofile-fault-tolerance-spec.html[specification] +for more details. + +== Examples + +=== Run the application + +.... - mvn clean install tomee:run ++mvn clean install tomee:run +.... + +=== Example 1 + +The method statusOfDay will fail three times, each time, throwing a +`WeatherGatewayTimeoutException` and as the @Retry annotation is +configured to `retryOn` in case of failure, the FailSafe library will +take the `maxRetry` value and retry the same operation until it reaches +the number maximum of attempts, which is 3 (default value). + +[source,java] +---- +@RequestScoped +public class WeatherGateway{ + ... + @Retry(maxRetry=3, retryOn = WeatherGatewayTimeoutException.class) + public String statusOfDay(){ + if(counterStatusOfDay.addAndGet(1) <= DEFAULT_MAX_RETRY){ + LOGGER.warning(String.format(FORECAST_TIMEOUT_MESSAGE, DEFAULT_MAX_RETRY, counterStatusOfDay.get())); + throw new WeatherGatewayTimeoutException(); + } + return "Today is a sunny day!"; + } + ... + } +---- + +Day status call + +.... +GET http://localhost:8080/mp-faulttolerance-retry/weather/day/status +.... + +Server log + +.... +WARNING - Timeout when accessing AccuWeather Forecast Service. Max of Attempts: (3), Attempts: (1) +WARNING - Timeout when accessing AccuWeather Forecast Service. Max of Attempts: (3), Attempts: (2) +WARNING - Timeout when accessing AccuWeather Forecast Service. Max of Attempts: (3), Attempts: (3) +.... + +Response + +.... +Today is a sunny day! +.... + +=== Example 2 + +The method weekStatus will fail two times, each time, throwing a +`WeatherGatewayTimeoutException` because `retryOn` is configured and +instead of returning a response to the caller, the logic states that at +the third attempt, a `WeatherGatewayBusyServiceException` will be +thrown. As the `@Retry` annotation is configured to `abortOn` in case of +`WeatherGatewayTimeoutException` happens, the remaining attempt wonât be +executed and the caller must handle the exception. + +[source,java] +---- +@Retry(maxRetries = 3, retryOn = WeatherGatewayTimeoutException.class, abortOn = WeatherGatewayBusyServiceException.class) +public String statusOfWeek(){ + if(counterStatusOfWeek.addAndGet(1) <= DEFAULT_MAX_RETRY){ + LOGGER.warning(String.format(FORECAST_TIMEOUT_MESSAGE_ATTEMPTS, DEFAULT_MAX_RETRY, counterStatusOfWeek.get())); + throw new WeatherGatewayTimeoutException(); + } + LOGGER.log(Level.SEVERE, String.format(FORECAST_BUSY_MESSAGE, counterStatusOfWeek.get())); + throw new WeatherGatewayBusyServiceException(); +} +---- + +Week status call + +.... +GET http://localhost:8080/mp-faulttolerance-retry/weather/week/status +.... + +Server log + +.... +WARNING - Timeout when accessing AccuWeather Forecast Service. Max of Attempts: (3), Attempts: (1) +WARNING - Timeout when accessing AccuWeather Forecast Service. Max of Attempts: (3), Attempts: (2) +WARNING - Timeout when accessing AccuWeather Forecast Service. Max of Attempts: (3), Attempts: (3) +SEVERE - Error AccuWeather Forecast Service is busy. Number of Attempts: (4) +.... + +Response + +.... +WeatherGateway Service is Busy. Retry later +.... + +=== Example 3 + +The `@Retry` annotation allows to configure a delay for each new attempt +be executed giving a chance to service requested to recover itself and +answerer the request properly. For each new retry follow the delay +configure, is needed to set `jitter` to zero (0). Otherwise the delay of +each new attempt will be randomized. + +Analysing the logged messages, is possible to see that all attempts took +the pretty much the same time to execute. + +[source,java] +---- +@Retry(retryOn = WeatherGatewayTimeoutException.class, maxRetries = 5, delay = 500, jitter = 0) +public String statusOfWeekend() { + if (counterStatusOfWeekend.addAndGet(1) <= 5) { + logTimeoutMessage(statusOfWeekendInstant); + statusOfWeekendInstant = Instant.now(); + throw new WeatherGatewayTimeoutException(); + } + return "The Forecast for the Weekend is Scattered Showers."; +} +---- + +Weekend status call + +.... +GET http://localhost:8080/mp-faulttolerance-retry/weather/weekend/status +.... + +Server log + +.... +WARNING - Timeout when accessing AccuWeather Forecast Service. +WARNING - Timeout when accessing AccuWeather Forecast Service. Delay before this attempt: (501) millis +WARNING - Timeout when accessing AccuWeather Forecast Service. Delay before this attempt: (501) millis +WARNING - Timeout when accessing AccuWeather Forecast Service. Delay before this attempt: (501) millis +WARNING - Timeout when accessing AccuWeather Forecast Service. Delay before this attempt: (500) millis +.... + +=== Example 4 + +Basically with the same behaviour of the `Example 3`, this example sets +the `delay` and `jitter` with 500 millis to randomly create a new delay +for each new attempt after the first failure. +https://github.com/jhalterman/failsafe/blob/master/src/main/java/net/jodah/failsafe/AbstractExecution.java[AbstractExecution#randomDelay(delay,jitter,random)] +can give a hit of how the new delay is calculated. + +Analysing the logged messages, is possible to see how long each attempt +had to wait until its execution. + +[source,java] +---- +@Retry(retryOn = WeatherGatewayTimeoutException.class, delay = 500, jitter = 500) +public String statusOfMonth() { + if (counterStatusOfWeekend.addAndGet(1) <= DEFAULT_MAX_RETRY) { + logTimeoutMessage(statusOfMonthInstant); + statusOfMonthInstant = Instant.now(); + throw new WeatherGatewayTimeoutException(); + } + return "The Forecast for the Weekend is Scattered Showers."; +} +---- + +Month status call + +.... +GET http://localhost:8080/mp-faulttolerance-retry/weather/month/status +.... + +Server log + +.... +WARNING - Timeout when accessing AccuWeather Forecast Service. +WARNING - Timeout when accessing AccuWeather Forecast Service. Delay before this attempt: (417) millis +WARNING - Timeout when accessing AccuWeather Forecast Service. Delay before this attempt: (90) millis +.... + +=== Example 5 + +If a condition for an operation be re-executed is not set as in the +previous examples using the parameter `retryOn`, the operation is +executed again for _any_ exception that is thrown. + +[source,java] +---- +@Retry(maxDuration = 1000) +public String statusOfYear(){ + if (counterStatusOfWeekend.addAndGet(1) <= 5) { + logTimeoutMessage(statusOfYearInstant); + statusOfYearInstant = Instant.now(); + throw new RuntimeException(); + } + return "WeatherGateway Service Error"; +} +---- + +Year status call + +.... +GET http://localhost:8080/mp-faulttolerance-retry/weather/year/statusk +.... + +Server log + +.... +WARNING - Timeout when accessing AccuWeather Forecast Service. +WARNING - Timeout when accessing AccuWeather Forecast Service. Delay before this attempt: (666) millis +WARNING - Timeout when accessing AccuWeather Forecast Service. Delay before this attempt: (266) millis +WARNING - Timeout when accessing AccuWeather Forecast Service. Delay before this attempt: (66) millis +.... + +=== Run the tests + +You can also try it out using the +link:src/test/java/org/superbiz/rest/WeatherServiceTest.java[WeatherServiceTest.java] +available in the project. + +.... +mvn clean test +.... + +.... +[INFO] Results: +[INFO] +[INFO] Tests run: 5, Failures: 0, Errors: 0, Skipped: 0 +.... http://git-wip-us.apache.org/repos/asf/tomee/blob/0d82e5ee/examples/mp-metrics-counted/README.md ---------------------------------------------------------------------- diff --cc examples/mp-metrics-counted/README.md index 0000000,cb91ef0..e69de29 mode 000000,100644..100644 --- a/examples/mp-metrics-counted/README.md +++ b/examples/mp-metrics-counted/README.md
