AMBARI-19321 : Hive View 2.0 - Minimal view for Hive which includes new UI changes. Also made changes in poms as required (nitirajrathore)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/853a1ce7 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/853a1ce7 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/853a1ce7 Branch: refs/heads/branch-dev-patch-upgrade Commit: 853a1ce780e2e840903d440b0705b7c56f385db7 Parents: 672fdf0 Author: Nitiraj Rathore <[email protected]> Authored: Tue Jan 3 17:12:13 2017 +0530 Committer: Nitiraj Rathore <[email protected]> Committed: Tue Jan 3 17:12:13 2017 +0530 ---------------------------------------------------------------------- .../src/main/resources/view.log4j.properties | 6 +- contrib/views/hive20/pom.xml | 431 +++++++++++ .../apache/ambari/view/hive20/AuthParams.java | 102 +++ .../apache/ambari/view/hive20/BaseService.java | 59 ++ .../ambari/view/hive20/ConnectionDelegate.java | 37 + .../ambari/view/hive20/ConnectionFactory.java | 167 ++++ .../ambari/view/hive20/ConnectionSystem.java | 158 ++++ .../apache/ambari/view/hive20/DataMigrator.java | 101 +++ .../apache/ambari/view/hive20/HelpService.java | 132 ++++ .../view/hive20/HiveJdbcConnectionDelegate.java | 106 +++ .../apache/ambari/view/hive20/HiveViewImpl.java | 52 ++ .../ambari/view/hive20/PropertyValidator.java | 107 +++ .../org/apache/ambari/view/hive20/TestBean.java | 36 + .../hive20/actor/DatabaseChangeNotifier.java | 168 ++++ .../view/hive20/actor/DatabaseManager.java | 285 +++++++ .../ambari/view/hive20/actor/DeathWatch.java | 54 ++ .../ambari/view/hive20/actor/HiveActor.java | 50 ++ .../ambari/view/hive20/actor/JdbcConnector.java | 642 +++++++++++++++ .../ambari/view/hive20/actor/LogAggregator.java | 119 +++ .../view/hive20/actor/MetaDataManager.java | 134 ++++ .../view/hive20/actor/MetaDataRetriever.java | 165 ++++ .../view/hive20/actor/OperationController.java | 408 ++++++++++ .../view/hive20/actor/ResultSetIterator.java | 165 ++++ .../view/hive20/actor/StatementExecutor.java | 150 ++++ .../view/hive20/actor/TableChangeNotifier.java | 95 +++ .../view/hive20/actor/YarnAtsGUIDFetcher.java | 71 ++ .../view/hive20/actor/message/Connect.java | 77 ++ .../view/hive20/actor/message/CursorReset.java | 22 + .../view/hive20/actor/message/ExecuteJob.java | 38 + .../view/hive20/actor/message/ExecuteQuery.java | 23 + .../view/hive20/actor/message/FetchError.java | 42 + .../view/hive20/actor/message/FetchResult.java | 42 + .../actor/message/GetColumnMetadataJob.java | 59 ++ .../view/hive20/actor/message/GetMoreLogs.java | 22 + .../view/hive20/actor/message/HiveJob.java | 48 ++ .../view/hive20/actor/message/HiveMessage.java | 53 ++ .../view/hive20/actor/message/JobRejected.java | 44 ++ .../view/hive20/actor/message/JobSubmitted.java | 38 + .../actor/message/LogAggregationFinished.java | 21 + .../ambari/view/hive20/actor/message/Ping.java | 40 + .../hive20/actor/message/RegisterActor.java | 34 + .../view/hive20/actor/message/ResetCursor.java | 22 + .../hive20/actor/message/ResultInformation.java | 83 ++ .../hive20/actor/message/ResultNotReady.java | 40 + .../view/hive20/actor/message/ResultReady.java | 44 ++ .../view/hive20/actor/message/RunStatement.java | 73 ++ .../hive20/actor/message/SQLStatementJob.java | 64 ++ .../actor/message/StartLogAggregation.java | 34 + .../actor/message/job/AsyncExecutionFailed.java | 46 ++ .../hive20/actor/message/job/CancelJob.java | 40 + .../actor/message/job/ExecuteNextStatement.java | 22 + .../actor/message/job/ExecutionFailed.java | 31 + .../view/hive20/actor/message/job/Failure.java | 37 + .../hive20/actor/message/job/FetchFailed.java | 31 + .../view/hive20/actor/message/job/Next.java | 22 + .../hive20/actor/message/job/NoMoreItems.java | 21 + .../view/hive20/actor/message/job/NoResult.java | 21 + .../view/hive20/actor/message/job/Result.java | 43 ++ .../actor/message/job/ResultSetHolder.java | 33 + .../actor/message/job/SaveDagInformation.java | 52 ++ .../hive20/actor/message/job/SaveGuidToDB.java | 46 ++ .../actor/message/job/UpdateYarnAtsGuid.java | 44 ++ .../hive20/actor/message/lifecycle/CleanUp.java | 21 + .../message/lifecycle/DestroyConnector.java | 52 ++ .../actor/message/lifecycle/FreeConnector.java | 53 ++ .../message/lifecycle/InactivityCheck.java | 21 + .../actor/message/lifecycle/KeepAlive.java | 21 + .../lifecycle/TerminateInactivityCheck.java | 21 + .../backgroundjobs/BackgroundJobController.java | 84 ++ .../view/hive20/client/AsyncJobRunner.java | 38 + .../view/hive20/client/AsyncJobRunnerImpl.java | 143 ++++ .../view/hive20/client/ColumnDescription.java | 45 ++ .../client/ColumnDescriptionExtended.java | 74 ++ .../hive20/client/ColumnDescriptionShort.java | 53 ++ .../view/hive20/client/ConnectionConfig.java | 59 ++ .../ambari/view/hive20/client/Cursor.java | 30 + .../ambari/view/hive20/client/DDLDelegator.java | 40 + .../view/hive20/client/DDLDelegatorImpl.java | 267 +++++++ .../ambari/view/hive20/client/EmptyCursor.java | 110 +++ .../view/hive20/client/HiveAuthCredentials.java | 31 + .../client/HiveAuthRequiredException.java | 27 + .../client/HiveClientAuthRequiredException.java | 25 + .../view/hive20/client/HiveClientException.java | 25 + .../client/HiveClientRuntimeException.java | 25 + .../view/hive20/client/NonPersistentCursor.java | 153 ++++ .../view/hive20/client/PersistentCursor.java | 87 +++ .../apache/ambari/view/hive20/client/Row.java | 74 ++ .../exceptions/NotConnectedException.java | 28 + .../hive20/exceptions/ServiceException.java | 40 + .../hive20/internal/AsyncExecutionFailure.java | 23 + .../hive20/internal/AsyncExecutionSuccess.java | 25 + .../view/hive20/internal/Connectable.java | 65 ++ .../hive20/internal/ConnectionException.java | 25 + .../hive20/internal/ConnectionProperties.java | 94 +++ .../hive20/internal/ConnectionSupplier.java | 37 + .../view/hive20/internal/ContextSupplier.java | 37 + .../hive20/internal/DataStorageSupplier.java | 42 + .../view/hive20/internal/DefaultSupplier.java | 60 ++ .../ambari/view/hive20/internal/Either.java | 79 ++ .../view/hive20/internal/HdfsApiSupplier.java | 63 ++ .../hive20/internal/HiveConnectionWrapper.java | 152 ++++ .../ambari/view/hive20/internal/HiveQuery.java | 71 ++ .../ambari/view/hive20/internal/HiveResult.java | 160 ++++ .../ambari/view/hive20/internal/HiveTask.java | 53 ++ .../view/hive20/internal/HiveTaskMessage.java | 118 +++ .../view/hive20/internal/SafeViewContext.java | 179 +++++ .../view/hive20/internal/dto/ColumnInfo.java | 117 +++ .../view/hive20/internal/dto/ColumnOrder.java | 54 ++ .../view/hive20/internal/dto/DatabaseInfo.java | 85 ++ .../hive20/internal/dto/DatabaseResponse.java | 71 ++ .../hive20/internal/dto/DetailedTableInfo.java | 124 +++ .../ambari/view/hive20/internal/dto/Order.java | 37 + .../view/hive20/internal/dto/PartitionInfo.java | 44 ++ .../view/hive20/internal/dto/Section.java | 46 ++ .../view/hive20/internal/dto/StorageInfo.java | 124 +++ .../view/hive20/internal/dto/TableInfo.java | 79 ++ .../view/hive20/internal/dto/TableMeta.java | 125 +++ .../view/hive20/internal/dto/TableResponse.java | 62 ++ .../view/hive20/internal/dto/ViewInfo.java | 52 ++ .../parsers/AbstractTableMetaParser.java | 177 +++++ .../internal/parsers/ColumnInfoParser.java | 97 +++ .../parsers/CreateTableStatementParser.java | 38 + .../parsers/DetailedTableInfoParser.java | 71 ++ .../hive20/internal/parsers/ParserUtils.java | 52 ++ .../internal/parsers/PartitionInfoParser.java | 76 ++ .../internal/parsers/StorageInfoParser.java | 100 +++ .../internal/parsers/TableMetaParser.java | 30 + .../internal/parsers/TableMetaParserImpl.java | 79 ++ .../parsers/TableMetaSectionParser.java | 30 + .../hive20/internal/parsers/ViewInfoParser.java | 47 ++ .../generators/AlterTableQueryGenerator.java | 365 +++++++++ .../generators/CreateTableQueryGenerator.java | 165 ++++ .../generators/DeleteTableQueryGenerator.java | 67 ++ .../query/generators/QueryGenerationUtils.java | 151 ++++ .../query/generators/QueryGenerator.java | 26 + .../hive20/persistence/DataStoreStorage.java | 140 ++++ .../hive20/persistence/IStorageFactory.java | 23 + .../persistence/InstanceKeyValueStorage.java | 132 ++++ .../hive20/persistence/KeyValueStorage.java | 163 ++++ .../persistence/LocalKeyValueStorage.java | 69 ++ .../persistence/PersistentConfiguration.java | 52 ++ .../ambari/view/hive20/persistence/Storage.java | 77 ++ .../utils/ContextConfigurationAdapter.java | 260 +++++++ .../persistence/utils/FilteringStrategy.java | 32 + .../view/hive20/persistence/utils/Indexed.java | 36 + .../hive20/persistence/utils/ItemNotFound.java | 43 ++ .../utils/OnlyOwnersFilteringStrategy.java | 38 + .../view/hive20/persistence/utils/Owned.java | 36 + .../persistence/utils/PersonalResource.java | 22 + .../persistence/utils/StorageFactory.java | 69 ++ .../hive20/resources/CRUDResourceManager.java | 131 ++++ .../view/hive20/resources/IResourceManager.java | 37 + .../resources/PersonalCRUDResourceManager.java | 99 +++ .../resources/SharedCRUDResourceManager.java | 44 ++ .../resources/browser/ConnectionService.java | 155 ++++ .../view/hive20/resources/browser/DDLProxy.java | 302 ++++++++ .../hive20/resources/browser/DDLService.java | 222 ++++++ .../hive20/resources/browser/FileService.java | 35 + .../resources/browser/HiveBrowserService.java | 259 +++++++ .../hive20/resources/files/FileResource.java | 70 ++ .../hive20/resources/files/FileService.java | 266 +++++++ .../view/hive20/resources/jobs/Aggregator.java | 382 +++++++++ .../resources/jobs/JobResourceProvider.java | 117 +++ .../view/hive20/resources/jobs/JobService.java | 626 +++++++++++++++ .../resources/jobs/JobServiceInternal.java | 35 + .../jobs/ModifyNotificationDelegate.java | 23 + .../ModifyNotificationInvocationHandler.java | 40 + .../jobs/NoOperationStatusSetException.java | 23 + .../resources/jobs/ProgressRetriever.java | 66 ++ .../jobs/ResultsPaginationController.java | 286 +++++++ .../resources/jobs/atsJobs/ATSParser.java | 248 ++++++ .../jobs/atsJobs/ATSParserFactory.java | 39 + .../jobs/atsJobs/ATSRequestsDelegate.java | 47 ++ .../jobs/atsJobs/ATSRequestsDelegateImpl.java | 175 +++++ .../resources/jobs/atsJobs/HiveQueryId.java | 42 + .../resources/jobs/atsJobs/IATSParser.java | 39 + .../hive20/resources/jobs/atsJobs/TezDagId.java | 26 + .../resources/jobs/atsJobs/TezVertexId.java | 24 + .../view/hive20/resources/jobs/rm/RMParser.java | 129 ++++ .../resources/jobs/rm/RMParserFactory.java | 48 ++ .../resources/jobs/rm/RMRequestsDelegate.java | 31 + .../jobs/rm/RMRequestsDelegateImpl.java | 99 +++ .../jobs/viewJobs/IJobControllerFactory.java | 23 + .../hive20/resources/jobs/viewJobs/Job.java | 131 ++++ .../resources/jobs/viewJobs/JobController.java | 44 ++ .../jobs/viewJobs/JobControllerFactory.java | 40 + .../jobs/viewJobs/JobControllerImpl.java | 311 ++++++++ .../hive20/resources/jobs/viewJobs/JobImpl.java | 335 ++++++++ .../hive20/resources/jobs/viewJobs/JobInfo.java | 78 ++ .../jobs/viewJobs/JobResourceManager.java | 93 +++ .../resources/resources/FileResourceItem.java | 78 ++ .../resources/FileResourceResourceManager.java | 65 ++ .../resources/FileResourceResourceProvider.java | 110 +++ .../resources/FileResourceService.java | 180 +++++ .../resources/savedQueries/SavedQuery.java | 96 +++ .../savedQueries/SavedQueryResourceManager.java | 162 ++++ .../SavedQueryResourceProvider.java | 113 +++ .../savedQueries/SavedQueryService.java | 267 +++++++ .../view/hive20/resources/settings/Setting.java | 71 ++ .../settings/SettingsResourceManager.java | 97 +++ .../resources/settings/SettingsService.java | 145 ++++ .../hive20/resources/system/SystemService.java | 48 ++ .../ambari/view/hive20/resources/udfs/UDF.java | 87 +++ .../resources/udfs/UDFResourceManager.java | 65 ++ .../resources/udfs/UDFResourceProvider.java | 111 +++ .../view/hive20/resources/udfs/UDFService.java | 193 +++++ .../hive20/resources/uploads/CSVParams.java | 74 ++ .../uploads/ColumnDescriptionImpl.java | 119 +++ .../hive20/resources/uploads/HiveFileType.java | 30 + .../resources/uploads/TableDataReader.java | 111 +++ .../hive20/resources/uploads/TableInput.java | 51 ++ .../resources/uploads/UploadFromHdfsInput.java | 130 ++++ .../hive20/resources/uploads/UploadService.java | 565 ++++++++++++++ .../resources/uploads/parsers/DataParser.java | 66 ++ .../uploads/parsers/EndOfDocumentException.java | 41 + .../resources/uploads/parsers/IParser.java | 32 + .../resources/uploads/parsers/ParseOptions.java | 61 ++ .../resources/uploads/parsers/ParseUtils.java | 213 +++++ .../resources/uploads/parsers/Parser.java | 161 ++++ .../resources/uploads/parsers/PreviewData.java | 56 ++ .../resources/uploads/parsers/RowIterator.java | 98 +++ .../uploads/parsers/RowMapIterator.java | 29 + .../parsers/csv/commonscsv/CSVIterator.java | 57 ++ .../parsers/csv/commonscsv/CSVParser.java | 88 +++ .../parsers/csv/opencsv/OpenCSVIterator.java | 56 ++ .../parsers/csv/opencsv/OpenCSVParser.java | 92 +++ .../uploads/parsers/json/JSONIterator.java | 160 ++++ .../uploads/parsers/json/JSONParser.java | 85 ++ .../uploads/parsers/xml/XMLIterator.java | 195 +++++ .../uploads/parsers/xml/XMLParser.java | 100 +++ .../uploads/query/DeleteQueryInput.java | 48 ++ .../uploads/query/InsertFromQueryInput.java | 92 +++ .../resources/uploads/query/LoadQueryInput.java | 67 ++ .../resources/uploads/query/QueryGenerator.java | 143 ++++ .../resources/uploads/query/RowFormat.java | 57 ++ .../resources/uploads/query/TableInfo.java | 97 +++ .../utils/BadRequestFormattedException.java | 27 + .../ambari/view/hive20/utils/FilePaginator.java | 127 +++ .../hive20/utils/HiveActorConfiguration.java | 71 ++ .../utils/HiveClientFormattedException.java | 26 + .../view/hive20/utils/LoggingOutputStream.java | 85 ++ .../MisconfigurationFormattedException.java | 47 ++ .../utils/NotFoundFormattedException.java | 27 + .../utils/ResultFetchFormattedException.java | 27 + .../utils/ResultNotReadyFormattedException.java | 27 + .../hive20/utils/ServiceFormattedException.java | 105 +++ .../view/hive20/utils/SharedObjectsFactory.java | 185 +++++ .../UniqueConstraintViolationException.java | 31 + .../hive20/src/main/resources/application.conf | 57 ++ .../views/hive20/src/main/resources/ui/.bowerrc | 4 + .../hive20/src/main/resources/ui/.editorconfig | 20 + .../hive20/src/main/resources/ui/.ember-cli | 27 + .../hive20/src/main/resources/ui/.gitignore | 18 + .../hive20/src/main/resources/ui/.jshintrc | 32 + .../hive20/src/main/resources/ui/.travis.yml | 40 + .../src/main/resources/ui/.watchmanconfig | 21 + .../hive20/src/main/resources/ui/README.md | 28 + .../resources/ui/app/adapters/application.js | 62 ++ .../main/resources/ui/app/adapters/database.js | 22 + .../src/main/resources/ui/app/adapters/ddl.js | 26 + .../resources/ui/app/adapters/hdfs-viewer.js | 26 + .../src/main/resources/ui/app/adapters/job.js | 31 + .../src/main/resources/ui/app/adapters/ping.js | 30 + .../src/main/resources/ui/app/adapters/query.js | 44 ++ .../resources/ui/app/adapters/table-info.js | 37 + .../src/main/resources/ui/app/adapters/table.js | 48 ++ .../hive20/src/main/resources/ui/app/app.js | 36 + .../src/main/resources/ui/app/breakpoints.js | 23 + .../main/resources/ui/app/components/.gitkeep | 0 .../ui/app/components/alert-message-display.js | 45 ++ .../ui/app/components/alert-message.js | 32 + .../resources/ui/app/components/column-item.js | 71 ++ .../resources/ui/app/components/create-table.js | 160 ++++ .../ui/app/components/database-drop-confirm.js | 32 + .../ui/app/components/database-not-empty.js | 29 + .../ui/app/components/database-search-bar.js | 78 ++ .../ui/app/components/edit-setting-item.js | 111 +++ .../ui/app/components/hdfs-viewer-modal.js | 51 ++ .../resources/ui/app/components/job-item.js | 38 + .../resources/ui/app/components/jobs-browser.js | 48 ++ .../resources/ui/app/components/list-filter.js | 45 ++ .../resources/ui/app/components/list-group.js | 23 + .../resources/ui/app/components/list-item.js | 29 + .../components/multiple-database-search-bar.js | 84 ++ .../ui/app/components/property-item.js | 43 ++ .../resources/ui/app/components/query-editor.js | 100 +++ .../ui/app/components/query-result-table.js | 84 ++ .../resources/ui/app/components/setting-item.js | 32 + .../resources/ui/app/components/setting-list.js | 28 + .../app/components/table-advanced-settings.js | 168 ++++ .../ui/app/components/table-columns.js | 52 ++ .../ui/app/components/table-properties.js | 39 + .../resources/ui/app/components/tabs-item.js | 61 ++ .../resources/ui/app/components/tabs-pane.js | 27 + .../ui/app/components/top-application-bar.js | 22 + .../ui/app/configs/create-table-tabs.js | 48 ++ .../main/resources/ui/app/configs/datatypes.js | 34 + .../resources/ui/app/configs/file-format.js | 26 + .../main/resources/ui/app/configs/helpers.js | 151 ++++ .../resources/ui/app/configs/hive-parameters.js | 93 +++ .../app/configs/non-printable-escape-chars.js | 53 ++ .../ui/app/configs/table-level-tabs.js | 66 ++ .../resources/ui/app/configs/top-level-tabs.js | 67 ++ .../main/resources/ui/app/controllers/.gitkeep | 0 .../main/resources/ui/app/controllers/jobs.js | 37 + .../src/main/resources/ui/app/helpers/.gitkeep | 0 .../main/resources/ui/app/helpers/to-json.js | 25 + .../hive20/src/main/resources/ui/app/index.html | 43 ++ .../main/resources/ui/app/initializers/.gitkeep | 0 .../resources/ui/app/initializers/responsive.js | 33 + .../resources/ui/app/mixins/table-common.js | 86 +++ .../src/main/resources/ui/app/models/.gitkeep | 0 .../src/main/resources/ui/app/models/alert.js | 28 + .../src/main/resources/ui/app/models/column.js | 107 +++ .../main/resources/ui/app/models/database.js | 25 + .../src/main/resources/ui/app/models/file.js | 26 + .../src/main/resources/ui/app/models/job.js | 56 ++ .../src/main/resources/ui/app/models/setting.js | 25 + .../main/resources/ui/app/models/table-info.js | 30 + .../resources/ui/app/models/table-property.js | 54 ++ .../src/main/resources/ui/app/models/table.js | 33 + .../src/main/resources/ui/app/resolver.js | 21 + .../hive20/src/main/resources/ui/app/router.js | 59 ++ .../src/main/resources/ui/app/routes/.gitkeep | 0 .../main/resources/ui/app/routes/application.js | 32 + .../main/resources/ui/app/routes/databases.js | 96 +++ .../ui/app/routes/databases/database.js | 25 + .../ui/app/routes/databases/database/index.js | 27 + .../ui/app/routes/databases/database/tables.js | 47 ++ .../routes/databases/database/tables/index.js | 28 + .../app/routes/databases/database/tables/new.js | 71 ++ .../routes/databases/database/tables/table.js | 44 ++ .../databases/database/tables/table/columns.js | 23 + .../databases/database/tables/table/ddl.js | 22 + .../databases/database/tables/table/details.js | 22 + .../databases/database/tables/table/index.js | 25 + .../database/tables/table/partitions.js | 22 + .../databases/database/tables/table/stats.js | 22 + .../databases/database/tables/table/storage.js | 22 + .../database/tables/table/table-meta-router.js | 27 + .../databases/database/tables/table/view.js | 22 + .../resources/ui/app/routes/databases/index.js | 26 + .../src/main/resources/ui/app/routes/jobs.js | 69 ++ .../main/resources/ui/app/routes/messages.js | 32 + .../resources/ui/app/routes/messages/message.js | 31 + .../src/main/resources/ui/app/routes/query.js | 280 +++++++ .../resources/ui/app/routes/savedqueries.js | 22 + .../main/resources/ui/app/routes/settings.js | 93 +++ .../src/main/resources/ui/app/routes/udfs.js | 22 + .../main/resources/ui/app/serializers/file.js | 23 + .../resources/ui/app/services/alert-messages.js | 144 ++++ .../resources/ui/app/services/create-table.js | 182 +++++ .../src/main/resources/ui/app/services/jobs.js | 28 + .../resources/ui/app/services/keep-alive.js | 31 + .../src/main/resources/ui/app/services/query.js | 45 ++ .../src/main/resources/ui/app/styles/app.scss | 774 +++++++++++++++++++ .../ui/app/styles/bootstrap-overrides.scss | 51 ++ .../src/main/resources/ui/app/styles/fonts.scss | 31 + .../ui/app/styles/power-select-overrides.scss | 24 + .../resources/ui/app/templates/application.hbs | 42 + .../ui/app/templates/components/.gitkeep | 0 .../components/alert-message-display.hbs | 34 + .../app/templates/components/alert-message.hbs | 34 + .../ui/app/templates/components/column-item.hbs | 124 +++ .../app/templates/components/create-table.hbs | 63 ++ .../components/database-drop-confirm.hbs | 37 + .../templates/components/database-not-empty.hbs | 38 + .../components/database-search-bar.hbs | 57 ++ .../templates/components/edit-setting-item.hbs | 42 + .../templates/components/hdfs-viewer-modal.hbs | 50 ++ .../ui/app/templates/components/job-item.hbs | 33 + .../app/templates/components/jobs-browser.hbs | 62 ++ .../ui/app/templates/components/list-filter.hbs | 33 + .../ui/app/templates/components/list-group.hbs | 22 + .../ui/app/templates/components/list-item.hbs | 22 + .../components/multiple-database-search-bar.hbs | 45 ++ .../app/templates/components/property-item.hbs | 45 ++ .../app/templates/components/query-editor.hbs | 21 + .../templates/components/query-result-table.hbs | 53 ++ .../app/templates/components/setting-item.hbs | 28 + .../app/templates/components/setting-list.hbs | 37 + .../components/table-advanced-settings.hbs | 226 ++++++ .../app/templates/components/table-columns.hbs | 42 + .../templates/components/table-properties.hbs | 40 + .../ui/app/templates/components/tabs-item.hbs | 24 + .../ui/app/templates/components/tabs-pane.hbs | 21 + .../components/top-application-bar.hbs | 25 + .../resources/ui/app/templates/databases.hbs | 39 + .../ui/app/templates/databases/database.hbs | 19 + .../app/templates/databases/database/tables.hbs | 45 ++ .../templates/databases/database/tables/new.hbs | 42 + .../databases/database/tables/table.hbs | 42 + .../databases/database/tables/table/columns.hbs | 38 + .../databases/database/tables/table/ddl.hbs | 27 + .../databases/database/tables/table/details.hbs | 65 ++ .../database/tables/table/partitions.hbs | 38 + .../databases/database/tables/table/stats.hbs | 17 + .../databases/database/tables/table/storage.hbs | 64 ++ .../databases/database/tables/table/view.hbs | 40 + .../main/resources/ui/app/templates/jobs.hbs | 23 + .../resources/ui/app/templates/messages.hbs | 54 ++ .../ui/app/templates/messages/message.hbs | 48 ++ .../main/resources/ui/app/templates/query.hbs | 88 +++ .../resources/ui/app/templates/savedqueries.hbs | 19 + .../resources/ui/app/templates/settings.hbs | 32 + .../main/resources/ui/app/templates/tables.hbs | 19 + .../main/resources/ui/app/templates/udfs.hbs | 19 + .../ui/app/utils/hdfs-picker-config.js | 32 + .../hive20/src/main/resources/ui/bower.json | 11 + .../src/main/resources/ui/config/environment.js | 64 ++ .../src/main/resources/ui/ember-cli-build.js | 68 ++ .../hive20/src/main/resources/ui/package.json | 64 ++ .../fonts/roboto/roboto-v15-latin-300.eot | Bin 0 -> 16205 bytes .../fonts/roboto/roboto-v15-latin-300.svg | 314 ++++++++ .../fonts/roboto/roboto-v15-latin-300.ttf | Bin 0 -> 32664 bytes .../fonts/roboto/roboto-v15-latin-300.woff | Bin 0 -> 18520 bytes .../fonts/roboto/roboto-v15-latin-300.woff2 | Bin 0 -> 14524 bytes .../fonts/roboto/roboto-v15-latin-regular.eot | Bin 0 -> 16227 bytes .../fonts/roboto/roboto-v15-latin-regular.svg | 308 ++++++++ .../fonts/roboto/roboto-v15-latin-regular.ttf | Bin 0 -> 32652 bytes .../fonts/roboto/roboto-v15-latin-regular.woff | Bin 0 -> 18520 bytes .../fonts/roboto/roboto-v15-latin-regular.woff2 | Bin 0 -> 14584 bytes .../hive20/src/main/resources/ui/testem.js | 31 + .../src/main/resources/ui/tests/.jshintrc | 53 ++ .../resources/ui/tests/helpers/destroy-app.js | 23 + .../resources/ui/tests/helpers/flash-message.js | 24 + .../ui/tests/helpers/module-for-acceptance.js | 41 + .../main/resources/ui/tests/helpers/resolver.js | 29 + .../resources/ui/tests/helpers/responsive.js | 76 ++ .../resources/ui/tests/helpers/start-app.js | 36 + .../src/main/resources/ui/tests/index.html | 51 ++ .../resources/ui/tests/integration/.gitkeep | 0 .../src/main/resources/ui/tests/test-helper.js | 28 + .../src/main/resources/ui/tests/unit/.gitkeep | 0 .../src/main/resources/ui/vendor/.gitkeep | 0 .../src/main/resources/view.log4j.properties | 27 + .../views/hive20/src/main/resources/view.xml | 362 +++++++++ .../view/hive20/AsyncJobRunnerImplTest.java | 138 ++++ .../view/hive20/ConnectionFailuresTest.java | 157 ++++ .../hive20/HiveJdbcConnectionDelegateTest.java | 105 +++ .../ambari/view/hive20/JobExecutionTest.java | 116 +++ .../view/hive20/PropertyValidatorTest.java | 113 +++ .../view/hive20/ResultSetIteratorTest.java | 100 +++ .../internal/parsers/ParserUtilsTest.java | 66 ++ .../AlterTableQueryGenerationSpecTest.groovy | 59 ++ .../AlterTableQueryGeneratorTest.java | 94 +++ .../CreateTableQueryGeneratorTest.java | 101 +++ .../hive20/resources/upload/CSVParserTest.java | 275 +++++++ .../resources/upload/DataParserCSVTest.java | 326 ++++++++ .../resources/upload/DataParserJSONTest.java | 263 +++++++ .../resources/upload/DataParserXMLTest.java | 295 +++++++ .../hive20/resources/upload/JsonParserTest.java | 146 ++++ .../resources/upload/OpenCSVParserTest.java | 313 ++++++++ .../hive20/resources/upload/OpenCSVTest.java | 245 ++++++ .../hive20/resources/upload/ParseUtilsTest.java | 56 ++ .../resources/upload/QueryGeneratorTest.java | 108 +++ .../resources/upload/TableDataReaderTest.java | 127 +++ .../hive20/resources/upload/XMLParserTest.java | 135 ++++ .../rest/postman/hive2.postman_collection.json | 107 +++ contrib/views/pom.xml | 1 + pom.xml | 2 + 461 files changed, 36270 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/853a1ce7/contrib/views/hive-next/src/main/resources/view.log4j.properties ---------------------------------------------------------------------- diff --git a/contrib/views/hive-next/src/main/resources/view.log4j.properties b/contrib/views/hive-next/src/main/resources/view.log4j.properties index 2e466cd..3de9afe 100644 --- a/contrib/views/hive-next/src/main/resources/view.log4j.properties +++ b/contrib/views/hive-next/src/main/resources/view.log4j.properties @@ -24,8 +24,4 @@ log4j.appender.hiveNextView.layout=org.apache.log4j.PatternLayout log4j.appender.hiveNextView.layout.ConversionPattern=%d{DATE} %5p [%t] [%X{viewName} %X{viewVersion} %X{viewInstanceName}] %c{1}:%L - %m%n log4j.logger.org.apache.ambari.view.hive2=INFO,hiveNextView -log4j.logger.org.apache.hive.jdbc=INFO,hiveNextView -log4j.logger.akka.actor=INFO,hiveNextView -log4j.additivity.org.apache.ambari.view.hive2 = false -log4j.additivity.org.apache.hive.jdbc = false -log4j.additivity.akka.actor = false +log4j.additivity.org.apache.ambari.view.hive2 = false \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/853a1ce7/contrib/views/hive20/pom.xml ---------------------------------------------------------------------- diff --git a/contrib/views/hive20/pom.xml b/contrib/views/hive20/pom.xml new file mode 100644 index 0000000..e9bde1d --- /dev/null +++ b/contrib/views/hive20/pom.xml @@ -0,0 +1,431 @@ +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.apache.ambari.contrib.views</groupId> + <artifactId>hive20</artifactId> + <version>2.0.0.0-SNAPSHOT</version> + <name>Hive 2.0</name> + + <parent> + <groupId>org.apache.ambari.contrib.views</groupId> + <artifactId>ambari-contrib-views</artifactId> + <version>2.0.0.0-SNAPSHOT</version> + </parent> + + <dependencies> + <dependency> + <groupId>com.jayway.jsonpath</groupId> + <artifactId>json-path</artifactId> + <version>2.0.0</version> + </dependency> + <dependency> + <groupId>com.google.inject</groupId> + <artifactId>guice</artifactId> + <version>4.1.0</version> + </dependency> + <dependency> + <groupId>com.sun.jersey.contribs</groupId> + <artifactId>jersey-multipart</artifactId> + </dependency> + <dependency> + <groupId>com.sun.jersey</groupId> + <artifactId>jersey-client</artifactId> + </dependency> + <dependency> + <groupId>com.sun.jersey</groupId> + <artifactId>jersey-core</artifactId> + </dependency> + <dependency> + <groupId>com.sun.jersey</groupId> + <artifactId>jersey-json</artifactId> + </dependency> + <dependency> + <groupId>com.googlecode.json-simple</groupId> + <artifactId>json-simple</artifactId> + <version>1.1.1</version> + </dependency> + <dependency> + <groupId>commons-configuration</groupId> + <artifactId>commons-configuration</artifactId> + <version>1.6</version> + </dependency> + <dependency> + <groupId>com.opencsv</groupId> + <artifactId>opencsv</artifactId> + <version>3.8</version> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-collections4</artifactId> + <version>4.0</version> + </dependency> + <dependency> + <groupId>org.apache.ambari</groupId> + <artifactId>ambari-views</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>com.google.code.gson</groupId> + <artifactId>gson</artifactId> + <version>2.2.2</version> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>javax.servlet-api</artifactId> + <version>3.0.1</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <version>1.7.5</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-simple</artifactId> + <version>1.7.5</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.hadoop</groupId> + <artifactId>hadoop-hdfs</artifactId> + <version>${hadoop.version}</version> + <exclusions> + <exclusion> + <groupId>tomcat</groupId> + <artifactId>jasper-runtime</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.apache.hadoop</groupId> + <artifactId>hadoop-common</artifactId> + <version>${hadoop.version}</version> + <exclusions> + <exclusion> + <groupId>tomcat</groupId> + <artifactId>jasper-runtime</artifactId> + </exclusion> + <exclusion> + <groupId>tomcat</groupId> + <artifactId>jasper-compiler</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.apache.hadoop</groupId> + <artifactId>hadoop-mapreduce-client-common</artifactId> + <version>${hadoop.version}</version> + </dependency> + <dependency> + <groupId>org.apache.hadoop</groupId> + <artifactId>hadoop-mapreduce-client-core</artifactId> + <version>${hadoop.version}</version> + </dependency> + <dependency> + <groupId>org.apache.hadoop</groupId> + <artifactId>hadoop-yarn-client</artifactId> + <version>${hadoop.version}</version> + </dependency> + <dependency> + <groupId>javax.ws.rs</groupId> + <artifactId>javax.ws.rs-api</artifactId> + <version>2.0</version> + </dependency> + <dependency> + <groupId>org.apache.hive</groupId> + <artifactId>hive-jdbc</artifactId> + <version>${hive-version}</version> + <exclusions> + <exclusion> + <groupId>tomcat</groupId> + <artifactId>jasper-runtime</artifactId> + </exclusion> + <exclusion> + <groupId>tomcat</groupId> + <artifactId>jasper-compiler</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>commons-cli</groupId> + <artifactId>commons-cli</artifactId> + <version>1.2</version> + </dependency> + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + <version>2.2</version> + </dependency> + <dependency> + <groupId>org.apache.thrift</groupId> + <artifactId>libthrift</artifactId> + <version>0.9.0</version> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.easymock</groupId> + <artifactId>easymock</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>com.typesafe.akka</groupId> + <artifactId>akka-testkit_2.11</artifactId> + <version>2.3.15</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.hadoop</groupId> + <artifactId>hadoop-minicluster</artifactId> + <version>${hadoop.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.ambari.contrib.views</groupId> + <artifactId>ambari-views-utils</artifactId> + <version>2.0.0.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>commons-validator</groupId> + <artifactId>commons-validator</artifactId> + <version>1.4.0</version> + </dependency> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>2.4</version> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + <version>4.5.2</version> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpcore</artifactId> + <version>4.4.3</version> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-csv</artifactId> + <version>1.1</version> + </dependency> + <dependency> + <groupId>com.typesafe.akka</groupId> + <artifactId>akka-actor_2.11</artifactId> + <version>2.3.15</version> + </dependency> + <dependency> + <groupId>org.apache.ambari.contrib.views</groupId> + <artifactId>ambari-views-commons</artifactId> + <version>2.0.0.0-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.codehaus.groovy</groupId> + <artifactId>groovy-all</artifactId> + <version>2.4.4</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.spockframework</groupId> + <artifactId>spock-core</artifactId> + <version>1.0-groovy-2.4</version> + <scope>test</scope> + </dependency> + </dependencies> + + <properties> + <ambari.dir>../../..</ambari.dir> + <hive-version>2.1.0</hive-version> + <ambari.version>1.3.0.0-SNAPSHOT</ambari.version> + </properties> + <build> + <plugins> + <plugin> + <groupId>org.codehaus.gmavenplus</groupId> + <artifactId>gmavenplus-plugin</artifactId> + <version>1.4</version> + <executions> + <execution> + <goals> + <goal>generateStubs</goal> + <goal>compile</goal> + <goal>testGenerateStubs</goal> + <goal>testCompile</goal> + </goals> + </execution> + </executions> + <dependencies> + <dependency> + <groupId>org.codehaus.groovy</groupId> + <artifactId>groovy-all</artifactId> + <version>2.4.4</version> + <scope>runtime</scope> + </dependency> + </dependencies> + </plugin> + <!-- Building frontend --> + <plugin> + <groupId>com.github.eirslett</groupId> + <artifactId>frontend-maven-plugin</artifactId> + <version>0.0.16</version> + <configuration> + <nodeVersion>v4.5.0</nodeVersion> + <npmVersion>2.15.0</npmVersion> + <workingDirectory>src/main/resources/ui/</workingDirectory> + </configuration> + <executions> + <execution> + <id>install node and npm</id> + <phase>generate-sources</phase> + <goals> + <goal>install-node-and-npm</goal> + </goals> + </execution> + <execution> + <id>npm install</id> + <phase>generate-sources</phase> + <goals> + <goal>npm</goal> + </goals> + <configuration> + <arguments>install --python="${project.basedir}/../src/main/unix/ambari-python-wrap" --unsafe-perm</arguments> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>exec-maven-plugin</artifactId> + <groupId>org.codehaus.mojo</groupId> + <version>1.3.2</version> + <executions> + <execution> + <id>Hive build</id> + <phase>generate-sources</phase> + <goals> + <goal>exec</goal> + </goals> + <configuration> + <workingDirectory>${basedir}/src/main/resources/ui</workingDirectory> + <executable>node/node</executable> + <arguments> + <argument>node_modules/.bin/ember</argument> + <argument>build</argument> + <argument>--environment=production</argument> + </arguments> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.1</version> + <configuration> + <source>1.7</source> + <target>1.7</target> + </configuration> + </plugin> + <plugin> + <artifactId>maven-dependency-plugin</artifactId> + <executions> + <execution> + <phase>generate-resources</phase> + <goals> + <goal>copy-dependencies</goal> + </goals> + <configuration> + <outputDirectory>${project.build.directory}/lib</outputDirectory> + <includeScope>runtime</includeScope> + </configuration> + </execution> + <execution> + <id>copy-artifact</id> + <phase>package</phase> + <goals> + <goal>copy</goal> + </goals> + <configuration> + <artifactItems> + <artifactItem> + <groupId>${project.groupId}</groupId> + <artifactId>${project.artifactId}</artifactId> + <version>${project.version}</version> + <type>${project.packaging}</type> + </artifactItem> + </artifactItems> + <outputDirectory>${views.jars.dir.rel}</outputDirectory> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.vafer</groupId> + <artifactId>jdeb</artifactId> + <version>1.0.1</version> + <executions> + <execution> + <phase>none</phase> + <goals> + <goal>jdeb</goal> + </goals> + </execution> + </executions> + <configuration> + <submodules>false</submodules> + </configuration> + </plugin> + </plugins> + <resources> + <resource> + <directory>src/main/resources</directory> + <filtering>false</filtering> + <includes> + <include>META-INF/**/*</include> + <include>view.xml</include> + <include>view.log4j.properties</include> + <include>application.conf</include> + </includes> + </resource> + <resource> + <directory>src/main/resources/ui/dist</directory> + <filtering>false</filtering> + </resource> + <resource> + <directory>src/main/resources/ui/bower_components/polestar</directory> + <filtering>false</filtering> + <targetPath>polestar</targetPath> + </resource> + <resource> + <directory>src/main/resources/ui/bower_components/voyager</directory> + <filtering>false</filtering> + <targetPath>voyager</targetPath> + </resource> + <resource> + <targetPath>WEB-INF/lib</targetPath> + <filtering>false</filtering> + <directory>target/lib</directory> + </resource> + </resources> + </build> +</project> http://git-wip-us.apache.org/repos/asf/ambari/blob/853a1ce7/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/AuthParams.java ---------------------------------------------------------------------- diff --git a/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/AuthParams.java b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/AuthParams.java new file mode 100644 index 0000000..98e6caf --- /dev/null +++ b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/AuthParams.java @@ -0,0 +1,102 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.view.hive20; + +import org.apache.ambari.view.ViewContext; +import org.apache.commons.lang3.StringUtils; +import org.apache.hadoop.security.UserGroupInformation; + +import java.io.IOException; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +/** + * Holds session parameters pulled from the + * view context + */ +public class AuthParams { + private static final String HIVE_SESSION_PARAMS = "hive.session.params"; + private Map<String, String> sessionParams = new HashMap<>(); + private final ViewContext context; + + public AuthParams(ViewContext context) { + sessionParams = parseSessionParams(context.getProperties().get(HIVE_SESSION_PARAMS)); + this.context = context; + } + + /** + * Returns a map created by parsing the parameters in view context + * @param params session parameters as string + * @return parsed session parameters + */ + private Map<String, String> parseSessionParams(String params) { + Map<String, String> sessions = new HashMap<>(); + if (StringUtils.isEmpty(params)) + return sessions; + String[] splits = params.split(";"); + for (String split : splits) { + String[] paramSplit = split.trim().split("="); + if ("auth".equals(paramSplit[0]) || "proxyuser".equals(paramSplit[0])) { + sessions.put(paramSplit[0], paramSplit[1]); + } + } + return Collections.unmodifiableMap(sessions); + } + + /** + * Gets the proxy user + * @return User and group information + * @throws IOException + */ + public UserGroupInformation getProxyUser() throws IOException { + UserGroupInformation ugi; + String proxyuser = null; + if(context.getCluster() != null) { + proxyuser = context.getCluster().getConfigurationValue("cluster-env","ambari_principal_name"); + } + + if(StringUtils.isEmpty(proxyuser)) { + if (sessionParams.containsKey("proxyuser")) { + ugi = UserGroupInformation.createRemoteUser(sessionParams.get("proxyuser")); + } else { + ugi = UserGroupInformation.getCurrentUser(); + } + } else { + ugi = UserGroupInformation.createRemoteUser(proxyuser); + } + ugi.setAuthenticationMethod(getAuthenticationMethod()); + return ugi; + } + + /** + * Get the Authentication method + * @return + */ + private UserGroupInformation.AuthenticationMethod getAuthenticationMethod() { + UserGroupInformation.AuthenticationMethod authMethod; + if (sessionParams.containsKey("auth") && !StringUtils.isEmpty(sessionParams.get("auth"))) { + String authName = sessionParams.get("auth"); + authMethod = UserGroupInformation.AuthenticationMethod.valueOf(authName.toUpperCase()); + } else { + authMethod = UserGroupInformation.AuthenticationMethod.SIMPLE; + } + return authMethod; + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/853a1ce7/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/BaseService.java ---------------------------------------------------------------------- diff --git a/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/BaseService.java b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/BaseService.java new file mode 100644 index 0000000..4d16340 --- /dev/null +++ b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/BaseService.java @@ -0,0 +1,59 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.view.hive20; + +import org.apache.ambari.view.ViewContext; +import org.apache.ambari.view.hive20.client.ConnectionConfig; +import org.apache.ambari.view.hive20.utils.SharedObjectsFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.inject.Inject; + + +/** + * Parent service + */ +public class BaseService { + @Inject + protected ViewContext context; + + protected final static Logger LOG = + LoggerFactory.getLogger(BaseService.class); + + private SharedObjectsFactory sharedObjectsFactory; + public SharedObjectsFactory getSharedObjectsFactory() { + if (sharedObjectsFactory == null) { + sharedObjectsFactory = new SharedObjectsFactory(context); + } + return sharedObjectsFactory; + } + + public void setSharedObjectsFactory(SharedObjectsFactory sharedObjectsFactory) { + this.sharedObjectsFactory = sharedObjectsFactory; + } + + public BaseService() { +// Thread.currentThread().setContextClassLoader(null); + } + + protected ConnectionConfig getHiveConnectionConfig() { + return ConnectionFactory.create(context); + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/853a1ce7/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/ConnectionDelegate.java ---------------------------------------------------------------------- diff --git a/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/ConnectionDelegate.java b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/ConnectionDelegate.java new file mode 100644 index 0000000..f3c4e91 --- /dev/null +++ b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/ConnectionDelegate.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.view.hive20; + +import com.google.common.base.Optional; +import org.apache.ambari.view.hive20.actor.message.GetColumnMetadataJob; +import org.apache.hive.jdbc.HiveConnection; +import org.apache.hive.jdbc.HiveStatement; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public interface ConnectionDelegate { + HiveStatement createStatement(HiveConnection connection) throws SQLException; + Optional<ResultSet> execute(String statement) throws SQLException; + Optional<ResultSet> execute(HiveConnection connection, String statement) throws SQLException; + ResultSet getColumnMetadata(HiveConnection connection, GetColumnMetadataJob job) throws SQLException; + void cancel() throws SQLException; + void closeResultSet(); + void closeStatement(); +} http://git-wip-us.apache.org/repos/asf/ambari/blob/853a1ce7/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/ConnectionFactory.java ---------------------------------------------------------------------- diff --git a/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/ConnectionFactory.java b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/ConnectionFactory.java new file mode 100644 index 0000000..9e36a31 --- /dev/null +++ b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/ConnectionFactory.java @@ -0,0 +1,167 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.view.hive20; + +import com.google.common.base.Function; +import com.google.common.base.Joiner; +import com.google.common.base.Optional; +import com.google.common.base.Strings; +import com.google.common.collect.FluentIterable; +import org.apache.ambari.view.ViewContext; +import org.apache.ambari.view.hive20.client.ConnectionConfig; + +import java.util.List; + +public class ConnectionFactory { + + private static final String ZK_HIVE_DYN_SERVICE_DISCOVERY_KEY = "hive.server2.support.dynamic.service.discovery"; + private static final String ZK_HIVE_NAMESPACE_KEY = "hive.server2.zookeeper.namespace"; + private static final String ZK_HIVE_QUORUM = "hive.zookeeper.quorum"; + + private static final String AMBARI_HIVE_SERVICE_NAME = "HIVE"; + private static final String AMBARI_HIVESERVER_COMPONENT_NAME = "HIVE_SERVER"; + + private static final String HIVE_SITE = "hive-site"; + private static final String HIVE_INTERACTIVE_SITE = "hive-interactive-site"; + + private static final String HIVE_JDBC_URL_KEY = "hive.jdbc.url"; + private static final String HIVE_SESSION_PARAMS = "hive.session.params"; + private static final String HIVE_LDAP_CONFIG = "hive.ldap.configured"; + + private static final String BINARY_PORT_KEY = "hive.server2.thrift.port"; + private static final String HIVE_AUTH_MODE = "hive.server2.authentication"; + private static final String HTTP_PORT_KEY = "hive.server2.thrift.http.port"; + private static final String HIVE_TRANSPORT_MODE_KEY = "hive.server2.transport.mode"; + private static final String HTTP_PATH_KEY = "hive.server2.thrift.http.path"; + private static final String HS2_PROXY_USER = "hive.server2.proxy.user"; + private static final String USE_HIVE_INTERACTIVE_MODE = "use.hive.interactive.mode"; + + public static boolean isLdapEnabled(ViewContext context){ + if (context.getCluster() == null) { + return context.getProperties().get(HIVE_LDAP_CONFIG).equalsIgnoreCase("true"); + } + return context.getCluster().getConfigurationValue(HIVE_SITE,HIVE_AUTH_MODE).equalsIgnoreCase("ldap"); + } + + public static ConnectionConfig create(ViewContext context) { + + String jdbcUrl; + if (context.getCluster() == null) { + jdbcUrl = getConnectFromCustom(context); + } else { + if (zookeeperConfigured(context)) { + jdbcUrl = getFromClusterZookeeperConfig(context); + } else { + jdbcUrl = getFromHiveConfiguration(context); + } + } + + String userName = context.getUsername(); + if(isLdapEnabled(context)){ + Optional<String> opPassword = ConnectionSystem.getInstance().getPassword(context); + if(opPassword.isPresent()){ + return new ConnectionConfig(userName, opPassword.get(), jdbcUrl); + } + } + return new ConnectionConfig(userName, "", jdbcUrl); + } + + + private static String getFromHiveConfiguration(ViewContext context) { + boolean useLLAP = Boolean.valueOf(context.getProperties().get(USE_HIVE_INTERACTIVE_MODE)); + String transportMode = context.getCluster().getConfigurationValue(HIVE_SITE, HIVE_TRANSPORT_MODE_KEY); + String binaryPort = context.getCluster().getConfigurationValue(HIVE_SITE, BINARY_PORT_KEY); + String httpPort = context.getCluster().getConfigurationValue(HIVE_SITE, HTTP_PORT_KEY); + if (useLLAP) { + binaryPort = context.getCluster().getConfigurationValue(HIVE_INTERACTIVE_SITE, BINARY_PORT_KEY); + httpPort = context.getCluster().getConfigurationValue(HIVE_INTERACTIVE_SITE, HTTP_PORT_KEY); + } + + + String pathKey = context.getCluster().getConfigurationValue(HIVE_SITE, HTTP_PATH_KEY); + List<String> hiveHosts = context.getCluster().getHostsForServiceComponent(AMBARI_HIVE_SERVICE_NAME, AMBARI_HIVESERVER_COMPONENT_NAME); + String sessionParams = context.getProperties().get(HIVE_SESSION_PARAMS); + + boolean isBinary = transportMode.equalsIgnoreCase("binary"); + final String port = isBinary ? binaryPort : httpPort; + + List<String> hostPorts = FluentIterable.from(hiveHosts).transform(new Function<String, String>() { + @Override + public String apply(String input) { + return input + ":" + port; + } + }).toList(); + + String concatHostPorts = Joiner.on(",").join(hostPorts); + + StringBuilder builder = new StringBuilder(); + builder.append("jdbc:hive2://") + .append(concatHostPorts); + if(!Strings.isNullOrEmpty(sessionParams)) { + builder.append(";").append(sessionParams); + } + + if (!isBinary) { + builder.append(";").append("transportMode=http;httpPath=").append(pathKey); + } + + return builder.toString(); + } + + private static String getFromClusterZookeeperConfig(ViewContext context) { + boolean useLLAP = Boolean.valueOf(context.getProperties().get(USE_HIVE_INTERACTIVE_MODE)); + String quorum = context.getCluster().getConfigurationValue(HIVE_SITE, ZK_HIVE_QUORUM); + + String namespace = context.getCluster().getConfigurationValue(HIVE_SITE, ZK_HIVE_NAMESPACE_KEY); + if (useLLAP) { + namespace = context.getCluster().getConfigurationValue(HIVE_INTERACTIVE_SITE, ZK_HIVE_NAMESPACE_KEY); + } + + String sessionParams = context.getProperties().get(HIVE_SESSION_PARAMS); + + String formatted = String.format("jdbc:hive2://%s/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=%s", quorum, namespace); + if (Strings.isNullOrEmpty(sessionParams)) { + sessionParams = ""; + } + + if (!sessionParams.contains(HS2_PROXY_USER)) { + if (!sessionParams.isEmpty()) { + sessionParams += ";"; + } + sessionParams = sessionParams + HS2_PROXY_USER + "=" + context.getUsername(); + } + + if (sessionParams.isEmpty()) { + return formatted; + } + return formatted + ";" + sessionParams; + } + + private static boolean zookeeperConfigured(ViewContext context) { + boolean fromHiveSite = Boolean.valueOf(context.getCluster().getConfigurationValue(HIVE_SITE, ZK_HIVE_DYN_SERVICE_DISCOVERY_KEY)); + boolean fromHiveInteractiveSite = Boolean.valueOf(context.getCluster().getConfigurationValue(HIVE_INTERACTIVE_SITE, ZK_HIVE_DYN_SERVICE_DISCOVERY_KEY)); + return fromHiveInteractiveSite || fromHiveSite; + } + + private static String getConnectFromCustom(ViewContext context) { + String jdbcUrl = context.getProperties().get(HIVE_JDBC_URL_KEY); + String hiveSessionParams = context.getProperties().get(HIVE_SESSION_PARAMS); + return jdbcUrl + ";" + hiveSessionParams; + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/853a1ce7/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/ConnectionSystem.java ---------------------------------------------------------------------- diff --git a/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/ConnectionSystem.java b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/ConnectionSystem.java new file mode 100644 index 0000000..40b4c04 --- /dev/null +++ b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/ConnectionSystem.java @@ -0,0 +1,158 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.view.hive20; + +import akka.actor.ActorRef; +import akka.actor.ActorSystem; +import akka.actor.Inbox; +import akka.actor.PoisonPill; +import akka.actor.Props; +import com.google.common.base.Optional; +import com.typesafe.config.Config; +import com.typesafe.config.ConfigFactory; +import org.apache.ambari.view.ViewContext; +import org.apache.ambari.view.hive20.actor.DeathWatch; +import org.apache.ambari.view.hive20.actor.MetaDataManager; +import org.apache.ambari.view.hive20.actor.OperationController; +import org.apache.ambari.view.hive20.internal.ConnectionSupplier; +import org.apache.ambari.view.hive20.internal.DataStorageSupplier; +import org.apache.ambari.view.hive20.internal.HdfsApiSupplier; +import org.apache.ambari.view.hive20.internal.SafeViewContext; +import org.apache.parquet.Strings; + +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +public class ConnectionSystem { + + private static final String ACTOR_SYSTEM_NAME = "HiveViewActorSystem"; + private ActorSystem actorSystem = null; + private static volatile ConnectionSystem instance = null; + private static final Object lock = new Object(); + private static Map<String, Map<String, ActorRef>> operationControllerMap = new ConcurrentHashMap<>(); + private final Map<String, ActorRef> metaDataManagerMap = new ConcurrentHashMap<>(); + + // credentials map stores usernames and passwords + private static Map<String, String> credentialsMap = new ConcurrentHashMap<>(); + + private ConnectionSystem() { + ClassLoader classLoader = getClass().getClassLoader(); + Config config = ConfigFactory.load(classLoader); + this.actorSystem = ActorSystem.create(ACTOR_SYSTEM_NAME, config, classLoader); + } + + public static ConnectionSystem getInstance() { + if (instance == null) { + synchronized (lock) { + if (instance == null) { + instance = new ConnectionSystem(); + } + } + } + return instance; + } + + private ActorRef createOperationController(ViewContext context) { + ActorRef deathWatch = actorSystem.actorOf(Props.create(DeathWatch.class)); + return actorSystem.actorOf( + Props.create(OperationController.class, actorSystem, deathWatch, context, + new ConnectionSupplier(), new DataStorageSupplier(), new HdfsApiSupplier())); + } + + public ActorSystem getActorSystem() { + return actorSystem; + } + + /** + * Returns one operationController per View Instance + * + * @param viewContext + * @return operationController Instance + */ + public synchronized ActorRef getOperationController(ViewContext viewContext) { + SafeViewContext context = new SafeViewContext(viewContext); + String instanceName = context.getInstanceName(); + ActorRef ref = null; + Map<String, ActorRef> stringActorRefMap = operationControllerMap.get(instanceName); + if (stringActorRefMap != null) { + ref = stringActorRefMap.get(context.getUsername()); + } + if (ref == null) { + ref = createOperationController(context); + if (stringActorRefMap == null) { + stringActorRefMap = new HashMap<>(); + stringActorRefMap.put(context.getUsername(), ref); + operationControllerMap.put(instanceName, stringActorRefMap); + } else { + stringActorRefMap.put(context.getUsername(), ref); + } + } + return ref; + } + + /** + * Returns one MetaDataManager actor per view instance + * @param context - View context + * @return MetaDataManager actor + */ + public synchronized ActorRef getMetaDataManager(ViewContext context) { + SafeViewContext safeViewContext = new SafeViewContext(context); + String instanceName = safeViewContext.getInstanceName(); + ActorRef metaDataManager = metaDataManagerMap.get(instanceName); + if(metaDataManager == null) { + metaDataManager = createMetaDataManager(safeViewContext); + metaDataManagerMap.put(instanceName, metaDataManager); + } + + return metaDataManager; + } + + private ActorRef createMetaDataManager(SafeViewContext safeViewContext) { + return actorSystem.actorOf(MetaDataManager.props(safeViewContext)); + } + + public synchronized void persistCredentials(String user,String password){ + if(!Strings.isNullOrEmpty(password)){ + credentialsMap.put(user,password); + } + } + + + public synchronized Optional<String> getPassword(ViewContext viewContext){ + String pass = credentialsMap.get(viewContext.getUsername()); + return Optional.fromNullable(pass); + } + + public void removeOperationControllerFromCache(String viewInstanceName) { + Map<String, ActorRef> refs = operationControllerMap.remove(viewInstanceName); + if (refs != null) { + for (ActorRef ref : refs.values()) { + Inbox inbox = Inbox.create(getActorSystem()); + inbox.send(ref, PoisonPill.getInstance()); + } + } + } + + public void shutdown() { + if (!actorSystem.isTerminated()) { + actorSystem.shutdown(); + } + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/853a1ce7/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/DataMigrator.java ---------------------------------------------------------------------- diff --git a/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/DataMigrator.java b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/DataMigrator.java new file mode 100644 index 0000000..ae0a958 --- /dev/null +++ b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/DataMigrator.java @@ -0,0 +1,101 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.view.hive20; + +import org.apache.ambari.view.ViewContext; +import org.apache.ambari.view.migration.ViewDataMigrationContext; +import org.apache.ambari.view.migration.ViewDataMigrationException; +import org.apache.ambari.view.migration.ViewDataMigrator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.inject.Inject; +import java.util.HashMap; +import java.util.Map; + +/** + * Data migrator that maps persistence entities names + * from Hive 1 to entities of Hive 2. + */ +public class DataMigrator implements ViewDataMigrator { + private final static Logger LOG = + LoggerFactory.getLogger(DataMigrator.class); + + /** + * The view context of target migration instance. + */ + @Inject + private ViewContext viewContext; + + /** + * The migration context. + */ + @Inject + private ViewDataMigrationContext migrationContext; + + private static final Map<String, Class> hive1EntitiesMapping; + static + { + hive1EntitiesMapping = new HashMap<>(); + hive1EntitiesMapping.put("org.apache.ambari.view.hive.resources.jobs.viewJobs.JobImpl", + org.apache.ambari.view.hive20.resources.jobs.viewJobs.JobImpl.class); + hive1EntitiesMapping.put("org.apache.ambari.view.hive.resources.savedQueries.SavedQuery", + org.apache.ambari.view.hive20.resources.savedQueries.SavedQuery.class); + hive1EntitiesMapping.put("org.apache.ambari.view.hive.resources.udfs.UDF", + org.apache.ambari.view.hive20.resources.udfs.UDF.class); + hive1EntitiesMapping.put("org.apache.ambari.view.hive.resources.resources.FileResourceItem", + org.apache.ambari.view.hive20.resources.resources.FileResourceItem.class); + hive1EntitiesMapping.put("org.apache.ambari.view.hive.TestBean", + org.apache.ambari.view.hive20.TestBean.class); + } + + @Override + public boolean beforeMigration() throws ViewDataMigrationException { + return isHive1(); + } + + @Override + public void afterMigration() throws ViewDataMigrationException { + } + + @Override + public void migrateEntity(Class originEntityClass, Class currentEntityClass) throws ViewDataMigrationException { + if (isHive1()) { + currentEntityClass = hive1EntitiesMapping.get(originEntityClass.getCanonicalName()); + if (currentEntityClass == null) { + LOG.debug("Mapping was not found for class " + originEntityClass.getCanonicalName()); + return; + } + + migrationContext.copyAllObjects(originEntityClass, currentEntityClass); + + } else { + LOG.warn("Unknown migration policy for class"); + } + } + + @Override + public void migrateInstanceData() throws ViewDataMigrationException { + migrationContext.copyAllInstanceData(); + } + + private boolean isHive1() { + return migrationContext.getOriginDataVersion() < 1; + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/853a1ce7/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/HelpService.java ---------------------------------------------------------------------- diff --git a/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/HelpService.java b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/HelpService.java new file mode 100644 index 0000000..9aaaafe --- /dev/null +++ b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/HelpService.java @@ -0,0 +1,132 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.view.hive20; + +import org.apache.ambari.view.ViewContext; +import org.apache.ambari.view.ViewResourceHandler; +import org.apache.ambari.view.hive20.resources.files.FileService; +import org.apache.ambari.view.hive20.resources.jobs.atsJobs.ATSParserFactory; +import org.apache.ambari.view.hive20.resources.jobs.atsJobs.ATSRequestsDelegateImpl; +import org.json.simple.JSONObject; + +import javax.inject.Inject; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.io.IOException; + +/** + * Help service + */ +public class HelpService extends BaseService { + @Inject + ViewContext context; + + @Inject + protected ViewResourceHandler handler; + + /** + * Constructor + */ + public HelpService() { + super(); + } + + /** + * Version + * @return version + */ + @GET + @Path("/version") + @Produces(MediaType.TEXT_PLAIN) + public Response version(){ + return Response.ok("0.0.1-SNAPSHOT").build(); + } + + // ================================================================================ + // Smoke tests + // ================================================================================ + + /** + * HDFS Status + * @return status + */ + @GET + @Path("/hdfsStatus") + @Produces(MediaType.APPLICATION_JSON) + public Response hdfsStatus(){ + FileService.hdfsSmokeTest(context); + return getOKResponse(); + } + + /** + * HomeDirectory Status + * @return status + */ + @GET + @Path("/userhomeStatus") + @Produces(MediaType.APPLICATION_JSON) + public Response userhomeStatus (){ + FileService.userhomeSmokeTest(context); + return getOKResponse(); + } + + + /** + * ATS Status + * @return status + */ + @GET + @Path("/atsStatus") + @Produces(MediaType.APPLICATION_JSON) + public Response atsStatus() { + try { + ATSRequestsDelegateImpl atsimpl = new ATSRequestsDelegateImpl(context, ATSParserFactory.getATSUrl(context)); + atsimpl.checkATSStatus(); + return getOKResponse(); + }catch (IOException e){ + throw new WebApplicationException(e); + } + } + + private Response getOKResponse() { + JSONObject response = new JSONObject(); + response.put("message", "OK"); + response.put("trace", null); + response.put("status", "200"); + return Response.ok().entity(response).type(MediaType.APPLICATION_JSON).build(); + } + + /** + * Version + * @return version + */ + @GET + @Path("/test") + @Produces(MediaType.TEXT_PLAIN) + public Response testStorage(){ + TestBean test = new TestBean(); + test.someData = "hello world"; + getSharedObjectsFactory().getStorage().store(TestBean.class, test); + return Response.ok("OK").build(); + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/853a1ce7/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/HiveJdbcConnectionDelegate.java ---------------------------------------------------------------------- diff --git a/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/HiveJdbcConnectionDelegate.java b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/HiveJdbcConnectionDelegate.java new file mode 100644 index 0000000..5cc60fb --- /dev/null +++ b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/HiveJdbcConnectionDelegate.java @@ -0,0 +1,106 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.view.hive20; + +import com.google.common.base.Optional; +import org.apache.ambari.view.hive20.actor.message.GetColumnMetadataJob; +import org.apache.hive.jdbc.HiveConnection; +import org.apache.hive.jdbc.HiveStatement; + +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; + +public class HiveJdbcConnectionDelegate implements ConnectionDelegate { + + private ResultSet currentResultSet; + private HiveStatement currentStatement; + + @Override + public HiveStatement createStatement(HiveConnection connection) throws SQLException { + Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); + currentStatement = (HiveStatement) statement; + return currentStatement; + } + + @Override + public Optional<ResultSet> execute(String statement) throws SQLException { + if (currentStatement == null) { + throw new SQLException("Statement not created. Cannot execute Hive queries"); + } + + boolean hasResultSet = currentStatement.execute(statement); + + if (hasResultSet) { + ResultSet resultSet = currentStatement.getResultSet(); + currentResultSet = resultSet; + return Optional.of(resultSet); + } else { + return Optional.absent(); + } + } + + @Override + public Optional<ResultSet> execute(HiveConnection connection, String sqlStatement) throws SQLException { + createStatement(connection); + return execute(sqlStatement); + } + + + @Override + public ResultSet getColumnMetadata(HiveConnection connection, GetColumnMetadataJob job) throws SQLException { + DatabaseMetaData metaData = connection.getMetaData(); + ResultSet resultSet = metaData.getColumns("", job.getSchemaPattern(), job.getTablePattern(), job.getColumnPattern()); + currentResultSet = resultSet; + return resultSet; + } + + @Override + public void cancel() throws SQLException { + if (currentStatement != null) { + currentStatement.cancel(); + } + } + + @Override + public void closeResultSet() { + + try { + if (currentResultSet != null) { + currentResultSet.close(); + } + } catch (SQLException e) { + // Cannot do anything here + } + } + + @Override + public void closeStatement() { + try { + if (currentStatement != null) { + currentStatement.close(); + } + } catch (SQLException e) { + // cannot do anything here + } + } + + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/853a1ce7/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/HiveViewImpl.java ---------------------------------------------------------------------- diff --git a/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/HiveViewImpl.java b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/HiveViewImpl.java new file mode 100644 index 0000000..aee7d03 --- /dev/null +++ b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/HiveViewImpl.java @@ -0,0 +1,52 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.view.hive20; + +import org.apache.ambari.view.View; +import org.apache.ambari.view.ViewDefinition; +import org.apache.ambari.view.ViewInstanceDefinition; +import org.apache.ambari.view.hive20.utils.SharedObjectsFactory; +import org.apache.ambari.view.utils.UserLocal; + + +public class HiveViewImpl implements View { + @Override + public void onDeploy(ViewDefinition definition) { + + } + + @Override + public void onCreate(ViewInstanceDefinition definition) { + + } + + @Override + public void onDestroy(ViewInstanceDefinition definition) { + SharedObjectsFactory.dropInstanceCache(definition.getInstanceName()); + ConnectionSystem.getInstance().removeOperationControllerFromCache(definition.getInstanceName()); + } + + @Override + public void onUpdate(ViewInstanceDefinition definition) { + //drop all cached connection for instance + UserLocal.dropInstanceCache(definition.getInstanceName()); + SharedObjectsFactory.dropInstanceCache(definition.getInstanceName()); + ConnectionSystem.getInstance().removeOperationControllerFromCache(definition.getInstanceName()); + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/853a1ce7/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/PropertyValidator.java ---------------------------------------------------------------------- diff --git a/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/PropertyValidator.java b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/PropertyValidator.java new file mode 100644 index 0000000..bca3a20 --- /dev/null +++ b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/PropertyValidator.java @@ -0,0 +1,107 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.view.hive20; + +import org.apache.ambari.view.ClusterType; +import org.apache.ambari.view.ViewInstanceDefinition; +import org.apache.ambari.view.utils.ambari.ValidatorUtils; +import org.apache.ambari.view.validation.ValidationResult; +import org.apache.ambari.view.validation.Validator; + +public class PropertyValidator implements Validator { + + public static final String WEBHDFS_URL = "webhdfs.url"; + public static final String HIVE_PORT = "hive.port"; + public static final String YARN_ATS_URL = "yarn.ats.url"; + public static final String HIVE_SESSION_PARAMS = "hive.session.params"; + public static final String USE_HIVE_INTERACTIVE_MODE = "use.hive.interactive.mode"; + + @Override + public ValidationResult validateInstance(ViewInstanceDefinition viewInstanceDefinition, ValidationContext validationContext) { + return null; + } + + @Override + public ValidationResult validateProperty(String property, ViewInstanceDefinition viewInstanceDefinition, ValidationContext validationContext) { + // Validate non cluster associated properties + if (property.equals(HIVE_SESSION_PARAMS)) { + String auth = viewInstanceDefinition.getPropertyMap().get(HIVE_SESSION_PARAMS); + + if (auth != null && !auth.isEmpty()) { + for(String param : auth.split(";")) { + String[] keyvalue = param.split("="); + if (keyvalue.length != 2) { + return new InvalidPropertyValidationResult(false, "Can not parse session param " + param + " in " + auth); + } + } + } + } + + if (property.equals(USE_HIVE_INTERACTIVE_MODE)) { + String value = viewInstanceDefinition.getPropertyMap().get(USE_HIVE_INTERACTIVE_MODE); + if (!("true".equalsIgnoreCase(value) || "false".equalsIgnoreCase(value))) { + return new InvalidPropertyValidationResult(false, "Must be 'true' or 'false'"); + } + } + + // if associated with cluster(local or remote), no need to validate associated properties + ClusterType clusterType = viewInstanceDefinition.getClusterType(); + if (clusterType == ClusterType.LOCAL_AMBARI || clusterType == ClusterType.REMOTE_AMBARI) { + return ValidationResult.SUCCESS; + } + + // Cluster associated properties + if (property.equals(WEBHDFS_URL)) { + String webhdfsUrl = viewInstanceDefinition.getPropertyMap().get(WEBHDFS_URL); + if (!ValidatorUtils.validateHdfsURL(webhdfsUrl)) { + return new InvalidPropertyValidationResult(false, "Must be valid URL"); + } + } + + if (property.equals(YARN_ATS_URL)) { + String atsUrl = viewInstanceDefinition.getPropertyMap().get(YARN_ATS_URL); + if (!ValidatorUtils.validateHttpURL(atsUrl)) { + return new InvalidPropertyValidationResult(false, "Must be valid URL"); + } + } + + return ValidationResult.SUCCESS; + } + + public static class InvalidPropertyValidationResult implements ValidationResult { + private boolean valid; + private String detail; + + public InvalidPropertyValidationResult(boolean valid, String detail) { + this.valid = valid; + this.detail = detail; + } + + @Override + public boolean isValid() { + return valid; + } + + @Override + public String getDetail() { + return detail; + } + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/853a1ce7/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/TestBean.java ---------------------------------------------------------------------- diff --git a/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/TestBean.java b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/TestBean.java new file mode 100644 index 0000000..c51c5c2 --- /dev/null +++ b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/TestBean.java @@ -0,0 +1,36 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.view.hive20; + +import org.apache.ambari.view.hive20.persistence.utils.Indexed; + +public class TestBean implements Indexed { + public String someData; + public String id; + + @Override + public String getId() { + return id; + } + + @Override + public void setId(String id) { + this.id = id; + } +}
