Return-Path: X-Original-To: apmail-helix-commits-archive@minotaur.apache.org Delivered-To: apmail-helix-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id AD289D6F7 for ; Wed, 24 Oct 2012 22:29:03 +0000 (UTC) Received: (qmail 22203 invoked by uid 500); 24 Oct 2012 22:29:03 -0000 Delivered-To: apmail-helix-commits-archive@helix.apache.org Received: (qmail 22184 invoked by uid 500); 24 Oct 2012 22:29:03 -0000 Mailing-List: contact commits-help@helix.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@helix.incubator.apache.org Delivered-To: mailing list commits@helix.incubator.apache.org Received: (qmail 22176 invoked by uid 99); 24 Oct 2012 22:29:03 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 24 Oct 2012 22:29:03 +0000 X-ASF-Spam-Status: No, hits=-2000.7 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Wed, 24 Oct 2012 22:27:04 +0000 Received: (qmail 13507 invoked by uid 99); 24 Oct 2012 22:26:40 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 24 Oct 2012 22:26:40 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id AFD824F16B; Wed, 24 Oct 2012 22:26:40 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: kishoreg@apache.org To: commits@helix.incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [3/47] git commit: Refactoring from com.linkedin.helix to org.apache.helix Message-Id: <20121024222640.AFD824F16B@tyr.zones.apache.org> Date: Wed, 24 Oct 2012 22:26:40 +0000 (UTC) X-Virus-Checked: Checked by ClamAV on apache.org Refactoring from com.linkedin.helix to org.apache.helix Project: http://git-wip-us.apache.org/repos/asf/incubator-helix/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-helix/commit/3cb7a1c9 Tree: http://git-wip-us.apache.org/repos/asf/incubator-helix/tree/3cb7a1c9 Diff: http://git-wip-us.apache.org/repos/asf/incubator-helix/diff/3cb7a1c9 Branch: refs/heads/master Commit: 3cb7a1c99422960230891bbe709bef5d93580726 Parents: c981fd7 Author: Kishore Gopalakrishna Authored: Wed Oct 24 15:24:51 2012 -0700 Committer: Kishore Gopalakrishna Committed: Wed Oct 24 15:24:51 2012 -0700 ---------------------------------------------------------------------- build | 2 +- helix-admin-webapp/helix-admin-webapp-0.5.28.ivy | 4 +- helix-admin-webapp/pom.xml | 2 +- .../linkedin/helix/webapp/HelixAdminWebApp.java | 65 - .../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 - helix-admin-webapp/src/test/conf/testng.xml | 4 +- .../com/linkedin/helix/tools/AdminTestBase.java | 68 - .../com/linkedin/helix/tools/AdminTestHelper.java | 63 - .../helix/tools/TestHelixAdminScenariosRest.java | 739 - .../linkedin/helix/tools/TestResetInstance.java | 117 - .../helix/tools/TestResetPartitionState.java | 211 - .../linkedin/helix/tools/TestResetResource.java | 118 - .../helix/webapp/TestClusterManagementWebapp.java | 649 - helix-core/helix-core-0.5.28.ivy | 2 +- helix-core/pom.xml | 18 +- .../main/java/com/linkedin/helix/AccessOption.java | 52 - .../java/com/linkedin/helix/BaseDataAccessor.java | 192 - .../linkedin/helix/ClusterMessagingService.java | 116 - .../main/java/com/linkedin/helix/ClusterView.java | 168 - .../java/com/linkedin/helix/ConfigAccessor.java | 269 - .../com/linkedin/helix/ConfigChangeListener.java | 38 - .../main/java/com/linkedin/helix/ConfigScope.java | 145 - .../com/linkedin/helix/ConfigScopeBuilder.java | 133 - .../linkedin/helix/ControllerChangeListener.java | 27 - .../src/main/java/com/linkedin/helix/Criteria.java | 151 - .../linkedin/helix/CurrentStateChangeListener.java | 36 - .../main/java/com/linkedin/helix/DataAccessor.java | 97 - .../linkedin/helix/ExternalViewChangeListener.java | 34 - .../main/java/com/linkedin/helix/GroupCommit.java | 168 - .../linkedin/helix/HealthStateChangeListener.java | 36 - .../main/java/com/linkedin/helix/HelixAdmin.java | 386 - .../java/com/linkedin/helix/HelixConstants.java | 47 - .../java/com/linkedin/helix/HelixDataAccessor.java | 161 - .../java/com/linkedin/helix/HelixException.java | 31 - .../main/java/com/linkedin/helix/HelixManager.java | 296 - .../com/linkedin/helix/HelixManagerFactory.java | 104 - .../java/com/linkedin/helix/HelixProperty.java | 224 - .../java/com/linkedin/helix/HelixTimerTask.java | 33 - .../linkedin/helix/IdealStateChangeListener.java | 33 - .../main/java/com/linkedin/helix/InstanceType.java | 34 - .../linkedin/helix/LiveInstanceChangeListener.java | 34 - .../java/com/linkedin/helix/MessageListener.java | 35 - .../com/linkedin/helix/NotificationContext.java | 103 - .../com/linkedin/helix/PreConnectCallback.java | 12 - .../main/java/com/linkedin/helix/PropertyKey.java | 553 - .../com/linkedin/helix/PropertyPathConfig.java | 214 - .../main/java/com/linkedin/helix/PropertyType.java | 193 - .../src/main/java/com/linkedin/helix/ZNRecord.java | 364 - .../java/com/linkedin/helix/ZNRecordAssembler.java | 30 - .../com/linkedin/helix/ZNRecordBucketizer.java | 116 - .../java/com/linkedin/helix/ZNRecordDelta.java | 49 - .../java/com/linkedin/helix/ZNRecordUpdater.java | 24 - .../helix/alerts/AccumulateAggregator.java | 70 - .../java/com/linkedin/helix/alerts/Aggregator.java | 38 - .../main/java/com/linkedin/helix/alerts/Alert.java | 53 - .../com/linkedin/helix/alerts/AlertComparator.java | 27 - .../com/linkedin/helix/alerts/AlertParser.java | 147 - .../com/linkedin/helix/alerts/AlertProcessor.java | 355 - .../linkedin/helix/alerts/AlertValueAndStatus.java | 39 - .../com/linkedin/helix/alerts/AlertsHolder.java | 286 - .../com/linkedin/helix/alerts/DecayAggregator.java | 78 - .../com/linkedin/helix/alerts/DivideOperator.java | 36 - .../com/linkedin/helix/alerts/ExpandOperator.java | 35 - .../helix/alerts/ExpressionOperatorType.java | 42 - .../linkedin/helix/alerts/ExpressionParser.java | 579 - .../helix/alerts/GreaterAlertComparator.java | 41 - .../linkedin/helix/alerts/MultiplyOperator.java | 59 - .../java/com/linkedin/helix/alerts/Operator.java | 115 - .../main/java/com/linkedin/helix/alerts/Stat.java | 44 - .../com/linkedin/helix/alerts/StatsHolder.java | 358 - .../com/linkedin/helix/alerts/SumEachOperator.java | 47 - .../com/linkedin/helix/alerts/SumOperator.java | 56 - .../main/java/com/linkedin/helix/alerts/Tuple.java | 94 - .../linkedin/helix/alerts/WindowAggregator.java | 90 - .../com/linkedin/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 - .../linkedin/helix/controller/package-info.java | 4 - .../controller/pipeline/AbstractBaseStage.java | 78 - .../helix/controller/pipeline/Pipeline.java | 65 - .../controller/pipeline/PipelineRegistry.java | 54 - .../linkedin/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 | 609 - .../controller/stages/BestPossibleStateOutput.java | 72 - .../helix/controller/stages/ClusterDataCache.java | 266 - .../helix/controller/stages/ClusterEvent.java | 73 - .../controller/stages/CompatibilityCheckStage.java | 123 - .../stages/CurrentStateComputationStage.java | 167 - .../controller/stages/CurrentStateOutput.java | 204 - .../stages/ExternalViewComputeStage.java | 122 - .../helix/controller/stages/HealthDataCache.java | 130 - .../controller/stages/MessageGenerationOutput.java | 73 - .../controller/stages/MessageGenerationPhase.java | 184 - .../controller/stages/MessageSelectionStage.java | 337 - .../stages/MessageSelectionStageOutput.java | 65 - .../controller/stages/MessageThrottleStage.java | 229 - .../stages/MessageThrottleStageOutput.java | 56 - .../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 - .../linkedin/helix/examples/BootstrapHandler.java | 111 - .../linkedin/helix/examples/BootstrapProcess.java | 405 - .../linkedin/helix/examples/DummyParticipant.java | 123 - .../com/linkedin/helix/examples/ExampleHelper.java | 56 - .../linkedin/helix/examples/ExampleProcess.java | 269 - .../linkedin/helix/examples/IdealStateExample.java | 163 - .../examples/LeaderStandbyStateModelFactory.java | 67 - .../examples/MasterSlaveStateModelFactory.java | 99 - .../examples/OnlineOfflineStateModelFactory.java | 74 - .../com/linkedin/helix/examples/package-info.java | 5 - .../healthcheck/AccumulateAggregationType.java | 41 - .../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/com/linkedin/helix/healthcheck/Stat.java | 146 - .../healthcheck/StatHealthReportProvider.java | 175 - .../helix/healthcheck/WindowAggregationType.java | 76 - .../linkedin/helix/healthcheck/package-info.java | 5 - .../helix/josql/ClusterJosqlQueryProcessor.java | 304 - .../helix/josql/DataAccessorBasedTupleReader.java | 171 - .../helix/josql/JsqlQueryListProcessor.java | 57 - .../helix/josql/ZNRecordJosqlFunctionHandler.java | 90 - .../helix/josql/ZNRecordQueryProcessor.java | 1401 -- .../java/com/linkedin/helix/josql/ZNRecordRow.java | 194 - .../com/linkedin/helix/josql/package-info.java | 5 - .../manager/file/DynamicFileHelixManager.java | 460 - .../helix/manager/file/FileCallbackHandler.java | 293 - .../helix/manager/file/FileDataAccessor.java | 319 - .../helix/manager/file/FileHelixAdmin.java | 486 - .../helix/manager/file/FileHelixDataAccessor.java | 351 - .../helix/manager/file/StaticFileHelixManager.java | 569 - .../linkedin/helix/manager/file/package-info.java | 5 - .../helix/manager/zk/BasicZkSerializer.java | 43 - .../helix/manager/zk/ByteArraySerializer.java | 20 - .../java/com/linkedin/helix/manager/zk/Cache.java | 146 - .../linkedin/helix/manager/zk/CallbackHandler.java | 399 - .../helix/manager/zk/ChainedPathZkSerializer.java | 131 - .../zk/DefaultControllerMessageHandlerFactory.java | 88 - ...faultParticipantErrorMessageHandlerFactory.java | 128 - .../zk/DefaultSchedulerMessageHandlerFactory.java | 277 - .../helix/manager/zk/HelixGroupCommit.java | 174 - .../helix/manager/zk/PathBasedZkSerializer.java | 28 - .../helix/manager/zk/WriteThroughCache.java | 114 - .../linkedin/helix/manager/zk/ZKDataAccessor.java | 329 - .../helix/manager/zk/ZKExceptionHandler.java | 49 - .../linkedin/helix/manager/zk/ZKHelixAdmin.java | 1272 -- .../helix/manager/zk/ZKHelixDataAccessor.java | 590 - .../linkedin/helix/manager/zk/ZKHelixManager.java | 1098 -- .../java/com/linkedin/helix/manager/zk/ZKUtil.java | 353 - .../helix/manager/zk/ZNRecordSerializer.java | 133 - .../manager/zk/ZNRecordStreamingSerializer.java | 300 - .../helix/manager/zk/ZkAsyncCallbacks.java | 171 - .../helix/manager/zk/ZkBaseDataAccessor.java | 1243 -- .../helix/manager/zk/ZkCacheBaseDataAccessor.java | 984 -- .../helix/manager/zk/ZkCacheEventThread.java | 88 - .../linkedin/helix/manager/zk/ZkCallbackCache.java | 348 - .../com/linkedin/helix/manager/zk/ZkClient.java | 445 - .../helix/manager/zk/ZkStateChangeListener.java | 93 - .../linkedin/helix/manager/zk/package-info.java | 5 - .../linkedin/helix/messaging/AsyncCallback.java | 168 - .../helix/messaging/CriteriaEvaluator.java | 94 - .../helix/messaging/DefaultMessagingService.java | 392 - .../messaging/handling/AsyncCallbackService.java | 149 - .../messaging/handling/GroupMessageHandler.java | 115 - .../handling/HelixStateTransitionHandler.java | 388 - .../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 - .../com/linkedin/helix/messaging/package-info.java | 5 - .../com/linkedin/helix/model/AlertHistory.java | 22 - .../java/com/linkedin/helix/model/AlertStatus.java | 85 - .../main/java/com/linkedin/helix/model/Alerts.java | 90 - .../linkedin/helix/model/ClusterConstraints.java | 217 - .../com/linkedin/helix/model/CurrentState.java | 169 - .../main/java/com/linkedin/helix/model/Error.java | 20 - .../com/linkedin/helix/model/ExternalView.java | 76 - .../java/com/linkedin/helix/model/HealthStat.java | 126 - .../java/com/linkedin/helix/model/IdealState.java | 312 - .../com/linkedin/helix/model/InstanceConfig.java | 190 - .../com/linkedin/helix/model/LeaderHistory.java | 64 - .../com/linkedin/helix/model/LiveInstance.java | 115 - .../java/com/linkedin/helix/model/Message.java | 583 - .../java/com/linkedin/helix/model/Partition.java | 57 - .../java/com/linkedin/helix/model/PauseSignal.java | 38 - .../com/linkedin/helix/model/PersistentStats.java | 98 - .../java/com/linkedin/helix/model/Resource.java | 123 - .../linkedin/helix/model/ResourceAssignment.java | 21 - .../linkedin/helix/model/StateModelDefinition.java | 143 - .../com/linkedin/helix/model/StatusUpdate.java | 36 - .../com/linkedin/helix/model/package-info.java | 5 - .../helix/monitoring/ParticipantMonitor.java | 137 - .../helix/monitoring/SensorNameProvider.java | 6 - .../linkedin/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 | 97 - .../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 - .../linkedin/helix/monitoring/package-info.java | 5 - .../main/java/com/linkedin/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 | 44 - .../helix/participant/HelixCustomCodeRunner.java | 183 - .../helix/participant/HelixStateMachineEngine.java | 284 - .../helix/participant/StateMachineEngine.java | 67 - .../linkedin/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 | 148 - .../statemachine/StateTransitionError.java | 43 - .../helix/participant/statemachine/Transition.java | 28 - .../participant/statemachine/package-info.java | 5 - .../helix/spectator/RoutingTableProvider.java | 301 - .../com/linkedin/helix/spectator/package-info.java | 5 - .../helix/store/HelixPropertyListener.java | 25 - .../linkedin/helix/store/HelixPropertyStore.java | 44 - .../helix/store/PropertyChangeListener.java | 39 - .../helix/store/PropertyJsonComparator.java | 65 - .../helix/store/PropertyJsonSerializer.java | 95 - .../linkedin/helix/store/PropertySerializer.java | 40 - .../com/linkedin/helix/store/PropertyStat.java | 55 - .../com/linkedin/helix/store/PropertyStore.java | 212 - .../helix/store/PropertyStoreException.java | 36 - .../linkedin/helix/store/PropertyStoreFactory.java | 63 - .../helix/store/ZNRecordJsonSerializer.java | 40 - .../helix/store/file/FileHelixPropertyStore.java | 293 - .../helix/store/file/FilePropertyStore.java | 942 -- .../linkedin/helix/store/file/package-info.java | 5 - .../com/linkedin/helix/store/package-info.java | 5 - .../com/linkedin/helix/store/zk/PropertyItem.java | 45 - .../linkedin/helix/store/zk/ZKPropertyStore.java | 735 - .../java/com/linkedin/helix/store/zk/ZNode.java | 110 - .../linkedin/helix/store/zk/ZkCallbackHandler.java | 97 - .../helix/store/zk/ZkHelixPropertyStore.java | 31 - .../com/linkedin/helix/store/zk/ZkListener.java | 10 - .../com/linkedin/helix/store/zk/package-info.java | 5 - .../linkedin/helix/tools/CLMLogFileAppender.java | 83 - .../com/linkedin/helix/tools/ClusterSetup.java | 1853 --- .../linkedin/helix/tools/ClusterStateVerifier.java | 909 -- .../helix/tools/ClusterViewSerializer.java | 177 - .../tools/IdealCalculatorByConsistentHashing.java | 625 - .../helix/tools/IdealStateCalculatorByRush.java | 325 - .../tools/IdealStateCalculatorByShuffling.java | 118 - .../IdealStateCalculatorForEspressoRelay.java | 100 - .../tools/IdealStateCalculatorForStorageNode.java | 787 -- .../java/com/linkedin/helix/tools/JmxDumper.java | 471 - .../com/linkedin/helix/tools/LocalZKServer.java | 75 - .../com/linkedin/helix/tools/MessagePoster.java | 119 - .../com/linkedin/helix/tools/PropertiesReader.java | 56 - .../java/com/linkedin/helix/tools/RUSHrHash.java | 352 - .../helix/tools/StateModelConfigGenerator.java | 346 - .../java/com/linkedin/helix/tools/TestCommand.java | 106 - .../com/linkedin/helix/tools/TestExecutor.java | 1029 -- .../java/com/linkedin/helix/tools/TestTrigger.java | 127 - .../com/linkedin/helix/tools/YAISCalculator.java | 202 - .../java/com/linkedin/helix/tools/ZKDumper.java | 274 - .../com/linkedin/helix/tools/ZKLogFormatter.java | 395 - .../com/linkedin/helix/tools/ZkLogAnalyzer.java | 491 - .../linkedin/helix/tools/ZkLogCSVFormatter.java | 444 - .../java/com/linkedin/helix/tools/ZnodeOpArg.java | 180 - .../java/com/linkedin/helix/tools/ZnodeValue.java | 76 - .../com/linkedin/helix/tools/package-info.java | 5 - .../java/com/linkedin/helix/util/HelixUtil.java | 181 - .../com/linkedin/helix/util/StatusUpdateUtil.java | 629 - .../com/linkedin/helix/util/StringTemplate.java | 83 - .../java/com/linkedin/helix/util/ZKClientPool.java | 71 - .../java/com/linkedin/helix/util/ZNRecordUtil.java | 123 - .../java/com/linkedin/helix/util/package-info.java | 5 - .../config/cluster-12345-cluster-view.json |10666 --------------- .../integration-test/script/driver_cmd_dict.py | 12 +- helix-core/src/test/conf/testng.xml | 28 +- .../src/test/java/com/linkedin/helix/AppTest.java | 189 - .../com/linkedin/helix/DummyProcessThread.java | 75 - .../java/com/linkedin/helix/ExternalCommand.java | 389 - .../src/test/java/com/linkedin/helix/Mocks.java | 765 -- .../java/com/linkedin/helix/ScriptTestHelper.java | 62 - .../linkedin/helix/TestClusterviewSerializer.java | 73 - .../com/linkedin/helix/TestConfigAccessor.java | 147 - .../TestEspressoStorageClusterIdealState.java | 319 - .../java/com/linkedin/helix/TestGetProperty.java | 48 - .../java/com/linkedin/helix/TestGroupCommit.java | 52 - .../com/linkedin/helix/TestHelixTaskExecutor.java | 87 - .../com/linkedin/helix/TestHelixTaskHandler.java | 127 - .../test/java/com/linkedin/helix/TestHelper.java | 1081 -- .../linkedin/helix/TestHierarchicalDataStore.java | 83 - .../TestParticipantHealthReportCollectorImpl.java | 70 - .../java/com/linkedin/helix/TestPerfCounters.java | 73 - .../helix/TestPerformanceHealthReportProvider.java | 162 - .../com/linkedin/helix/TestPropertyPathConfig.java | 55 - .../helix/TestRelayIdealStateCalculator.java | 70 - .../java/com/linkedin/helix/TestRoutingTable.java | 282 - .../test/java/com/linkedin/helix/TestSample.java | 66 - .../com/linkedin/helix/TestShuffledIdealState.java | 266 - .../java/com/linkedin/helix/TestZKCallback.java | 246 - .../linkedin/helix/TestZKRoutingInfoProvider.java | 208 - .../test/java/com/linkedin/helix/TestZNRecord.java | 126 - .../com/linkedin/helix/TestZNRecordBucketizer.java | 39 - .../com/linkedin/helix/TestZkClientWrapper.java | 120 - .../com/linkedin/helix/TestZkConnectionCount.java | 46 - .../java/com/linkedin/helix/TestZnodeModify.java | 278 - .../test/java/com/linkedin/helix/ZkTestHelper.java | 173 - .../java/com/linkedin/helix/ZkUnitTestBase.java | 428 - .../com/linkedin/helix/alerts/TestAddAlerts.java | 119 - .../helix/alerts/TestAddPersistentStats.java | 216 - .../linkedin/helix/alerts/TestAlertValidation.java | 165 - .../helix/alerts/TestArrivingParticipantStats.java | 485 - .../helix/alerts/TestBaseStatsValidation.java | 181 - .../linkedin/helix/alerts/TestEvaluateAlerts.java | 386 - .../com/linkedin/helix/alerts/TestOperators.java | 289 - .../com/linkedin/helix/alerts/TestStatsMatch.java | 105 - .../controller/TestControllerRebalancingTimer.java | 286 - .../TestControllerRebalancingTimerPeriod.java | 157 - .../helix/controller/stages/BaseStageTest.java | 172 - .../controller/stages/DummyClusterManager.java | 268 - .../stages/TestBestPossibleStateCalcStage.java | 69 - .../helix/controller/stages/TestClusterEvent.java | 34 - .../stages/TestCompatibilityCheckStage.java | 168 - .../stages/TestCurrentStateComputationStage.java | 122 - .../stages/TestMessageThrottleStage.java | 358 - .../controller/stages/TestMsgSelectionStage.java | 117 - .../controller/stages/TestParseInfoFromAlert.java | 37 - .../controller/stages/TestRebalancePipeline.java | 417 - .../stages/TestResourceComputationStage.java | 241 - .../helix/healthcheck/TestAddDropAlert.java | 194 - .../healthcheck/TestAlertActionTriggering.java | 188 - .../helix/healthcheck/TestAlertFireHistory.java | 328 - .../helix/healthcheck/TestDummyAlerts.java | 153 - .../helix/healthcheck/TestExpandAlert.java | 195 - .../helix/healthcheck/TestSimpleAlert.java | 207 - .../helix/healthcheck/TestSimpleWildcardAlert.java | 256 - .../helix/healthcheck/TestStalenessAlert.java | 192 - .../helix/healthcheck/TestWildcardAlert.java | 301 - .../linkedin/helix/integration/FileCMTestBase.java | 208 - .../helix/integration/IntegrationTest.java | 39 - .../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 - .../linkedin/helix/integration/TestDisable.java | 403 - .../helix/integration/TestDisableNode.java | 46 - .../helix/integration/TestDisablePartition.java | 75 - .../helix/integration/TestDistributedCMMain.java | 179 - .../TestDistributedClusterController.java | 148 - .../com/linkedin/helix/integration/TestDriver.java | 519 - .../com/linkedin/helix/integration/TestDrop.java | 200 - .../helix/integration/TestDropResource.java | 91 - .../integration/TestDynamicFileClusterManager.java | 59 - .../TestEnablePartitionDuringDisable.java | 159 - .../helix/integration/TestErrorPartition.java | 148 - .../helix/integration/TestExpandCluster.java | 72 - .../helix/integration/TestExternalCmd.java | 36 - .../helix/integration/TestExternalViewUpdates.java | 89 - .../helix/integration/TestFailOverPerf1kp.java | 52 - .../integration/TestFileBasedHelixManager.java | 67 - .../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 - .../helix/integration/TestNullReplica.java | 78 - .../integration/TestParticipantErrorMessage.java | 76 - .../integration/TestParticipantNameCollision.java | 57 - .../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 | 424 - .../linkedin/helix/integration/TestSchemataSM.java | 66 - .../integration/TestSessionExpiryInTransition.java | 115 - .../helix/integration/TestStandAloneCMMain.java | 57 - .../integration/TestStandAloneCMSessionExpiry.java | 136 - .../integration/TestStateTransitionTimeout.java | 210 - .../helix/integration/TestStatusUpdate.java | 103 - .../helix/integration/TestSwapInstance.java | 128 - .../TestZNRecordQueryProcessorWithZK.java | 157 - .../helix/integration/ZkIntegrationTestBase.java | 160 - .../helix/integration/ZkStandAloneCMTestBase.java | 166 - ...tandAloneCMTestBaseWithPropertyServerCheck.java | 73 - .../josql/TestClusterJosqlQueryProcessor.java | 102 - .../linkedin/helix/josql/TestJosqlProcessor.java | 227 - .../helix/josql/TestZNRecordQueryProcessor.java | 231 - .../com/linkedin/helix/manager/MockListener.java | 105 - .../helix/manager/file/MockFileHelixManager.java | 274 - .../manager/file/TestFileCallbackHandler.java | 104 - .../helix/manager/file/TestFileDataAccessor.java | 93 - .../helix/manager/file/TestStaticFileCM.java | 148 - .../manager/file/UnitTestDynFileClusterMgr.java | 280 - .../zk/TestDefaultControllerMsgHandlerFactory.java | 102 - .../helix/manager/zk/TestHandleNewSession.java | 70 - .../helix/manager/zk/TestLiveInstanceBounce.java | 64 - .../manager/zk/TestWtCacheAsyncOpMultiThread.java | 276 - .../manager/zk/TestWtCacheAsyncOpSingleThread.java | 251 - .../manager/zk/TestWtCacheSyncOpSingleThread.java | 194 - .../helix/manager/zk/TestZKDataAccessor.java | 171 - .../helix/manager/zk/TestZKDataAccessorCache.java | 149 - .../helix/manager/zk/TestZKLiveInstanceData.java | 150 - .../manager/zk/TestZKPropertyTransferServer.java | 58 - .../com/linkedin/helix/manager/zk/TestZKUtil.java | 160 - .../helix/manager/zk/TestZNRecordSizeLimit.java | 322 - .../helix/manager/zk/TestZkBaseDataAccessor.java | 315 - .../manager/zk/TestZkCacheAsyncOpSingleThread.java | 378 - .../manager/zk/TestZkCacheSyncOpSingleThread.java | 205 - .../helix/manager/zk/TestZkClusterManager.java | 145 - .../helix/manager/zk/TestZkHelixAdmin.java | 196 - .../helix/messaging/TestAsyncCallback.java | 127 - .../helix/messaging/TestAsyncCallbackSvc.java | 128 - .../messaging/TestDefaultMessagingService.java | 243 - .../handling/TestConfigThreadpoolSize.java | 124 - .../messaging/handling/TestHelixTaskExecutor.java | 584 - .../handling/TestResourceThreadpoolSize.java | 50 - .../helix/mock/consumer/ConsumerAdapter.java | 134 - .../linkedin/helix/mock/consumer/RelayConfig.java | 81 - .../helix/mock/consumer/RelayConsumer.java | 108 - .../helix/mock/controller/ClusterController.java | 152 - .../helix/mock/controller/MockController.java | 143 - .../mock/controller/MockControllerProcess.java | 73 - .../helix/mock/relay/DummyRelayProcess.java | 248 - .../helix/mock/relay/RelayIdealStateGenerator.java | 47 - .../helix/mock/router/MockRouterProcess.java | 158 - .../linkedin/helix/mock/router/RouterAdapter.java | 21 - .../linkedin/helix/mock/storage/DummyProcess.java | 546 - .../helix/mock/storage/HealthCheckStateModel.java | 247 - .../mock/storage/HealthCheckStateModelFactory.java | 50 - .../storage/MockEspressoHealthReportProvider.java | 82 - .../mock/storage/MockHealthReportParticipant.java | 274 - .../linkedin/helix/mock/storage/MockJobIntf.java | 24 - .../helix/mock/storage/MockParticipant.java | 615 - .../helix/mock/storage/MockStorageProcess.java | 171 - .../helix/mock/storage/MockTransition.java | 39 - .../helix/mock/storage/StorageAdapter.java | 206 - .../helix/mock/storage/StorageStateModel.java | 157 - .../mock/storage/StorageStateModelFactory.java | 49 - .../com/linkedin/helix/model/TestConstraint.java | 264 - .../com/linkedin/helix/model/TestIdealState.java | 60 - .../helix/monitoring/TestParticipantMonitor.java | 152 - .../helix/monitoring/TestStatCollector.java | 54 - .../TestClusterAlertItemMBeanCollection.java | 255 - .../mbeans/TestClusterStatusMonitor.java | 128 - .../monitoring/mbeans/TestResourceMonitor.java | 172 - .../helix/participant/MockZKHelixManager.java | 278 - .../participant/TestDistControllerElection.java | 180 - .../participant/TestDistControllerStateModel.java | 134 - .../TestDistControllerStateModelFactory.java | 36 - .../linkedin/helix/store/TestJsonComparator.java | 40 - .../com/linkedin/helix/store/TestPropertyStat.java | 35 - .../helix/store/TestPropertyStoreException.java | 37 - .../helix/store/TestPropertyStoreFactory.java | 89 - .../helix/store/TestZNRecordJsonSerializer.java | 75 - .../helix/store/file/TestFilePropertyStore.java | 156 - .../helix/store/zk/TestZKPropertyStore.java | 536 - .../store/zk/TestZKPropertyStoreMultiThread.java | 156 - .../helix/store/zk/TestZkHelixPropertyStore.java | 368 - .../store/zk/TestZkPropertyStoreSessionExpiry.java | 106 - .../com/linkedin/helix/tools/TestClusterSetup.java | 494 - .../helix/tools/TestHelixAdminScenariosCli.java | 421 - .../com/linkedin/helix/util/TestZKClientPool.java | 71 - helix-core/src/test/resources/log4j.properties | 2 +- .../src/test/resources/relay_ideal_state.json | 178 - mockservice/pom.xml | 2 +- .../main/java/com/linkedin/helix/CMConnector.java | 42 - .../java/com/linkedin/helix/EspressoResource.java | 214 - .../linkedin/helix/EspressoStorageMockNode.java | 198 - .../EspressoStorageMockStateModelFactory.java | 99 - .../java/com/linkedin/helix/FnvHashFunction.java | 206 - .../main/java/com/linkedin/helix/HashFunction.java | 68 - .../com/linkedin/helix/MockEspressoService.java | 269 - .../src/main/java/com/linkedin/helix/MockNode.java | 32 - .../java/com/linkedin/helix/MockNodeFactory.java | 37 - .../main/java/com/linkedin/helix/MockRunner.java | 58 - .../com/linkedin/helix/StopServiceResource.java | 141 - mockservice/src/test/conf/testng.xml | 2 +- .../src/test/java/com/linkedin/helix/AppTest.java | 43 - .../rabbitmq-consumer-group/bin/send-message.sh | 4 +- .../rabbitmq-consumer-group/bin/setup-cluster.sh | 4 +- .../bin/start-cluster-manager.sh | 4 +- .../rabbitmq-consumer-group/bin/start-consumer.sh | 4 +- .../lib/helix-core-0.5.28-sources.jar | Bin 480433 -> 0 bytes .../lib/helix-core-0.5.28.jar | Bin 838805 -> 0 bytes recipes/rabbitmq-consumer-group/pom.xml | 6 +- .../linkedin/helix/recipes/rabbitmq/Consumer.java | 129 - .../helix/recipes/rabbitmq/ConsumerStateModel.java | 97 - .../rabbitmq/ConsumerStateModelFactory.java | 21 - .../helix/recipes/rabbitmq/ConsumerThread.java | 76 - .../linkedin/helix/recipes/rabbitmq/Emitter.java | 56 - .../recipes/rabbitmq/SetupConsumerCluster.java | 58 - .../recipes/rabbitmq/StartClusterManager.java | 42 - sun_checks.xml | 208 - 566 files changed, 50 insertions(+), 106674 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/build ---------------------------------------------------------------------- diff --git a/build b/build index 51f1688..12a843e 100644 --- a/build +++ b/build @@ -1 +1 @@ -mvn clean install -Dmaven.test.skip=true +mvn clean install -Dmaven.test.skip.exec=true http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/helix-admin-webapp/helix-admin-webapp-0.5.28.ivy ---------------------------------------------------------------------- diff --git a/helix-admin-webapp/helix-admin-webapp-0.5.28.ivy b/helix-admin-webapp/helix-admin-webapp-0.5.28.ivy index 0cd54cf..536c360 100644 --- a/helix-admin-webapp/helix-admin-webapp-0.5.28.ivy +++ b/helix-admin-webapp/helix-admin-webapp-0.5.28.ivy @@ -1,5 +1,5 @@ - - + http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/helix-admin-webapp/pom.xml ---------------------------------------------------------------------- diff --git a/helix-admin-webapp/pom.xml b/helix-admin-webapp/pom.xml index 3a834eb..943b451 100644 --- a/helix-admin-webapp/pom.xml +++ b/helix-admin-webapp/pom.xml @@ -85,7 +85,7 @@ under the License. - com.linkedin.helix.webapp.RestAdminApplication + org.apache.helix.webapp.RestAdminApplication run-rest-admin http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/3cb7a1c9/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/HelixAdminWebApp.java ---------------------------------------------------------------------- diff --git a/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/HelixAdminWebApp.java b/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/HelixAdminWebApp.java deleted file mode 100644 index 5457d3d..0000000 --- a/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/HelixAdminWebApp.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.linkedin.helix.webapp; - -import org.apache.log4j.Logger; -import org.restlet.Component; -import org.restlet.Context; -import org.restlet.data.Protocol; - -import com.linkedin.helix.manager.zk.ZNRecordSerializer; -import com.linkedin.helix.manager.zk.ZkClient; - -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/3cb7a1c9/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/RestAdminApplication.java ---------------------------------------------------------------------- diff --git a/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/RestAdminApplication.java b/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/RestAdminApplication.java deleted file mode 100644 index 9d0785b..0000000 --- a/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/RestAdminApplication.java +++ /dev/null @@ -1,221 +0,0 @@ -/** - * Copyright (C) 2012 LinkedIn Inc - * - * 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.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.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; - -import com.linkedin.helix.webapp.resources.ClusterResource; -import com.linkedin.helix.webapp.resources.ClustersResource; -import com.linkedin.helix.webapp.resources.ConfigResource; -import com.linkedin.helix.webapp.resources.ControllerResource; -import com.linkedin.helix.webapp.resources.ControllerStatusUpdateResource; -import com.linkedin.helix.webapp.resources.CurrentStateResource; -import com.linkedin.helix.webapp.resources.CurrentStatesResource; -import com.linkedin.helix.webapp.resources.ErrorResource; -import com.linkedin.helix.webapp.resources.ErrorsResource; -import com.linkedin.helix.webapp.resources.ExternalViewResource; -import com.linkedin.helix.webapp.resources.IdealStateResource; -import com.linkedin.helix.webapp.resources.InstanceResource; -import com.linkedin.helix.webapp.resources.InstancesResource; -import com.linkedin.helix.webapp.resources.ResourceGroupResource; -import com.linkedin.helix.webapp.resources.ResourceGroupsResource; -import com.linkedin.helix.webapp.resources.SchedulerTasksResource; -import com.linkedin.helix.webapp.resources.StateModelResource; -import com.linkedin.helix.webapp.resources.StateModelsResource; -import com.linkedin.helix.webapp.resources.StatusUpdateResource; -import com.linkedin.helix.webapp.resources.StatusUpdatesResource; -import com.linkedin.helix.webapp.resources.ZkChildResource; -import com.linkedin.helix.webapp.resources.ZkPathResource; - -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(""); - stringBuilder - .append("Restlet Cluster Management page"); - stringBuilder.append(""); - stringBuilder.append(""); - stringBuilder.append(""); - stringBuilder.append(""); - stringBuilder.append(""); - stringBuilder.append("
"); - stringBuilder.append("

Rest cluster management interface V1

"); - stringBuilder.append("
"); - stringBuilder.append(""); - stringBuilder.append(""); - 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/3cb7a1c9/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ClusterRepresentationUtil.java ---------------------------------------------------------------------- diff --git a/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ClusterRepresentationUtil.java b/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ClusterRepresentationUtil.java deleted file mode 100644 index 214f6f1..0000000 --- a/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ClusterRepresentationUtil.java +++ /dev/null @@ -1,286 +0,0 @@ -/** - * Copyright (C) 2012 LinkedIn Inc - * - * 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.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.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; - -import com.linkedin.helix.HelixDataAccessor; -import com.linkedin.helix.HelixProperty; -import com.linkedin.helix.PropertyKey; -import com.linkedin.helix.PropertyKey.Builder; -import com.linkedin.helix.PropertyType; -import com.linkedin.helix.ZNRecord; -import com.linkedin.helix.manager.zk.ZKHelixDataAccessor; -import com.linkedin.helix.manager.zk.ZNRecordSerializer; -import com.linkedin.helix.manager.zk.ZkBaseDataAccessor; -import com.linkedin.helix.manager.zk.ZkClient; -import com.linkedin.helix.model.LiveInstance.LiveInstanceProperty; -import com.linkedin.helix.util.HelixUtil; - -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(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 recordNames = zkClient.getChildren(path); - return ObjectToJson(recordNames); - } - - return ObjectToJson(new ArrayList()); - } - - public static String getInstancePropertyAsString(ZkClient zkClient, - String clusterName, - PropertyKey propertyKey, - MediaType mediaType) throws JsonGenerationException, - JsonMappingException, - IOException - { - ZKHelixDataAccessor accessor = - new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor(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(zkClient)); - - List 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(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(zkClient)); - } - - public static T JsonToObject(Class clazz, String jsonString) throws JsonParseException, - JsonMappingException, - IOException - { - StringReader sr = new StringReader(jsonString); - ObjectMapper mapper = new ObjectMapper(); - return mapper.readValue(sr, clazz); - - } - - public static Map JsonToMap(String jsonString) throws JsonParseException, - JsonMappingException, - IOException - { - StringReader sr = new StringReader(jsonString); - ObjectMapper mapper = new ObjectMapper(); - - TypeReference> typeRef = - new TypeReference>() - { - }; - - return mapper.readValue(sr, typeRef); - } - - public static Map getFormJsonParameters(Form form) throws JsonParseException, - JsonMappingException, - IOException - { - String jsonPayload = form.getFirstValue(JsonParameters.JSON_PARAMETERS, true); - return ClusterRepresentationUtil.JsonToMap(jsonPayload); - } - - public static Map 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 getFormJsonParameters(Class 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 result = new TreeMap(); - 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(zkClient)); - Builder keyBuilder = accessor.keyBuilder(); - - ZNRecord liveInstance = - accessor.getProperty(keyBuilder.liveInstance(instanceName)).getRecord(); - - return liveInstance.getSimpleField(LiveInstanceProperty.SESSION_ID.toString()); - } - - public static List 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/3cb7a1c9/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ClusterResource.java ---------------------------------------------------------------------- diff --git a/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ClusterResource.java b/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ClusterResource.java deleted file mode 100644 index 26315cc..0000000 --- a/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ClusterResource.java +++ /dev/null @@ -1,210 +0,0 @@ -/** - * Copyright (C) 2012 LinkedIn Inc - * - * 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.webapp.resources; - -import java.io.IOException; -import java.util.List; - -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; - -import com.linkedin.helix.HelixDataAccessor; -import com.linkedin.helix.HelixException; -import com.linkedin.helix.PropertyKey.Builder; -import com.linkedin.helix.ZNRecord; -import com.linkedin.helix.manager.zk.ZkClient; -import com.linkedin.helix.model.LiveInstance; -import com.linkedin.helix.tools.ClusterSetup; -import com.linkedin.helix.webapp.RestAdminApplication; - -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 instances = - setupTool.getClusterManagementTool().getInstancesInCluster(clusterName); - - ZNRecord clusterSummayRecord = new ZNRecord("Cluster Summary"); - clusterSummayRecord.setListField("participants", instances); - - List resources = - setupTool.getClusterManagementTool().getResourcesInCluster(clusterName); - clusterSummayRecord.setListField("resources", resources); - - List 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/3cb7a1c9/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ClustersResource.java ---------------------------------------------------------------------- diff --git a/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ClustersResource.java b/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ClustersResource.java deleted file mode 100644 index 9b680f0..0000000 --- a/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ClustersResource.java +++ /dev/null @@ -1,152 +0,0 @@ -/** - * Copyright (C) 2012 LinkedIn Inc - * - * 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.webapp.resources; - -import java.io.IOException; -import java.util.List; - -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; - -import com.linkedin.helix.HelixException; -import com.linkedin.helix.ZNRecord; -import com.linkedin.helix.manager.zk.ZkClient; -import com.linkedin.helix.tools.ClusterSetup; -import com.linkedin.helix.webapp.RestAdminApplication; - -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 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/3cb7a1c9/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ConfigResource.java ---------------------------------------------------------------------- diff --git a/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ConfigResource.java b/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ConfigResource.java deleted file mode 100644 index 5accb91..0000000 --- a/helix-admin-webapp/src/main/java/com/linkedin/helix/webapp/resources/ConfigResource.java +++ /dev/null @@ -1,311 +0,0 @@ -/** - * Copyright (C) 2012 LinkedIn Inc - * - * 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.webapp.resources; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Map; - -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; - -import com.linkedin.helix.ConfigScope; -import com.linkedin.helix.ConfigScope.ConfigScopeProperty; -import com.linkedin.helix.ConfigScopeBuilder; -import com.linkedin.helix.HelixAdmin; -import com.linkedin.helix.HelixException; -import com.linkedin.helix.ZNRecord; -import com.linkedin.helix.manager.zk.ZkClient; -import com.linkedin.helix.tools.ClusterSetup; -import com.linkedin.helix.webapp.RestAdminApplication; - -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 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 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 configKeys = admin.getConfigKeys(scopeProperty, clusterName, keys); - Map configs = admin.getConfig(scope, new HashSet(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); - } - } -}