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 01:14:57 UTC

[1/42] git commit: Refactoring the package names and removing jsql parser

Updated Branches:
  refs/heads/master 351784289 -> 437eb42ea


Refactoring the package names and removing jsql parser


Project: http://git-wip-us.apache.org/repos/asf/incubator-helix/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-helix/commit/437eb42e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-helix/tree/437eb42e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-helix/diff/437eb42e

Branch: refs/heads/master
Commit: 437eb42eac35e181ae6793dd17390df33565e4dd
Parents: 3517842
Author: Kishore Gopalakrishna <g....@gmail.com>
Authored: Wed Oct 24 16:14:36 2012 -0700
Committer: Kishore Gopalakrishna <g....@gmail.com>
Committed: Wed Oct 24 16:14:36 2012 -0700

----------------------------------------------------------------------
 .../org/apache/helix/webapp/HelixAdminWebApp.java  |   65 +
 .../apache/helix/webapp/RestAdminApplication.java  |  221 ++
 .../resources/ClusterRepresentationUtil.java       |  286 +++
 .../helix/webapp/resources/ClusterResource.java    |  210 ++
 .../helix/webapp/resources/ClustersResource.java   |  152 ++
 .../helix/webapp/resources/ConfigResource.java     |  311 +++
 .../helix/webapp/resources/ControllerResource.java |  157 ++
 .../resources/ControllerStatusUpdateResource.java  |  117 +
 .../webapp/resources/CurrentStateResource.java     |  123 +
 .../webapp/resources/CurrentStatesResource.java    |   98 +
 .../helix/webapp/resources/ErrorResource.java      |  121 +
 .../helix/webapp/resources/ErrorsResource.java     |   99 +
 .../webapp/resources/ExternalViewResource.java     |  111 +
 .../helix/webapp/resources/IdealStateResource.java |  195 ++
 .../helix/webapp/resources/InstanceResource.java   |  230 ++
 .../helix/webapp/resources/InstancesResource.java  |  192 ++
 .../helix/webapp/resources/JsonParameters.java     |  248 ++
 .../webapp/resources/ResourceGroupResource.java    |  173 ++
 .../webapp/resources/ResourceGroupsResource.java   |  174 ++
 .../webapp/resources/SchedulerTasksResource.java   |  186 ++
 .../helix/webapp/resources/StateModelResource.java |  157 ++
 .../webapp/resources/StateModelsResource.java      |  150 ++
 .../webapp/resources/StatusUpdateResource.java     |  127 +
 .../webapp/resources/StatusUpdatesResource.java    |  103 +
 .../helix/webapp/resources/ZkChildResource.java    |  158 ++
 .../helix/webapp/resources/ZkPathResource.java     |  213 ++
 .../java/org/apache/helix/tools/AdminTestBase.java |   69 +
 .../org/apache/helix/tools/AdminTestHelper.java    |   64 +
 .../helix/tools/TestHelixAdminScenariosRest.java   |  741 ++++++
 .../org/apache/helix/tools/TestResetInstance.java  |  119 +
 .../helix/tools/TestResetPartitionState.java       |  213 ++
 .../org/apache/helix/tools/TestResetResource.java  |  120 +
 .../helix/webapp/TestClusterManagementWebapp.java  |  649 +++++
 .../main/java/org/apache/helix/AccessOption.java   |   52 +
 .../java/org/apache/helix/BaseDataAccessor.java    |  192 ++
 .../org/apache/helix/ClusterMessagingService.java  |  116 +
 .../main/java/org/apache/helix/ClusterView.java    |  168 ++
 .../main/java/org/apache/helix/ConfigAccessor.java |  269 +++
 .../org/apache/helix/ConfigChangeListener.java     |   39 +
 .../main/java/org/apache/helix/ConfigScope.java    |  145 ++
 .../java/org/apache/helix/ConfigScopeBuilder.java  |  133 +
 .../org/apache/helix/ControllerChangeListener.java |   27 +
 .../src/main/java/org/apache/helix/Criteria.java   |  151 ++
 .../apache/helix/CurrentStateChangeListener.java   |   37 +
 .../main/java/org/apache/helix/DataAccessor.java   |   97 +
 .../apache/helix/ExternalViewChangeListener.java   |   35 +
 .../main/java/org/apache/helix/GroupCommit.java    |  168 ++
 .../apache/helix/HealthStateChangeListener.java    |   37 +
 .../src/main/java/org/apache/helix/HelixAdmin.java |  387 +++
 .../main/java/org/apache/helix/HelixConstants.java |   47 +
 .../java/org/apache/helix/HelixDataAccessor.java   |  161 ++
 .../main/java/org/apache/helix/HelixException.java |   31 +
 .../main/java/org/apache/helix/HelixManager.java   |  297 +++
 .../java/org/apache/helix/HelixManagerFactory.java |  104 +
 .../main/java/org/apache/helix/HelixProperty.java  |  224 ++
 .../main/java/org/apache/helix/HelixTimerTask.java |   33 +
 .../org/apache/helix/IdealStateChangeListener.java |   34 +
 .../main/java/org/apache/helix/InstanceType.java   |   34 +
 .../apache/helix/LiveInstanceChangeListener.java   |   35 +
 .../java/org/apache/helix/MessageListener.java     |   36 +
 .../java/org/apache/helix/NotificationContext.java |  103 +
 .../java/org/apache/helix/PreConnectCallback.java  |   12 +
 .../main/java/org/apache/helix/PropertyKey.java    |  553 +++++
 .../java/org/apache/helix/PropertyPathConfig.java  |  214 ++
 .../main/java/org/apache/helix/PropertyType.java   |  193 ++
 .../src/main/java/org/apache/helix/ZNRecord.java   |  364 +++
 .../java/org/apache/helix/ZNRecordAssembler.java   |   30 +
 .../java/org/apache/helix/ZNRecordBucketizer.java  |  116 +
 .../main/java/org/apache/helix/ZNRecordDelta.java  |   49 +
 .../java/org/apache/helix/ZNRecordUpdater.java     |   24 +
 .../apache/helix/alerts/AccumulateAggregator.java  |   71 +
 .../java/org/apache/helix/alerts/Aggregator.java   |   38 +
 .../main/java/org/apache/helix/alerts/Alert.java   |   53 +
 .../org/apache/helix/alerts/AlertComparator.java   |   27 +
 .../java/org/apache/helix/alerts/AlertParser.java  |  147 ++
 .../org/apache/helix/alerts/AlertProcessor.java    |  355 +++
 .../apache/helix/alerts/AlertValueAndStatus.java   |   39 +
 .../java/org/apache/helix/alerts/AlertsHolder.java |  286 +++
 .../org/apache/helix/alerts/DecayAggregator.java   |   79 +
 .../org/apache/helix/alerts/DivideOperator.java    |   36 +
 .../org/apache/helix/alerts/ExpandOperator.java    |   35 +
 .../helix/alerts/ExpressionOperatorType.java       |   42 +
 .../org/apache/helix/alerts/ExpressionParser.java  |  579 +++++
 .../helix/alerts/GreaterAlertComparator.java       |   41 +
 .../org/apache/helix/alerts/MultiplyOperator.java  |   59 +
 .../java/org/apache/helix/alerts/Operator.java     |  115 +
 .../main/java/org/apache/helix/alerts/Stat.java    |   44 +
 .../java/org/apache/helix/alerts/StatsHolder.java  |  358 +++
 .../org/apache/helix/alerts/SumEachOperator.java   |   47 +
 .../java/org/apache/helix/alerts/SumOperator.java  |   56 +
 .../main/java/org/apache/helix/alerts/Tuple.java   |   94 +
 .../org/apache/helix/alerts/WindowAggregator.java  |   91 +
 .../java/org/apache/helix/alerts/package-info.java |    4 +
 .../helix/controller/ExternalViewGenerator.java    |  154 ++
 .../helix/controller/GenericHelixController.java   |  608 +++++
 .../helix/controller/HelixControllerMain.java      |  266 +++
 .../helix/controller/HierarchicalDataHolder.java   |  168 ++
 .../org/apache/helix/controller/package-info.java  |    4 +
 .../controller/pipeline/AbstractBaseStage.java     |   79 +
 .../apache/helix/controller/pipeline/Pipeline.java |   65 +
 .../controller/pipeline/PipelineRegistry.java      |   54 +
 .../apache/helix/controller/pipeline/Stage.java    |   60 +
 .../helix/controller/pipeline/StageContext.java    |   21 +
 .../helix/controller/pipeline/StageException.java  |   29 +
 .../helix/controller/pipeline/package-info.java    |    5 +
 .../restlet/ZKPropertyTransferServer.java          |  262 ++
 .../helix/controller/restlet/ZNRecordUpdate.java   |   77 +
 .../controller/restlet/ZNRecordUpdateResource.java |   80 +
 .../restlet/ZkPropertyTransferApplication.java     |   30 +
 .../restlet/ZkPropertyTransferClient.java          |  178 ++
 .../helix/controller/restlet/package-info.java     |    5 +
 .../helix/controller/stages/AttributeName.java     |   27 +
 .../stages/BestPossibleStateCalcStage.java         |  532 +++++
 .../controller/stages/BestPossibleStateOutput.java |   73 +
 .../helix/controller/stages/ClusterDataCache.java  |  266 +++
 .../helix/controller/stages/ClusterEvent.java      |   73 +
 .../controller/stages/CompatibilityCheckStage.java |  123 +
 .../stages/CurrentStateComputationStage.java       |  168 ++
 .../controller/stages/CurrentStateOutput.java      |  205 ++
 .../stages/ExternalViewComputeStage.java           |  122 +
 .../helix/controller/stages/HealthDataCache.java   |  131 +
 .../controller/stages/MessageGenerationOutput.java |   74 +
 .../controller/stages/MessageGenerationPhase.java  |  184 ++
 .../controller/stages/MessageSelectionStage.java   |  337 +++
 .../stages/MessageSelectionStageOutput.java        |   66 +
 .../controller/stages/MessageThrottleStage.java    |  229 ++
 .../stages/MessageThrottleStageOutput.java         |   57 +
 .../controller/stages/ReadClusterDataStage.java    |   78 +
 .../controller/stages/ReadHealthDataStage.java     |   55 +
 .../stages/ResourceComputationStage.java           |  156 ++
 .../controller/stages/StatsAggregationStage.java   |  457 ++++
 .../controller/stages/TaskAssignmentStage.java     |  140 ++
 .../helix/controller/stages/package-info.java      |    5 +
 .../apache/helix/examples/BootstrapHandler.java    |  112 +
 .../apache/helix/examples/BootstrapProcess.java    |  405 ++++
 .../apache/helix/examples/DummyParticipant.java    |  123 +
 .../org/apache/helix/examples/ExampleHelper.java   |   56 +
 .../org/apache/helix/examples/ExampleProcess.java  |  269 +++
 .../apache/helix/examples/IdealStateExample.java   |  164 ++
 .../examples/LeaderStandbyStateModelFactory.java   |   67 +
 .../examples/MasterSlaveStateModelFactory.java     |   99 +
 .../examples/OnlineOfflineStateModelFactory.java   |   74 +
 .../org/apache/helix/examples/package-info.java    |    5 +
 .../healthcheck/AccumulateAggregationType.java     |   41 +
 .../apache/helix/healthcheck/AggregationType.java  |   29 +
 .../helix/healthcheck/AggregationTypeFactory.java  |   83 +
 .../helix/healthcheck/DecayAggregationType.java    |   62 +
 .../healthcheck/DefaultHealthReportProvider.java   |   94 +
 .../helix/healthcheck/DefaultPerfCounters.java     |  111 +
 .../helix/healthcheck/HealthReportProvider.java    |   38 +
 .../healthcheck/HealthStatsAggregationTask.java    |  203 ++
 .../ParticipantHealthReportCollector.java          |   29 +
 .../ParticipantHealthReportCollectorImpl.java      |  186 ++
 .../PerformanceHealthReportProvider.java           |  161 ++
 .../java/org/apache/helix/healthcheck/Stat.java    |  146 ++
 .../healthcheck/StatHealthReportProvider.java      |  175 ++
 .../helix/healthcheck/WindowAggregationType.java   |   76 +
 .../org/apache/helix/healthcheck/package-info.java |    5 +
 .../helix/josql/ClusterJosqlQueryProcessor.java    |  304 +++
 .../helix/josql/ZNRecordJosqlFunctionHandler.java  |   90 +
 .../java/org/apache/helix/josql/ZNRecordRow.java   |  195 ++
 .../java/org/apache/helix/josql/package-info.java  |    5 +
 .../manager/file/DynamicFileHelixManager.java      |  460 ++++
 .../helix/manager/file/FileCallbackHandler.java    |  293 +++
 .../helix/manager/file/FileDataAccessor.java       |  319 +++
 .../apache/helix/manager/file/FileHelixAdmin.java  |  486 ++++
 .../helix/manager/file/FileHelixDataAccessor.java  |  351 +++
 .../helix/manager/file/StaticFileHelixManager.java |  569 +++++
 .../apache/helix/manager/file/package-info.java    |    5 +
 .../apache/helix/manager/zk/BasicZkSerializer.java |   43 +
 .../helix/manager/zk/ByteArraySerializer.java      |   20 +
 .../java/org/apache/helix/manager/zk/Cache.java    |  146 ++
 .../apache/helix/manager/zk/CallbackHandler.java   |  399 ++++
 .../helix/manager/zk/ChainedPathZkSerializer.java  |  131 +
 .../zk/DefaultControllerMessageHandlerFactory.java |   88 +
 ...faultParticipantErrorMessageHandlerFactory.java |  128 +
 .../zk/DefaultSchedulerMessageHandlerFactory.java  |  277 +++
 .../apache/helix/manager/zk/HelixGroupCommit.java  |  174 ++
 .../helix/manager/zk/PathBasedZkSerializer.java    |   28 +
 .../apache/helix/manager/zk/WriteThroughCache.java |  114 +
 .../apache/helix/manager/zk/ZKDataAccessor.java    |  329 +++
 .../helix/manager/zk/ZKExceptionHandler.java       |   49 +
 .../org/apache/helix/manager/zk/ZKHelixAdmin.java  | 1272 ++++++++++
 .../helix/manager/zk/ZKHelixDataAccessor.java      |  590 +++++
 .../apache/helix/manager/zk/ZKHelixManager.java    | 1098 +++++++++
 .../java/org/apache/helix/manager/zk/ZKUtil.java   |  353 +++
 .../helix/manager/zk/ZNRecordSerializer.java       |  133 +
 .../manager/zk/ZNRecordStreamingSerializer.java    |  300 +++
 .../apache/helix/manager/zk/ZkAsyncCallbacks.java  |  171 ++
 .../helix/manager/zk/ZkBaseDataAccessor.java       | 1243 ++++++++++
 .../helix/manager/zk/ZkCacheBaseDataAccessor.java  |  984 ++++++++
 .../helix/manager/zk/ZkCacheEventThread.java       |   88 +
 .../apache/helix/manager/zk/ZkCallbackCache.java   |  348 +++
 .../java/org/apache/helix/manager/zk/ZkClient.java |  445 ++++
 .../helix/manager/zk/ZkStateChangeListener.java    |   93 +
 .../org/apache/helix/manager/zk/package-info.java  |    5 +
 .../org/apache/helix/messaging/AsyncCallback.java  |  168 ++
 .../apache/helix/messaging/CriteriaEvaluator.java  |   94 +
 .../helix/messaging/DefaultMessagingService.java   |  392 +++
 .../messaging/handling/AsyncCallbackService.java   |  149 ++
 .../messaging/handling/GroupMessageHandler.java    |  116 +
 .../handling/HelixStateTransitionHandler.java      |  388 +++
 .../apache/helix/messaging/handling/HelixTask.java |  369 +++
 .../messaging/handling/HelixTaskExecutor.java      |  638 +++++
 .../helix/messaging/handling/HelixTaskResult.java  |   74 +
 .../helix/messaging/handling/MessageHandler.java   |   83 +
 .../messaging/handling/MessageHandlerFactory.java  |   28 +
 .../helix/messaging/handling/package-info.java     |    5 +
 .../org/apache/helix/messaging/package-info.java   |    5 +
 .../java/org/apache/helix/model/AlertHistory.java  |   22 +
 .../java/org/apache/helix/model/AlertStatus.java   |   86 +
 .../main/java/org/apache/helix/model/Alerts.java   |   91 +
 .../org/apache/helix/model/ClusterConstraints.java |  217 ++
 .../java/org/apache/helix/model/CurrentState.java  |  169 ++
 .../main/java/org/apache/helix/model/Error.java    |   20 +
 .../java/org/apache/helix/model/ExternalView.java  |   77 +
 .../java/org/apache/helix/model/HealthStat.java    |  126 +
 .../java/org/apache/helix/model/IdealState.java    |  312 +++
 .../org/apache/helix/model/InstanceConfig.java     |  190 ++
 .../java/org/apache/helix/model/LeaderHistory.java |   65 +
 .../java/org/apache/helix/model/LiveInstance.java  |  115 +
 .../main/java/org/apache/helix/model/Message.java  |  584 +++++
 .../java/org/apache/helix/model/Partition.java     |   57 +
 .../java/org/apache/helix/model/PauseSignal.java   |   38 +
 .../org/apache/helix/model/PersistentStats.java    |   98 +
 .../main/java/org/apache/helix/model/Resource.java |  123 +
 .../org/apache/helix/model/ResourceAssignment.java |   21 +
 .../apache/helix/model/StateModelDefinition.java   |  143 ++
 .../java/org/apache/helix/model/StatusUpdate.java  |   36 +
 .../java/org/apache/helix/model/package-info.java  |    5 +
 .../helix/monitoring/ParticipantMonitor.java       |  137 ++
 .../helix/monitoring/SensorNameProvider.java       |    6 +
 .../org/apache/helix/monitoring/StatCollector.java |   90 +
 .../helix/monitoring/StateTransitionContext.java   |   90 +
 .../helix/monitoring/StateTransitionDataPoint.java |   45 +
 .../helix/monitoring/ZKPathDataDumpTask.java       |  163 ++
 .../helix/monitoring/mbeans/ClusterAlertItem.java  |   98 +
 .../monitoring/mbeans/ClusterAlertItemMBean.java   |   27 +
 .../mbeans/ClusterAlertMBeanCollection.java        |  333 +++
 .../monitoring/mbeans/ClusterMBeanObserver.java    |   98 +
 .../monitoring/mbeans/ClusterStatusMonitor.java    |  283 +++
 .../mbeans/ClusterStatusMonitorMBean.java          |   43 +
 .../mbeans/HelixStageLatencyMonitor.java           |  113 +
 .../mbeans/HelixStageLatencyMonitorMBean.java      |   25 +
 .../monitoring/mbeans/MessageQueueMonitor.java     |   51 +
 .../mbeans/MessageQueueMonitorMBean.java           |   19 +
 .../helix/monitoring/mbeans/ResourceMonitor.java   |  141 ++
 .../monitoring/mbeans/ResourceMonitorMBean.java    |   29 +
 .../mbeans/StateTransitionStatMonitor.java         |  157 ++
 .../mbeans/StateTransitionStatMonitorMBean.java    |   44 +
 .../helix/monitoring/mbeans/package-info.java      |    5 +
 .../org/apache/helix/monitoring/package-info.java  |    5 +
 .../main/java/org/apache/helix/package-info.java   |   29 +
 .../participant/CustomCodeCallbackHandler.java     |   31 +
 .../helix/participant/CustomCodeInvoker.java       |  122 +
 .../participant/DistClusterControllerElection.java |  199 ++
 .../DistClusterControllerStateModel.java           |  149 ++
 .../DistClusterControllerStateModelFactory.java    |   36 +
 .../participant/GenericLeaderStandbyModel.java     |   96 +
 .../GenericLeaderStandbyStateModelFactory.java     |   45 +
 .../helix/participant/HelixCustomCodeRunner.java   |  183 ++
 .../helix/participant/HelixStateMachineEngine.java |  284 +++
 .../helix/participant/StateMachineEngine.java      |   67 +
 .../org/apache/helix/participant/package-info.java |    5 +
 .../helix/participant/statemachine/StateModel.java |   75 +
 .../statemachine/StateModelFactory.java            |   75 +
 .../participant/statemachine/StateModelInfo.java   |   28 +
 .../participant/statemachine/StateModelParser.java |  149 ++
 .../statemachine/StateTransitionError.java         |   43 +
 .../helix/participant/statemachine/Transition.java |   28 +
 .../participant/statemachine/package-info.java     |    5 +
 .../helix/spectator/RoutingTableProvider.java      |  301 +++
 .../org/apache/helix/spectator/package-info.java   |    5 +
 .../apache/helix/store/HelixPropertyListener.java  |   25 +
 .../org/apache/helix/store/HelixPropertyStore.java |   44 +
 .../apache/helix/store/PropertyChangeListener.java |   39 +
 .../apache/helix/store/PropertyJsonComparator.java |   65 +
 .../apache/helix/store/PropertyJsonSerializer.java |   95 +
 .../org/apache/helix/store/PropertySerializer.java |   40 +
 .../java/org/apache/helix/store/PropertyStat.java  |   55 +
 .../java/org/apache/helix/store/PropertyStore.java |  212 ++
 .../apache/helix/store/PropertyStoreException.java |   36 +
 .../apache/helix/store/PropertyStoreFactory.java   |   63 +
 .../apache/helix/store/ZNRecordJsonSerializer.java |   40 +
 .../helix/store/file/FileHelixPropertyStore.java   |  293 +++
 .../apache/helix/store/file/FilePropertyStore.java |  942 ++++++++
 .../org/apache/helix/store/file/package-info.java  |    5 +
 .../java/org/apache/helix/store/package-info.java  |    5 +
 .../org/apache/helix/store/zk/PropertyItem.java    |   45 +
 .../org/apache/helix/store/zk/ZKPropertyStore.java |  735 ++++++
 .../main/java/org/apache/helix/store/zk/ZNode.java |  110 +
 .../apache/helix/store/zk/ZkCallbackHandler.java   |   97 +
 .../helix/store/zk/ZkHelixPropertyStore.java       |   31 +
 .../java/org/apache/helix/store/zk/ZkListener.java |   10 +
 .../org/apache/helix/store/zk/package-info.java    |    5 +
 .../org/apache/helix/tools/CLMLogFileAppender.java |   83 +
 .../java/org/apache/helix/tools/ClusterSetup.java  | 1853 +++++++++++++++
 .../apache/helix/tools/ClusterStateVerifier.java   |  909 +++++++
 .../apache/helix/tools/ClusterViewSerializer.java  |  177 ++
 .../tools/IdealCalculatorByConsistentHashing.java  |  626 +++++
 .../helix/tools/IdealStateCalculatorByRush.java    |  326 +++
 .../tools/IdealStateCalculatorByShuffling.java     |  119 +
 .../IdealStateCalculatorForEspressoRelay.java      |  101 +
 .../tools/IdealStateCalculatorForStorageNode.java  |  788 ++++++
 .../java/org/apache/helix/tools/JmxDumper.java     |  471 ++++
 .../java/org/apache/helix/tools/LocalZKServer.java |   75 +
 .../java/org/apache/helix/tools/MessagePoster.java |  120 +
 .../org/apache/helix/tools/PropertiesReader.java   |   56 +
 .../java/org/apache/helix/tools/RUSHrHash.java     |  352 +++
 .../helix/tools/StateModelConfigGenerator.java     |  347 +++
 .../java/org/apache/helix/tools/TestCommand.java   |  106 +
 .../java/org/apache/helix/tools/TestExecutor.java  | 1029 ++++++++
 .../java/org/apache/helix/tools/TestTrigger.java   |  128 +
 .../org/apache/helix/tools/YAISCalculator.java     |  202 ++
 .../main/java/org/apache/helix/tools/ZKDumper.java |  274 +++
 .../org/apache/helix/tools/ZKLogFormatter.java     |  395 +++
 .../java/org/apache/helix/tools/ZkLogAnalyzer.java |  491 ++++
 .../org/apache/helix/tools/ZkLogCSVFormatter.java  |  445 ++++
 .../java/org/apache/helix/tools/ZnodeOpArg.java    |  181 ++
 .../java/org/apache/helix/tools/ZnodeValue.java    |   77 +
 .../java/org/apache/helix/tools/package-info.java  |    5 +
 .../main/java/org/apache/helix/util/HelixUtil.java |  181 ++
 .../org/apache/helix/util/StatusUpdateUtil.java    |  629 +++++
 .../java/org/apache/helix/util/StringTemplate.java |   83 +
 .../java/org/apache/helix/util/ZKClientPool.java   |   71 +
 .../java/org/apache/helix/util/ZNRecordUtil.java   |  123 +
 .../java/org/apache/helix/util/package-info.java   |    5 +
 .../src/test/java/org/apache/helix/AppTest.java    |  189 ++
 .../java/org/apache/helix/DummyProcessThread.java  |   76 +
 .../java/org/apache/helix/ExternalCommand.java     |  389 +++
 .../src/test/java/org/apache/helix/Mocks.java      |  788 ++++++
 .../java/org/apache/helix/ScriptTestHelper.java    |   62 +
 .../apache/helix/TestClusterviewSerializer.java    |   73 +
 .../java/org/apache/helix/TestConfigAccessor.java  |  150 ++
 .../TestEspressoStorageClusterIdealState.java      |  320 +++
 .../java/org/apache/helix/TestGetProperty.java     |   48 +
 .../java/org/apache/helix/TestGroupCommit.java     |   57 +
 .../org/apache/helix/TestHelixTaskExecutor.java    |   89 +
 .../org/apache/helix/TestHelixTaskHandler.java     |  130 +
 .../src/test/java/org/apache/helix/TestHelper.java | 1089 +++++++++
 .../apache/helix/TestHierarchicalDataStore.java    |   83 +
 .../TestParticipantHealthReportCollectorImpl.java  |   70 +
 .../java/org/apache/helix/TestPerfCounters.java    |   73 +
 .../helix/TestPerformanceHealthReportProvider.java |  164 ++
 .../org/apache/helix/TestPropertyPathConfig.java   |   55 +
 .../helix/TestRelayIdealStateCalculator.java       |   70 +
 .../java/org/apache/helix/TestRoutingTable.java    |  289 +++
 .../src/test/java/org/apache/helix/TestSample.java |   66 +
 .../org/apache/helix/TestShuffledIdealState.java   |  266 +++
 .../test/java/org/apache/helix/TestZKCallback.java |  258 ++
 .../apache/helix/TestZKRoutingInfoProvider.java    |  208 ++
 .../test/java/org/apache/helix/TestZNRecord.java   |  128 +
 .../org/apache/helix/TestZNRecordBucketizer.java   |   41 +
 .../java/org/apache/helix/TestZkClientWrapper.java |  121 +
 .../org/apache/helix/TestZkConnectionCount.java    |   46 +
 .../java/org/apache/helix/TestZnodeModify.java     |  278 +++
 .../test/java/org/apache/helix/ZkTestHelper.java   |  175 ++
 .../test/java/org/apache/helix/ZkUnitTestBase.java |  433 ++++
 .../org/apache/helix/alerts/TestAddAlerts.java     |  121 +
 .../helix/alerts/TestAddPersistentStats.java       |  217 ++
 .../apache/helix/alerts/TestAlertValidation.java   |  165 ++
 .../helix/alerts/TestArrivingParticipantStats.java |  487 ++++
 .../helix/alerts/TestBaseStatsValidation.java      |  181 ++
 .../apache/helix/alerts/TestEvaluateAlerts.java    |  391 +++
 .../org/apache/helix/alerts/TestOperators.java     |  289 +++
 .../org/apache/helix/alerts/TestStatsMatch.java    |  105 +
 .../helix/controller/stages/BaseStageTest.java     |  173 ++
 .../controller/stages/DummyClusterManager.java     |  268 +++
 .../stages/TestBestPossibleStateCalcStage.java     |   69 +
 .../helix/controller/stages/TestClusterEvent.java  |   34 +
 .../stages/TestCompatibilityCheckStage.java        |  170 ++
 .../stages/TestCurrentStateComputationStage.java   |  126 +
 .../stages/TestMessageThrottleStage.java           |  365 +++
 .../controller/stages/TestMsgSelectionStage.java   |  118 +
 .../controller/stages/TestParseInfoFromAlert.java  |   38 +
 .../controller/stages/TestRebalancePipeline.java   |  428 ++++
 .../stages/TestResourceComputationStage.java       |  245 ++
 .../apache/helix/healthcheck/TestAddDropAlert.java |  194 ++
 .../healthcheck/TestAlertActionTriggering.java     |  189 ++
 .../helix/healthcheck/TestAlertFireHistory.java    |  328 +++
 .../apache/helix/healthcheck/TestDummyAlerts.java  |  153 ++
 .../apache/helix/healthcheck/TestExpandAlert.java  |  195 ++
 .../apache/helix/healthcheck/TestSimpleAlert.java  |  207 ++
 .../helix/healthcheck/TestSimpleWildcardAlert.java |  256 ++
 .../helix/healthcheck/TestStalenessAlert.java      |  192 ++
 .../helix/healthcheck/TestWildcardAlert.java       |  301 +++
 .../apache/helix/integration/FileCMTestBase.java   |  208 ++
 .../apache/helix/integration/IntegrationTest.java  |   39 +
 .../apache/helix/integration/TestAddClusterV2.java |  227 ++
 .../TestAddNodeAfterControllerStart.java           |  238 ++
 .../TestAddStateModelFactoryAfterConnect.java      |  126 +
 .../helix/integration/TestAutoIsWithEmptyMap.java  |   87 +
 .../helix/integration/TestAutoRebalance.java       |  213 ++
 .../helix/integration/TestBasicSpectator.java      |   61 +
 .../helix/integration/TestBucketizedResource.java  |   87 +
 .../integration/TestCMWithFailParticipant.java     |   68 +
 .../integration/TestCarryOverBadCurState.java      |   73 +
 .../helix/integration/TestClusterStartsup.java     |  165 ++
 .../helix/integration/TestCustomIdealState.java    |  155 ++
 .../org/apache/helix/integration/TestDisable.java  |  403 ++++
 .../apache/helix/integration/TestDisableNode.java  |   46 +
 .../helix/integration/TestDisablePartition.java    |   75 +
 .../helix/integration/TestDistributedCMMain.java   |  179 ++
 .../TestDistributedClusterController.java          |  148 ++
 .../org/apache/helix/integration/TestDriver.java   |  519 ++++
 .../org/apache/helix/integration/TestDrop.java     |  200 ++
 .../apache/helix/integration/TestDropResource.java |   91 +
 .../integration/TestDynamicFileClusterManager.java |   59 +
 .../TestEnablePartitionDuringDisable.java          |  159 ++
 .../helix/integration/TestErrorPartition.java      |  148 ++
 .../helix/integration/TestExpandCluster.java       |   72 +
 .../apache/helix/integration/TestExternalCmd.java  |   36 +
 .../helix/integration/TestExternalViewUpdates.java |   89 +
 .../helix/integration/TestFailOverPerf1kp.java     |   52 +
 .../integration/TestFileBasedHelixManager.java     |   67 +
 .../apache/helix/integration/TestGroupMessage.java |  194 ++
 .../integration/TestHelixCustomCodeRunner.java     |  154 ++
 .../integration/TestHelixUsingDifferentParams.java |   74 +
 .../TestMessagePartitionStateMismatch.java         |   78 +
 .../helix/integration/TestMessageThrottle.java     |  144 ++
 .../helix/integration/TestMessagingService.java    |  478 ++++
 .../helix/integration/TestNonOfflineInitState.java |  113 +
 .../apache/helix/integration/TestNullReplica.java  |   78 +
 .../integration/TestParticipantErrorMessage.java   |   76 +
 .../integration/TestParticipantNameCollision.java  |   57 +
 .../apache/helix/integration/TestPauseSignal.java  |  121 +
 .../helix/integration/TestRenamePartition.java     |  140 ++
 .../helix/integration/TestResetInstance.java       |  113 +
 .../helix/integration/TestResetPartitionState.java |  224 ++
 .../helix/integration/TestResetResource.java       |  112 +
 .../helix/integration/TestRestartParticipant.java  |  115 +
 .../helix/integration/TestSchedulerMessage.java    |  425 ++++
 .../apache/helix/integration/TestSchemataSM.java   |   66 +
 .../integration/TestSessionExpiryInTransition.java |  115 +
 .../helix/integration/TestStandAloneCMMain.java    |   57 +
 .../integration/TestStandAloneCMSessionExpiry.java |  136 ++
 .../integration/TestStateTransitionTimeout.java    |  210 ++
 .../apache/helix/integration/TestStatusUpdate.java |  103 +
 .../apache/helix/integration/TestSwapInstance.java |  128 +
 .../helix/integration/ZkIntegrationTestBase.java   |  160 ++
 .../helix/integration/ZkStandAloneCMTestBase.java  |  166 ++
 ...tandAloneCMTestBaseWithPropertyServerCheck.java |   73 +
 .../josql/TestClusterJosqlQueryProcessor.java      |  102 +
 .../org/apache/helix/josql/TestJosqlProcessor.java |  228 ++
 .../org/apache/helix/manager/MockListener.java     |  106 +
 .../helix/manager/file/MockFileHelixManager.java   |  275 +++
 .../manager/file/TestFileCallbackHandler.java      |  104 +
 .../helix/manager/file/TestFileDataAccessor.java   |   94 +
 .../helix/manager/file/TestStaticFileCM.java       |  148 ++
 .../manager/file/UnitTestDynFileClusterMgr.java    |  282 +++
 .../zk/TestDefaultControllerMsgHandlerFactory.java |  102 +
 .../helix/manager/zk/TestHandleNewSession.java     |   71 +
 .../helix/manager/zk/TestLiveInstanceBounce.java   |   65 +
 .../manager/zk/TestWtCacheAsyncOpMultiThread.java  |  278 +++
 .../manager/zk/TestWtCacheAsyncOpSingleThread.java |  253 ++
 .../manager/zk/TestWtCacheSyncOpSingleThread.java  |  196 ++
 .../helix/manager/zk/TestZKDataAccessor.java       |  174 ++
 .../helix/manager/zk/TestZKDataAccessorCache.java  |  152 ++
 .../helix/manager/zk/TestZKLiveInstanceData.java   |  152 ++
 .../manager/zk/TestZKPropertyTransferServer.java   |   59 +
 .../org/apache/helix/manager/zk/TestZKUtil.java    |  163 ++
 .../helix/manager/zk/TestZNRecordSizeLimit.java    |  328 +++
 .../helix/manager/zk/TestZkBaseDataAccessor.java   |  318 +++
 .../manager/zk/TestZkCacheAsyncOpSingleThread.java |  382 +++
 .../manager/zk/TestZkCacheSyncOpSingleThread.java  |  209 ++
 .../helix/manager/zk/TestZkClusterManager.java     |  146 ++
 .../apache/helix/manager/zk/TestZkHelixAdmin.java  |  198 ++
 .../apache/helix/messaging/TestAsyncCallback.java  |  127 +
 .../helix/messaging/TestAsyncCallbackSvc.java      |  128 +
 .../messaging/TestDefaultMessagingService.java     |  243 ++
 .../handling/TestConfigThreadpoolSize.java         |  124 +
 .../messaging/handling/TestHelixTaskExecutor.java  |  588 +++++
 .../handling/TestResourceThreadpoolSize.java       |   51 +
 .../helix/mock/consumer/ConsumerAdapter.java       |  134 ++
 .../apache/helix/mock/consumer/RelayConfig.java    |   81 +
 .../apache/helix/mock/consumer/RelayConsumer.java  |  108 +
 .../helix/mock/controller/ClusterController.java   |  152 ++
 .../helix/mock/controller/MockController.java      |  143 ++
 .../mock/controller/MockControllerProcess.java     |   73 +
 .../apache/helix/mock/relay/DummyRelayProcess.java |  248 ++
 .../helix/mock/relay/RelayIdealStateGenerator.java |   48 +
 .../helix/mock/router/MockRouterProcess.java       |  158 ++
 .../apache/helix/mock/router/RouterAdapter.java    |   21 +
 .../apache/helix/mock/storage/DummyProcess.java    |  546 +++++
 .../helix/mock/storage/HealthCheckStateModel.java  |  247 ++
 .../mock/storage/HealthCheckStateModelFactory.java |   50 +
 .../storage/MockEspressoHealthReportProvider.java  |   83 +
 .../mock/storage/MockHealthReportParticipant.java  |  274 +++
 .../org/apache/helix/mock/storage/MockJobIntf.java |   24 +
 .../apache/helix/mock/storage/MockParticipant.java |  615 +++++
 .../helix/mock/storage/MockStorageProcess.java     |  171 ++
 .../apache/helix/mock/storage/MockTransition.java  |   39 +
 .../apache/helix/mock/storage/StorageAdapter.java  |  206 ++
 .../helix/mock/storage/StorageStateModel.java      |  157 ++
 .../mock/storage/StorageStateModelFactory.java     |   49 +
 .../org/apache/helix/model/TestConstraint.java     |  266 +++
 .../org/apache/helix/model/TestIdealState.java     |   61 +
 .../helix/monitoring/TestParticipantMonitor.java   |  155 ++
 .../apache/helix/monitoring/TestStatCollector.java |   54 +
 .../TestClusterAlertItemMBeanCollection.java       |  255 ++
 .../mbeans/TestClusterStatusMonitor.java           |  128 +
 .../monitoring/mbeans/TestResourceMonitor.java     |  172 ++
 .../helix/participant/MockZKHelixManager.java      |  280 +++
 .../participant/TestDistControllerElection.java    |  181 ++
 .../participant/TestDistControllerStateModel.java  |  135 ++
 .../TestDistControllerStateModelFactory.java       |   36 +
 .../org/apache/helix/store/TestJsonComparator.java |   40 +
 .../org/apache/helix/store/TestPropertyStat.java   |   35 +
 .../helix/store/TestPropertyStoreException.java    |   37 +
 .../helix/store/TestPropertyStoreFactory.java      |   93 +
 .../helix/store/TestZNRecordJsonSerializer.java    |   76 +
 .../helix/store/file/TestFilePropertyStore.java    |  156 ++
 .../apache/helix/store/zk/TestZKPropertyStore.java |  537 +++++
 .../store/zk/TestZKPropertyStoreMultiThread.java   |  157 ++
 .../helix/store/zk/TestZkHelixPropertyStore.java   |  369 +++
 .../store/zk/TestZkPropertyStoreSessionExpiry.java |  107 +
 .../org/apache/helix/tools/TestClusterSetup.java   |  494 ++++
 .../helix/tools/TestHelixAdminScenariosCli.java    |  423 ++++
 .../org/apache/helix/util/TestZKClientPool.java    |   72 +
 .../main/java/org/apache/helix/CMConnector.java    |   42 +
 .../java/org/apache/helix/EspressoResource.java    |  214 ++
 .../org/apache/helix/EspressoStorageMockNode.java  |  194 ++
 .../EspressoStorageMockStateModelFactory.java      |   99 +
 .../java/org/apache/helix/FnvHashFunction.java     |  201 ++
 .../main/java/org/apache/helix/HashFunction.java   |   68 +
 .../java/org/apache/helix/MockEspressoService.java |  269 +++
 .../src/main/java/org/apache/helix/MockNode.java   |   32 +
 .../java/org/apache/helix/MockNodeFactory.java     |   37 +
 .../src/main/java/org/apache/helix/MockRunner.java |   58 +
 .../java/org/apache/helix/StopServiceResource.java |  141 ++
 .../src/test/java/org/apache/helix/AppTest.java    |   43 +
 .../apache/helix/recipes/rabbitmq/Consumer.java    |  130 +
 .../helix/recipes/rabbitmq/ConsumerStateModel.java |   97 +
 .../rabbitmq/ConsumerStateModelFactory.java        |   21 +
 .../helix/recipes/rabbitmq/ConsumerThread.java     |   76 +
 .../org/apache/helix/recipes/rabbitmq/Emitter.java |   56 +
 .../recipes/rabbitmq/SetupConsumerCluster.java     |   58 +
 .../recipes/rabbitmq/StartClusterManager.java      |   42 +
 538 files changed, 93277 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/437eb42e/helix-admin-webapp/src/main/java/org/apache/helix/webapp/HelixAdminWebApp.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/main/java/org/apache/helix/webapp/HelixAdminWebApp.java b/helix-admin-webapp/src/main/java/org/apache/helix/webapp/HelixAdminWebApp.java
new file mode 100644
index 0000000..cf87916
--- /dev/null
+++ b/helix-admin-webapp/src/main/java/org/apache/helix/webapp/HelixAdminWebApp.java
@@ -0,0 +1,65 @@
+package org.apache.helix.webapp;
+
+import org.apache.helix.manager.zk.ZNRecordSerializer;
+import org.apache.helix.manager.zk.ZkClient;
+import org.apache.log4j.Logger;
+import org.restlet.Component;
+import org.restlet.Context;
+import org.restlet.data.Protocol;
+
+
+public class HelixAdminWebApp
+{
+  public final Logger LOG = Logger.getLogger(HelixAdminWebApp.class);
+  RestAdminApplication _adminApp = null;
+  Component _component = null; 
+  
+  int _helixAdminPort;
+  String _zkServerAddress;
+  ZkClient _zkClient;
+  
+  public HelixAdminWebApp(String zkServerAddress, int adminPort)
+  {
+    _zkServerAddress = zkServerAddress;
+    _helixAdminPort = adminPort;
+  }
+  
+  public synchronized void start() throws Exception
+  {
+    LOG.info("helixAdminWebApp starting");
+    if(_component == null)
+    {
+      _zkClient = new ZkClient(_zkServerAddress,  ZkClient.DEFAULT_SESSION_TIMEOUT, ZkClient.DEFAULT_CONNECTION_TIMEOUT, new ZNRecordSerializer());
+      _component =  new Component();
+      _component.getServers().add(Protocol.HTTP, _helixAdminPort);
+      Context applicationContext = _component.getContext().createChildContext();
+      applicationContext.getAttributes().put(RestAdminApplication.ZKSERVERADDRESS, _zkServerAddress);
+      applicationContext.getAttributes().put(RestAdminApplication.PORT, ""+_helixAdminPort);
+      applicationContext.getAttributes().put(RestAdminApplication.ZKCLIENT, _zkClient);
+      _adminApp = new RestAdminApplication(applicationContext); 
+      // Attach the application to the component and start it
+      _component.getDefaultHost().attach(_adminApp);
+      _component.start();
+    }
+    LOG.info("helixAdminWebApp started on port " + _helixAdminPort);
+  }
+  
+  public synchronized void stop() 
+  {
+    try
+    {
+      _component.stop();
+    }
+    catch(Exception e)
+    {
+      LOG.error("", e);
+    }
+    finally
+    {
+      if(_zkClient != null)
+      {
+        _zkClient.close();
+      }
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/437eb42e/helix-admin-webapp/src/main/java/org/apache/helix/webapp/RestAdminApplication.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/main/java/org/apache/helix/webapp/RestAdminApplication.java b/helix-admin-webapp/src/main/java/org/apache/helix/webapp/RestAdminApplication.java
new file mode 100644
index 0000000..c6688b9
--- /dev/null
+++ b/helix-admin-webapp/src/main/java/org/apache/helix/webapp/RestAdminApplication.java
@@ -0,0 +1,221 @@
+/**
+ * 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 org.apache.helix.webapp;
+
+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.helix.webapp.resources.ClusterResource;
+import org.apache.helix.webapp.resources.ClustersResource;
+import org.apache.helix.webapp.resources.ConfigResource;
+import org.apache.helix.webapp.resources.ControllerResource;
+import org.apache.helix.webapp.resources.ControllerStatusUpdateResource;
+import org.apache.helix.webapp.resources.CurrentStateResource;
+import org.apache.helix.webapp.resources.CurrentStatesResource;
+import org.apache.helix.webapp.resources.ErrorResource;
+import org.apache.helix.webapp.resources.ErrorsResource;
+import org.apache.helix.webapp.resources.ExternalViewResource;
+import org.apache.helix.webapp.resources.IdealStateResource;
+import org.apache.helix.webapp.resources.InstanceResource;
+import org.apache.helix.webapp.resources.InstancesResource;
+import org.apache.helix.webapp.resources.ResourceGroupResource;
+import org.apache.helix.webapp.resources.ResourceGroupsResource;
+import org.apache.helix.webapp.resources.SchedulerTasksResource;
+import org.apache.helix.webapp.resources.StateModelResource;
+import org.apache.helix.webapp.resources.StateModelsResource;
+import org.apache.helix.webapp.resources.StatusUpdateResource;
+import org.apache.helix.webapp.resources.StatusUpdatesResource;
+import org.apache.helix.webapp.resources.ZkChildResource;
+import org.apache.helix.webapp.resources.ZkPathResource;
+import org.restlet.Application;
+import org.restlet.Context;
+import org.restlet.Restlet;
+import org.restlet.Router;
+import org.restlet.data.MediaType;
+import org.restlet.data.Request;
+import org.restlet.data.Response;
+import org.restlet.resource.StringRepresentation;
+import org.restlet.util.Template;
+
+
+public class RestAdminApplication extends Application
+{
+  public static final String HELP = "help";
+  public static final String ZKSERVERADDRESS = "zkSvr";
+  public static final String PORT = "port";
+  public static final String ZKCLIENT = "zkClient";
+  public static final int DEFAULT_PORT = 8100;
+  
+
+  public RestAdminApplication()
+  {
+    super();
+  }
+
+  public RestAdminApplication(Context context)
+  {
+    super(context);
+  }
+  
+  @Override
+  public Restlet createRoot()
+  {
+    Router router = new Router(getContext());
+    router.setDefaultMatchingMode(Template.MODE_EQUALS);
+    router.attach("/clusters", ClustersResource.class);
+    router.attach("/clusters/{clusterName}", ClusterResource.class);
+    router.attach("/clusters/{clusterName}/resourceGroups", ResourceGroupsResource.class);
+    router.attach("/clusters/{clusterName}/resourceGroups/{resourceName}", ResourceGroupResource.class);
+    router.attach("/clusters/{clusterName}/instances", InstancesResource.class);
+    router.attach("/clusters/{clusterName}/instances/{instanceName}", InstanceResource.class);
+    router.attach("/clusters/{clusterName}/instances/{instanceName}/currentState/{resourceName}", CurrentStateResource.class);
+    router.attach("/clusters/{clusterName}/instances/{instanceName}/statusUpdate/{resourceName}", StatusUpdateResource.class);
+    router.attach("/clusters/{clusterName}/instances/{instanceName}/errors/{resourceName}", ErrorResource.class);
+    router.attach("/clusters/{clusterName}/instances/{instanceName}/currentState", CurrentStatesResource.class);
+    router.attach("/clusters/{clusterName}/instances/{instanceName}/statusUpdate", StatusUpdatesResource.class);
+    router.attach("/clusters/{clusterName}/instances/{instanceName}/errors", ErrorsResource.class);
+    router.attach("/clusters/{clusterName}/resourceGroups/{resourceName}/idealState", IdealStateResource.class);
+    router.attach("/clusters/{clusterName}/resourceGroups/{resourceName}/externalView", ExternalViewResource.class);
+    router.attach("/clusters/{clusterName}/StateModelDefs/{modelName}", StateModelResource.class);
+    router.attach("/clusters/{clusterName}/StateModelDefs", StateModelsResource.class);
+    router.attach("/clusters/{clusterName}/SchedulerTasks", SchedulerTasksResource.class);
+    router.attach("/clusters/{clusterName}/Controller", ControllerResource.class);
+    router.attach("/clusters/{clusterName}/Controller/statusUpdates/{MessageType}/{MessageId}", ControllerStatusUpdateResource.class);
+    router.attach("/clusters/{clusterName}/configs", ConfigResource.class);
+    router.attach("/clusters/{clusterName}/configs/{scope}", ConfigResource.class);
+    router.attach("/clusters/{clusterName}/configs/{scope}/{scopeKey1}", ConfigResource.class);
+    router.attach("/clusters/{clusterName}/configs/{scope}/{scopeKey1}/{scopeKey2}", ConfigResource.class);
+    router.attach("/zkPath", ZkPathResource.class).setMatchingMode(Template.MODE_STARTS_WITH);
+    router.attach("/zkChild", ZkChildResource.class).setMatchingMode(Template.MODE_STARTS_WITH);
+
+    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));
+      }
+    };
+    router.attach("", mainpage);
+    return router;
+  }
+
+  public static void printUsage(Options cliOptions)
+  {
+    HelpFormatter helpFormatter = new HelpFormatter();
+    helpFormatter.printHelp("java " + RestAdminApplication.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 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(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("RestAdminApplication: failed to parse command-line options: "
+          + pe.toString());
+      printUsage(cliOptions);
+      System.exit(1);
+    }
+    int port = DEFAULT_PORT;
+    if(cmd.hasOption(HELP))
+    {
+      printUsage(cliOptions);
+      return;
+    }
+    else if(cmd.hasOption(PORT))
+    {
+      port = Integer.parseInt(cmd.getOptionValue(PORT));
+    }
+   
+    HelixAdminWebApp app = new HelixAdminWebApp(cmd.getOptionValue(ZKSERVERADDRESS), port);
+    app.start();
+    try
+    {
+      Thread.currentThread().join();
+    }
+    finally
+    {
+      app.stop();
+    }
+  }
+  
+  /**
+   * @param args
+   * @throws Exception
+   */
+  public static void main(String[] args) throws Exception
+  {
+    processCommandLineArgs(args);
+    
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/437eb42e/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ClusterRepresentationUtil.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ClusterRepresentationUtil.java b/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ClusterRepresentationUtil.java
new file mode 100644
index 0000000..e3763b7
--- /dev/null
+++ b/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ClusterRepresentationUtil.java
@@ -0,0 +1,286 @@
+/**
+ * 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 org.apache.helix.webapp.resources;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.apache.helix.HelixDataAccessor;
+import org.apache.helix.HelixProperty;
+import org.apache.helix.PropertyKey;
+import org.apache.helix.PropertyType;
+import org.apache.helix.ZNRecord;
+import org.apache.helix.PropertyKey.Builder;
+import org.apache.helix.manager.zk.ZKHelixDataAccessor;
+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.LiveInstance.LiveInstanceProperty;
+import org.apache.helix.util.HelixUtil;
+import org.codehaus.jackson.JsonGenerationException;
+import org.codehaus.jackson.JsonParseException;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.type.TypeReference;
+import org.restlet.data.Form;
+import org.restlet.data.MediaType;
+
+
+public class ClusterRepresentationUtil
+{
+  private static final ZNRecord EMPTY_ZNRECORD = new ZNRecord("EMPTY_ZNRECORD");
+
+  public static String getClusterPropertyAsString(ZkClient zkClient,
+                                                  String clusterName,
+                                                  PropertyKey propertyKey,
+                                                  // String key,
+                                                  MediaType mediaType)
+
+  throws JsonGenerationException,
+      JsonMappingException,
+      IOException
+  {
+    return getClusterPropertyAsString(zkClient, clusterName, mediaType, propertyKey);
+  }
+
+  public static String getClusterPropertyAsString(ZkClient zkClient,
+                                                  String clusterName,
+                                                  MediaType mediaType,
+                                                  PropertyKey propertyKey) throws JsonGenerationException,
+      JsonMappingException,
+      IOException
+  {
+
+    ZKHelixDataAccessor accessor =
+        new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(zkClient));
+
+    HelixProperty property = accessor.getProperty(propertyKey);
+    ZNRecord record = property == null ? null : property.getRecord();
+    return ZNRecordToJson(record);
+  }
+
+  public static String getInstancePropertyNameListAsString(ZkClient zkClient,
+                                                           String clusterName,
+                                                           String instanceName,
+                                                           PropertyType instanceProperty,
+                                                           String key,
+                                                           MediaType mediaType) throws JsonGenerationException,
+      JsonMappingException,
+      IOException
+  {
+    String path =
+        HelixUtil.getInstancePropertyPath(clusterName, instanceName, instanceProperty)
+            + "/" + key;
+    if (zkClient.exists(path))
+    {
+      List<String> recordNames = zkClient.getChildren(path);
+      return ObjectToJson(recordNames);
+    }
+
+    return ObjectToJson(new ArrayList<String>());
+  }
+
+  public static String getInstancePropertyAsString(ZkClient zkClient,
+                                                   String clusterName,
+                                                   PropertyKey propertyKey,
+                                                   MediaType mediaType) throws JsonGenerationException,
+      JsonMappingException,
+      IOException
+  {
+    ZKHelixDataAccessor accessor =
+        new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(zkClient));
+
+    ZNRecord records = accessor.getProperty(propertyKey).getRecord();
+    return ZNRecordToJson(records);
+  }
+
+  public static String getInstancePropertiesAsString(ZkClient zkClient,
+                                                     String clusterName,
+                                                     PropertyKey propertyKey,
+                                                     MediaType mediaType) throws JsonGenerationException,
+      JsonMappingException,
+      IOException
+  {
+    zkClient.setZkSerializer(new ZNRecordSerializer());
+    ZKHelixDataAccessor accessor =
+        new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(zkClient));
+
+    List<ZNRecord> records =
+        HelixProperty.convertToList(accessor.getChildValues(propertyKey));
+    return ObjectToJson(records);
+  }
+
+  public static String getPropertyAsString(ZkClient zkClient,
+                                           String clusterName,
+                                           PropertyKey propertyKey,
+                                           MediaType mediaType) throws JsonGenerationException,
+      JsonMappingException,
+      IOException
+  {
+    ZKHelixDataAccessor accessor =
+        new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(zkClient));
+
+    ZNRecord record = EMPTY_ZNRECORD;
+    HelixProperty property = accessor.getProperty(propertyKey);
+    if (property != null)
+    {
+      record = property.getRecord();
+    }
+    return ObjectToJson(record);
+  }
+
+  public static String ZNRecordToJson(ZNRecord record) throws JsonGenerationException,
+      JsonMappingException,
+      IOException
+  {
+    return ObjectToJson(record);
+  }
+
+  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();
+  }
+
+  public static HelixDataAccessor getClusterDataAccessor(ZkClient zkClient,
+                                                         String clusterName)
+  {
+    return new ZKHelixDataAccessor(clusterName,
+                                   new ZkBaseDataAccessor<ZNRecord>(zkClient));
+  }
+
+  public static <T extends Object> T JsonToObject(Class<T> clazz, String jsonString) throws JsonParseException,
+      JsonMappingException,
+      IOException
+  {
+    StringReader sr = new StringReader(jsonString);
+    ObjectMapper mapper = new ObjectMapper();
+    return mapper.readValue(sr, clazz);
+
+  }
+
+  public static Map<String, String> JsonToMap(String jsonString) throws JsonParseException,
+      JsonMappingException,
+      IOException
+  {
+    StringReader sr = new StringReader(jsonString);
+    ObjectMapper mapper = new ObjectMapper();
+
+    TypeReference<TreeMap<String, String>> typeRef =
+        new TypeReference<TreeMap<String, String>>()
+        {
+        };
+
+    return mapper.readValue(sr, typeRef);
+  }
+
+  public static Map<String, String> getFormJsonParameters(Form form) throws JsonParseException,
+      JsonMappingException,
+      IOException
+  {
+    String jsonPayload = form.getFirstValue(JsonParameters.JSON_PARAMETERS, true);
+    return ClusterRepresentationUtil.JsonToMap(jsonPayload);
+  }
+
+  public static Map<String, String> getFormJsonParameters(Form form, String key) throws JsonParseException,
+      JsonMappingException,
+      IOException
+  {
+    String jsonPayload = form.getFirstValue(key, true);
+    return ClusterRepresentationUtil.JsonToMap(jsonPayload);
+  }
+
+  public static String getFormJsonParameterString(Form form, String key) throws JsonParseException,
+      JsonMappingException,
+      IOException
+  {
+    return form.getFirstValue(key, true);
+  }
+
+  public static <T extends Object> T getFormJsonParameters(Class<T> clazz,
+                                                           Form form,
+                                                           String key) throws JsonParseException,
+      JsonMappingException,
+      IOException
+  {
+    return JsonToObject(clazz, form.getFirstValue(key, true));
+  }
+
+  public static String getErrorAsJsonStringFromException(Exception e)
+  {
+    StringWriter sw = new StringWriter();
+    PrintWriter pw = new PrintWriter(sw);
+    e.printStackTrace(pw);
+
+    String error = e.getMessage() + '\n' + sw.toString();
+    Map<String, String> result = new TreeMap<String, String>();
+    result.put("ERROR", error);
+    try
+    {
+      return ObjectToJson(result);
+    }
+    catch (Exception e1)
+    {
+      StringWriter sw1 = new StringWriter();
+      PrintWriter pw1 = new PrintWriter(sw1);
+      e.printStackTrace(pw1);
+      return "{\"ERROR\": \"" + sw1.toString() + "\"}";
+    }
+  }
+
+  public static String getInstanceSessionId(ZkClient zkClient,
+                                            String clusterName,
+                                            String instanceName)
+  {
+    ZKHelixDataAccessor accessor =
+        new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(zkClient));
+    Builder keyBuilder = accessor.keyBuilder();
+
+    ZNRecord liveInstance =
+        accessor.getProperty(keyBuilder.liveInstance(instanceName)).getRecord();
+
+    return liveInstance.getSimpleField(LiveInstanceProperty.SESSION_ID.toString());
+  }
+
+  public static List<String> getInstancePropertyList(ZkClient zkClient,
+                                                     String clusterName,
+                                                     String instanceName,
+                                                     PropertyType property,
+                                                     String key)
+  {
+    String propertyPath =
+        HelixUtil.getInstancePropertyPath(clusterName, instanceName, property) + "/"
+            + key;
+
+    return zkClient.getChildren(propertyPath);
+
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/437eb42e/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
new file mode 100644
index 0000000..4e7b745
--- /dev/null
+++ b/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ClusterResource.java
@@ -0,0 +1,210 @@
+/**
+ * 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 org.apache.helix.webapp.resources;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.helix.HelixDataAccessor;
+import org.apache.helix.HelixException;
+import org.apache.helix.ZNRecord;
+import org.apache.helix.PropertyKey.Builder;
+import org.apache.helix.manager.zk.ZkClient;
+import org.apache.helix.model.LiveInstance;
+import org.apache.helix.tools.ClusterSetup;
+import org.apache.helix.webapp.RestAdminApplication;
+import org.codehaus.jackson.JsonGenerationException;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.restlet.Context;
+import org.restlet.data.MediaType;
+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.StringRepresentation;
+import org.restlet.resource.Variant;
+
+
+public class ClusterResource extends Resource
+{
+  public ClusterResource(Context context, Request request, Response response)
+  {
+    super(context, request, response);
+    getVariants().add(new Variant(MediaType.TEXT_PLAIN));
+    getVariants().add(new Variant(MediaType.APPLICATION_JSON));
+  }
+
+  @Override
+  public boolean allowGet()
+  {
+    return true;
+  }
+
+  @Override
+  public boolean allowPost()
+  {
+    return true;
+  }
+
+  @Override
+  public boolean allowPut()
+  {
+    return false;
+  }
+
+  @Override
+  public boolean allowDelete()
+  {
+    return true;
+  }
+
+  @Override
+  public Representation represent(Variant variant)
+  {
+    StringRepresentation presentation = null;
+    try
+    {
+      String clusterName = (String) getRequest().getAttributes().get("clusterName");
+      presentation = getClusterRepresentation(clusterName);
+    }
+
+    catch (Exception e)
+    {
+      String error = ClusterRepresentationUtil.getErrorAsJsonStringFromException(e);
+      presentation = new StringRepresentation(error, MediaType.APPLICATION_JSON);
+
+      e.printStackTrace();
+    }
+    return presentation;
+  }
+
+  StringRepresentation getClusterRepresentation(String clusterName) throws JsonGenerationException,
+      JsonMappingException,
+      IOException
+  {
+    ZkClient zkClient =
+        (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
+    ClusterSetup setupTool = new ClusterSetup(zkClient);
+    List<String> instances =
+        setupTool.getClusterManagementTool().getInstancesInCluster(clusterName);
+
+    ZNRecord clusterSummayRecord = new ZNRecord("Cluster Summary");
+    clusterSummayRecord.setListField("participants", instances);
+
+    List<String> resources =
+        setupTool.getClusterManagementTool().getResourcesInCluster(clusterName);
+    clusterSummayRecord.setListField("resources", resources);
+
+    List<String> models =
+        setupTool.getClusterManagementTool().getStateModelDefs(clusterName);
+    clusterSummayRecord.setListField("stateModelDefs", models);
+
+    HelixDataAccessor accessor =
+        ClusterRepresentationUtil.getClusterDataAccessor(zkClient, clusterName);
+    Builder keyBuilder = accessor.keyBuilder();
+
+    LiveInstance leader = accessor.getProperty(keyBuilder.controllerLeader());
+    if (leader != null)
+    {
+      clusterSummayRecord.setSimpleField("LEADER", leader.getInstanceName());
+    }
+    else
+    {
+      clusterSummayRecord.setSimpleField("LEADER", "");
+    }
+    StringRepresentation representation =
+        new StringRepresentation(ClusterRepresentationUtil.ZNRecordToJson(clusterSummayRecord),
+                                 MediaType.APPLICATION_JSON);
+
+    return representation;
+  }
+
+  @Override
+  public void acceptRepresentation(Representation entity)
+  {
+    try
+    {
+      String clusterName = (String) getRequest().getAttributes().get("clusterName");
+      ZkClient zkClient =
+          (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
+      ClusterSetup setupTool = new ClusterSetup(zkClient);
+
+      JsonParameters jsonParameters = new JsonParameters(entity);
+      String command = jsonParameters.getCommand();
+
+      if (command == null)
+      {
+        throw new HelixException("Could NOT find 'command' in parameterMap: " + jsonParameters._parameterMap);
+      }
+      else if (command.equalsIgnoreCase(ClusterSetup.activateCluster)
+          || JsonParameters.CLUSTERSETUP_COMMAND_ALIASES.get(ClusterSetup.activateCluster)
+                                                        .contains(command))
+      {
+        jsonParameters.verifyCommand(ClusterSetup.activateCluster);
+
+        boolean enabled = true;
+        if (jsonParameters.getParameter(JsonParameters.ENABLED) != null)
+        {
+          enabled =
+              Boolean.parseBoolean(jsonParameters.getParameter(JsonParameters.ENABLED));
+        }
+
+        String grandCluster = jsonParameters.getParameter(JsonParameters.GRAND_CLUSTER);
+
+        setupTool.activateCluster(clusterName, grandCluster, enabled);
+      }
+      else if (command.equalsIgnoreCase(ClusterSetup.expandCluster))
+      {
+        setupTool.expandCluster(clusterName);
+      }
+      else
+      {
+        throw new HelixException("Unsupported command: " + command
+            + ". Should be one of [" + ClusterSetup.activateCluster + ", "
+            + ClusterSetup.expandCluster + "]");
+      }
+      getResponse().setEntity(getClusterRepresentation(clusterName));
+      getResponse().setStatus(Status.SUCCESS_OK);
+    }
+    catch (Exception e)
+    {
+      getResponse().setEntity(ClusterRepresentationUtil.getErrorAsJsonStringFromException(e),
+                              MediaType.APPLICATION_JSON);
+      getResponse().setStatus(Status.SUCCESS_OK);
+    }
+  }
+
+  @Override
+  public void removeRepresentations()
+  {
+    try
+    {
+      String clusterName = (String) getRequest().getAttributes().get("clusterName");
+      ZkClient zkClient =
+          (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
+      ClusterSetup setupTool = new ClusterSetup(zkClient);
+      setupTool.deleteCluster(clusterName);
+      getResponse().setStatus(Status.SUCCESS_OK);
+    }
+    catch (Exception e)
+    {
+      getResponse().setEntity(ClusterRepresentationUtil.getErrorAsJsonStringFromException(e),
+                              MediaType.APPLICATION_JSON);
+      getResponse().setStatus(Status.SUCCESS_OK);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/437eb42e/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ClustersResource.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ClustersResource.java b/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ClustersResource.java
new file mode 100644
index 0000000..2980831
--- /dev/null
+++ b/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ClustersResource.java
@@ -0,0 +1,152 @@
+/**
+ * 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 org.apache.helix.webapp.resources;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.helix.HelixException;
+import org.apache.helix.ZNRecord;
+import org.apache.helix.manager.zk.ZkClient;
+import org.apache.helix.tools.ClusterSetup;
+import org.apache.helix.webapp.RestAdminApplication;
+import org.apache.log4j.Logger;
+import org.codehaus.jackson.JsonGenerationException;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.restlet.Context;
+import org.restlet.data.MediaType;
+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.StringRepresentation;
+import org.restlet.resource.Variant;
+
+
+public class ClustersResource extends Resource
+{
+  private final static Logger LOG = Logger.getLogger(ClustersResource.class);
+
+  public ClustersResource(Context context, Request request, Response response)
+  {
+    super(context, request, response);
+    getVariants().add(new Variant(MediaType.TEXT_PLAIN));
+    getVariants().add(new Variant(MediaType.APPLICATION_JSON));
+    // handle(request,response);
+  }
+
+  @Override
+  public boolean allowPost()
+  {
+    return true;
+  }
+
+  @Override
+  public boolean allowPut()
+  {
+    return false;
+  }
+
+  @Override
+  public boolean allowDelete()
+  {
+    return true;
+  }
+
+  @Override
+  public Representation represent(Variant variant)
+  {
+    StringRepresentation presentation = null;
+    try
+    {
+      presentation = getClustersRepresentation();
+    }
+    catch (Exception e)
+    {
+      LOG.error("", e);
+      String error = ClusterRepresentationUtil.getErrorAsJsonStringFromException(e);
+      presentation = new StringRepresentation(error, MediaType.APPLICATION_JSON);
+
+      e.printStackTrace();
+    }
+    return presentation;
+  }
+
+  StringRepresentation getClustersRepresentation() throws JsonGenerationException,
+      JsonMappingException,
+      IOException
+  {
+    ZkClient zkClient =
+        (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
+    ClusterSetup setupTool = new ClusterSetup(zkClient);
+    List<String> clusters = setupTool.getClusterManagementTool().getClusters();
+
+    ZNRecord clustersRecord = new ZNRecord("Clusters Summary");
+    clustersRecord.setListField("clusters", clusters);
+    StringRepresentation representation =
+        new StringRepresentation(ClusterRepresentationUtil.ZNRecordToJson(clustersRecord),
+                                 MediaType.APPLICATION_JSON);
+
+    return representation;
+  }
+
+  @Override
+  public void acceptRepresentation(Representation entity)
+  {
+    try
+    {
+      JsonParameters jsonParameters = new JsonParameters(entity);
+      String command = jsonParameters.getCommand();
+
+      if (command == null)
+      {
+        throw new HelixException("Could NOT find 'command' in parameterMap: " + jsonParameters._parameterMap);
+      }
+      else if (command.equalsIgnoreCase(ClusterSetup.addCluster))
+      {
+        jsonParameters.verifyCommand(ClusterSetup.addCluster);
+
+        ZkClient zkClient =
+            (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
+        ClusterSetup setupTool = new ClusterSetup(zkClient);
+        setupTool.addCluster(jsonParameters.getParameter(JsonParameters.CLUSTER_NAME),
+                             false);
+      }
+      else
+      {
+        throw new HelixException("Unsupported command: " + command
+            + ". Should be one of [" + ClusterSetup.addCluster + "]");
+      }
+
+      getResponse().setEntity(getClustersRepresentation());
+      getResponse().setStatus(Status.SUCCESS_OK);
+    }
+    catch (Exception e)
+    {
+      getResponse().setEntity(ClusterRepresentationUtil.getErrorAsJsonStringFromException(e),
+                              MediaType.APPLICATION_JSON);
+      getResponse().setStatus(Status.SUCCESS_OK);
+      LOG.error("Error in posting " + entity, e);
+    }
+  }
+
+  @Override
+  public void removeRepresentations()
+  {
+
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/437eb42e/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ConfigResource.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ConfigResource.java b/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ConfigResource.java
new file mode 100644
index 0000000..222f6e6
--- /dev/null
+++ b/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ConfigResource.java
@@ -0,0 +1,311 @@
+/**
+ * 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 org.apache.helix.webapp.resources;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.helix.ConfigScope;
+import org.apache.helix.ConfigScopeBuilder;
+import org.apache.helix.HelixAdmin;
+import org.apache.helix.HelixException;
+import org.apache.helix.ZNRecord;
+import org.apache.helix.ConfigScope.ConfigScopeProperty;
+import org.apache.helix.manager.zk.ZkClient;
+import org.apache.helix.tools.ClusterSetup;
+import org.apache.helix.webapp.RestAdminApplication;
+import org.apache.log4j.Logger;
+import org.restlet.Context;
+import org.restlet.data.MediaType;
+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.StringRepresentation;
+import org.restlet.resource.Variant;
+
+
+public class ConfigResource extends Resource
+{
+  private final static Logger LOG = Logger.getLogger(ConfigResource.class);
+
+  public ConfigResource(Context context, Request request, Response response)
+  {
+    super(context, request, response);
+    getVariants().add(new Variant(MediaType.TEXT_PLAIN));
+    getVariants().add(new Variant(MediaType.APPLICATION_JSON));
+    setModifiable(true);
+  }
+
+  String getValue(String key)
+  {
+    return (String) getRequest().getAttributes().get(key);
+  }
+
+  StringRepresentation getConfigScopes() throws Exception
+  {
+    StringRepresentation representation = null;
+    ZNRecord record = new ZNRecord("Config");
+
+    List<String> scopeList =
+        Arrays.asList(ConfigScopeProperty.CLUSTER.toString(),
+                      ConfigScopeProperty.RESOURCE.toString(),
+                      ConfigScopeProperty.PARTICIPANT.toString(),
+                      ConfigScopeProperty.PARTITION.toString());
+    record.setListField("scopes", scopeList);
+
+    representation =
+        new StringRepresentation(ClusterRepresentationUtil.ZNRecordToJson(record),
+                                 MediaType.APPLICATION_JSON);
+
+    return representation;
+  }
+
+  StringRepresentation getConfigKeys(ConfigScopeProperty scopeProperty, String... keys) throws Exception
+  {
+    StringRepresentation representation = null;
+    String clusterName = getValue("clusterName");
+
+    ZkClient zkClient =
+        (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
+    ClusterSetup setupTool = new ClusterSetup(zkClient);
+    HelixAdmin admin = setupTool.getClusterManagementTool();
+    ZNRecord record = new ZNRecord(scopeProperty + " Config");
+
+    List<String> configKeys = admin.getConfigKeys(scopeProperty, clusterName, keys);
+    record.setListField(scopeProperty.toString(), configKeys);
+
+    representation =
+        new StringRepresentation(ClusterRepresentationUtil.ZNRecordToJson(record),
+                                 MediaType.APPLICATION_JSON);
+
+    return representation;
+  }
+
+  StringRepresentation getConfigs(ConfigScope scope,
+                                  ConfigScopeProperty scopeProperty,
+                                  String... keys) throws Exception
+  {
+    StringRepresentation representation = null;
+    String clusterName = getValue("clusterName");
+
+    ZkClient zkClient =
+        (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
+    ClusterSetup setupTool = new ClusterSetup(zkClient);
+    HelixAdmin admin = setupTool.getClusterManagementTool();
+    ZNRecord record = new ZNRecord(scopeProperty + " Config");
+
+    List<String> configKeys = admin.getConfigKeys(scopeProperty, clusterName, keys);
+    Map<String, String> configs = admin.getConfig(scope, new HashSet<String>(configKeys));
+    record.setSimpleFields(configs);
+
+    representation =
+        new StringRepresentation(ClusterRepresentationUtil.ZNRecordToJson(record),
+                                 MediaType.APPLICATION_JSON);
+
+    return representation;
+  }
+
+  @Override
+  public Representation represent(Variant variant)
+  {
+    StringRepresentation representation = null;
+
+    String clusterName = getValue("clusterName");
+    String scopeStr = getValue("scope");
+    try
+    {
+      if (scopeStr == null)
+      {
+        // path is "/clusters/{clusterName}/configs"
+        return getConfigScopes();
+      }
+
+      scopeStr = scopeStr.toUpperCase();
+
+      ConfigScopeProperty scopeProperty = ConfigScopeProperty.valueOf(scopeStr);
+      switch (scopeProperty)
+      {
+      case CLUSTER:
+      case PARTICIPANT:
+      case RESOURCE:
+        String scopeKey1 = getValue("scopeKey1");
+        if (scopeKey1 == null)
+        {
+          // path is "/clusters/{clusterName}/configs/cluster|participant|resource"
+          representation = getConfigKeys(scopeProperty);
+        }
+        else
+        {
+          // path is "/clusters/{clusterName}/configs/cluster|particicpant|resource/
+          // {clusterName}|{participantName}|{resourceName}"
+          ConfigScope scope;
+          if (scopeProperty == ConfigScopeProperty.CLUSTER)
+          {
+            scope = new ConfigScopeBuilder().build(scopeProperty, clusterName);
+          }
+          else
+          {
+            scope = new ConfigScopeBuilder().build(scopeProperty, clusterName, scopeKey1);
+          }
+          representation = getConfigs(scope, scopeProperty, scopeKey1);
+        }
+        break;
+      case PARTITION:
+        scopeKey1 = getValue("scopeKey1");
+        String scopeKey2 = getValue("scopeKey2");
+        if (scopeKey1 == null)
+        {
+          // path is "/clusters/{clusterName}/configs/partition"
+          throw new HelixException("Missing resourceName");
+        }
+        else if (scopeKey2 == null)
+        {
+          // path is "/clusters/{clusterName}/configs/partition/resourceName"
+          representation = getConfigKeys(scopeProperty, scopeKey1);
+        }
+        else
+        {
+          // path is
+          // "/clusters/{clusterName}/configs/partition/resourceName/partitionName"
+          ConfigScope scope =
+              new ConfigScopeBuilder().build(scopeProperty,
+                                             clusterName,
+                                             scopeKey1,
+                                             scopeKey2);
+          representation = getConfigs(scope, scopeProperty, scopeKey1, scopeKey2);
+        }
+        break;
+      default:
+        break;
+      }
+    }
+    catch (Exception e)
+    {
+      String error = ClusterRepresentationUtil.getErrorAsJsonStringFromException(e);
+      representation = new StringRepresentation(error, MediaType.APPLICATION_JSON);
+      LOG.error("", e);
+    }
+
+    return representation;
+  }
+
+  /**
+   * set or remove configs depends on "command" field of jsonParameters in POST body
+   * 
+   * @param entity
+   * @param scopeStr
+   * @throws Exception
+   */
+  void setConfigs(Representation entity, String scopeStr) throws Exception
+  {
+    JsonParameters jsonParameters = new JsonParameters(entity);
+    String command = jsonParameters.getCommand();
+
+    ZkClient zkClient =
+        (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
+    ClusterSetup setupTool = new ClusterSetup(zkClient);
+    if (command.equalsIgnoreCase(ClusterSetup.setConfig))
+    {
+      jsonParameters.verifyCommand(ClusterSetup.setConfig);
+      String propertiesStr = jsonParameters.getParameter(JsonParameters.CONFIGS);
+
+      setupTool.setConfig(scopeStr, propertiesStr);
+    }
+    else if (command.equalsIgnoreCase(ClusterSetup.removeConfig))
+    {
+      jsonParameters.verifyCommand(ClusterSetup.removeConfig);
+      String propertiesStr = jsonParameters.getParameter(JsonParameters.CONFIGS);
+
+      setupTool.removeConfig(scopeStr, propertiesStr);
+    }
+    else
+    {
+      throw new HelixException("Unsupported command: " + command + ". Should be one of ["
+          + ClusterSetup.setConfig + ", " + ClusterSetup.removeConfig + "]");
+
+    }
+
+    getResponse().setEntity(represent());
+    getResponse().setStatus(Status.SUCCESS_OK);
+  }
+
+  @Override
+  public void acceptRepresentation(Representation entity)
+  {
+    String clusterName = getValue("clusterName");
+
+    String scopeStr = getValue("scope").toUpperCase();
+    try
+    {
+      ConfigScopeProperty scopeProperty = ConfigScopeProperty.valueOf(scopeStr);
+
+      switch (scopeProperty)
+      {
+      case CLUSTER:
+        String scopeConfigStr =
+            ConfigScopeProperty.CLUSTER.toString() + "=" + clusterName;
+        setConfigs(entity, scopeConfigStr);
+        break;
+      case PARTICIPANT:
+      case RESOURCE:
+        String scopeKey1 = getValue("scopeKey1");
+
+        if (scopeKey1 == null)
+        {
+          throw new HelixException("Missing resourceName|participantName");
+        }
+        else
+        {
+          scopeConfigStr =
+              ConfigScopeProperty.CLUSTER.toString() + "=" + clusterName + ","
+                  + scopeProperty.toString() + "=" + scopeKey1;
+
+          setConfigs(entity, scopeConfigStr);
+        }
+        break;
+      case PARTITION:
+        scopeKey1 = getValue("scopeKey1");
+        String scopeKey2 = getValue("scopeKey2");
+        if (scopeKey1 == null || scopeKey2 == null)
+        {
+          throw new HelixException("Missing resourceName|partitionName");
+        }
+        else
+        {
+          scopeConfigStr =
+              ConfigScopeProperty.CLUSTER.toString() + "=" + clusterName + ","
+                  + ConfigScopeProperty.RESOURCE.toString() + "=" + scopeKey1 + ","
+                  + scopeProperty.toString() + "=" + scopeKey2;
+          setConfigs(entity, scopeConfigStr);
+        }
+        break;
+      default:
+        break;
+      }
+    }
+    catch (Exception e)
+    {
+      LOG.error("Error in posting " + entity, e);
+      getResponse().setEntity(ClusterRepresentationUtil.getErrorAsJsonStringFromException(e),
+                              MediaType.APPLICATION_JSON);
+      getResponse().setStatus(Status.SUCCESS_OK);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/437eb42e/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
new file mode 100644
index 0000000..1be8829
--- /dev/null
+++ b/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ControllerResource.java
@@ -0,0 +1,157 @@
+package org.apache.helix.webapp.resources;
+
+import java.io.IOException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.apache.helix.HelixException;
+import org.apache.helix.HelixProperty;
+import org.apache.helix.PropertyKey;
+import org.apache.helix.PropertyType;
+import org.apache.helix.ZNRecord;
+import org.apache.helix.PropertyKey.Builder;
+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.LiveInstance;
+import org.apache.helix.model.PauseSignal;
+import org.apache.helix.tools.ClusterSetup;
+import org.apache.helix.util.StatusUpdateUtil.Level;
+import org.apache.helix.webapp.RestAdminApplication;
+import org.codehaus.jackson.JsonGenerationException;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.restlet.data.MediaType;
+import org.restlet.data.Status;
+import org.restlet.resource.Representation;
+import org.restlet.resource.Resource;
+import org.restlet.resource.StringRepresentation;
+import org.restlet.resource.Variant;
+
+
+public class ControllerResource extends Resource
+{
+  @Override
+  public boolean allowGet()
+  {
+    return true;
+  }
+
+  @Override
+  public boolean allowPost()
+  {
+    return true;
+  }
+
+  @Override
+  public boolean allowPut()
+  {
+    return false;
+  }
+
+  @Override
+  public boolean allowDelete()
+  {
+    return false;
+  }
+
+  StringRepresentation getControllerRepresentation(String clusterName) throws JsonGenerationException,
+      JsonMappingException,
+      IOException
+  {
+    Builder keyBuilder = new PropertyKey.Builder(clusterName);
+    ZkClient zkClient =
+        (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
+
+    ZKHelixDataAccessor accessor =
+        new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(zkClient));
+
+
+    ZNRecord record = null;
+    LiveInstance leader = accessor.getProperty(keyBuilder.controllerLeader());
+    if (leader != null)
+    {
+      record = leader.getRecord();
+    }
+    else
+    {
+      record = new ZNRecord("");
+      DateFormat formatter = new SimpleDateFormat("yyyyMMdd-HHmmss.SSSSSS");
+      String time = formatter.format(new Date());
+      Map<String, String> contentMap = new TreeMap<String, String>();
+      contentMap.put("AdditionalInfo", "No leader exists");
+      record.setMapField(Level.HELIX_INFO + "-" + time, contentMap);
+    }
+    
+    boolean paused = (accessor.getProperty(keyBuilder.pause()) == null? false : true);
+    record.setSimpleField(PropertyType.PAUSE.toString(), "" + paused);
+
+    String retVal = ClusterRepresentationUtil.ZNRecordToJson(record);
+    StringRepresentation representation =
+        new StringRepresentation(retVal, MediaType.APPLICATION_JSON);
+
+    return representation;
+  }
+
+  @Override
+  public Representation represent(Variant variant)
+  {
+    StringRepresentation presentation = null;
+    try
+    {
+      String clusterName = (String) getRequest().getAttributes().get("clusterName");
+      presentation = getControllerRepresentation(clusterName);
+    }
+    catch (Exception e)
+    {
+      String error = ClusterRepresentationUtil.getErrorAsJsonStringFromException(e);
+      presentation = new StringRepresentation(error, MediaType.APPLICATION_JSON);
+      e.printStackTrace();
+    }
+    return presentation;
+  }
+
+  @Override
+  public void acceptRepresentation(Representation entity)
+  {
+    try
+    {
+      String clusterName = (String) getRequest().getAttributes().get("clusterName");
+      ZkClient zkClient =
+          (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
+      ClusterSetup setupTool = new ClusterSetup(zkClient);
+
+      JsonParameters jsonParameters = new JsonParameters(entity);
+      String command = jsonParameters.getCommand();
+
+      if (command == null)
+      {
+        throw new HelixException("Could NOT find 'command' in parameterMap: " + jsonParameters._parameterMap);
+      }
+      else if (command.equalsIgnoreCase(ClusterSetup.enableCluster))
+      {
+        boolean enabled =
+            Boolean.parseBoolean(jsonParameters.getParameter(JsonParameters.ENABLED));
+
+        setupTool.getClusterManagementTool().enableCluster(clusterName, enabled);
+      }
+      else
+      {
+        throw new HelixException("Unsupported command: " + command
+                                 + ". Should be one of [" + ClusterSetup.enableCluster + "]");
+      }
+      
+      getResponse().setEntity(getControllerRepresentation(clusterName));
+      getResponse().setStatus(Status.SUCCESS_OK);
+
+    }
+    catch (Exception e)
+    {
+      getResponse().setEntity(ClusterRepresentationUtil.getErrorAsJsonStringFromException(e),
+                              MediaType.APPLICATION_JSON);
+      getResponse().setStatus(Status.SUCCESS_OK);
+    }
+  }
+}