You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2017/06/16 15:39:03 UTC

[02/13] camel git commit: CAMEL-11362: create a LeaderElectionservice

CAMEL-11362: create a LeaderElectionservice


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

Branch: refs/heads/master
Commit: 21b65d965ff8f3eeecaf7aa3fbc599e5e3b23ace
Parents: 4907665
Author: lburgazzoli <lb...@gmail.com>
Authored: Thu Jun 1 19:27:09 2017 +0200
Committer: lburgazzoli <lb...@gmail.com>
Committed: Fri Jun 16 17:37:53 2017 +0200

----------------------------------------------------------------------
 .../apache/camel/ha/CamelClusterFactory.java    | 27 -----------------
 .../apache/camel/ha/CamelClusterService.java    | 31 ++++++++++++++++++++
 .../camel/impl/ha/AbstractCamelClusterView.java |  4 +--
 .../camel/impl/ha/ClusteredRoutePolicy.java     |  7 +++--
 4 files changed, 38 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/21b65d96/camel-core/src/main/java/org/apache/camel/ha/CamelClusterFactory.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/ha/CamelClusterFactory.java b/camel-core/src/main/java/org/apache/camel/ha/CamelClusterFactory.java
deleted file mode 100644
index be332b4..0000000
--- a/camel-core/src/main/java/org/apache/camel/ha/CamelClusterFactory.java
+++ /dev/null
@@ -1,27 +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.ha;
-
-import org.apache.camel.CamelContext;
-
-@FunctionalInterface
-public interface CamelClusterFactory {
-    /**
-     * Creates an instance of a cluster.
-     */
-    CamelCluster newInstance(CamelContext camelContext) throws Exception;
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/21b65d96/camel-core/src/main/java/org/apache/camel/ha/CamelClusterService.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/ha/CamelClusterService.java b/camel-core/src/main/java/org/apache/camel/ha/CamelClusterService.java
new file mode 100644
index 0000000..004eab3
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/ha/CamelClusterService.java
@@ -0,0 +1,31 @@
+/**
+ * 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.ha;
+
+import org.apache.camel.Service;
+
+public interface CamelClusterService extends Service {
+    /**
+     * Get the {@linke CamelCluster} instance managed by the service
+     */
+    CamelCluster getCluster() throws Exception;
+
+    /**
+     * Create a {@linke CamelClusterView} for the given namespace
+     */
+    CamelClusterView createView(String namespace) throws Exception;
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/21b65d96/camel-core/src/main/java/org/apache/camel/impl/ha/AbstractCamelClusterView.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/ha/AbstractCamelClusterView.java b/camel-core/src/main/java/org/apache/camel/impl/ha/AbstractCamelClusterView.java
index 1149a7f..8fc9c27 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/ha/AbstractCamelClusterView.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/ha/AbstractCamelClusterView.java
@@ -48,12 +48,12 @@ public abstract class AbstractCamelClusterView extends ServiceSupport implements
 
     @Override
     public CamelContext getCamelContext() {
-        return null;
+        return camelContext;
     }
 
     @Override
     public CamelCluster getCluster() {
-        return  this.cluster;
+        return this.cluster;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/21b65d96/camel-core/src/main/java/org/apache/camel/impl/ha/ClusteredRoutePolicy.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/ha/ClusteredRoutePolicy.java b/camel-core/src/main/java/org/apache/camel/impl/ha/ClusteredRoutePolicy.java
index 4aa1fa2..b08cddb 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/ha/ClusteredRoutePolicy.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/ha/ClusteredRoutePolicy.java
@@ -247,10 +247,13 @@ public final class ClusteredRoutePolicy extends RoutePolicySupport implements Ca
     // ****************************************************
 
     public static ClusteredRoutePolicy forNamespace(CamelCluster cluster, String namespace) throws Exception {
-        return new ClusteredRoutePolicy(cluster.createView(namespace));
+        return forView(cluster.createView(namespace));
     }
 
     public static ClusteredRoutePolicy forView(CamelClusterView view) throws Exception  {
-        return new ClusteredRoutePolicy(view);
+        ClusteredRoutePolicy policy = new ClusteredRoutePolicy(view);
+        policy.setCamelContext(view.getCamelContext());
+
+        return policy;
     }
 }