Repository: camel Updated Branches: refs/heads/master 8e14a77d2 -> bf82a5ed1
http://git-wip-us.apache.org/repos/asf/camel/blob/bf82a5ed/components/camel-zookeeper-master/src/test/java/org/apache/camel/component/zookeepermaster/group/GroupTest.java ---------------------------------------------------------------------- diff --git a/components/camel-zookeeper-master/src/test/java/org/apache/camel/component/zookeepermaster/group/GroupTest.java b/components/camel-zookeeper-master/src/test/java/org/apache/camel/component/zookeepermaster/group/GroupTest.java new file mode 100644 index 0000000..6bc5757 --- /dev/null +++ b/components/camel-zookeeper-master/src/test/java/org/apache/camel/component/zookeepermaster/group/GroupTest.java @@ -0,0 +1,388 @@ +/** + * 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.zookeepermaster.group; + +import java.io.File; +import java.net.ServerSocket; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +import org.apache.camel.component.zookeepermaster.group.internal.ChildData; +import org.apache.camel.component.zookeepermaster.group.internal.ZooKeeperGroup; +import org.apache.curator.framework.CuratorFramework; +import org.apache.curator.framework.CuratorFrameworkFactory; +import org.apache.curator.retry.RetryNTimes; +import org.apache.zookeeper.server.NIOServerCnxnFactory; +import org.apache.zookeeper.server.ServerConfig; +import org.apache.zookeeper.server.ZooKeeperServer; +import org.apache.zookeeper.server.persistence.FileTxnSnapLog; +import org.junit.Test; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertTrue; + +public class GroupTest { + + private GroupListener listener = new GroupListener<NodeState>() { + @Override + public void groupEvent(Group<NodeState> group, GroupListener.GroupEvent event) { + boolean connected = group.isConnected(); + boolean master = group.isMaster(); + if (connected) { + Collection<NodeState> members = group.members().values(); + System.err.println("GroupEvent: " + event + " (connected=" + connected + ", master=" + master + ", members=" + members + ")"); + } else { + System.err.println("GroupEvent: " + event + " (connected=" + connected + ", master=false)"); + } + } + }; + + private int findFreePort() throws Exception { + ServerSocket ss = new ServerSocket(0); + int port = ss.getLocalPort(); + ss.close(); + return port; + } + + private NIOServerCnxnFactory startZooKeeper(int port) throws Exception { + ServerConfig cfg = new ServerConfig(); + cfg.parse(new String[] {Integer.toString(port), "target/zk/data"}); + + ZooKeeperServer zkServer = new ZooKeeperServer(); + FileTxnSnapLog ftxn = new FileTxnSnapLog(new File(cfg.getDataLogDir()), new File(cfg.getDataDir())); + zkServer.setTxnLogFactory(ftxn); + zkServer.setTickTime(cfg.getTickTime()); + zkServer.setMinSessionTimeout(6000); + zkServer.setMaxSessionTimeout(9000); + NIOServerCnxnFactory cnxnFactory = new NIOServerCnxnFactory(); + cnxnFactory.configure(cfg.getClientPortAddress(), cfg.getMaxClientCnxns()); + cnxnFactory.startup(zkServer); + return cnxnFactory; + } + + + @Test + public void testOrder() throws Exception { + int port = findFreePort(); + + CuratorFramework curator = CuratorFrameworkFactory.builder() + .connectString("localhost:" + port) + .retryPolicy(new RetryNTimes(10, 100)) + .build(); + curator.start(); + + + final String path = "/singletons/test/Order" + System.currentTimeMillis(); + ArrayList<ZooKeeperGroup> members = new ArrayList<ZooKeeperGroup>(); + for (int i = 0; i < 4; i++) { + ZooKeeperGroup<NodeState> group = new ZooKeeperGroup<NodeState>(curator, path, NodeState.class); + group.add(listener); + members.add(group); + } + + for (ZooKeeperGroup group : members) { + assertFalse(group.isConnected()); + assertFalse(group.isMaster()); + } + + NIOServerCnxnFactory cnxnFactory = startZooKeeper(port); + + curator.getZookeeperClient().blockUntilConnectedOrTimedOut(); + + // first to start should be master if members are ordered... + int i = 0; + for (ZooKeeperGroup group : members) { + group.start(); + group.update(new NodeState("foo" + i)); + i++; + + // wait for registration + while (group.getId() == null) { + TimeUnit.MILLISECONDS.sleep(100); + } + } + + boolean firsStartedIsMaster = members.get(0).isMaster(); + + for (ZooKeeperGroup group : members) { + group.close(); + } + curator.close(); + cnxnFactory.shutdown(); + cnxnFactory.join(); + + assertTrue("first started is master", firsStartedIsMaster); + + } + + @Test + public void testJoinAfterConnect() throws Exception { + int port = findFreePort(); + + CuratorFramework curator = CuratorFrameworkFactory.builder() + .connectString("localhost:" + port) + .retryPolicy(new RetryNTimes(10, 100)) + .build(); + curator.start(); + + final Group<NodeState> group = new ZooKeeperGroup<NodeState>(curator, "/singletons/test" + System.currentTimeMillis(), NodeState.class); + group.add(listener); + group.start(); + + assertFalse(group.isConnected()); + assertFalse(group.isMaster()); + + GroupCondition groupCondition = new GroupCondition(); + group.add(groupCondition); + + NIOServerCnxnFactory cnxnFactory = startZooKeeper(port); + + curator.getZookeeperClient().blockUntilConnectedOrTimedOut(); + + assertTrue(groupCondition.waitForConnected(5, TimeUnit.SECONDS)); + assertFalse(group.isMaster()); + + group.update(new NodeState("foo")); + assertTrue(groupCondition.waitForMaster(5, TimeUnit.SECONDS)); + + + group.close(); + curator.close(); + cnxnFactory.shutdown(); + cnxnFactory.join(); + } + + @Test + public void testJoinBeforeConnect() throws Exception { + int port = findFreePort(); + + CuratorFramework curator = CuratorFrameworkFactory.builder() + .connectString("localhost:" + port) + .retryPolicy(new RetryNTimes(10, 100)) + .build(); + curator.start(); + + Group<NodeState> group = new ZooKeeperGroup<NodeState>(curator, "/singletons/test" + System.currentTimeMillis(), NodeState.class); + group.add(listener); + group.start(); + + GroupCondition groupCondition = new GroupCondition(); + group.add(groupCondition); + + assertFalse(group.isConnected()); + assertFalse(group.isMaster()); + group.update(new NodeState("foo")); + + NIOServerCnxnFactory cnxnFactory = startZooKeeper(port); + + curator.getZookeeperClient().blockUntilConnectedOrTimedOut(); + + assertTrue(groupCondition.waitForConnected(5, TimeUnit.SECONDS)); + assertTrue(groupCondition.waitForMaster(5, TimeUnit.SECONDS)); + + + group.close(); + curator.close(); + cnxnFactory.shutdown(); + cnxnFactory.join(); + } + + @Test + public void testRejoinAfterDisconnect() throws Exception { + int port = findFreePort(); + + CuratorFramework curator = CuratorFrameworkFactory.builder() + .connectString("localhost:" + port) + .retryPolicy(new RetryNTimes(10, 100)) + .build(); + curator.start(); + + NIOServerCnxnFactory cnxnFactory = startZooKeeper(port); + Group<NodeState> group = new ZooKeeperGroup<NodeState>(curator, "/singletons/test" + System.currentTimeMillis(), NodeState.class); + group.add(listener); + group.update(new NodeState("foo")); + group.start(); + + GroupCondition groupCondition = new GroupCondition(); + group.add(groupCondition); + + curator.getZookeeperClient().blockUntilConnectedOrTimedOut(); + assertTrue(groupCondition.waitForConnected(5, TimeUnit.SECONDS)); + assertTrue(groupCondition.waitForMaster(5, TimeUnit.SECONDS)); + + cnxnFactory.shutdown(); + cnxnFactory.join(); + + groupCondition.waitForDisconnected(5, TimeUnit.SECONDS); + group.remove(groupCondition); + + assertFalse(group.isConnected()); + assertFalse(group.isMaster()); + + groupCondition = new GroupCondition(); + group.add(groupCondition); + + cnxnFactory = startZooKeeper(port); + + curator.getZookeeperClient().blockUntilConnectedOrTimedOut(); + curator.getZookeeperClient().blockUntilConnectedOrTimedOut(); + assertTrue(groupCondition.waitForConnected(5, TimeUnit.SECONDS)); + assertTrue(groupCondition.waitForMaster(5, TimeUnit.SECONDS)); + + + group.close(); + curator.close(); + cnxnFactory.shutdown(); + cnxnFactory.join(); + } + + //Tests that if close() is executed right after start(), there are no left over entries. + //(see https://github.com/jboss-fuse/fuse/issues/133) + @Test + public void testGroupClose() throws Exception { + int port = findFreePort(); + NIOServerCnxnFactory cnxnFactory = startZooKeeper(port); + + CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder() + .connectString("localhost:" + port) + .connectionTimeoutMs(6000) + .sessionTimeoutMs(6000) + .retryPolicy(new RetryNTimes(10, 100)); + CuratorFramework curator = builder.build(); + curator.start(); + curator.getZookeeperClient().blockUntilConnectedOrTimedOut(); + String groupNode = "/singletons/test" + System.currentTimeMillis(); + curator.create().creatingParentsIfNeeded().forPath(groupNode); + + for (int i = 0; i < 100; i++) { + ZooKeeperGroup<NodeState> group = new ZooKeeperGroup<NodeState>(curator, groupNode, NodeState.class); + group.add(listener); + group.update(new NodeState("foo")); + group.start(); + group.close(); + List<String> entries = curator.getChildren().forPath(groupNode); + assertTrue(entries.isEmpty() || group.isUnstable()); + if (group.isUnstable()) { + // let's wait for session timeout + curator.close(); + curator = builder.build(); + curator.start(); + curator.getZookeeperClient().blockUntilConnectedOrTimedOut(); + } + } + + curator.close(); + cnxnFactory.shutdown(); + cnxnFactory.join(); + } + + @Test + public void testAddFieldIgnoredOnParse() throws Exception { + + int port = findFreePort(); + NIOServerCnxnFactory cnxnFactory = startZooKeeper(port); + + CuratorFramework curator = CuratorFrameworkFactory.builder() + .connectString("localhost:" + port) + .retryPolicy(new RetryNTimes(10, 100)) + .build(); + curator.start(); + curator.getZookeeperClient().blockUntilConnectedOrTimedOut(); + String groupNode = "/singletons/test" + System.currentTimeMillis(); + curator.create().creatingParentsIfNeeded().forPath(groupNode); + + curator.getZookeeperClient().blockUntilConnectedOrTimedOut(); + + final ZooKeeperGroup<NodeState> group = new ZooKeeperGroup<NodeState>(curator, groupNode, NodeState.class); + group.add(listener); + group.start(); + + GroupCondition groupCondition = new GroupCondition(); + group.add(groupCondition); + + group.update(new NodeState("foo")); + + assertTrue(groupCondition.waitForConnected(5, TimeUnit.SECONDS)); + assertTrue(groupCondition.waitForMaster(5, TimeUnit.SECONDS)); + + ChildData currentData = group.getCurrentData().get(0); + final int version = currentData.getStat().getVersion(); + + NodeState lastState = group.getLastState(); + String json = lastState.toString(); + System.err.println("JSON:" + json); + + String newValWithNewField = json.substring(0, json.lastIndexOf('}')) + ",\"Rubbish\":\"Rubbish\"}"; + curator.getZookeeperClient().getZooKeeper().setData(group.getId(), newValWithNewField.getBytes(), version); + + assertTrue(group.isMaster()); + + int attempts = 0; + while (attempts++ < 5 && version == group.getCurrentData().get(0).getStat().getVersion()) { + TimeUnit.SECONDS.sleep(1); + } + + assertNotEquals("We see the updated version", version, group.getCurrentData().get(0).getStat().getVersion()); + + System.err.println("CurrentData:" + group.getCurrentData()); + + group.close(); + curator.close(); + cnxnFactory.shutdown(); + cnxnFactory.join(); + } + + private class GroupCondition implements GroupListener<NodeState> { + private CountDownLatch connected = new CountDownLatch(1); + private CountDownLatch master = new CountDownLatch(1); + private CountDownLatch disconnected = new CountDownLatch(1); + + @Override + public void groupEvent(Group<NodeState> group, GroupEvent event) { + switch (event) { + case CONNECTED: + case CHANGED: + connected.countDown(); + if (group.isMaster()) { + master.countDown(); + } + break; + case DISCONNECTED: + disconnected.countDown(); + break; + default: + // noop + } + } + + public boolean waitForConnected(long time, TimeUnit timeUnit) throws InterruptedException { + return connected.await(time, timeUnit); + } + + public boolean waitForDisconnected(long time, TimeUnit timeUnit) throws InterruptedException { + return disconnected.await(time, timeUnit); + } + + public boolean waitForMaster(long time, TimeUnit timeUnit) throws InterruptedException { + return master.await(time, timeUnit); + } + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/bf82a5ed/components/camel-zookeeper-master/src/test/java/org/apache/camel/component/zookeepermaster/group/internal/ZooKeeperGroupTest.java ---------------------------------------------------------------------- diff --git a/components/camel-zookeeper-master/src/test/java/org/apache/camel/component/zookeepermaster/group/internal/ZooKeeperGroupTest.java b/components/camel-zookeeper-master/src/test/java/org/apache/camel/component/zookeepermaster/group/internal/ZooKeeperGroupTest.java new file mode 100644 index 0000000..9e00621 --- /dev/null +++ b/components/camel-zookeeper-master/src/test/java/org/apache/camel/component/zookeepermaster/group/internal/ZooKeeperGroupTest.java @@ -0,0 +1,232 @@ +/** + * 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.zookeepermaster.group.internal; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.net.ServerSocket; +import java.util.List; +import java.util.Map; + +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.camel.component.zookeepermaster.group.NodeState; +import org.apache.curator.framework.CuratorFramework; +import org.apache.curator.framework.CuratorFrameworkFactory; +import org.apache.curator.retry.RetryOneTime; +import org.apache.zookeeper.data.Stat; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.junit.Assert.assertThat; + +public class ZooKeeperGroupTest { + + private static final String PATH = "/singletons/test/" + ZooKeeperGroupTest.class.getSimpleName(); + + private CuratorFramework curator; + private ZooKeeperGroup<NodeState> group; + + private int findFreePort() throws Exception { + ServerSocket ss = new ServerSocket(0); + int port = ss.getLocalPort(); + ss.close(); + return port; + } + + @Before + public void setUp() throws Exception { + int port = findFreePort(); + curator = CuratorFrameworkFactory.builder() + .connectString("localhost:" + port) + .retryPolicy(new RetryOneTime(1)) + .build(); + //curator.start(); + group = new ZooKeeperGroup<>(curator, PATH, NodeState.class); + //group.start(); + // Starting curator and group is not necessary for the current tests. + } + + @After + public void tearDown() throws IOException { + group.close(); + curator.close(); + group = null; + curator = null; + } + + private static void putChildData(ZooKeeperGroup<NodeState> group, String path, String container) throws Exception { + NodeState node = new NodeState("test", container); + ByteArrayOutputStream data = new ByteArrayOutputStream(); + new ObjectMapper().disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES).writeValue(data, node); + ChildData<NodeState> child = new ChildData<>(path, new Stat(), data.toByteArray(), node); + group.putCurrentData(path, child); + } + + @Test + public void testMembers() throws Exception { + putChildData(group, PATH + "/001", "container1"); + putChildData(group, PATH + "/002", "container2"); + putChildData(group, PATH + "/003", "container3"); + + Map<String, NodeState> members = group.members(); + assertThat(members.size(), equalTo(3)); + assertThat(members.get(PATH + "/001").getContainer(), equalTo("container1")); + assertThat(members.get(PATH + "/002").getContainer(), equalTo("container2")); + assertThat(members.get(PATH + "/003").getContainer(), equalTo("container3")); + } + + @Test + public void testMembersWithStaleNodes() throws Exception { + putChildData(group, PATH + "/001", "container1"); // stale + putChildData(group, PATH + "/002", "container1"); + putChildData(group, PATH + "/003", "container2"); // stale + putChildData(group, PATH + "/004", "container3"); // stale + putChildData(group, PATH + "/005", "container2"); + putChildData(group, PATH + "/006", "container3"); + + Map<String, NodeState> members = group.members(); + assertThat(members.size(), equalTo(3)); + assertThat(members.get(PATH + "/002").getContainer(), equalTo("container1")); + assertThat(members.get(PATH + "/005").getContainer(), equalTo("container2")); + assertThat(members.get(PATH + "/006").getContainer(), equalTo("container3")); + } + + @Test + public void testIsMaster() throws Exception { + putChildData(group, PATH + "/001", "container1"); + putChildData(group, PATH + "/002", "container2"); + putChildData(group, PATH + "/003", "container3"); + + group.setId(PATH + "/001"); + assertThat(group.isMaster(), equalTo(true)); + group.setId(PATH + "/002"); + assertThat(group.isMaster(), equalTo(false)); + } + + @Test + public void testIsMasterWithStaleNodes1() throws Exception { + putChildData(group, PATH + "/001", "container1"); // stale + putChildData(group, PATH + "/002", "container1"); + putChildData(group, PATH + "/003", "container2"); // stale + putChildData(group, PATH + "/004", "container3"); // stale + putChildData(group, PATH + "/005", "container2"); + putChildData(group, PATH + "/006", "container3"); + + group.setId(PATH + "/002"); + assertThat(group.isMaster(), equalTo(true)); + group.setId(PATH + "/005"); + assertThat(group.isMaster(), equalTo(false)); + } + + @Test + public void testIsMasterWithStaleNodes2() throws Exception { + putChildData(group, PATH + "/001", "container1"); // stale + putChildData(group, PATH + "/002", "container2"); + putChildData(group, PATH + "/003", "container1"); + putChildData(group, PATH + "/004", "container3"); // stale + putChildData(group, PATH + "/005", "container3"); + + group.setId(PATH + "/002"); + assertThat(group.isMaster(), equalTo(true)); + group.setId(PATH + "/003"); + assertThat(group.isMaster(), equalTo(false)); + } + + @Test + public void testMaster() throws Exception { + putChildData(group, PATH + "/001", "container1"); + putChildData(group, PATH + "/002", "container2"); + putChildData(group, PATH + "/003", "container3"); + + NodeState master = group.master(); + assertThat(master, notNullValue()); + assertThat(master.getContainer(), equalTo("container1")); + } + + @Test + public void testMasterWithStaleNodes1() throws Exception { + putChildData(group, PATH + "/001", "container1"); // stale + putChildData(group, PATH + "/002", "container1"); + putChildData(group, PATH + "/003", "container2"); // stale + putChildData(group, PATH + "/004", "container3"); // stale + putChildData(group, PATH + "/005", "container2"); + putChildData(group, PATH + "/006", "container3"); + + NodeState master = group.master(); + assertThat(master, notNullValue()); + assertThat(master.getContainer(), equalTo("container1")); + } + + @Test + public void testMasterWithStaleNodes2() throws Exception { + putChildData(group, PATH + "/001", "container1"); // stale + putChildData(group, PATH + "/002", "container2"); + putChildData(group, PATH + "/003", "container1"); + putChildData(group, PATH + "/004", "container3"); // stale + putChildData(group, PATH + "/005", "container3"); + + NodeState master = group.master(); + assertThat(master, notNullValue()); + assertThat(master.getContainer(), equalTo("container2")); + } + + @Test + public void testSlaves() throws Exception { + putChildData(group, PATH + "/001", "container1"); + putChildData(group, PATH + "/002", "container2"); + putChildData(group, PATH + "/003", "container3"); + + List<NodeState> slaves = group.slaves(); + assertThat(slaves.size(), equalTo(2)); + assertThat(slaves.get(0).getContainer(), equalTo("container2")); + assertThat(slaves.get(1).getContainer(), equalTo("container3")); + } + + @Test + public void testSlavesWithStaleNodes1() throws Exception { + putChildData(group, PATH + "/001", "container1"); // stale + putChildData(group, PATH + "/002", "container1"); + putChildData(group, PATH + "/003", "container2"); // stale + putChildData(group, PATH + "/004", "container3"); // stale + putChildData(group, PATH + "/005", "container2"); + putChildData(group, PATH + "/006", "container3"); + + List<NodeState> slaves = group.slaves(); + assertThat(slaves.size(), equalTo(2)); + assertThat(slaves.get(0).getContainer(), equalTo("container2")); + assertThat(slaves.get(1).getContainer(), equalTo("container3")); + } + + @Test + public void testSlavesWithStaleNodes2() throws Exception { + putChildData(group, PATH + "/001", "container1"); // stale + putChildData(group, PATH + "/002", "container2"); + putChildData(group, PATH + "/003", "container1"); + putChildData(group, PATH + "/004", "container3"); // stale + putChildData(group, PATH + "/005", "container3"); + + List<NodeState> slaves = group.slaves(); + assertThat(slaves.size(), equalTo(2)); + assertThat(slaves.get(0).getContainer(), equalTo("container1")); + assertThat(slaves.get(1).getContainer(), equalTo("container3")); + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/bf82a5ed/components/camel-zookeeper-master/src/test/resources/log4j2.properties ---------------------------------------------------------------------- diff --git a/components/camel-zookeeper-master/src/test/resources/log4j2.properties b/components/camel-zookeeper-master/src/test/resources/log4j2.properties new file mode 100644 index 0000000..409eaf7 --- /dev/null +++ b/components/camel-zookeeper-master/src/test/resources/log4j2.properties @@ -0,0 +1,45 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +appender.file.type = File +appender.file.name = file +appender.file.fileName = target/camel-zookeeper-master-test.log +appender.file.layout.type = PatternLayout +appender.file.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n +appender.out.type = Console +appender.out.name = out +appender.out.layout.type = PatternLayout +# appender.out.layout.pattern = %highlight{%d [%t] %-5level: %msg%n%throwable}{FATAL=red, ERROR=red, WARN=blue, INFO=black, DEBUG=grey, TRACE=blue} +appender.out.layout.pattern = [%t] %c{1} %-5p %m%n + +logger.zookeeper.name = org.apache.zookeeper +logger.zookeeper.level = INFO +logger.camel-zookeeper.name = org.apache.camel.component.zookeepermaster +logger.camel-zookeeper.level = INFO +logger.camel-support.name = org.apache.camel.support +logger.camel-support.level = INFO +logger.camel.name = org.apache.camel +logger.camel.level = INFO + + +logger.springframework.name = org.springframework +logger.springframework.level = WARN +rootLogger.level = INFO +#rootLogger.appenderRef.stdout.ref = out +rootLogger.appenderRef.file.ref = file + + http://git-wip-us.apache.org/repos/asf/camel/blob/bf82a5ed/components/camel-zookeeper-master/src/test/resources/org/apache/camel/component/zookeepermaster/MasterEndpointTest-context.xml ---------------------------------------------------------------------- diff --git a/components/camel-zookeeper-master/src/test/resources/org/apache/camel/component/zookeepermaster/MasterEndpointTest-context.xml b/components/camel-zookeeper-master/src/test/resources/org/apache/camel/component/zookeepermaster/MasterEndpointTest-context.xml new file mode 100644 index 0000000..1e1ca47 --- /dev/null +++ b/components/camel-zookeeper-master/src/test/resources/org/apache/camel/component/zookeepermaster/MasterEndpointTest-context.xml @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. +--> +<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd + http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"> + + <!-- Since this is a test case lets run a local ZK server --> + <bean id="zkServer" class="org.apache.camel.component.zookeepermaster.ZKServerFactoryBean"> + <property name="port" value="9003"/> + </bean> + + <bean id="curator" class="org.apache.camel.component.zookeepermaster.CuratorFactoryBean" depends-on="zkServer"> + <property name="timeout" value="3000"/> + <property name="connectString" value="localhost:9003"/> + </bean> + + <camelContext xmlns="http://camel.apache.org/schema/spring" depends-on="curator"> + + <route> + <from uri="zookeeper-master:master-000:seda:bar"/> + <to uri="mock:results"/> + </route> + + </camelContext> + + <!-- some other stuff here... --> + +</beans> http://git-wip-us.apache.org/repos/asf/camel/blob/bf82a5ed/components/camel-zookeeper-master/src/test/resources/org/apache/camel/component/zookeepermaster/MasterQuartz2EndpointTest-context.xml ---------------------------------------------------------------------- diff --git a/components/camel-zookeeper-master/src/test/resources/org/apache/camel/component/zookeepermaster/MasterQuartz2EndpointTest-context.xml b/components/camel-zookeeper-master/src/test/resources/org/apache/camel/component/zookeepermaster/MasterQuartz2EndpointTest-context.xml new file mode 100644 index 0000000..fe549e3 --- /dev/null +++ b/components/camel-zookeeper-master/src/test/resources/org/apache/camel/component/zookeepermaster/MasterQuartz2EndpointTest-context.xml @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. +--> +<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd + http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"> + + <!-- Since this is a test case lets run a local ZK server --> + <bean id="zkServer" class="org.apache.camel.component.zookeepermaster.ZKServerFactoryBean"> + <property name="port" value="9003"/> + </bean> + + + <bean id="curator" class="org.apache.camel.component.zookeepermaster.CuratorFactoryBean" depends-on="zkServer"> + <property name="timeout" value="3000"/> + <property name="connectString" value="localhost:9003"/> + </bean> + + <camelContext xmlns="http://camel.apache.org/schema/spring" depends-on="curator"> + + <route> + <from uri="zookeeper-master:master-000:quartz2://masterTest?cron=0/2+0/1+*+1/1+*+?+*"/> + + <to uri="mock:results"/> + </route> + + </camelContext> + + <!-- some other stuff here... --> + +</beans> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/bf82a5ed/components/readme.adoc ---------------------------------------------------------------------- diff --git a/components/readme.adoc b/components/readme.adoc index 0d26279..35e9644 100644 --- a/components/readme.adoc +++ b/components/readme.adoc @@ -2,7 +2,7 @@ Components ^^^^^^^^^^ // components: START -Number of Components: 221 in 175 JAR artifacts (13 deprecated) +Number of Components: 222 in 176 JAR artifacts (13 deprecated) [width="100%",cols="4,1,5",options="header"] |======================================================================= @@ -632,7 +632,7 @@ Number of Components: 221 in 175 JAR artifacts (13 deprecated) | link:camel-twitter/src/main/docs/twitter-component.adoc[Twitter] (camel-twitter) + `twitter:kind` | 2.10 | This component integrates with Twitter to send tweets or search for tweets and more. -| link:camel-undertow/src/main/docs/undertow-component.adoc[Undertow] (camel-undertow) + +| link:null/src/main/docs/undertow-component.adoc[Undertow] (null) + `undertow:httpURI` | 2.16 | The undertow component provides HTTP-based endpoints for consuming and producing HTTP requests. | link:../camel-core/src/main/docs/validator-component.adoc[Validator] (camel-core) + @@ -671,6 +671,9 @@ Number of Components: 221 in 175 JAR artifacts (13 deprecated) | link:camel-zookeeper/src/main/docs/zookeeper-component.adoc[ZooKeeper] (camel-zookeeper) + `zookeeper:serverUrls/path` | 2.9 | The zookeeper component allows interaction with a ZooKeeper cluster. +| link:camel-zookeeper-master/src/main/docs/zookeeper-master-component.adoc[ZooKeeper Master] (camel-zookeeper-master) + +`zookeeper-master:name:endpoint` | 2.19 | Represents an endpoint which only becomes active when it obtains the master lock + |======================================================================= // components: END http://git-wip-us.apache.org/repos/asf/camel/blob/bf82a5ed/docs/user-manual/en/SUMMARY.md ---------------------------------------------------------------------- diff --git a/docs/user-manual/en/SUMMARY.md b/docs/user-manual/en/SUMMARY.md index 1edd5ca..e8bd83b 100644 --- a/docs/user-manual/en/SUMMARY.md +++ b/docs/user-manual/en/SUMMARY.md @@ -320,6 +320,7 @@ * [XQuery](xquery-component.adoc) * [Yammer](yammer-component.adoc) * [ZooKeeper](zookeeper-component.adoc) + * [ZooKeeper Master](zookeeper-master-component.adoc) <!-- components: END --> http://git-wip-us.apache.org/repos/asf/camel/blob/bf82a5ed/parent/pom.xml ---------------------------------------------------------------------- diff --git a/parent/pom.xml b/parent/pom.xml index 0e95441..ee6d05a 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -2037,6 +2037,11 @@ <artifactId>camel-zookeeper</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-zookeeper-master</artifactId> + <version>${project.version}</version> + </dependency> <!-- camel catalog --> <dependency> http://git-wip-us.apache.org/repos/asf/camel/blob/bf82a5ed/platforms/spring-boot/components-starter/camel-zookeeper-master-starter/pom.xml ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-zookeeper-master-starter/pom.xml b/platforms/spring-boot/components-starter/camel-zookeeper-master-starter/pom.xml new file mode 100644 index 0000000..a7abe74 --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-zookeeper-master-starter/pom.xml @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.camel</groupId> + <artifactId>components-starter</artifactId> + <version>2.19.0-SNAPSHOT</version> + </parent> + <artifactId>camel-zookeeper-master-starter</artifactId> + <packaging>jar</packaging> + <name>Spring-Boot Starter :: Camel :: Zookeeper Master</name> + <description>Spring-Boot Starter for Camel Zookeeper Master Support</description> + <dependencies> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter</artifactId> + <version>${spring-boot-version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-zookeeper-master</artifactId> + <version>${project.version}</version> + </dependency> + <!--START OF GENERATED CODE--> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-core-starter</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-spring-boot-starter</artifactId> + </dependency> + <!--END OF GENERATED CODE--> + </dependencies> +</project> http://git-wip-us.apache.org/repos/asf/camel/blob/bf82a5ed/platforms/spring-boot/components-starter/camel-zookeeper-master-starter/src/main/java/org/apache/camel/component/zookeepermaster/springboot/MasterComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-zookeeper-master-starter/src/main/java/org/apache/camel/component/zookeepermaster/springboot/MasterComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-zookeeper-master-starter/src/main/java/org/apache/camel/component/zookeepermaster/springboot/MasterComponentAutoConfiguration.java new file mode 100644 index 0000000..5afd8cc --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-zookeeper-master-starter/src/main/java/org/apache/camel/component/zookeepermaster/springboot/MasterComponentAutoConfiguration.java @@ -0,0 +1,110 @@ +/** + * 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.zookeepermaster.springboot; + +import java.util.HashMap; +import java.util.Map; +import org.apache.camel.CamelContext; +import org.apache.camel.component.zookeepermaster.MasterComponent; +import org.apache.camel.util.IntrospectionSupport; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionMessage; +import org.springframework.boot.autoconfigure.condition.ConditionOutcome; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.SpringBootCondition; +import org.springframework.boot.bind.RelaxedPropertyResolver; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ConditionContext; +import org.springframework.context.annotation.Conditional; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Lazy; +import org.springframework.core.type.AnnotatedTypeMetadata; + +/** + * Generated by camel-package-maven-plugin - do not edit this file! + */ +@Configuration +@ConditionalOnBean(type = "org.apache.camel.spring.boot.CamelAutoConfiguration") +@Conditional(MasterComponentAutoConfiguration.Condition.class) +@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") +@EnableConfigurationProperties(MasterComponentConfiguration.class) +public class MasterComponentAutoConfiguration { + + @Lazy + @Bean(name = "zookeeper-master-component") + @ConditionalOnClass(CamelContext.class) + @ConditionalOnMissingBean(MasterComponent.class) + public MasterComponent configureMasterComponent(CamelContext camelContext, + MasterComponentConfiguration configuration) throws Exception { + MasterComponent component = new MasterComponent(); + component.setCamelContext(camelContext); + Map<String, Object> parameters = new HashMap<>(); + IntrospectionSupport.getProperties(configuration, parameters, null, + false); + for (Map.Entry<String, Object> entry : parameters.entrySet()) { + Object value = entry.getValue(); + Class<?> paramClass = value.getClass(); + if (paramClass.getName().endsWith("NestedConfiguration")) { + Class nestedClass = null; + try { + nestedClass = (Class) paramClass.getDeclaredField( + "CAMEL_NESTED_CLASS").get(null); + HashMap<String, Object> nestedParameters = new HashMap<>(); + IntrospectionSupport.getProperties(value, nestedParameters, + null, false); + Object nestedProperty = nestedClass.newInstance(); + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), nestedProperty, + nestedParameters); + entry.setValue(nestedProperty); + } catch (NoSuchFieldException e) { + } + } + } + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), component, parameters); + return component; + } + + public static class Condition extends SpringBootCondition { + @Override + public ConditionOutcome getMatchOutcome( + ConditionContext conditionContext, + AnnotatedTypeMetadata annotatedTypeMetadata) { + boolean groupEnabled = isEnabled(conditionContext, + "camel.component.", true); + ConditionMessage.Builder message = ConditionMessage + .forCondition("camel.component.zookeeper-master"); + if (isEnabled(conditionContext, + "camel.component.zookeeper-master.", groupEnabled)) { + return ConditionOutcome.match(message.because("enabled")); + } + return ConditionOutcome.noMatch(message.because("not enabled")); + } + + private boolean isEnabled( + org.springframework.context.annotation.ConditionContext context, + java.lang.String prefix, boolean defaultValue) { + RelaxedPropertyResolver resolver = new RelaxedPropertyResolver( + context.getEnvironment(), prefix); + return resolver.getProperty("enabled", Boolean.class, defaultValue); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/bf82a5ed/platforms/spring-boot/components-starter/camel-zookeeper-master-starter/src/main/java/org/apache/camel/component/zookeepermaster/springboot/MasterComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-zookeeper-master-starter/src/main/java/org/apache/camel/component/zookeepermaster/springboot/MasterComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-zookeeper-master-starter/src/main/java/org/apache/camel/component/zookeepermaster/springboot/MasterComponentConfiguration.java new file mode 100644 index 0000000..8408447 --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-zookeeper-master-starter/src/main/java/org/apache/camel/component/zookeepermaster/springboot/MasterComponentConfiguration.java @@ -0,0 +1,111 @@ +/** + * 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.zookeepermaster.springboot; + +import org.apache.curator.framework.CuratorFramework; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +/** + * Represents an endpoint which only becomes active when it obtains the master + * lock + * + * Generated by camel-package-maven-plugin - do not edit this file! + */ +@ConfigurationProperties(prefix = "camel.component.zookeeper-master") +public class MasterComponentConfiguration { + + /** + * The root path to use in zookeeper where information is stored which nodes + * are master/slave etc. Will by default use: + * /camel/zookeepermaster/clusters/master + */ + private String zkRoot = "/camel/zookeepermaster/clusters/master"; + /** + * To use a custom configured CuratorFramework as connection to zookeeper + * ensemble. + */ + @NestedConfigurationProperty + private CuratorFramework curator; + /** + * Timeout in millis to use when connecting to the zookeeper ensemble + */ + private Integer maximumConnectionTimeout = 10000; + /** + * The url for the zookeeper ensemble + */ + private String zooKeeperUrl = "localhost:2181"; + /** + * The password to use when connecting to the zookeeper ensemble + */ + private String zooKeeperPassword; + /** + * Whether the component should resolve property placeholders on itself when + * starting. Only properties which are of String type can use property + * placeholders. + */ + private Boolean resolvePropertyPlaceholders = true; + + public String getZkRoot() { + return zkRoot; + } + + public void setZkRoot(String zkRoot) { + this.zkRoot = zkRoot; + } + + public CuratorFramework getCurator() { + return curator; + } + + public void setCurator(CuratorFramework curator) { + this.curator = curator; + } + + public Integer getMaximumConnectionTimeout() { + return maximumConnectionTimeout; + } + + public void setMaximumConnectionTimeout(Integer maximumConnectionTimeout) { + this.maximumConnectionTimeout = maximumConnectionTimeout; + } + + public String getZooKeeperUrl() { + return zooKeeperUrl; + } + + public void setZooKeeperUrl(String zooKeeperUrl) { + this.zooKeeperUrl = zooKeeperUrl; + } + + public String getZooKeeperPassword() { + return zooKeeperPassword; + } + + public void setZooKeeperPassword(String zooKeeperPassword) { + this.zooKeeperPassword = zooKeeperPassword; + } + + public Boolean getResolvePropertyPlaceholders() { + return resolvePropertyPlaceholders; + } + + public void setResolvePropertyPlaceholders( + Boolean resolvePropertyPlaceholders) { + this.resolvePropertyPlaceholders = resolvePropertyPlaceholders; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/bf82a5ed/platforms/spring-boot/components-starter/camel-zookeeper-master-starter/src/main/resources/META-INF/LICENSE.txt ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-zookeeper-master-starter/src/main/resources/META-INF/LICENSE.txt b/platforms/spring-boot/components-starter/camel-zookeeper-master-starter/src/main/resources/META-INF/LICENSE.txt new file mode 100644 index 0000000..6b0b127 --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-zookeeper-master-starter/src/main/resources/META-INF/LICENSE.txt @@ -0,0 +1,203 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. + http://git-wip-us.apache.org/repos/asf/camel/blob/bf82a5ed/platforms/spring-boot/components-starter/camel-zookeeper-master-starter/src/main/resources/META-INF/NOTICE.txt ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-zookeeper-master-starter/src/main/resources/META-INF/NOTICE.txt b/platforms/spring-boot/components-starter/camel-zookeeper-master-starter/src/main/resources/META-INF/NOTICE.txt new file mode 100644 index 0000000..2e215bf --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-zookeeper-master-starter/src/main/resources/META-INF/NOTICE.txt @@ -0,0 +1,11 @@ + ========================================================================= + == NOTICE file corresponding to the section 4 d of == + == the Apache License, Version 2.0, == + == in this case for the Apache Camel distribution. == + ========================================================================= + + This product includes software developed by + The Apache Software Foundation (http://www.apache.org/). + + Please read the different LICENSE files present in the licenses directory of + this distribution. http://git-wip-us.apache.org/repos/asf/camel/blob/bf82a5ed/platforms/spring-boot/components-starter/camel-zookeeper-master-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-zookeeper-master-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/platforms/spring-boot/components-starter/camel-zookeeper-master-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json new file mode 100644 index 0000000..0b8cff5 --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-zookeeper-master-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -0,0 +1,10 @@ +{ + "properties": [ + { + "defaultValue": true, + "name": "camel.component.zookeeper-master.enabled", + "description": "Enable zookeeper-master component", + "type": "java.lang.Boolean" + } + ] +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/bf82a5ed/platforms/spring-boot/components-starter/camel-zookeeper-master-starter/src/main/resources/META-INF/spring.factories ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-zookeeper-master-starter/src/main/resources/META-INF/spring.factories b/platforms/spring-boot/components-starter/camel-zookeeper-master-starter/src/main/resources/META-INF/spring.factories new file mode 100644 index 0000000..4dee811 --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-zookeeper-master-starter/src/main/resources/META-INF/spring.factories @@ -0,0 +1,19 @@ +# +# 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. +# + +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ +org.apache.camel.component.zookeepermaster.springboot.MasterComponentAutoConfiguration http://git-wip-us.apache.org/repos/asf/camel/blob/bf82a5ed/platforms/spring-boot/components-starter/camel-zookeeper-master-starter/src/main/resources/META-INF/spring.provides ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-zookeeper-master-starter/src/main/resources/META-INF/spring.provides b/platforms/spring-boot/components-starter/camel-zookeeper-master-starter/src/main/resources/META-INF/spring.provides new file mode 100644 index 0000000..d50cd0a --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-zookeeper-master-starter/src/main/resources/META-INF/spring.provides @@ -0,0 +1,18 @@ +# +# 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. +# + +provides: camel-zookeeper-master \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/bf82a5ed/platforms/spring-boot/components-starter/pom.xml ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/pom.xml b/platforms/spring-boot/components-starter/pom.xml index e0e5fca..efb907f 100644 --- a/platforms/spring-boot/components-starter/pom.xml +++ b/platforms/spring-boot/components-starter/pom.xml @@ -304,6 +304,7 @@ <module>camel-yammer-starter</module> <module>camel-zipfile-starter</module> <module>camel-zipkin-starter</module> + <module>camel-zookeeper-master-starter</module> <module>camel-zookeeper-starter</module> </modules> </project>