camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/2] camel git commit: CAMEL-9879: Circuit Breaker EIP - That is using hystrix.
Date Wed, 20 Apr 2016 05:06:36 GMT
Repository: camel
Updated Branches:
  refs/heads/master 88b651146 -> 5c80379c4


CAMEL-9879: Circuit Breaker EIP - That is using hystrix.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/a90d9151
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/a90d9151
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/a90d9151

Branch: refs/heads/master
Commit: a90d915180fa07492895036ab7067ab004ec0d9d
Parents: 88b6511
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Wed Apr 20 06:36:44 2016 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Wed Apr 20 06:53:52 2016 +0200

----------------------------------------------------------------------
 .../apache/camel/model/FallbackDefinition.java  | 60 --------------------
 .../apache/camel/model/HystrixDefinition.java   | 49 ++++++++--------
 .../camel/model/OnFallbackDefinition.java       | 60 ++++++++++++++++++++
 .../resources/org/apache/camel/model/jaxb.index |  2 +-
 .../processor/HystrixProcessorFactory.java      |  5 +-
 .../processor/HystrixRouteConfigTest.java       |  5 +-
 .../processor/HystrixRouteFallbackTest.java     |  2 +-
 .../hystrix/processor/HystrixRouteOkTest.java   |  2 +-
 .../SpringHystrixRouteConfigRefTest.xml         |  4 +-
 .../processor/SpringHystrixRouteConfigTest.xml  |  4 +-
 .../SpringHystrixRouteFallbackTest.xml          |  4 +-
 .../processor/SpringHystrixRouteOkTest.xml      |  4 +-
 12 files changed, 101 insertions(+), 100 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/a90d9151/camel-core/src/main/java/org/apache/camel/model/FallbackDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/FallbackDefinition.java b/camel-core/src/main/java/org/apache/camel/model/FallbackDefinition.java
deleted file mode 100644
index 301c6d1..0000000
--- a/camel-core/src/main/java/org/apache/camel/model/FallbackDefinition.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * 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.camel.model;
-
-import java.util.List;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.apache.camel.Processor;
-import org.apache.camel.spi.Metadata;
-import org.apache.camel.spi.RouteContext;
-import org.apache.camel.util.CollectionStringBuffer;
-
-/**
- * Route to be executed when circuit breaker executes fallback
- */
-@Metadata(label = "eip,routing,circuitbreaker")
-@XmlRootElement(name = "fallback")
-@XmlAccessorType(XmlAccessType.FIELD)
-public class FallbackDefinition extends OutputDefinition<FallbackDefinition> {
-
-    public FallbackDefinition() {
-    }
-
-    @Override
-    public String toString() {
-        return "Fallback[" + getOutputs() + "]";
-    }
-
-    @Override
-    public Processor createProcessor(RouteContext routeContext) throws Exception {
-        return this.createChildProcessor(routeContext, false);
-    }
-
-    @Override
-    public String getLabel() {
-        CollectionStringBuffer buffer = new CollectionStringBuffer("fallback[");
-        List<ProcessorDefinition<?>> list = getOutputs();
-        for (ProcessorDefinition<?> type : list) {
-            buffer.append(type.getLabel());
-        }
-        buffer.append("]");
-        return buffer.toString();
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/a90d9151/camel-core/src/main/java/org/apache/camel/model/HystrixDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/HystrixDefinition.java b/camel-core/src/main/java/org/apache/camel/model/HystrixDefinition.java
index 6741e91..adc656c 100644
--- a/camel-core/src/main/java/org/apache/camel/model/HystrixDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/HystrixDefinition.java
@@ -25,6 +25,7 @@ import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlElementRef;
 import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
 
 import org.apache.camel.Processor;
 import org.apache.camel.spi.Metadata;
@@ -39,8 +40,8 @@ public class HystrixDefinition extends ProcessorDefinition<HystrixDefinition>
{
     private HystrixConfigurationDefinition hystrixConfiguration;
     @XmlElementRef
     private List<ProcessorDefinition<?>> outputs = new ArrayList<ProcessorDefinition<?>>();
-    @XmlElement
-    private FallbackDefinition fallback;
+    @XmlTransient
+    private OnFallbackDefinition onFallback;
     @XmlAttribute
     private String hystrixConfigurationRef;
 
@@ -81,11 +82,11 @@ public class HystrixDefinition extends ProcessorDefinition<HystrixDefinition>
{
 
     @Override
     public void addOutput(ProcessorDefinition<?> output) {
-        if (output instanceof FallbackDefinition) {
-            fallback = (FallbackDefinition) output;
+        if (output instanceof OnFallbackDefinition) {
+            onFallback = (OnFallbackDefinition) output;
         } else {
-            if (fallback != null) {
-                fallback.addOutput(output);
+            if (onFallback != null) {
+                onFallback.addOutput(output);
             } else {
                 super.addOutput(output);
             }
@@ -94,9 +95,9 @@ public class HystrixDefinition extends ProcessorDefinition<HystrixDefinition>
{
 
     @Override
     public ProcessorDefinition<?> end() {
-        if (fallback != null) {
+        if (onFallback != null) {
             // end fallback as well
-            fallback.end();
+            onFallback.end();
         }
         return super.end();
     }
@@ -107,8 +108,8 @@ public class HystrixDefinition extends ProcessorDefinition<HystrixDefinition>
{
         Iterator<ProcessorDefinition<?>> it = outputs.iterator();
         while (it.hasNext()) {
             ProcessorDefinition<?> out = it.next();
-            if (out instanceof FallbackDefinition) {
-                fallback = (FallbackDefinition) out;
+            if (out instanceof OnFallbackDefinition) {
+                onFallback = (OnFallbackDefinition) out;
                 it.remove();
             }
         }
@@ -133,12 +134,12 @@ public class HystrixDefinition extends ProcessorDefinition<HystrixDefinition>
{
         this.hystrixConfigurationRef = hystrixConfigurationRef;
     }
 
-    public FallbackDefinition getFallback() {
-        return fallback;
+    public OnFallbackDefinition getOnFallback() {
+        return onFallback;
     }
 
-    public void setFallback(FallbackDefinition fallback) {
-        this.fallback = fallback;
+    public void setOnFallback(OnFallbackDefinition onFallback) {
+        this.onFallback = onFallback;
     }
 
     // Fluent API
@@ -148,7 +149,7 @@ public class HystrixDefinition extends ProcessorDefinition<HystrixDefinition>
{
      * Sets the group key to use. The default value is CamelHystrix.
      */
     public HystrixDefinition groupKey(String groupKey) {
-        configure().groupKey(groupKey);
+        hystrixConfiguration().groupKey(groupKey);
         return this;
     }
 
@@ -156,7 +157,7 @@ public class HystrixDefinition extends ProcessorDefinition<HystrixDefinition>
{
      * Sets the thread pool key to use. The default value is CamelHystrix.
      */
     public HystrixDefinition threadPoolKey(String threadPoolKey) {
-        configure().threadPoolKey(threadPoolKey);
+        hystrixConfiguration().threadPoolKey(threadPoolKey);
         return this;
     }
 
@@ -165,7 +166,7 @@ public class HystrixDefinition extends ProcessorDefinition<HystrixDefinition>
{
      * <p/>
      * Use <tt>end</tt> when configuration is complete, to return back to the
Hystrix EIP.
      */
-    public HystrixConfigurationDefinition configure() {
+    public HystrixConfigurationDefinition hystrixConfiguration() {
         hystrixConfiguration = new HystrixConfigurationDefinition(this);
         return hystrixConfiguration;
     }
@@ -173,25 +174,25 @@ public class HystrixDefinition extends ProcessorDefinition<HystrixDefinition>
{
     /**
      * Configures the Hystrix EIP using the given configuration
      */
-    public HystrixDefinition configure(HystrixConfigurationDefinition configuration) {
+    public HystrixDefinition hystrixConfiguration(HystrixConfigurationDefinition configuration)
{
         hystrixConfiguration = configuration;
         return this;
     }
 
     /**
-     * Refers to a hystrix configuration to use for configuring the Hystrix EIP.
+     * Refers to a Hystrix configuration to use for configuring the Hystrix EIP.
      */
-    public HystrixDefinition configure(String ref) {
+    public HystrixDefinition hystrixConfiguration(String ref) {
         hystrixConfigurationRef = ref;
         return this;
     }
 
     /**
-     * Sets the fallback node
+     * The Hystrix fallback route path to execute.
      */
-    public HystrixDefinition fallback() {
-        fallback = new FallbackDefinition();
-        fallback.setParent(this);
+    public HystrixDefinition onFallback() {
+        onFallback = new OnFallbackDefinition();
+        onFallback.setParent(this);
         return this;
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/a90d9151/camel-core/src/main/java/org/apache/camel/model/OnFallbackDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/OnFallbackDefinition.java b/camel-core/src/main/java/org/apache/camel/model/OnFallbackDefinition.java
new file mode 100644
index 0000000..de6944a
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/model/OnFallbackDefinition.java
@@ -0,0 +1,60 @@
+/**
+ * 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.camel.model;
+
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.camel.Processor;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.spi.RouteContext;
+import org.apache.camel.util.CollectionStringBuffer;
+
+/**
+ * Route to be executed when Hystrix EIP executes fallback
+ */
+@Metadata(label = "eip,routing,circuitbreaker")
+@XmlRootElement(name = "onFallback")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class OnFallbackDefinition extends OutputDefinition<OnFallbackDefinition> {
+
+    public OnFallbackDefinition() {
+    }
+
+    @Override
+    public String toString() {
+        return "OnFallback[" + getOutputs() + "]";
+    }
+
+    @Override
+    public Processor createProcessor(RouteContext routeContext) throws Exception {
+        return this.createChildProcessor(routeContext, false);
+    }
+
+    @Override
+    public String getLabel() {
+        CollectionStringBuffer buffer = new CollectionStringBuffer("onFallback[");
+        List<ProcessorDefinition<?>> list = getOutputs();
+        for (ProcessorDefinition<?> type : list) {
+            buffer.append(type.getLabel());
+        }
+        buffer.append("]");
+        return buffer.toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/a90d9151/camel-core/src/main/resources/org/apache/camel/model/jaxb.index
----------------------------------------------------------------------
diff --git a/camel-core/src/main/resources/org/apache/camel/model/jaxb.index b/camel-core/src/main/resources/org/apache/camel/model/jaxb.index
index 9315335..9859736 100644
--- a/camel-core/src/main/resources/org/apache/camel/model/jaxb.index
+++ b/camel-core/src/main/resources/org/apache/camel/model/jaxb.index
@@ -27,7 +27,6 @@ DescriptionDefinition
 DynamicRouterDefinition
 EnrichDefinition
 ExpressionSubElementDefinition
-FallbackDefinition
 FilterDefinition
 FinallyDefinition
 FromDefinition
@@ -48,6 +47,7 @@ MulticastDefinition
 OnCompletionDefinition
 OnCompletionMode
 OnExceptionDefinition
+OnFallbackDefinition
 OptimisticLockRetryPolicyDefinition
 OptionalIdentifiedDefinition
 OtherwiseDefinition

http://git-wip-us.apache.org/repos/asf/camel/blob/a90d9151/components/camel-hystrix/src/main/java/org/apache/camel/component/hystrix/processor/HystrixProcessorFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-hystrix/src/main/java/org/apache/camel/component/hystrix/processor/HystrixProcessorFactory.java
b/components/camel-hystrix/src/main/java/org/apache/camel/component/hystrix/processor/HystrixProcessorFactory.java
index fb9aca6..f8aa572 100644
--- a/components/camel-hystrix/src/main/java/org/apache/camel/component/hystrix/processor/HystrixProcessorFactory.java
+++ b/components/camel-hystrix/src/main/java/org/apache/camel/component/hystrix/processor/HystrixProcessorFactory.java
@@ -21,7 +21,6 @@ import com.netflix.hystrix.HystrixCommandGroupKey;
 import com.netflix.hystrix.HystrixCommandProperties;
 import com.netflix.hystrix.HystrixThreadPoolKey;
 import com.netflix.hystrix.HystrixThreadPoolProperties;
-import org.apache.camel.Expression;
 import org.apache.camel.Processor;
 import org.apache.camel.model.HystrixConfigurationDefinition;
 import org.apache.camel.model.HystrixDefinition;
@@ -49,8 +48,8 @@ public class HystrixProcessorFactory implements ProcessorFactory {
             // create the regular and fallback processors
             Processor processor = cb.createChildProcessor(routeContext, true);
             Processor fallback = null;
-            if (cb.getFallback() != null) {
-                fallback = cb.getFallback().createProcessor(routeContext);
+            if (cb.getOnFallback() != null) {
+                fallback = cb.getOnFallback().createProcessor(routeContext);
             }
 
             HystrixConfigurationDefinition config = cb.getHystrixConfiguration();

http://git-wip-us.apache.org/repos/asf/camel/blob/a90d9151/components/camel-hystrix/src/test/java/org/apache/camel/component/hystrix/processor/HystrixRouteConfigTest.java
----------------------------------------------------------------------
diff --git a/components/camel-hystrix/src/test/java/org/apache/camel/component/hystrix/processor/HystrixRouteConfigTest.java
b/components/camel-hystrix/src/test/java/org/apache/camel/component/hystrix/processor/HystrixRouteConfigTest.java
index d8dc5f4..cf0b164 100644
--- a/components/camel-hystrix/src/test/java/org/apache/camel/component/hystrix/processor/HystrixRouteConfigTest.java
+++ b/components/camel-hystrix/src/test/java/org/apache/camel/component/hystrix/processor/HystrixRouteConfigTest.java
@@ -37,9 +37,10 @@ public class HystrixRouteConfigTest extends CamelTestSupport {
             @Override
             public void configure() throws Exception {
                 from("direct:start")
-                    .hystrix().configure().groupKey("myCamelApp").requestLogEnabled(false).corePoolSize(5).end()
+                    .hystrix()
+                        .hystrixConfiguration().groupKey("myCamelApp").requestLogEnabled(false).corePoolSize(5).end()
                         .to("direct:foo")
-                    .fallback()
+                    .onFallback()
                         .transform().constant("Fallback message")
                     .end()
                     .to("mock:result");

http://git-wip-us.apache.org/repos/asf/camel/blob/a90d9151/components/camel-hystrix/src/test/java/org/apache/camel/component/hystrix/processor/HystrixRouteFallbackTest.java
----------------------------------------------------------------------
diff --git a/components/camel-hystrix/src/test/java/org/apache/camel/component/hystrix/processor/HystrixRouteFallbackTest.java
b/components/camel-hystrix/src/test/java/org/apache/camel/component/hystrix/processor/HystrixRouteFallbackTest.java
index b6cced0..fb96f98 100644
--- a/components/camel-hystrix/src/test/java/org/apache/camel/component/hystrix/processor/HystrixRouteFallbackTest.java
+++ b/components/camel-hystrix/src/test/java/org/apache/camel/component/hystrix/processor/HystrixRouteFallbackTest.java
@@ -39,7 +39,7 @@ public class HystrixRouteFallbackTest extends CamelTestSupport {
                 from("direct:start")
                     .hystrix()
                         .to("direct:foo")
-                    .fallback()
+                    .onFallback()
                         .transform().constant("Fallback message")
                     .end()
                     .to("mock:result");

http://git-wip-us.apache.org/repos/asf/camel/blob/a90d9151/components/camel-hystrix/src/test/java/org/apache/camel/component/hystrix/processor/HystrixRouteOkTest.java
----------------------------------------------------------------------
diff --git a/components/camel-hystrix/src/test/java/org/apache/camel/component/hystrix/processor/HystrixRouteOkTest.java
b/components/camel-hystrix/src/test/java/org/apache/camel/component/hystrix/processor/HystrixRouteOkTest.java
index 5d90610..4980bb4 100644
--- a/components/camel-hystrix/src/test/java/org/apache/camel/component/hystrix/processor/HystrixRouteOkTest.java
+++ b/components/camel-hystrix/src/test/java/org/apache/camel/component/hystrix/processor/HystrixRouteOkTest.java
@@ -39,7 +39,7 @@ public class HystrixRouteOkTest extends CamelTestSupport {
                 from("direct:start")
                     .hystrix()
                         .to("direct:foo")
-                    .fallback()
+                    .onFallback()
                         .transform().constant("Fallback message")
                     .end()
                     .to("mock:result");

http://git-wip-us.apache.org/repos/asf/camel/blob/a90d9151/components/camel-hystrix/src/test/resources/org/apache/camel/component/hystrix/processor/SpringHystrixRouteConfigRefTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-hystrix/src/test/resources/org/apache/camel/component/hystrix/processor/SpringHystrixRouteConfigRefTest.xml
b/components/camel-hystrix/src/test/resources/org/apache/camel/component/hystrix/processor/SpringHystrixRouteConfigRefTest.xml
index 1035cde..3a71542 100644
--- a/components/camel-hystrix/src/test/resources/org/apache/camel/component/hystrix/processor/SpringHystrixRouteConfigRefTest.xml
+++ b/components/camel-hystrix/src/test/resources/org/apache/camel/component/hystrix/processor/SpringHystrixRouteConfigRefTest.xml
@@ -29,11 +29,11 @@
       <from uri="direct:start"/>
       <hystrix hystrixConfigurationRef="hysConfig">
         <to uri="direct:foo"/>
-        <fallback>
+        <onFallback>
           <transform>
             <constant>Fallback message</constant>
           </transform>
-        </fallback>
+        </onFallback>
       </hystrix>
       <to uri="mock:result"/>
     </route>

http://git-wip-us.apache.org/repos/asf/camel/blob/a90d9151/components/camel-hystrix/src/test/resources/org/apache/camel/component/hystrix/processor/SpringHystrixRouteConfigTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-hystrix/src/test/resources/org/apache/camel/component/hystrix/processor/SpringHystrixRouteConfigTest.xml
b/components/camel-hystrix/src/test/resources/org/apache/camel/component/hystrix/processor/SpringHystrixRouteConfigTest.xml
index 6d62e40..40bddfe 100644
--- a/components/camel-hystrix/src/test/resources/org/apache/camel/component/hystrix/processor/SpringHystrixRouteConfigTest.xml
+++ b/components/camel-hystrix/src/test/resources/org/apache/camel/component/hystrix/processor/SpringHystrixRouteConfigTest.xml
@@ -27,11 +27,11 @@
       <hystrix>
         <hystrixConfiguration groupKey="myCamelApp" requestLogEnabled="false" corePoolSize="5"/>
         <to uri="direct:foo"/>
-        <fallback>
+        <onFallback>
           <transform>
             <constant>Fallback message</constant>
           </transform>
-        </fallback>
+        </onFallback>
       </hystrix>
       <to uri="mock:result"/>
     </route>

http://git-wip-us.apache.org/repos/asf/camel/blob/a90d9151/components/camel-hystrix/src/test/resources/org/apache/camel/component/hystrix/processor/SpringHystrixRouteFallbackTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-hystrix/src/test/resources/org/apache/camel/component/hystrix/processor/SpringHystrixRouteFallbackTest.xml
b/components/camel-hystrix/src/test/resources/org/apache/camel/component/hystrix/processor/SpringHystrixRouteFallbackTest.xml
index 441b8b6..9116ee2 100644
--- a/components/camel-hystrix/src/test/resources/org/apache/camel/component/hystrix/processor/SpringHystrixRouteFallbackTest.xml
+++ b/components/camel-hystrix/src/test/resources/org/apache/camel/component/hystrix/processor/SpringHystrixRouteFallbackTest.xml
@@ -26,11 +26,11 @@
       <from uri="direct:start"/>
       <hystrix>
         <to uri="direct:foo"/>
-        <fallback>
+        <onFallback>
           <transform>
             <constant>Fallback message</constant>
           </transform>
-        </fallback>
+        </onFallback>
       </hystrix>
       <to uri="mock:result"/>
     </route>

http://git-wip-us.apache.org/repos/asf/camel/blob/a90d9151/components/camel-hystrix/src/test/resources/org/apache/camel/component/hystrix/processor/SpringHystrixRouteOkTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-hystrix/src/test/resources/org/apache/camel/component/hystrix/processor/SpringHystrixRouteOkTest.xml
b/components/camel-hystrix/src/test/resources/org/apache/camel/component/hystrix/processor/SpringHystrixRouteOkTest.xml
index 26fdabc..b103c64 100644
--- a/components/camel-hystrix/src/test/resources/org/apache/camel/component/hystrix/processor/SpringHystrixRouteOkTest.xml
+++ b/components/camel-hystrix/src/test/resources/org/apache/camel/component/hystrix/processor/SpringHystrixRouteOkTest.xml
@@ -26,11 +26,11 @@
       <from uri="direct:start"/>
       <hystrix>
         <to uri="direct:foo"/>
-        <fallback>
+        <onFallback>
           <transform>
             <constant>Fallback message</constant>
           </transform>
-        </fallback>
+        </onFallback>
       </hystrix>
       <to uri="mock:result"/>
     </route>


Mime
View raw message