You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@helix.apache.org by ki...@apache.org on 2012/10/25 00:26:41 UTC
[46/47] Refactoring from com.linkedin.helix to org.apache.helix
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/helix-core/src/test/java/com/linkedin/helix/tools/TestHelixAdminScenariosCli.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/com/linkedin/helix/tools/TestHelixAdminScenariosCli.java b/helix-core/src/test/java/com/linkedin/helix/tools/TestHelixAdminScenariosCli.java
deleted file mode 100644
index ceb8603..0000000
--- a/helix-core/src/test/java/com/linkedin/helix/tools/TestHelixAdminScenariosCli.java
+++ /dev/null
@@ -1,421 +0,0 @@
-package com.linkedin.helix.tools;
-/*
- * Simulate all the admin tasks needed by using command line tool
- *
- * */
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.codehaus.jackson.JsonGenerationException;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.map.SerializationConfig;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import com.linkedin.helix.HelixDataAccessor;
-import com.linkedin.helix.TestHelper;
-import com.linkedin.helix.TestHelper.StartCMResult;
-import com.linkedin.helix.ZNRecord;
-import com.linkedin.helix.controller.HelixControllerMain;
-import com.linkedin.helix.controller.restlet.ZKPropertyTransferServer;
-import com.linkedin.helix.controller.restlet.ZkPropertyTransferClient;
-import com.linkedin.helix.integration.ZkIntegrationTestBase;
-import com.linkedin.helix.manager.zk.ZKUtil;
-import com.linkedin.helix.model.LiveInstance;
-import com.linkedin.helix.tools.ClusterStateVerifier.BestPossAndExtViewZkVerifier;
-import com.linkedin.helix.tools.ClusterStateVerifier.MasterNbInExtViewVerifier;
-
-public class TestHelixAdminScenariosCli extends ZkIntegrationTestBase
-{
- Map<String, StartCMResult> _startCMResultMap =
- new HashMap<String, StartCMResult>();
-
- public static String ObjectToJson(Object object) throws JsonGenerationException,
- JsonMappingException,
- IOException
- {
- ObjectMapper mapper = new ObjectMapper();
- SerializationConfig serializationConfig = mapper.getSerializationConfig();
- serializationConfig.set(SerializationConfig.Feature.INDENT_OUTPUT, true);
-
- StringWriter sw = new StringWriter();
- mapper.writeValue(sw, object);
-
- return sw.toString();
- }
-
-
- @Test
- public void testAddDeleteClusterAndInstanceAndResource() throws Exception
- {
- // Helix bug helix-102
- //ZKPropertyTransferServer.PERIOD = 500;
- //ZkPropertyTransferClient.SEND_PERIOD = 500;
- //ZKPropertyTransferServer.getInstance().init(19999, ZK_ADDR);
-
- /**======================= Add clusters ==============================*/
-
- testAddCluster();
-
- /**================= Add / drop some resources ===========================*/
-
- testAddResource();
-
- /**====================== Add / delete instances ===========================*/
-
- testAddInstance();
-
- /**===================== Rebalance resource ===========================*/
-
- testRebalanceResource();
-
- /**==================== start the clusters =============================*/
-
- testStartCluster();
-
- /**==================== drop add resource in live clusters ===================*/
- testDropAddResource();
- /**======================Operations with live node ============================*/
-
- testInstanceOperations();
-
- /**============================ expand cluster ===========================*/
-
- testExpandCluster();
-
- /**============================ deactivate cluster ===========================*/
- testDeactivateCluster();
-
- }
-
- void assertClusterSetupException(String command)
- {
- boolean exceptionThrown = false;
- try
- {
- ClusterSetup.processCommandLineArgs(command.split(" "));
- }
- catch(Exception e)
- {
- exceptionThrown = true;
- }
- Assert.assertTrue(exceptionThrown);
- }
-
- public void testAddCluster() throws Exception
- {
- String command = "--zkSvr localhost:2183 -addCluster clusterTest";
- ClusterSetup.processCommandLineArgs(command.split(" "));
-
- // malformed cluster name
- command = "--zkSvr localhost:2183 -addCluster /ClusterTest";
- assertClusterSetupException(command);
-
- // Add the grand cluster
- command = "--zkSvr localhost:2183 -addCluster \"Klazt3rz";
- ClusterSetup.processCommandLineArgs(command.split(" "));
-
- command = "--zkSvr localhost:2183 -addCluster \\ClusterTest";
- ClusterSetup.processCommandLineArgs(command.split(" "));
-
- // Add already exist cluster
- command = "--zkSvr localhost:2183 -addCluster clusterTest";
- assertClusterSetupException(command);
-
- // delete cluster without resource and instance
- Assert.assertTrue(ZKUtil.isClusterSetup("Klazt3rz", _gZkClient));
- Assert.assertTrue(ZKUtil.isClusterSetup("clusterTest", _gZkClient));
- Assert.assertTrue(ZKUtil.isClusterSetup("\\ClusterTest", _gZkClient));
-
- command = "-zkSvr localhost:2183 -dropCluster \\ClusterTest";
- ClusterSetup.processCommandLineArgs(command.split(" "));
-
- command = "-zkSvr localhost:2183 -dropCluster clusterTest1";
- ClusterSetup.processCommandLineArgs(command.split(" "));
-
- command = "-zkSvr localhost:2183 -dropCluster clusterTest";
- ClusterSetup.processCommandLineArgs(command.split(" "));
-
- Assert.assertFalse(_gZkClient.exists("/clusterTest"));
- Assert.assertFalse(_gZkClient.exists("/\\ClusterTest"));
- Assert.assertFalse(_gZkClient.exists("/clusterTest1"));
-
- command = "-zkSvr localhost:2183 -addCluster clusterTest1";
- ClusterSetup.processCommandLineArgs(command.split(" "));
- }
-
- public void testAddResource() throws Exception
- {
- String command = "-zkSvr localhost:2183 -addResource clusterTest1 db_22 144 MasterSlave";
- ClusterSetup.processCommandLineArgs(command.split(" "));
-
- command = "-zkSvr localhost:2183 -addResource clusterTest1 db_11 44 MasterSlave";
- ClusterSetup.processCommandLineArgs(command.split(" "));
-
- // Add duplicate resource
- command = "-zkSvr localhost:2183 -addResource clusterTest1 db_22 55 OnlineOffline";
- assertClusterSetupException(command);
-
- // drop resource now
- command = "-zkSvr localhost:2183 -dropResource clusterTest1 db_11 ";
- ClusterSetup.processCommandLineArgs(command.split(" "));
-
- command = "-zkSvr localhost:2183 -addResource clusterTest1 db_11 44 MasterSlave";
- ClusterSetup.processCommandLineArgs(command.split(" "));
- }
-
- private void testDeactivateCluster() throws Exception, InterruptedException
- {
- String command;
- HelixDataAccessor accessor;
- String path;
- // deactivate cluster
- command = "-zkSvr localhost:2183 -activateCluster clusterTest1 Klazt3rz false";
- ClusterSetup.processCommandLineArgs(command.split(" "));
- Thread.sleep(6000);
-
- accessor = _startCMResultMap.get("localhost_1231")._manager.getHelixDataAccessor();
- path = accessor.keyBuilder().controllerLeader().getPath();
- Assert.assertFalse(_gZkClient.exists(path));
-
- command = "-zkSvr localhost:2183 -dropCluster clusterTest1";
- assertClusterSetupException(command);
-
- // leader node should be gone
- for(StartCMResult result : _startCMResultMap.values())
- {
- result._manager.disconnect();
- result._thread.interrupt();
- }
-
- command = "-zkSvr localhost:2183 -dropCluster clusterTest1";
- ClusterSetup.processCommandLineArgs(command.split(" "));
-
- command = "-zkSvr localhost:2183 -dropCluster Klazt3rz";
- ClusterSetup.processCommandLineArgs(command.split(" "));
- }
-
- private void testDropAddResource() throws Exception
- {
- ZNRecord record = _gSetupTool._admin.getResourceIdealState("clusterTest1", "db_11").getRecord();
- String x = ObjectToJson(record);
-
- FileWriter fos = new FileWriter("/tmp/temp.log");
- PrintWriter pw = new PrintWriter(fos);
- pw.write(x);
- pw.close();
-
- String command = "-zkSvr localhost:2183 -dropResource clusterTest1 db_11 ";
- ClusterSetup.processCommandLineArgs(command.split(" "));
-
- boolean verifyResult =
- ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR,
- "clusterTest1"));
- Assert.assertTrue(verifyResult);
-
- command = "-zkSvr localhost:2183 -addIdealState clusterTest1 db_11 \"/tmp/temp.log\"";
- ClusterSetup.processCommandLineArgs(command.split(" "));
-
- verifyResult =
- ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR,
- "clusterTest1"));
- Assert.assertTrue(verifyResult);
-
- ZNRecord record2 = _gSetupTool._admin.getResourceIdealState("clusterTest1", "db_11").getRecord();
- Assert.assertTrue(record2.equals(record));
- }
-
- private void testExpandCluster() throws Exception
- {
- String command;
- HelixDataAccessor accessor;
- boolean verifyResult;
- String path;
-
- command = "-zkSvr localhost:2183 -addNode clusterTest1 localhost:12331;localhost:12341;localhost:12351;localhost:12361";
- ClusterSetup.processCommandLineArgs(command.split(" "));
-
- command = "-zkSvr localhost:2183 -expandCluster clusterTest1";
- ClusterSetup.processCommandLineArgs(command.split(" "));
-
- for(int i = 3; i<= 6; i++)
- {
- StartCMResult result =
- TestHelper.startDummyProcess(ZK_ADDR, "clusterTest1", "localhost_123"+i+"1");
- _startCMResultMap.put("localhost_123"+i + "1", result);
- }
-
- verifyResult =
- ClusterStateVerifier.verifyByZkCallback(new MasterNbInExtViewVerifier(ZK_ADDR,
- "clusterTest1"));
- Assert.assertTrue(verifyResult);
-
- verifyResult =
- ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR,
- "clusterTest1"));
- Assert.assertTrue(verifyResult);
- }
-
- private void testInstanceOperations() throws Exception
- {
- String command;
- HelixDataAccessor accessor;
- boolean verifyResult;
- // drop node should fail as not disabled
- command = "-zkSvr localhost:2183 -dropNode clusterTest1 localhost:1232";
- assertClusterSetupException(command);
-
- // disabled node
- command = "-zkSvr localhost:2183 -enableInstance clusterTest1 localhost:1232 false";
- ClusterSetup.processCommandLineArgs(command.split(" "));
-
- // Cannot drop / swap
- command = "-zkSvr localhost:2183 -dropNode clusterTest1 localhost:1232";
- assertClusterSetupException(command);
-
- command = "-zkSvr localhost:2183 -swapInstance clusterTest1 localhost_1232 localhost_12320";
- assertClusterSetupException(command);
-
- // disconnect the node
- _startCMResultMap.get("localhost_1232")._manager.disconnect();
- _startCMResultMap.get("localhost_1232")._thread.interrupt();
-
- // add new node then swap instance
- command = "-zkSvr localhost:2183 -addNode clusterTest1 localhost:12320";
- ClusterSetup.processCommandLineArgs(command.split(" "));
-
- // swap instance. The instance get swapped out should not exist anymore
- command = "-zkSvr localhost:2183 -swapInstance clusterTest1 localhost_1232 localhost_12320";
- ClusterSetup.processCommandLineArgs(command.split(" "));
-
- accessor = _startCMResultMap.get("localhost_1231")._manager.getHelixDataAccessor();
- String path = accessor.keyBuilder().instanceConfig("localhost_1232").getPath();
- Assert.assertFalse(_gZkClient.exists(path));
-
- _startCMResultMap.put("localhost_12320", TestHelper.startDummyProcess(ZK_ADDR, "clusterTest1", "localhost_12320"));
- }
-
- private void testStartCluster() throws Exception, InterruptedException
- {
- String command;
- //start mock nodes
- for(int i = 0; i < 6 ; i++)
- {
- StartCMResult result =
- TestHelper.startDummyProcess(ZK_ADDR, "clusterTest1", "localhost_123"+i);
- _startCMResultMap.put("localhost_123"+i, result);
- }
-
- //start controller nodes
- for(int i = 0; i< 2; i++)
- {
- StartCMResult result =
- TestHelper.startController("Klazt3rz", "controller_900" + i, ZK_ADDR, HelixControllerMain.DISTRIBUTED);
-
- _startCMResultMap.put("controller_900" + i, result);
- }
- Thread.sleep(100);
-
- // activate clusters
- // wrong grand clustername
- command = "-zkSvr localhost:2183 -activateCluster clusterTest1 Klazters true";
- assertClusterSetupException(command);
-
- // wrong cluster name
- command = "-zkSvr localhost:2183 -activateCluster clusterTest2 Klazt3rs true";
- assertClusterSetupException(command);
-
- command = "-zkSvr localhost:2183 -activateCluster clusterTest1 Klazt3rz true";
- ClusterSetup.processCommandLineArgs(command.split(" "));
- Thread.sleep(500);
-
- command = "-zkSvr localhost:2183 -dropCluster clusterTest1";
- assertClusterSetupException(command);
-
- // verify leader node
- HelixDataAccessor accessor = _startCMResultMap.get("controller_9001")._manager.getHelixDataAccessor();
- LiveInstance controllerLeader = accessor.getProperty(accessor.keyBuilder().controllerLeader());
- Assert.assertTrue(controllerLeader.getInstanceName().startsWith("controller_900"));
-
- accessor = _startCMResultMap.get("localhost_1232")._manager.getHelixDataAccessor();
- LiveInstance leader = accessor.getProperty(accessor.keyBuilder().controllerLeader());
- Assert.assertTrue(leader.getInstanceName().startsWith("controller_900"));
-
- boolean verifyResult =
- ClusterStateVerifier.verifyByZkCallback(new MasterNbInExtViewVerifier(ZK_ADDR,
- "clusterTest1"));
- Assert.assertTrue(verifyResult);
-
- verifyResult =
- ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR,
- "clusterTest1"));
- Assert.assertTrue(verifyResult);
- }
-
- private void testRebalanceResource() throws Exception
- {
- String command = "-zkSvr localhost:2183 -rebalance clusterTest1 db_11 3";
- ClusterSetup.processCommandLineArgs(command.split(" "));
-
- command = "-zkSvr localhost:2183 -dropResource clusterTest1 db_11 ";
- ClusterSetup.processCommandLineArgs(command.split(" "));
-
- // re-add and rebalance
- command = "-zkSvr localhost:2183 -addResource clusterTest1 db_11 48 MasterSlave";
- ClusterSetup.processCommandLineArgs(command.split(" "));
-
- command = "-zkSvr localhost:2183 -rebalance clusterTest1 db_11 3";
- ClusterSetup.processCommandLineArgs(command.split(" "));
-
- // rebalance with key prefix
- command = "-zkSvr localhost:2183 -rebalance clusterTest1 db_22 2 -key alias";
- ClusterSetup.processCommandLineArgs(command.split(" "));
- }
-
- private void testAddInstance() throws Exception
- {
- String command;
- for(int i = 0; i < 3; i++)
- {
- command = "-zkSvr localhost:2183 -addNode clusterTest1 localhost:123"+i;
- ClusterSetup.processCommandLineArgs(command.split(" "));
- }
- command = "-zkSvr localhost:2183 -addNode clusterTest1 localhost:1233;localhost:1234;localhost:1235;localhost:1236";
- ClusterSetup.processCommandLineArgs(command.split(" "));
-
- // delete one node without disable
- command = "-zkSvr localhost:2183 -dropNode clusterTest1 localhost:1236";
- assertClusterSetupException(command);
-
- // delete non-exist node
- command = "-zkSvr localhost:2183 -dropNode clusterTest1 localhost:12367";
- assertClusterSetupException(command);
-
- // disable node
- command = "-zkSvr localhost:2183 -enableInstance clusterTest1 localhost:1236 false";
- ClusterSetup.processCommandLineArgs(command.split(" "));
-
- command = "-zkSvr localhost:2183 -dropNode clusterTest1 localhost:1236";
- ClusterSetup.processCommandLineArgs(command.split(" "));
-
- // add node to controller cluster
- command = "-zkSvr localhost:2183 -addNode Klazt3rz controller:9000;controller:9001";
- ClusterSetup.processCommandLineArgs(command.split(" "));
-
- // add a dup host
- command = "-zkSvr localhost:2183 -addNode clusterTest1 localhost:1234";
- assertClusterSetupException(command);
-
- // drop and add resource
- command = "-zkSvr localhost:2183 -dropResource clusterTest1 db_11 ";
- ClusterSetup.processCommandLineArgs(command.split(" "));
-
- command = "-zkSvr localhost:2183 -addResource clusterTest1 db_11 12 MasterSlave";
- ClusterSetup.processCommandLineArgs(command.split(" "));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/helix-core/src/test/java/com/linkedin/helix/util/TestZKClientPool.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/com/linkedin/helix/util/TestZKClientPool.java b/helix-core/src/test/java/com/linkedin/helix/util/TestZKClientPool.java
deleted file mode 100644
index bb1757f..0000000
--- a/helix-core/src/test/java/com/linkedin/helix/util/TestZKClientPool.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * Copyright (C) 2012 LinkedIn Inc <op...@linkedin.com>
- *
- * 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.
- */
-package com.linkedin.helix.util;
-
-import java.util.Date;
-
-import org.I0Itec.zkclient.ZkServer;
-import org.I0Itec.zkclient.exception.ZkNoNodeException;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import com.linkedin.helix.TestHelper;
-import com.linkedin.helix.ZNRecord;
-import com.linkedin.helix.manager.zk.ZkClient;
-
-public class TestZKClientPool
-{
-
- @Test
- public void test() throws Exception
- {
- String testName = "TestZKClientPool";
- System.out.println("START " + testName + " at " + new Date(System.currentTimeMillis()));
-
- String zkAddr = "localhost:2187";
- ZkServer zkServer = TestHelper.startZkSever(zkAddr);
- ZkClient zkClient = ZKClientPool.getZkClient(zkAddr);
-
- zkClient.createPersistent("/" + testName, new ZNRecord(testName));
- ZNRecord record = zkClient.readData("/" + testName);
- Assert.assertEquals(record.getId(), testName);
-
- TestHelper.stopZkServer(zkServer);
-
- // restart zk
- zkServer = TestHelper.startZkSever(zkAddr);
- try
- {
- zkClient = ZKClientPool.getZkClient(zkAddr);
- record = zkClient.readData("/" + testName);
- Assert.fail("should fail on zk no node exception");
- } catch (ZkNoNodeException e)
- {
- // OK
- } catch (Exception e)
- {
- Assert.fail("should not fail on exception other than ZkNoNodeException");
- }
-
- zkClient.createPersistent("/" + testName, new ZNRecord(testName));
- record = zkClient.readData("/" + testName);
- Assert.assertEquals(record.getId(), testName);
-
- zkClient.close();
- TestHelper.stopZkServer(zkServer);
- System.out.println("END " + testName + " at " + new Date(System.currentTimeMillis()));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/helix-core/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/helix-core/src/test/resources/log4j.properties b/helix-core/src/test/resources/log4j.properties
index debfd6b..6fb6122 100644
--- a/helix-core/src/test/resources/log4j.properties
+++ b/helix-core/src/test/resources/log4j.properties
@@ -20,4 +20,4 @@ log4j.logger.org.apache=ERROR
log4j.logger.com.noelios=ERROR
log4j.logger.org.restlet=ERROR
-log4j.logger.com.linkedin.helix.monitoring.ZKPathDataDumpTask=INFO,STATUSDUMP
+log4j.logger.org.apache.helix.monitoring.ZKPathDataDumpTask=INFO,STATUSDUMP
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/helix-core/src/test/resources/relay_ideal_state.json
----------------------------------------------------------------------
diff --git a/helix-core/src/test/resources/relay_ideal_state.json b/helix-core/src/test/resources/relay_ideal_state.json
deleted file mode 100644
index e6d23c8..0000000
--- a/helix-core/src/test/resources/relay_ideal_state.json
+++ /dev/null
@@ -1,178 +0,0 @@
-{
-"id" : "SdrRelay",
- "simpleFields" : {
- "partitions" : "28"
- },
- "mapFields" : {
- "ela4-db-sdr.prod.linkedin.com:1521/sdr1/sdr_people_search_/p1_6/MASTER" : {
- "rly09" : "ONLINE",
- "rly10" : "ONLINE",
- "rly11" : "ONLINE",
- "rly12" : "ONLINE",
- },
- "ela4-db-sdr.prod.linkedin.com:1521/sdr1/sdr_people_search_/p2_6/MASTER" : {
- "rly09" : "ONLINE",
- "rly10" : "ONLINE",
- "rly11" : "ONLINE",
- "rly12" : "ONLINE",,
- },
- "ela4-db-sdr.prod.linkedin.com:1521/sdr1/sdr_people_search_/p3_6/MASTER" : {
- "rly09" : "ONLINE",
- "rly10" : "ONLINE",
- "rly11" : "ONLINE",
- "rly12" : "ONLINE",
- },
- "ela4-db-sdr.prod.linkedin.com:1521/sdr1/sdr_people_search_/p4_6/MASTER" : {
- "rly09" : "ONLINE",
- "rly10" : "ONLINE",
- "rly11" : "ONLINE",
- "rly12" : "ONLINE",
- },
- "ela4-db-sdr.prod.linkedin.com:1521/sdr1/sdr_people_search_/p5_6/MASTER" : {
- "rly09" : "ONLINE",
- "rly10" : "ONLINE",
- "rly11" : "ONLINE",
- "rly12" : "ONLINE",
- },
- "ela4-db-sdr.prod.linkedin.com:1521/sdr1/sdr_people_search_/p6_6/MASTER" : {
- "rly09" : "ONLINE",
- "rly10" : "ONLINE",
- "rly11" : "ONLINE",
- "rly12" : "ONLINE",
- },
- "ela4-db-sdr.prod.linkedin.com:1521/sdr1/sdr_people_search_/p7_6/MASTER" : {
- "rly09" : "ONLINE",
- "rly10" : "ONLINE",
- "rly11" : "ONLINE",
- "rly12" : "ONLINE",
- },
- "ela4-db-sdr.prod.linkedin.com:1521/sdr1/sdr_people_search_/p8_6/MASTER" : {
- "rly05" : "ONLINE",
- "rly06" : "ONLINE",
- "rly07" : "ONLINE",
- "rly08" : "ONLINE",
- },
- "ela4-db-sdr.prod.linkedin.com:1521/sdr1/sdr_people_search_/p9_6/MASTER" : {
- "rly05" : "ONLINE",
- "rly06" : "ONLINE",
- "rly07" : "ONLINE",
- "rly08" : "ONLINE",
- },
- "ela4-db-sdr.prod.linkedin.com:1521/sdr1/sdr_people_search_/p10_6/MASTER" : {
- "rly05" : "ONLINE",
- "rly06" : "ONLINE",
- "rly07" : "ONLINE",
- "rly08" : "ONLINE",
- },
- "ela4-db-sdr.prod.linkedin.com:1521/sdr1/sdr_people_search_/p11_6/MASTER" : {
- "rly05" : "ONLINE",
- "rly06" : "ONLINE",
- "rly07" : "ONLINE",
- "rly08" : "ONLINE",
- },
- "ela4-db-sdr.prod.linkedin.com:1521/sdr1/sdr_people_search_/p12_6/MASTER" : {
- "rly05" : "ONLINE",
- "rly06" : "ONLINE",
- "rly07" : "ONLINE",
- "rly08" : "ONLINE",
- },
- "ela4-db-sdr.prod.linkedin.com:1521/sdr1/sdr_people_search_/p13_6/MASTER" : {
- "rly05" : "ONLINE",
- "rly06" : "ONLINE",
- "rly07" : "ONLINE",
- "rly08" : "ONLINE",
- },
- "ela4-db-sdr.prod.linkedin.com:1521/sdr1/sdr_people_search_/p14_6/MASTER" : {
- "rly05" : "ONLINE",
- "rly06" : "ONLINE",
- "rly07" : "ONLINE",
- "rly08" : "ONLINE",
- },
- "ela4-db-sdr.prod.linkedin.com:1521/sdr1/sdr_people_search_/p15_6/MASTER" : {
- "rly05" : "ONLINE",
- "rly06" : "ONLINE",
- "rly07" : "ONLINE",
- "rly08" : "ONLINE",
- },
- "ela4-db-sdr.prod.linkedin.com:1521/sdr1/sdr_people_search_/p16_6/MASTER" : {
- "rly05" : "ONLINE",
- "rly06" : "ONLINE",
- "rly07" : "ONLINE",
- "rly08" : "ONLINE",
- },
- "ela4-db-sdr.prod.linkedin.com:1521/sdr1/sdr_people_search_/p17_6/MASTER" : {
- "rly05" : "ONLINE",
- "rly06" : "ONLINE",
- "rly07" : "ONLINE",
- "rly08" : "ONLINE",
- },
- "ela4-db-sdr.prod.linkedin.com:1521/sdr1/sdr_people_search_/p18_6/MASTER" : {
- "rly05" : "ONLINE",
- "rly06" : "ONLINE",
- "rly07" : "ONLINE",
- "rly08" : "ONLINE",
- },
- "ela4-db-sdr.prod.linkedin.com:1521/sdr1/sdr_people_search_/p19_6/MASTER" : {
- "rly05" : "ONLINE",
- "rly06" : "ONLINE",
- "rly07" : "ONLINE",
- "rly08" : "ONLINE",
- },
- "ela4-db-sdr.prod.linkedin.com:1521/sdr1/sdr_people_search_/p20_6/MASTER" : {
- "rly05" : "ONLINE",
- "rly06" : "ONLINE",
- "rly07" : "ONLINE",
- "rly08" : "ONLINE",
- },
- "ela4-db-sdr.prod.linkedin.com:1521/sdr1/sdr_people_search_/p21_6/MASTER" : {
- "rly05" : "ONLINE",
- "rly06" : "ONLINE",
- "rly07" : "ONLINE",
- "rly08" : "ONLINE",
- },
- "ela4-db-sdr.prod.linkedin.com:1521/sdr1/sdr_people_search_/p22_6/MASTER" : {
- "rly05" : "ONLINE",
- "rly06" : "ONLINE",
- "rly07" : "ONLINE",
- "rly08" : "ONLINE",
- },
- "ela4-db40.prod.linkedin.com:1521/sdr1/sdr_people_search_/p23_6/MASTER" : {
- "rly01" : "ONLINE",
- "ela4-rly02.prod.linkedin.com_10015" : "ONLINE",
- "rly03" : "ONLINE",
- "rly04" : "ONLINE",
- },
- "ela4-db40.prod.linkedin.com:1521/sdr1/sdr_people_search_/p24_6/MASTER" : {
- "rly01" : "ONLINE",
- "ela4-rly02.prod.linkedin.com_10015" : "ONLINE",
- "rly03" : "ONLINE",
- "rly04" : "ONLINE",
- },
- "ela4-db40.prod.linkedin.com:1521/sdr1/sdr_people_search_/p25_6/MASTER" : {
- "rly01" : "ONLINE",
- "ela4-rly02.prod.linkedin.com_10015" : "ONLINE",
- "rly03" : "ONLINE",
- "rly04" : "ONLINE",
- },
- "ela4-db40.prod.linkedin.com:1521/sdr1/sdr_people_search_/p26_6/MASTER" : {
- "rly01" : "ONLINE",
- "ela4-rly02.prod.linkedin.com_10015" : "ONLINE",
- "rly03" : "ONLINE",
- "rly04" : "ONLINE",
- },
- "ela4-db40.prod.linkedin.com:1521/sdr1/sdr_people_search_/p27_6/MASTER" : {
- "rly01" : "ONLINE",
- "ela4-rly02.prod.linkedin.com_10015" : "ONLINE",
- "rly03" : "ONLINE",
- "rly04" : "ONLINE",
- },
- "ela4-db40.prod.linkedin.com:1521/sdr1/sdr_people_search_/p28_6/MASTER" : {
- "rly01" : "ONLINE",
- "ela4-rly02.prod.linkedin.com_10015" : "ONLINE",
- "rly03" : "ONLINE",
- "rly04" : "ONLINE",
- }
- },
- "listFields" : {
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/mockservice/pom.xml
----------------------------------------------------------------------
diff --git a/mockservice/pom.xml b/mockservice/pom.xml
index bfa259a..675686d 100644
--- a/mockservice/pom.xml
+++ b/mockservice/pom.xml
@@ -58,7 +58,7 @@ under the License.
<configuration>
<programs>
<program>
- <mainClass>com.linkedin.helix.MockEspressoService</mainClass>
+ <mainClass>org.apache.helix.MockEspressoService</mainClass>
<name>run-mock-espresso-service</name>
</program>
</programs>
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/mockservice/src/main/java/com/linkedin/helix/CMConnector.java
----------------------------------------------------------------------
diff --git a/mockservice/src/main/java/com/linkedin/helix/CMConnector.java b/mockservice/src/main/java/com/linkedin/helix/CMConnector.java
deleted file mode 100644
index ddbce98..0000000
--- a/mockservice/src/main/java/com/linkedin/helix/CMConnector.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * Copyright (C) 2012 LinkedIn Inc <op...@linkedin.com>
- *
- * 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.
- */
-package com.linkedin.helix;
-
-import com.linkedin.helix.HelixManager;
-import com.linkedin.helix.HelixManagerFactory;
-import com.linkedin.helix.InstanceType;
-
-
-public class CMConnector {
-
- HelixManager _manager;
-
- public CMConnector(final String clusterName, final String instanceName, final String zkAddr) throws Exception //, final ZkClient zkClient) throws Exception
- {
- _manager = null;
- _manager = HelixManagerFactory
- .getZKHelixManager(clusterName, instanceName, InstanceType.PARTICIPANT, zkAddr); //, zkClient);
- _manager.connect();
- }
-
- public HelixManager getManager() {
- return _manager;
- }
-
- public void disconnect() {
- _manager.disconnect();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/mockservice/src/main/java/com/linkedin/helix/EspressoResource.java
----------------------------------------------------------------------
diff --git a/mockservice/src/main/java/com/linkedin/helix/EspressoResource.java b/mockservice/src/main/java/com/linkedin/helix/EspressoResource.java
deleted file mode 100644
index c1a8130..0000000
--- a/mockservice/src/main/java/com/linkedin/helix/EspressoResource.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/**
- * Copyright (C) 2012 LinkedIn Inc <op...@linkedin.com>
- *
- * 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.
- */
-package com.linkedin.helix;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.nio.ByteBuffer;
-import java.nio.CharBuffer;
-import java.nio.channels.ReadableByteChannel;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.log4j.Logger;
-import org.codehaus.jackson.JsonGenerationException;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.restlet.Context;
-import org.restlet.data.Form;
-import org.restlet.data.MediaType;
-import org.restlet.data.Method;
-import org.restlet.data.Request;
-import org.restlet.data.Response;
-import org.restlet.data.Status;
-import org.restlet.resource.Representation;
-import org.restlet.resource.Resource;
-import org.restlet.resource.ResourceException;
-import org.restlet.resource.StringRepresentation;
-import org.restlet.resource.Variant;
-
-import com.linkedin.helix.tools.ClusterSetup;
-
-public class EspressoResource extends Resource {
-
- private static final int POST_BODY_BUFFER_SIZE = 1024*10;
-
- private static final Logger logger = Logger
- .getLogger(EspressoResource.class);
-
- Context _context;
-
- public EspressoResource(Context context,
- Request request,
- Response response)
- {
- super(context, request, response);
- getVariants().add(new Variant(MediaType.TEXT_PLAIN));
- getVariants().add(new Variant(MediaType.APPLICATION_JSON));
- _context = context;
- }
-
- public boolean allowGet()
- {
- System.out.println("PutResource.allowGet()");
- return true;
- }
-
- public boolean allowPost()
- {
- System.out.println("PutResource.allowPost()");
- return true;
- }
-
- public boolean allowPut()
- {
- System.out.println("PutResource.allowPut()");
- return true;
- }
-
- public boolean allowDelete()
- {
- return false;
- }
-
- /*
- * Handle get requests
- * @see org.restlet.resource.Resource#represent(org.restlet.resource.Variant)
- */
- public Representation represent(Variant variant)
- {
- StringRepresentation presentation = null;
- try
- {
- String databaseId = (String)getRequest().getAttributes().get(MockEspressoService.DATABASENAME);
- String tableId = (String)getRequest().getAttributes().get(MockEspressoService.TABLENAME);
- String resourceId = (String)getRequest().getAttributes().get(MockEspressoService.RESOURCENAME);
- String subResourceId = (String)getRequest().getAttributes().get(MockEspressoService.SUBRESOURCENAME);
- logger.debug("Done getting request components");
- logger.debug("method: "+getRequest().getMethod());
- String composedKey = databaseId + tableId + resourceId; // + subResourceId;
- EspressoStorageMockNode mock = (EspressoStorageMockNode)_context.getAttributes().get(MockEspressoService.CONTEXT_MOCK_NODE_NAME);
-
-
- if (getRequest().getMethod() == Method.PUT) {
- logger.debug("processing PUT");
- Reader postBodyReader;
- //TODO: get to no fixed size on buffer
- char[] postBody = new char[POST_BODY_BUFFER_SIZE];
- postBodyReader = getRequest().getEntity().getReader();
- postBodyReader.read(postBody);
- logger.debug("postBody: "+new String(postBody));
- mock.doPut(databaseId, composedKey, new String(postBody));
- presentation = new StringRepresentation("Put succeeded", MediaType.APPLICATION_JSON);
- }
- else if (getRequest().getMethod() == Method.GET) {
- logger.debug("processing GET");
- String result = mock.doGet(databaseId, composedKey);
- logger.debug("result: "+result);
- if (result == null) {
- presentation = new StringRepresentation("Record not found", MediaType.APPLICATION_JSON);
- getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND,"Record not found");
- }
- else {
- getResponse().setStatus(Status.SUCCESS_OK,"Success");
- presentation = new StringRepresentation(result, MediaType.APPLICATION_JSON);
- }
- }
- }
-
- catch (IOException e) {
- presentation = new StringRepresentation(e.getMessage(), MediaType.APPLICATION_JSON);
- e.printStackTrace();
- }
-
- catch(Exception e)
- {
- String error = "Error with op"; //ClusterRepresentationUtil.getErrorAsJsonStringFromException(e);
- presentation = new StringRepresentation(error, MediaType.APPLICATION_JSON);
- e.printStackTrace();
- }
- return presentation;
- }
-
- /*
- * Handle put requests (non-Javadoc)
- * @see org.restlet.resource.Resource#storeRepresentation(org.restlet.resource.Representation)
- */
- public void storeRepresentation(Representation entity) throws ResourceException {
- logger.debug("in storeRepresentation");
- StringRepresentation presentation = null;
- // try {
- Form requestHeaders = (Form) getRequest().getAttributes().get("org.restlet.http.headers");
- Map<String, String> headerMap = requestHeaders.getValuesMap();
- logger.debug("HEADERS MAP");
- for (String key : headerMap.keySet()) {
- logger.debug(key+" : "+headerMap.get(key));
- }
- // } catch (IOException e1) {
- // TODO Auto-generated catch block
- //e1.printStackTrace();
- //}
- try
- {
- logger.debug("in PutResource handle");
- String databaseId = (String)getRequest().getAttributes().get(MockEspressoService.DATABASENAME);
- String tableId = (String)getRequest().getAttributes().get(MockEspressoService.TABLENAME);
- String resourceId = (String)getRequest().getAttributes().get(MockEspressoService.RESOURCENAME);
- String subResourceId = (String)getRequest().getAttributes().get(MockEspressoService.SUBRESOURCENAME);
- logger.debug("Done getting request components");
- logger.debug("method: "+getRequest().getMethod());
- String composedKey = databaseId + tableId + resourceId; // + subResourceId;
- EspressoStorageMockNode mock = (EspressoStorageMockNode)_context.getAttributes().get(MockEspressoService.CONTEXT_MOCK_NODE_NAME);
-
- if (getRequest().getMethod() == Method.PUT) {
- logger.debug("processing PUT");
- Reader postBodyReader;
- //TODO: get to no fixed size on buffer
- char[] postBody = new char[POST_BODY_BUFFER_SIZE];
- postBodyReader = getRequest().getEntity().getReader();
- postBodyReader.read(postBody);
- logger.debug("postBody: "+new String(postBody));
- mock.doPut(databaseId, composedKey, new String(postBody));
- presentation = new StringRepresentation("Put succeeded", MediaType.APPLICATION_JSON);
- }
- else if (getRequest().getMethod() == Method.GET) {
- logger.debug("Processing GET");
- String result = mock.doGet(databaseId, composedKey);
- logger.debug("result: "+result);
- if (result == null) {
- presentation = new StringRepresentation("Record not found", MediaType.APPLICATION_JSON);
- }
- else {
- presentation = new StringRepresentation(result, MediaType.APPLICATION_JSON);
- }
- }
- }
-
- catch (IOException e) {
- presentation = new StringRepresentation(e.getMessage(), MediaType.APPLICATION_JSON);
- e.printStackTrace();
- }
-
- catch(Exception e)
- {
- String error = "Error with op";
- presentation = new StringRepresentation(error, MediaType.APPLICATION_JSON);
- e.printStackTrace();
- }
- finally {
- entity.release();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/mockservice/src/main/java/com/linkedin/helix/EspressoStorageMockNode.java
----------------------------------------------------------------------
diff --git a/mockservice/src/main/java/com/linkedin/helix/EspressoStorageMockNode.java b/mockservice/src/main/java/com/linkedin/helix/EspressoStorageMockNode.java
deleted file mode 100644
index 7c69fad..0000000
--- a/mockservice/src/main/java/com/linkedin/helix/EspressoStorageMockNode.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/**
- * Copyright (C) 2012 LinkedIn Inc <op...@linkedin.com>
- *
- * 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.
- */
-package com.linkedin.helix;
-
-//import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-//import java.util.Map.Entry;
-import java.util.concurrent.ConcurrentHashMap;
-//import java.util.concurrent.ConcurrentMap;
-
-import org.apache.log4j.Logger;
-
-//import com.linkedin.espresso.router.RoutingToken;
-
-//import com.linkedin.clustermanager.EspressoStorageMockStateModelFactory.EspressoStorageMockStateModel;
-//import com.linkedin.clustermanager.healthcheck.ParticipantHealthReportCollector;
-import com.linkedin.helix.EspressoStorageMockStateModelFactory;
-import com.linkedin.helix.PropertyKey.Builder;
-import com.linkedin.helix.PropertyType;
-import com.linkedin.helix.ZNRecord;
-import com.linkedin.helix.healthcheck.PerformanceHealthReportProvider;
-import com.linkedin.helix.healthcheck.StatHealthReportProvider;
-import com.linkedin.helix.model.IdealState;
-import com.linkedin.helix.model.Message.MessageType;
-import com.linkedin.helix.participant.StateMachineEngine;
-import com.linkedin.helix.participant.statemachine.StateModel;
-
-public class EspressoStorageMockNode extends MockNode {
-
- private static final Logger logger = Logger
- .getLogger(EspressoStorageMockNode.class);
-
- private final String GET_STAT_NAME = "get";
- private final String SET_STAT_NAME = "set";
- private final String COUNT_STAT_TYPE = "count";
- private final String REPORT_NAME = "ParticipantStats";
-
- StatHealthReportProvider _healthProvider;
- //PerformanceHealthReportProvider _healthProvider;
- EspressoStorageMockStateModelFactory _stateModelFactory;
-
- HashSet<String>_partitions;
-
- ConcurrentHashMap<String, String> _keyValueMap;
- FnvHashFunction _hashFunction;
- int _numTotalEspressoPartitions = 0;
-
- public EspressoStorageMockNode(CMConnector cm) {
- super(cm);
- _stateModelFactory = new EspressoStorageMockStateModelFactory(0);
-
-// StateMachineEngine genericStateMachineHandler = new StateMachineEngine();
- StateMachineEngine stateMach = _cmConnector.getManager().getStateMachineEngine();
- stateMach.registerStateModelFactory("MasterSlave", _stateModelFactory);
-// _cmConnector
-// .getManager()
-// .getMessagingService()
-// .registerMessageHandlerFactory(
-// MessageType.STATE_TRANSITION.toString(),
-// genericStateMachineHandler);
- /*
- _healthProvider = new StatHealthReportProvider();
- _healthProvider.setReportName(REPORT_NAME);
- */
-
- _healthProvider = new StatHealthReportProvider();
- //_healthProvider.setReportName(REPORT_NAME);
-
- _cmConnector.getManager().getHealthReportCollector()
- .addHealthReportProvider(_healthProvider);
- _partitions = new HashSet<String>();
- _keyValueMap = new ConcurrentHashMap<String, String>();
- _hashFunction = new FnvHashFunction();
-
- //start thread to keep checking what partitions this node owns
- //Thread partitionGetter = new Thread(new PartitionGetterThread());
- //partitionGetter.start();
- //logger.debug("set partition getter thread to run");
- }
-
- public String formStatName(String dbName, String partitionName, String metricName)
- {
- String statName;
- statName = "db"+dbName+".partition"+partitionName+"."+metricName;
- return statName;
-
- }
-
- public String doGet(String dbId, String key) {
- String partition = getPartitionName(dbId, getKeyPartition(dbId, key));
- if (!isPartitionOwnedByNode(partition)) {
- logger.error("Key "+key+" hashed to partition "+partition +" but this node does not own it.");
- return null;
- }
-
- //_healthProvider.submitIncrementPartitionRequestCount(partition);
- //_healthProvider.incrementPartitionStat(GET_STAT_NAME, partition);
- _healthProvider.incrementStat(formStatName(dbId, partition, "getCount"), String.valueOf(System.currentTimeMillis()));
- return _keyValueMap.get(key);
- }
-
- public void doPut(String dbId, String key, String value) {
- String partition = getPartitionName(dbId, getKeyPartition(dbId, key));
- if (!isPartitionOwnedByNode(partition)) {
- logger.error("Key "+key+" hashed to partition "+partition +" but this node does not own it.");
- return;
- }
-
- //_healthProvider.submitIncrementPartitionRequestCount(partition);
- //_healthProvider.incrementPartitionStat(SET_STAT_NAME, partition);
- //_healthProvider.incrementStat(SET_STAT_NAME, COUNT_STAT_TYPE,
- // dbId, partition, "FIXMENODENAME", String.valueOf(System.currentTimeMillis()));
- _healthProvider.incrementStat(formStatName(dbId, partition, "putCount"), String.valueOf(System.currentTimeMillis()));
-
- _keyValueMap.put(key, value);
- }
-
- private String getPartitionName(String databaseName, int partitionNum) {
- return databaseName+"_"+partitionNum;
- }
-
- private boolean isPartitionOwnedByNode(String partitionName) {
- Map<String, StateModel> stateModelMap = _stateModelFactory
- .getStateModelMap();
- logger.debug("state model map size: "+stateModelMap.size());
-
- return (stateModelMap.keySet().contains(partitionName));
- }
-
- private int getKeyPartition(String dbName, String key) {
- int numPartitions = getNumPartitions(dbName);
- logger.debug("numPartitions: "+numPartitions);
- int part = Math.abs((int)_hashFunction.hash(key.getBytes(), numPartitions));
- logger.debug("part: "+part);
- return part;
- }
-
- private int getNumPartitions(String dbName) {
- logger.debug("dbName: "+dbName);
- HelixDataAccessor helixDataAccessor = _cmConnector.getManager().getHelixDataAccessor();
- Builder keyBuilder = helixDataAccessor.keyBuilder();
- ZNRecord rec = helixDataAccessor.getProperty(keyBuilder.idealStates(dbName)).getRecord();
- if (rec == null) {
- logger.debug("rec is null");
- }
- IdealState state = new IdealState(rec);
- return state.getNumPartitions();
- }
-
- class PartitionGetterThread implements Runnable {
-
- @Override
- public void run() {
- while (true) {
- synchronized (_partitions) {
- //logger.debug("Building partition map");
- _partitions.clear();
- Map<String, StateModel> stateModelMap = _stateModelFactory
- .getStateModelMap();
- for (String s: stateModelMap.keySet()) {
- logger.debug("adding key "+s);
- _partitions.add(s);
- }
- }
- //sleep for 60 seconds
- try {
- Thread.sleep(60000);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
- }
-
- @Override
- public void run() {
-
- }
-
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/mockservice/src/main/java/com/linkedin/helix/EspressoStorageMockStateModelFactory.java
----------------------------------------------------------------------
diff --git a/mockservice/src/main/java/com/linkedin/helix/EspressoStorageMockStateModelFactory.java b/mockservice/src/main/java/com/linkedin/helix/EspressoStorageMockStateModelFactory.java
deleted file mode 100644
index 6b27469..0000000
--- a/mockservice/src/main/java/com/linkedin/helix/EspressoStorageMockStateModelFactory.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/**
- * Copyright (C) 2012 LinkedIn Inc <op...@linkedin.com>
- *
- * 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.
- */
-package com.linkedin.helix;
-
-import com.linkedin.helix.NotificationContext;
-import com.linkedin.helix.model.Message;
-import com.linkedin.helix.participant.statemachine.StateModel;
-import com.linkedin.helix.participant.statemachine.StateModelFactory;
-
-@SuppressWarnings("rawtypes")
-public class EspressoStorageMockStateModelFactory extends StateModelFactory<StateModel> {
- int _delay;
-
- public EspressoStorageMockStateModelFactory(int delay) {
- _delay = delay;
- }
-
- @Override
- public StateModel createNewStateModel(String stateUnitKey) {
- EspressoStorageMockStateModel stateModel = new EspressoStorageMockStateModel();
- stateModel.setDelay(_delay);
- stateModel.setStateUnitKey(stateUnitKey);
- return stateModel;
- }
-
- public static class EspressoStorageMockStateModel extends StateModel {
- int _transDelay = 0;
- String stateUnitKey;
-
- public String getStateUnitKey() {
- return stateUnitKey;
- }
-
- public void setStateUnitKey(String stateUnitKey) {
- this.stateUnitKey = stateUnitKey;
- }
-
- public void setDelay(int delay) {
- _transDelay = delay > 0 ? delay : 0;
- }
-
- public void onBecomeSlaveFromOffline(Message message,
- NotificationContext context) {
-
- System.out.println("EspressoStorageMockStateModel.onBecomeSlaveFromOffline() for "+ stateUnitKey);
- sleep();
- }
-
- private void sleep() {
- try {
- Thread.sleep(_transDelay);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- public void onBecomeSlaveFromMaster(Message message,
- NotificationContext context) {
- System.out.println("EspressoStorageMockStateModel.onBecomeSlaveFromMaster() for "+ stateUnitKey);
- sleep();
-
- }
-
- public void onBecomeMasterFromSlave(Message message,
- NotificationContext context) {
- System.out.println("EspressoStorageMockStateModel.onBecomeMasterFromSlave() for "+ stateUnitKey);
- sleep();
-
- }
-
- public void onBecomeOfflineFromSlave(Message message,
- NotificationContext context) {
- System.out.println("EspressoStorageMockStateModel.onBecomeOfflineFromSlave() for "+ stateUnitKey);
- sleep();
-
- }
-
- public void onBecomeDroppedFromOffline(Message message,
- NotificationContext context) {
- System.out.println("ObBecomeDroppedFromOffline() for "+ stateUnitKey);
- sleep();
-
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/mockservice/src/main/java/com/linkedin/helix/FnvHashFunction.java
----------------------------------------------------------------------
diff --git a/mockservice/src/main/java/com/linkedin/helix/FnvHashFunction.java b/mockservice/src/main/java/com/linkedin/helix/FnvHashFunction.java
deleted file mode 100644
index 26c93df..0000000
--- a/mockservice/src/main/java/com/linkedin/helix/FnvHashFunction.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/**
- * Copyright (C) 2012 LinkedIn Inc <op...@linkedin.com>
- *
- * 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.
- */
-package com.linkedin.helix;
-
-import java.nio.ByteBuffer;
-
-/**
- * Forked from com.linkedin.databus.core.util @ r293057
- * @author sdas
- *
- */
-public class FnvHashFunction implements HashFunction
-{
- private static final long FNV_BASIS = 0x811c9dc5;
- private static final long FNV_PRIME = (1 << 24) + 0x193;
-
- @Override
- public long hash(ByteBuffer buf)
- {
- int length = buf.position() + buf.remaining();
- return hash(buf, 0, length);
- }
-
- @Override
- public long hash(ByteBuffer buf, int off, int len)
- {
- long hash = FNV_BASIS;
-
- int last = Math.min(off + len, buf.position() + buf.remaining());
-
- for (int i=off; i< last; i++)
- {
- hash ^= 0xFF & buf.get(i);
- hash *= FNV_PRIME;
- }
- return hash;
- }
-
- public long hash(byte[] key)
- {
- long hash = FNV_BASIS;
- for(int i = 0; i < key.length; i++) {
- hash ^= 0xFF & key[i];
- hash *= FNV_PRIME;
- }
-
- return hash;
- }
-
- @Override
- public long hash(byte[] key, int numBuckets)
- {
- return hash(key)%numBuckets;
- }
-
-
- private long hash(long val)
- {
- long hashval = FNV_BASIS;
-
- for(int i = 0; i < 8; i++)
- {
- long octet = val & 0x00ff;
- val = val >> 8;
-
- hashval = hashval ^ octet;
- hashval = hashval * FNV_PRIME;
- }
- return (int)hashval;
- }
-
- @Override
- public long hash(long val, int numBuckets)
- {
- return hash(val)%numBuckets;
- }
-
- /*
- public static void main(String[] args)
- {
- byte[] b = new byte[1024*1024*100];
- ByteBuffer buf = ByteBuffer.allocateDirect(1024*1024*100).order(DbusEvent.byteOrder);
- Random r = new Random();
- r.nextBytes(b);
- buf.put(b);
-
- FnvHashFunction fun = new FnvHashFunction();
- CRC32 chksum = new CRC32();
- JenkinsHashFunction jFun = new JenkinsHashFunction();
-
- long start = 0;
- long end = 0;
- long hash = 0;
- long diff = 0;
- long delayMicro = 0;
-
- chksum.reset();
- chksum.update(b);
- long prevhash = chksum.getValue();
- for (int i = 0; i < 10; i++)
- {
- start = System.nanoTime();
- chksum.reset();
- chksum.update(b);
- hash = chksum.getValue();
- end = System.nanoTime();
- assert(prevhash == hash);
- diff += (end - start);
- }
-
- delayMicro = (diff/1000)/10;
-
- System.out.println("Latency of System CRC32 (Micro Seconds) is: " + delayMicro);
-
- prevhash = fun.hash(b);
- for (int i = 0; i < 10; i++)
- {
- start = System.nanoTime();
- hash = fun.hash(b);
- end = System.nanoTime();
- assert(prevhash == hash);
- diff += (end - start);
- }
- delayMicro = (diff/1000)/10;
- System.out.println("Latency of FNV (Micro Seconds) is: " + delayMicro);
-
- prevhash = jFun.hash(b);
- for (int i = 0; i < 10; i++)
- {
- start = System.nanoTime();
- hash = jFun.hash(b);
- end = System.nanoTime();
- assert(prevhash == hash);
- diff += (end - start);
- }
- delayMicro = (diff/1000)/10;
- System.out.println("Latency of Jenkins (Micro Seconds) is: " + delayMicro);
-
- prevhash = ByteBufferCRC32.getChecksum(b);
- for (int i = 0; i < 10; i++)
- {
- start = System.nanoTime();
- hash = ByteBufferCRC32.getChecksum(b);
- end = System.nanoTime();
- assert(prevhash == hash);
- diff += (end - start);
- }
- delayMicro = (diff/1000)/10;
- System.out.println("Latency of ByteBufferCRC32 (Micro Seconds) is: " + delayMicro);
-
- //System.out.println("Buffer position-Remaining :" + buf.position() + "-" + buf.remaining());
-
- prevhash = fun.hash(buf);
- for (int i = 0; i < 10; i++)
- {
- start = System.nanoTime();
- hash = fun.hash(buf);
- end = System.nanoTime();
- assert(prevhash == hash);
- diff += (end - start);
- }
- delayMicro = (diff/1000)/10;
- System.out.println("Latency of FNV (Micro Seconds) for ByteBuffer is: " + delayMicro);
- //System.out.println("Buffer position-Remaining :" + buf.position() + "-" + buf.remaining());
-
- prevhash = fun.hash(buf);
- for (int i = 0; i < 10; i++)
- {
- start = System.nanoTime();
- hash = fun.hash(buf);
- end = System.nanoTime();
- assert(prevhash == hash);
- diff += (end - start);
- }
- delayMicro = (diff/1000)/10;
- System.out.println("Latency of Jenkins (Micro Seconds) for ByteBuffer is: " + delayMicro);
- //System.out.println("Buffer position-Remaining :" + buf.position() + "-" + buf.remaining());
- prevhash = ByteBufferCRC32.getChecksum(buf);
- for (int i = 0; i < 10; i++)
- {
- start = System.nanoTime();
- hash = ByteBufferCRC32.getChecksum(buf);
- end = System.nanoTime();
- assert(prevhash == hash);
- diff += (end - start);
- }
- delayMicro = (diff/1000)/10;
- System.out.println("Latency of ByteBufferCRC32 (Micro Seconds) for ByteBuffer is: " + delayMicro);
-
- //System.out.println("Buffer position-Remaining :" + buf.position() + "-" + buf.remaining());
- }
- */
-}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/mockservice/src/main/java/com/linkedin/helix/HashFunction.java
----------------------------------------------------------------------
diff --git a/mockservice/src/main/java/com/linkedin/helix/HashFunction.java b/mockservice/src/main/java/com/linkedin/helix/HashFunction.java
deleted file mode 100644
index 637179a..0000000
--- a/mockservice/src/main/java/com/linkedin/helix/HashFunction.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- * Copyright (C) 2012 LinkedIn Inc <op...@linkedin.com>
- *
- * 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.
- */
-package com.linkedin.helix;
-
-import java.nio.ByteBuffer;
-
-/**
- * Forked from com.linkedin.databus.core.util @ r293057
- * @author sdas
- *
- */
-public interface HashFunction {
-
-
- /*
- * Generates Hash for entire byte buffer
- * @param buf : ByteBuffer for which hash needs to be computed
- * @return hash value of buffer
- */
- public long hash(ByteBuffer buf);
-
- /*
- * Generates Hash for a section of byte buffer denoted by its
- * endpoints
- *
- * @param buf : ByteBuffer for which hash needs to be computed
- * @param off : Starting Offset
- * @param len : Length of the section for hash computation
- * @return the hash value for the section of the buffer
- */
- public long hash(ByteBuffer buf, int off, int len);
-
- /*
- * Generates hash for the byte array and bucketize the value to
- * 0.. (numBuckets - 1)
- *
- * @param key : Array to apply hash and bucketize
- * @param numBuckets : Number of buckets for bucketization
- *
- * @return Returns the bucket in the range 0..(numBuckets - 1)
- */
- public long hash(byte[] key, int numBuckets);
-
- /*
- * Generates hash for the key and bucketize the value to
- * 0.. (numBuckets - 1)
- *
- * @param key : Input key for which hash needs to be calculated
- * @param numBuckets : Number of buckets for bucketization
- *
- * @return Returns the bucket in the range 0..(numBuckets - 1)
- */
- public long hash(long key, int numBuckets);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/mockservice/src/main/java/com/linkedin/helix/MockEspressoService.java
----------------------------------------------------------------------
diff --git a/mockservice/src/main/java/com/linkedin/helix/MockEspressoService.java b/mockservice/src/main/java/com/linkedin/helix/MockEspressoService.java
deleted file mode 100644
index f2db19d..0000000
--- a/mockservice/src/main/java/com/linkedin/helix/MockEspressoService.java
+++ /dev/null
@@ -1,269 +0,0 @@
-/**
- * Copyright (C) 2012 LinkedIn Inc <op...@linkedin.com>
- *
- * 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.
- */
-package com.linkedin.helix;
-
-import java.net.InetAddress;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.CommandLineParser;
-import org.apache.commons.cli.GnuParser;
-import org.apache.commons.cli.HelpFormatter;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.OptionBuilder;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.ParseException;
-import org.apache.log4j.Logger;
-import org.restlet.Application;
-import org.restlet.Component;
-import org.restlet.Context;
-import org.restlet.data.Request;
-import org.restlet.Restlet;
-import org.restlet.data.MediaType;
-import org.restlet.data.Protocol;
-import org.restlet.resource.StringRepresentation;
-import org.restlet.Router;
-
-import org.restlet.data.Response;
-
-import com.linkedin.helix.tools.ClusterSetup;
-
-public class MockEspressoService extends Application
-{
- private static final Logger logger = Logger.getLogger(MockEspressoService.class);
-
- public static final String HELP = "help";
- public static final String CLUSTERNAME = "clusterName";
- public static final String INSTANCENAME = "instanceName";
- public static final String ZKSERVERADDRESS = "zkSvr";
- public static final String PORT = "port";
- public static final int DEFAULT_PORT = 8100;
- protected static final String NODE_TYPE = "EspressoStorage";
- //protected static final String INSTANCE_NAME = "localhost_1234";
-
- public static final String DATABASENAME = "database";
- public static final String TABLENAME = "table";
- public static final String RESOURCENAME = "resource";
- public static final String SUBRESOURCENAME = "subresource";
- public static final String STOPSERVICECOMMAND = "stopservice";
-
- public static final String CONTEXT_MOCK_NODE_NAME = "mocknode";
- public static final String COMPONENT_NAME = "component";
-
- Context _applicationContext;
- static int _serverPort;
- static String _zkAddr = "localhost:9999";
- static String _instanceName = "localhost";
- static String _clusterName = "";
- public CMConnector _connector;
- public EspressoStorageMockNode _mockNode;
- static Context _context;
- static Component _component;
-
- public MockEspressoService(Context context)
- {
- super(_context);
- _connector = null;
-
-
- try {
- _connector = new CMConnector(_clusterName, _instanceName, _zkAddr); //, zkClient);
- }
- catch (Exception e) {
- logger.error("Unable to initialize CMConnector: "+e);
- e.printStackTrace();
- System.exit(-1);
- }
- _mockNode = (EspressoStorageMockNode)MockNodeFactory.createMockNode(NODE_TYPE, _connector);
- context.getAttributes().put(CONTEXT_MOCK_NODE_NAME, (Object)_mockNode);
- }
-
- @Override
- public Restlet createRoot()
- {
- Router router = new Router(_context);
-
- Restlet mainpage = new Restlet()
- {
- @Override
- public void handle(Request request, Response response)
- {
- StringBuilder stringBuilder = new StringBuilder();
- stringBuilder.append("<html>");
- stringBuilder
- .append("<head><title>Restlet Cluster Management page</title></head>");
- stringBuilder.append("<body bgcolor=white>");
- stringBuilder.append("<table border=\"0\">");
- stringBuilder.append("<tr>");
- stringBuilder.append("<td>");
- stringBuilder.append("<h1>Rest cluster management interface V1</h1>");
- stringBuilder.append("</td>");
- stringBuilder.append("</tr>");
- stringBuilder.append("</table>");
- stringBuilder.append("</body>");
- stringBuilder.append("</html>");
- response.setEntity(new StringRepresentation(stringBuilder.toString(),
- MediaType.TEXT_HTML));
- }
- };
-
- if (_mockNode == null) {
- logger.debug("_mockNode in createRoot is null");
- }
- router.attach("", mainpage);
-
- //Espresso handlers
- router.attach("/{"+DATABASENAME+"}/{"+TABLENAME+"}/{"+RESOURCENAME+"}", EspressoResource.class);
- router.attach("/{"+DATABASENAME+"}/{"+TABLENAME+"}/{"+RESOURCENAME+"}/{"+SUBRESOURCENAME+"}", EspressoResource.class);
-
- //Admin handlers
- router.attach("/{"+STOPSERVICECOMMAND+"}", StopServiceResource.class);
-
- return router;
- }
-
- public static void printUsage(Options cliOptions)
- {
- HelpFormatter helpFormatter = new HelpFormatter();
- helpFormatter.printHelp("java " + MockEspressoService.class.getName(), cliOptions);
- }
-
- @SuppressWarnings("static-access")
- private static Options constructCommandLineOptions()
- {
- Option helpOption = OptionBuilder.withLongOpt(HELP)
- .withDescription("Prints command-line options info").create();
- helpOption.setArgs(0);
- helpOption.setRequired(false);
- helpOption.setArgName("print help message");
-
- Option zkServerOption = OptionBuilder.withLongOpt(ZKSERVERADDRESS)
- .withDescription("Provide zookeeper address").create();
- zkServerOption.setArgs(1);
- zkServerOption.setRequired(true);
- zkServerOption.setArgName("ZookeeperServerAddress(Required)");
-
- Option clusterOption = OptionBuilder.withLongOpt(CLUSTERNAME)
- .withDescription("Provide cluster name").create();
- clusterOption.setArgs(1);
- clusterOption.setRequired(true);
- clusterOption.setArgName("Cluster name(Required)");
-
- Option instanceOption = OptionBuilder.withLongOpt(INSTANCENAME)
- .withDescription("Provide name for this instance").create();
- instanceOption.setArgs(1);
- instanceOption.setRequired(false);
- instanceOption.setArgName("Instance name(Optional, defaults to localhost)");
-
- Option portOption = OptionBuilder.withLongOpt(PORT)
- .withDescription("Provide web service port").create();
- portOption.setArgs(1);
- portOption.setRequired(false);
- portOption.setArgName("web service port, default: "+ DEFAULT_PORT);
-
- Options options = new Options();
- options.addOption(helpOption);
- options.addOption(zkServerOption);
- options.addOption(clusterOption);
- options.addOption(instanceOption);
- options.addOption(portOption);
-
- return options;
- }
-
- public static void processCommandLineArgs(String[] cliArgs) throws Exception
- {
- CommandLineParser cliParser = new GnuParser();
- Options cliOptions = constructCommandLineOptions();
- CommandLine cmd = null;
-
- try
- {
- cmd = cliParser.parse(cliOptions, cliArgs);
- }
- catch (ParseException pe)
- {
- System.err.println("MockEspressoService: failed to parse command-line options: "
- + pe.toString());
- printUsage(cliOptions);
- System.exit(1);
- }
- _serverPort = DEFAULT_PORT;
- if(cmd.hasOption(HELP))
- {
- printUsage(cliOptions);
- return;
- }
- else if(cmd.hasOption(PORT))
- {
- _serverPort = Integer.parseInt(cmd.getOptionValue(PORT));
- }
- if (cmd.hasOption(ZKSERVERADDRESS)) {
- _zkAddr = cmd.getOptionValue(ZKSERVERADDRESS);
- }
- if (cmd.hasOption(CLUSTERNAME)) {
- _clusterName = cmd.getOptionValue(CLUSTERNAME);
- logger.debug("_clusterName: "+_clusterName);
- }
- if (cmd.hasOption(INSTANCENAME)) {
- _instanceName = cmd.getOptionValue(INSTANCENAME);
- _instanceName = _instanceName.replace(':', '_');
- logger.debug("_instanceName: "+_instanceName);
- }
- }
-
- public void run() throws Exception {
-
- logger.debug("Start of mock service run");
-
-
- if (_mockNode == null) {
- logger.debug("_mockNode null");
- }
- else {
- logger.debug("_mockNode not null");
- }
- if (_mockNode != null) {
- // start web server with the zkServer address
- _component = new Component();
- _component.getServers().add(Protocol.HTTP, _serverPort);
- // Attach the application to the component and start it
- _component.getDefaultHost().attach(this); //(application);
- _context.getAttributes().put(COMPONENT_NAME, (Object)_component);
- // _context.getParameters().set("maxTotalConnections", "16",true);
- _component.start();
- //start mock espresso node
- //!!!_mockNode.run();
- }
- else {
- logger.error("Unknown MockNode type "+NODE_TYPE);
- System.exit(-1);
- }
- logger.debug("mock service done");
- }
-
- /**
- * @param args
- * @throws Exception
- */
- public static void main(String[] args) throws Exception
- {
- processCommandLineArgs(args);
- _context = new Context();
- MockEspressoService service = new MockEspressoService(_context);
- service.run();
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/mockservice/src/main/java/com/linkedin/helix/MockNode.java
----------------------------------------------------------------------
diff --git a/mockservice/src/main/java/com/linkedin/helix/MockNode.java b/mockservice/src/main/java/com/linkedin/helix/MockNode.java
deleted file mode 100644
index e6f53f7..0000000
--- a/mockservice/src/main/java/com/linkedin/helix/MockNode.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * Copyright (C) 2012 LinkedIn Inc <op...@linkedin.com>
- *
- * 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.
- */
-package com.linkedin.helix;
-
-import org.apache.log4j.Logger;
-
-public abstract class MockNode {
- CMConnector _cmConnector;
-
- public MockNode(CMConnector cm) {
- _cmConnector = cm;
- }
-
- public abstract void run();
-
- public void disconnect() {
- _cmConnector.disconnect();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/mockservice/src/main/java/com/linkedin/helix/MockNodeFactory.java
----------------------------------------------------------------------
diff --git a/mockservice/src/main/java/com/linkedin/helix/MockNodeFactory.java b/mockservice/src/main/java/com/linkedin/helix/MockNodeFactory.java
deleted file mode 100644
index 71f145d..0000000
--- a/mockservice/src/main/java/com/linkedin/helix/MockNodeFactory.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * Copyright (C) 2012 LinkedIn Inc <op...@linkedin.com>
- *
- * 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.
- */
-package com.linkedin.helix;
-
-import org.apache.log4j.Logger;
-
-public class MockNodeFactory {
-
- private static final Logger logger = Logger.getLogger(MockNodeFactory.class);
-
- public MockNodeFactory()
- {
- }
-
- public static MockNode createMockNode(String type, CMConnector cm) {
- if (type.equals("EspressoStorage")) {
- return new EspressoStorageMockNode(cm);
- }
- else {
- logger.error("Unknown MockNode type "+type);
- return null;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/mockservice/src/main/java/com/linkedin/helix/MockRunner.java
----------------------------------------------------------------------
diff --git a/mockservice/src/main/java/com/linkedin/helix/MockRunner.java b/mockservice/src/main/java/com/linkedin/helix/MockRunner.java
deleted file mode 100644
index bef274e..0000000
--- a/mockservice/src/main/java/com/linkedin/helix/MockRunner.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * Copyright (C) 2012 LinkedIn Inc <op...@linkedin.com>
- *
- * 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.
- */
-package com.linkedin.helix;
-
-import org.apache.log4j.Logger;
-
-import com.linkedin.helix.manager.zk.ZNRecordSerializer;
-import com.linkedin.helix.manager.zk.ZkClient;
-
-/**
- * Hello world!
- *
- */
-public class MockRunner
-{
-
- private static final Logger logger = Logger.getLogger(MockRunner.class);
-
- protected static final String nodeType = "EspressoStorage";
- protected static final String ZK_ADDR = "localhost:2184";
- protected static final String INSTANCE_NAME = "localhost_1234";
- protected static final String CLUSTER_NAME = "MockCluster";
-
- public static void main( String[] args )
- {
- //ZkClient zkClient = new ZkClient(ZK_ADDR, 3000, 10000, new ZNRecordSerializer());
- CMConnector cm = null;
- try {
- cm = new CMConnector(CLUSTER_NAME, INSTANCE_NAME, ZK_ADDR); //, zkClient);
- }
- catch (Exception e) {
- logger.error("Unable to initialize CMConnector: "+e);
- e.printStackTrace();
- System.exit(-1);
- }
- MockNode mock = MockNodeFactory.createMockNode(nodeType, cm);
- if (mock != null) {
- mock.run();
- }
- else {
- logger.error("Unknown MockNode type "+nodeType);
- System.exit(-1);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/mockservice/src/main/java/com/linkedin/helix/StopServiceResource.java
----------------------------------------------------------------------
diff --git a/mockservice/src/main/java/com/linkedin/helix/StopServiceResource.java b/mockservice/src/main/java/com/linkedin/helix/StopServiceResource.java
deleted file mode 100644
index a7377e5..0000000
--- a/mockservice/src/main/java/com/linkedin/helix/StopServiceResource.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/**
- * Copyright (C) 2012 LinkedIn Inc <op...@linkedin.com>
- *
- * 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.
- */
-package com.linkedin.helix;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.nio.ByteBuffer;
-import java.nio.CharBuffer;
-import java.nio.channels.ReadableByteChannel;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-import org.codehaus.jackson.JsonGenerationException;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.restlet.Component;
-import org.restlet.Context;
-import org.restlet.data.MediaType;
-import org.restlet.data.Method;
-import org.restlet.data.Request;
-import org.restlet.data.Response;
-import org.restlet.data.Status;
-import org.restlet.resource.Representation;
-import org.restlet.resource.Resource;
-import org.restlet.resource.ResourceException;
-import org.restlet.resource.StringRepresentation;
-import org.restlet.resource.Variant;
-
-import com.linkedin.helix.tools.ClusterSetup;
-
-public class StopServiceResource extends Resource {
-
-
- private static final Logger logger = Logger
- .getLogger(StopServiceResource.class);
-
- Context _context;
-
- public StopServiceResource(Context context,
- Request request,
- Response response)
- {
- super(context, request, response);
- getVariants().add(new Variant(MediaType.TEXT_PLAIN));
- getVariants().add(new Variant(MediaType.APPLICATION_JSON));
- _context = context;
- }
-
- public boolean allowGet()
- {
- System.out.println("PutResource.allowGet()");
- return true;
- }
-
- public boolean allowPost()
- {
- System.out.println("PutResource.allowPost()");
- return false;
- }
-
- public boolean allowPut()
- {
- System.out.println("PutResource.allowPut()");
- return false;
- }
-
- public boolean allowDelete()
- {
- return false;
- }
-
-
- class StopThread implements Runnable {
-
- Component _component;
- MockNode _mockNode;
-
- StopThread(Component c, MockNode m) {
- _component = c;
- _mockNode = m;
- }
-
- @Override
- public void run() {
- try {
- //sleep for 1 second, then end service
- Thread.sleep(1000);
- _component.stop();
- _mockNode.disconnect();
- System.exit(0);
- } catch (Exception e) {
- logger.error("Unable to stop service: "+e);
- e.printStackTrace();
- }
- }
-
- }
-
- //XXX: handling both gets and puts here for now
- public Representation represent(Variant variant)
- {
- System.out.println("StopServiceResource.represent()");
- StringRepresentation presentation = null;
- try
- {
- logger.debug("in represent, stopping service");
- Component component = (Component)_context.getAttributes().get(MockEspressoService.COMPONENT_NAME);
- EspressoStorageMockNode mock = (EspressoStorageMockNode)_context.getAttributes().get(MockEspressoService.CONTEXT_MOCK_NODE_NAME);
- presentation = new StringRepresentation("Stopping in 1 second", MediaType.APPLICATION_JSON);
- Thread stopper = new Thread(new StopThread(component, mock));
- stopper.start();
- }
-
- catch(Exception e)
- {
- String error = "Error shutting down";
- presentation = new StringRepresentation(error, MediaType.APPLICATION_JSON);
- e.printStackTrace();
- }
- return presentation;
- }
-
- public void storeRepresentation(Representation entity) throws ResourceException {
-
- }
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/mockservice/src/test/conf/testng.xml
----------------------------------------------------------------------
diff --git a/mockservice/src/test/conf/testng.xml b/mockservice/src/test/conf/testng.xml
index f8ebd4b..a6298bc 100644
--- a/mockservice/src/test/conf/testng.xml
+++ b/mockservice/src/test/conf/testng.xml
@@ -20,7 +20,7 @@
<suite name="Suite" parallel="none">
<test name="Test" preserve-order="false">
<packages>
- <package name="com.linkedin.helix"/>
+ <package name="org.apache.helix"/>
</packages>
</test>
</suite>
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/mockservice/src/test/java/com/linkedin/helix/AppTest.java
----------------------------------------------------------------------
diff --git a/mockservice/src/test/java/com/linkedin/helix/AppTest.java b/mockservice/src/test/java/com/linkedin/helix/AppTest.java
deleted file mode 100644
index f5e61c5..0000000
--- a/mockservice/src/test/java/com/linkedin/helix/AppTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * Copyright (C) 2012 LinkedIn Inc <op...@linkedin.com>
- *
- * 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.
- */
-package com.linkedin.helix;
-
-import org.testng.annotations.Test;
-import org.testng.AssertJUnit;
-
-/**
- * Unit test for simple App.
- */
-public class AppTest
-{
- /**
- * Create the test case
- *
- * @param testName name of the test case
- */
- public AppTest( String testName )
- {
- }
-
- /**
- * Rigourous Test :-)
- */
- @Test
- public void testApp()
- {
- AssertJUnit.assertTrue( true );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/recipes/rabbitmq-consumer-group/bin/send-message.sh
----------------------------------------------------------------------
diff --git a/recipes/rabbitmq-consumer-group/bin/send-message.sh b/recipes/rabbitmq-consumer-group/bin/send-message.sh
index 86bc51c..9333d71 100755
--- a/recipes/rabbitmq-consumer-group/bin/send-message.sh
+++ b/recipes/rabbitmq-consumer-group/bin/send-message.sh
@@ -2,7 +2,7 @@
script_dir=`dirname $0`
LIB=$script_dir/../lib
-CLASSPATH=$script_dir/../target/classes:"$LIB"/helix-core-0.5.28.jar:"$LIB"/rabbitmq-client.jar:"$LIB"/commons-cli-1.1.jar:"$LIB"/commons-io-1.2.jar:"$LIB"/commons-math-2.1.jar:"$LIB"/jackson-core-asl-1.8.5.jar:"$LIB"/jackson-mapper-asl-1.8.5.jar:"$LIB"/log4j-1.2.15.jar:"$LIB"/org.restlet-1.1.10.jar:"$LIB"/zkclient-0.1.jar:"$LIB"/zookeeper-3.3.4.jar
+CLASSPATH=$script_dir/../target/classes:"$LIB"/helix-core-0.1-SNAPSHOT-incubating.jar:"$LIB"/rabbitmq-client.jar:"$LIB"/commons-cli-1.1.jar:"$LIB"/commons-io-1.2.jar:"$LIB"/commons-math-2.1.jar:"$LIB"/jackson-core-asl-1.8.5.jar:"$LIB"/jackson-mapper-asl-1.8.5.jar:"$LIB"/log4j-1.2.15.jar:"$LIB"/org.restlet-1.1.10.jar:"$LIB"/zkclient-0.1.jar:"$LIB"/zookeeper-3.3.4.jar
# echo $CLASSPATH
-java -cp "$CLASSPATH" com.linkedin.helix.recipes.rabbitmq.Emitter $@
+java -cp "$CLASSPATH" org.apache.helix.recipes.rabbitmq.Emitter $@
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/recipes/rabbitmq-consumer-group/bin/setup-cluster.sh
----------------------------------------------------------------------
diff --git a/recipes/rabbitmq-consumer-group/bin/setup-cluster.sh b/recipes/rabbitmq-consumer-group/bin/setup-cluster.sh
index 53e8407..cb7dbca 100755
--- a/recipes/rabbitmq-consumer-group/bin/setup-cluster.sh
+++ b/recipes/rabbitmq-consumer-group/bin/setup-cluster.sh
@@ -2,7 +2,7 @@
script_dir=`dirname $0`
LIB=$script_dir/../lib
-CLASSPATH=$script_dir/../target/classes:"$LIB"/helix-core-0.5.28.jar:"$LIB"/rabbitmq-client.jar:"$LIB"/commons-cli-1.1.jar:"$LIB"/commons-io-1.2.jar:"$LIB"/commons-math-2.1.jar:"$LIB"/jackson-core-asl-1.8.5.jar:"$LIB"/jackson-mapper-asl-1.8.5.jar:"$LIB"/log4j-1.2.15.jar:"$LIB"/org.restlet-1.1.10.jar:"$LIB"/zkclient-0.1.jar:"$LIB"/zookeeper-3.3.4.jar
+CLASSPATH=$script_dir/../target/classes:"$LIB"/helix-core-0.1-SNAPSHOT-incubating.jar:"$LIB"/rabbitmq-client.jar:"$LIB"/commons-cli-1.1.jar:"$LIB"/commons-io-1.2.jar:"$LIB"/commons-math-2.1.jar:"$LIB"/jackson-core-asl-1.8.5.jar:"$LIB"/jackson-mapper-asl-1.8.5.jar:"$LIB"/log4j-1.2.15.jar:"$LIB"/org.restlet-1.1.10.jar:"$LIB"/zkclient-0.1.jar:"$LIB"/zookeeper-3.3.4.jar
# echo $CLASSPATH
-java -cp "$CLASSPATH" com.linkedin.helix.recipes.rabbitmq.SetupConsumerCluster $@
+java -cp "$CLASSPATH" org.apache.helix.recipes.rabbitmq.SetupConsumerCluster $@
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/recipes/rabbitmq-consumer-group/bin/start-cluster-manager.sh
----------------------------------------------------------------------
diff --git a/recipes/rabbitmq-consumer-group/bin/start-cluster-manager.sh b/recipes/rabbitmq-consumer-group/bin/start-cluster-manager.sh
index a7c9ca8..fd63801 100755
--- a/recipes/rabbitmq-consumer-group/bin/start-cluster-manager.sh
+++ b/recipes/rabbitmq-consumer-group/bin/start-cluster-manager.sh
@@ -2,7 +2,7 @@
script_dir=`dirname $0`
LIB=$script_dir/../lib
-CLASSPATH=$script_dir/../target/classes:"$LIB"/helix-core-0.5.28.jar:"$LIB"/rabbitmq-client.jar:"$LIB"/commons-cli-1.1.jar:"$LIB"/commons-io-1.2.jar:"$LIB"/commons-math-2.1.jar:"$LIB"/jackson-core-asl-1.8.5.jar:"$LIB"/jackson-mapper-asl-1.8.5.jar:"$LIB"/log4j-1.2.15.jar:"$LIB"/org.restlet-1.1.10.jar:"$LIB"/zkclient-0.1.jar:"$LIB"/zookeeper-3.3.4.jar
+CLASSPATH=$script_dir/../target/classes:"$LIB"/helix-core-0.1-SNAPSHOT-incubating.jar:"$LIB"/rabbitmq-client.jar:"$LIB"/commons-cli-1.1.jar:"$LIB"/commons-io-1.2.jar:"$LIB"/commons-math-2.1.jar:"$LIB"/jackson-core-asl-1.8.5.jar:"$LIB"/jackson-mapper-asl-1.8.5.jar:"$LIB"/log4j-1.2.15.jar:"$LIB"/org.restlet-1.1.10.jar:"$LIB"/zkclient-0.1.jar:"$LIB"/zookeeper-3.3.4.jar
# echo $CLASSPATH
-java -cp "$CLASSPATH" com.linkedin.helix.recipes.rabbitmq.StartClusterManager $@
+java -cp "$CLASSPATH" org.apache.helix.recipes.rabbitmq.StartClusterManager $@
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/recipes/rabbitmq-consumer-group/bin/start-consumer.sh
----------------------------------------------------------------------
diff --git a/recipes/rabbitmq-consumer-group/bin/start-consumer.sh b/recipes/rabbitmq-consumer-group/bin/start-consumer.sh
index 8f36473..5328353 100755
--- a/recipes/rabbitmq-consumer-group/bin/start-consumer.sh
+++ b/recipes/rabbitmq-consumer-group/bin/start-consumer.sh
@@ -2,7 +2,7 @@
script_dir=`dirname $0`
LIB=$script_dir/../lib
-CLASSPATH=$script_dir/../target/classes:"$LIB"/helix-core-0.5.28.jar:"$LIB"/rabbitmq-client.jar:"$LIB"/commons-cli-1.1.jar:"$LIB"/commons-io-1.2.jar:"$LIB"/commons-math-2.1.jar:"$LIB"/jackson-core-asl-1.8.5.jar:"$LIB"/jackson-mapper-asl-1.8.5.jar:"$LIB"/log4j-1.2.15.jar:"$LIB"/org.restlet-1.1.10.jar:"$LIB"/zkclient-0.1.jar:"$LIB"/zookeeper-3.3.4.jar
+CLASSPATH=$script_dir/../target/classes:"$LIB"/helix-core-0.1-SNAPSHOT-incubating.jar:"$LIB"/rabbitmq-client.jar:"$LIB"/commons-cli-1.1.jar:"$LIB"/commons-io-1.2.jar:"$LIB"/commons-math-2.1.jar:"$LIB"/jackson-core-asl-1.8.5.jar:"$LIB"/jackson-mapper-asl-1.8.5.jar:"$LIB"/log4j-1.2.15.jar:"$LIB"/org.restlet-1.1.10.jar:"$LIB"/zkclient-0.1.jar:"$LIB"/zookeeper-3.3.4.jar
# echo $CLASSPATH
-java -cp "$CLASSPATH" com.linkedin.helix.recipes.rabbitmq.Consumer $@
+java -cp "$CLASSPATH" org.apache.helix.recipes.rabbitmq.Consumer $@
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/recipes/rabbitmq-consumer-group/lib/helix-core-0.5.28-sources.jar
----------------------------------------------------------------------
diff --git a/recipes/rabbitmq-consumer-group/lib/helix-core-0.5.28-sources.jar b/recipes/rabbitmq-consumer-group/lib/helix-core-0.5.28-sources.jar
deleted file mode 100644
index 42b3e86..0000000
Binary files a/recipes/rabbitmq-consumer-group/lib/helix-core-0.5.28-sources.jar and /dev/null differ
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/recipes/rabbitmq-consumer-group/lib/helix-core-0.5.28.jar
----------------------------------------------------------------------
diff --git a/recipes/rabbitmq-consumer-group/lib/helix-core-0.5.28.jar b/recipes/rabbitmq-consumer-group/lib/helix-core-0.5.28.jar
deleted file mode 100644
index 3323a16..0000000
Binary files a/recipes/rabbitmq-consumer-group/lib/helix-core-0.5.28.jar and /dev/null differ
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/recipes/rabbitmq-consumer-group/pom.xml
----------------------------------------------------------------------
diff --git a/recipes/rabbitmq-consumer-group/pom.xml b/recipes/rabbitmq-consumer-group/pom.xml
index 523832d..94708c5 100644
--- a/recipes/rabbitmq-consumer-group/pom.xml
+++ b/recipes/rabbitmq-consumer-group/pom.xml
@@ -15,11 +15,11 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>com.linkedin.helix</groupId>
+ <groupId>org.apache.helix</groupId>
<artifactId>helix-core</artifactId>
- <version>0.5.28</version>
+ <version>0.1-SNAPSHOT-incubating</version>
<scope>system</scope>
- <systemPath>${PWD}/lib/helix-core-0.5.28.jar</systemPath>
+ <systemPath>${PWD}/lib/helix-core-0.1-SNAPSHOT-incubating.jar</systemPath>
</dependency>
<dependency>
<groupId>com.rabbitmq</groupId>