├── .asf.yaml ├── .gitattributes ├── .github └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── ambari-infra-assembly ├── build.xml ├── pom.xml └── src │ └── main │ └── package │ ├── deb │ ├── manager │ │ ├── control │ │ ├── postinst │ │ ├── postrm │ │ ├── preinst │ │ └── prerm │ ├── solr-client │ │ ├── control │ │ ├── postinst │ │ ├── postrm │ │ ├── preinst │ │ └── prerm │ └── solr │ │ ├── control │ │ ├── postinst │ │ ├── postrm │ │ ├── preinst │ │ └── prerm │ └── rpm │ ├── manager │ ├── postinstall.sh │ └── postremove.sh │ └── solr-client │ └── postinstall.sh ├── ambari-infra-manager-it ├── pom.xml └── src │ └── test │ ├── java │ └── org │ │ └── apache │ │ └── ambari │ │ └── infra │ │ ├── HttpResponse.java │ │ ├── InfraClient.java │ │ ├── InfraManagerStories.java │ │ ├── JobExecutionInfo.java │ │ ├── OffsetDateTimeConverter.java │ │ ├── S3Client.java │ │ ├── Solr.java │ │ ├── TestUtil.java │ │ ├── solr │ │ └── metrics │ │ │ ├── MetricsIT.java │ │ │ └── MockMetricsServer.java │ │ └── steps │ │ ├── AbstractInfraSteps.java │ │ └── ExportJobsSteps.java │ └── resources │ ├── conf │ ├── core-site.xml │ ├── hdfs-site.xml │ └── infra-manager.properties │ ├── log4j2-test.properties │ └── stories │ └── infra_api_tests.story ├── ambari-infra-manager ├── .gitignore ├── README.md ├── build.xml ├── docker │ ├── Dockerfile │ ├── bin │ │ └── start.sh │ ├── docker-compose.yml │ ├── infra-manager-docker-compose.sh │ └── infra-manager-docker.sh ├── docs │ └── images │ │ ├── batch-1.png │ │ ├── batch-2.png │ │ ├── batch-3.png │ │ └── batch-4.png ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── apache │ │ │ └── ambari │ │ │ └── infra │ │ │ ├── InfraManager.java │ │ │ ├── conf │ │ │ ├── InfraManagerApiDocConfig.java │ │ │ ├── InfraManagerConfig.java │ │ │ ├── InfraManagerDataConfig.java │ │ │ ├── InfraManagerJerseyResourceConfig.java │ │ │ ├── InfraManagerSchedulingConfig.java │ │ │ ├── InfraManagerServletConfig.java │ │ │ ├── InfraManagerWebServerCustomizer.java │ │ │ ├── StaticResourceConfiguration.java │ │ │ ├── batch │ │ │ │ └── InfraManagerBatchConfig.java │ │ │ └── security │ │ │ │ ├── CompositeSecret.java │ │ │ │ ├── EnvironmentalSecret.java │ │ │ │ ├── HadoopCredential.java │ │ │ │ ├── HadoopCredentialStore.java │ │ │ │ ├── Secret.java │ │ │ │ ├── SecretStoreConfig.java │ │ │ │ ├── SslSecrets.java │ │ │ │ └── WebSecurityConfig.java │ │ │ ├── job │ │ │ ├── AbstractJobsConfiguration.java │ │ │ ├── CloseableIterator.java │ │ │ ├── InfraJobExecutionDao.java │ │ │ ├── JobConfigurationException.java │ │ │ ├── JobContextRepository.java │ │ │ ├── JobContextRepositoryImpl.java │ │ │ ├── JobProperties.java │ │ │ ├── JobPropertiesHolder.java │ │ │ ├── JobScheduler.java │ │ │ ├── JobsPropertyMap.java │ │ │ ├── ObjectSource.java │ │ │ ├── SchedulingProperties.java │ │ │ ├── SolrDAOBase.java │ │ │ ├── Validatable.java │ │ │ ├── archive │ │ │ │ ├── AbstractFileAction.java │ │ │ │ ├── ArchivingProperties.java │ │ │ │ ├── BZip2Compressor.java │ │ │ │ ├── CompositeFileAction.java │ │ │ │ ├── Document.java │ │ │ │ ├── DocumentArchivingConfiguration.java │ │ │ │ ├── DocumentArchivingPropertyMap.java │ │ │ │ ├── DocumentDestination.java │ │ │ │ ├── DocumentExporter.java │ │ │ │ ├── DocumentItemReader.java │ │ │ │ ├── DocumentItemWriter.java │ │ │ │ ├── DocumentWiper.java │ │ │ │ ├── ExportDestination.java │ │ │ │ ├── FileAction.java │ │ │ │ ├── FileNameSuffixFormatter.java │ │ │ │ ├── HdfsProperties.java │ │ │ │ ├── HdfsUploader.java │ │ │ │ ├── ItemWriterListener.java │ │ │ │ ├── LocalDocumentItemWriter.java │ │ │ │ ├── LocalItemWriterListener.java │ │ │ │ ├── SolrDAO.java │ │ │ │ ├── SolrDocumentIterator.java │ │ │ │ ├── SolrDocumentSource.java │ │ │ │ ├── SolrParametrizedString.java │ │ │ │ ├── SolrProperties.java │ │ │ │ ├── SolrQueryBuilder.java │ │ │ │ ├── SolrQueryProperties.java │ │ │ │ ├── TarGzCompressor.java │ │ │ │ └── WriteCompletedEvent.java │ │ │ ├── cleanup │ │ │ │ ├── CleanUpConfiguration.java │ │ │ │ ├── CleanUpProperties.java │ │ │ │ └── TaskHistoryWiper.java │ │ │ ├── deleting │ │ │ │ ├── DeletingProperties.java │ │ │ │ ├── DocumentDeletingConfiguration.java │ │ │ │ ├── DocumentDeletingPropertyMap.java │ │ │ │ └── DocumentWiperTasklet.java │ │ │ └── dummy │ │ │ │ ├── DummyItemProcessor.java │ │ │ │ ├── DummyItemWriter.java │ │ │ │ ├── DummyJobConfiguration.java │ │ │ │ ├── DummyJobListener.java │ │ │ │ ├── DummyObject.java │ │ │ │ └── DummyStepListener.java │ │ │ ├── json │ │ │ ├── DurationToStringConverter.java │ │ │ ├── FsPermissionToStringConverter.java │ │ │ ├── OffsetDateTimeToStringConverter.java │ │ │ ├── StringToDurationConverter.java │ │ │ └── StringToFsPermissionConverter.java │ │ │ ├── manager │ │ │ ├── JobManager.java │ │ │ └── Jobs.java │ │ │ ├── model │ │ │ ├── DateUtil.java │ │ │ ├── ExecutionContextResponse.java │ │ │ ├── ISO8601DateFormatter.java │ │ │ ├── JobExecutionDetailsResponse.java │ │ │ ├── JobExecutionInfoResponse.java │ │ │ ├── JobExecutionRequest.java │ │ │ ├── JobExecutionRestartRequest.java │ │ │ ├── JobExecutionStopRequest.java │ │ │ ├── JobInstanceDetailsResponse.java │ │ │ ├── JobInstanceStartRequest.java │ │ │ ├── JobOperationParams.java │ │ │ ├── JobRequest.java │ │ │ ├── PageRequest.java │ │ │ ├── StepExecutionContextResponse.java │ │ │ ├── StepExecutionInfoResponse.java │ │ │ ├── StepExecutionProgressResponse.java │ │ │ └── StepExecutionRequest.java │ │ │ └── rest │ │ │ ├── JobExceptionMapper.java │ │ │ └── JobResource.java │ └── resources │ │ ├── dummy │ │ └── dummy.txt │ │ ├── infra-manager-env.sh │ │ ├── infra-manager.properties │ │ ├── infraManager.sh │ │ ├── log4j2.xml │ │ ├── static │ │ └── index.html │ │ └── swagger │ │ └── swagger.html │ └── test │ ├── java │ └── org │ │ └── apache │ │ └── ambari │ │ └── infra │ │ ├── conf │ │ └── security │ │ │ └── CompositeSecretTest.java │ │ ├── env │ │ └── TestAppConfig.java │ │ ├── job │ │ ├── InfraJobExecutionDAOIT.java │ │ ├── JobSchedulerTest.java │ │ └── archive │ │ │ ├── DocumentExporterTest.java │ │ │ ├── DocumentItemReaderTest.java │ │ │ ├── FileNameSuffixFormatterTest.java │ │ │ ├── LocalDocumentItemWriterTest.java │ │ │ ├── SolrParametrizedStringTest.java │ │ │ ├── SolrPropertiesTest.java │ │ │ ├── SolrQueryBuilderTest.java │ │ │ └── SolrQueryPropertiesTest.java │ │ ├── json │ │ └── FsPermissionToStringConverterTest.java │ │ └── model │ │ └── ISO8601DateFormatterTest.java │ └── resoruces │ └── vagrant-infra-manager.properties.sample ├── ambari-infra-solr-client ├── README.md ├── build.xml ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── apache │ │ │ └── ambari │ │ │ └── infra │ │ │ └── solr │ │ │ ├── AmbariSolrCloudCLI.java │ │ │ ├── AmbariSolrCloudClient.java │ │ │ ├── AmbariSolrCloudClientBuilder.java │ │ │ ├── AmbariSolrCloudClientException.java │ │ │ ├── S3Uploader.java │ │ │ ├── commands │ │ │ ├── AbstractRetryCommand.java │ │ │ ├── AbstractSolrRetryCommand.java │ │ │ ├── AbstractStateFileZkCommand.java │ │ │ ├── AbstractZookeeperConfigCommand.java │ │ │ ├── AbstractZookeeperRetryCommand.java │ │ │ ├── CheckConfigZkCommand.java │ │ │ ├── CheckZnodeZkCommand.java │ │ │ ├── CreateCollectionCommand.java │ │ │ ├── CreateShardCommand.java │ │ │ ├── CreateSolrZnodeZkCommand.java │ │ │ ├── DeleteZnodeZkCommand.java │ │ │ ├── DownloadConfigZkCommand.java │ │ │ ├── DumpCollectionsCommand.java │ │ │ ├── EnableKerberosPluginSolrZkCommand.java │ │ │ ├── GetShardsCommand.java │ │ │ ├── GetSolrHostsCommand.java │ │ │ ├── GetStateFileZkCommand.java │ │ │ ├── ListCollectionCommand.java │ │ │ ├── RemoveAdminHandlersCommand.java │ │ │ ├── SecureSolrZNodeZkCommand.java │ │ │ ├── SecureZNodeZkCommand.java │ │ │ ├── SetAutoScalingZkCommand.java │ │ │ ├── SetClusterPropertyZkCommand.java │ │ │ ├── TransferZnodeZkCommand.java │ │ │ ├── UnsecureZNodeZkCommand.java │ │ │ ├── UpdateStateFileZkCommand.java │ │ │ └── UploadConfigZkCommand.java │ │ │ ├── domain │ │ │ ├── AmbariSolrState.java │ │ │ ├── ZookeeperClient.java │ │ │ └── json │ │ │ │ ├── SolrCollection.java │ │ │ │ ├── SolrCoreData.java │ │ │ │ └── SolrShard.java │ │ │ └── util │ │ │ ├── AclUtils.java │ │ │ └── ShardUtils.java │ ├── python │ │ ├── migrationConfigGenerator.py │ │ ├── migrationHelper.py │ │ └── solrDataManager.py │ └── resources │ │ ├── ambariSolrMigration.sh │ │ ├── data │ │ └── security-without-authr.json │ │ ├── log4j.properties │ │ ├── managed-schema │ │ ├── solrCloudCli.sh │ │ └── solrIndexHelper.sh │ └── test │ └── java │ └── org │ └── apache │ └── ambari │ └── infra │ └── solr │ └── AmbariSolrCloudClientTest.java ├── ambari-infra-solr-plugin ├── .gitignore ├── docker │ ├── Dockerfile │ ├── docker-compose.yml │ ├── infra-solr-docker-compose.sh │ ├── infra-solr.sh │ └── solr.xml ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── apache │ │ │ ├── ambari │ │ │ └── infra │ │ │ │ └── solr │ │ │ │ └── metrics │ │ │ │ └── reporters │ │ │ │ ├── AMSCacheReporter.java │ │ │ │ ├── AMSProtocol.java │ │ │ │ ├── AMSReporter.java │ │ │ │ ├── GaugeConverter.java │ │ │ │ ├── MetricsUtils.java │ │ │ │ ├── ScheduledAMSReporter.java │ │ │ │ ├── ScheduledAMSReporterBuilder.java │ │ │ │ ├── SimpleAMSReporter.java │ │ │ │ ├── SolrMetricsSecurityConfig.java │ │ │ │ └── SolrMetricsSink.java │ │ │ └── solr │ │ │ └── security │ │ │ ├── InfraKerberosHostValidator.java │ │ │ ├── InfraRuleBasedAuthorizationPlugin.java │ │ │ └── InfraUserRolesLookupStrategy.java │ └── resources │ │ └── apispec │ │ └── cluster.security.InfraRuleBasedAuthorization.json │ └── test │ └── java │ └── org │ └── apache │ └── solr │ └── security │ ├── InfraKerberosHostValidatorTest.java │ ├── InfraRuleBasedAuthorizationPluginTest.java │ └── InfraUserRolesLookupStrategyTest.java ├── jenkins └── containers │ └── docker-infra-solr │ ├── Dockerfile │ ├── bin │ ├── entrypoint.sh │ └── init.sh │ └── conf │ ├── infra-solr.conf │ └── solr.xml └── pom.xml /.asf.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | github: 16 | description: "Apache Ambari Infra is a sub project of Apache Ambari." 17 | homepage: https://ambari.apache.org 18 | labels: 19 | - javascript 20 | - python 21 | - java 22 | - big-data 23 | - ambari 24 | enabled_merge_buttons: 25 | squash: true 26 | merge: false 27 | rebase: false 28 | notifications: 29 | commits: commits@ambari.apache.org 30 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## What changes were proposed in this pull request? 2 | 3 | (Please fill in changes proposed in this fix) 4 | 5 | ## How was this patch tested? 6 | 7 | (Please explain how this patch was tested. Ex: unit tests, manual tests) 8 | (If this patch involves UI changes, please attach a screen-shot; otherwise, remove this) 9 | 10 | Please review [Ambari Contributing Guide](https://cwiki.apache.org/confluence/display/AMBARI/How+to+Contribute) before opening a pull request. 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .classpath 2 | .project 3 | .settings 4 | .repository 5 | .idea/ 6 | .iml/ 7 | .DS_Store 8 | **/target/ 9 | *.pyc 10 | *.py~ 11 | **/*.iml 12 | .hg 13 | .hgignore 14 | .hgtags 15 | derby.log 16 | pass.txt 17 | out 18 | job-repository.db 19 | .flattened-pom.xml -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | GIT_REV_SHORT = $(shell git rev-parse --short HEAD) 14 | MAVEN_BINARY ?= mvn 15 | 16 | ifeq ("$(INFRA_JDK_11)", "true") 17 | INFRA_JAVA_VERSION = "11" 18 | else 19 | INFRA_JAVA_VERSION = "1.8" 20 | endif 21 | 22 | package: 23 | $(MAVEN_BINARY) clean package -Djdk.version=$(INFRA_JAVA_VERSION) 24 | 25 | install: 26 | $(MAVEN_BINARY) clean install -Djdk.version=$(INFRA_JAVA_VERSION) 27 | 28 | test: 29 | $(MAVEN_BINARY) clean test -Djdk.version=$(INFRA_JAVA_VERSION) 30 | 31 | update-version: 32 | $(MAVEN_BINARY) versions:set-property -Dproperty=revision -DnewVersion=$(new-version) -DgenerateBackupPoms=false -Djdk.version=$(INFRA_JAVA_VERSION) 33 | 34 | rpm: 35 | $(MAVEN_BINARY) clean package -Dbuild-rpm -DskipTests -Djdk.version=$(INFRA_JAVA_VERSION) 36 | 37 | deb: 38 | $(MAVEN_BINARY) clean package -Dbuild-deb -DskipTests -Djdk.version=$(INFRA_JAVA_VERSION) 39 | 40 | docker-build: 41 | $(MAVEN_BINARY) clean package docker:build -DskipTests -Dbuild-deb -Djdk.version=$(INFRA_JAVA_VERSION) 42 | 43 | docker-push: 44 | $(MAVEN_BINARY) clean package docker:build docker:push -DskipTests -Dbuild-deb -Djdk.version=$(INFRA_JAVA_VERSION) 45 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Apache Ambari Infra 2 | [![Build Status](https://builds.apache.org/buildStatus/icon?job=Ambari-Infra-master-Commit)](https://builds.apache.org/view/A/view/Ambari/job/Ambari-Infra-master-Commit/) 3 | ![license](http://img.shields.io/badge/license-Apache%20v2-blue.svg) 4 | 5 | Core shared service used by Ambari managed components. (Infra Solr and Infra Manager) 6 | 7 | Ambari Infra is a sub-project of [Apache Ambari](https://github.com/apache/ambari) 8 | 9 | ## Development 10 | 11 | Requires JDK 8 12 | 13 | ### Build RPM package 14 | 15 | ```bash 16 | # requires rpm-build on Mac OS X 17 | make rpm 18 | ``` 19 | 20 | ### Build Deb package 21 | 22 | ```bash 23 | make deb 24 | ``` 25 | 26 | ## License 27 | 28 | - http://ambari.apache.org/license.html 29 | - See more at [Ambari repository](https://github.com/apache/ambari) 30 | -------------------------------------------------------------------------------- /ambari-infra-assembly/src/main/package/deb/manager/control: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License 15 | Package: [[infra-manager.package.name]] 16 | Version: [[package-version]]-[[package-release]] 17 | Section: [[deb.section]] 18 | Priority: [[deb.priority]] 19 | Depends: [[deb.dependency.list]] 20 | Architecture: [[deb.architecture]] 21 | Description: [[description]] 22 | Maintainer: [[deb.publisher]] -------------------------------------------------------------------------------- /ambari-infra-assembly/src/main/package/deb/manager/postinst: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License 16 | 17 | INFRA_MANAGER_LINK_NAME="/usr/bin/infra-manager" 18 | INFRA_MANAGER_SOURCE="/usr/lib/ambari-infra-manager/bin/infraManager.sh" 19 | INFRA_MANAGER_CONF_LINK_DIR="/etc/ambari-infra-manager" 20 | INFRA_MANAGER_CONF_LINK_NAME="$INFRA_MANAGER_CONF_LINK_DIR/conf" 21 | INFRA_MANAGER_CONF_SOURCE="/usr/lib/ambari-infra-manager/conf" 22 | 23 | rm -f $INFRA_MANAGER_LINK_NAME ; ln -s $INFRA_MANAGER_SOURCE $INFRA_MANAGER_LINK_NAME 24 | rm -f $INFRA_MANAGER_CONF_LINK_NAME 25 | rm -rf $INFRA_MANAGER_CONF_LINK_DIR 26 | mkdir -p $INFRA_MANAGER_CONF_LINK_DIR 27 | ln -s $INFRA_MANAGER_CONF_SOURCE $INFRA_MANAGER_CONF_LINK_NAME 28 | -------------------------------------------------------------------------------- /ambari-infra-assembly/src/main/package/deb/manager/postrm: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License 16 | 17 | INFRA_MANAGER_CONF_LINK_DIR="/etc/ambari-infra-manager" 18 | INFRA_MANAGER_CONF_LINK_NAME="$INFRA_MANAGER_CONF_LINK_DIR/conf" 19 | INFRA_MANAGER_LINK_NAME="/usr/bin/infra-manager" 20 | 21 | rm -f $INFRA_MANAGER_LINK_NAME 22 | rm -f $INFRA_MANAGER_CONF_LINK_NAME 23 | rm -rf $INFRA_MANAGER_CONF_LINK_DIR -------------------------------------------------------------------------------- /ambari-infra-assembly/src/main/package/deb/manager/preinst: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License 16 | -------------------------------------------------------------------------------- /ambari-infra-assembly/src/main/package/deb/manager/prerm: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License 16 | -------------------------------------------------------------------------------- /ambari-infra-assembly/src/main/package/deb/solr-client/control: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License 15 | Package: [[solr.client.package.name]] 16 | Version: [[package-version]]-[[package-release]] 17 | Section: [[deb.section]] 18 | Priority: [[deb.priority]] 19 | Depends: [[deb.dependency.list]] 20 | Architecture: [[deb.architecture]] 21 | Description: [[description]] 22 | Maintainer: [[deb.publisher]] 23 | -------------------------------------------------------------------------------- /ambari-infra-assembly/src/main/package/deb/solr-client/postinst: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License 16 | 17 | SOLR_CLOUD_CLI_LINK_NAME="/usr/bin/infra-solr-cloud-cli" 18 | SOLR_CLOUD_CLI_SOURCE="/usr/lib/ambari-infra-solr-client/solrCloudCli.sh" 19 | 20 | SOLR_INDEX_TOOL_LINK_NAME="/usr/bin/infra-lucene-index-tool" 21 | SOLR_INDEX_TOOL_SOURCE="/usr/lib/ambari-infra-solr-client/solrIndexHelper.sh" 22 | 23 | SOLR_DATA_MANAGER_LINK_NAME="/usr/bin/infra-solr-data-manager" 24 | SOLR_DATA_MANAGER_SOURCE="/usr/lib/ambari-infra-solr-client/solrDataManager.py" 25 | 26 | rm -f $SOLR_CLOUD_CLI_LINK_NAME ; ln -s $SOLR_CLOUD_CLI_SOURCE $SOLR_CLOUD_CLI_LINK_NAME 27 | rm -f $SOLR_INDEX_TOOL_LINK_NAME ; ln -s $SOLR_INDEX_TOOL_SOURCE $SOLR_INDEX_TOOL_LINK_NAME 28 | rm -f $SOLR_DATA_MANAGER_LINK_NAME ; ln -s $SOLR_DATA_MANAGER_SOURCE $SOLR_DATA_MANAGER_LINK_NAME -------------------------------------------------------------------------------- /ambari-infra-assembly/src/main/package/deb/solr-client/postrm: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License 16 | -------------------------------------------------------------------------------- /ambari-infra-assembly/src/main/package/deb/solr-client/preinst: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License 16 | -------------------------------------------------------------------------------- /ambari-infra-assembly/src/main/package/deb/solr-client/prerm: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License 16 | -------------------------------------------------------------------------------- /ambari-infra-assembly/src/main/package/deb/solr/control: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License 15 | Package: [[solr.package.name]] 16 | Version: [[package-version]]-[[package-release]] 17 | Section: [[deb.section]] 18 | Priority: [[deb.priority]] 19 | Depends: [[deb.dependency.list]] 20 | Architecture: [[deb.architecture]] 21 | Description: [[description]] 22 | Maintainer: [[deb.publisher]] 23 | -------------------------------------------------------------------------------- /ambari-infra-assembly/src/main/package/deb/solr/postinst: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License 16 | -------------------------------------------------------------------------------- /ambari-infra-assembly/src/main/package/deb/solr/postrm: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License 16 | -------------------------------------------------------------------------------- /ambari-infra-assembly/src/main/package/deb/solr/preinst: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License 16 | -------------------------------------------------------------------------------- /ambari-infra-assembly/src/main/package/deb/solr/prerm: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License 16 | -------------------------------------------------------------------------------- /ambari-infra-assembly/src/main/package/rpm/manager/postinstall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License 16 | 17 | INFRA_MANAGER_LINK_NAME="/usr/bin/infra-manager" 18 | INFRA_MANAGER_SOURCE="/usr/lib/ambari-infra-manager/bin/infraManager.sh" 19 | INFRA_MANAGER_CONF_LINK_DIR="/etc/ambari-infra-manager" 20 | INFRA_MANAGER_CONF_LINK_NAME="$INFRA_MANAGER_CONF_LINK_DIR/conf" 21 | INFRA_MANAGER_CONF_SOURCE="/usr/lib/ambari-infra-manager/conf" 22 | 23 | rm -f $INFRA_MANAGER_LINK_NAME ; ln -s $INFRA_MANAGER_SOURCE $INFRA_MANAGER_LINK_NAME 24 | rm -f $INFRA_MANAGER_CONF_LINK_NAME 25 | rm -rf $INFRA_MANAGER_CONF_LINK_DIR 26 | mkdir -p $INFRA_MANAGER_CONF_LINK_DIR 27 | ln -s $INFRA_MANAGER_CONF_SOURCE $INFRA_MANAGER_CONF_LINK_NAME 28 | -------------------------------------------------------------------------------- /ambari-infra-assembly/src/main/package/rpm/manager/postremove.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License 16 | 17 | INFRA_MANAGER_CONF_LINK_DIR="/etc/ambari-infra-manager" 18 | INFRA_MANAGER_CONF_LINK_NAME="$INFRA_MANAGER_CONF_LINK_DIR/conf" 19 | INFRA_MANAGER_LINK_NAME="/usr/bin/infra-manager" 20 | 21 | rm -f $INFRA_MANAGER_LINK_NAME 22 | rm -f $INFRA_MANAGER_CONF_LINK_NAME 23 | rm -rf $INFRA_MANAGER_CONF_LINK_DIR -------------------------------------------------------------------------------- /ambari-infra-assembly/src/main/package/rpm/solr-client/postinstall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License 16 | 17 | SOLR_CLOUD_CLI_LINK_NAME="/usr/bin/infra-solr-cloud-cli" 18 | SOLR_CLOUD_CLI_SOURCE="/usr/lib/ambari-infra-solr-client/solrCloudCli.sh" 19 | 20 | SOLR_INDEX_TOOL_LINK_NAME="/usr/bin/infra-lucene-index-tool" 21 | SOLR_INDEX_TOOL_SOURCE="/usr/lib/ambari-infra-solr-client/solrIndexHelper.sh" 22 | 23 | SOLR_DATA_MANAGER_LINK_NAME="/usr/bin/infra-solr-data-manager" 24 | SOLR_DATA_MANAGER_SOURCE="/usr/lib/ambari-infra-solr-client/solrDataManager.py" 25 | 26 | rm -f $SOLR_CLOUD_CLI_LINK_NAME ; ln -s $SOLR_CLOUD_CLI_SOURCE $SOLR_CLOUD_CLI_LINK_NAME 27 | rm -f $SOLR_INDEX_TOOL_LINK_NAME ; ln -s $SOLR_INDEX_TOOL_SOURCE $SOLR_INDEX_TOOL_LINK_NAME 28 | rm -f $SOLR_DATA_MANAGER_LINK_NAME ; ln -s $SOLR_DATA_MANAGER_SOURCE $SOLR_DATA_MANAGER_LINK_NAME -------------------------------------------------------------------------------- /ambari-infra-manager-it/src/test/java/org/apache/ambari/infra/HttpResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra; 20 | 21 | public class HttpResponse { 22 | private final int code; 23 | private final String body; 24 | 25 | public HttpResponse(int code, String body) { 26 | this.code = code; 27 | this.body = body; 28 | } 29 | 30 | public int getCode() { 31 | return code; 32 | } 33 | 34 | public String getBody() { 35 | return body; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /ambari-infra-manager-it/src/test/java/org/apache/ambari/infra/JobExecutionInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra; 20 | 21 | public class JobExecutionInfo { 22 | private final String jobId; 23 | private final String executionId; 24 | 25 | public JobExecutionInfo(String jobId, String executionId) { 26 | this.jobId = jobId; 27 | this.executionId = executionId; 28 | } 29 | 30 | public String getJobId() { 31 | return jobId; 32 | } 33 | 34 | public String getExecutionId() { 35 | return executionId; 36 | } 37 | 38 | @Override 39 | public String toString() { 40 | return "JobExecutionInfo{" + 41 | "jobId='" + jobId + '\'' + 42 | ", executionId='" + executionId + '\'' + 43 | '}'; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /ambari-infra-manager-it/src/test/java/org/apache/ambari/infra/OffsetDateTimeConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra; 20 | 21 | import org.jbehave.core.steps.ParameterConverters; 22 | 23 | import java.lang.reflect.Type; 24 | import java.time.OffsetDateTime; 25 | import java.time.format.DateTimeFormatter; 26 | 27 | public class OffsetDateTimeConverter implements ParameterConverters.ParameterConverter { 28 | public static final DateTimeFormatter SOLR_DATETIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSX"); 29 | 30 | @Override 31 | public boolean accept(Type type) { 32 | return type instanceof Class && OffsetDateTime.class.isAssignableFrom((Class) type); 33 | } 34 | 35 | @Override 36 | public Object convertValue(String value, Type type) { 37 | return OffsetDateTime.parse(value, SOLR_DATETIME_FORMATTER); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /ambari-infra-manager-it/src/test/resources/conf/core-site.xml: -------------------------------------------------------------------------------- 1 | 17 | 18 | 19 | fs.defaultFS 20 | s3a://testbucket 21 | 22 | 23 | fs.s3a.endpoint 24 | http://fakes3:4569 25 | 26 | 27 | fs.s3a.access.key 28 | MyAccessKey 29 | 30 | 31 | fs.s3a.secret.key 32 | MySecretKey 33 | 34 | 35 | fs.s3a.path.style.access 36 | true 37 | 38 | 39 | fs.s3a.multiobjectdelete.enable 40 | false 41 | 42 | -------------------------------------------------------------------------------- /ambari-infra-manager-it/src/test/resources/conf/hdfs-site.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | dfs.namenode.rpc-addressnamenode:9000 20 | dfs.replication1 21 | 22 | -------------------------------------------------------------------------------- /ambari-infra-manager-it/src/test/resources/log4j2-test.properties: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | status = error 14 | dest = err 15 | name = PropertiesConfig 16 | 17 | appender.console.type = Console 18 | appender.console.name = STDOUT 19 | appender.console.layout.type = PatternLayout 20 | appender.console.layout.pattern = %d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n 21 | appender.console.filter.threshold.type = ThresholdFilter 22 | appender.console.filter.threshold.level = info 23 | 24 | rootLogger.level = info 25 | rootLogger.appenderRef.stdout.ref = STDOUT 26 | -------------------------------------------------------------------------------- /ambari-infra-manager/.gitignore: -------------------------------------------------------------------------------- 1 | out/* 2 | *.pid 3 | Profile 4 | .env 5 | test-out 6 | test.db 7 | **/swagger/swagger.json 8 | **/swagger/swagger.yaml -------------------------------------------------------------------------------- /ambari-infra-manager/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | FROM centos:centos6 14 | 15 | RUN echo root:changeme | chpasswd 16 | 17 | RUN yum clean all -y && yum update -y 18 | RUN yum -y install vim wget rpm-build sudo which telnet tar openssh-server openssh-clients ntp git httpd lsof 19 | RUN rpm -e --nodeps --justdb glibc-common 20 | RUN yum -y install glibc-common 21 | 22 | ENV HOME /root 23 | 24 | #Install JAVA 25 | ENV JAVA_VERSION 11.0.1 26 | ENV BUILD_VERSION 13 27 | 28 | RUN wget --no-check-certificate --no-cookies --header "Cookie:oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/$JAVA_VERSION+$BUILD_VERSION/90cf5d8f270a4347a95050320eef3fb7/jdk-${JAVA_VERSION}_linux-x64_bin.rpm -O jdk-11-linux-x64.rpm 29 | RUN rpm -ivh jdk-11-linux-x64.rpm 30 | ENV JAVA_HOME /usr/java/default/ 31 | 32 | #Install Maven 33 | RUN mkdir -p /opt/maven 34 | WORKDIR /opt/maven 35 | RUN wget http://archive.apache.org/dist/maven/maven-3/3.3.1/binaries/apache-maven-3.3.1-bin.tar.gz 36 | RUN tar -xvzf /opt/maven/apache-maven-3.3.1-bin.tar.gz 37 | RUN rm -rf /opt/maven/apache-maven-3.3.1-bin.tar.gz 38 | 39 | ENV M2_HOME /opt/maven/apache-maven-3.3.1 40 | ENV MAVEN_OPTS -Xmx2048m 41 | ENV PATH $PATH:$JAVA_HOME/bin:$M2_HOME/bin 42 | 43 | # SSH key 44 | RUN ssh-keygen -f /root/.ssh/id_rsa -t rsa -N '' 45 | RUN cat /root/.ssh/id_rsa.pub > /root/.ssh/authorized_keys 46 | RUN chmod 600 /root/.ssh/authorized_keys 47 | RUN sed -ri 's/UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config 48 | 49 | ADD bin/start.sh /root/start.sh 50 | RUN chmod +x /root/start.sh 51 | 52 | WORKDIR /root 53 | CMD /root/start.sh -------------------------------------------------------------------------------- /ambari-infra-manager/docker/bin/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License 16 | 17 | export INFRA_MANAGER_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,address=5007,server=y,suspend=n" 18 | touch /root/infra-manager.log 19 | /root/ambari-infra-manager/bin/infraManager.sh start > /root/infra-manager.log 20 | tail -f /root/infra-manager.log 21 | 22 | -------------------------------------------------------------------------------- /ambari-infra-manager/docs/images/batch-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/ambari-infra/cc48de866cf5e0a2c71b7f190cba91390b3d1339/ambari-infra-manager/docs/images/batch-1.png -------------------------------------------------------------------------------- /ambari-infra-manager/docs/images/batch-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/ambari-infra/cc48de866cf5e0a2c71b7f190cba91390b3d1339/ambari-infra-manager/docs/images/batch-2.png -------------------------------------------------------------------------------- /ambari-infra-manager/docs/images/batch-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/ambari-infra/cc48de866cf5e0a2c71b7f190cba91390b3d1339/ambari-infra-manager/docs/images/batch-3.png -------------------------------------------------------------------------------- /ambari-infra-manager/docs/images/batch-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/ambari-infra/cc48de866cf5e0a2c71b7f190cba91390b3d1339/ambari-infra-manager/docs/images/batch-4.png -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/conf/InfraManagerConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.conf; 20 | 21 | import org.springframework.context.annotation.Bean; 22 | import org.springframework.context.annotation.ComponentScan; 23 | import org.springframework.context.annotation.Configuration; 24 | import org.springframework.context.annotation.PropertySource; 25 | import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; 26 | 27 | @Configuration 28 | @ComponentScan("org.apache.ambari.infra") 29 | @PropertySource(value = {"classpath:infra-manager.properties"}) 30 | public class InfraManagerConfig { 31 | 32 | @Bean 33 | public static PropertySourcesPlaceholderConfigurer propertyConfigurer() { 34 | PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer(); 35 | propertySourcesPlaceholderConfigurer.setNullValue("@null"); 36 | return propertySourcesPlaceholderConfigurer; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/conf/InfraManagerDataConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.conf; 20 | 21 | import org.springframework.beans.factory.annotation.Value; 22 | import org.springframework.context.annotation.Configuration; 23 | 24 | @Configuration 25 | public class InfraManagerDataConfig { 26 | 27 | @Value("${infra-manager.server.data.folder:/opt/ambari-infra-manager/data}") 28 | private String dataFolder; 29 | 30 | public String getDataFolder() { 31 | return dataFolder; 32 | } 33 | 34 | public void setDataFolder(String dataFolder) { 35 | this.dataFolder = dataFolder; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/conf/InfraManagerJerseyResourceConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.conf; 20 | 21 | import javax.ws.rs.ApplicationPath; 22 | 23 | import org.apache.ambari.infra.rest.JobResource; 24 | import org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJaxbJsonProvider; 25 | import org.glassfish.jersey.server.ResourceConfig; 26 | import org.glassfish.jersey.servlet.ServletProperties; 27 | 28 | @ApplicationPath("/api/v1") 29 | public class InfraManagerJerseyResourceConfig extends ResourceConfig { 30 | 31 | public InfraManagerJerseyResourceConfig() { 32 | packages(JobResource.class.getPackage().getName()); 33 | register(JacksonJaxbJsonProvider.class); 34 | property(ServletProperties.FILTER_FORWARD_ON_404, true); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/conf/InfraManagerSchedulingConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.conf; 20 | 21 | import org.springframework.context.annotation.Bean; 22 | import org.springframework.context.annotation.Configuration; 23 | import org.springframework.scheduling.TaskScheduler; 24 | import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; 25 | 26 | @Configuration 27 | public class InfraManagerSchedulingConfig { 28 | @Bean 29 | public TaskScheduler taskScheduler() { 30 | return new ThreadPoolTaskScheduler(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/conf/StaticResourceConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.conf; 20 | 21 | import org.springframework.context.annotation.Configuration; 22 | import org.springframework.web.servlet.config.annotation.EnableWebMvc; 23 | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; 24 | import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; 25 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 26 | 27 | @EnableWebMvc 28 | @Configuration 29 | public class StaticResourceConfiguration implements WebMvcConfigurer { 30 | 31 | private static final String[] CLASSPATH_RESOURCE_LOCATIONS = { 32 | "classpath:/static/", "classpath:/swagger/","classpath:META-INF/resources/webjars/" 33 | }; 34 | 35 | @Override 36 | public void addResourceHandlers(ResourceHandlerRegistry registry) { 37 | registry.addResourceHandler("/**") 38 | .addResourceLocations(CLASSPATH_RESOURCE_LOCATIONS); 39 | } 40 | 41 | @Override 42 | public void addViewControllers(ViewControllerRegistry registry) { 43 | registry.addViewController("/").setViewName( 44 | "forward:/index.html"); 45 | registry.addViewController("/docs").setViewName( 46 | "forward:/swagger.html"); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/conf/security/CompositeSecret.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.conf.security; 20 | 21 | import java.util.Optional; 22 | 23 | public class CompositeSecret implements Secret { 24 | private Secret[] secrets; 25 | 26 | public CompositeSecret(Secret... secrets) { 27 | this.secrets = secrets; 28 | } 29 | 30 | @Override 31 | public Optional get() { 32 | for (Secret secret : secrets) { 33 | Optional optionalPassword = secret.get(); 34 | if (optionalPassword.isPresent()) 35 | return optionalPassword; 36 | } 37 | return Optional.empty(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/conf/security/EnvironmentalSecret.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.conf.security; 20 | 21 | import java.util.Optional; 22 | 23 | public class EnvironmentalSecret implements Secret { 24 | 25 | private final String environmentalVariableName; 26 | 27 | public EnvironmentalSecret(String environmentalVariableName) { 28 | this.environmentalVariableName = environmentalVariableName; 29 | } 30 | 31 | @Override 32 | public Optional get() { 33 | return Optional.ofNullable(System.getenv(environmentalVariableName)); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/conf/security/HadoopCredential.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.conf.security; 20 | 21 | import java.util.Optional; 22 | 23 | public class HadoopCredential implements Secret { 24 | 25 | private final HadoopCredentialStore hadoopCredentialStore; 26 | private final String propertyName; 27 | 28 | public HadoopCredential(HadoopCredentialStore hadoopCredentialStore, String propertyName) { 29 | this.propertyName = propertyName; 30 | this.hadoopCredentialStore = hadoopCredentialStore; 31 | } 32 | 33 | @Override 34 | public Optional get() { 35 | if (hadoopCredentialStore == null) { 36 | return Optional.empty(); 37 | } 38 | 39 | return hadoopCredentialStore.get(propertyName).map(String::new); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/conf/security/Secret.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.conf.security; 20 | 21 | import java.util.Optional; 22 | 23 | public interface Secret { 24 | Optional get(); 25 | } 26 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/conf/security/SecretStoreConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.conf.security; 20 | 21 | import static org.apache.ambari.infra.conf.security.HadoopCredentialStore.CREDENTIAL_STORE_PROVIDER_PATH_PROPERTY; 22 | 23 | import org.springframework.beans.factory.annotation.Value; 24 | import org.springframework.context.annotation.Bean; 25 | import org.springframework.context.annotation.Configuration; 26 | 27 | @Configuration 28 | public class SecretStoreConfig { 29 | 30 | @Value("${"+ CREDENTIAL_STORE_PROVIDER_PATH_PROPERTY + ":}") 31 | private String credentialStoreProviderPath; 32 | 33 | @Bean 34 | public HadoopCredentialStore hadoopCredentialStore() { 35 | return new HadoopCredentialStore(credentialStoreProviderPath); 36 | } 37 | 38 | @Bean 39 | public SslSecrets sslSecrets(HadoopCredentialStore hadoopCredentialStore) { 40 | return new SslSecrets( 41 | hadoopCredentialStore.getSecret("infra_manager_keystore_password"), 42 | hadoopCredentialStore.getSecret("infra_manager_truststore_password")); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/conf/security/SslSecrets.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.conf.security; 20 | 21 | public class SslSecrets { 22 | private final Secret keyStorePassword; 23 | private final Secret trustStorePassword; 24 | 25 | public SslSecrets(Secret keyStorePassword, Secret trustStorePassword) { 26 | this.keyStorePassword = keyStorePassword; 27 | this.trustStorePassword = trustStorePassword; 28 | } 29 | 30 | public Secret getKeyStorePassword() { 31 | return keyStorePassword; 32 | } 33 | 34 | public Secret getTrustStorePassword() { 35 | return trustStorePassword; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/job/CloseableIterator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.job; 20 | 21 | import java.util.Iterator; 22 | 23 | public interface CloseableIterator extends Iterator, AutoCloseable { 24 | } 25 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/job/JobConfigurationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.job; 20 | 21 | public class JobConfigurationException extends RuntimeException { 22 | public JobConfigurationException(String message, Exception ex) { 23 | super(message, ex); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/job/JobContextRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.job; 20 | 21 | import org.springframework.batch.core.StepExecution; 22 | 23 | public interface JobContextRepository { 24 | StepExecution getStepExecution(Long jobExecutionId, Long id); 25 | void updateExecutionContext(StepExecution stepExecution); 26 | } 27 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/job/JobContextRepositoryImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.job; 20 | 21 | import org.springframework.batch.admin.service.JobService; 22 | import org.springframework.batch.admin.service.NoSuchStepExecutionException; 23 | import org.springframework.batch.core.StepExecution; 24 | import org.springframework.batch.core.launch.NoSuchJobExecutionException; 25 | import org.springframework.batch.core.repository.JobRepository; 26 | 27 | import javax.inject.Inject; 28 | import javax.inject.Named; 29 | 30 | @Named 31 | public class JobContextRepositoryImpl implements JobContextRepository { 32 | 33 | @Inject 34 | private JobRepository jobRepository; 35 | @Inject 36 | private JobService jobService; 37 | 38 | 39 | @Override 40 | public StepExecution getStepExecution(Long jobExecutionId, Long id) { 41 | try { 42 | return jobService.getStepExecution(jobExecutionId, id); 43 | } catch (NoSuchStepExecutionException | NoSuchJobExecutionException e) { 44 | throw new RuntimeException(e); 45 | } 46 | } 47 | 48 | @Override 49 | public void updateExecutionContext(StepExecution stepExecution) { 50 | jobRepository.updateExecutionContext(stepExecution); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/job/JobProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.job; 20 | 21 | import java.util.Optional; 22 | 23 | import org.springframework.batch.core.JobParameters; 24 | 25 | public abstract class JobProperties { 26 | 27 | private SchedulingProperties scheduling; 28 | private boolean enabled; 29 | 30 | public SchedulingProperties getScheduling() { 31 | return scheduling; 32 | } 33 | 34 | public Optional scheduling() { 35 | if (scheduling != null && scheduling.isEnabled()) 36 | return Optional.of(scheduling); 37 | return Optional.empty(); 38 | } 39 | 40 | public void setScheduling(SchedulingProperties scheduling) { 41 | this.scheduling = scheduling; 42 | } 43 | 44 | public abstract TParameters merge(JobParameters jobParameters); 45 | 46 | public void validate(String jobName) { 47 | try { 48 | merge(new JobParameters()).validate(); 49 | } 50 | catch (Exception ex) { 51 | throw new JobConfigurationException(String.format("Configuration of job %s is invalid: %s!", jobName, ex.getMessage()), ex); 52 | } 53 | } 54 | 55 | public boolean isEnabled() { 56 | return enabled; 57 | } 58 | 59 | public void setEnabled(boolean enabled) { 60 | this.enabled = enabled; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/job/JobPropertiesHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.job; 20 | 21 | import static org.apache.ambari.infra.job.JobsPropertyMap.PARAMETERS_CONTEXT_KEY; 22 | 23 | import org.springframework.batch.core.ExitStatus; 24 | import org.springframework.batch.core.JobExecution; 25 | import org.springframework.batch.core.JobExecutionListener; 26 | 27 | public class JobPropertiesHolder 28 | implements JobExecutionListener { 29 | 30 | private final JobProperties defaultProperties; 31 | 32 | public JobPropertiesHolder(JobProperties defaultProperties) { 33 | this.defaultProperties = defaultProperties; 34 | } 35 | 36 | @Override 37 | public void beforeJob(JobExecution jobExecution) { 38 | try { 39 | T parameters = defaultProperties.merge(jobExecution.getJobParameters()); 40 | parameters.validate(); 41 | jobExecution.getExecutionContext().put(PARAMETERS_CONTEXT_KEY, parameters); 42 | } 43 | catch (UnsupportedOperationException | IllegalArgumentException ex) { 44 | jobExecution.stop(); 45 | jobExecution.setExitStatus(new ExitStatus(ExitStatus.FAILED.getExitCode(), ex.getMessage())); 46 | throw ex; 47 | } 48 | } 49 | 50 | @Override 51 | public void afterJob(JobExecution jobExecution) { 52 | 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/job/JobsPropertyMap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.job; 20 | 21 | import java.util.Map; 22 | 23 | import org.springframework.batch.core.JobExecution; 24 | import org.springframework.batch.core.JobExecutionListener; 25 | 26 | public class JobsPropertyMap, TParameters extends Validatable> 27 | implements JobExecutionListener { 28 | 29 | public static final String PARAMETERS_CONTEXT_KEY = "jobParameters"; 30 | private final Map propertyMap; 31 | 32 | public JobsPropertyMap(Map propertyMap) { 33 | this.propertyMap = propertyMap; 34 | } 35 | 36 | @Override 37 | public void beforeJob(JobExecution jobExecution) { 38 | String jobName = jobExecution.getJobInstance().getJobName(); 39 | TProperties defaultProperties = propertyMap.get(jobName); 40 | if (defaultProperties == null) 41 | throw new UnsupportedOperationException("Properties not found for job " + jobName); 42 | 43 | new JobPropertiesHolder<>(defaultProperties).beforeJob(jobExecution); 44 | } 45 | 46 | @Override 47 | public void afterJob(JobExecution jobExecution) { 48 | 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/job/ObjectSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.job; 20 | 21 | public interface ObjectSource { 22 | CloseableIterator open(T current, int rows); 23 | } 24 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/job/SchedulingProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.job; 20 | 21 | public class SchedulingProperties { 22 | private boolean enabled = false; 23 | private String cron; 24 | 25 | public boolean isEnabled() { 26 | return enabled; 27 | } 28 | 29 | public void setEnabled(boolean enabled) { 30 | this.enabled = enabled; 31 | } 32 | 33 | public String getCron() { 34 | return cron; 35 | } 36 | 37 | public void setCron(String cron) { 38 | this.cron = cron; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/job/Validatable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.job; 20 | 21 | public interface Validatable { 22 | void validate(); 23 | } 24 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/job/archive/AbstractFileAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.job.archive; 20 | 21 | import java.io.File; 22 | 23 | import org.apache.logging.log4j.LogManager; 24 | import org.apache.logging.log4j.Logger; 25 | 26 | public abstract class AbstractFileAction implements FileAction { 27 | private static final Logger logger = LogManager.getLogger(AbstractFileAction.class); 28 | 29 | @Override 30 | public File perform(File inputFile) { 31 | File outputFile = onPerform(inputFile); 32 | if (!inputFile.delete()) 33 | logger.warn("File {} was not deleted. Exists: {}", inputFile.getAbsolutePath(), inputFile.exists()); 34 | return outputFile; 35 | } 36 | 37 | protected abstract File onPerform(File inputFile); 38 | } 39 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/job/archive/BZip2Compressor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.job.archive; 20 | 21 | import java.io.File; 22 | import java.io.FileInputStream; 23 | import java.io.FileOutputStream; 24 | import java.io.IOException; 25 | import java.io.UncheckedIOException; 26 | 27 | import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream; 28 | import org.apache.commons.io.IOUtils; 29 | 30 | public class BZip2Compressor extends AbstractFileAction { 31 | @Override 32 | protected File onPerform(File inputFile) { 33 | File bz2File = new File(inputFile.getParent(), inputFile.getName() + ".bz2"); 34 | try (BZip2CompressorOutputStream bZip2CompressorOutputStream = new BZip2CompressorOutputStream(new FileOutputStream(bz2File))) { 35 | try (FileInputStream fileInputStream = new FileInputStream(inputFile)) { 36 | IOUtils.copy(fileInputStream, bZip2CompressorOutputStream); 37 | } 38 | } 39 | catch (IOException ex) { 40 | throw new UncheckedIOException(ex); 41 | } 42 | return bz2File; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/job/archive/CompositeFileAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.job.archive; 20 | 21 | import java.io.File; 22 | import java.util.ArrayList; 23 | import java.util.List; 24 | 25 | import static java.util.Arrays.asList; 26 | 27 | public class CompositeFileAction implements FileAction { 28 | 29 | private final List actions; 30 | 31 | public CompositeFileAction(FileAction... actions) { 32 | this.actions = new ArrayList<>(asList(actions)); 33 | } 34 | 35 | public void add(FileAction action) { 36 | actions.add(action); 37 | } 38 | 39 | @Override 40 | public File perform(File inputFile) { 41 | File file = inputFile; 42 | for (FileAction action : actions) { 43 | file = action.perform(file); 44 | } 45 | return file; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/job/archive/Document.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.job.archive; 20 | 21 | import static java.util.Collections.unmodifiableMap; 22 | 23 | import java.util.HashMap; 24 | import java.util.Map; 25 | 26 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 27 | import com.fasterxml.jackson.annotation.JsonAnySetter; 28 | 29 | public class Document { 30 | private final Map fieldMap; 31 | 32 | private Document() { 33 | fieldMap = new HashMap<>(); 34 | } 35 | 36 | public Document(Map fieldMap) { 37 | this.fieldMap = unmodifiableMap(fieldMap); 38 | } 39 | 40 | public String getString(String key) { 41 | Object value = fieldMap.get(key); 42 | return value == null ? null : value.toString(); 43 | } 44 | 45 | @JsonAnyGetter 46 | public Map getFieldMap() { 47 | return fieldMap; 48 | } 49 | 50 | @JsonAnySetter 51 | private void put(String key, Object value) { 52 | fieldMap.put(key, value); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/job/archive/DocumentArchivingPropertyMap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.job.archive; 20 | 21 | import java.util.Map; 22 | 23 | import org.springframework.boot.context.properties.ConfigurationProperties; 24 | import org.springframework.context.annotation.Configuration; 25 | 26 | @Configuration 27 | @ConfigurationProperties(prefix = "infra-manager.jobs") 28 | public class DocumentArchivingPropertyMap { 29 | private Map solrDataArchiving; 30 | 31 | public Map getSolrDataArchiving() { 32 | return solrDataArchiving; 33 | } 34 | 35 | public void setSolrDataArchiving(Map solrDataArchiving) { 36 | this.solrDataArchiving = solrDataArchiving; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/job/archive/DocumentDestination.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.job.archive; 20 | 21 | public interface DocumentDestination { 22 | DocumentItemWriter open(Document firstDocument); 23 | } 24 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/job/archive/DocumentItemWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.job.archive; 20 | 21 | public interface DocumentItemWriter { 22 | void write(Document document); 23 | void revert(); 24 | void close(); 25 | } 26 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/job/archive/DocumentWiper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.job.archive; 20 | 21 | public interface DocumentWiper { 22 | void delete(Document firstDocument, Document lastDocument); 23 | } 24 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/job/archive/ExportDestination.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.job.archive; 20 | 21 | public enum ExportDestination { 22 | LOCAL, 23 | HDFS 24 | } 25 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/job/archive/FileAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.job.archive; 20 | 21 | import java.io.File; 22 | 23 | public interface FileAction { 24 | File perform(File inputFile); 25 | } 26 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/job/archive/ItemWriterListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.job.archive; 20 | 21 | public interface ItemWriterListener { 22 | void onCompleted(WriteCompletedEvent event); 23 | } 24 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/job/archive/LocalItemWriterListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.job.archive; 20 | 21 | public class LocalItemWriterListener implements ItemWriterListener { 22 | private final FileAction fileAction; 23 | private final DocumentWiper documentWiper; 24 | 25 | public LocalItemWriterListener(FileAction fileAction, DocumentWiper documentWiper) { 26 | this.fileAction = fileAction; 27 | this.documentWiper = documentWiper; 28 | } 29 | 30 | 31 | @Override 32 | public void onCompleted(WriteCompletedEvent event) { 33 | fileAction.perform(event.getOutFile()); 34 | documentWiper.delete(event.getFirstDocument(), event.getLastDocument()); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/job/archive/SolrDocumentSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.job.archive; 20 | 21 | import org.apache.ambari.infra.job.CloseableIterator; 22 | import org.apache.ambari.infra.job.ObjectSource; 23 | 24 | public class SolrDocumentSource implements ObjectSource { 25 | private final SolrDAO solrDAO; 26 | private final String start; 27 | private final String end; 28 | 29 | public SolrDocumentSource(SolrDAO solrDAO, String start, String end) { 30 | this.solrDAO = solrDAO; 31 | this.start = start; 32 | this.end = end; 33 | } 34 | 35 | @Override 36 | public CloseableIterator open(Document current, int rows) { 37 | return solrDAO.query(start, end, current, rows); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/job/archive/TarGzCompressor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.job.archive; 20 | 21 | import org.apache.commons.compress.archivers.tar.TarArchiveEntry; 22 | import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream; 23 | import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream; 24 | import org.apache.commons.io.IOUtils; 25 | 26 | import java.io.*; 27 | 28 | public class TarGzCompressor extends AbstractFileAction { 29 | @Override 30 | public File onPerform(File inputFile) { 31 | File tarGzFile = new File(inputFile.getParent(), inputFile.getName() + ".tar.gz"); 32 | try (TarArchiveOutputStream tarArchiveOutputStream = new TarArchiveOutputStream( 33 | new GzipCompressorOutputStream(new FileOutputStream(tarGzFile)))) { 34 | TarArchiveEntry archiveEntry = new TarArchiveEntry(inputFile.getName()); 35 | archiveEntry.setSize(inputFile.length()); 36 | tarArchiveOutputStream.putArchiveEntry(archiveEntry); 37 | 38 | try (FileInputStream fileInputStream = new FileInputStream(inputFile)) { 39 | IOUtils.copy(fileInputStream, tarArchiveOutputStream); 40 | } 41 | 42 | tarArchiveOutputStream.closeArchiveEntry(); 43 | } 44 | catch (IOException ex) { 45 | throw new UncheckedIOException(ex); 46 | } 47 | 48 | return tarGzFile; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/job/archive/WriteCompletedEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.job.archive; 20 | 21 | import java.io.File; 22 | 23 | public class WriteCompletedEvent { 24 | private final File outFile; 25 | private final Document firstDocument; 26 | private final Document lastDocument; 27 | 28 | public WriteCompletedEvent(File outFile, Document firstDocument, Document lastDocument) { 29 | this.outFile = outFile; 30 | this.firstDocument = firstDocument; 31 | this.lastDocument = lastDocument; 32 | } 33 | 34 | public File getOutFile() { 35 | return outFile; 36 | } 37 | 38 | public Document getFirstDocument() { 39 | return firstDocument; 40 | } 41 | 42 | public Document getLastDocument() { 43 | return lastDocument; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/job/deleting/DocumentDeletingPropertyMap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.job.deleting; 20 | 21 | import java.util.Map; 22 | 23 | import org.springframework.boot.context.properties.ConfigurationProperties; 24 | import org.springframework.context.annotation.Configuration; 25 | 26 | @Configuration 27 | @ConfigurationProperties(prefix = "infra-manager.jobs") 28 | public class DocumentDeletingPropertyMap { 29 | private Map solrDataDeleting; 30 | 31 | public Map getSolrDataDeleting() { 32 | return solrDataDeleting; 33 | } 34 | 35 | public void setSolrDataDeleting(Map solrDataDeleting) { 36 | this.solrDataDeleting = solrDataDeleting; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/job/dummy/DummyItemProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.job.dummy; 20 | 21 | import org.apache.logging.log4j.LogManager; 22 | import org.apache.logging.log4j.Logger; 23 | import org.springframework.batch.item.ItemProcessor; 24 | 25 | public class DummyItemProcessor implements ItemProcessor { 26 | 27 | private static final Logger logger = LogManager.getLogger(DummyItemProcessor.class); 28 | 29 | @Override 30 | public String process(DummyObject input) throws Exception { 31 | logger.info("Dummy processing, f1: {}, f2: {}. wait 10 seconds", input.getF1(), input.getF2()); 32 | Thread.sleep(10000); 33 | return String.format("%s, %s", input.getF1(), input.getF2()); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/job/dummy/DummyJobListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.job.dummy; 20 | 21 | import org.apache.logging.log4j.LogManager; 22 | import org.apache.logging.log4j.Logger; 23 | import org.springframework.batch.core.ExitStatus; 24 | import org.springframework.batch.core.JobExecution; 25 | import org.springframework.batch.core.JobExecutionListener; 26 | 27 | public class DummyJobListener implements JobExecutionListener { 28 | 29 | private static final Logger logger = LogManager.getLogger(DummyJobListener.class); 30 | 31 | @Override 32 | public void beforeJob(JobExecution jobExecution) { 33 | logger.info("Dummy - before job execution"); 34 | } 35 | 36 | @Override 37 | public void afterJob(JobExecution jobExecution) { 38 | logger.info("Dummy - after job execution"); 39 | if (jobExecution.getExecutionContext().get("jobOutputLocation") != null) { 40 | String jobOutputLocation = (String) jobExecution.getExecutionContext().get("jobOutputLocation"); 41 | String exitDescription = "file://" + jobOutputLocation; 42 | logger.info("Add exit description '{}'", exitDescription); 43 | jobExecution.setExitStatus(new ExitStatus(ExitStatus.COMPLETED.getExitCode(), exitDescription)); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/job/dummy/DummyObject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.job.dummy; 20 | 21 | public class DummyObject { 22 | private String f1; 23 | private String f2; 24 | 25 | public String getF1() { 26 | return f1; 27 | } 28 | 29 | public void setF1(String f1) { 30 | this.f1 = f1; 31 | } 32 | 33 | public String getF2() { 34 | return f2; 35 | } 36 | 37 | public void setF2(String f2) { 38 | this.f2 = f2; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/job/dummy/DummyStepListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.job.dummy; 20 | 21 | import org.apache.logging.log4j.LogManager; 22 | import org.apache.logging.log4j.Logger; 23 | import org.springframework.batch.core.ExitStatus; 24 | import org.springframework.batch.core.StepExecution; 25 | import org.springframework.batch.core.StepExecutionListener; 26 | 27 | public class DummyStepListener implements StepExecutionListener { 28 | 29 | private static final Logger logger = LogManager.getLogger(DummyStepListener.class); 30 | 31 | @Override 32 | public void beforeStep(StepExecution stepExecution) { 33 | logger.info("Dummy step - before step execution"); 34 | } 35 | 36 | @Override 37 | public ExitStatus afterStep(StepExecution stepExecution) { 38 | logger.info("Dummy step - after step execution"); 39 | return stepExecution.getExitStatus(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/json/DurationToStringConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.json; 20 | 21 | import java.time.Duration; 22 | 23 | import com.fasterxml.jackson.databind.util.StdConverter; 24 | 25 | public class DurationToStringConverter extends StdConverter { 26 | @Override 27 | public String convert(Duration value) { 28 | return toString(value); 29 | } 30 | 31 | public static String toString(Duration value) { 32 | return value == null ? null : value.toString(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/json/FsPermissionToStringConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.json; 20 | 21 | import org.apache.hadoop.fs.permission.FsPermission; 22 | 23 | import com.fasterxml.jackson.databind.util.StdConverter; 24 | 25 | public class FsPermissionToStringConverter extends StdConverter { 26 | @Override 27 | public String convert(FsPermission value) { 28 | return toString(value); 29 | } 30 | 31 | public static String toString(FsPermission value) { 32 | return value == null ? null : Short.toString(value.toOctal()); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/json/OffsetDateTimeToStringConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.json; 20 | 21 | import java.time.OffsetDateTime; 22 | import java.time.format.DateTimeFormatter; 23 | 24 | import com.fasterxml.jackson.databind.util.StdConverter; 25 | 26 | public class OffsetDateTimeToStringConverter extends StdConverter { 27 | 28 | @Override 29 | public String convert(OffsetDateTime value) { 30 | return DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(value); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/json/StringToDurationConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.json; 20 | 21 | import java.time.Duration; 22 | 23 | import javax.inject.Named; 24 | 25 | import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; 26 | import org.springframework.core.convert.converter.Converter; 27 | import org.springframework.lang.NonNull; 28 | 29 | import com.fasterxml.jackson.databind.util.StdConverter; 30 | 31 | @Named 32 | @ConfigurationPropertiesBinding 33 | public class StringToDurationConverter extends StdConverter implements Converter { 34 | @Override 35 | public Duration convert(@NonNull String value) { 36 | return toDuration(value); 37 | } 38 | 39 | public static Duration toDuration(String value) { 40 | return value == null ? null : Duration.parse(value); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/json/StringToFsPermissionConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.json; 20 | 21 | import static org.apache.commons.lang.StringUtils.isBlank; 22 | 23 | import javax.inject.Named; 24 | 25 | import org.apache.hadoop.fs.permission.FsPermission; 26 | import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; 27 | import org.springframework.core.convert.converter.Converter; 28 | import org.springframework.lang.NonNull; 29 | 30 | import com.fasterxml.jackson.databind.util.StdConverter; 31 | 32 | @Named 33 | @ConfigurationPropertiesBinding 34 | public class StringToFsPermissionConverter extends StdConverter implements Converter { 35 | @Override 36 | public FsPermission convert(@NonNull String value) { 37 | return toFsPermission(value); 38 | } 39 | 40 | public static FsPermission toFsPermission(String value) { 41 | return isBlank(value) ? null : new FsPermission(value); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/model/DateUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.model; 20 | 21 | import java.time.OffsetDateTime; 22 | import java.time.ZoneOffset; 23 | import java.util.Date; 24 | 25 | public class DateUtil { 26 | public static OffsetDateTime toOffsetDateTime(Date date) { 27 | if (date == null) 28 | return null; 29 | return date.toInstant().atOffset(ZoneOffset.UTC); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/model/ExecutionContextResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.model; 20 | 21 | import static java.util.Collections.unmodifiableMap; 22 | 23 | import java.util.Map; 24 | 25 | public class ExecutionContextResponse { 26 | 27 | private final Long jobExecutionId; 28 | private final Map executionContextMap; 29 | 30 | public ExecutionContextResponse(Long jobExecutionId, Map executionContextMap) { 31 | this.jobExecutionId = jobExecutionId; 32 | this.executionContextMap = unmodifiableMap(executionContextMap); 33 | } 34 | 35 | public Long getJobExecutionId() { 36 | return jobExecutionId; 37 | } 38 | 39 | public Map getExecutionContextMap() { 40 | return executionContextMap; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/model/ISO8601DateFormatter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.model; 20 | 21 | import java.text.DateFormat; 22 | import java.text.FieldPosition; 23 | import java.text.ParsePosition; 24 | import java.time.OffsetDateTime; 25 | import java.time.format.DateTimeFormatter; 26 | import java.util.Date; 27 | 28 | public class ISO8601DateFormatter extends DateFormat { 29 | @Override 30 | public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { 31 | toAppendTo.append(DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(DateUtil.toOffsetDateTime(date))); 32 | return toAppendTo; 33 | } 34 | 35 | @Override 36 | public Date parse(String source, ParsePosition pos) { 37 | OffsetDateTime offsetDateTime = OffsetDateTime.parse(source, DateTimeFormatter.ISO_OFFSET_DATE_TIME); 38 | pos.setIndex(pos.getIndex() + source.length()); 39 | return Date.from(offsetDateTime.toInstant()); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/model/JobExecutionDetailsResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.model; 20 | 21 | import static java.util.Collections.unmodifiableList; 22 | 23 | import java.util.List; 24 | 25 | import com.fasterxml.jackson.annotation.JsonProperty; 26 | 27 | public class JobExecutionDetailsResponse { 28 | 29 | @JsonProperty("jobExecution") 30 | private final JobExecutionInfoResponse jobExecutionInfoResponse; 31 | 32 | @JsonProperty("stepExecutionList") 33 | private final List stepExecutionInfoList; 34 | 35 | public JobExecutionDetailsResponse(JobExecutionInfoResponse jobExecutionInfoResponse, List stepExecutionInfoList) { 36 | this.jobExecutionInfoResponse = jobExecutionInfoResponse; 37 | this.stepExecutionInfoList = unmodifiableList(stepExecutionInfoList); 38 | } 39 | 40 | public JobExecutionInfoResponse getJobExecutionInfoResponse() { 41 | return jobExecutionInfoResponse; 42 | } 43 | 44 | public List getStepExecutionInfoList() { 45 | return stepExecutionInfoList; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/model/JobExecutionRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.model; 20 | 21 | import javax.ws.rs.PathParam; 22 | 23 | public class JobExecutionRequest { 24 | 25 | @PathParam("jobName") 26 | private String jobName; 27 | 28 | @PathParam("jobInstanceId") 29 | private Long jobInstanceId; 30 | 31 | public String getJobName() { 32 | return jobName; 33 | } 34 | 35 | public Long getJobInstanceId() { 36 | return jobInstanceId; 37 | } 38 | 39 | public void setJobName(String jobName) { 40 | this.jobName = jobName; 41 | } 42 | 43 | public void setJobInstanceId(Long jobInstanceId) { 44 | this.jobInstanceId = jobInstanceId; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/model/JobExecutionRestartRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.model; 20 | 21 | import javax.validation.constraints.NotNull; 22 | import javax.ws.rs.PathParam; 23 | import javax.ws.rs.QueryParam; 24 | 25 | import io.swagger.annotations.ApiParam; 26 | 27 | public class JobExecutionRestartRequest { 28 | 29 | @PathParam("jobName") 30 | @NotNull 31 | private String jobName; 32 | 33 | @PathParam("jobInstanceId") 34 | @NotNull 35 | private Long jobInstanceId; 36 | 37 | @QueryParam("operation") 38 | @NotNull 39 | @ApiParam(required = true) 40 | private JobOperationParams.JobRestartOperationParam operation; 41 | 42 | public String getJobName() { 43 | return jobName; 44 | } 45 | 46 | public void setJobName(String jobName) { 47 | this.jobName = jobName; 48 | } 49 | 50 | public Long getJobInstanceId() { 51 | return jobInstanceId; 52 | } 53 | 54 | public void setJobExecutionId(Long jobExecutionId) { 55 | this.jobInstanceId = jobExecutionId; 56 | } 57 | 58 | public JobOperationParams.JobRestartOperationParam getOperation() { 59 | return operation; 60 | } 61 | 62 | public void setOperation(JobOperationParams.JobRestartOperationParam operation) { 63 | this.operation = operation; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/model/JobExecutionStopRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.model; 20 | 21 | import javax.validation.constraints.NotNull; 22 | import javax.ws.rs.PathParam; 23 | import javax.ws.rs.QueryParam; 24 | 25 | import io.swagger.annotations.ApiParam; 26 | 27 | public class JobExecutionStopRequest { 28 | 29 | @PathParam("jobExecutionId") 30 | @NotNull 31 | private Long jobExecutionId; 32 | 33 | @QueryParam("operation") 34 | @NotNull 35 | @ApiParam(required = true) 36 | private JobOperationParams.JobStopOrAbandonOperationParam operation; 37 | 38 | public Long getJobExecutionId() { 39 | return jobExecutionId; 40 | } 41 | 42 | public void setJobExecutionId(Long jobExecutionId) { 43 | this.jobExecutionId = jobExecutionId; 44 | } 45 | 46 | public JobOperationParams.JobStopOrAbandonOperationParam getOperation() { 47 | return operation; 48 | } 49 | 50 | public void setOperation(JobOperationParams.JobStopOrAbandonOperationParam operation) { 51 | this.operation = operation; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/model/JobInstanceDetailsResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.model; 20 | 21 | import static java.util.Collections.unmodifiableList; 22 | 23 | import java.util.List; 24 | 25 | import org.springframework.batch.admin.web.JobInfo; 26 | 27 | import com.fasterxml.jackson.annotation.JsonProperty; 28 | 29 | 30 | public class JobInstanceDetailsResponse { 31 | 32 | private final JobInfo jobInfo; 33 | @JsonProperty("jobExecutionList") 34 | private final List jobExecutionInfoResponseList; 35 | 36 | public JobInstanceDetailsResponse(JobInfo jobInfo, List jobExecutionInfoResponseList) { 37 | this.jobInfo = jobInfo; 38 | this.jobExecutionInfoResponseList = unmodifiableList(jobExecutionInfoResponseList); 39 | } 40 | 41 | public JobInfo getJobInfo() { 42 | return jobInfo; 43 | } 44 | 45 | public List getJobExecutionInfoResponseList() { 46 | return jobExecutionInfoResponseList; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/model/JobInstanceStartRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.model; 20 | 21 | import javax.validation.constraints.NotNull; 22 | import javax.ws.rs.PathParam; 23 | import javax.ws.rs.QueryParam; 24 | 25 | import io.swagger.annotations.ApiParam; 26 | 27 | public class JobInstanceStartRequest { 28 | 29 | @PathParam("jobName") 30 | @NotNull 31 | @ApiParam(required = true) 32 | private String jobName; 33 | 34 | @QueryParam("params") 35 | private String params; 36 | 37 | public String getJobName() { 38 | return jobName; 39 | } 40 | 41 | public void setJobName(String jobName) { 42 | this.jobName = jobName; 43 | } 44 | 45 | public String getParams() { 46 | return params; 47 | } 48 | 49 | public void setParams(String params) { 50 | this.params = params; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/model/JobOperationParams.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.model; 20 | 21 | public class JobOperationParams { 22 | 23 | public enum JobStopOrAbandonOperationParam { 24 | STOP, ABANDON; 25 | } 26 | 27 | public enum JobRestartOperationParam { 28 | RESTART; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/model/JobRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.model; 20 | 21 | import javax.validation.constraints.NotNull; 22 | import javax.ws.rs.PathParam; 23 | 24 | public class JobRequest extends PageRequest { 25 | 26 | @NotNull 27 | @PathParam("jobName") 28 | private String jobName; 29 | 30 | public String getJobName() { 31 | return jobName; 32 | } 33 | 34 | public void setJobName(String jobName) { 35 | this.jobName = jobName; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/model/PageRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.model; 20 | 21 | import javax.ws.rs.DefaultValue; 22 | import javax.ws.rs.QueryParam; 23 | 24 | public class PageRequest { 25 | 26 | @QueryParam("page") 27 | @DefaultValue("0") 28 | private int page; 29 | 30 | @QueryParam("size") 31 | @DefaultValue("20") 32 | private int size; 33 | 34 | public int getPage() { 35 | return page; 36 | } 37 | 38 | public void setPage(int page) { 39 | this.page = page; 40 | } 41 | 42 | public int getSize() { 43 | return size; 44 | } 45 | 46 | public void setSize(int size) { 47 | this.size = size; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/model/StepExecutionContextResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.model; 20 | 21 | import static java.util.Collections.unmodifiableMap; 22 | 23 | import java.util.Map; 24 | 25 | public class StepExecutionContextResponse { 26 | 27 | private final Map executionContextMap; 28 | 29 | private final Long jobExecutionId; 30 | 31 | private final Long stepExecutionId; 32 | 33 | private final String stepName; 34 | 35 | public StepExecutionContextResponse(Map executionContextMap, Long jobExecutionId, Long stepExecutionId, String stepName) { 36 | this.executionContextMap = unmodifiableMap(executionContextMap); 37 | this.jobExecutionId = jobExecutionId; 38 | this.stepExecutionId = stepExecutionId; 39 | this.stepName = stepName; 40 | } 41 | 42 | public Map getExecutionContextMap() { 43 | return executionContextMap; 44 | } 45 | 46 | public Long getJobExecutionId() { 47 | return jobExecutionId; 48 | } 49 | 50 | public Long getStepExecutionId() { 51 | return stepExecutionId; 52 | } 53 | 54 | public String getStepName() { 55 | return stepName; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/model/StepExecutionProgressResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.model; 20 | 21 | import org.springframework.batch.admin.history.StepExecutionHistory; 22 | import org.springframework.batch.admin.web.StepExecutionProgress; 23 | 24 | import com.fasterxml.jackson.annotation.JsonProperty; 25 | 26 | public class StepExecutionProgressResponse { 27 | 28 | private final StepExecutionProgress stepExecutionProgress; 29 | 30 | private final StepExecutionHistory stepExecutionHistory; 31 | 32 | @JsonProperty("stepExecution") 33 | private final StepExecutionInfoResponse stepExecutionInfoResponse; 34 | 35 | public StepExecutionProgressResponse(StepExecutionProgress stepExecutionProgress, StepExecutionHistory stepExecutionHistory, 36 | StepExecutionInfoResponse stepExecutionInfoResponse) { 37 | this.stepExecutionProgress = stepExecutionProgress; 38 | this.stepExecutionHistory = stepExecutionHistory; 39 | this.stepExecutionInfoResponse = stepExecutionInfoResponse; 40 | } 41 | 42 | public StepExecutionProgress getStepExecutionProgress() { 43 | return stepExecutionProgress; 44 | } 45 | 46 | public StepExecutionHistory getStepExecutionHistory() { 47 | return stepExecutionHistory; 48 | } 49 | 50 | public StepExecutionInfoResponse getStepExecutionInfoResponse() { 51 | return stepExecutionInfoResponse; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/java/org/apache/ambari/infra/model/StepExecutionRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.model; 20 | 21 | import javax.validation.constraints.NotNull; 22 | import javax.ws.rs.PathParam; 23 | 24 | public class StepExecutionRequest { 25 | 26 | @PathParam("jobExecutionId") 27 | @NotNull 28 | private Long jobExecutionId; 29 | 30 | @PathParam("stepExecutionId") 31 | @NotNull 32 | private Long stepExecutionId; 33 | 34 | public Long getJobExecutionId() { 35 | return jobExecutionId; 36 | } 37 | 38 | public void setJobExecutionId(Long jobExecutionId) { 39 | this.jobExecutionId = jobExecutionId; 40 | } 41 | 42 | public Long getStepExecutionId() { 43 | return stepExecutionId; 44 | } 45 | 46 | public void setStepExecutionId(Long stepExecutionId) { 47 | this.stepExecutionId = stepExecutionId; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/resources/dummy/dummy.txt: -------------------------------------------------------------------------------- 1 | f1,f2 2 | v1,v2 3 | v3,v4 -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/resources/infra-manager-env.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | # Extend with java options or system properties. e.g.: INFRA_MANAGER_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,address=5007,server=y,suspend=n" 18 | export INFRA_MANAGER_OPTS="" 19 | 20 | # Infra Manager debug options 21 | #export INFRA_MANAGER_DEBUG=true 22 | #export INFRA_MANAGER_DEBUG_SUSPEND=n 23 | export INFRA_MANAGER_DEBUG_PORT=5005 24 | 25 | # Infra Manager memory 26 | # export INFRA_MANAGER_JAVA_MEM="--Xmx1024m" 27 | 28 | #export LOG_PATH=/var/log/ambari-infra-manager/ 29 | #export LOG_FILE=infra-manager.log 30 | 31 | # Pid file of the application 32 | #export INFRA_MANAGER_PID_DIR=/var/run/ambari-infra-manager 33 | #export INFRA_MANAGER_PID_FILE=infra-manager.pid 34 | 35 | # SSL settings" 36 | # export INFRA_MANAGER_SSL="true" 37 | # export INFRA_MANAGER_KEYSTORE_LOCATION="/my/path/keystore.jks" 38 | # export INFRA_MANAGER_KEYSTORE_TYPE="jks" 39 | # export INFRA_MANAGER_TRUSTSTORE_LOCATION="/my/path/trutstore.jks" 40 | # export INFRA_MANAGER_TRUSTSTORE_TYPE="jks" -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | target/log/infra-manager.log 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/main/resources/static/index.html: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 |

Welcome!

23 | 24 | -------------------------------------------------------------------------------- /ambari-infra-manager/src/test/java/org/apache/ambari/infra/conf/security/CompositeSecretTest.java: -------------------------------------------------------------------------------- 1 | package org.apache.ambari.infra.conf.security; 2 | 3 | import static org.hamcrest.core.Is.is; 4 | import static org.junit.Assert.assertThat; 5 | 6 | import java.util.Optional; 7 | 8 | import org.junit.Test; 9 | 10 | /* 11 | * Licensed to the Apache Software Foundation (ASF) under one 12 | * or more contributor license agreements. See the NOTICE file 13 | * distributed with this work for additional information 14 | * regarding copyright ownership. The ASF licenses this file 15 | * to you under the Apache License, Version 2.0 (the 16 | * "License"); you may not use this file except in compliance 17 | * with the License. You may obtain a copy of the License at 18 | * 19 | * http://www.apache.org/licenses/LICENSE-2.0 20 | * 21 | * Unless required by applicable law or agreed to in writing, 22 | * software distributed under the License is distributed on an 23 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 24 | * KIND, either express or implied. See the License for the 25 | * specific language governing permissions and limitations 26 | * under the License. 27 | */ 28 | public class CompositeSecretTest { 29 | @Test 30 | public void testGetPasswordReturnNullIfNoPasswordStoresWereAdded() { 31 | assertThat(new CompositeSecret().get().isPresent(), is(false)); 32 | } 33 | 34 | @Test 35 | public void testGetPasswordReturnNullIfPasswordNotFoundInAnyStore() { 36 | assertThat(new CompositeSecret(Optional::empty, Optional::empty).get().isPresent(), is(false)); 37 | } 38 | 39 | @Test 40 | public void testGetPasswordReturnPasswordFromFirstStoreIfExists() { 41 | assertThat(new CompositeSecret(() -> Optional.of("Pass"), Optional::empty).get().get(), is("Pass")); 42 | } 43 | 44 | @Test 45 | public void testGetPasswordReturnPasswordFromSecondStoreIfNotExistsInFirst() { 46 | assertThat(new CompositeSecret(Optional::empty, () -> Optional.of("Pass")).get().get(), is("Pass")); 47 | } 48 | } -------------------------------------------------------------------------------- /ambari-infra-manager/src/test/java/org/apache/ambari/infra/json/FsPermissionToStringConverterTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.json; 20 | 21 | import static org.hamcrest.CoreMatchers.nullValue; 22 | import static org.hamcrest.core.Is.is; 23 | import static org.junit.Assert.assertThat; 24 | 25 | import org.apache.hadoop.fs.permission.FsPermission; 26 | import org.junit.Test; 27 | 28 | public class FsPermissionToStringConverterTest { 29 | @Test 30 | public void testConvertWhenInputIsNotNull() { 31 | assertThat(new FsPermissionToStringConverter().convert(new FsPermission("640")), is("640")); 32 | } 33 | 34 | @Test 35 | public void testConvertWhenInputIsNull() { 36 | assertThat(new FsPermissionToStringConverter().convert(null), is(nullValue())); 37 | } 38 | } -------------------------------------------------------------------------------- /ambari-infra-manager/src/test/java/org/apache/ambari/infra/model/ISO8601DateFormatterTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.model; 20 | 21 | import static org.hamcrest.core.Is.is; 22 | import static org.junit.Assert.assertThat; 23 | 24 | import java.text.ParseException; 25 | import java.time.OffsetDateTime; 26 | import java.time.ZoneOffset; 27 | import java.util.Date; 28 | 29 | import org.junit.Test; 30 | 31 | public class ISO8601DateFormatterTest { 32 | 33 | @Test 34 | public void testFormat() { 35 | OffsetDateTime offsetDateTime = OffsetDateTime.of( 36 | 2018, 11, 30, 37 | 2, 30, 11, 0, 38 | ZoneOffset.ofHoursMinutes(1, 30)); 39 | String text = new ISO8601DateFormatter().format(Date.from(offsetDateTime.toInstant())); 40 | assertThat(text, is("2018-11-30T01:00:11Z")); 41 | } 42 | 43 | @Test 44 | public void testParse() throws ParseException { 45 | Date now = new Date(); 46 | ISO8601DateFormatter iso8601DateFormatter = new ISO8601DateFormatter(); 47 | Date parsed = iso8601DateFormatter.parse(iso8601DateFormatter.format(now)); 48 | assertThat(parsed, is(now)); 49 | } 50 | } -------------------------------------------------------------------------------- /ambari-infra-solr-client/src/main/java/org/apache/ambari/infra/solr/AmbariSolrCloudClientException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.solr; 20 | 21 | public class AmbariSolrCloudClientException extends Exception{ 22 | public AmbariSolrCloudClientException(String message) { 23 | super(message); 24 | } 25 | public AmbariSolrCloudClientException(String message, Throwable throwable) { 26 | super(message, throwable); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /ambari-infra-solr-client/src/main/java/org/apache/ambari/infra/solr/commands/AbstractStateFileZkCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.solr.commands; 20 | 21 | import org.apache.ambari.infra.solr.AmbariSolrCloudClient; 22 | import org.apache.ambari.infra.solr.domain.AmbariSolrState; 23 | import org.codehaus.jackson.JsonNode; 24 | import org.codehaus.jackson.map.ObjectMapper; 25 | 26 | public abstract class AbstractStateFileZkCommand extends AbstractZookeeperRetryCommand{ 27 | 28 | public static final String STATE_FILE = "ambari-solr-state.json"; 29 | public static final String STATE_FIELD = "ambari_solr_security_state"; 30 | 31 | public AbstractStateFileZkCommand(int maxRetries, int interval) { 32 | super(maxRetries, interval); 33 | } 34 | 35 | public AmbariSolrState getStateFromJson(AmbariSolrCloudClient client, String fileName) throws Exception { 36 | byte[] data = client.getSolrZkClient().getData(fileName, null, null, true); 37 | String input = new String(data); 38 | ObjectMapper mapper = new ObjectMapper(); 39 | JsonNode rootNode = mapper.readValue(input.getBytes(), JsonNode.class); 40 | return AmbariSolrState.valueOf(rootNode.get(STATE_FIELD).asText()); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /ambari-infra-solr-client/src/main/java/org/apache/ambari/infra/solr/commands/AbstractZookeeperConfigCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.solr.commands; 20 | 21 | import org.apache.ambari.infra.solr.AmbariSolrCloudClient; 22 | import org.apache.solr.common.cloud.SolrZkClient; 23 | import org.apache.solr.common.cloud.SolrZooKeeper; 24 | import org.apache.solr.common.cloud.ZkConfigManager; 25 | 26 | public abstract class AbstractZookeeperConfigCommand extends AbstractZookeeperRetryCommand { 27 | 28 | public AbstractZookeeperConfigCommand(int maxRetries, int interval) { 29 | super(maxRetries, interval); 30 | } 31 | 32 | protected abstract RESPONSE executeZkConfigCommand(ZkConfigManager zkConfigManager, AmbariSolrCloudClient client) 33 | throws Exception; 34 | 35 | @Override 36 | protected RESPONSE executeZkCommand(AmbariSolrCloudClient client, SolrZkClient zkClient, SolrZooKeeper solrZooKeeper) throws Exception { 37 | ZkConfigManager zkConfigManager = createZkConfigManager(zkClient); 38 | return executeZkConfigCommand(zkConfigManager, client); 39 | } 40 | 41 | protected ZkConfigManager createZkConfigManager(SolrZkClient zkClient) { 42 | return new ZkConfigManager(zkClient); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /ambari-infra-solr-client/src/main/java/org/apache/ambari/infra/solr/commands/AbstractZookeeperRetryCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.solr.commands; 20 | 21 | import org.apache.ambari.infra.solr.AmbariSolrCloudClient; 22 | import org.apache.solr.common.cloud.SolrZkClient; 23 | import org.apache.solr.common.cloud.SolrZooKeeper; 24 | 25 | public abstract class AbstractZookeeperRetryCommand extends AbstractRetryCommand { 26 | 27 | public AbstractZookeeperRetryCommand(int maxRetries, int interval) { 28 | super(maxRetries, interval); 29 | } 30 | 31 | protected abstract RESPONSE executeZkCommand(AmbariSolrCloudClient client, SolrZkClient zkClient, SolrZooKeeper solrZooKeeper) 32 | throws Exception; 33 | 34 | @Override 35 | public RESPONSE createAndProcessRequest(AmbariSolrCloudClient client) throws Exception { 36 | SolrZkClient zkClient = client.getSolrZkClient(); 37 | SolrZooKeeper solrZooKeeper = zkClient.getSolrZooKeeper(); 38 | return executeZkCommand(client, zkClient, solrZooKeeper); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /ambari-infra-solr-client/src/main/java/org/apache/ambari/infra/solr/commands/CheckConfigZkCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.solr.commands; 20 | 21 | import org.apache.ambari.infra.solr.AmbariSolrCloudClient; 22 | import org.apache.solr.common.cloud.ZkConfigManager; 23 | 24 | public class CheckConfigZkCommand extends AbstractZookeeperConfigCommand { 25 | 26 | public CheckConfigZkCommand(int maxRetries, int interval) { 27 | super(maxRetries, interval); 28 | } 29 | 30 | @Override 31 | protected Boolean executeZkConfigCommand(ZkConfigManager zkConfigManager, AmbariSolrCloudClient client) throws Exception { 32 | return zkConfigManager.configExists(client.getConfigSet()); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /ambari-infra-solr-client/src/main/java/org/apache/ambari/infra/solr/commands/CheckZnodeZkCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.solr.commands; 20 | 21 | import org.apache.ambari.infra.solr.AmbariSolrCloudClient; 22 | import org.apache.ambari.infra.solr.AmbariSolrCloudClientException; 23 | import org.apache.solr.common.cloud.SolrZkClient; 24 | import org.apache.solr.common.cloud.SolrZooKeeper; 25 | import org.apache.zookeeper.KeeperException; 26 | 27 | public class CheckZnodeZkCommand extends AbstractZookeeperRetryCommand { 28 | 29 | private String znode; 30 | 31 | public CheckZnodeZkCommand(int maxRetries, int interval, String znode) { 32 | super(maxRetries, interval); 33 | this.znode = znode; 34 | } 35 | 36 | @Override 37 | protected Boolean executeZkCommand(AmbariSolrCloudClient client, SolrZkClient zkClient, SolrZooKeeper solrZooKeeper) throws Exception { 38 | try { 39 | return zkClient.exists(this.znode, false); 40 | } catch (KeeperException e) { 41 | throw new AmbariSolrCloudClientException("Exception during checking znode, " + 42 | "Check zookeeper servers are running (n+1/2) or zookeeper quorum has established or not.", e); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /ambari-infra-solr-client/src/main/java/org/apache/ambari/infra/solr/commands/CreateShardCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.solr.commands; 20 | 21 | import org.apache.ambari.infra.solr.AmbariSolrCloudClient; 22 | import org.apache.solr.client.solrj.request.CollectionAdminRequest; 23 | import org.apache.solr.client.solrj.response.CollectionAdminResponse; 24 | 25 | public class CreateShardCommand extends AbstractSolrRetryCommand { 26 | 27 | private final String shardName; 28 | 29 | public CreateShardCommand(String shardName, int maxRetries, int interval) { 30 | super(maxRetries, interval); 31 | this.shardName = shardName; 32 | } 33 | 34 | @Override 35 | public String handleResponse(CollectionAdminResponse response, AmbariSolrCloudClient client) throws Exception { 36 | return shardName; 37 | } 38 | 39 | @Override 40 | public CollectionAdminRequest.CreateShard createRequest(AmbariSolrCloudClient client) { 41 | return CollectionAdminRequest.createShard(client.getCollection(), shardName); 42 | } 43 | 44 | @Override 45 | public String errorMessage(AmbariSolrCloudClient client) { 46 | return String.format("Cannot add shard to collection '%s'", client.getCollection()); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /ambari-infra-solr-client/src/main/java/org/apache/ambari/infra/solr/commands/CreateSolrZnodeZkCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.solr.commands; 20 | 21 | import org.apache.ambari.infra.solr.AmbariSolrCloudClient; 22 | import org.apache.ambari.infra.solr.AmbariSolrCloudClientException; 23 | import org.apache.solr.common.cloud.SolrZkClient; 24 | import org.apache.solr.common.cloud.SolrZooKeeper; 25 | import org.apache.zookeeper.KeeperException; 26 | 27 | public class CreateSolrZnodeZkCommand extends AbstractZookeeperRetryCommand { 28 | 29 | public CreateSolrZnodeZkCommand(int maxRetries, int interval) { 30 | super(maxRetries, interval); 31 | } 32 | 33 | @Override 34 | protected String executeZkCommand(AmbariSolrCloudClient client, SolrZkClient zkClient, SolrZooKeeper solrZooKeeper) throws Exception { 35 | try { 36 | zkClient.makePath(client.getZnode(), true); 37 | return client.getZnode(); 38 | } catch (KeeperException e) { 39 | throw new AmbariSolrCloudClientException("Cannot create ZNode, check zookeeper servers are running (n+1/2), or zookeeper quorum has established or not.",e); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /ambari-infra-solr-client/src/main/java/org/apache/ambari/infra/solr/commands/DeleteZnodeZkCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.solr.commands; 20 | 21 | import org.apache.ambari.infra.solr.AmbariSolrCloudClient; 22 | import org.apache.solr.common.cloud.SolrZkClient; 23 | import org.apache.solr.common.cloud.SolrZooKeeper; 24 | 25 | public class DeleteZnodeZkCommand extends AbstractZookeeperRetryCommand { 26 | 27 | public DeleteZnodeZkCommand(int maxRetries, int interval) { 28 | super(maxRetries, interval); 29 | } 30 | 31 | @Override 32 | protected Boolean executeZkCommand(AmbariSolrCloudClient client, SolrZkClient zkClient, SolrZooKeeper solrZooKeeper) throws Exception { 33 | zkClient.clean(client.getZnode()); 34 | return true; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /ambari-infra-solr-client/src/main/java/org/apache/ambari/infra/solr/commands/DownloadConfigZkCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.solr.commands; 20 | 21 | import org.apache.ambari.infra.solr.AmbariSolrCloudClient; 22 | import org.apache.ambari.infra.solr.AmbariSolrCloudClientException; 23 | import org.apache.solr.common.cloud.ZkConfigManager; 24 | 25 | import java.io.IOException; 26 | import java.nio.file.Path; 27 | import java.nio.file.Paths; 28 | 29 | public class DownloadConfigZkCommand extends AbstractZookeeperConfigCommand { 30 | 31 | public DownloadConfigZkCommand(int maxRetries, int interval) { 32 | super(maxRetries, interval); 33 | } 34 | 35 | @Override 36 | protected String executeZkConfigCommand(ZkConfigManager zkConfigManager, AmbariSolrCloudClient client) throws Exception { 37 | Path configDir = Paths.get(client.getConfigDir()); 38 | String configSet = client.getConfigSet(); 39 | try { 40 | zkConfigManager.downloadConfigDir(configSet, configDir); 41 | return configDir.toString(); 42 | } catch (IOException e){ 43 | throw new AmbariSolrCloudClientException("Error downloading configuration set, check Solr Znode has started or not " + 44 | "(starting Solr (for Log Search) is responsible to create the Znode)" ,e); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /ambari-infra-solr-client/src/main/java/org/apache/ambari/infra/solr/commands/GetShardsCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.solr.commands; 20 | 21 | import org.apache.ambari.infra.solr.AmbariSolrCloudClient; 22 | import org.apache.solr.common.cloud.Slice; 23 | import org.apache.solr.common.cloud.ZkStateReader; 24 | 25 | import java.util.Collection; 26 | 27 | public class GetShardsCommand extends AbstractRetryCommand> { 28 | 29 | public GetShardsCommand(int maxRetries, int interval) { 30 | super(maxRetries, interval); 31 | } 32 | 33 | @Override 34 | public Collection createAndProcessRequest(AmbariSolrCloudClient solrCloudClient) throws Exception { 35 | ZkStateReader zkReader = new ZkStateReader(solrCloudClient.getSolrZkClient()); 36 | zkReader.createClusterStateWatchersAndUpdate(); 37 | return zkReader.getClusterState().getCollection(solrCloudClient.getCollection()).getSlices(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /ambari-infra-solr-client/src/main/java/org/apache/ambari/infra/solr/commands/GetSolrHostsCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.solr.commands; 20 | 21 | import org.apache.ambari.infra.solr.AmbariSolrCloudClient; 22 | import org.apache.zookeeper.ZooKeeper; 23 | 24 | import java.net.InetAddress; 25 | import java.util.ArrayList; 26 | import java.util.Collection; 27 | import java.util.List; 28 | 29 | public class GetSolrHostsCommand extends AbstractRetryCommand> { 30 | 31 | public GetSolrHostsCommand(int maxRetries, int interval) { 32 | super(maxRetries, interval); 33 | } 34 | 35 | @Override 36 | public Collection createAndProcessRequest(AmbariSolrCloudClient solrCloudClient) throws Exception { 37 | List solrHosts = new ArrayList<>(); 38 | 39 | ZooKeeper zk = new ZooKeeper(solrCloudClient.getZkConnectString(), 10000, null); 40 | List ids = zk.getChildren("/live_nodes", false); 41 | for (String id : ids) { 42 | if (id.endsWith("_solr")) { 43 | String hostAndPort = id.substring(0, id.length() - 5); 44 | String[] tokens = hostAndPort.split(":"); 45 | String host = InetAddress.getByName(tokens[0]).getHostName(); 46 | 47 | solrHosts.add(host); 48 | } 49 | } 50 | 51 | return solrHosts; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /ambari-infra-solr-client/src/main/java/org/apache/ambari/infra/solr/commands/GetStateFileZkCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.solr.commands; 20 | 21 | import org.apache.ambari.infra.solr.AmbariSolrCloudClient; 22 | import org.apache.ambari.infra.solr.domain.AmbariSolrState; 23 | import org.apache.solr.common.cloud.SolrZkClient; 24 | import org.apache.solr.common.cloud.SolrZooKeeper; 25 | 26 | public class GetStateFileZkCommand extends AbstractStateFileZkCommand { 27 | private String unsecureZnode; 28 | 29 | public GetStateFileZkCommand(int maxRetries, int interval, String unsecureZnode) { 30 | super(maxRetries, interval); 31 | this.unsecureZnode = unsecureZnode; 32 | } 33 | 34 | @Override 35 | protected AmbariSolrState executeZkCommand(AmbariSolrCloudClient client, SolrZkClient zkClient, SolrZooKeeper solrZooKeeper) throws Exception { 36 | AmbariSolrState result = AmbariSolrState.UNSECURE; 37 | String stateFile = String.format("%s/%s", unsecureZnode, AbstractStateFileZkCommand.STATE_FILE); 38 | if (zkClient.exists(stateFile, true)) { 39 | result = getStateFromJson(client, stateFile); 40 | } 41 | return result; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /ambari-infra-solr-client/src/main/java/org/apache/ambari/infra/solr/commands/ListCollectionCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.solr.commands; 20 | 21 | import org.apache.ambari.infra.solr.AmbariSolrCloudClient; 22 | import org.apache.solr.client.solrj.request.CollectionAdminRequest; 23 | import org.apache.solr.client.solrj.response.CollectionAdminResponse; 24 | 25 | import java.util.List; 26 | 27 | public class ListCollectionCommand extends AbstractSolrRetryCommand> { 28 | 29 | public ListCollectionCommand(int maxRetries, int interval) { 30 | super(maxRetries, interval); 31 | } 32 | 33 | @Override 34 | public List handleResponse(CollectionAdminResponse response, AmbariSolrCloudClient client) throws Exception { 35 | List allCollectionList = (List) response 36 | .getResponse().get("collections"); 37 | return allCollectionList; 38 | } 39 | 40 | @Override 41 | public CollectionAdminRequest.List createRequest(AmbariSolrCloudClient client) { 42 | return new CollectionAdminRequest.List(); 43 | } 44 | 45 | @Override 46 | public String errorMessage(AmbariSolrCloudClient client) { 47 | return "Cannot get collections."; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /ambari-infra-solr-client/src/main/java/org/apache/ambari/infra/solr/commands/RemoveAdminHandlersCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.solr.commands; 20 | 21 | import org.apache.ambari.infra.solr.AmbariSolrCloudClient; 22 | import org.apache.solr.common.cloud.SolrZkClient; 23 | import org.apache.solr.common.cloud.SolrZooKeeper; 24 | import org.apache.zookeeper.data.Stat; 25 | 26 | public class RemoveAdminHandlersCommand extends AbstractZookeeperRetryCommand { 27 | 28 | public RemoveAdminHandlersCommand(int maxRetries, int interval) { 29 | super(maxRetries, interval); 30 | } 31 | 32 | @Override 33 | protected Boolean executeZkCommand(AmbariSolrCloudClient client, SolrZkClient zkClient, SolrZooKeeper solrZooKeeper) throws Exception { 34 | String solrConfigXmlPath = String.format("/configs/%s/solrconfig.xml", client.getCollection()); 35 | if (zkClient.exists(solrConfigXmlPath, true)) { 36 | Stat stat = new Stat(); 37 | byte[] solrConfigXmlBytes = zkClient.getData(solrConfigXmlPath, null, stat, true); 38 | String solrConfigStr = new String(solrConfigXmlBytes); 39 | if (solrConfigStr.contains("class=\"solr.admin.AdminHandlers\"")) { 40 | byte[] newSolrConfigXmlBytes = new String(solrConfigXmlBytes).replaceAll("(?s)", "").getBytes(); 41 | zkClient.setData(solrConfigXmlPath, newSolrConfigXmlBytes, stat.getVersion() + 1, true); 42 | } 43 | } 44 | return true; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /ambari-infra-solr-client/src/main/java/org/apache/ambari/infra/solr/commands/SecureZNodeZkCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.solr.commands; 20 | 21 | import org.apache.ambari.infra.solr.AmbariSolrCloudClient; 22 | import org.apache.ambari.infra.solr.util.AclUtils; 23 | import org.apache.solr.common.cloud.SolrZkClient; 24 | import org.apache.solr.common.cloud.SolrZooKeeper; 25 | import org.apache.zookeeper.ZooDefs; 26 | import org.apache.zookeeper.data.ACL; 27 | import org.apache.zookeeper.data.Id; 28 | 29 | import java.util.ArrayList; 30 | import java.util.List; 31 | 32 | public class SecureZNodeZkCommand extends AbstractZookeeperRetryCommand { 33 | 34 | public SecureZNodeZkCommand(int maxRetries, int interval) { 35 | super(maxRetries, interval); 36 | } 37 | 38 | @Override 39 | protected Boolean executeZkCommand(AmbariSolrCloudClient client, SolrZkClient zkClient, SolrZooKeeper solrZooKeeper) throws Exception { 40 | String zNode = client.getZnode(); 41 | List newAclList = new ArrayList<>(); 42 | List saslUserList = AclUtils.createAclListFromSaslUsers(client.getSaslUsers().split(",")); 43 | newAclList.addAll(saslUserList); 44 | newAclList.add(new ACL(ZooDefs.Perms.READ, new Id("world", "anyone"))); 45 | AclUtils.setRecursivelyOn(client.getSolrZkClient().getSolrZooKeeper(), zNode, newAclList); 46 | return true; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /ambari-infra-solr-client/src/main/java/org/apache/ambari/infra/solr/commands/SetClusterPropertyZkCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.solr.commands; 20 | 21 | import org.apache.ambari.infra.solr.AmbariSolrCloudClient; 22 | import org.apache.solr.common.cloud.ClusterProperties; 23 | import org.apache.solr.common.cloud.SolrZkClient; 24 | import org.apache.solr.common.cloud.SolrZooKeeper; 25 | 26 | public class SetClusterPropertyZkCommand extends AbstractZookeeperRetryCommand{ 27 | 28 | public SetClusterPropertyZkCommand(int maxRetries, int interval) { 29 | super(maxRetries, interval); 30 | } 31 | 32 | @Override 33 | protected String executeZkCommand(AmbariSolrCloudClient client, SolrZkClient zkClient, SolrZooKeeper solrZooKeeper) throws Exception { 34 | String propertyName = client.getPropName(); 35 | String propertyValue = client.getPropValue(); 36 | ClusterProperties clusterProperties = new ClusterProperties(zkClient); 37 | clusterProperties.setClusterProperty(propertyName, propertyValue); 38 | return propertyValue; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /ambari-infra-solr-client/src/main/java/org/apache/ambari/infra/solr/commands/TransferZnodeZkCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.solr.commands; 20 | 21 | import org.apache.ambari.infra.solr.AmbariSolrCloudClient; 22 | import org.apache.solr.common.cloud.SolrZkClient; 23 | import org.apache.solr.common.cloud.SolrZooKeeper; 24 | 25 | public class TransferZnodeZkCommand extends AbstractZookeeperRetryCommand { 26 | 27 | public TransferZnodeZkCommand(int maxRetries, int interval) { 28 | super(maxRetries, interval); 29 | } 30 | 31 | @Override 32 | protected Boolean executeZkCommand(AmbariSolrCloudClient client, SolrZkClient zkClient, SolrZooKeeper solrZooKeeper) throws Exception { 33 | boolean isSrcZk = true; 34 | boolean isDestZk = true; 35 | if ("copyToLocal".equals(client.getTransferMode())) { 36 | isDestZk = false; 37 | } else if ("copyFromLocal".equals(client.getTransferMode())) { 38 | isSrcZk = false; 39 | } 40 | zkClient.zkTransfer(client.getCopySrc(), isSrcZk, client.getCopyDest(), isDestZk, true); 41 | return true; 42 | } 43 | 44 | 45 | } 46 | -------------------------------------------------------------------------------- /ambari-infra-solr-client/src/main/java/org/apache/ambari/infra/solr/commands/UnsecureZNodeZkCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.solr.commands; 20 | 21 | import org.apache.ambari.infra.solr.AmbariSolrCloudClient; 22 | import org.apache.ambari.infra.solr.util.AclUtils; 23 | import org.apache.solr.common.cloud.SolrZkClient; 24 | import org.apache.solr.common.cloud.SolrZooKeeper; 25 | import org.apache.zookeeper.ZooDefs; 26 | import org.apache.zookeeper.data.ACL; 27 | import org.apache.zookeeper.data.Id; 28 | 29 | import java.util.ArrayList; 30 | import java.util.List; 31 | 32 | public class UnsecureZNodeZkCommand extends AbstractZookeeperRetryCommand { 33 | 34 | public UnsecureZNodeZkCommand(int maxRetries, int interval) { 35 | super(maxRetries, interval); 36 | } 37 | 38 | @Override 39 | protected Boolean executeZkCommand(AmbariSolrCloudClient client, SolrZkClient zkClient, SolrZooKeeper solrZooKeeper) throws Exception { 40 | String zNode = client.getZnode(); 41 | AclUtils.setRecursivelyOn(client.getSolrZkClient().getSolrZooKeeper(), zNode, ZooDefs.Ids.OPEN_ACL_UNSAFE); 42 | return true; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /ambari-infra-solr-client/src/main/java/org/apache/ambari/infra/solr/commands/UploadConfigZkCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.solr.commands; 20 | 21 | import org.apache.ambari.infra.solr.AmbariSolrCloudClient; 22 | import org.apache.solr.common.cloud.ZkConfigManager; 23 | 24 | import java.io.IOException; 25 | import java.nio.file.Path; 26 | import java.nio.file.Paths; 27 | 28 | public class UploadConfigZkCommand extends AbstractZookeeperConfigCommand { 29 | 30 | public UploadConfigZkCommand(int maxRetries, int interval) { 31 | super(maxRetries, interval); 32 | } 33 | 34 | @Override 35 | protected String executeZkConfigCommand(ZkConfigManager zkConfigManager, AmbariSolrCloudClient client) throws Exception { 36 | Path configDir = Paths.get(client.getConfigDir()); 37 | String configSet = client.getConfigSet(); 38 | zkConfigManager.uploadConfigDir(configDir, configSet); 39 | return configSet; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /ambari-infra-solr-client/src/main/java/org/apache/ambari/infra/solr/domain/AmbariSolrState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.solr.domain; 20 | 21 | /** 22 | * Enum state values for storing security status in unsecure znode 23 | */ 24 | public enum AmbariSolrState { 25 | SECURE, UNSECURE 26 | } 27 | -------------------------------------------------------------------------------- /ambari-infra-solr-client/src/main/java/org/apache/ambari/infra/solr/domain/ZookeeperClient.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.solr.domain; 20 | 21 | import static java.nio.charset.StandardCharsets.UTF_8; 22 | import static org.apache.zookeeper.CreateMode.PERSISTENT; 23 | 24 | import java.util.Optional; 25 | 26 | import org.apache.solr.common.cloud.SolrZkClient; 27 | 28 | public class ZookeeperClient { 29 | private final SolrZkClient zkClient; 30 | 31 | public ZookeeperClient(SolrZkClient zkClient) { 32 | this.zkClient = zkClient; 33 | } 34 | 35 | public void putFileContent(String fileName, String content) throws Exception { 36 | if (zkClient.exists(fileName, true)) { 37 | zkClient.setData(fileName, content.getBytes(UTF_8), true); 38 | } else { 39 | zkClient.create(fileName, content.getBytes(UTF_8), PERSISTENT, true); 40 | } 41 | } 42 | 43 | public Optional getFileContent(String fileName) throws Exception { 44 | if (!zkClient.exists(fileName, true)) 45 | return Optional.empty(); 46 | 47 | byte[] data = zkClient.getData(fileName, null, null, true); 48 | return Optional.of(new String(data, UTF_8)); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /ambari-infra-solr-client/src/main/java/org/apache/ambari/infra/solr/domain/json/SolrCoreData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.solr.domain.json; 20 | 21 | import java.util.Map; 22 | 23 | public class SolrCoreData { 24 | private String coreNodeName; 25 | private String hostName; 26 | private Map properties; 27 | 28 | public SolrCoreData(String coreNodeName, String hostName, Map properties) { 29 | this.coreNodeName = coreNodeName; 30 | this.hostName = hostName; 31 | this.properties = properties; 32 | } 33 | 34 | public String getCoreNodeName() { 35 | return coreNodeName; 36 | } 37 | 38 | public void setCoreNodeName(String coreNodeName) { 39 | this.coreNodeName = coreNodeName; 40 | } 41 | 42 | public String getHostName() { 43 | return hostName; 44 | } 45 | 46 | public void setHostName(String hostName) { 47 | this.hostName = hostName; 48 | } 49 | 50 | public Map getProperties() { 51 | return properties; 52 | } 53 | 54 | public void setProperties(Map properties) { 55 | this.properties = properties; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /ambari-infra-solr-client/src/main/java/org/apache/ambari/infra/solr/domain/json/SolrShard.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.solr.domain.json; 20 | 21 | import org.apache.solr.common.cloud.Replica; 22 | import org.apache.solr.common.cloud.Slice.State; 23 | 24 | import java.util.Map; 25 | 26 | public class SolrShard { 27 | 28 | private String name; 29 | private State state; 30 | private Map replicas; 31 | 32 | public Map getReplicas() { 33 | return replicas; 34 | } 35 | 36 | public void setReplicas(Map replicas) { 37 | this.replicas = replicas; 38 | } 39 | 40 | public String getName() { 41 | return name; 42 | } 43 | 44 | public void setName(String name) { 45 | this.name = name; 46 | } 47 | 48 | public State getState() { 49 | return state; 50 | } 51 | 52 | public void setState(State state) { 53 | this.state = state; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /ambari-infra-solr-client/src/main/resources/data/security-without-authr.json: -------------------------------------------------------------------------------- 1 | { 2 | "authentication": 3 | { 4 | "class": "org.apache.solr.security.KerberosPlugin" 5 | } 6 | } -------------------------------------------------------------------------------- /ambari-infra-solr-client/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | # Copyright 2011 The Apache Software Foundation 2 | # 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | log4j.rootLogger=INFO,stdout,stderr 20 | 21 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 22 | log4j.appender.stdout.Threshold=INFO 23 | log4j.appender.stdout.Target=System.out 24 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 25 | log4j.appender.stdout.layout.ConversionPattern=%m%n 26 | log4j.appender.stdout.filter.lvlRangeFilter=org.apache.log4j.varia.LevelRangeFilter 27 | log4j.appender.stdout.filter.lvlRangeFilter.LevelMax=WARN 28 | 29 | log4j.appender.stderr=org.apache.log4j.ConsoleAppender 30 | log4j.appender.stderr.Threshold=ERROR 31 | log4j.appender.stderr.Target=System.err 32 | log4j.appender.stderr.layout=org.apache.log4j.PatternLayout 33 | log4j.appender.stderr.layout.ConversionPattern=%m%n 34 | log4j.appender.stderr.filter.lvlRangeFilter=org.apache.log4j.varia.LevelRangeFilter 35 | log4j.appender.stderr.filter.lvlRangeFilter.LevelMin=ERROR -------------------------------------------------------------------------------- /ambari-infra-solr-client/src/main/resources/solrCloudCli.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | JVM="java" 18 | sdir="`dirname \"$0\"`" 19 | ldir="`dirname "$(readlink -f "$0")"`" 20 | 21 | DIR="$sdir" 22 | if [ "$sdir" != "$ldir" ]; then 23 | DIR="$ldir" 24 | fi 25 | 26 | PATH=$JAVA_HOME/bin:$PATH $JVM -classpath "$DIR:$DIR/libs/*" $INFRA_SOLR_CLI_OPTS org.apache.ambari.infra.solr.AmbariSolrCloudCLI ${1+"$@"} -------------------------------------------------------------------------------- /ambari-infra-solr-plugin/.gitignore: -------------------------------------------------------------------------------- 1 | Profile 2 | .env 3 | ambari-infra-solr-*.rpm -------------------------------------------------------------------------------- /ambari-infra-solr-plugin/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | FROM centos:centos6 14 | 15 | 16 | RUN yum clean all -y && yum update -y 17 | RUN yum -y install vim wget rpm-build sudo which telnet tar openssh-server openssh-clients ntp git httpd lsof 18 | 19 | ENV HOME /root 20 | 21 | #Install JAVA 22 | ENV JAVA_VERSION 8u131 23 | ENV BUILD_VERSION b11 24 | RUN wget --no-check-certificate --no-cookies --header "Cookie:oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/$JAVA_VERSION-$BUILD_VERSION/d54c1d3a095b4ff2b6607d096fa80163/jdk-$JAVA_VERSION-linux-x64.rpm -O jdk-8-linux-x64.rpm 25 | RUN rpm -ivh jdk-8-linux-x64.rpm 26 | ENV JAVA_HOME /usr/java/default/ 27 | 28 | 29 | #Install Solr 30 | ADD ambari-infra-solr-2.0.0.0-SNAPSHOT.noarch.rpm /root/ambari-infra-solr.rpm 31 | RUN rpm -ivh /root/ambari-infra-solr.rpm 32 | 33 | RUN mkdir -p /root/solr_index/data 34 | ENV SOLR_HOME /root/solr_index/data 35 | ADD solr.xml /root/solr_index/data/solr.xml 36 | 37 | ENV PATH $PATH:$JAVA_HOME/bin:/usr/lib/ambari-infra-solr/bin 38 | 39 | #Enable G1 GC 40 | #ENV GC_TUNE="-XX:+UseG1GC -XX:+PerfDisableSharedMem -XX:+ParallelRefProcEnabled -XX:G1HeapRegionSize=3m -XX:MaxGCPauseMillis=250 -XX:InitiatingHeapOccupancyPercent=75 -XX:+UseLargePages -XX:+AggressiveOpts" 41 | 42 | # Start in debug mode 43 | #ENV SOLR_OPTS -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005 44 | 45 | WORKDIR /root 46 | CMD /usr/lib/ambari-infra-solr/bin/solr start -force -f 47 | -------------------------------------------------------------------------------- /ambari-infra-solr-plugin/docker/docker-compose.yml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License 15 | version: '3.3' 16 | services: 17 | zookeeper: 18 | image: zookeeper:${ZOOKEEPER_VERSION:-3.4.10} 19 | restart: always 20 | hostname: zookeeper 21 | networks: 22 | - infra-network 23 | ports: 24 | - 2181:2181 25 | environment: 26 | ZOO_MY_ID: 1 27 | ZOO_SERVERS: server.1=zookeeper:2888:3888 28 | solr: 29 | image: ambari-infra-solr:v1.0 30 | restart: always 31 | hostname: solr 32 | ports: 33 | - "8983:8983" 34 | - "5005:5005" 35 | networks: 36 | - infra-network 37 | env_file: 38 | - Profile 39 | entrypoint: 40 | - solr 41 | - start 42 | - "-f" 43 | - "-force" 44 | - "-c" 45 | - "-z" 46 | - ${ZOOKEEPER_CONNECTION_STRING} 47 | volumes: 48 | - $AMBARI_LOCATION/ambari-logsearch/ambari-logsearch-server/src/main/configsets:/usr/lib/ambari-infra-solr/server/solr/configsets 49 | extra_hosts: 50 | - metrics_collector:$DOCKERIP 51 | networks: 52 | infra-network: 53 | driver: bridge 54 | 55 | -------------------------------------------------------------------------------- /ambari-infra-solr-plugin/docker/infra-solr.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License 16 | 17 | sdir="`dirname \"$0\"`" 18 | : ${1:?"argument is missing: (build|build-docker|start|stop)"} 19 | command="$1" 20 | 21 | function build() { 22 | pushd $sdir/.. 23 | mvn clean install 24 | popd 25 | 26 | pushd $sdir/../../ambari-infra-assembly 27 | mvn clean install -Dbuild-rpm 28 | popd 29 | 30 | build_docker 31 | } 32 | 33 | function build_docker() { 34 | pushd $sdir 35 | cp ././../../ambari-infra-assembly/target/rpm/ambari-infra-solr/RPMS/noarch/ambari-infra-solr-2.0.0.0-SNAPSHOT.noarch.rpm . 36 | docker build -t ambari-infra-solr:v1.0 . 37 | popd 38 | } 39 | 40 | function start() { 41 | pushd $sdir 42 | docker run -d -p 8983:8983 -p 5005:5005 --name infra-solr ambari-infra-solr:v1.0 43 | popd 44 | } 45 | 46 | function stop() { 47 | pushd $sdir 48 | docker kill infra-solr 49 | docker rm infra-solr 50 | popd 51 | } 52 | 53 | case $command in 54 | "build") 55 | build 56 | ;; 57 | "build-docker") 58 | build_docker 59 | ;; 60 | "start") 61 | start 62 | ;; 63 | "stop") 64 | stop 65 | ;; 66 | *) 67 | echo "Available commands: (build|build-docker|start|stop)" 68 | ;; 69 | esac 70 | -------------------------------------------------------------------------------- /ambari-infra-solr-plugin/src/main/java/org/apache/ambari/infra/solr/metrics/reporters/AMSCacheReporter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.solr.metrics.reporters; 20 | 21 | import static org.apache.ambari.infra.solr.metrics.reporters.MetricsUtils.toTimelineMetric; 22 | 23 | import java.util.Arrays; 24 | import java.util.List; 25 | import java.util.Map; 26 | import java.util.stream.Collectors; 27 | 28 | import org.apache.solr.metrics.SolrMetricManager; 29 | 30 | public class AMSCacheReporter extends AMSReporter> { 31 | 32 | private List fields; 33 | 34 | public AMSCacheReporter(SolrMetricManager metricManager, String registryName) { 35 | super(metricManager, registryName); 36 | } 37 | 38 | public void setFields(String fields) { 39 | this.fields = Arrays.stream(fields.split(",")).map(String::trim).collect(Collectors.toList()); 40 | } 41 | 42 | @Override 43 | protected GaugeConverter> gaugeConverter() { 44 | return (metricName, gauge, currentMillis) -> fields.stream() 45 | .map(field -> toTimelineMetric( 46 | String.format("%s.%s", metricName, field), 47 | gauge.getValue().get(field).doubleValue(), 48 | currentMillis)) 49 | .collect(Collectors.toList()); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /ambari-infra-solr-plugin/src/main/java/org/apache/ambari/infra/solr/metrics/reporters/AMSProtocol.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.solr.metrics.reporters; 20 | 21 | public enum AMSProtocol { 22 | http, 23 | https 24 | } 25 | -------------------------------------------------------------------------------- /ambari-infra-solr-plugin/src/main/java/org/apache/ambari/infra/solr/metrics/reporters/GaugeConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.solr.metrics.reporters; 20 | 21 | import java.util.Collection; 22 | 23 | import org.apache.hadoop.metrics2.sink.timeline.TimelineMetric; 24 | 25 | import com.codahale.metrics.Gauge; 26 | 27 | public interface GaugeConverter { 28 | Collection convert(String metricName, Gauge gauge, long currentMillis); 29 | } 30 | -------------------------------------------------------------------------------- /ambari-infra-solr-plugin/src/main/java/org/apache/ambari/infra/solr/metrics/reporters/SimpleAMSReporter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.solr.metrics.reporters; 20 | 21 | import static java.util.Collections.singletonList; 22 | import static org.apache.ambari.infra.solr.metrics.reporters.MetricsUtils.toTimelineMetric; 23 | 24 | import org.apache.solr.metrics.SolrMetricManager; 25 | 26 | public class SimpleAMSReporter extends AMSReporter { 27 | 28 | public SimpleAMSReporter(SolrMetricManager metricManager, String registryName) { 29 | super(metricManager, registryName); 30 | } 31 | 32 | @Override 33 | protected GaugeConverter gaugeConverter() { 34 | return (metricName, gauge, currentMillis) -> 35 | singletonList(toTimelineMetric(metricName, gauge.getValue().doubleValue(), currentMillis)); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /ambari-infra-solr-plugin/src/main/java/org/apache/ambari/infra/solr/metrics/reporters/SolrMetricsSecurityConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.ambari.infra.solr.metrics.reporters; 20 | 21 | public class SolrMetricsSecurityConfig { 22 | 23 | private final String trustStoreLocation; 24 | private final String trustStoreType; 25 | private final String trustStorePassword; 26 | 27 | public SolrMetricsSecurityConfig(String trustStoreLocation, String trustStoreType, String trustStorePassword) { 28 | this.trustStoreLocation = trustStoreLocation; 29 | this.trustStoreType = trustStoreType; 30 | this.trustStorePassword = trustStorePassword; 31 | } 32 | 33 | public String getTrustStoreLocation() { 34 | return trustStoreLocation; 35 | } 36 | 37 | public String getTrustStoreType() { 38 | return trustStoreType; 39 | } 40 | 41 | public String getTrustStorePassword() { 42 | return trustStorePassword; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /ambari-infra-solr-plugin/src/main/java/org/apache/solr/security/InfraUserRolesLookupStrategy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.solr.security; 20 | 21 | import org.apache.commons.collections.CollectionUtils; 22 | import org.apache.hadoop.security.authentication.server.AuthenticationToken; 23 | import org.apache.hadoop.security.authentication.util.KerberosName; 24 | 25 | import java.security.Principal; 26 | import java.util.Map; 27 | import java.util.Set; 28 | 29 | 30 | /** 31 | * Strategy class to get roles with the principal name (in a specific format e.g.: 'name@DOMAIN') 32 | * in case of KerberosPlugin is used for authentication 33 | */ 34 | public class InfraUserRolesLookupStrategy { 35 | 36 | public Set getUserRolesFromPrincipal(Map> usersVsRoles, Principal principal) { 37 | if (principal instanceof AuthenticationToken) { 38 | AuthenticationToken authenticationToken = (AuthenticationToken) principal; 39 | KerberosName kerberosName = new KerberosName(authenticationToken.getName()); 40 | Set rolesResult = usersVsRoles.get(String.format("%s@%s", kerberosName.getServiceName(), kerberosName.getRealm())); 41 | if (CollectionUtils.isEmpty(rolesResult)) { 42 | rolesResult = usersVsRoles.get(principal.getName()); 43 | } 44 | return rolesResult; 45 | } else { 46 | return usersVsRoles.get(principal.getName()); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /jenkins/containers/docker-infra-solr/bin/init.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | echo "No init file specified." 14 | -------------------------------------------------------------------------------- /jenkins/containers/docker-infra-solr/conf/infra-solr.conf: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | infra-solr - nofile 128000 17 | infra-solr - nproc 65536 -------------------------------------------------------------------------------- /jenkins/containers/docker-infra-solr/conf/solr.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | ${host:} 21 | ${jetty.port:} 22 | ${hostContext:solr} 23 | ${zkClientTimeout:15000} 24 | ${genericCoreNodeNames:true} 25 | 26 | --------------------------------------------------------------------------------