Repository: camel
Updated Branches:
  refs/heads/master 2993c5145 -> 37a15c727


camel-atomix: makes cluster service simpler


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

Branch: refs/heads/master
Commit: c73844880d659267fef9f662a1459c0ca3b6dd4f
Parents: 2993c51
Author: lburgazzoli <lburgazz...@gmail.com>
Authored: Mon Jun 26 15:26:25 2017 +0200
Committer: lburgazzoli <lburgazz...@gmail.com>
Committed: Mon Jun 26 15:26:25 2017 +0200

----------------------------------------------------------------------
 .../atomix/AtomixConfigurationAware.java        | 29 --------------------
 .../atomix/ha/AtomixClusterClientService.java   |  7 ++---
 .../atomix/ha/AtomixClusterService.java         |  7 ++---
 .../component/atomix/ha/AtomixClusterView.java  |  8 ++----
 4 files changed, 7 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/c7384488/components/camel-atomix/src/main/java/org/apache/camel/component/atomix/AtomixConfigurationAware.java
----------------------------------------------------------------------
diff --git 
a/components/camel-atomix/src/main/java/org/apache/camel/component/atomix/AtomixConfigurationAware.java
 
b/components/camel-atomix/src/main/java/org/apache/camel/component/atomix/AtomixConfigurationAware.java
deleted file mode 100644
index b13de80..0000000
--- 
a/components/camel-atomix/src/main/java/org/apache/camel/component/atomix/AtomixConfigurationAware.java
+++ /dev/null
@@ -1,29 +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.component.atomix;
-
-public interface AtomixConfigurationAware<C extends AtomixConfiguration> {
-    /**
-     * @return the configuration
-     */
-    C getConfiguration();
-
-    /**
-     * @param configuration the configuration
-     */
-    void setConfiguration(C configuration);
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/c7384488/components/camel-atomix/src/main/java/org/apache/camel/component/atomix/ha/AtomixClusterClientService.java
----------------------------------------------------------------------
diff --git 
a/components/camel-atomix/src/main/java/org/apache/camel/component/atomix/ha/AtomixClusterClientService.java
 
b/components/camel-atomix/src/main/java/org/apache/camel/component/atomix/ha/AtomixClusterClientService.java
index 00695c0..cc135ca 100644
--- 
a/components/camel-atomix/src/main/java/org/apache/camel/component/atomix/ha/AtomixClusterClientService.java
+++ 
b/components/camel-atomix/src/main/java/org/apache/camel/component/atomix/ha/AtomixClusterClientService.java
@@ -22,7 +22,6 @@ import io.atomix.AtomixClient;
 import io.atomix.catalyst.transport.Address;
 import io.atomix.catalyst.transport.Transport;
 import org.apache.camel.CamelContext;
-import org.apache.camel.component.atomix.AtomixConfigurationAware;
 import org.apache.camel.component.atomix.client.AtomixClientConfiguration;
 import org.apache.camel.component.atomix.client.AtomixClientHelper;
 import org.apache.camel.impl.ha.AbstractCamelClusterService;
@@ -30,7 +29,7 @@ import org.apache.camel.util.ObjectHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public final class AtomixClusterClientService extends 
AbstractCamelClusterService<AtomixClusterView> implements 
AtomixConfigurationAware<AtomixClientConfiguration> {
+public final class AtomixClusterClientService extends 
AbstractCamelClusterService<AtomixClusterView> {
     private static final Logger LOGGER = 
LoggerFactory.getLogger(AtomixClusterClientService.class);
     private AtomixClientConfiguration configuration;
     private AtomixClient atomix;
@@ -49,12 +48,10 @@ public final class AtomixClusterClientService extends 
AbstractCamelClusterServic
     // Properties
     // **********************************
 
-    @Override
     public AtomixClientConfiguration getConfiguration() {
         return configuration;
     }
 
-    @Override
     public void setConfiguration(AtomixClientConfiguration configuration) {
         this.configuration = configuration.copy();
     }
@@ -109,7 +106,7 @@ public final class AtomixClusterClientService extends 
AbstractCamelClusterServic
 
     @Override
     protected AtomixClusterView createView(String namespace) throws Exception {
-        return new AtomixClusterView(this, namespace, getOrCreateClient());
+        return new AtomixClusterView(this, namespace, getOrCreateClient(), 
configuration);
     }
 
     private AtomixClient getOrCreateClient() throws Exception {

http://git-wip-us.apache.org/repos/asf/camel/blob/c7384488/components/camel-atomix/src/main/java/org/apache/camel/component/atomix/ha/AtomixClusterService.java
----------------------------------------------------------------------
diff --git 
a/components/camel-atomix/src/main/java/org/apache/camel/component/atomix/ha/AtomixClusterService.java
 
b/components/camel-atomix/src/main/java/org/apache/camel/component/atomix/ha/AtomixClusterService.java
index a5a8e51..a7901ce 100644
--- 
a/components/camel-atomix/src/main/java/org/apache/camel/component/atomix/ha/AtomixClusterService.java
+++ 
b/components/camel-atomix/src/main/java/org/apache/camel/component/atomix/ha/AtomixClusterService.java
@@ -23,13 +23,12 @@ import io.atomix.catalyst.transport.Address;
 import io.atomix.catalyst.transport.Transport;
 import io.atomix.copycat.server.storage.StorageLevel;
 import org.apache.camel.CamelContext;
-import org.apache.camel.component.atomix.AtomixConfigurationAware;
 import org.apache.camel.impl.ha.AbstractCamelClusterService;
 import org.apache.camel.util.ObjectHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public final class AtomixClusterService extends 
AbstractCamelClusterService<AtomixClusterView>  implements 
AtomixConfigurationAware<AtomixClusterConfiguration> {
+public final class AtomixClusterService extends 
AbstractCamelClusterService<AtomixClusterView> {
     private static final Logger LOGGER = 
LoggerFactory.getLogger(AtomixClusterService.class);
 
     private Address address;
@@ -63,12 +62,10 @@ public final class AtomixClusterService extends 
AbstractCamelClusterService<Atom
         this.address = address;
     }
 
-    @Override
     public AtomixClusterConfiguration getConfiguration() {
         return configuration;
     }
 
-    @Override
     public void setConfiguration(AtomixClusterConfiguration configuration) {
         this.configuration = configuration.copy();
     }
@@ -139,7 +136,7 @@ public final class AtomixClusterService extends 
AbstractCamelClusterService<Atom
 
     @Override
     protected AtomixClusterView createView(String namespace) throws Exception {
-        return new AtomixClusterView(this, namespace, getOrCreateReplica());
+        return new AtomixClusterView(this, namespace, getOrCreateReplica(), 
configuration);
     }
 
     private AtomixReplica getOrCreateReplica() throws Exception {

http://git-wip-us.apache.org/repos/asf/camel/blob/c7384488/components/camel-atomix/src/main/java/org/apache/camel/component/atomix/ha/AtomixClusterView.java
----------------------------------------------------------------------
diff --git 
a/components/camel-atomix/src/main/java/org/apache/camel/component/atomix/ha/AtomixClusterView.java
 
b/components/camel-atomix/src/main/java/org/apache/camel/component/atomix/ha/AtomixClusterView.java
index 62104a7..c7bbf2d 100644
--- 
a/components/camel-atomix/src/main/java/org/apache/camel/component/atomix/ha/AtomixClusterView.java
+++ 
b/components/camel-atomix/src/main/java/org/apache/camel/component/atomix/ha/AtomixClusterView.java
@@ -27,7 +27,6 @@ import io.atomix.group.DistributedGroup;
 import io.atomix.group.GroupMember;
 import io.atomix.group.LocalMember;
 import org.apache.camel.component.atomix.AtomixConfiguration;
-import org.apache.camel.component.atomix.AtomixConfigurationAware;
 import org.apache.camel.ha.CamelClusterMember;
 import org.apache.camel.ha.CamelClusterService;
 import org.apache.camel.impl.ha.AbstractCamelClusterView;
@@ -40,12 +39,14 @@ final class AtomixClusterView extends 
AbstractCamelClusterView {
 
     private final Atomix atomix;
     private final AtomixLocalMember localMember;
+    private final AtomixConfiguration<?> configuration;
     private DistributedGroup group;
 
-    AtomixClusterView(CamelClusterService cluster, String namespace, Atomix 
atomix) {
+    AtomixClusterView(CamelClusterService cluster, String namespace, Atomix 
atomix, AtomixConfiguration<?> configuration) {
         super(cluster, namespace);
 
         this.atomix = atomix;
+        this.configuration = configuration;
         this.localMember = new AtomixLocalMember();
     }
 
@@ -89,9 +90,6 @@ final class AtomixClusterView extends 
AbstractCamelClusterView {
         if (!localMember.hasJoined()) {
             LOGGER.debug("Get group {}", getNamespace());
 
-            final AtomixConfigurationAware service = 
AtomixConfigurationAware.class.cast(getClusterService());
-            final AtomixConfiguration<?> configuration = 
service.getConfiguration();
-
             group = this.atomix.getGroup(
                 getNamespace(),
                 new 
DistributedGroup.Config(configuration.getResourceConfig(getNamespace())),

Reply via email to