You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@helix.apache.org by ka...@apache.org on 2013/12/04 22:13:10 UTC
[1/2] [HELIX-319] Plug Riemann server into Helix, config management,
first take
Updated Branches:
refs/heads/helix-monitoring [created] 77f14b4a4
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-core/src/test/java/org/apache/helix/participant/TestDistControllerElection.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/participant/TestDistControllerElection.java b/helix-core/src/test/java/org/apache/helix/participant/TestDistControllerElection.java
index 28068ec..9ec4d90 100644
--- a/helix-core/src/test/java/org/apache/helix/participant/TestDistControllerElection.java
+++ b/helix-core/src/test/java/org/apache/helix/participant/TestDistControllerElection.java
@@ -32,7 +32,7 @@ import org.apache.helix.ZNRecord;
import org.apache.helix.ZkUnitTestBase;
import org.apache.helix.manager.zk.ZKHelixDataAccessor;
import org.apache.helix.manager.zk.ZkBaseDataAccessor;
-import org.apache.helix.model.LiveInstance;
+import org.apache.helix.model.Leader;
import org.apache.log4j.Logger;
import org.testng.AssertJUnit;
import org.testng.annotations.Test;
@@ -69,8 +69,8 @@ public class TestDistControllerElection extends ZkUnitTestBase {
// path = PropertyPathConfig.getPath(PropertyType.LEADER, clusterName);
// ZNRecord leaderRecord = _gZkClient.<ZNRecord> readData(path);
- LiveInstance liveInstance = accessor.getProperty(keyBuilder.controllerLeader());
- AssertJUnit.assertEquals(controllerName, liveInstance.getInstanceName());
+ Leader leader = accessor.getProperty(keyBuilder.controllerLeader());
+ AssertJUnit.assertEquals(controllerName, leader.getInstanceName());
// AssertJUnit.assertNotNull(election.getController());
// AssertJUnit.assertNull(election.getLeader());
@@ -81,8 +81,8 @@ public class TestDistControllerElection extends ZkUnitTestBase {
context.setType(NotificationContext.Type.INIT);
election.onControllerChange(context);
// leaderRecord = _gZkClient.<ZNRecord> readData(path);
- liveInstance = accessor.getProperty(keyBuilder.controllerLeader());
- AssertJUnit.assertEquals(controllerName, liveInstance.getInstanceName());
+ leader = accessor.getProperty(keyBuilder.controllerLeader());
+ AssertJUnit.assertEquals(controllerName, leader.getInstanceName());
// AssertJUnit.assertNull(election.getController());
// AssertJUnit.assertNull(election.getLeader());
@@ -117,8 +117,8 @@ public class TestDistControllerElection extends ZkUnitTestBase {
context.setType(NotificationContext.Type.CALLBACK);
election.onControllerChange(context);
- LiveInstance liveInstance = accessor.getProperty(keyBuilder.controllerLeader());
- AssertJUnit.assertEquals(controllerName, liveInstance.getInstanceName());
+ Leader leader = accessor.getProperty(keyBuilder.controllerLeader());
+ AssertJUnit.assertEquals(controllerName, leader.getInstanceName());
// path = PropertyPathConfig.getPath(PropertyType.LEADER, clusterName);
// ZNRecord leaderRecord = _gZkClient.<ZNRecord> readData(path);
@@ -134,8 +134,8 @@ public class TestDistControllerElection extends ZkUnitTestBase {
context.setType(NotificationContext.Type.CALLBACK);
election.onControllerChange(context);
- liveInstance = accessor.getProperty(keyBuilder.controllerLeader());
- AssertJUnit.assertEquals(controllerName, liveInstance.getInstanceName());
+ leader = accessor.getProperty(keyBuilder.controllerLeader());
+ AssertJUnit.assertEquals(controllerName, leader.getInstanceName());
// leaderRecord = _gZkClient.<ZNRecord> readData(path);
// AssertJUnit.assertEquals(controllerName, leaderRecord.getSimpleField("LEADER"));
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-core/src/test/java/org/apache/helix/tools/TestHelixAdminCli.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/tools/TestHelixAdminCli.java b/helix-core/src/test/java/org/apache/helix/tools/TestHelixAdminCli.java
index 4d7f93c..d281abe 100644
--- a/helix-core/src/test/java/org/apache/helix/tools/TestHelixAdminCli.java
+++ b/helix-core/src/test/java/org/apache/helix/tools/TestHelixAdminCli.java
@@ -39,7 +39,7 @@ import org.apache.helix.manager.zk.ZKUtil;
import org.apache.helix.manager.zk.ZkBaseDataAccessor;
import org.apache.helix.model.IdealState;
import org.apache.helix.model.InstanceConfig;
-import org.apache.helix.model.LiveInstance;
+import org.apache.helix.model.Leader;
import org.apache.helix.store.ZNRecordJsonSerializer;
import org.apache.helix.tools.ClusterStateVerifier.BestPossAndExtViewZkVerifier;
import org.apache.helix.tools.ClusterStateVerifier.MasterNbInExtViewVerifier;
@@ -283,13 +283,13 @@ public class TestHelixAdminCli extends ZkIntegrationTestBase {
// verify leader node
BaseDataAccessor<ZNRecord> baseAccessor = new ZkBaseDataAccessor<ZNRecord>(_gZkClient);
HelixDataAccessor accessor = new ZKHelixDataAccessor(grandClusterName, baseAccessor);
- LiveInstance controllerLeader = accessor.getProperty(accessor.keyBuilder().controllerLeader());
+ Leader controllerLeader = accessor.getProperty(accessor.keyBuilder().controllerLeader());
Assert.assertNotNull(controllerLeader,
"controllerLeader should be either controller_9000 or controller_9001");
Assert.assertTrue(controllerLeader.getInstanceName().startsWith("controller_900"));
accessor = new ZKHelixDataAccessor(clusterName, baseAccessor);
- LiveInstance leader = accessor.getProperty(accessor.keyBuilder().controllerLeader());
+ Leader leader = accessor.getProperty(accessor.keyBuilder().controllerLeader());
for (int i = 0; i < 20; i++) {
if (leader != null) {
break;
@@ -388,8 +388,7 @@ public class TestHelixAdminCli extends ZkIntegrationTestBase {
private void setupCluster(String clusterName, String grandClusterName, final int n,
MockParticipantManager[] participants, ClusterDistributedController[] controllers)
- throws Exception,
- InterruptedException {
+ throws Exception, InterruptedException {
// add cluster
String command = "-zkSvr " + ZK_ADDR + " -addCluster " + clusterName;
ClusterSetup.processCommandLineArgs(command.split("\\s+"));
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-monitor-server/.gitignore
----------------------------------------------------------------------
diff --git a/helix-monitor-server/.gitignore b/helix-monitor-server/.gitignore
new file mode 100644
index 0000000..a2d1ebb
--- /dev/null
+++ b/helix-monitor-server/.gitignore
@@ -0,0 +1,11 @@
+/target
+/.project
+/.classpath
+/.settings
+/zkdata
+/test-output
+/src/main/scripts/integration-test/var
+/src/main/scripts/target/
+/src/main/scripts/integration-test/script/.metadata_infra
+*.pyc
+/bin
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-monitor-server/DISCLAIMER
----------------------------------------------------------------------
diff --git a/helix-monitor-server/DISCLAIMER b/helix-monitor-server/DISCLAIMER
new file mode 100644
index 0000000..2001d31
--- /dev/null
+++ b/helix-monitor-server/DISCLAIMER
@@ -0,0 +1,15 @@
+Apache Helix is an effort undergoing incubation at the Apache Software
+Foundation (ASF), sponsored by the Apache Incubator PMC.
+
+Incubation is required of all newly accepted projects until a further review
+indicates that the infrastructure, communications, and decision making process
+have stabilized in a manner consistent with other successful ASF projects.
+
+While incubation status is not necessarily a reflection of the completeness
+or stability of the code, it does indicate that the project has yet to be
+fully endorsed by the ASF.
+
+For more information about the incubation status of the Apache Helix project you
+can go to the following page:
+
+http://incubator.apache.org/projects/helix.html
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-monitor-server/LICENSE
----------------------------------------------------------------------
diff --git a/helix-monitor-server/LICENSE b/helix-monitor-server/LICENSE
new file mode 100644
index 0000000..413913f
--- /dev/null
+++ b/helix-monitor-server/LICENSE
@@ -0,0 +1,273 @@
+
+ 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.
+
+
+
+For xstream:
+
+Copyright (c) 2003-2006, Joe Walnes
+Copyright (c) 2006-2009, 2011 XStream Committers
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this list of
+conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice, this list of
+conditions and the following disclaimer in the documentation and/or other materials provided
+with the distribution.
+
+3. Neither the name of XStream nor the names of its contributors may be used to endorse
+or promote products derived from this software without specific prior written
+permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
+WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGE.
+
+for jline:
+
+Copyright (c) 2002-2006, Marc Prud'hommeaux <mw...@cornell.edu>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or
+without modification, are permitted provided that the following
+conditions are met:
+
+Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+
+Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with
+the distribution.
+
+Neither the name of JLine nor the names of its contributors
+may be used to endorse or promote products derived from this
+software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
+BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-monitor-server/NOTICE
----------------------------------------------------------------------
diff --git a/helix-monitor-server/NOTICE b/helix-monitor-server/NOTICE
new file mode 100644
index 0000000..e070e15
--- /dev/null
+++ b/helix-monitor-server/NOTICE
@@ -0,0 +1,30 @@
+Apache Helix
+Copyright 2012 The Apache Software Foundation
+
+
+I. Included Software
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+Licensed under the Apache License 2.0.
+
+This product includes software developed at
+Codehaus (http://www.codehaus.org/)
+Licensed under the BSD License.
+
+This product includes software developed at
+jline (http://jline.sourceforge.net/ )
+Licensed under the BSD License.
+
+This product includes software developed at
+josql (http://sourceforge.net/projects/josql/).
+Licensed under the Apache License 2.0.
+
+This product includes software developed at
+restlet (http://www.restlet.org/about/legal).
+Licensed under the Apache License 2.0.
+
+
+II. License Summary
+- Apache License 2.0
+- BSD License
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-monitor-server/pom.xml
----------------------------------------------------------------------
diff --git a/helix-monitor-server/pom.xml b/helix-monitor-server/pom.xml
new file mode 100644
index 0000000..a703e0e
--- /dev/null
+++ b/helix-monitor-server/pom.xml
@@ -0,0 +1,113 @@
+<?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/xsd/maven-4.0.0.xsd">
+ <parent>
+ <groupId>org.apache.helix</groupId>
+ <artifactId>helix</artifactId>
+ <version>0.7.1-incubating-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>helix-monitor-server</artifactId>
+ <packaging>jar</packaging>
+ <name>Apache Helix :: Helix Monitoring Server</name>
+
+ <properties>
+ <osgi.import>
+ org.apache.helix*,
+ org.apache.log4j,
+ *
+ </osgi.import>
+ <osgi.export>org.apache.helix.monitoring*;version="${project.version};-noimport:=true</osgi.export>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.helix</groupId>
+ <artifactId>helix-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>riemann</groupId>
+ <artifactId>riemann</artifactId>
+ <version>0.2.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.helix</groupId>
+ <artifactId>helix-core</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <resources>
+ <resource>
+ <directory>${basedir}/src/main/resources</directory>
+ <filtering>true</filtering>
+ </resource>
+ <resource>
+ <directory>${basedir}</directory>
+ <includes>
+ <include>DISCLAIMER</include>
+ </includes>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>appassembler-maven-plugin</artifactId>
+ <configuration>
+ <platforms>
+ <platform>windows</platform>
+ <platform>unix</platform>
+ </platforms>
+ <programs />
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <descriptors>
+ <descriptor>src/assemble/assembly.xml</descriptor>
+ </descriptors>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-monitor-server/src/assemble/assembly.xml
----------------------------------------------------------------------
diff --git a/helix-monitor-server/src/assemble/assembly.xml b/helix-monitor-server/src/assemble/assembly.xml
new file mode 100644
index 0000000..c2d08a1
--- /dev/null
+++ b/helix-monitor-server/src/assemble/assembly.xml
@@ -0,0 +1,60 @@
+<?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.
+-->
+<assembly>
+ <id>pkg</id>
+ <formats>
+ <format>tar</format>
+ </formats>
+ <fileSets>
+ <fileSet>
+ <directory>${project.build.directory}/${project.artifactId}-pkg/bin</directory>
+ <outputDirectory>bin</outputDirectory>
+ <lineEnding>unix</lineEnding>
+ <fileMode>0755</fileMode>
+ <directoryMode>0755</directoryMode>
+ </fileSet>
+ <fileSet>
+ <directory>${project.build.directory}/${project.artifactId}-pkg/repo/</directory>
+ <outputDirectory>repo</outputDirectory>
+ <fileMode>0755</fileMode>
+ <directoryMode>0755</directoryMode>
+ <excludes>
+ <exclude>**/*.xml</exclude>
+ </excludes>
+ </fileSet>
+ <fileSet>
+ <directory>${project.build.directory}/${project.artifactId}-pkg/conf</directory>
+ <outputDirectory>conf</outputDirectory>
+ <lineEnding>unix</lineEnding>
+ <fileMode>0755</fileMode>
+ <directoryMode>0755</directoryMode>
+ </fileSet>
+ <fileSet>
+ <directory>${project.basedir}</directory>
+ <outputDirectory>/</outputDirectory>
+ <includes>
+ <include>LICENSE</include>
+ <include>NOTICE</include>
+ <include>DISCLAIMER</include>
+ </includes>
+ <fileMode>0755</fileMode>
+ </fileSet>
+ </fileSets>
+</assembly>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-monitor-server/src/main/config/log4j.properties
----------------------------------------------------------------------
diff --git a/helix-monitor-server/src/main/config/log4j.properties b/helix-monitor-server/src/main/config/log4j.properties
new file mode 100644
index 0000000..4b3dc31
--- /dev/null
+++ b/helix-monitor-server/src/main/config/log4j.properties
@@ -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.
+#
+
+# Set root logger level to DEBUG and its only appender to A1.
+log4j.rootLogger=ERROR,A1
+
+# A1 is set to be a ConsoleAppender.
+log4j.appender.A1=org.apache.log4j.ConsoleAppender
+
+# A1 uses PatternLayout.
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
+
+log4j.logger.org.I0Itec=ERROR
+log4j.logger.org.apache=ERROR
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-monitor-server/src/main/java/org/apache/helix/monitoring/RiemannMonitoringServer.java
----------------------------------------------------------------------
diff --git a/helix-monitor-server/src/main/java/org/apache/helix/monitoring/RiemannMonitoringServer.java b/helix-monitor-server/src/main/java/org/apache/helix/monitoring/RiemannMonitoringServer.java
new file mode 100644
index 0000000..36719aa
--- /dev/null
+++ b/helix-monitor-server/src/main/java/org/apache/helix/monitoring/RiemannMonitoringServer.java
@@ -0,0 +1,182 @@
+package org.apache.helix.monitoring;
+
+/*
+ * 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.
+ */
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.net.InetAddress;
+import java.net.URL;
+import java.net.UnknownHostException;
+import java.util.List;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.helix.BaseDataAccessor;
+import org.apache.helix.HelixDataAccessor;
+import org.apache.helix.ZNRecord;
+import org.apache.helix.manager.zk.ZKHelixDataAccessor;
+import org.apache.helix.manager.zk.ZkBaseDataAccessor;
+import org.apache.helix.model.MonitoringConfig;
+import org.apache.helix.util.ZKClientPool;
+import org.apache.log4j.Logger;
+
+import clojure.lang.RT;
+import clojure.lang.Symbol;
+
+/**
+ * A monitoring server implementation that uses Riemann
+ */
+public class RiemannMonitoringServer implements MonitoringServer {
+ private static final Logger LOG = Logger.getLogger(RiemannMonitoringServer.class);
+ private static final String DEFAULT_CONFIG_DIR = "/tmp/riemannconfigs";
+ private final String _host;
+ private boolean _isStarted;
+ private boolean _configsAdded;
+ private String _configDir;
+
+ /**
+ * Create a monitoring server. Configs will be placed in "/tmp/riemannconfigs".
+ */
+ public RiemannMonitoringServer(String host) {
+ this(DEFAULT_CONFIG_DIR, host);
+ }
+
+ /**
+ * Create a monitoring server.
+ * @param configDir Directory to use for storing configs
+ * @param host Hostname where the server lives (i.e. the hostname of this machine)
+ */
+ public RiemannMonitoringServer(String configDir, String host) {
+ _configDir = configDir;
+ _isStarted = false;
+ _configsAdded = false;
+ _host = host;
+ }
+
+ @Override
+ public synchronized void start() {
+ // get the config file
+ URL url = Thread.currentThread().getContextClassLoader().getResource("riemann.config");
+ if (url == null) {
+ LOG.error("Riemann config file does not exist!");
+ return;
+ }
+ String path = url.getPath();
+ LOG.info("Riemann config file is at: " + path);
+
+ // register config files
+ if (_configsAdded) {
+ try {
+ File srcFile = new File(path);
+ File file = File.createTempFile("riemann", "config");
+ file.deleteOnExit();
+ FileUtils.copyFile(srcFile, file);
+ PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(file, true)));
+ out.println("\n(include \"" + _configDir + "\")\n");
+ out.close();
+ path = file.getAbsolutePath();
+ } catch (IOException e) {
+ LOG.error("Could not add configs!");
+ }
+ }
+
+ // start Riemann
+ RT.var("clojure.core", "require").invoke(Symbol.intern("riemann.bin"));
+ RT.var("clojure.core", "require").invoke(Symbol.intern("riemann.config"));
+ RT.var("riemann.bin", "-main").invoke(path);
+ _isStarted = true;
+ }
+
+ @Override
+ public synchronized void stop() {
+ if (!_isStarted) {
+ LOG.error("Tried to stop Riemann when not started!");
+ return;
+ }
+ RT.var("riemann.config", "stop!").invoke();
+ _isStarted = false;
+ }
+
+ @Override
+ public synchronized void addConfigs(HelixDataAccessor accessor) {
+ // create the directory
+ File dir = new File(_configDir);
+ if (!dir.exists()) {
+ dir.mkdir();
+ }
+
+ // persist ZK-based configs
+ if (accessor != null) {
+ List<MonitoringConfig> configs =
+ accessor.getChildValues(accessor.keyBuilder().monitoringConfigs());
+ for (MonitoringConfig config : configs) {
+ String configData = config.getConfig();
+ String fileName = _configDir + "/" + config.getId();
+ try {
+ PrintWriter writer = new PrintWriter(fileName);
+ writer.println(configData);
+ writer.close();
+
+ // make sure this is cleaned up eventually
+ File file = new File(fileName);
+ file.deleteOnExit();
+ } catch (FileNotFoundException e) {
+ LOG.error("Could not write " + config.getId(), e);
+ }
+ }
+ }
+
+ // restart if started
+ if (_isStarted) {
+ stop();
+ start();
+ }
+ _configsAdded = true;
+ }
+
+ @Override
+ public boolean isStarted() {
+ return _isStarted;
+ }
+
+ @Override
+ public String getHost() {
+ return _host;
+ }
+
+ @Override
+ public int getPort() {
+ return 5555;
+ }
+
+ public static void main(String[] args) throws InterruptedException, UnknownHostException {
+ RiemannMonitoringServer service =
+ new RiemannMonitoringServer(InetAddress.getLocalHost().getHostName());
+ BaseDataAccessor<ZNRecord> baseAccessor =
+ new ZkBaseDataAccessor<ZNRecord>(ZKClientPool.getZkClient("eat1-app87.corp:2181"));
+ HelixDataAccessor accessor = new ZKHelixDataAccessor("perf-test-cluster", baseAccessor);
+ service.addConfigs(accessor);
+ service.start();
+ Thread.currentThread().join();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-monitor-server/src/main/resources/riemann.config
----------------------------------------------------------------------
diff --git a/helix-monitor-server/src/main/resources/riemann.config b/helix-monitor-server/src/main/resources/riemann.config
new file mode 100644
index 0000000..08c3bce
--- /dev/null
+++ b/helix-monitor-server/src/main/resources/riemann.config
@@ -0,0 +1,36 @@
+; -*- mode: clojure; -*-
+; vim: filetype=clojure
+
+; 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.
+
+(logging/init :file "/dev/null")
+
+(tcp-server)
+
+(instrumentation {:interval 1})
+
+(udp-server)
+(ws-server)
+(repl-server)
+
+(periodically-expire 1)
+
+(let [index (default :ttl 3 (update-index (index)))]
+ (streams
+ (expired prn)
+ index))
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-monitor-server/src/test/conf/testng.xml
----------------------------------------------------------------------
diff --git a/helix-monitor-server/src/test/conf/testng.xml b/helix-monitor-server/src/test/conf/testng.xml
new file mode 100644
index 0000000..90910aa
--- /dev/null
+++ b/helix-monitor-server/src/test/conf/testng.xml
@@ -0,0 +1,27 @@
+<?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.
+-->
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
+<suite name="Suite" parallel="none">
+ <test name="Test" preserve-order="false">
+ <packages>
+ <package name="org.apache.helix.monitoring"/>
+ </packages>
+ </test>
+</suite>
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-monitor-server/src/test/java/org/apache/helix/monitoring/BasicMonitoringTest.java
----------------------------------------------------------------------
diff --git a/helix-monitor-server/src/test/java/org/apache/helix/monitoring/BasicMonitoringTest.java b/helix-monitor-server/src/test/java/org/apache/helix/monitoring/BasicMonitoringTest.java
new file mode 100644
index 0000000..6680f00
--- /dev/null
+++ b/helix-monitor-server/src/test/java/org/apache/helix/monitoring/BasicMonitoringTest.java
@@ -0,0 +1,93 @@
+package org.apache.helix.monitoring;
+
+/*
+ * 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.
+ */
+
+import java.net.InetAddress;
+import java.util.Date;
+
+import org.apache.helix.HelixDataAccessor;
+import org.apache.helix.PropertyKey;
+import org.apache.helix.TestHelper;
+import org.apache.helix.ZkUnitTestBase;
+import org.apache.helix.integration.manager.ClusterControllerManager;
+import org.apache.helix.model.IdealState.RebalanceMode;
+import org.apache.helix.model.Leader;
+import org.junit.Assert;
+import org.testng.annotations.Test;
+
+public class BasicMonitoringTest extends ZkUnitTestBase {
+ @Test
+ public void testStartAndStop() throws Exception {
+ final int NUM_PARTICIPANTS = 10;
+ final int NUM_PARTITIONS = 4;
+ final int NUM_REPLICAS = 2;
+
+ String className = TestHelper.getTestClassName();
+ String methodName = TestHelper.getTestMethodName();
+ String clusterName = className + "_" + methodName;
+ System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis()));
+
+ // Set up cluster
+ TestHelper.setupCluster(clusterName, ZK_ADDR, 12918, // participant port
+ "localhost", // participant name prefix
+ "TestDB", // resource name prefix
+ 1, // resources
+ NUM_PARTITIONS, // partitions per resource
+ NUM_PARTICIPANTS, // number of nodes
+ NUM_REPLICAS, // replicas
+ "MasterSlave", // pick a built-in state model
+ RebalanceMode.FULL_AUTO, // let Helix handle rebalancing
+ true); // do rebalance
+
+ // start controller
+ ClusterControllerManager controller =
+ new ClusterControllerManager(ZK_ADDR, clusterName, "controller");
+ controller.registerMonitoringServer(new RiemannMonitoringServer(InetAddress.getLocalHost()
+ .getHostName()));
+ controller.syncStart();
+
+ // make sure the leader has registered and is showing the server port
+ HelixDataAccessor accessor = controller.getHelixDataAccessor();
+ PropertyKey.Builder keyBuilder = accessor.keyBuilder();
+ Leader leader = accessor.getProperty(keyBuilder.controllerLeader());
+ Assert.assertNotNull(leader);
+ Assert.assertNotEquals(leader.getMonitoringPort(), -1);
+ Assert.assertNotNull(leader.getMonitoringHost());
+
+ // stop controller
+ controller.syncStop();
+
+ // start controller without monitoring
+ ClusterControllerManager rawController =
+ new ClusterControllerManager(ZK_ADDR, clusterName, "controller");
+ rawController.syncStart();
+
+ // make sure the leader has registered, but has no monitoring port
+ accessor = rawController.getHelixDataAccessor();
+ keyBuilder = accessor.keyBuilder();
+ leader = accessor.getProperty(keyBuilder.controllerLeader());
+ Assert.assertNotNull(leader);
+ Assert.assertEquals(leader.getMonitoringPort(), -1);
+ Assert.assertNull(leader.getMonitoringHost());
+
+ // stop controller
+ rawController.syncStop();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 010023c..c220e2b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -198,6 +198,7 @@ under the License.
<module>helix-admin-webapp</module>
<module>helix-agent</module>
<module>helix-examples</module>
+ <module>helix-monitor-server</module>
<module>recipes</module>
<module>site-releases</module>
</modules>
@@ -256,6 +257,10 @@ under the License.
<name>JBoss FuseSource repository</name>
<url>http://repository.jboss.org/nexus/content/groups/fs-public/</url>
</repository>
+ <repository>
+ <id>clojars.org</id>
+ <url>http://clojars.org/repo</url>
+ </repository>
</repositories>
[2/2] git commit: [HELIX-319] Plug Riemann server into Helix,
config management, first take
Posted by ka...@apache.org.
[HELIX-319] Plug Riemann server into Helix, config management, first take
Project: http://git-wip-us.apache.org/repos/asf/incubator-helix/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-helix/commit/77f14b4a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-helix/tree/77f14b4a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-helix/diff/77f14b4a
Branch: refs/heads/helix-monitoring
Commit: 77f14b4a40d6613de294824f6ae74f4fe9be1a2e
Parents: 2904c83
Author: Kanak Biscuitwala <ka...@apache.org>
Authored: Wed Nov 27 16:20:36 2013 -0800
Committer: Kanak Biscuitwala <ka...@apache.org>
Committed: Mon Dec 2 14:55:42 2013 -0800
----------------------------------------------------------------------
.../helix/webapp/resources/ClusterResource.java | 3 +-
.../webapp/resources/ControllerResource.java | 3 +-
.../resources/SchedulerTasksResource.java | 3 +-
.../tools/TestHelixAdminScenariosRest.java | 5 +-
.../org/apache/helix/HelixAutoController.java | 5 +-
.../java/org/apache/helix/HelixController.java | 4 +-
.../java/org/apache/helix/HelixManager.java | 3 +-
.../main/java/org/apache/helix/PropertyKey.java | 26 +-
.../helix/api/accessor/ClusterAccessor.java | 5 +-
.../helix/api/accessor/ControllerAccessor.java | 4 +-
.../controller/GenericHelixController.java | 3 +-
.../manager/zk/DistributedLeaderElection.java | 44 +--
.../manager/zk/HelixConnectionAdaptor.java | 51 +++-
.../helix/manager/zk/ZKHelixDataAccessor.java | 4 +-
.../apache/helix/manager/zk/ZKHelixManager.java | 38 ++-
.../helix/manager/zk/ZkHelixAutoController.java | 11 +
.../helix/manager/zk/ZkHelixController.java | 40 ++-
.../helix/manager/zk/ZkHelixLeaderElection.java | 50 ++--
.../apache/helix/model/HelixConfigScope.java | 26 +-
.../java/org/apache/helix/model/Leader.java | 98 +++++++
.../org/apache/helix/model/LiveInstance.java | 19 +-
.../apache/helix/model/MonitoringConfig.java | 87 ++++++
.../model/builder/HelixConfigScopeBuilder.java | 18 ++
.../helix/monitoring/MonitoringServer.java | 61 +++++
.../helix/monitoring/MonitoringServerOwner.java | 37 +++
.../DistClusterControllerElection.java | 49 +---
.../src/test/java/org/apache/helix/Mocks.java | 13 +
.../controller/stages/DummyClusterManager.java | 13 +
.../integration/TestDistributedCMMain.java | 5 +-
.../TestDistributedClusterController.java | 5 +-
.../helix/integration/TestStandAloneCMMain.java | 7 +-
.../integration/ZkIntegrationTestBase.java | 4 +-
.../manager/TestConsecutiveZkSessionExpiry.java | 4 +-
.../TestDistributedControllerManager.java | 6 +-
.../apache/helix/manager/zk/TestZkFlapping.java | 3 +-
.../manager/zk/TestZkHelixAutoController.java | 3 +-
.../helix/manager/zk/TestZkHelixController.java | 5 +-
.../helix/participant/MockZKHelixManager.java | 13 +
.../participant/TestDistControllerElection.java | 18 +-
.../apache/helix/tools/TestHelixAdminCli.java | 9 +-
helix-monitor-server/.gitignore | 11 +
helix-monitor-server/DISCLAIMER | 15 +
helix-monitor-server/LICENSE | 273 +++++++++++++++++++
helix-monitor-server/NOTICE | 30 ++
helix-monitor-server/pom.xml | 113 ++++++++
helix-monitor-server/src/assemble/assembly.xml | 60 ++++
.../src/main/config/log4j.properties | 31 +++
.../monitoring/RiemannMonitoringServer.java | 182 +++++++++++++
.../src/main/resources/riemann.config | 36 +++
helix-monitor-server/src/test/conf/testng.xml | 27 ++
.../helix/monitoring/BasicMonitoringTest.java | 93 +++++++
pom.xml | 5 +
52 files changed, 1479 insertions(+), 202 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ClusterResource.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ClusterResource.java b/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ClusterResource.java
index b22d801..86459eb 100644
--- a/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ClusterResource.java
+++ b/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ClusterResource.java
@@ -29,6 +29,7 @@ import org.apache.helix.HelixException;
import org.apache.helix.PropertyKey.Builder;
import org.apache.helix.ZNRecord;
import org.apache.helix.manager.zk.ZkClient;
+import org.apache.helix.model.Leader;
import org.apache.helix.model.LiveInstance;
import org.apache.helix.tools.ClusterSetup;
import org.apache.helix.webapp.RestAdminApplication;
@@ -87,7 +88,7 @@ public class ClusterResource extends ServerResource {
ClusterRepresentationUtil.getClusterDataAccessor(zkClient, clusterName);
Builder keyBuilder = accessor.keyBuilder();
- LiveInstance leader = accessor.getProperty(keyBuilder.controllerLeader());
+ Leader leader = accessor.getProperty(keyBuilder.controllerLeader());
if (leader != null) {
clusterSummayRecord.setSimpleField("LEADER", leader.getInstanceName());
} else {
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ControllerResource.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ControllerResource.java b/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ControllerResource.java
index ea7be42..8e81a08 100644
--- a/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ControllerResource.java
+++ b/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ControllerResource.java
@@ -34,6 +34,7 @@ import org.apache.helix.ZNRecord;
import org.apache.helix.manager.zk.ZKHelixDataAccessor;
import org.apache.helix.manager.zk.ZkBaseDataAccessor;
import org.apache.helix.manager.zk.ZkClient;
+import org.apache.helix.model.Leader;
import org.apache.helix.model.LiveInstance;
import org.apache.helix.tools.ClusterSetup;
import org.apache.helix.util.StatusUpdateUtil.Level;
@@ -68,7 +69,7 @@ public class ControllerResource extends ServerResource {
new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(zkClient));
ZNRecord record = null;
- LiveInstance leader = accessor.getProperty(keyBuilder.controllerLeader());
+ Leader leader = accessor.getProperty(keyBuilder.controllerLeader());
if (leader != null) {
record = leader.getRecord();
} else {
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/SchedulerTasksResource.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/SchedulerTasksResource.java b/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/SchedulerTasksResource.java
index 5803e98..b48d0cb 100644
--- a/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/SchedulerTasksResource.java
+++ b/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/SchedulerTasksResource.java
@@ -35,6 +35,7 @@ import org.apache.helix.api.id.MessageId;
import org.apache.helix.api.id.SessionId;
import org.apache.helix.manager.zk.DefaultSchedulerMessageHandlerFactory;
import org.apache.helix.manager.zk.ZkClient;
+import org.apache.helix.model.Leader;
import org.apache.helix.model.LiveInstance;
import org.apache.helix.model.Message;
import org.apache.helix.model.Message.MessageType;
@@ -125,7 +126,7 @@ public class SchedulerTasksResource extends ServerResource {
}
HelixDataAccessor accessor =
ClusterRepresentationUtil.getClusterDataAccessor(zkClient, clusterName);
- LiveInstance leader = accessor.getProperty(accessor.keyBuilder().controllerLeader());
+ Leader leader = accessor.getProperty(accessor.keyBuilder().controllerLeader());
if (leader == null) {
throw new HelixException("There is no leader for the cluster " + clusterName);
}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-admin-webapp/src/test/java/org/apache/helix/tools/TestHelixAdminScenariosRest.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/test/java/org/apache/helix/tools/TestHelixAdminScenariosRest.java b/helix-admin-webapp/src/test/java/org/apache/helix/tools/TestHelixAdminScenariosRest.java
index 6a0e331..e4307d3 100644
--- a/helix-admin-webapp/src/test/java/org/apache/helix/tools/TestHelixAdminScenariosRest.java
+++ b/helix-admin-webapp/src/test/java/org/apache/helix/tools/TestHelixAdminScenariosRest.java
@@ -35,6 +35,7 @@ import org.apache.helix.integration.manager.MockParticipantManager;
import org.apache.helix.manager.zk.ZKUtil;
import org.apache.helix.model.ExternalView;
import org.apache.helix.model.IdealState.IdealStateProperty;
+import org.apache.helix.model.Leader;
import org.apache.helix.model.LiveInstance;
import org.apache.helix.tools.ClusterStateVerifier.BestPossAndExtViewZkVerifier;
import org.apache.helix.tools.ClusterStateVerifier.MasterNbInExtViewVerifier;
@@ -778,11 +779,11 @@ public class TestHelixAdminScenariosRest extends AdminTestBase {
// verify leader node
HelixDataAccessor accessor = distControllers.get("controller_9001").getHelixDataAccessor();
- LiveInstance controllerLeader = accessor.getProperty(accessor.keyBuilder().controllerLeader());
+ Leader controllerLeader = accessor.getProperty(accessor.keyBuilder().controllerLeader());
Assert.assertTrue(controllerLeader.getInstanceName().startsWith("controller_900"));
accessor = participants.get("localhost_1232").getHelixDataAccessor();
- LiveInstance leader = accessor.getProperty(accessor.keyBuilder().controllerLeader());
+ Leader leader = accessor.getProperty(accessor.keyBuilder().controllerLeader());
for (int i = 0; i < 5; i++) {
if (leader != null) {
break;
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-core/src/main/java/org/apache/helix/HelixAutoController.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/HelixAutoController.java b/helix-core/src/main/java/org/apache/helix/HelixAutoController.java
index 91ec809..fdab2a6 100644
--- a/helix-core/src/main/java/org/apache/helix/HelixAutoController.java
+++ b/helix-core/src/main/java/org/apache/helix/HelixAutoController.java
@@ -20,12 +20,14 @@ package org.apache.helix;
*/
import org.apache.helix.api.id.ControllerId;
+import org.apache.helix.monitoring.MonitoringServerOwner;
import org.apache.helix.participant.StateMachineEngine;
/**
* Autonomous controller
*/
-public interface HelixAutoController extends HelixRole, HelixService, HelixConnectionStateListener {
+public interface HelixAutoController extends HelixRole, HelixService, HelixConnectionStateListener,
+ MonitoringServerOwner {
/**
* get controller id
* @return controller id
@@ -58,5 +60,4 @@ public interface HelixAutoController extends HelixRole, HelixService, HelixConne
* @return
*/
boolean isLeader();
-
}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-core/src/main/java/org/apache/helix/HelixController.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/HelixController.java b/helix-core/src/main/java/org/apache/helix/HelixController.java
index 9565cfb..098fd96 100644
--- a/helix-core/src/main/java/org/apache/helix/HelixController.java
+++ b/helix-core/src/main/java/org/apache/helix/HelixController.java
@@ -20,8 +20,10 @@ package org.apache.helix;
*/
import org.apache.helix.api.id.ControllerId;
+import org.apache.helix.monitoring.MonitoringServerOwner;
-public interface HelixController extends HelixRole, HelixService, HelixConnectionStateListener {
+public interface HelixController extends HelixRole, HelixService, HelixConnectionStateListener,
+ MonitoringServerOwner {
/**
* get controller id
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-core/src/main/java/org/apache/helix/HelixManager.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/HelixManager.java b/helix-core/src/main/java/org/apache/helix/HelixManager.java
index 54e9943..17c94e5 100644
--- a/helix-core/src/main/java/org/apache/helix/HelixManager.java
+++ b/helix-core/src/main/java/org/apache/helix/HelixManager.java
@@ -25,6 +25,7 @@ import org.apache.helix.controller.GenericHelixController;
import org.apache.helix.healthcheck.ParticipantHealthReportCollector;
import org.apache.helix.manager.zk.ZKHelixManager;
import org.apache.helix.model.HelixConfigScope.ConfigScopeProperty;
+import org.apache.helix.monitoring.MonitoringServerOwner;
import org.apache.helix.participant.HelixStateMachineEngine;
import org.apache.helix.participant.StateMachineEngine;
import org.apache.helix.spectator.RoutingTableProvider;
@@ -55,7 +56,7 @@ import org.apache.helix.store.zk.ZkHelixPropertyStore;
* @see RoutingTableProvider RoutingTableProvider for spectator
* @see GenericHelixController RoutingTableProvider for controller
*/
-public interface HelixManager {
+public interface HelixManager extends MonitoringServerOwner {
public static final String ALLOW_PARTICIPANT_AUTO_JOIN =
ZKHelixManager.ALLOW_PARTICIPANT_AUTO_JOIN;
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-core/src/main/java/org/apache/helix/PropertyKey.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/PropertyKey.java b/helix-core/src/main/java/org/apache/helix/PropertyKey.java
index ebd7a35..4ee3f83 100644
--- a/helix-core/src/main/java/org/apache/helix/PropertyKey.java
+++ b/helix-core/src/main/java/org/apache/helix/PropertyKey.java
@@ -58,9 +58,11 @@ import org.apache.helix.model.HealthStat;
import org.apache.helix.model.HelixConfigScope.ConfigScopeProperty;
import org.apache.helix.model.IdealState;
import org.apache.helix.model.InstanceConfig;
+import org.apache.helix.model.Leader;
import org.apache.helix.model.LeaderHistory;
import org.apache.helix.model.LiveInstance;
import org.apache.helix.model.Message;
+import org.apache.helix.model.MonitoringConfig;
import org.apache.helix.model.PartitionConfiguration;
import org.apache.helix.model.PauseSignal;
import org.apache.helix.model.PersistentStats;
@@ -317,13 +319,31 @@ public class PropertyKey {
* @param constraintType
* @return {@link PropertyKey}
*/
-
public PropertyKey constraint(String constraintType) {
return new PropertyKey(CONFIGS, ClusterConstraints.class, _clusterName,
ConfigScopeProperty.CONSTRAINT.toString(), constraintType);
}
/**
+ * Get a property key associated with all {@link MonitoringConfig}
+ * @return {@link PropertyKey}
+ */
+ public PropertyKey monitoringConfigs() {
+ return new PropertyKey(CONFIGS, ConfigScopeProperty.MONITORING, MonitoringConfig.class,
+ _clusterName, ConfigScopeProperty.MONITORING.toString());
+ }
+
+ /**
+ * Get a property key associated with a single {@link MonitoringConfig}
+ * @param monitoringConfigName name of the configuration
+ * @return {@link PropertyKey}
+ */
+ public PropertyKey monitoringConfig(String monitoringConfigName) {
+ return new PropertyKey(CONFIGS, ConfigScopeProperty.MONITORING, MonitoringConfig.class,
+ _clusterName, ConfigScopeProperty.MONITORING.toString(), monitoringConfigName);
+ }
+
+ /**
* Get a property key associated with {@link LiveInstance}
* @return {@link PropertyKey}
*/
@@ -648,11 +668,11 @@ public class PropertyKey {
}
/**
- * Get a property key associated with a {@link LiveInstance} leader
+ * Get a property key associated with a {@link Leader} leader
* @return {@link PropertyKey}
*/
public PropertyKey controllerLeader() {
- return new PropertyKey(LEADER, LiveInstance.class, _clusterName);
+ return new PropertyKey(LEADER, Leader.class, _clusterName);
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-core/src/main/java/org/apache/helix/api/accessor/ClusterAccessor.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/api/accessor/ClusterAccessor.java b/helix-core/src/main/java/org/apache/helix/api/accessor/ClusterAccessor.java
index b01a3ec..1195ce2 100644
--- a/helix-core/src/main/java/org/apache/helix/api/accessor/ClusterAccessor.java
+++ b/helix-core/src/main/java/org/apache/helix/api/accessor/ClusterAccessor.java
@@ -61,6 +61,7 @@ import org.apache.helix.model.CurrentState;
import org.apache.helix.model.ExternalView;
import org.apache.helix.model.IdealState;
import org.apache.helix.model.InstanceConfig;
+import org.apache.helix.model.Leader;
import org.apache.helix.model.LiveInstance;
import org.apache.helix.model.Message;
import org.apache.helix.model.PauseSignal;
@@ -194,7 +195,7 @@ public class ClusterAccessor {
return false;
}
- LiveInstance leader = _accessor.getProperty(_keyBuilder.controllerLeader());
+ Leader leader = _accessor.getProperty(_keyBuilder.controllerLeader());
if (leader != null) {
LOG.error("Can't drop cluster: " + _clusterId + ", because leader: " + leader.getId()
+ " are running, shutdown leader first.");
@@ -213,7 +214,7 @@ public class ClusterAccessor {
LOG.error("Cluster is not fully set up");
return null;
}
- LiveInstance leader = _accessor.getProperty(_keyBuilder.controllerLeader());
+ Leader leader = _accessor.getProperty(_keyBuilder.controllerLeader());
/**
* map of constraint-type to constraints
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-core/src/main/java/org/apache/helix/api/accessor/ControllerAccessor.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/api/accessor/ControllerAccessor.java b/helix-core/src/main/java/org/apache/helix/api/accessor/ControllerAccessor.java
index 609e458..74328d7 100644
--- a/helix-core/src/main/java/org/apache/helix/api/accessor/ControllerAccessor.java
+++ b/helix-core/src/main/java/org/apache/helix/api/accessor/ControllerAccessor.java
@@ -23,7 +23,7 @@ import org.apache.helix.HelixDataAccessor;
import org.apache.helix.PropertyKey;
import org.apache.helix.api.Controller;
import org.apache.helix.api.id.ControllerId;
-import org.apache.helix.model.LiveInstance;
+import org.apache.helix.model.Leader;
public class ControllerAccessor {
private final HelixDataAccessor _accessor;
@@ -39,7 +39,7 @@ public class ControllerAccessor {
* @return Controller snapshot, or null
*/
public Controller readLeader() {
- LiveInstance leader = _accessor.getProperty(_keyBuilder.controllerLeader());
+ Leader leader = _accessor.getProperty(_keyBuilder.controllerLeader());
if (leader != null) {
ControllerId leaderId = ControllerId.from(leader.getId());
return new Controller(leaderId, leader, true);
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java b/helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java
index eec745e..ab51670 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java
+++ b/helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java
@@ -61,6 +61,7 @@ import org.apache.helix.model.ExternalView;
import org.apache.helix.model.HealthStat;
import org.apache.helix.model.IdealState;
import org.apache.helix.model.InstanceConfig;
+import org.apache.helix.model.Leader;
import org.apache.helix.model.LiveInstance;
import org.apache.helix.model.Message;
import org.apache.helix.model.PauseSignal;
@@ -420,7 +421,7 @@ public class GenericHelixController implements ConfigChangeListener, IdealStateC
// double check if this controller is the leader
Builder keyBuilder = accessor.keyBuilder();
- LiveInstance leader = accessor.getProperty(keyBuilder.controllerLeader());
+ Leader leader = accessor.getProperty(keyBuilder.controllerLeader());
if (leader == null) {
logger
.warn("No controller exists for cluster:" + changeContext.getManager().getClusterName());
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-core/src/main/java/org/apache/helix/manager/zk/DistributedLeaderElection.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/DistributedLeaderElection.java b/helix-core/src/main/java/org/apache/helix/manager/zk/DistributedLeaderElection.java
index 9836020..d4ffd80 100644
--- a/helix-core/src/main/java/org/apache/helix/manager/zk/DistributedLeaderElection.java
+++ b/helix-core/src/main/java/org/apache/helix/manager/zk/DistributedLeaderElection.java
@@ -19,7 +19,6 @@ package org.apache.helix.manager.zk;
* under the License.
*/
-import java.lang.management.ManagementFactory;
import java.util.List;
import org.apache.helix.ControllerChangeListener;
@@ -31,9 +30,7 @@ import org.apache.helix.NotificationContext;
import org.apache.helix.PropertyKey.Builder;
import org.apache.helix.PropertyType;
import org.apache.helix.controller.GenericHelixController;
-import org.apache.helix.controller.restlet.ZKPropertyTransferServer;
import org.apache.helix.model.LeaderHistory;
-import org.apache.helix.model.LiveInstance;
import org.apache.log4j.Logger;
/**
@@ -113,46 +110,7 @@ public class DistributedLeaderElection implements ControllerChangeListener {
}
private boolean tryUpdateController(HelixManager manager) {
- HelixDataAccessor accessor = manager.getHelixDataAccessor();
- Builder keyBuilder = accessor.keyBuilder();
-
- LiveInstance leader = new LiveInstance(manager.getInstanceName());
- try {
- leader.setLiveInstance(ManagementFactory.getRuntimeMXBean().getName());
- leader.setSessionId(manager.getSessionId());
- leader.setHelixVersion(manager.getVersion());
- if (ZKPropertyTransferServer.getInstance() != null) {
- String zkPropertyTransferServiceUrl =
- ZKPropertyTransferServer.getInstance().getWebserviceUrl();
- if (zkPropertyTransferServiceUrl != null) {
- leader.setWebserviceUrl(zkPropertyTransferServiceUrl);
- }
- } else {
- LOG.warn("ZKPropertyTransferServer instnace is null");
- }
- boolean success = accessor.createProperty(keyBuilder.controllerLeader(), leader);
- if (success) {
- return true;
- } else {
- LOG.info("Unable to become leader probably because some other controller becames the leader");
- }
- } catch (Exception e) {
- LOG.error(
- "Exception when trying to updating leader record in cluster:" + manager.getClusterName()
- + ". Need to check again whether leader node has been created or not", e);
- }
-
- leader = accessor.getProperty(keyBuilder.controllerLeader());
- if (leader != null) {
- String leaderSessionId = leader.getTypedSessionId().stringify();
- LOG.info("Leader exists for cluster: " + manager.getClusterName() + ", currentLeader: "
- + leader.getInstanceName() + ", leaderSessionId: " + leaderSessionId);
-
- if (leaderSessionId != null && leaderSessionId.equals(manager.getSessionId())) {
- return true;
- }
- }
- return false;
+ return ZkHelixLeaderElection.tryBecomingLeader(manager);
}
private void updateHistory(HelixManager manager) {
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-core/src/main/java/org/apache/helix/manager/zk/HelixConnectionAdaptor.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/HelixConnectionAdaptor.java b/helix-core/src/main/java/org/apache/helix/manager/zk/HelixConnectionAdaptor.java
index e52427c..65a192a 100644
--- a/helix-core/src/main/java/org/apache/helix/manager/zk/HelixConnectionAdaptor.java
+++ b/helix-core/src/main/java/org/apache/helix/manager/zk/HelixConnectionAdaptor.java
@@ -51,6 +51,7 @@ import org.apache.helix.api.id.ParticipantId;
import org.apache.helix.api.id.SessionId;
import org.apache.helix.healthcheck.ParticipantHealthReportCollector;
import org.apache.helix.model.HelixConfigScope.ConfigScopeProperty;
+import org.apache.helix.monitoring.MonitoringServer;
import org.apache.helix.participant.StateMachineEngine;
import org.apache.helix.store.zk.ZkHelixPropertyStore;
import org.apache.log4j.Logger;
@@ -235,8 +236,7 @@ public class HelixConnectionAdaptor implements HelixManager {
engine = autoController.getStateMachineEngine();
break;
default:
- LOG.info("helix manager type: " + _role.getType()
- + " does NOT have state-machine-engine");
+ LOG.error("Helix role: " + _role.getType() + " does NOT have state-machine engine");
break;
}
@@ -256,7 +256,7 @@ public class HelixConnectionAdaptor implements HelixManager {
isLeader = autoController.isLeader();
break;
default:
- LOG.info("helix manager type: " + _role.getType() + " does NOT support leadership");
+ LOG.error("Helix role: " + _role.getType() + " does NOT support leadership");
break;
}
return isLeader;
@@ -286,8 +286,8 @@ public class HelixConnectionAdaptor implements HelixManager {
autoController.addPreConnectCallback(callback);
break;
default:
- LOG.info("helix manager type: " + _role.getType()
- + " does NOT support add pre-connect callback");
+ LOG.error("Helix role: " + _role.getType()
+ + " does NOT support adding a pre-connect callback");
break;
}
}
@@ -304,16 +304,51 @@ public class HelixConnectionAdaptor implements HelixManager {
autoController.setLiveInstanceInfoProvider(liveInstanceInfoProvider);
break;
default:
- LOG.info("helix manager type: " + _role.getType()
- + " does NOT support set additional live instance information");
+ LOG.error("Helix role: " + _role.getType()
+ + " does NOT support setting additional live instance information");
break;
}
}
@Override
public void addControllerMessageListener(MessageListener listener) {
- // TODO Auto-generated method stub
+ _connection.addControllerMessageListener(_role, listener, _clusterId);
+ }
+ @Override
+ public void registerMonitoringServer(MonitoringServer monitoringServer) {
+ switch (_role.getType()) {
+ case CONTROLLER:
+ HelixController controller = (HelixController) _role;
+ controller.registerMonitoringServer(monitoringServer);
+ break;
+ case CONTROLLER_PARTICIPANT:
+ HelixAutoController autoController = (HelixAutoController) _role;
+ autoController.registerMonitoringServer(monitoringServer);
+ break;
+ default:
+ LOG.error("A non-controller cannot own a monitoring server!");
+ break;
+ }
+ }
+
+ @Override
+ public MonitoringServer getMonitoringServer() {
+ MonitoringServer server = null;
+ switch (_role.getType()) {
+ case CONTROLLER:
+ HelixController controller = (HelixController) _role;
+ server = controller.getMonitoringServer();
+ break;
+ case CONTROLLER_PARTICIPANT:
+ HelixAutoController autoController = (HelixAutoController) _role;
+ server = autoController.getMonitoringServer();
+ break;
+ default:
+ LOG.error("Cannot get a monitoring server for a non-controller (" + _role.getType() + ")!");
+ break;
+ }
+ return server;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixDataAccessor.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixDataAccessor.java b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixDataAccessor.java
index 471530c..f93d7c4 100644
--- a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixDataAccessor.java
+++ b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixDataAccessor.java
@@ -45,7 +45,7 @@ import org.apache.helix.ZNRecordUpdater;
import org.apache.helix.controller.restlet.ZNRecordUpdate;
import org.apache.helix.controller.restlet.ZNRecordUpdate.OpCode;
import org.apache.helix.controller.restlet.ZkPropertyTransferClient;
-import org.apache.helix.model.LiveInstance;
+import org.apache.helix.model.Leader;
import org.apache.log4j.Logger;
import org.apache.zookeeper.data.Stat;
@@ -504,7 +504,7 @@ public class ZKHelixDataAccessor implements HelixDataAccessor, ControllerChangeL
void refreshZkPropertyTransferUrl() {
try {
- LiveInstance leader = getProperty(keyBuilder().controllerLeader());
+ Leader leader = getProperty(keyBuilder().controllerLeader());
if (leader != null) {
_zkPropertyTransferSvcUrl = leader.getWebserviceUrl();
LOG.info("_zkPropertyTransferSvcUrl : " + _zkPropertyTransferSvcUrl + " Controller "
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java
index b71304a..83eba53 100644
--- a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java
+++ b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java
@@ -37,12 +37,12 @@ import org.apache.helix.CurrentStateChangeListener;
import org.apache.helix.ExternalViewChangeListener;
import org.apache.helix.HealthStateChangeListener;
import org.apache.helix.HelixAdmin;
+import org.apache.helix.HelixConstants.ChangeType;
import org.apache.helix.HelixDataAccessor;
import org.apache.helix.HelixException;
import org.apache.helix.HelixManager;
import org.apache.helix.HelixManagerProperties;
import org.apache.helix.HelixTimerTask;
-import org.apache.helix.HelixConstants.ChangeType;
import org.apache.helix.IdealStateChangeListener;
import org.apache.helix.InstanceConfigChangeListener;
import org.apache.helix.InstanceType;
@@ -63,17 +63,17 @@ import org.apache.helix.healthcheck.ParticipantHealthReportCollector;
import org.apache.helix.healthcheck.ParticipantHealthReportCollectorImpl;
import org.apache.helix.healthcheck.ParticipantHealthReportTask;
import org.apache.helix.messaging.DefaultMessagingService;
-import org.apache.helix.model.ConfigScope;
import org.apache.helix.model.HelixConfigScope.ConfigScopeProperty;
+import org.apache.helix.model.Leader;
import org.apache.helix.model.LiveInstance;
-import org.apache.helix.model.builder.ConfigScopeBuilder;
+import org.apache.helix.monitoring.MonitoringServer;
import org.apache.helix.monitoring.ZKPathDataDumpTask;
import org.apache.helix.participant.HelixStateMachineEngine;
import org.apache.helix.participant.StateMachineEngine;
import org.apache.helix.store.zk.ZkHelixPropertyStore;
import org.apache.log4j.Logger;
-import org.apache.zookeeper.Watcher.Event.KeeperState;
import org.apache.zookeeper.Watcher.Event.EventType;
+import org.apache.zookeeper.Watcher.Event.KeeperState;
import org.apache.zookeeper.ZooKeeper.States;
public class ZKHelixManager implements HelixManager, IZkStateListener {
@@ -106,6 +106,7 @@ public class ZKHelixManager implements HelixManager, IZkStateListener {
private ConfigAccessor _configAccessor;
private ZkHelixPropertyStore<ZNRecord> _helixPropertyStore;
protected LiveInstanceInfoProvider _liveInstanceInfoProvider = null;
+ private MonitoringServer _monitoringServer;
private volatile String _sessionId;
@@ -213,6 +214,8 @@ public class ZKHelixManager implements HelixManager, IZkStateListener {
_sessionTimeout =
getSystemPropertyAsInt("zk.session.timeout", ZkClient.DEFAULT_SESSION_TIMEOUT);
+ _monitoringServer = null;
+
/**
* instance type specific init
*/
@@ -545,6 +548,11 @@ public class ZKHelixManager implements HelixManager, IZkStateListener {
*/
_messagingService.getExecutor().shutdown();
+ // stop monitoring
+ if (_monitoringServer != null && _monitoringServer.isStarted()) {
+ _monitoringServer.stop();
+ }
+
// TODO reset user defined handlers only
resetHandlers();
@@ -603,7 +611,7 @@ public class ZKHelixManager implements HelixManager, IZkStateListener {
}
try {
- LiveInstance leader = _dataAccessor.getProperty(_keyBuilder.controllerLeader());
+ Leader leader = _dataAccessor.getProperty(_keyBuilder.controllerLeader());
if (leader != null) {
String leaderName = leader.getInstanceName();
String sessionId = leader.getSessionId();
@@ -859,6 +867,16 @@ public class ZKHelixManager implements HelixManager, IZkStateListener {
initHandlers(_handlers);
}
+ @Override
+ public void registerMonitoringServer(MonitoringServer monitoringServer) {
+ _monitoringServer = monitoringServer;
+ }
+
+ @Override
+ public MonitoringServer getMonitoringServer() {
+ return _monitoringServer;
+ }
+
void handleNewSessionAsParticipant() throws Exception {
/**
* auto-join
@@ -889,6 +907,16 @@ public class ZKHelixManager implements HelixManager, IZkStateListener {
}
void handleNewSessionAsController() {
+ // get the monitoring service up
+ if (_monitoringServer != null) {
+ if (_monitoringServer.isStarted()) {
+ _monitoringServer.stop();
+ }
+ _monitoringServer.addConfigs(_dataAccessor);
+ _monitoringServer.start();
+ }
+
+ // get the leader election process going
if (_leaderElectionHandler != null) {
_leaderElectionHandler.init();
} else {
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-core/src/main/java/org/apache/helix/manager/zk/ZkHelixAutoController.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/ZkHelixAutoController.java b/helix-core/src/main/java/org/apache/helix/manager/zk/ZkHelixAutoController.java
index 136d47e..3967ed9 100644
--- a/helix-core/src/main/java/org/apache/helix/manager/zk/ZkHelixAutoController.java
+++ b/helix-core/src/main/java/org/apache/helix/manager/zk/ZkHelixAutoController.java
@@ -29,6 +29,7 @@ import org.apache.helix.api.id.ClusterId;
import org.apache.helix.api.id.ControllerId;
import org.apache.helix.api.id.Id;
import org.apache.helix.api.id.ParticipantId;
+import org.apache.helix.monitoring.MonitoringServer;
import org.apache.helix.participant.StateMachineEngine;
import org.apache.log4j.Logger;
@@ -130,4 +131,14 @@ public class ZkHelixAutoController implements HelixAutoController {
return _controller.isLeader();
}
+ @Override
+ public void registerMonitoringServer(MonitoringServer server) {
+ _controller.registerMonitoringServer(server);
+ }
+
+ @Override
+ public MonitoringServer getMonitoringServer() {
+ return _controller.getMonitoringServer();
+ }
+
}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-core/src/main/java/org/apache/helix/manager/zk/ZkHelixController.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/ZkHelixController.java b/helix-core/src/main/java/org/apache/helix/manager/zk/ZkHelixController.java
index f116c76..9da59b9 100644
--- a/helix-core/src/main/java/org/apache/helix/manager/zk/ZkHelixController.java
+++ b/helix-core/src/main/java/org/apache/helix/manager/zk/ZkHelixController.java
@@ -41,7 +41,8 @@ import org.apache.helix.healthcheck.HealthStatsAggregationTask;
import org.apache.helix.healthcheck.HealthStatsAggregator;
import org.apache.helix.messaging.DefaultMessagingService;
import org.apache.helix.messaging.handling.MessageHandlerFactory;
-import org.apache.helix.model.LiveInstance;
+import org.apache.helix.model.Leader;
+import org.apache.helix.monitoring.MonitoringServer;
import org.apache.helix.monitoring.StatusDumpTask;
import org.apache.log4j.Logger;
@@ -58,8 +59,10 @@ public class ZkHelixController implements HelixController {
final HelixDataAccessor _accessor;
final HelixManager _manager;
final ZkHelixLeaderElection _leaderElection;
+ MonitoringServer _monitoringServer;
- public ZkHelixController(ZkHelixConnection connection, ClusterId clusterId, ControllerId controllerId) {
+ public ZkHelixController(ZkHelixConnection connection, ClusterId clusterId,
+ ControllerId controllerId) {
_connection = connection;
_clusterId = clusterId;
_controllerId = controllerId;
@@ -75,6 +78,8 @@ public class ZkHelixController implements HelixController {
_timerTasks.add(new HealthStatsAggregationTask(new HealthStatsAggregator(_manager)));
_timerTasks.add(new StatusDumpTask(clusterId, _manager.getHelixDataAccessor()));
+
+ _monitoringServer = null;
}
void startTimerTasks() {
@@ -113,6 +118,11 @@ public class ZkHelixController implements HelixController {
*/
_connection.resetHandlers(this);
+ // stop the monitoring service if it's running
+ if (_monitoringServer != null && _monitoringServer.isStarted()) {
+ _monitoringServer.stop();
+ }
+
}
void init() {
@@ -125,6 +135,14 @@ public class ZkHelixController implements HelixController {
}
/**
+ * start the monitoring service if it exists; this must happen before leader election
+ */
+ if (_monitoringServer != null) {
+ _monitoringServer.addConfigs(_accessor);
+ _monitoringServer.start();
+ }
+
+ /**
* leader-election listener should be reset/init before all other controller listeners;
* it's ok to add a listener multiple times, since we check existence in
* ZkHelixConnection#addXXXListner()
@@ -180,7 +198,7 @@ public class ZkHelixController implements HelixController {
public boolean isLeader() {
PropertyKey.Builder keyBuilder = _accessor.keyBuilder();
try {
- LiveInstance leader = _accessor.getProperty(keyBuilder.controllerLeader());
+ Leader leader = _accessor.getProperty(keyBuilder.controllerLeader());
if (leader != null) {
String leaderName = leader.getInstanceName();
String sessionId = leader.getSessionId();
@@ -195,13 +213,22 @@ public class ZkHelixController implements HelixController {
return false;
}
+ @Override
+ public void registerMonitoringServer(MonitoringServer server) {
+ _monitoringServer = server;
+ }
+
+ @Override
+ public MonitoringServer getMonitoringServer() {
+ return _monitoringServer;
+ }
+
void addListenersToController(GenericHelixController pipeline) {
try {
/**
* setup controller message listener and register message handlers
*/
- _connection.addControllerMessageListener(this, _messagingService.getExecutor(),
- _clusterId);
+ _connection.addControllerMessageListener(this, _messagingService.getExecutor(), _clusterId);
MessageHandlerFactory defaultControllerMsgHandlerFactory =
new DefaultControllerMessageHandlerFactory();
_messagingService.getExecutor().registerMessageHandlerFactory(
@@ -224,8 +251,7 @@ public class ZkHelixController implements HelixController {
_connection.addIdealStateChangeListener(this, pipeline, _clusterId);
_connection.addControllerListener(this, pipeline, _clusterId);
} catch (ZkInterruptedException e) {
- LOG.warn("zk connection is interrupted during addListenersToController()"
- + e);
+ LOG.warn("zk connection is interrupted during addListenersToController()", e);
} catch (Exception e) {
LOG.error("Error addListenersToController", e);
}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-core/src/main/java/org/apache/helix/manager/zk/ZkHelixLeaderElection.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/ZkHelixLeaderElection.java b/helix-core/src/main/java/org/apache/helix/manager/zk/ZkHelixLeaderElection.java
index 77da158..3c5b3db 100644
--- a/helix-core/src/main/java/org/apache/helix/manager/zk/ZkHelixLeaderElection.java
+++ b/helix-core/src/main/java/org/apache/helix/manager/zk/ZkHelixLeaderElection.java
@@ -22,8 +22,6 @@ package org.apache.helix.manager.zk;
import java.lang.management.ManagementFactory;
import org.apache.helix.ControllerChangeListener;
-import org.apache.helix.HelixConnection;
-import org.apache.helix.HelixController;
import org.apache.helix.HelixDataAccessor;
import org.apache.helix.HelixManager;
import org.apache.helix.InstanceType;
@@ -34,8 +32,9 @@ import org.apache.helix.api.id.ClusterId;
import org.apache.helix.api.id.ControllerId;
import org.apache.helix.controller.GenericHelixController;
import org.apache.helix.controller.restlet.ZKPropertyTransferServer;
+import org.apache.helix.model.Leader;
import org.apache.helix.model.LeaderHistory;
-import org.apache.helix.model.LiveInstance;
+import org.apache.helix.monitoring.MonitoringServer;
import org.apache.log4j.Logger;
// TODO GenericHelixController has a controller-listener, we can invoke leader-election from there
@@ -84,7 +83,6 @@ public class ZkHelixLeaderElection implements ControllerChangeListener {
|| changeContext.getType().equals(NotificationContext.Type.CALLBACK)) {
LOG.info(_controllerId + " is trying to acquire leadership for cluster: " + _clusterId);
-
while (accessor.getProperty(keyBuilder.controllerLeader()) == null) {
boolean success = tryUpdateController(_manager);
if (success) {
@@ -123,10 +121,31 @@ public class ZkHelixLeaderElection implements ControllerChangeListener {
}
private boolean tryUpdateController(HelixManager manager) {
+ return tryBecomingLeader(manager);
+ }
+
+ private void updateHistory(HelixManager manager) {
+ HelixDataAccessor accessor = manager.getHelixDataAccessor();
+ PropertyKey.Builder keyBuilder = accessor.keyBuilder();
+
+ LeaderHistory history = accessor.getProperty(keyBuilder.controllerLeaderHistory());
+ if (history == null) {
+ history = new LeaderHistory(PropertyType.HISTORY.toString());
+ }
+ history.updateHistory(manager.getClusterName(), manager.getInstanceName());
+ accessor.setProperty(keyBuilder.controllerLeaderHistory(), history);
+ }
+
+ /**
+ * Try to make this controller the leader
+ * @param manager HelixManager connection for the controller
+ * @return true if the controller is the leader, false otherwise
+ */
+ public static boolean tryBecomingLeader(HelixManager manager) {
HelixDataAccessor accessor = manager.getHelixDataAccessor();
PropertyKey.Builder keyBuilder = accessor.keyBuilder();
- LiveInstance leader = new LiveInstance(manager.getInstanceName());
+ Leader leader = new Leader(ControllerId.from(manager.getInstanceName()));
try {
leader.setLiveInstance(ManagementFactory.getRuntimeMXBean().getName());
leader.setSessionId(manager.getSessionId());
@@ -138,13 +157,18 @@ public class ZkHelixLeaderElection implements ControllerChangeListener {
leader.setWebserviceUrl(zkPropertyTransferServiceUrl);
}
} else {
- LOG.warn("ZKPropertyTransferServer instnace is null");
+ LOG.warn("ZKPropertyTransferServer instance is null");
+ }
+ MonitoringServer server = manager.getMonitoringServer();
+ if (server != null) {
+ leader.setMonitoringHost(server.getHost());
+ leader.setMonitoringPort(server.getPort());
}
boolean success = accessor.createProperty(keyBuilder.controllerLeader(), leader);
if (success) {
return true;
} else {
- LOG.info("Unable to become leader probably because some other controller becames the leader");
+ LOG.info("Unable to become leader probably because some other controller became the leader");
}
} catch (Exception e) {
LOG.error(
@@ -164,16 +188,4 @@ public class ZkHelixLeaderElection implements ControllerChangeListener {
}
return false;
}
-
- private void updateHistory(HelixManager manager) {
- HelixDataAccessor accessor = manager.getHelixDataAccessor();
- PropertyKey.Builder keyBuilder = accessor.keyBuilder();
-
- LeaderHistory history = accessor.getProperty(keyBuilder.controllerLeaderHistory());
- if (history == null) {
- history = new LeaderHistory(PropertyType.HISTORY.toString());
- }
- history.updateHistory(manager.getClusterName(), manager.getInstanceName());
- accessor.setProperty(keyBuilder.controllerLeaderHistory(), history);
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-core/src/main/java/org/apache/helix/model/HelixConfigScope.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/model/HelixConfigScope.java b/helix-core/src/main/java/org/apache/helix/model/HelixConfigScope.java
index 95c9848..40d5671 100644
--- a/helix-core/src/main/java/org/apache/helix/model/HelixConfigScope.java
+++ b/helix-core/src/main/java/org/apache/helix/model/HelixConfigScope.java
@@ -35,7 +35,8 @@ public class HelixConfigScope {
PARTICIPANT(2, 0),
RESOURCE(2, 0),
PARTITION(2, 1),
- CONSTRAINT(2, 0);
+ CONSTRAINT(2, 0),
+ MONITORING(2, 0);
final int _zkPathArgNum;
final int _mapKeyArgNum;
@@ -77,11 +78,14 @@ public class HelixConfigScope {
"/{clusterName}/CONFIGS/RESOURCE/{resourceName}");
template.addEntry(ConfigScopeProperty.PARTITION, 2,
"/{clusterName}/CONFIGS/RESOURCE/{resourceName}");
+ template.addEntry(ConfigScopeProperty.MONITORING, 2,
+ "/{clusterName}/CONFIGS/MONITORING/{configName}");
// get children
template.addEntry(ConfigScopeProperty.CLUSTER, 1, "/{clusterName}/CONFIGS/CLUSTER");
template.addEntry(ConfigScopeProperty.PARTICIPANT, 1, "/{clusterName}/CONFIGS/PARTICIPANT");
template.addEntry(ConfigScopeProperty.RESOURCE, 1, "/{clusterName}/CONFIGS/RESOURCE");
+ template.addEntry(ConfigScopeProperty.MONITORING, 1, "/{clusterName}/CONFIGS/MONITORING");
}
final ConfigScopeProperty _type;
@@ -92,6 +96,11 @@ public class HelixConfigScope {
*/
final String _participantName;
+ /**
+ * this is the monitoring config name if type is MONITORING, or null otherwise
+ */
+ final String _monitoringConfigName;
+
final String _resourceName;
final String _zkPath;
@@ -140,6 +149,13 @@ public class HelixConfigScope {
_resourceName = null;
}
+ // init monitoring config name
+ if (type == ConfigScopeProperty.MONITORING && _isFullKey) {
+ _monitoringConfigName = zkPathKeys.get(1);
+ } else {
+ _monitoringConfigName = null;
+ }
+
_zkPath = template.instantiate(type, zkPathKeys.toArray(new String[0]));
_mapKey = mapKey;
}
@@ -177,6 +193,14 @@ public class HelixConfigScope {
}
/**
+ * Get the monitoring config name if it exists
+ * @return the monitoring config name if the type is MONITORING, or null
+ */
+ public String getMonitoringConfigName() {
+ return _monitoringConfigName;
+ }
+
+ /**
* Get the path to the corresponding ZNode
* @return a Zookeeper path
*/
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-core/src/main/java/org/apache/helix/model/Leader.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/model/Leader.java b/helix-core/src/main/java/org/apache/helix/model/Leader.java
new file mode 100644
index 0000000..1aaf465
--- /dev/null
+++ b/helix-core/src/main/java/org/apache/helix/model/Leader.java
@@ -0,0 +1,98 @@
+package org.apache.helix.model;
+
+/*
+ * 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.
+ */
+
+import org.apache.helix.ZNRecord;
+import org.apache.helix.api.id.ControllerId;
+
+/**
+ * A special live instance that represents the leader controller
+ */
+public class Leader extends LiveInstance {
+ public enum LeaderProperty {
+ ZKPROPERTYTRANSFERURL,
+ MONITORING_HOST,
+ MONITORING_PORT
+ }
+
+ /**
+ * Instantiate with a controller identifier
+ * @param controllerId typed controller identifier
+ */
+ public Leader(ControllerId controllerId) {
+ super(controllerId.toString());
+ }
+
+ /**
+ * Instantiate with a pre-populated record
+ * @param record ZNRecord corresponding to a live instance
+ */
+ public Leader(ZNRecord record) {
+ super(record);
+ }
+
+ /**
+ * Get a web service URL where ZK properties can be transferred to
+ * @return a fully-qualified URL
+ */
+ public String getWebserviceUrl() {
+ return _record.getSimpleField(LeaderProperty.ZKPROPERTYTRANSFERURL.toString());
+ }
+
+ /**
+ * Set a web service URL where ZK properties can be transferred to
+ * @param url a fully-qualified URL
+ */
+ public void setWebserviceUrl(String url) {
+ _record.setSimpleField(LeaderProperty.ZKPROPERTYTRANSFERURL.toString(), url);
+ }
+
+ /**
+ * Get the monitoring port attached to this instance
+ * @return port, or -1
+ */
+ public int getMonitoringPort() {
+ return _record.getIntField(LeaderProperty.MONITORING_PORT.toString(), -1);
+ }
+
+ /**
+ * Set the monitoring port attached to this instance
+ * @param port the port to contact for monitoring
+ */
+ public void setMonitoringPort(int port) {
+ _record.setIntField(LeaderProperty.MONITORING_PORT.toString(), port);
+ }
+
+ /**
+ * Get the monitoring host attached to this instance
+ * @return host, or null
+ */
+ public String getMonitoringHost() {
+ return _record.getSimpleField(LeaderProperty.MONITORING_HOST.toString());
+ }
+
+ /**
+ * Set the monitoring host attached to this instance
+ * @param host the host to contact for monitoring
+ */
+ public void setMonitoringHost(String host) {
+ _record.setSimpleField(LeaderProperty.MONITORING_HOST.toString(), host);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-core/src/main/java/org/apache/helix/model/LiveInstance.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/model/LiveInstance.java b/helix-core/src/main/java/org/apache/helix/model/LiveInstance.java
index e9348ec..8f919fb 100644
--- a/helix-core/src/main/java/org/apache/helix/model/LiveInstance.java
+++ b/helix-core/src/main/java/org/apache/helix/model/LiveInstance.java
@@ -37,8 +37,7 @@ public class LiveInstance extends HelixProperty {
public enum LiveInstanceProperty {
SESSION_ID,
HELIX_VERSION,
- LIVE_INSTANCE,
- ZKPROPERTYTRANSFERURL
+ LIVE_INSTANCE
}
private static final Logger _logger = Logger.getLogger(LiveInstance.class.getName());
@@ -163,22 +162,6 @@ public class LiveInstance extends HelixProperty {
return _record.getModifiedTime();
}
- /**
- * Get a web service URL where ZK properties can be transferred to
- * @return a fully-qualified URL
- */
- public String getWebserviceUrl() {
- return _record.getSimpleField(LiveInstanceProperty.ZKPROPERTYTRANSFERURL.toString());
- }
-
- /**
- * Set a web service URL where ZK properties can be transferred to
- * @param url a fully-qualified URL
- */
- public void setWebserviceUrl(String url) {
- _record.setSimpleField(LiveInstanceProperty.ZKPROPERTYTRANSFERURL.toString(), url);
- }
-
@Override
public boolean isValid() {
if (getTypedSessionId() == null) {
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-core/src/main/java/org/apache/helix/model/MonitoringConfig.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/model/MonitoringConfig.java b/helix-core/src/main/java/org/apache/helix/model/MonitoringConfig.java
new file mode 100644
index 0000000..e95b545
--- /dev/null
+++ b/helix-core/src/main/java/org/apache/helix/model/MonitoringConfig.java
@@ -0,0 +1,87 @@
+package org.apache.helix.model;
+
+/*
+ * 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.
+ */
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.helix.HelixProperty;
+import org.apache.helix.ZNRecord;
+import org.apache.log4j.Logger;
+
+/**
+ * Wrapper for a monitoring config file
+ */
+public class MonitoringConfig extends HelixProperty {
+ private static final Logger LOG = Logger.getLogger(MonitoringConfig.class);
+
+ /**
+ * Properties describing the config
+ */
+ public enum MonitoringConfigProperty {
+ CONFIG_FILE
+ }
+
+ /**
+ * Instantiate from a record
+ * @param record populated ZNRecord
+ */
+ public MonitoringConfig(ZNRecord record) {
+ super(record);
+ }
+
+ /**
+ * Create an empty config with a name
+ * @param configName the name, will map to a file name
+ */
+ public MonitoringConfig(String configName) {
+ super(configName);
+ }
+
+ /**
+ * Set the config from an input stream
+ * @param is an open InputStream
+ */
+ public void setConfig(InputStream is) {
+ try {
+ String config = IOUtils.toString(is);
+ setConfig(config);
+ } catch (IOException e) {
+ LOG.error("Could not persist the monitoring config!");
+ }
+ }
+
+ /**
+ * Set the config from a String
+ * @param config a String containing the entire config
+ */
+ public void setConfig(String config) {
+ _record.setSimpleField(MonitoringConfigProperty.CONFIG_FILE.toString(), config);
+ }
+
+ /**
+ * Get the config
+ * @return String containing the config
+ */
+ public String getConfig() {
+ return _record.getSimpleField(MonitoringConfigProperty.CONFIG_FILE.toString());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-core/src/main/java/org/apache/helix/model/builder/HelixConfigScopeBuilder.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/model/builder/HelixConfigScopeBuilder.java b/helix-core/src/main/java/org/apache/helix/model/builder/HelixConfigScopeBuilder.java
index d65ffd3..87cabcf 100644
--- a/helix-core/src/main/java/org/apache/helix/model/builder/HelixConfigScopeBuilder.java
+++ b/helix-core/src/main/java/org/apache/helix/model/builder/HelixConfigScopeBuilder.java
@@ -34,6 +34,7 @@ public class HelixConfigScopeBuilder {
private String _participantName;
private String _resourceName;
private String _partitionName;
+ private String _monitoringConfigName;
public HelixConfigScopeBuilder(ConfigScopeProperty type, String... keys) {
int argNum = type.getZkPathArgNum() + type.getMapKeyArgNum();
@@ -64,6 +65,11 @@ public class HelixConfigScopeBuilder {
_partitionName = keys[2];
}
break;
+ case MONITORING:
+ if (keys.length > 1) {
+ _monitoringConfigName = keys[1];
+ }
+ break;
default:
break;
}
@@ -93,6 +99,11 @@ public class HelixConfigScopeBuilder {
return this;
}
+ public HelixConfigScopeBuilder forMonitoringConfig(String monitoringConfigName) {
+ _participantName = monitoringConfigName;
+ return this;
+ }
+
public HelixConfigScope build() {
HelixConfigScope scope = null;
switch (_type) {
@@ -121,6 +132,13 @@ public class HelixConfigScopeBuilder {
new HelixConfigScope(_type, Arrays.asList(_clusterName, _resourceName), _partitionName);
}
break;
+ case MONITORING:
+ if (_monitoringConfigName == null) {
+ scope = new HelixConfigScope(_type, Arrays.asList(_clusterName), null);
+ } else {
+ scope = new HelixConfigScope(_type, Arrays.asList(_clusterName, _monitoringConfigName), null);
+ }
+ break;
default:
break;
}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-core/src/main/java/org/apache/helix/monitoring/MonitoringServer.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/monitoring/MonitoringServer.java b/helix-core/src/main/java/org/apache/helix/monitoring/MonitoringServer.java
new file mode 100644
index 0000000..3168bb2
--- /dev/null
+++ b/helix-core/src/main/java/org/apache/helix/monitoring/MonitoringServer.java
@@ -0,0 +1,61 @@
+package org.apache.helix.monitoring;
+
+/*
+ * 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.
+ */
+
+import org.apache.helix.HelixDataAccessor;
+
+/**
+ * Generic interface for a monitoring service that should be attached to a controller.
+ */
+public interface MonitoringServer {
+ /**
+ * Start the monitoring service synchronously
+ */
+ public void start();
+
+ /**
+ * Stop the monitoring service synchronously
+ */
+ public void stop();
+
+ /**
+ * Add a collection of configuration files
+ * @param accessor HelixDataAccessor that can reach Helix's backing store
+ */
+ public void addConfigs(HelixDataAccessor accessor);
+
+ /**
+ * Check if the service has been started
+ * @return true if started, false otherwise
+ */
+ public boolean isStarted();
+
+ /**
+ * Get the host of the service
+ * @return String hostname
+ */
+ public String getHost();
+
+ /**
+ * Get the port of the service
+ * @return integer port
+ */
+ public int getPort();
+}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-core/src/main/java/org/apache/helix/monitoring/MonitoringServerOwner.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/monitoring/MonitoringServerOwner.java b/helix-core/src/main/java/org/apache/helix/monitoring/MonitoringServerOwner.java
new file mode 100644
index 0000000..8e00c54
--- /dev/null
+++ b/helix-core/src/main/java/org/apache/helix/monitoring/MonitoringServerOwner.java
@@ -0,0 +1,37 @@
+package org.apache.helix.monitoring;
+
+/*
+ * 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.
+ */
+
+/**
+ * Interface to implement for Helix components that can manage a monitoring server
+ */
+public interface MonitoringServerOwner {
+ /**
+ * Attach a monitoring server to this controller
+ * @param server MonitoringServer implementation
+ */
+ void registerMonitoringServer(MonitoringServer server);
+
+ /**
+ * Get the monitoring service, if any, registered with this connection
+ * @return a MonitoringService, or null if none
+ */
+ MonitoringServer getMonitoringServer();
+}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-core/src/main/java/org/apache/helix/participant/DistClusterControllerElection.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/participant/DistClusterControllerElection.java b/helix-core/src/main/java/org/apache/helix/participant/DistClusterControllerElection.java
index 0e8c6fd..d76e874 100644
--- a/helix-core/src/main/java/org/apache/helix/participant/DistClusterControllerElection.java
+++ b/helix-core/src/main/java/org/apache/helix/participant/DistClusterControllerElection.java
@@ -19,8 +19,6 @@ package org.apache.helix.participant;
* under the License.
*/
-import java.lang.management.ManagementFactory;
-
import org.apache.helix.ControllerChangeListener;
import org.apache.helix.HelixDataAccessor;
import org.apache.helix.HelixManager;
@@ -31,9 +29,8 @@ import org.apache.helix.PropertyKey.Builder;
import org.apache.helix.PropertyType;
import org.apache.helix.controller.GenericHelixController;
import org.apache.helix.controller.HelixControllerMain;
-import org.apache.helix.controller.restlet.ZKPropertyTransferServer;
+import org.apache.helix.manager.zk.ZkHelixLeaderElection;
import org.apache.helix.model.LeaderHistory;
-import org.apache.helix.model.LiveInstance;
import org.apache.log4j.Logger;
// TODO: merge with GenericHelixController
@@ -108,49 +105,7 @@ public class DistClusterControllerElection implements ControllerChangeListener {
}
private boolean tryUpdateController(HelixManager manager) {
- // DataAccessor dataAccessor = manager.getDataAccessor();
- HelixDataAccessor accessor = manager.getHelixDataAccessor();
- Builder keyBuilder = accessor.keyBuilder();
-
- LiveInstance leader = new LiveInstance(manager.getInstanceName());
- try {
- leader.setLiveInstance(ManagementFactory.getRuntimeMXBean().getName());
- // TODO: this session id is not the leader's session id in
- // distributed mode
- leader.setSessionId(manager.getSessionId());
- leader.setHelixVersion(manager.getVersion());
- if (ZKPropertyTransferServer.getInstance() != null) {
- String zkPropertyTransferServiceUrl =
- ZKPropertyTransferServer.getInstance().getWebserviceUrl();
- if (zkPropertyTransferServiceUrl != null) {
- leader.setWebserviceUrl(zkPropertyTransferServiceUrl);
- }
- } else {
- LOG.warn("ZKPropertyTransferServer instnace is null");
- }
- boolean success = accessor.createProperty(keyBuilder.controllerLeader(), leader);
- if (success) {
- return true;
- } else {
- LOG.info("Unable to become leader probably because some other controller becames the leader");
- }
- } catch (Exception e) {
- LOG.error(
- "Exception when trying to updating leader record in cluster:" + manager.getClusterName()
- + ". Need to check again whether leader node has been created or not", e);
- }
-
- leader = accessor.getProperty(keyBuilder.controllerLeader());
- if (leader != null) {
- String leaderSessionId = leader.getTypedSessionId().stringify();
- LOG.info("Leader exists for cluster: " + manager.getClusterName() + ", currentLeader: "
- + leader.getInstanceName() + ", leaderSessionId: " + leaderSessionId);
-
- if (leaderSessionId != null && leaderSessionId.equals(manager.getSessionId())) {
- return true;
- }
- }
- return false;
+ return ZkHelixLeaderElection.tryBecomingLeader(manager);
}
private void updateHistory(HelixManager manager) {
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-core/src/test/java/org/apache/helix/Mocks.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/Mocks.java b/helix-core/src/test/java/org/apache/helix/Mocks.java
index 919eb00..87d4e68 100644
--- a/helix-core/src/test/java/org/apache/helix/Mocks.java
+++ b/helix-core/src/test/java/org/apache/helix/Mocks.java
@@ -40,6 +40,7 @@ import org.apache.helix.messaging.handling.MessageHandlerFactory;
import org.apache.helix.messaging.handling.MessageTask;
import org.apache.helix.model.HelixConfigScope.ConfigScopeProperty;
import org.apache.helix.model.Message;
+import org.apache.helix.monitoring.MonitoringServer;
import org.apache.helix.participant.StateMachineEngine;
import org.apache.helix.participant.statemachine.StateModel;
import org.apache.helix.participant.statemachine.StateModelInfo;
@@ -478,6 +479,18 @@ public class Mocks {
}
+ @Override
+ public void registerMonitoringServer(MonitoringServer monitoringServer) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public MonitoringServer getMonitoringServer() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
}
public static class MockAccessor implements HelixDataAccessor // DataAccessor
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-core/src/test/java/org/apache/helix/controller/stages/DummyClusterManager.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/controller/stages/DummyClusterManager.java b/helix-core/src/test/java/org/apache/helix/controller/stages/DummyClusterManager.java
index fc9b7d5..e07f0b5 100644
--- a/helix-core/src/test/java/org/apache/helix/controller/stages/DummyClusterManager.java
+++ b/helix-core/src/test/java/org/apache/helix/controller/stages/DummyClusterManager.java
@@ -42,6 +42,7 @@ import org.apache.helix.ScopedConfigChangeListener;
import org.apache.helix.ZNRecord;
import org.apache.helix.healthcheck.ParticipantHealthReportCollector;
import org.apache.helix.model.HelixConfigScope.ConfigScopeProperty;
+import org.apache.helix.monitoring.MonitoringServer;
import org.apache.helix.participant.StateMachineEngine;
import org.apache.helix.store.zk.ZkHelixPropertyStore;
@@ -260,4 +261,16 @@ public class DummyClusterManager implements HelixManager {
// TODO Auto-generated method stub
}
+
+ @Override
+ public void registerMonitoringServer(MonitoringServer monitoringServer) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public MonitoringServer getMonitoringServer() {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-core/src/test/java/org/apache/helix/integration/TestDistributedCMMain.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestDistributedCMMain.java b/helix-core/src/test/java/org/apache/helix/integration/TestDistributedCMMain.java
index 8135191..e29e73f 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestDistributedCMMain.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestDistributedCMMain.java
@@ -24,12 +24,11 @@ import java.util.Date;
import org.apache.helix.PropertyKey.Builder;
import org.apache.helix.TestHelper;
import org.apache.helix.ZNRecord;
-import org.apache.helix.controller.HelixControllerMain;
import org.apache.helix.integration.manager.ClusterDistributedController;
import org.apache.helix.integration.manager.MockParticipantManager;
import org.apache.helix.manager.zk.ZKHelixDataAccessor;
import org.apache.helix.manager.zk.ZkBaseDataAccessor;
-import org.apache.helix.model.LiveInstance;
+import org.apache.helix.model.Leader;
import org.apache.helix.tools.ClusterSetup;
import org.apache.helix.tools.ClusterStateVerifier;
import org.apache.helix.tools.ClusterStateVerifier.BestPossAndExtViewZkVerifier;
@@ -135,7 +134,7 @@ public class TestDistributedCMMain extends ZkIntegrationTestBase {
ZKHelixDataAccessor accessor = new ZKHelixDataAccessor(controllerClusterName, baseAccessor);
Builder keyBuilder = accessor.keyBuilder();
for (int i = 0; i < n; i++) {
- LiveInstance leader = accessor.getProperty(keyBuilder.controllerLeader());
+ Leader leader = accessor.getProperty(keyBuilder.controllerLeader());
String leaderName = leader.getId();
int j = Integer.parseInt(leaderName.substring(leaderName.lastIndexOf('_') + 1));
controllers[j].syncStop();
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-core/src/test/java/org/apache/helix/integration/TestDistributedClusterController.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestDistributedClusterController.java b/helix-core/src/test/java/org/apache/helix/integration/TestDistributedClusterController.java
index f3def23..c073c44 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestDistributedClusterController.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestDistributedClusterController.java
@@ -24,12 +24,11 @@ import java.util.Date;
import org.apache.helix.PropertyKey.Builder;
import org.apache.helix.TestHelper;
import org.apache.helix.ZNRecord;
-import org.apache.helix.controller.HelixControllerMain;
import org.apache.helix.integration.manager.ClusterDistributedController;
import org.apache.helix.integration.manager.MockParticipantManager;
import org.apache.helix.manager.zk.ZKHelixDataAccessor;
import org.apache.helix.manager.zk.ZkBaseDataAccessor;
-import org.apache.helix.model.LiveInstance;
+import org.apache.helix.model.Leader;
import org.apache.helix.tools.ClusterStateVerifier;
import org.apache.helix.tools.ClusterStateVerifier.BestPossAndExtViewZkVerifier;
import org.testng.Assert;
@@ -107,7 +106,7 @@ public class TestDistributedClusterController extends ZkIntegrationTestBase {
ZkBaseDataAccessor<ZNRecord> baseAccessor = new ZkBaseDataAccessor<ZNRecord>(_gZkClient);
ZKHelixDataAccessor accessor = new ZKHelixDataAccessor(controllerClusterName, baseAccessor);
Builder keyBuilder = accessor.keyBuilder();
- LiveInstance leader = accessor.getProperty(keyBuilder.controllerLeader());
+ Leader leader = accessor.getProperty(keyBuilder.controllerLeader());
String leaderName = leader.getId();
int j = Integer.parseInt(leaderName.substring(leaderName.lastIndexOf('_') + 1));
controllers[j].syncStop();
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-core/src/test/java/org/apache/helix/integration/TestStandAloneCMMain.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestStandAloneCMMain.java b/helix-core/src/test/java/org/apache/helix/integration/TestStandAloneCMMain.java
index 6eb7a8c..5ea912e 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestStandAloneCMMain.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestStandAloneCMMain.java
@@ -29,7 +29,7 @@ import org.apache.helix.ZNRecord;
import org.apache.helix.integration.manager.ClusterControllerManager;
import org.apache.helix.manager.zk.ZKHelixDataAccessor;
import org.apache.helix.manager.zk.ZkBaseDataAccessor;
-import org.apache.helix.model.LiveInstance;
+import org.apache.helix.model.Leader;
import org.apache.helix.tools.ClusterStateVerifier;
import org.apache.log4j.Logger;
import org.testng.Assert;
@@ -44,8 +44,7 @@ public class TestStandAloneCMMain extends ZkStandAloneCMTestBase {
ClusterControllerManager newController = null;
for (int i = 1; i <= 2; i++) {
String controllerName = "controller_" + i;
- newController =
- new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, controllerName);
+ newController = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, controllerName);
newController.syncStart();
}
@@ -60,7 +59,7 @@ public class TestStandAloneCMMain extends ZkStandAloneCMTestBase {
@Override
public boolean verify() throws Exception {
- LiveInstance leader = accessor.getProperty(keyBuilder.controllerLeader());
+ Leader leader = accessor.getProperty(keyBuilder.controllerLeader());
if (leader == null) {
return false;
}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-core/src/test/java/org/apache/helix/integration/ZkIntegrationTestBase.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/ZkIntegrationTestBase.java b/helix-core/src/test/java/org/apache/helix/integration/ZkIntegrationTestBase.java
index 9188e61..65d6597 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/ZkIntegrationTestBase.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/ZkIntegrationTestBase.java
@@ -31,7 +31,7 @@ import org.apache.helix.manager.zk.ZNRecordSerializer;
import org.apache.helix.manager.zk.ZkBaseDataAccessor;
import org.apache.helix.manager.zk.ZkClient;
import org.apache.helix.model.ConfigScope;
-import org.apache.helix.model.LiveInstance;
+import org.apache.helix.model.Leader;
import org.apache.helix.model.builder.ConfigScopeBuilder;
import org.apache.helix.tools.ClusterSetup;
import org.apache.helix.util.ZKClientPool;
@@ -86,7 +86,7 @@ public class ZkIntegrationTestBase {
new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(zkClient));
Builder keyBuilder = accessor.keyBuilder();
- LiveInstance leader = accessor.getProperty(keyBuilder.controllerLeader());
+ Leader leader = accessor.getProperty(keyBuilder.controllerLeader());
if (leader == null) {
return null;
}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-core/src/test/java/org/apache/helix/integration/manager/TestConsecutiveZkSessionExpiry.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/manager/TestConsecutiveZkSessionExpiry.java b/helix-core/src/test/java/org/apache/helix/integration/manager/TestConsecutiveZkSessionExpiry.java
index 8625c0c..af427f7 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/manager/TestConsecutiveZkSessionExpiry.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/manager/TestConsecutiveZkSessionExpiry.java
@@ -33,7 +33,7 @@ import org.apache.helix.manager.zk.CallbackHandler;
import org.apache.helix.manager.zk.ZKHelixDataAccessor;
import org.apache.helix.manager.zk.ZkBaseDataAccessor;
import org.apache.helix.mock.participant.MockMSModelFactory;
-import org.apache.helix.model.LiveInstance;
+import org.apache.helix.model.Leader;
import org.apache.helix.tools.ClusterStateVerifier;
import org.apache.helix.tools.ClusterStateVerifier.BestPossAndExtViewZkVerifier;
import org.apache.log4j.Logger;
@@ -230,7 +230,7 @@ public class TestConsecutiveZkSessionExpiry extends ZkUnitTestBase {
new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_gZkClient));
PropertyKey.Builder keyBuilder = accessor.keyBuilder();
Assert.assertNotNull(accessor.getProperty(keyBuilder.liveInstance("localhost_12918")));
- LiveInstance leader = accessor.getProperty(keyBuilder.controllerLeader());
+ Leader leader = accessor.getProperty(keyBuilder.controllerLeader());
Assert.assertNotNull(leader);
Assert.assertEquals(leader.getId(), "localhost_12919");
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-core/src/test/java/org/apache/helix/integration/manager/TestDistributedControllerManager.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/manager/TestDistributedControllerManager.java b/helix-core/src/test/java/org/apache/helix/integration/manager/TestDistributedControllerManager.java
index aa00a8d..6ddfac8 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/manager/TestDistributedControllerManager.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/manager/TestDistributedControllerManager.java
@@ -34,7 +34,7 @@ import org.apache.helix.manager.zk.ZKHelixDataAccessor;
import org.apache.helix.manager.zk.ZKHelixManager;
import org.apache.helix.manager.zk.ZkBaseDataAccessor;
import org.apache.helix.mock.participant.MockMSModelFactory;
-import org.apache.helix.model.LiveInstance;
+import org.apache.helix.model.Leader;
import org.apache.helix.tools.ClusterStateVerifier;
import org.apache.helix.tools.ClusterStateVerifier.BestPossAndExtViewZkVerifier;
import org.apache.log4j.Logger;
@@ -93,7 +93,7 @@ public class TestDistributedControllerManager extends ZkIntegrationTestBase {
new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_gZkClient));
PropertyKey.Builder keyBuilder = accessor.keyBuilder();
Assert.assertNull(accessor.getProperty(keyBuilder.liveInstance("localhost_12918")));
- LiveInstance leader = accessor.getProperty(keyBuilder.controllerLeader());
+ Leader leader = accessor.getProperty(keyBuilder.controllerLeader());
Assert.assertNotNull(leader);
Assert.assertEquals(leader.getId(), "localhost_12919");
@@ -134,7 +134,7 @@ public class TestDistributedControllerManager extends ZkIntegrationTestBase {
PropertyKey.Builder keyBuilder = accessor.keyBuilder();
Assert.assertNotNull(accessor.getProperty(keyBuilder.liveInstance(expireController
.getInstanceName())));
- LiveInstance leader = accessor.getProperty(keyBuilder.controllerLeader());
+ Leader leader = accessor.getProperty(keyBuilder.controllerLeader());
Assert.assertNotNull(leader);
Assert.assertEquals(leader.getId(), newController.getInstanceName());
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkFlapping.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkFlapping.java b/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkFlapping.java
index 79c74f5..f84c372 100644
--- a/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkFlapping.java
+++ b/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkFlapping.java
@@ -34,6 +34,7 @@ import org.apache.helix.ZkTestHelper;
import org.apache.helix.ZkUnitTestBase;
import org.apache.helix.integration.manager.ClusterControllerManager;
import org.apache.helix.integration.manager.MockParticipantManager;
+import org.apache.helix.model.Leader;
import org.apache.helix.model.LiveInstance;
import org.apache.zookeeper.Watcher.Event.KeeperState;
import org.testng.Assert;
@@ -282,7 +283,7 @@ public class TestZkFlapping extends ZkUnitTestBase {
@Override
public boolean verify() throws Exception {
- LiveInstance leader = accessor.getProperty(keyBuilder.controllerLeader());
+ Leader leader = accessor.getProperty(keyBuilder.controllerLeader());
return leader == null;
}
}, 5 * 1000);
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkHelixAutoController.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkHelixAutoController.java b/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkHelixAutoController.java
index 28b1477..438ebd4 100644
--- a/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkHelixAutoController.java
+++ b/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkHelixAutoController.java
@@ -30,6 +30,7 @@ import org.apache.helix.ZNRecord;
import org.apache.helix.ZkUnitTestBase;
import org.apache.helix.api.id.ClusterId;
import org.apache.helix.api.id.ControllerId;
+import org.apache.helix.model.Leader;
import org.apache.helix.model.LiveInstance;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -95,7 +96,7 @@ public class TestZkHelixAutoController extends ZkUnitTestBase {
@Override
public boolean verify() throws Exception {
- LiveInstance leader = accessor.getProperty(keyBuilder.controllerLeader());
+ Leader leader = accessor.getProperty(keyBuilder.controllerLeader());
if (leader == null) {
return false;
}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkHelixController.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkHelixController.java b/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkHelixController.java
index 0127edb..d823ae0 100644
--- a/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkHelixController.java
+++ b/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkHelixController.java
@@ -30,6 +30,7 @@ import org.apache.helix.ZNRecord;
import org.apache.helix.ZkUnitTestBase;
import org.apache.helix.api.id.ClusterId;
import org.apache.helix.api.id.ControllerId;
+import org.apache.helix.model.Leader;
import org.apache.helix.model.LiveInstance;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -68,7 +69,7 @@ public class TestZkHelixController extends ZkUnitTestBase {
// check leader znode exists
HelixDataAccessor accessor = connection.createDataAccessor(clusterId);
PropertyKey.Builder keyBuilder = accessor.keyBuilder();
- LiveInstance leader = accessor.getProperty(keyBuilder.controllerLeader());
+ Leader leader = accessor.getProperty(keyBuilder.controllerLeader());
Assert.assertNotNull(leader);
Assert.assertEquals(leader.getInstanceName(), controllerId.stringify());
@@ -138,7 +139,7 @@ public class TestZkHelixController extends ZkUnitTestBase {
@Override
public boolean verify() throws Exception {
- LiveInstance leader = accessor.getProperty(keyBuilder.controllerLeader());
+ Leader leader = accessor.getProperty(keyBuilder.controllerLeader());
if (leader == null) {
return false;
}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/77f14b4a/helix-core/src/test/java/org/apache/helix/participant/MockZKHelixManager.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/participant/MockZKHelixManager.java b/helix-core/src/test/java/org/apache/helix/participant/MockZKHelixManager.java
index d97b22a..0b8395e 100644
--- a/helix-core/src/test/java/org/apache/helix/participant/MockZKHelixManager.java
+++ b/helix-core/src/test/java/org/apache/helix/participant/MockZKHelixManager.java
@@ -47,6 +47,7 @@ import org.apache.helix.manager.zk.ZKHelixDataAccessor;
import org.apache.helix.manager.zk.ZkBaseDataAccessor;
import org.apache.helix.manager.zk.ZkClient;
import org.apache.helix.model.HelixConfigScope.ConfigScopeProperty;
+import org.apache.helix.monitoring.MonitoringServer;
import org.apache.helix.store.zk.ZkHelixPropertyStore;
public class MockZKHelixManager implements HelixManager {
@@ -267,4 +268,16 @@ public class MockZKHelixManager implements HelixManager {
}
+ @Override
+ public void registerMonitoringServer(MonitoringServer monitoringServer) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public MonitoringServer getMonitoringServer() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
}