You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by ma...@apache.org on 2025/01/24 17:30:58 UTC
(atlas) branch atlas-2.5 updated (e2d36ac9d -> 4f3566647)
This is an automated email from the ASF dual-hosted git repository.
madhan pushed a change to branch atlas-2.5
in repository https://gitbox.apache.org/repos/asf/atlas.git
from e2d36ac9d ATLAS-4980: fix test setup failure in HBaseAtlasHookIT
new 4e10950f0 ATLAS-4937: update checkstyle to improve code readability (#269)
new 55655786b ATLAS-4957: checkstyle compliance updates - atlas-common module (#272)
new 4f3566647 ATLAS-4960: checkstyle compliance updates - atlas-intg module (#273)
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
build-tools/src/main/resources/checkstyle.xml | 240 -----
common/pom.xml | 5 +
.../main/java/org/apache/atlas/AtlasConstants.java | 16 +-
.../annotation/ConditionalOnAtlasProperty.java | 3 +-
.../java/org/apache/atlas/annotation/Timed.java | 11 +-
.../atlas/groovy/AbstractFunctionExpression.java | 22 +-
.../atlas/groovy/AbstractGroovyExpression.java | 15 +-
.../apache/atlas/groovy/ArithmeticExpression.java | 46 +-
.../org/apache/atlas/groovy/BinaryExpression.java | 21 +-
.../org/apache/atlas/groovy/CastExpression.java | 20 +-
.../org/apache/atlas/groovy/ClosureExpression.java | 85 +-
.../apache/atlas/groovy/ComparisonExpression.java | 51 +-
.../atlas/groovy/ComparisonOperatorExpression.java | 8 +-
.../org/apache/atlas/groovy/FieldExpression.java | 13 +-
.../atlas/groovy/FunctionCallExpression.java | 51 +-
.../org/apache/atlas/groovy/GroovyExpression.java | 8 +-
.../atlas/groovy/GroovyGenerationContext.java | 20 +-
.../apache/atlas/groovy/IdentifierExpression.java | 27 +-
.../org/apache/atlas/groovy/LabeledExpression.java | 15 +-
.../org/apache/atlas/groovy/ListExpression.java | 18 +-
.../org/apache/atlas/groovy/LiteralExpression.java | 99 +-
.../org/apache/atlas/groovy/LogicalExpression.java | 38 +-
.../org/apache/atlas/groovy/RangeExpression.java | 24 +-
.../atlas/groovy/StatementListExpression.java | 31 +-
.../atlas/groovy/TernaryOperatorExpression.java | 37 +-
.../org/apache/atlas/groovy/TraversalStepType.java | 6 +-
.../atlas/groovy/TypeCoersionExpression.java | 18 +-
.../atlas/groovy/VariableAssignmentExpression.java | 25 +-
.../java/org/apache/atlas/ha/HAConfiguration.java | 154 ++-
.../java/org/apache/atlas/pc/StatusReporter.java | 42 +-
.../java/org/apache/atlas/pc/WorkItemBuilder.java | 6 +-
.../java/org/apache/atlas/pc/WorkItemConsumer.java | 20 +-
.../java/org/apache/atlas/pc/WorkItemManager.java | 67 +-
.../org/apache/atlas/repository/Constants.java | 105 +-
.../java/org/apache/atlas/service/Service.java | 7 +-
.../java/org/apache/atlas/service/Services.java | 4 +-
.../apache/atlas/utils/AtlasPathExtractorUtil.java | 181 ++--
.../org/apache/atlas/utils/AtlasPerfMetrics.java | 44 +-
.../org/apache/atlas/utils/AtlasPerfTracer.java | 28 +-
.../atlas/utils/HdfsNameServiceResolver.java | 77 +-
.../java/org/apache/atlas/utils/KafkaUtils.java | 277 +++--
.../main/java/org/apache/atlas/utils/LruCache.java | 44 +-
.../atlas/utils/OnAtlasPropertyCondition.java | 21 +-
.../java/org/apache/atlas/utils/ParamChecker.java | 19 +-
.../apache/atlas/utils/PathExtractorContext.java | 8 +-
.../org/apache/atlas/utils/PropertiesUtil.java | 100 +-
.../java/org/apache/atlas/utils/SHA256Utils.java | 48 +-
.../org/apache/atlas/ha/HAConfigurationTest.java | 24 +-
.../atlas/utils/AtlasPathExtractorUtilTest.java | 240 ++---
.../atlas/utils/HdfsNameServiceResolverTest.java | 4 +-
.../org/apache/atlas/utils/KafkaUtilsTest.java | 209 ++--
.../java/org/apache/atlas/utils/LruCacheTest.java | 71 +-
dev-support/AtlasCodeScheme-IntelliJ.xml | 501 +++++++++
.../checkstyle-suppressions.xml | 7 +-
dev-support/checkstyle.xml | 272 +++++
intg/pom.xml | 5 +
.../org/apache/atlas/ApplicationProperties.java | 200 ++--
.../java/org/apache/atlas/AtlasConfiguration.java | 43 +-
.../main/java/org/apache/atlas/AtlasErrorCode.java | 54 +-
.../main/java/org/apache/atlas/AtlasException.java | 7 +-
.../src/main/java/org/apache/atlas/DeleteType.java | 8 +-
intg/src/main/java/org/apache/atlas/SortOrder.java | 6 +-
.../atlas/bulkimport/BulkImportResponse.java | 29 +-
.../apache/atlas/exception/AtlasBaseException.java | 26 +-
.../apache/atlas/model/AtlasBaseModelObject.java | 42 +-
.../java/org/apache/atlas/model/Clearable.java | 6 +-
.../main/java/org/apache/atlas/model/PList.java | 41 +-
.../java/org/apache/atlas/model/SearchFilter.java | 39 +-
.../java/org/apache/atlas/model/TimeBoundary.java | 48 +-
.../java/org/apache/atlas/model/TypeCategory.java | 4 +-
.../apache/atlas/model/annotation/AtlasJSON.java | 6 +-
.../apache/atlas/model/audit/AtlasAuditEntry.java | 118 ++-
.../atlas/model/audit/AuditReductionCriteria.java | 45 +-
.../atlas/model/audit/AuditSearchParameters.java | 67 +-
.../atlas/model/audit/EntityAuditEventV2.java | 262 ++---
.../model/discovery/AtlasAggregationEntry.java | 33 +-
.../model/discovery/AtlasQuickSearchResult.java | 12 +-
.../atlas/model/discovery/AtlasSearchResult.java | 250 +++--
.../discovery/AtlasSearchResultDownloadStatus.java | 29 +-
.../model/discovery/AtlasSuggestionsResult.java | 4 +-
.../model/discovery/QuickSearchParameters.java | 17 +-
.../discovery/RelationshipSearchParameters.java | 21 +-
.../atlas/model/discovery/SearchParameters.java | 276 ++---
.../apache/atlas/model/glossary/AtlasGlossary.java | 127 ++-
.../model/glossary/AtlasGlossaryBaseObject.java | 43 +-
.../model/glossary/AtlasGlossaryCategory.java | 60 +-
.../atlas/model/glossary/AtlasGlossaryTerm.java | 184 ++--
.../model/glossary/AtlasGlossaryTermHeader.java | 34 +-
.../glossary/enums/AtlasTermAssignmentStatus.java | 5 +-
.../enums/AtlasTermRelationshipStatus.java | 5 +-
.../glossary/relations/AtlasGlossaryHeader.java | 30 +-
.../relations/AtlasRelatedCategoryHeader.java | 39 +-
.../glossary/relations/AtlasRelatedTermHeader.java | 63 +-
.../relations/AtlasTermAssignmentHeader.java | 89 +-
.../relations/AtlasTermCategorizationHeader.java | 39 +-
.../atlas/model/impexp/AtlasExportRequest.java | 68 +-
.../atlas/model/impexp/AtlasExportResult.java | 81 +-
.../atlas/model/impexp/AtlasImportRequest.java | 109 +-
.../atlas/model/impexp/AtlasImportResult.java | 41 +-
.../org/apache/atlas/model/impexp/AtlasServer.java | 33 +-
.../atlas/model/impexp/AttributeTransform.java | 16 +-
.../atlas/model/impexp/ExportImportAuditEntry.java | 51 +-
.../apache/atlas/model/impexp/MigrationStatus.java | 38 +-
.../model/instance/AtlasCheckStateRequest.java | 20 +-
.../model/instance/AtlasCheckStateResult.java | 66 +-
.../atlas/model/instance/AtlasClassification.java | 87 +-
.../apache/atlas/model/instance/AtlasEntity.java | 286 ++---
.../atlas/model/instance/AtlasEntityHeader.java | 68 +-
.../atlas/model/instance/AtlasEntityHeaders.java | 27 +-
.../apache/atlas/model/instance/AtlasObjectId.java | 76 +-
.../atlas/model/instance/AtlasRelatedObjectId.java | 126 ++-
.../atlas/model/instance/AtlasRelationship.java | 244 +++--
.../model/instance/AtlasRelationshipHeader.java | 61 +-
.../apache/atlas/model/instance/AtlasStruct.java | 226 ++--
.../instance/ClassificationAssociateRequest.java | 73 +-
.../model/instance/EntityMutationResponse.java | 140 +--
.../atlas/model/instance/EntityMutations.java | 144 +--
.../apache/atlas/model/instance/GuidMapping.java | 37 +-
.../apache/atlas/model/legacy/EntityResult.java | 47 +-
.../atlas/model/lineage/AtlasLineageInfo.java | 113 +-
.../model/lineage/LineageOnDemandConstraints.java | 12 +-
.../apache/atlas/model/metrics/AtlasMetrics.java | 14 +-
.../model/metrics/AtlasMetricsMapToChart.java | 18 +-
.../atlas/model/metrics/AtlasMetricsStat.java | 49 +-
.../model/migration/MigrationImportStatus.java | 26 +-
.../notification/AtlasNotificationBaseMessage.java | 159 ++-
.../notification/AtlasNotificationMessage.java | 30 +-
.../AtlasNotificationStringMessage.java | 31 +-
.../model/notification/EntityNotification.java | 78 +-
.../atlas/model/notification/HookNotification.java | 71 +-
.../atlas/model/notification/MessageSource.java | 50 +-
.../atlas/model/notification/MessageVersion.java | 55 +-
.../org/apache/atlas/model/patches/AtlasPatch.java | 84 +-
.../atlas/model/profile/AtlasUserProfile.java | 23 +-
.../atlas/model/profile/AtlasUserSavedSearch.java | 44 +-
.../org/apache/atlas/model/tasks/AtlasTask.java | 32 +-
.../atlas/model/typedef/AtlasBaseTypeDef.java | 329 +++---
.../model/typedef/AtlasBusinessMetadataDef.java | 27 +-
.../model/typedef/AtlasClassificationDef.java | 70 +-
.../apache/atlas/model/typedef/AtlasEntityDef.java | 105 +-
.../apache/atlas/model/typedef/AtlasEnumDef.java | 134 +--
.../atlas/model/typedef/AtlasRelationshipDef.java | 178 ++--
.../model/typedef/AtlasRelationshipEndDef.java | 88 +-
.../apache/atlas/model/typedef/AtlasStructDef.java | 252 +++--
.../atlas/model/typedef/AtlasTypeDefHeader.java | 43 +-
.../apache/atlas/model/typedef/AtlasTypesDef.java | 91 +-
.../atlas/security/InMemoryJAASConfiguration.java | 162 ++-
.../apache/atlas/security/SecurityProperties.java | 47 +-
.../org/apache/atlas/security/SecurityUtil.java | 29 +-
.../java/org/apache/atlas/type/AtlasArrayType.java | 243 +++--
.../org/apache/atlas/type/AtlasBuiltInTypes.java | 92 +-
.../atlas/type/AtlasBusinessMetadataType.java | 38 +-
.../apache/atlas/type/AtlasClassificationType.java | 542 +++++-----
.../org/apache/atlas/type/AtlasEntityType.java | 969 +++++++++--------
.../java/org/apache/atlas/type/AtlasEnumType.java | 26 +-
.../java/org/apache/atlas/type/AtlasMapType.java | 157 +--
.../apache/atlas/type/AtlasRelationshipType.java | 275 +++--
.../org/apache/atlas/type/AtlasStructType.java | 954 +++++++++--------
.../main/java/org/apache/atlas/type/AtlasType.java | 73 +-
.../org/apache/atlas/type/AtlasTypeRegistry.java | 820 +++++++-------
.../java/org/apache/atlas/type/AtlasTypeUtil.java | 284 +++--
.../java/org/apache/atlas/type/AttributeToken.java | 4 +-
.../java/org/apache/atlas/type/ConstantToken.java | 2 +-
.../main/java/org/apache/atlas/type/Constants.java | 35 +-
.../java/org/apache/atlas/type/DependentToken.java | 9 +-
.../apache/atlas/typesystem/types/DataTypes.java | 2 +-
.../apache/atlas/utils/AtlasConfigurationUtil.java | 15 +-
.../org/apache/atlas/utils/AtlasEntityUtil.java | 41 +-
.../java/org/apache/atlas/utils/AtlasJson.java | 173 ++-
.../org/apache/atlas/utils/AtlasStringUtil.java | 10 +-
.../org/apache/atlas/utils/AuthenticationUtil.java | 16 +-
.../org/apache/atlas/utils/FixedBufferList.java | 19 +-
.../main/java/org/apache/atlas/utils/SSLUtil.java | 83 +-
.../atlas/v1/model/discovery/DSLSearchResult.java | 46 +-
.../v1/model/discovery/FullTextSearchResult.java | 46 +-
.../v1/model/instance/AtlasSystemAttributes.java | 44 +-
.../org/apache/atlas/v1/model/instance/Id.java | 179 ++--
.../atlas/v1/model/instance/Referenceable.java | 127 ++-
.../org/apache/atlas/v1/model/instance/Struct.java | 94 +-
.../v1/model/lineage/DataSetLineageResponse.java | 31 +-
.../atlas/v1/model/lineage/LineageResponse.java | 32 +-
.../atlas/v1/model/lineage/SchemaResponse.java | 39 +-
.../model/notification/EntityNotificationV1.java | 84 +-
.../v1/model/notification/HookNotificationV1.java | 42 +-
.../v1/model/typedef/AttributeDefinition.java | 95 +-
.../v1/model/typedef/ClassTypeDefinition.java | 21 +-
.../atlas/v1/model/typedef/EnumTypeDefinition.java | 53 +-
.../model/typedef/HierarchicalTypeDefinition.java | 30 +-
.../atlas/v1/model/typedef/Multiplicity.java | 33 +-
.../v1/model/typedef/StructTypeDefinition.java | 34 +-
.../v1/model/typedef/TraitTypeDefinition.java | 17 +-
.../apache/atlas/v1/model/typedef/TypesDef.java | 21 +-
.../atlas/v1/typesystem/types/utils/TypesUtil.java | 53 +-
.../apache/atlas/ApplicationPropertiesTest.java | 81 +-
.../org/apache/atlas/TestRelationshipUtilsV2.java | 265 +++--
.../test/java/org/apache/atlas/TestUtilsV2.java | 1120 +++++++-------------
.../java/org/apache/atlas/model/ModelTestUtil.java | 170 +--
.../model/instance/TestAtlasClassification.java | 15 +-
.../atlas/model/instance/TestAtlasEntity.java | 24 +-
.../typedef/TestAtlasBusinessMetadataDef.java | 40 +-
.../model/typedef/TestAtlasClassificationDef.java | 22 +-
.../atlas/model/typedef/TestAtlasEntityDef.java | 14 +-
.../atlas/model/typedef/TestAtlasEnumDef.java | 18 +-
.../model/typedef/TestAtlasRelationshipDef.java | 66 +-
.../atlas/model/typedef/TestAtlasStructDef.java | 10 +-
.../security/InMemoryJAASConfigurationTest.java | 61 +-
...AASConfigurationTicketBasedKafkaClientTest.java | 24 +-
.../org/apache/atlas/type/TestAtlasArrayType.java | 90 +-
.../apache/atlas/type/TestAtlasBigDecimalType.java | 26 +-
.../apache/atlas/type/TestAtlasBigIntegerType.java | 24 +-
.../apache/atlas/type/TestAtlasBooleanType.java | 27 +-
.../type/TestAtlasBuiltInTypesFloatDouble.java | 12 +-
.../org/apache/atlas/type/TestAtlasByteType.java | 30 +-
.../atlas/type/TestAtlasClassificationType.java | 385 +++----
.../org/apache/atlas/type/TestAtlasDateType.java | 29 +-
.../org/apache/atlas/type/TestAtlasDoubleType.java | 32 +-
.../org/apache/atlas/type/TestAtlasEntityType.java | 440 ++++----
.../org/apache/atlas/type/TestAtlasFloatType.java | 33 +-
.../org/apache/atlas/type/TestAtlasIntType.java | 28 +-
.../org/apache/atlas/type/TestAtlasLongType.java | 29 +-
.../org/apache/atlas/type/TestAtlasMapType.java | 72 +-
.../apache/atlas/type/TestAtlasObjectIdType.java | 127 +--
.../atlas/type/TestAtlasRelationshipType.java | 152 ++-
.../org/apache/atlas/type/TestAtlasShortType.java | 32 +-
.../org/apache/atlas/type/TestAtlasStringType.java | 20 +-
.../org/apache/atlas/type/TestAtlasStructType.java | 216 ++--
.../apache/atlas/type/TestAtlasTypeRegistry.java | 374 +++----
.../org/apache/atlas/type/TestMultiplicity.java | 11 +-
.../apache/atlas/utils/FixedBufferListTest.java | 85 +-
pom.xml | 22 +-
.../org/apache/atlas/pc/StatusReporterTest.java | 36 +-
.../org/apache/atlas/pc/WorkItemManagerTest.java | 14 +-
.../atlas/pc/WorkItemManagerWithResultsTest.java | 41 +-
233 files changed, 10738 insertions(+), 10160 deletions(-)
delete mode 100755 build-tools/src/main/resources/checkstyle.xml
create mode 100644 dev-support/AtlasCodeScheme-IntelliJ.xml
rename {build-tools/src/main/resources => dev-support}/checkstyle-suppressions.xml (76%)
create mode 100755 dev-support/checkstyle.xml
(atlas) 01/03: ATLAS-4937: update checkstyle to improve code readability (#269)
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
madhan pushed a commit to branch atlas-2.5
in repository https://gitbox.apache.org/repos/asf/atlas.git
commit 4e10950f0b83082cfd16b80b5af7e08fb9e10445
Author: Madhan Neethiraj <ma...@apache.org>
AuthorDate: Thu Jan 23 20:56:08 2025 -0800
ATLAS-4937: update checkstyle to improve code readability (#269)
(cherry picked from commit e25a32d045b8689174efb8f3046ba19a5c56dfb6)
---
build-tools/src/main/resources/checkstyle.xml | 240 ----------
dev-support/AtlasCodeScheme-IntelliJ.xml | 501 +++++++++++++++++++++
.../checkstyle-suppressions.xml | 6 +-
dev-support/checkstyle.xml | 272 +++++++++++
pom.xml | 22 +-
5 files changed, 790 insertions(+), 251 deletions(-)
diff --git a/build-tools/src/main/resources/checkstyle.xml b/build-tools/src/main/resources/checkstyle.xml
deleted file mode 100755
index 54423176f..000000000
--- a/build-tools/src/main/resources/checkstyle.xml
+++ /dev/null
@@ -1,240 +0,0 @@
-<?xml version="1.0"?>
-<!--
- 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.
- -->
-
-<!DOCTYPE module PUBLIC
- "-//Puppy Crawl//DTD Check Configuration 1.2//EN"
- "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
-
-<!--
-
- Checkstyle configuration for Metadata that is based on the sun_checks.xml file
- that is bundled with Checkstyle and includes checks for:
-
- - the Java Language Specification at
- http://java.sun.com/docs/books/jls/second_edition/html/index.html
-
- - the Sun Code Conventions at http://java.sun.com/docs/codeconv/
-
- - the Javadoc guidelines at
- http://java.sun.com/j2se/javadoc/writingdoccomments/index.html
-
- - the JDK Api documentation http://java.sun.com/j2se/docs/api/index.html
-
- - some best practices
-
- Checkstyle is very configurable. Be sure to read the documentation at
- http://checkstyle.sf.net (or in your downloaded distribution).
-
- Most Checks are configurable, be sure to consult the documentation.
-
- To completely disable a check, just comment it out or delete it from the file.
-
- Finally, it is worth reading the documentation.
-
--->
-
-<module name="Checker">
-
- <!-- Checks that a package.html file exists for each package. -->
- <!-- See http://checkstyle.sf.net/config_javadoc.html#PackageHtml -->
- <!-- module name="PackageHtml"/ -->
-
- <!-- Checks whether files end with a new line. -->
- <!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile -->
- <module name="NewlineAtEndOfFile"/>
-
- <!-- Checks for Headers -->
- <!-- See http://checkstyle.sf.net/config_header.html -->
- <module name="Header">
- <property name="headerFile" value="${checkstyle.header.file}"/>
- <property name="fileExtensions" value="java"/>
- </module>
-
- <module name="FileLength"/>
- <module name="FileTabCharacter"/>
-
- <module name="TreeWalker">
- <!-- Checks for Javadoc comments. -->
- <!-- See http://checkstyle.sf.net/config_javadoc.html -->
- <module name="JavadocType">
- <property name="scope" value="public"/>
- <property name="allowMissingParamTags" value="true"/>
- </module>
- <module name="JavadocStyle"/>
-
- <module name="SuperClone"/>
- <module name="SuperFinalize"/>
-
- <!-- Checks for Naming Conventions. -->
- <!-- See http://checkstyle.sf.net/config_naming.html -->
- <module name="ConstantName"/>
- <module name="ClassTypeParameterName">
- <property name="format" value="^[A-Z]+$"/>
- </module>
- <module name="LocalFinalVariableName">
- <!--<property name="format" value="^[A-Z][_A-Z0-9]*$"/>-->
- </module>
- <module name="LocalVariableName"/>
- <module name="MemberName"/>
- <module name="MethodName"/>
- <module name="MethodTypeParameterName">
- <property name="format" value="^[A-Z]+$"/>
- </module>
- <module name="PackageName"/>
- <module name="ParameterName"/>
- <module name="StaticVariableName"/>
- <module name="TypeName"/>
-
- <!-- Checks for imports -->
- <!-- See http://checkstyle.sf.net/config_import.html -->
- <module name="IllegalImport"/>
- <!-- defaults to sun.* packages -->
- <module name="RedundantImport"/>
- <module name="UnusedImports"/>
-
-
- <!-- Checks for Size Violations. -->
- <!-- See http://checkstyle.sf.net/config_sizes.html -->
- <module name="LineLength">
- <property name="max" value="120"/>
- </module>
- <module name="MethodLength"/>
- <module name="ParameterNumber">
- <property name="tokens" value="METHOD_DEF"/>
- </module>
- <module name="OuterTypeNumber"/>
-
- <!-- Checks for whitespace -->
- <!-- See http://checkstyle.sf.net/config_whitespace.html -->
- <module name="GenericWhitespace"/>
- <module name="EmptyForIteratorPad"/>
- <module name="MethodParamPad"/>
- <module name="WhitespaceAround">
- <property name="tokens" value="LITERAL_IF"/>
- </module>
- <module name="NoWhitespaceAfter">
- <property name="tokens"
- value="BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS, UNARY_PLUS"/>
- </module>
- <module name="NoWhitespaceBefore"/>
- <module name="OperatorWrap"/>
- <module name="ParenPad"/>
- <module name="TypecastParenPad"/>
- <module name="WhitespaceAfter">
- <property name="tokens" value="COMMA, SEMI"/>
- </module>
-
- <module name="Regexp">
- <property name="format" value="[ \t]+$"/>
- <property name="illegalPattern" value="true"/>
- <property name="message" value="Trailing whitespace"/>
- </module>
-
- <!-- Modifier Checks -->
- <!-- See http://checkstyle.sf.net/config_modifiers.html -->
- <module name="ModifierOrder"/>
- <module name="RedundantModifier"/>
-
-
- <!-- Checks for blocks. You know, those {}'s -->
- <!-- See http://checkstyle.sf.net/config_blocks.html -->
- <module name="AvoidNestedBlocks"/>
- <module name="EmptyBlock">
- <!-- catch blocks need a statement or a comment. -->
- <property name="option" value="text"/>
- <property name="tokens" value="LITERAL_CATCH"/>
- </module>
- <module name="EmptyBlock">
- <!-- all other blocks need a real statement. -->
- <property name="option" value="stmt"/>
- <property name="tokens" value="LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY,
- LITERAL_IF, LITERAL_FOR, LITERAL_TRY, LITERAL_WHILE, INSTANCE_INIT,
- STATIC_INIT"/>
- </module>
- <module name="LeftCurly"/>
- <module name="NeedBraces"/>
- <module name="RightCurly"/>
-
-
- <!-- Checks for common coding problems -->
- <!-- See http://checkstyle.sf.net/config_coding.html -->
- <!-- module name="AvoidInlineConditionals"/-->
- <!-- DoubleCheckedLocking check is no longer required. See http://checkstyle.sourceforge.net/releasenotes.html -->
- <!-- module name="DoubleCheckedLocking"/-->
- <module name="EmptyStatement"/>
- <module name="EqualsHashCode"/>
- <module name="StringLiteralEquality"/>
- <module name="HiddenField">
- <property name="ignoreConstructorParameter" value="true"/>
- <property name="ignoreAbstractMethods" value="true"/>
- <property name="ignoreSetter" value="true"/>
- </module>
- <module name="IllegalInstantiation"/>
- <module name="InnerAssignment"/>
- <module name="MissingSwitchDefault"/>
- <module name="RedundantThrows"/>
- <module name="SimplifyBooleanExpression"/>
- <module name="SimplifyBooleanReturn"/>
- <module name="DefaultComesLast"/>
-
- <!-- Checks for class design -->
- <!-- See http://checkstyle.sf.net/config_design.html -->
- <module name="FinalClass"/>
- <module name="HideUtilityClassConstructor"/>
- <module name="InterfaceIsType"/>
- <module name="VisibilityModifier">
- <property name="protectedAllowed" value="true"/>
- </module>
- <module name="MissingOverride"/>
-
-
- <!-- Miscellaneous other checks. -->
- <!-- See http://checkstyle.sf.net/config_misc.html -->
- <module name="ArrayTypeStyle"/>
- <module name="ArrayTrailingComma"/>
- <!--
- This generates too many false-positives on wrapped 'throws' clauses
- to be really useful. Disabled for now.
-
- Metadata style is:
- * Spaces, not tabs.
- * Indent by four spaces.
- * Indent by four spaces when wrapping a line.
- -->
- <module name="Indentation">
- <property name="basicOffset" value="4"/>
- <property name="caseIndent" value="0"/>
- </module>
- <module name="TodoComment"/>
- <module name="UpperEll"/>
-
- <module name="FileContentsHolder"/>
- </module>
-
- <!-- allow warnings to be suppressed -->
- <module name="SuppressionCommentFilter">
- <property name="offCommentFormat" value="SUSPEND CHECKSTYLE CHECK ParameterNumberCheck|VisibilityModifierCheck|HiddenFieldCheck|MethodName"/>
- <property name="onCommentFormat" value="RESUME CHECKSTYLE CHECK ParameterNumberCheck|VisibilityModifierCheck|HiddenFieldCheck|MethodName"/>
- <property name="checkFormat" value="ParameterNumberCheck|VisibilityModifierCheck|HiddenFieldCheck|MethodName"/>
- </module>
-
- <module name="SuppressionFilter">
- <property name="file" value="${checkstyle.suppressions.file}"/>
- </module>
-</module>
diff --git a/dev-support/AtlasCodeScheme-IntelliJ.xml b/dev-support/AtlasCodeScheme-IntelliJ.xml
new file mode 100644
index 000000000..f3edfb2a0
--- /dev/null
+++ b/dev-support/AtlasCodeScheme-IntelliJ.xml
@@ -0,0 +1,501 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<code_scheme name="ApacheAtlas">
+ <option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="9999" />
+ <option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="9999" />
+ <option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
+ <value />
+ </option>
+ <option name="IMPORT_LAYOUT_TABLE">
+ <value>
+ <package name="" withSubpackages="true" static="false" />
+ <emptyLine />
+ <package name="javax" withSubpackages="true" static="false" />
+ <emptyLine />
+ <package name="java" withSubpackages="true" static="false" />
+ <emptyLine />
+ <package name="" withSubpackages="true" static="true" />
+ </value>
+ </option>
+ <option name="RIGHT_MARGIN" value="512" />
+ <option name="JD_ALIGN_PARAM_COMMENTS" value="false" />
+ <option name="JD_ALIGN_EXCEPTION_COMMENTS" value="false" />
+ <option name="JD_PRESERVE_LINE_FEEDS" value="true" />
+ <option name="HTML_DO_NOT_INDENT_CHILDREN_OF" value="html,body,thead,tbody,tfoot,script" />
+ <option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false" />
+ <option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" />
+ <option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
+ <option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="0" />
+ <option name="CLASS_BRACE_STYLE" value="1" />
+ <option name="METHOD_BRACE_STYLE" value="1" />
+ <option name="ELSE_ON_NEW_LINE" value="false" />
+ <option name="WHILE_ON_NEW_LINE" value="true" />
+ <option name="CATCH_ON_NEW_LINE" value="false" />
+ <option name="FINALLY_ON_NEW_LINE" value="false" />
+ <option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
+ <option name="ALIGN_MULTILINE_ASSIGNMENT" value="true" />
+ <option name="ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION" value="true" />
+ <option name="SPACE_WITHIN_ARRAY_INITIALIZER_BRACES" value="true" />
+ <option name="SPACE_BEFORE_ARRAY_INITIALIZER_LBRACE" value="true" />
+ <option name="SPACE_WITHIN_BRACES" value="true" />
+ <option name="CALL_PARAMETERS_WRAP" value="5" />
+ <option name="EXTENDS_LIST_WRAP" value="1" />
+ <option name="THROWS_LIST_WRAP" value="1" />
+ <option name="EXTENDS_KEYWORD_WRAP" value="1" />
+ <option name="THROWS_KEYWORD_WRAP" value="1" />
+ <option name="METHOD_CALL_CHAIN_WRAP" value="5" />
+ <option name="TERNARY_OPERATION_WRAP" value="5" />
+ <option name="KEEP_SIMPLE_CLASSES_IN_ONE_LINE" value="true" />
+ <option name="FOR_STATEMENT_WRAP" value="5" />
+ <option name="ARRAY_INITIALIZER_WRAP" value="1" />
+ <option name="ASSERT_STATEMENT_WRAP" value="5" />
+ <option name="IF_BRACE_FORCE" value="3" />
+ <option name="DOWHILE_BRACE_FORCE" value="3" />
+ <option name="WHILE_BRACE_FORCE" value="3" />
+ <option name="FOR_BRACE_FORCE" value="3" />
+ <JavaCodeStyleSettings>
+ <option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="9999" />
+ <option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="9999" />
+ <option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
+ <value />
+ </option>
+ <option name="IMPORT_LAYOUT_TABLE">
+ <value>
+ <package name="" withSubpackages="true" static="false" />
+ <emptyLine />
+ <package name="javax" withSubpackages="true" static="false" />
+ <emptyLine />
+ <package name="java" withSubpackages="true" static="false" />
+ <emptyLine />
+ <package name="" withSubpackages="true" static="true" />
+ </value>
+ </option>
+ <option name="JD_ALIGN_PARAM_COMMENTS" value="false" />
+ <option name="JD_ALIGN_EXCEPTION_COMMENTS" value="false" />
+ </JavaCodeStyleSettings>
+ <XML>
+ <option name="XML_ATTRIBUTE_WRAP" value="0" />
+ <option name="XML_TEXT_WRAP" value="0" />
+ <option name="XML_KEEP_BLANK_LINES" value="1" />
+ <option name="XML_SPACE_INSIDE_EMPTY_TAG" value="true" />
+ <option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
+ </XML>
+ <ADDITIONAL_INDENT_OPTIONS fileType="clj">
+ <option name="INDENT_SIZE" value="2" />
+ <option name="TAB_SIZE" value="2" />
+ </ADDITIONAL_INDENT_OPTIONS>
+ <ADDITIONAL_INDENT_OPTIONS fileType="gsp">
+ <option name="INDENT_SIZE" value="2" />
+ </ADDITIONAL_INDENT_OPTIONS>
+ <ADDITIONAL_INDENT_OPTIONS fileType="scala">
+ <option name="INDENT_SIZE" value="2" />
+ <option name="TAB_SIZE" value="2" />
+ </ADDITIONAL_INDENT_OPTIONS>
+ <codeStyleSettings language="CoffeeScript">
+ <indentOptions>
+ <option name="CONTINUATION_INDENT_SIZE" value="4" />
+ <option name="USE_RELATIVE_INDENTS" value="true" />
+ </indentOptions>
+ </codeStyleSettings>
+ <codeStyleSettings language="Groovy">
+ <option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false" />
+ <option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" />
+ <option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
+ <option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="0" />
+ <option name="CLASS_BRACE_STYLE" value="2" />
+ <option name="METHOD_BRACE_STYLE" value="2" />
+ <option name="ELSE_ON_NEW_LINE" value="true" />
+ <option name="CATCH_ON_NEW_LINE" value="true" />
+ <option name="FINALLY_ON_NEW_LINE" value="true" />
+ <option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
+ <option name="ALIGN_MULTILINE_ASSIGNMENT" value="true" />
+ <option name="CALL_PARAMETERS_WRAP" value="5" />
+ <option name="EXTENDS_LIST_WRAP" value="1" />
+ <option name="THROWS_LIST_WRAP" value="1" />
+ <option name="EXTENDS_KEYWORD_WRAP" value="2" />
+ <option name="THROWS_KEYWORD_WRAP" value="2" />
+ <option name="METHOD_CALL_CHAIN_WRAP" value="5" />
+ <option name="TERNARY_OPERATION_WRAP" value="5" />
+ <option name="FOR_STATEMENT_WRAP" value="5" />
+ <option name="ASSERT_STATEMENT_WRAP" value="5" />
+ <option name="IF_BRACE_FORCE" value="3" />
+ <option name="WHILE_BRACE_FORCE" value="3" />
+ <option name="FOR_BRACE_FORCE" value="3" />
+ <option name="PARENT_SETTINGS_INSTALLED" value="true" />
+ <indentOptions>
+ <option name="INDENT_SIZE" value="2" />
+ </indentOptions>
+ </codeStyleSettings>
+ <codeStyleSettings language="JAVA">
+ <option name="ALIGN_GROUP_FIELD_DECLARATIONS" value="true" />
+ <option name="ALIGN_CONSECUTIVE_VARIABLE_DECLARATIONS" value="true" />
+ <option name="ALIGN_CONSECUTIVE_ASSIGNMENTS" value="true" />
+ <option name="ALIGN_SUBSEQUENT_SIMPLE_METHODS" value="true" />
+ <option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false" />
+ <option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" />
+ <option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
+ <option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="0" />
+ <option name="CLASS_BRACE_STYLE" value="1" />
+ <option name="METHOD_BRACE_STYLE" value="1" />
+ <option name="ELSE_ON_NEW_LINE" value="false" />
+ <option name="WHILE_ON_NEW_LINE" value="true" />
+ <option name="CATCH_ON_NEW_LINE" value="false" />
+ <option name="FINALLY_ON_NEW_LINE" value="false" />
+ <option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
+ <option name="ALIGN_MULTILINE_RESOURCES" value="false" />
+ <option name="ALIGN_MULTILINE_FOR" value="false" />
+ <option name="ALIGN_MULTILINE_ASSIGNMENT" value="true" />
+ <option name="SPACE_BEFORE_ARRAY_INITIALIZER_LBRACE" value="true" />
+ <option name="EXTENDS_LIST_WRAP" value="1" />
+ <option name="THROWS_LIST_WRAP" value="1" />
+ <option name="EXTENDS_KEYWORD_WRAP" value="1" />
+ <option name="THROWS_KEYWORD_WRAP" value="1" />
+ <option name="KEEP_SIMPLE_BLOCKS_IN_ONE_LINE" value="false" />
+ <option name="KEEP_SIMPLE_METHODS_IN_ONE_LINE" value="true" />
+ <option name="KEEP_SIMPLE_LAMBDAS_IN_ONE_LINE" value="true" />
+ <option name="KEEP_SIMPLE_CLASSES_IN_ONE_LINE" value="true" />
+ <option name="ARRAY_INITIALIZER_WRAP" value="1" />
+ <option name="ASSERT_STATEMENT_WRAP" value="5" />
+ <option name="IF_BRACE_FORCE" value="3" />
+ <option name="DOWHILE_BRACE_FORCE" value="3" />
+ <option name="WHILE_BRACE_FORCE" value="3" />
+ <option name="FOR_BRACE_FORCE" value="3" />
+ <option name="FIELD_ANNOTATION_WRAP" value="0" />
+ <option name="PARENT_SETTINGS_INSTALLED" value="true" />
+ <arrangement>
+ <groups>
+ <group>
+ <type>GETTERS_AND_SETTERS</type>
+ <order>KEEP</order>
+ </group>
+ <group>
+ <type>OVERRIDDEN_METHODS</type>
+ <order>KEEP</order>
+ </group>
+ </groups>
+ <rules>
+ <rule>
+ <match>
+ <AND>
+ <FIELD />
+ <FINAL />
+ <PUBLIC />
+ <STATIC />
+ </AND>
+ </match>
+ </rule>
+ <rule>
+ <match>
+ <AND>
+ <FIELD />
+ <FINAL />
+ <PROTECTED />
+ <STATIC />
+ </AND>
+ </match>
+ </rule>
+ <rule>
+ <match>
+ <AND>
+ <FIELD />
+ <FINAL />
+ <PACKAGE_PRIVATE />
+ <STATIC />
+ </AND>
+ </match>
+ </rule>
+ <rule>
+ <match>
+ <AND>
+ <FIELD />
+ <FINAL />
+ <PRIVATE />
+ <STATIC />
+ </AND>
+ </match>
+ </rule>
+ <rule>
+ <match>
+ <AND>
+ <FIELD />
+ <PUBLIC />
+ <STATIC />
+ </AND>
+ </match>
+ </rule>
+ <rule>
+ <match>
+ <AND>
+ <FIELD />
+ <PROTECTED />
+ <STATIC />
+ </AND>
+ </match>
+ </rule>
+ <rule>
+ <match>
+ <AND>
+ <FIELD />
+ <PACKAGE_PRIVATE />
+ <STATIC />
+ </AND>
+ </match>
+ </rule>
+ <rule>
+ <match>
+ <AND>
+ <FIELD />
+ <PRIVATE />
+ <STATIC />
+ </AND>
+ </match>
+ </rule>
+ <rule>
+ <match>
+ <AND>
+ <FIELD />
+ <FINAL />
+ <PUBLIC />
+ </AND>
+ </match>
+ </rule>
+ <rule>
+ <match>
+ <AND>
+ <FIELD />
+ <FINAL />
+ <PROTECTED />
+ </AND>
+ </match>
+ </rule>
+ <rule>
+ <match>
+ <AND>
+ <FIELD />
+ <FINAL />
+ <PACKAGE_PRIVATE />
+ </AND>
+ </match>
+ </rule>
+ <rule>
+ <match>
+ <AND>
+ <FIELD />
+ <FINAL />
+ <PRIVATE />
+ </AND>
+ </match>
+ </rule>
+ <rule>
+ <match>
+ <AND>
+ <FIELD />
+ <PUBLIC />
+ </AND>
+ </match>
+ </rule>
+ <rule>
+ <match>
+ <AND>
+ <FIELD />
+ <PROTECTED />
+ </AND>
+ </match>
+ </rule>
+ <rule>
+ <match>
+ <AND>
+ <FIELD />
+ <PACKAGE_PRIVATE />
+ </AND>
+ </match>
+ </rule>
+ <rule>
+ <match>
+ <AND>
+ <FIELD />
+ <PRIVATE />
+ </AND>
+ </match>
+ </rule>
+ <rule>
+ <match>
+ <FIELD />
+ </match>
+ </rule>
+ <rule>
+ <match>
+ <CONSTRUCTOR />
+ </match>
+ </rule>
+ <rule>
+ <match>
+ <AND>
+ <METHOD />
+ <STATIC />
+ <PUBLIC />
+ </AND>
+ </match>
+ </rule>
+ <rule>
+ <match>
+ <AND>
+ <METHOD />
+ <STATIC />
+ <PROTECTED />
+ </AND>
+ </match>
+ </rule>
+ <rule>
+ <match>
+ <AND>
+ <METHOD />
+ <STATIC />
+ <PACKAGE_PRIVATE />
+ </AND>
+ </match>
+ </rule>
+ <rule>
+ <match>
+ <AND>
+ <METHOD />
+ <PUBLIC />
+ </AND>
+ </match>
+ </rule>
+ <rule>
+ <match>
+ <AND>
+ <METHOD />
+ <PROTECTED />
+ </AND>
+ </match>
+ </rule>
+ <rule>
+ <match>
+ <AND>
+ <METHOD />
+ <PACKAGE_PRIVATE />
+ </AND>
+ </match>
+ </rule>
+ <rule>
+ <match>
+ <METHOD />
+ </match>
+ </rule>
+ <rule>
+ <match>
+ <ENUM />
+ </match>
+ </rule>
+ <rule>
+ <match>
+ <INTERFACE />
+ </match>
+ </rule>
+ <rule>
+ <match>
+ <AND>
+ <CLASS />
+ <STATIC />
+ </AND>
+ </match>
+ </rule>
+ <rule>
+ <match>
+ <CLASS />
+ </match>
+ </rule>
+ </rules>
+ </arrangement>
+ </codeStyleSettings>
+ <codeStyleSettings language="JavaScript">
+ <option name="ELSE_ON_NEW_LINE" value="true" />
+ <option name="WHILE_ON_NEW_LINE" value="true" />
+ <option name="CATCH_ON_NEW_LINE" value="true" />
+ <option name="FINALLY_ON_NEW_LINE" value="true" />
+ <option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
+ <option name="ALIGN_MULTILINE_FOR" value="false" />
+ <option name="ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION" value="true" />
+ <option name="KEEP_SIMPLE_BLOCKS_IN_ONE_LINE" value="true" />
+ <option name="KEEP_SIMPLE_METHODS_IN_ONE_LINE" value="true" />
+ <option name="ARRAY_INITIALIZER_WRAP" value="1" />
+ <option name="IF_BRACE_FORCE" value="3" />
+ <option name="DOWHILE_BRACE_FORCE" value="3" />
+ <option name="WHILE_BRACE_FORCE" value="3" />
+ <option name="FOR_BRACE_FORCE" value="3" />
+ <option name="PARENT_SETTINGS_INSTALLED" value="true" />
+ </codeStyleSettings>
+ <codeStyleSettings language="PHP">
+ <option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false" />
+ <option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" />
+ <option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
+ <option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="0" />
+ <option name="ELSE_ON_NEW_LINE" value="true" />
+ <option name="WHILE_ON_NEW_LINE" value="true" />
+ <option name="CATCH_ON_NEW_LINE" value="true" />
+ <option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
+ <option name="ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION" value="true" />
+ <option name="SPACE_WITHIN_ARRAY_INITIALIZER_BRACES" value="true" />
+ <option name="SPACE_BEFORE_ARRAY_INITIALIZER_LBRACE" value="true" />
+ <option name="CALL_PARAMETERS_WRAP" value="5" />
+ <option name="EXTENDS_LIST_WRAP" value="1" />
+ <option name="EXTENDS_KEYWORD_WRAP" value="2" />
+ <option name="METHOD_CALL_CHAIN_WRAP" value="5" />
+ <option name="TERNARY_OPERATION_WRAP" value="5" />
+ <option name="FOR_STATEMENT_WRAP" value="5" />
+ <option name="ARRAY_INITIALIZER_WRAP" value="1" />
+ <option name="IF_BRACE_FORCE" value="3" />
+ <option name="DOWHILE_BRACE_FORCE" value="3" />
+ <option name="WHILE_BRACE_FORCE" value="3" />
+ <option name="FOR_BRACE_FORCE" value="3" />
+ <option name="PARENT_SETTINGS_INSTALLED" value="true" />
+ </codeStyleSettings>
+ <codeStyleSettings language="Python">
+ <option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" />
+ <option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
+ <option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
+ <option name="PARENT_SETTINGS_INSTALLED" value="true" />
+ </codeStyleSettings>
+ <codeStyleSettings language="SQL">
+ <indentOptions>
+ <option name="CONTINUATION_INDENT_SIZE" value="2" />
+ </indentOptions>
+ </codeStyleSettings>
+ <codeStyleSettings language="Shell Script">
+ <indentOptions>
+ <option name="INDENT_SIZE" value="4" />
+ </indentOptions>
+ </codeStyleSettings>
+ <codeStyleSettings language="TypeScript">
+ <option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
+ <option name="CLASS_BRACE_STYLE" value="2" />
+ <option name="METHOD_BRACE_STYLE" value="2" />
+ <option name="ELSE_ON_NEW_LINE" value="true" />
+ <option name="WHILE_ON_NEW_LINE" value="true" />
+ <option name="CATCH_ON_NEW_LINE" value="true" />
+ <option name="FINALLY_ON_NEW_LINE" value="true" />
+ <option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
+ <option name="ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION" value="true" />
+ <option name="CALL_PARAMETERS_WRAP" value="5" />
+ <option name="EXTENDS_LIST_WRAP" value="1" />
+ <option name="EXTENDS_KEYWORD_WRAP" value="2" />
+ <option name="TERNARY_OPERATION_WRAP" value="5" />
+ <option name="FOR_STATEMENT_WRAP" value="5" />
+ <option name="ARRAY_INITIALIZER_WRAP" value="1" />
+ <option name="IF_BRACE_FORCE" value="3" />
+ <option name="DOWHILE_BRACE_FORCE" value="3" />
+ <option name="WHILE_BRACE_FORCE" value="3" />
+ <option name="FOR_BRACE_FORCE" value="3" />
+ <option name="PARENT_SETTINGS_INSTALLED" value="true" />
+ </codeStyleSettings>
+ <codeStyleSettings language="jet">
+ <option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
+ <option name="PARENT_SETTINGS_INSTALLED" value="true" />
+ </codeStyleSettings>
+ <codeStyleSettings language="ruby">
+ <option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" />
+ <option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
+ <option name="PARENT_SETTINGS_INSTALLED" value="true" />
+ </codeStyleSettings>
+</code_scheme>
diff --git a/build-tools/src/main/resources/checkstyle-suppressions.xml b/dev-support/checkstyle-suppressions.xml
similarity index 79%
rename from build-tools/src/main/resources/checkstyle-suppressions.xml
rename to dev-support/checkstyle-suppressions.xml
index 759a52ec7..d56f4a143 100644
--- a/build-tools/src/main/resources/checkstyle-suppressions.xml
+++ b/dev-support/checkstyle-suppressions.xml
@@ -24,6 +24,8 @@
<suppressions>
<suppress checks="JavadocType" files="[/\\]src[/\\]test[/\\]java[/\\]"/>
- <!-- skip checks on customized titan 0.5.4 files -->
- <suppress checks="[a-zA-Z0-9]*" files="[/\\]com[/\\]thinkaurelius[/\\]titan[/\\]"/>
+ <suppress files="[*]*.properties" checks="[a-zA-Z0-9]*"/>
+ <suppress files="[\\/]target[\\/]" checks="[a-zA-Z0-9]*"/>
+ <suppress files="[\\/]generated-sources[\\/]" checks="[a-zA-Z0-9]*"/>
+ <suppress files="[\\/]surefire-reports[\\/]" checks="[a-zA-Z0-9]*"/>
</suppressions>
diff --git a/dev-support/checkstyle.xml b/dev-support/checkstyle.xml
new file mode 100755
index 000000000..349971428
--- /dev/null
+++ b/dev-support/checkstyle.xml
@@ -0,0 +1,272 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<!DOCTYPE module PUBLIC
+ "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
+ "http://checkstyle.sourceforge.net/dtds/configuration_1_3.dtd">
+<module name="Checker">
+ <module name="SuppressWithPlainTextCommentFilter">
+ <property name="offCommentFormat" value='"""'/>
+ <property name="onCommentFormat" value='"""'/>
+ </module>
+
+ <module name="FileTabCharacter" />
+ <module name="NewlineAtEndOfFile">
+ <property name="lineSeparator" value="lf" />
+ </module>
+ <module name="RegexpMultiline">
+ <property name="format" value="\r" />
+ <property name="message" value="Line contains carriage return" />
+ </module>
+ <module name="RegexpMultiline">
+ <property name="format" value=" \n" />
+ <property name="message" value="Line has trailing whitespace" />
+ </module>
+ <module name="RegexpMultiline">
+ <property name="format" value="\n\n\n" />
+ <property name="message" value="Multiple consecutive blank lines" />
+ </module>
+ <module name="RegexpMultiline">
+ <property name="format" value="\n\n\Z" />
+ <property name="message" value="Blank line before end of file" />
+ </module>
+
+ <module name="RegexpMultiline">
+ <property name="format" value="\{\n\n" />
+ <property name="message" value="Blank line after opening brace" />
+ </module>
+ <module name="RegexpMultiline">
+ <property name="format" value="\n\n\s*\}" />
+ <property name="message" value="Blank line before closing brace" />
+ </module>
+ <module name="RegexpMultiline">
+ <property name="format" value="[^;]\s\)+\s*[\{;,]?\s*\n" />
+ <property name="message" value="Whitespace character before closing parenthesis" />
+ </module>
+ <module name="RegexpMultiline">
+ <property name="format" value="->\s*\{\s+\}" />
+ <property name="message" value="Whitespace inside empty lambda body" />
+ </module>
+ <module name="RegexpMultiline">
+ <property name="format" value="->(\s*+(//.*+)?\n)++\s*+\{" />
+ <property name="message" value="Lambda opening brace should be on the same line as ->" />
+ </module>
+
+ <module name="RegexpSingleline">
+ <property name="format" value="^import static .*\.(of|copyOf|valueOf|builder);$" />
+ <property name="message" value="The following methods may not be statically imported: of, copyOf, valueOf, builder" />
+ </module>
+ <module name="RegexpSingleline">
+ <property name="format" value="^import static (?!java\.lang\.String\.format;).*\.format;" />
+ <property name="message" value="Only 'format' from java.lang.String may be statically imported" />
+ </module>
+ <module name="RegexpSingleline">
+ <property name="format" value="^import static java\.util\.Optional\." />
+ <property name="message" value="Members of Optional may not be statically imported" />
+ </module>
+
+ <module name="RegexpSingleline">
+ <property name="format" value="^(?!import ).*Objects\.requireNonNull" />
+ <property name="message" value="Objects.requireNonNull should only be used with static imports" />
+ </module>
+ <module name="RegexpSingleline">
+ <property name="format" value="^(?!import ).*Math\.toIntExact" />
+ <property name="message" value="Math.toIntExact should only be used with static imports" />
+ </module>
+ <module name="RegexpSingleline">
+ <property name="format" value="^(?!import ).*ImmutableMap\.toImmutableMap" />
+ <property name="message" value="ImmutableMap.toImmutableMap should only be used with static imports" />
+ </module>
+ <module name="RegexpSingleline">
+ <property name="format" value="^(?!import ).*ImmutableList\.toImmutableList" />
+ <property name="message" value="ImmutableList.toImmutableList should only be used with static imports" />
+ </module>
+ <module name="RegexpSingleline">
+ <property name="format" value="^(?!import ).*ImmutableSet\.toImmutableSet" />
+ <property name="message" value="ImmutableSet.toImmutableSet should only be used with static imports" />
+ </module>
+ <module name="RegexpMultiline">
+ <property name="format" value="^[ \t]*import org\.testng\.Assert;$" />
+ <property name="message" value="org.testng.Assert should only be used with static imports" />
+ </module>
+ <module name="RegexpMultiline">
+ <property name="format" value="^[ \t]*import com\.google\.common\.base\.MoreObjects;$" />
+ <property name="message" value="com.google.common.base.MoreObjects should only be used with static imports" />
+ </module>
+ <module name="RegexpMultiline">
+ <property name="format" value="^[ \t]*import com\.google\.common\.base\.Preconditions;$" />
+ <property name="message" value="com.google.common.base.Preconditions should only be used with static imports" />
+ </module>
+ <module name="RegexpMultiline">
+ <property name="format" value="^[ \t]*import com\.google\.common\.base\.Verify;$" />
+ <property name="message" value="com.google.common.base.Verify should only be used with static imports" />
+ </module>
+
+ <module name="SuppressWarningsFilter" />
+
+ <module name="TreeWalker">
+ <module name="SuppressWarningsHolder" />
+
+ <module name="SuppressionXpathSingleFilter">
+ <property name="checks" value="RedundantModifier"/>
+ <property name="query" value="//(CLASS_DEF)/OBJBLOCK/*/MODIFIERS/*"/>
+ </module>
+ <module name="RedundantModifier" />
+
+ <module name="EmptyBlock">
+ <property name="option" value="text" />
+ <property name="tokens" value="
+ LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_IF,
+ LITERAL_FOR, LITERAL_TRY, LITERAL_WHILE, INSTANCE_INIT, STATIC_INIT" />
+ </module>
+ <module name="EmptyStatement" />
+ <module name="EmptyForInitializerPad" />
+ <module name="EmptyForIteratorPad">
+ <property name="option" value="space" />
+ </module>
+ <module name="MethodParamPad">
+ <property name="allowLineBreaks" value="true" />
+ <property name="option" value="nospace" />
+ </module>
+ <module name="ParenPad" />
+ <module name="TypecastParenPad" />
+ <module name="NeedBraces" />
+ <module name="LeftCurly">
+ <property name="option" value="eol" />
+ <property name="tokens" value="
+ CLASS_DEF, CTOR_DEF, INTERFACE_DEF, METHOD_DEF,
+ LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR,
+ LITERAL_IF, LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE" />
+ </module>
+ <module name="RightCurly">
+ <property name="option" value="alone" />
+ <property name="tokens" value="LITERAL_ELSE" />
+ </module>
+ <module name="EmptyLineSeparator">
+ <property name="allowNoEmptyLineBetweenFields" value="true" />
+ <property name="tokens" value="
+ IMPORT, STATIC_IMPORT, CLASS_DEF, INTERFACE_DEF, ENUM_DEF,
+ STATIC_INIT, INSTANCE_INIT, METHOD_DEF, CTOR_DEF, VARIABLE_DEF" />
+ </module>
+ <module name="GenericWhitespace" />
+ <module name="WhitespaceAfter" />
+ <module name="NoWhitespaceAfter" />
+ <module name="NoWhitespaceBefore" />
+ <!-- module name="SingleSpaceSeparator" /-->
+ <module name="Indentation">
+ <property name="throwsIndent" value="8" />
+ <property name="lineWrappingIndentation" value="8" />
+ </module>
+
+ <module name="UpperEll" />
+ <module name="DefaultComesLast" />
+ <module name="ArrayTypeStyle" />
+ <module name="MultipleVariableDeclarations" />
+ <module name="ModifierOrder" />
+ <module name="OneStatementPerLine" />
+ <module name="StringLiteralEquality" />
+ <module name="MutableException" />
+ <module name="EqualsHashCode" />
+ <module name="InnerAssignment" />
+ <module name="HideUtilityClassConstructor" />
+ <module name="ExplicitInitialization" />
+ <module name="OneTopLevelClass" />
+
+ <module name="MemberName" />
+ <module name="LocalVariableName">
+ <property name="format" value="^([a-z][a-zA-Z0-9]*|_)$" />
+ </module>
+ <module name="LocalFinalVariableName">
+ <property name="format" value="^([a-z][a-zA-Z0-9]*|_)$" />
+ </module>
+ <module name="TypeName" />
+ <module name="PackageName">
+ <property name="format" value="^[a-z][a-z0-9]*(\.[a-z][a-z0-9]*)*$" />
+ </module>
+ <module name="PackageDeclaration" />
+ <module name="ParameterName" />
+ <module name="StaticVariableName" />
+ <module name="ClassTypeParameterName">
+ <property name="format" value="^[A-Z][A-Za-z0-9]*$" />
+ </module>
+ <module name="MethodTypeParameterName">
+ <property name="format" value="^[A-Z][A-Za-z0-9]*$" />
+ </module>
+
+ <module name="AnnotationUseStyle">
+ <property name="trailingArrayComma" value="ignore" />
+ </module>
+
+ <module name="AvoidStarImport" />
+ <module name="RedundantImport" />
+ <module name="UnusedImports" />
+ <module name="ImportOrder">
+ <property name="groups" value="*,javax,java" />
+ <property name="separated" value="true" />
+ <property name="option" value="bottom" />
+ <property name="sortStaticImportsAlphabetically" value="true" />
+ </module>
+
+ <module name="SuppressionXpathSingleFilter">
+ <property name="checks" value="WhitespaceAround"/>
+ <property name="query" value="//LITERAL_SWITCH//SLIST"/>
+ </module>
+ <module name="SuppressionXpathSingleFilter">
+ <property name="checks" value="WhitespaceAround"/>
+ <property name="query" value="//LITERAL_SWITCH//RCURLY"/>
+ </module>
+ <module name="WhitespaceAround">
+ <property name="allowEmptyConstructors" value="true" />
+ <property name="allowEmptyMethods" value="true" />
+ <property name="allowEmptyLambdas" value="true" />
+ <property name="allowEmptyTypes" value="true" />
+ <property name="ignoreEnhancedForColon" value="false" />
+ <property name="tokens" value="
+ ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN,
+ BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, DO_WHILE, EQUAL, GE, GT,
+ LAMBDA, LAND, LCURLY, LE, LITERAL_ASSERT, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE,
+ LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN,
+ LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE,
+ LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL,
+ PLUS, PLUS_ASSIGN, QUESTION, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN,
+ STAR, STAR_ASSIGN, TYPE_EXTENSION_AND" />
+ </module>
+
+ <module name="WhitespaceAfter" />
+
+ <module name="NoWhitespaceAfter">
+ <property name="tokens" value="DOT" />
+ <property name="allowLineBreaks" value="false" />
+ </module>
+
+ <module name="IllegalToken">
+ <property name="tokens" value="LITERAL_ASSERT" />
+ </module>
+
+ <module name="MethodName">
+ <property name="format" value="^[a-z][a-zA-Z0-9_]*$"/>
+ </module>
+
+ <module name="RegexpSinglelineJava">
+ <!-- Forbid "new Type[]{", IntelliJ would reformat adding a space -->
+ <!-- Forbid "new Type[] {", IntelliJ would reformat removing a space -->
+ <property name="format" value="new\s++\w++(<\?>)?(\[\])++(\s{2,})?\{" />
+ <property name="message" value="Incorrect whitespace before array initializer" />
+ <property name="ignoreComments" value="true" />
+ </module>
+ </module>
+</module>
diff --git a/pom.xml b/pom.xml
index f8d8a7472..a578cacef 100644
--- a/pom.xml
+++ b/pom.xml
@@ -88,6 +88,9 @@
<avro.version>1.7.5</avro.version>
<calcite.version>1.16.0</calcite.version>
<checkstyle.failOnViolation>false</checkstyle.failOnViolation>
+ <checkstyle.plugin.version>3.1.0</checkstyle.plugin.version>
+ <checkstyle.skip>true</checkstyle.skip>
+ <checkstyle.version>8.29</checkstyle.version>
<codehaus.woodstox.stax2-api.version>3.1.4</codehaus.woodstox.stax2-api.version>
<commons-cli.version>1.4</commons-cli.version>
<commons-codec.version>1.14</commons-codec.version>
@@ -1162,12 +1165,6 @@
<version>0.13</version>
</plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <version>2.9.1</version>
- </plugin>
-
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
@@ -1504,7 +1501,13 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
+ <version>${checkstyle.plugin.version}</version>
<dependencies>
+ <dependency>
+ <groupId>com.puppycrawl.tools</groupId>
+ <artifactId>checkstyle</artifactId>
+ <version>${checkstyle.version}</version>
+ </dependency>
<dependency>
<groupId>org.apache.atlas</groupId>
<artifactId>atlas-buildtools</artifactId>
@@ -1519,10 +1522,11 @@
</goals>
<phase>verify</phase>
<configuration>
- <skip>${skipCheck}</skip>
- <consoleOutput>false</consoleOutput>
+ <consoleOutput>true</consoleOutput>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
- <suppressionsFileExpression>checkstyle.suppressions.file</suppressionsFileExpression>
+ <configLocation>./dev-support/checkstyle.xml</configLocation>
+ <suppressionsLocation>./dev-support/checkstyle-suppressions.xml</suppressionsLocation>
+ <skip>${checkstyle.skip}</skip>
<failOnViolation>${checkstyle.failOnViolation}</failOnViolation>
</configuration>
</execution>
(atlas) 03/03: ATLAS-4960: checkstyle compliance updates - atlas-intg module (#273)
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
madhan pushed a commit to branch atlas-2.5
in repository https://gitbox.apache.org/repos/asf/atlas.git
commit 4f3566647f613dabeb09e1888291481c7b4a50b7
Author: Madhan Neethiraj <ma...@apache.org>
AuthorDate: Fri Jan 24 09:28:25 2025 -0800
ATLAS-4960: checkstyle compliance updates - atlas-intg module (#273)
(cherry picked from commit 6ff6b62125b2833a80a6854770232594f388d29c)
---
dev-support/checkstyle-suppressions.xml | 1 +
intg/pom.xml | 5 +
.../org/apache/atlas/ApplicationProperties.java | 200 ++--
.../java/org/apache/atlas/AtlasConfiguration.java | 43 +-
.../main/java/org/apache/atlas/AtlasErrorCode.java | 54 +-
.../main/java/org/apache/atlas/AtlasException.java | 7 +-
.../src/main/java/org/apache/atlas/DeleteType.java | 8 +-
intg/src/main/java/org/apache/atlas/SortOrder.java | 6 +-
.../atlas/bulkimport/BulkImportResponse.java | 29 +-
.../apache/atlas/exception/AtlasBaseException.java | 26 +-
.../apache/atlas/model/AtlasBaseModelObject.java | 42 +-
.../java/org/apache/atlas/model/Clearable.java | 6 +-
.../main/java/org/apache/atlas/model/PList.java | 41 +-
.../java/org/apache/atlas/model/SearchFilter.java | 39 +-
.../java/org/apache/atlas/model/TimeBoundary.java | 48 +-
.../java/org/apache/atlas/model/TypeCategory.java | 4 +-
.../apache/atlas/model/annotation/AtlasJSON.java | 6 +-
.../apache/atlas/model/audit/AtlasAuditEntry.java | 118 ++-
.../atlas/model/audit/AuditReductionCriteria.java | 45 +-
.../atlas/model/audit/AuditSearchParameters.java | 67 +-
.../atlas/model/audit/EntityAuditEventV2.java | 262 ++---
.../model/discovery/AtlasAggregationEntry.java | 33 +-
.../model/discovery/AtlasQuickSearchResult.java | 12 +-
.../atlas/model/discovery/AtlasSearchResult.java | 250 +++--
.../discovery/AtlasSearchResultDownloadStatus.java | 29 +-
.../model/discovery/AtlasSuggestionsResult.java | 4 +-
.../model/discovery/QuickSearchParameters.java | 17 +-
.../discovery/RelationshipSearchParameters.java | 21 +-
.../atlas/model/discovery/SearchParameters.java | 276 ++---
.../apache/atlas/model/glossary/AtlasGlossary.java | 127 ++-
.../model/glossary/AtlasGlossaryBaseObject.java | 43 +-
.../model/glossary/AtlasGlossaryCategory.java | 60 +-
.../atlas/model/glossary/AtlasGlossaryTerm.java | 184 ++--
.../model/glossary/AtlasGlossaryTermHeader.java | 34 +-
.../glossary/enums/AtlasTermAssignmentStatus.java | 5 +-
.../enums/AtlasTermRelationshipStatus.java | 5 +-
.../glossary/relations/AtlasGlossaryHeader.java | 30 +-
.../relations/AtlasRelatedCategoryHeader.java | 39 +-
.../glossary/relations/AtlasRelatedTermHeader.java | 63 +-
.../relations/AtlasTermAssignmentHeader.java | 89 +-
.../relations/AtlasTermCategorizationHeader.java | 39 +-
.../atlas/model/impexp/AtlasExportRequest.java | 68 +-
.../atlas/model/impexp/AtlasExportResult.java | 81 +-
.../atlas/model/impexp/AtlasImportRequest.java | 109 +-
.../atlas/model/impexp/AtlasImportResult.java | 41 +-
.../org/apache/atlas/model/impexp/AtlasServer.java | 33 +-
.../atlas/model/impexp/AttributeTransform.java | 16 +-
.../atlas/model/impexp/ExportImportAuditEntry.java | 51 +-
.../apache/atlas/model/impexp/MigrationStatus.java | 38 +-
.../model/instance/AtlasCheckStateRequest.java | 20 +-
.../model/instance/AtlasCheckStateResult.java | 66 +-
.../atlas/model/instance/AtlasClassification.java | 87 +-
.../apache/atlas/model/instance/AtlasEntity.java | 286 ++---
.../atlas/model/instance/AtlasEntityHeader.java | 68 +-
.../atlas/model/instance/AtlasEntityHeaders.java | 27 +-
.../apache/atlas/model/instance/AtlasObjectId.java | 76 +-
.../atlas/model/instance/AtlasRelatedObjectId.java | 126 ++-
.../atlas/model/instance/AtlasRelationship.java | 244 +++--
.../model/instance/AtlasRelationshipHeader.java | 61 +-
.../apache/atlas/model/instance/AtlasStruct.java | 226 ++--
.../instance/ClassificationAssociateRequest.java | 73 +-
.../model/instance/EntityMutationResponse.java | 140 +--
.../atlas/model/instance/EntityMutations.java | 144 +--
.../apache/atlas/model/instance/GuidMapping.java | 37 +-
.../apache/atlas/model/legacy/EntityResult.java | 47 +-
.../atlas/model/lineage/AtlasLineageInfo.java | 113 +-
.../model/lineage/LineageOnDemandConstraints.java | 12 +-
.../apache/atlas/model/metrics/AtlasMetrics.java | 14 +-
.../model/metrics/AtlasMetricsMapToChart.java | 18 +-
.../atlas/model/metrics/AtlasMetricsStat.java | 49 +-
.../model/migration/MigrationImportStatus.java | 26 +-
.../notification/AtlasNotificationBaseMessage.java | 159 ++-
.../notification/AtlasNotificationMessage.java | 30 +-
.../AtlasNotificationStringMessage.java | 31 +-
.../model/notification/EntityNotification.java | 78 +-
.../atlas/model/notification/HookNotification.java | 71 +-
.../atlas/model/notification/MessageSource.java | 50 +-
.../atlas/model/notification/MessageVersion.java | 55 +-
.../org/apache/atlas/model/patches/AtlasPatch.java | 84 +-
.../atlas/model/profile/AtlasUserProfile.java | 23 +-
.../atlas/model/profile/AtlasUserSavedSearch.java | 44 +-
.../org/apache/atlas/model/tasks/AtlasTask.java | 32 +-
.../atlas/model/typedef/AtlasBaseTypeDef.java | 329 +++---
.../model/typedef/AtlasBusinessMetadataDef.java | 27 +-
.../model/typedef/AtlasClassificationDef.java | 70 +-
.../apache/atlas/model/typedef/AtlasEntityDef.java | 105 +-
.../apache/atlas/model/typedef/AtlasEnumDef.java | 134 +--
.../atlas/model/typedef/AtlasRelationshipDef.java | 178 ++--
.../model/typedef/AtlasRelationshipEndDef.java | 88 +-
.../apache/atlas/model/typedef/AtlasStructDef.java | 252 +++--
.../atlas/model/typedef/AtlasTypeDefHeader.java | 43 +-
.../apache/atlas/model/typedef/AtlasTypesDef.java | 91 +-
.../atlas/security/InMemoryJAASConfiguration.java | 162 ++-
.../apache/atlas/security/SecurityProperties.java | 47 +-
.../org/apache/atlas/security/SecurityUtil.java | 29 +-
.../java/org/apache/atlas/type/AtlasArrayType.java | 243 +++--
.../org/apache/atlas/type/AtlasBuiltInTypes.java | 92 +-
.../atlas/type/AtlasBusinessMetadataType.java | 38 +-
.../apache/atlas/type/AtlasClassificationType.java | 542 +++++-----
.../org/apache/atlas/type/AtlasEntityType.java | 969 +++++++++--------
.../java/org/apache/atlas/type/AtlasEnumType.java | 26 +-
.../java/org/apache/atlas/type/AtlasMapType.java | 157 +--
.../apache/atlas/type/AtlasRelationshipType.java | 275 +++--
.../org/apache/atlas/type/AtlasStructType.java | 954 +++++++++--------
.../main/java/org/apache/atlas/type/AtlasType.java | 73 +-
.../org/apache/atlas/type/AtlasTypeRegistry.java | 820 +++++++-------
.../java/org/apache/atlas/type/AtlasTypeUtil.java | 284 +++--
.../java/org/apache/atlas/type/AttributeToken.java | 4 +-
.../java/org/apache/atlas/type/ConstantToken.java | 2 +-
.../main/java/org/apache/atlas/type/Constants.java | 35 +-
.../java/org/apache/atlas/type/DependentToken.java | 9 +-
.../apache/atlas/typesystem/types/DataTypes.java | 2 +-
.../apache/atlas/utils/AtlasConfigurationUtil.java | 15 +-
.../org/apache/atlas/utils/AtlasEntityUtil.java | 41 +-
.../java/org/apache/atlas/utils/AtlasJson.java | 173 ++-
.../org/apache/atlas/utils/AtlasStringUtil.java | 10 +-
.../org/apache/atlas/utils/AuthenticationUtil.java | 16 +-
.../org/apache/atlas/utils/FixedBufferList.java | 19 +-
.../main/java/org/apache/atlas/utils/SSLUtil.java | 83 +-
.../atlas/v1/model/discovery/DSLSearchResult.java | 46 +-
.../v1/model/discovery/FullTextSearchResult.java | 46 +-
.../v1/model/instance/AtlasSystemAttributes.java | 44 +-
.../org/apache/atlas/v1/model/instance/Id.java | 179 ++--
.../atlas/v1/model/instance/Referenceable.java | 127 ++-
.../org/apache/atlas/v1/model/instance/Struct.java | 94 +-
.../v1/model/lineage/DataSetLineageResponse.java | 31 +-
.../atlas/v1/model/lineage/LineageResponse.java | 32 +-
.../atlas/v1/model/lineage/SchemaResponse.java | 39 +-
.../model/notification/EntityNotificationV1.java | 84 +-
.../v1/model/notification/HookNotificationV1.java | 42 +-
.../v1/model/typedef/AttributeDefinition.java | 95 +-
.../v1/model/typedef/ClassTypeDefinition.java | 21 +-
.../atlas/v1/model/typedef/EnumTypeDefinition.java | 53 +-
.../model/typedef/HierarchicalTypeDefinition.java | 30 +-
.../atlas/v1/model/typedef/Multiplicity.java | 33 +-
.../v1/model/typedef/StructTypeDefinition.java | 34 +-
.../v1/model/typedef/TraitTypeDefinition.java | 17 +-
.../apache/atlas/v1/model/typedef/TypesDef.java | 21 +-
.../atlas/v1/typesystem/types/utils/TypesUtil.java | 53 +-
.../apache/atlas/ApplicationPropertiesTest.java | 81 +-
.../org/apache/atlas/TestRelationshipUtilsV2.java | 265 +++--
.../test/java/org/apache/atlas/TestUtilsV2.java | 1120 +++++++-------------
.../java/org/apache/atlas/model/ModelTestUtil.java | 170 +--
.../model/instance/TestAtlasClassification.java | 15 +-
.../atlas/model/instance/TestAtlasEntity.java | 24 +-
.../typedef/TestAtlasBusinessMetadataDef.java | 40 +-
.../model/typedef/TestAtlasClassificationDef.java | 22 +-
.../atlas/model/typedef/TestAtlasEntityDef.java | 14 +-
.../atlas/model/typedef/TestAtlasEnumDef.java | 18 +-
.../model/typedef/TestAtlasRelationshipDef.java | 66 +-
.../atlas/model/typedef/TestAtlasStructDef.java | 10 +-
.../security/InMemoryJAASConfigurationTest.java | 61 +-
...AASConfigurationTicketBasedKafkaClientTest.java | 24 +-
.../org/apache/atlas/type/TestAtlasArrayType.java | 90 +-
.../apache/atlas/type/TestAtlasBigDecimalType.java | 26 +-
.../apache/atlas/type/TestAtlasBigIntegerType.java | 24 +-
.../apache/atlas/type/TestAtlasBooleanType.java | 27 +-
.../type/TestAtlasBuiltInTypesFloatDouble.java | 12 +-
.../org/apache/atlas/type/TestAtlasByteType.java | 30 +-
.../atlas/type/TestAtlasClassificationType.java | 385 +++----
.../org/apache/atlas/type/TestAtlasDateType.java | 29 +-
.../org/apache/atlas/type/TestAtlasDoubleType.java | 32 +-
.../org/apache/atlas/type/TestAtlasEntityType.java | 440 ++++----
.../org/apache/atlas/type/TestAtlasFloatType.java | 33 +-
.../org/apache/atlas/type/TestAtlasIntType.java | 28 +-
.../org/apache/atlas/type/TestAtlasLongType.java | 29 +-
.../org/apache/atlas/type/TestAtlasMapType.java | 72 +-
.../apache/atlas/type/TestAtlasObjectIdType.java | 127 +--
.../atlas/type/TestAtlasRelationshipType.java | 152 ++-
.../org/apache/atlas/type/TestAtlasShortType.java | 32 +-
.../org/apache/atlas/type/TestAtlasStringType.java | 20 +-
.../org/apache/atlas/type/TestAtlasStructType.java | 216 ++--
.../apache/atlas/type/TestAtlasTypeRegistry.java | 374 +++----
.../org/apache/atlas/type/TestMultiplicity.java | 11 +-
.../apache/atlas/utils/FixedBufferListTest.java | 85 +-
175 files changed, 8657 insertions(+), 8576 deletions(-)
diff --git a/dev-support/checkstyle-suppressions.xml b/dev-support/checkstyle-suppressions.xml
index d56f4a143..6d3bf47d1 100644
--- a/dev-support/checkstyle-suppressions.xml
+++ b/dev-support/checkstyle-suppressions.xml
@@ -28,4 +28,5 @@
<suppress files="[\\/]target[\\/]" checks="[a-zA-Z0-9]*"/>
<suppress files="[\\/]generated-sources[\\/]" checks="[a-zA-Z0-9]*"/>
<suppress files="[\\/]surefire-reports[\\/]" checks="[a-zA-Z0-9]*"/>
+ <suppress files="Id.java" checks="MethodName"/>
</suppressions>
diff --git a/intg/pom.xml b/intg/pom.xml
index c0f8d19ef..eb6ea9e1e 100644
--- a/intg/pom.xml
+++ b/intg/pom.xml
@@ -31,6 +31,11 @@
<name>Apache Atlas Integration</name>
<description>Apache Atlas Integration</description>
+ <properties>
+ <checkstyle.failOnViolation>true</checkstyle.failOnViolation>
+ <checkstyle.skip>false</checkstyle.skip>
+ </properties>
+
<dependencies>
<dependency>
diff --git a/intg/src/main/java/org/apache/atlas/ApplicationProperties.java b/intg/src/main/java/org/apache/atlas/ApplicationProperties.java
index 82ddc8ab0..7551cc950 100644
--- a/intg/src/main/java/org/apache/atlas/ApplicationProperties.java
+++ b/intg/src/main/java/org/apache/atlas/ApplicationProperties.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -34,45 +34,45 @@ import java.net.URL;
import java.util.AbstractMap.SimpleEntry;
import java.util.Iterator;
import java.util.Properties;
+
import static org.apache.atlas.security.SecurityProperties.HADOOP_SECURITY_CREDENTIAL_PROVIDER_PATH;
/**
* Application properties used by Atlas.
*/
public final class ApplicationProperties extends PropertiesConfiguration {
- public static final String ATLAS_CONFIGURATION_DIRECTORY_PROPERTY = "atlas.conf";
private static final Logger LOG = LoggerFactory.getLogger(ApplicationProperties.class);
- public static final String APPLICATION_PROPERTIES = "atlas-application.properties";
-
- public static final String GRAPHDB_BACKEND_CONF = "atlas.graphdb.backend";
- public static final String STORAGE_BACKEND_CONF = "atlas.graph.storage.backend";
- public static final String INDEX_BACKEND_CONF = "atlas.graph.index.search.backend";
- public static final String INDEX_MAP_NAME_CONF = "atlas.graph.index.search.map-name";
- public static final String SOLR_WAIT_SEARCHER_CONF = "atlas.graph.index.search.solr.wait-searcher";
- public static final String ELASTICSEARCH_INDEX_NAME_CONF = "atlas.graph.index.search.elasticsearch.index-name";
- public static final String INDEX_RECOVERY_CONF = "atlas.index.recovery.enable";
- public static final String ENABLE_FULLTEXT_SEARCH_CONF = "atlas.search.fulltext.enable";
- public static final String ENABLE_FREETEXT_SEARCH_CONF = "atlas.search.freetext.enable";
- public static final String ATLAS_RUN_MODE = "atlas.run.mode";
- public static final String GRAPHBD_BACKEND_JANUS = "janus";
- public static final String DEFAULT_INDEX_NAME = "janusgraph";
- public static final String STORAGE_BACKEND_HBASE = "hbase";
- public static final String STORAGE_BACKEND_HBASE2 = "hbase2";
- public static final String INDEX_BACKEND_SOLR = "solr";
- public static final String INDEX_BACKEND_ELASTICSEARCH = "elasticsearch";
- public static final String LDAP_TYPE = "atlas.authentication.method.ldap.type";
- public static final String LDAP = "LDAP";
- public static final String AD = "AD";
- public static final String LDAP_AD_BIND_PASSWORD = "atlas.authentication.method.ldap.ad.bind.password";
- public static final String LDAP_BIND_PASSWORD = "atlas.authentication.method.ldap.bind.password";
- public static final String MASK_LDAP_PASSWORD = "********";
- public static final String DEFAULT_GRAPHDB_BACKEND = GRAPHBD_BACKEND_JANUS;
- public static final boolean DEFAULT_SOLR_WAIT_SEARCHER = false;
- public static final boolean DEFAULT_INDEX_MAP_NAME = false;
- public static final boolean DEFAULT_INDEX_RECOVERY = true;
- public static final AtlasRunMode DEFAULT_ATLAS_RUN_MODE = AtlasRunMode.PROD;
- public static final String INDEX_SEARCH_MAX_RESULT_SET_SIZE = "atlas.graph.index.search.max-result-set-size";
+ public static final String ATLAS_CONFIGURATION_DIRECTORY_PROPERTY = "atlas.conf";
+ public static final String APPLICATION_PROPERTIES = "atlas-application.properties";
+ public static final String GRAPHDB_BACKEND_CONF = "atlas.graphdb.backend";
+ public static final String STORAGE_BACKEND_CONF = "atlas.graph.storage.backend";
+ public static final String INDEX_BACKEND_CONF = "atlas.graph.index.search.backend";
+ public static final String INDEX_MAP_NAME_CONF = "atlas.graph.index.search.map-name";
+ public static final String SOLR_WAIT_SEARCHER_CONF = "atlas.graph.index.search.solr.wait-searcher";
+ public static final String ELASTICSEARCH_INDEX_NAME_CONF = "atlas.graph.index.search.elasticsearch.index-name";
+ public static final String INDEX_RECOVERY_CONF = "atlas.index.recovery.enable";
+ public static final String ENABLE_FULLTEXT_SEARCH_CONF = "atlas.search.fulltext.enable";
+ public static final String ENABLE_FREETEXT_SEARCH_CONF = "atlas.search.freetext.enable";
+ public static final String ATLAS_RUN_MODE = "atlas.run.mode";
+ public static final String GRAPHBD_BACKEND_JANUS = "janus";
+ public static final String DEFAULT_INDEX_NAME = "janusgraph";
+ public static final String STORAGE_BACKEND_HBASE = "hbase";
+ public static final String STORAGE_BACKEND_HBASE2 = "hbase2";
+ public static final String INDEX_BACKEND_SOLR = "solr";
+ public static final String INDEX_BACKEND_ELASTICSEARCH = "elasticsearch";
+ public static final String LDAP_TYPE = "atlas.authentication.method.ldap.type";
+ public static final String LDAP = "LDAP";
+ public static final String AD = "AD";
+ public static final String LDAP_AD_BIND_PASSWORD = "atlas.authentication.method.ldap.ad.bind.password";
+ public static final String LDAP_BIND_PASSWORD = "atlas.authentication.method.ldap.bind.password";
+ public static final String MASK_LDAP_PASSWORD = "********";
+ public static final String DEFAULT_GRAPHDB_BACKEND = GRAPHBD_BACKEND_JANUS;
+ public static final boolean DEFAULT_SOLR_WAIT_SEARCHER = false;
+ public static final boolean DEFAULT_INDEX_MAP_NAME = false;
+ public static final boolean DEFAULT_INDEX_RECOVERY = true;
+ public static final AtlasRunMode DEFAULT_ATLAS_RUN_MODE = AtlasRunMode.PROD;
+ public static final String INDEX_SEARCH_MAX_RESULT_SET_SIZE = "atlas.graph.index.search.max-result-set-size";
public static final SimpleEntry<String, String> DB_CACHE_CONF = new SimpleEntry<>("atlas.graph.cache.db-cache", "true");
public static final SimpleEntry<String, String> DB_CACHE_CLEAN_WAIT_CONF = new SimpleEntry<>("atlas.graph.cache.db-cache-clean-wait", "20");
@@ -80,12 +80,7 @@ public final class ApplicationProperties extends PropertiesConfiguration {
public static final SimpleEntry<String, String> DB_TX_CACHE_SIZE_CONF = new SimpleEntry<>("atlas.graph.cache.tx-cache-size", "15000");
public static final SimpleEntry<String, String> DB_CACHE_TX_DIRTY_SIZE_CONF = new SimpleEntry<>("atlas.graph.cache.tx-dirty-size", "120");
- private static volatile Configuration instance = null;
-
- public enum AtlasRunMode {
- PROD,
- DEV
- }
+ private static volatile Configuration instance;
private ApplicationProperties(URL url) throws ConfigurationException {
super(url);
@@ -102,28 +97,36 @@ public final class ApplicationProperties extends PropertiesConfiguration {
}
public static Configuration get() throws AtlasException {
- if (instance == null) {
+ Configuration me = instance;
+
+ if (me == null) {
synchronized (ApplicationProperties.class) {
- if (instance == null) {
+ me = instance;
+
+ if (me == null) {
set(get(APPLICATION_PROPERTIES));
+
+ me = instance;
}
}
}
- return instance;
+ return me;
}
public static Configuration set(Configuration configuration) throws AtlasException {
synchronized (ApplicationProperties.class) {
instance = configuration;
}
+
return instance;
}
public static Configuration get(String fileName) throws AtlasException {
String confLocation = System.getProperty(ATLAS_CONFIGURATION_DIRECTORY_PROPERTY);
+
try {
- URL url = null;
+ URL url;
if (confLocation == null) {
LOG.info("Looking for {} in classpath", fileName);
@@ -150,45 +153,35 @@ public final class ApplicationProperties extends PropertiesConfiguration {
Configuration configuration = appProperties.interpolatedConfiguration();
logConfiguration(configuration);
+
return configuration;
} catch (Exception e) {
throw new AtlasException("Failed to load application properties", e);
}
}
- private static void logConfiguration(Configuration configuration) {
- if (LOG.isDebugEnabled()) {
- Iterator<String> keys = configuration.getKeys();
- LOG.debug("Configuration loaded:");
- while (keys.hasNext()) {
- String key = keys.next();
- LOG.debug("{} = {}", key, configuration.getProperty(key));
- }
- }
- }
-
public static Configuration getSubsetConfiguration(Configuration inConf, String prefix) {
return inConf.subset(prefix);
}
public static Properties getSubsetAsProperties(Configuration inConf, String prefix) {
Configuration subset = inConf.subset(prefix);
- Properties ret = ConfigurationConverter.getProperties(subset);
- return ret;
+ return ConfigurationConverter.getProperties(subset);
}
- public static Class getClass(Configuration configuration, String propertyName, String defaultValue,
- Class assignableClass) throws AtlasException {
+ public static Class getClass(Configuration configuration, String propertyName, String defaultValue, Class assignableClass) throws AtlasException {
try {
- String propertyValue = configuration.getString(propertyName, defaultValue);
- Class<?> clazz = Class.forName(propertyValue);
+ String propertyValue = configuration.getString(propertyName, defaultValue);
+ Class<?> clazz = Class.forName(propertyValue);
+
if (assignableClass == null || assignableClass.isAssignableFrom(clazz)) {
return clazz;
} else {
- String message = "Class " + clazz.getName() + " specified in property " + propertyName
- + " is not assignable to class " + assignableClass.getName();
+ String message = "Class " + clazz.getName() + " specified in property " + propertyName + " is not assignable to class " + assignableClass.getName();
+
LOG.error(message);
+
throw new AtlasException(message);
}
} catch (Exception e) {
@@ -199,11 +192,14 @@ public final class ApplicationProperties extends PropertiesConfiguration {
public static Class getClass(String fullyQualifiedClassName, Class assignableClass) throws AtlasException {
try {
Class<?> clazz = Class.forName(fullyQualifiedClassName);
+
if (assignableClass == null || assignableClass.isAssignableFrom(clazz)) {
return clazz;
} else {
String message = "Class " + clazz.getName() + " is not assignable to class " + assignableClass.getName();
+
LOG.error(message);
+
throw new AtlasException(message);
}
} catch (Exception e) {
@@ -227,7 +223,7 @@ public final class ApplicationProperties extends PropertiesConfiguration {
* @throws AtlasException if no file was found or if there was an error loading the file
*/
public static InputStream getFileAsInputStream(Configuration configuration, String propertyName, String defaultFileName) throws AtlasException {
- File fileToLoad = null;
+ File fileToLoad;
String fileName = configuration.getString(propertyName);
if (fileName == null) {
@@ -253,7 +249,7 @@ public final class ApplicationProperties extends PropertiesConfiguration {
fileToLoad = new File(fileName);
}
- InputStream inStr = null;
+ InputStream inStr;
if (fileToLoad.exists()) {
try {
@@ -275,12 +271,37 @@ public final class ApplicationProperties extends PropertiesConfiguration {
throw new AtlasException(msg);
}
- LOG.info("Loaded {} as resource from {}", fileName, Thread.currentThread().getContextClassLoader().getResource(fileName).toString());
+ LOG.info("Loaded {} as resource from {}", fileName, Thread.currentThread().getContextClassLoader().getResource(fileName));
}
return inStr;
}
+ void setDefault(SimpleEntry<String, String> keyValueDefault, String currentValue) {
+ if (StringUtils.isNotEmpty(currentValue)) {
+ return;
+ }
+
+ clearPropertyDirect(keyValueDefault.getKey());
+ addPropertyDirect(keyValueDefault.getKey(), keyValueDefault.getValue());
+
+ LOG.info("Property (set to default) {} = {}", keyValueDefault.getKey(), keyValueDefault.getValue());
+ }
+
+ private static void logConfiguration(Configuration configuration) {
+ if (LOG.isDebugEnabled()) {
+ Iterator<String> keys = configuration.getKeys();
+
+ LOG.debug("Configuration loaded:");
+
+ while (keys.hasNext()) {
+ String key = keys.next();
+
+ LOG.debug("{} = {}", key, configuration.getProperty(key));
+ }
+ }
+ }
+
private static void setLdapPasswordFromKeystore(Configuration configuration) {
String ldapType = configuration.getString(LDAP_TYPE);
@@ -288,15 +309,19 @@ public final class ApplicationProperties extends PropertiesConfiguration {
try {
if (ldapType.equalsIgnoreCase(LDAP)) {
String maskPasssword = configuration.getString(LDAP_BIND_PASSWORD);
+
if (MASK_LDAP_PASSWORD.equals(maskPasssword)) {
String password = SecurityUtil.getPassword(configuration, LDAP_BIND_PASSWORD, HADOOP_SECURITY_CREDENTIAL_PROVIDER_PATH);
+
configuration.clearProperty(LDAP_BIND_PASSWORD);
configuration.addProperty(LDAP_BIND_PASSWORD, password);
}
} else if (ldapType.equalsIgnoreCase(AD)) {
String maskPasssword = configuration.getString(LDAP_AD_BIND_PASSWORD);
+
if (MASK_LDAP_PASSWORD.equals(maskPasssword)) {
String password = SecurityUtil.getPassword(configuration, LDAP_AD_BIND_PASSWORD, HADOOP_SECURITY_CREDENTIAL_PROVIDER_PATH);
+
configuration.clearProperty(LDAP_AD_BIND_PASSWORD);
configuration.addProperty(LDAP_AD_BIND_PASSWORD, password);
}
@@ -319,7 +344,8 @@ public final class ApplicationProperties extends PropertiesConfiguration {
clearPropertyDirect(GRAPHDB_BACKEND_CONF);
addPropertyDirect(GRAPHDB_BACKEND_CONF, graphDbBackend);
- LOG.info("Using graphdb backend '" + graphDbBackend + "'");
+
+ LOG.info("Using graphdb backend '{}'", graphDbBackend);
// setting value for 'atlas.graph.storage.backend' (default = 'hbase2')
String storageBackend = getString(STORAGE_BACKEND_CONF);
@@ -330,7 +356,8 @@ public final class ApplicationProperties extends PropertiesConfiguration {
clearPropertyDirect(STORAGE_BACKEND_CONF);
addPropertyDirect(STORAGE_BACKEND_CONF, storageBackend);
- LOG.info("Using storage backend '" + storageBackend + "'");
+
+ LOG.info("Using storage backend '{}'", storageBackend);
// setting value for 'atlas.graph.index.search.backend' (default = 'solr')
String indexBackend = getString(INDEX_BACKEND_CONF);
@@ -341,7 +368,8 @@ public final class ApplicationProperties extends PropertiesConfiguration {
clearPropertyDirect(INDEX_BACKEND_CONF);
addPropertyDirect(INDEX_BACKEND_CONF, indexBackend);
- LOG.info("Using index backend '" + indexBackend + "'");
+
+ LOG.info("Using index backend '{}'", indexBackend);
// set the following if indexing backend is 'solr'
if (indexBackend.equalsIgnoreCase(INDEX_BACKEND_SOLR)) {
@@ -352,16 +380,17 @@ public final class ApplicationProperties extends PropertiesConfiguration {
addPropertyDirect(SOLR_WAIT_SEARCHER_CONF, DEFAULT_SOLR_WAIT_SEARCHER);
}
- LOG.info("Setting " + SOLR_WAIT_SEARCHER_CONF + " = " + getBoolean(SOLR_WAIT_SEARCHER_CONF));
+ LOG.info("Setting {} = {}", SOLR_WAIT_SEARCHER_CONF, getBoolean(SOLR_WAIT_SEARCHER_CONF));
clearPropertyDirect(INDEX_MAP_NAME_CONF);
addPropertyDirect(INDEX_MAP_NAME_CONF, DEFAULT_INDEX_MAP_NAME);
- LOG.info("Setting index.search.map-name property '" + DEFAULT_INDEX_MAP_NAME + "'");
+
+ LOG.info("Setting index.search.map-name property '{}'", DEFAULT_INDEX_MAP_NAME);
}
- } else if (indexBackend.equalsIgnoreCase(INDEX_BACKEND_ELASTICSEARCH)){
- addPropertyDirect(ELASTICSEARCH_INDEX_NAME_CONF, DEFAULT_INDEX_NAME);
+ } else if (indexBackend.equalsIgnoreCase(INDEX_BACKEND_ELASTICSEARCH)) {
+ addPropertyDirect(ELASTICSEARCH_INDEX_NAME_CONF, DEFAULT_INDEX_NAME);
- LOG.info("Setting elasticsearch.index-name property '" + DEFAULT_INDEX_NAME + "'");
+ LOG.info("Setting elasticsearch.index-name property '{}'", DEFAULT_INDEX_NAME);
}
// setting value for 'atlas.graph.index.search.max-result-set-size' (default = 500000)
@@ -370,30 +399,23 @@ public final class ApplicationProperties extends PropertiesConfiguration {
clearPropertyDirect(INDEX_SEARCH_MAX_RESULT_SET_SIZE);
addPropertyDirect(INDEX_SEARCH_MAX_RESULT_SET_SIZE, indexMaxResultSetSize);
- LOG.info("Setting " + INDEX_SEARCH_MAX_RESULT_SET_SIZE + " = " + indexMaxResultSetSize);
+ LOG.info("Setting {} = {}", INDEX_SEARCH_MAX_RESULT_SET_SIZE, indexMaxResultSetSize);
setDbCacheConfDefaults();
}
- void setDefault(SimpleEntry<String, String> keyValueDefault, String currentValue) {
- if (StringUtils.isNotEmpty(currentValue)) {
- return;
- }
-
- clearPropertyDirect(keyValueDefault.getKey());
- addPropertyDirect(keyValueDefault.getKey(), keyValueDefault.getValue());
- LOG.info("Property (set to default) {} = {}", keyValueDefault.getKey(), keyValueDefault.getValue());
- }
-
private void setDbCacheConfDefaults() {
- SimpleEntry<String, String> keyValues[] = new SimpleEntry[]{ DB_CACHE_CONF, DB_CACHE_CLEAN_WAIT_CONF,
- DB_CACHE_SIZE_CONF, DB_TX_CACHE_SIZE_CONF,
- DB_CACHE_TX_DIRTY_SIZE_CONF };
+ SimpleEntry<String, String>[] keyValues = new SimpleEntry[] {DB_CACHE_CONF, DB_CACHE_CLEAN_WAIT_CONF, DB_CACHE_SIZE_CONF, DB_TX_CACHE_SIZE_CONF, DB_CACHE_TX_DIRTY_SIZE_CONF};
- for(SimpleEntry<String, String> kv : keyValues) {
+ for (SimpleEntry<String, String> kv : keyValues) {
String currentValue = getString(kv.getKey());
setDefault(kv, currentValue);
}
}
+
+ public enum AtlasRunMode {
+ PROD,
+ DEV
+ }
}
diff --git a/intg/src/main/java/org/apache/atlas/AtlasConfiguration.java b/intg/src/main/java/org/apache/atlas/AtlasConfiguration.java
index 6c39ee406..1b6fbd74b 100644
--- a/intg/src/main/java/org/apache/atlas/AtlasConfiguration.java
+++ b/intg/src/main/java/org/apache/atlas/AtlasConfiguration.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -32,7 +32,7 @@ public enum AtlasConfiguration {
WEBSERVER_QUEUE_SIZE("atlas.webserver.queuesize", 100),
WEBSERVER_REQUEST_BUFFER_SIZE("atlas.jetty.request.buffer.size", 16192),
- QUERY_PARAM_MAX_LENGTH("atlas.query.param.max.length", 4*1024),
+ QUERY_PARAM_MAX_LENGTH("atlas.query.param.max.length", 4 * 1024),
REST_API_ENABLE_DELETE_TYPE_OVERRIDE("atlas.rest.enable.delete.type.override", false),
NOTIFICATION_RELATIONSHIPS_ENABLED("atlas.notification.relationships.enabled", false),
@@ -47,7 +47,7 @@ public enum AtlasConfiguration {
NOTIFICATION_HOOK_CONSUMER_TOPIC_NAMES("atlas.notification.hook.consumer.topic.names", "ATLAS_HOOK"), // a comma separated list of topic names
NOTIFICATION_ENTITIES_CONSUMER_TOPIC_NAMES("atlas.notification.entities.consumer.topic.names", "ATLAS_ENTITIES"), // a comma separated list of topic names
- NOTIFICATION_REST_BODY_MAX_LENGTH_BYTES("atlas.notification.rest.body.max.length.bytes", (1 * 1024 * 1024)),
+ NOTIFICATION_REST_BODY_MAX_LENGTH_BYTES("atlas.notification.rest.body.max.length.bytes", (1024 * 1024)),
NOTIFICATION_MESSAGE_MAX_LENGTH_BYTES("atlas.notification.message.max.length.bytes", (1000 * 1000)),
NOTIFICATION_MESSAGE_COMPRESSION_ENABLED("atlas.notification.message.compression.enabled", true),
NOTIFICATION_SPLIT_MESSAGE_SEGMENTS_WAIT_TIME_SECONDS("atlas.notification.split.message.segments.wait.time.seconds", 15 * 60),
@@ -80,7 +80,7 @@ public enum AtlasConfiguration {
LINEAGE_ON_DEMAND_DEFAULT_NODE_COUNT("atlas.lineage.on.demand.default.node.count", 3),
LINEAGE_MAX_NODE_COUNT("atlas.lineage.max.node.count", 9000),
- HTTP_HEADER_SERVER_VALUE("atlas.http.header.server.value","Apache Atlas"),
+ HTTP_HEADER_SERVER_VALUE("atlas.http.header.server.value", "Apache Atlas"),
STORAGE_CONSISTENCY_LOCK_ENABLED("atlas.graph.storage.consistency-lock.enabled", true),
REBUILD_INDEX("atlas.rebuild.index", false),
PROCESS_NAME_UPDATE_PATCH("atlas.process.name.update.patch", false),
@@ -92,8 +92,8 @@ public enum AtlasConfiguration {
TASKS_USE_ENABLED("atlas.tasks.enabled", true),
SESSION_TIMEOUT_SECS("atlas.session.timeout.secs", -1),
UPDATE_COMPOSITE_INDEX_STATUS("atlas.update.composite.index.status", true),
- METRICS_TIME_TO_LIVE_HOURS( "atlas.metrics.ttl.hours", 336), // 14 days default
- SOLR_INDEX_TX_LOG_TTL_CONF("write.ahead.log.ttl.in.hours", 240), //10 days default
+ METRICS_TIME_TO_LIVE_HOURS("atlas.metrics.ttl.hours", 336), // 14 days default
+ SOLR_INDEX_TX_LOG_TTL_CONF("write.ahead.log.ttl.in.hours", 240), //10 days default
ATLAS_AUDIT_AGING_ENABLED("atlas.audit.aging.enabled", false),
ATLAS_AUDIT_DEFAULT_AGEOUT_ENABLED("atlas.audit.default.ageout.enabled", true),
@@ -109,20 +109,12 @@ public enum AtlasConfiguration {
MIN_AUDIT_COUNT_TO_MAINTAIN("atlas.audit.min.count.to.maintain", 50),
ATLAS_AUDIT_AGING_SEARCH_MAX_LIMIT("atlas.audit.aging.search.maxlimit", 10000),
ATLAS_AUDIT_DEFAULT_AGEOUT_IGNORE_TTL("atlas.audit.default.ageout.ignore.ttl", false),
- ATLAS_AUDIT_AGING_TTL_TEST_AUTOMATION("atlas.audit.aging.ttl.test.automation", false),//Only for test automation
- RELATIONSHIP_SEARCH_ENABLED("atlas.relationship.search.enabled" ,false),
+ ATLAS_AUDIT_AGING_TTL_TEST_AUTOMATION("atlas.audit.aging.ttl.test.automation", false), //Only for test automation
+ RELATIONSHIP_SEARCH_ENABLED("atlas.relationship.search.enabled", false),
UI_TASKS_TAB_USE_ENABLED("atlas.tasks.ui.tab.enabled", false);
private static final Configuration APPLICATION_PROPERTIES;
- static {
- try {
- APPLICATION_PROPERTIES = ApplicationProperties.get();
- } catch (AtlasException e) {
- throw new RuntimeException(e);
- }
- }
-
private final String propertyName;
private final Object defaultValue;
@@ -136,7 +128,7 @@ public enum AtlasConfiguration {
}
public int getInt() {
- return APPLICATION_PROPERTIES.getInt(propertyName, Integer.valueOf(defaultValue.toString()).intValue());
+ return APPLICATION_PROPERTIES.getInt(propertyName, Integer.parseInt(defaultValue.toString()));
}
public long getLong() {
@@ -154,7 +146,7 @@ public enum AtlasConfiguration {
public String[] getStringArray() {
String[] ret = APPLICATION_PROPERTIES.getStringArray(propertyName);
- if (ret == null || ret.length == 0 || (ret.length == 1 && StringUtils.isEmpty(ret[0]))) {
+ if (ret == null || ret.length == 0 || (ret.length == 1 && StringUtils.isEmpty(ret[0]))) {
if (defaultValue != null) {
ret = StringUtils.split(defaultValue.toString(), ',');
}
@@ -166,7 +158,7 @@ public enum AtlasConfiguration {
public String[] getStringArray(String... defaultValue) {
String[] ret = APPLICATION_PROPERTIES.getStringArray(propertyName);
- if (ret == null || ret.length == 0 || (ret.length == 1 && StringUtils.isEmpty(ret[0]))) {
+ if (ret == null || ret.length == 0 || (ret.length == 1 && StringUtils.isEmpty(ret[0]))) {
ret = defaultValue;
}
@@ -175,6 +167,15 @@ public enum AtlasConfiguration {
public Object get() {
Object value = APPLICATION_PROPERTIES.getProperty(propertyName);
+
return value == null ? defaultValue : value;
}
+
+ static {
+ try {
+ APPLICATION_PROPERTIES = ApplicationProperties.get();
+ } catch (AtlasException e) {
+ throw new RuntimeException(e);
+ }
+ }
}
diff --git a/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java b/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
index 61b8155b9..a5430ce44 100644
--- a/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
+++ b/intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
@@ -6,9 +6,9 @@
* 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.
@@ -21,6 +21,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.ws.rs.core.Response;
+
import java.text.MessageFormat;
import java.util.Arrays;
@@ -72,15 +73,15 @@ public enum AtlasErrorCode {
BAD_REQUEST(400, "ATLAS-400-00-029", "{0}"),
PARAMETER_PARSING_FAILED(400, "ATLAS-400-00-02A", "Parameter parsing failed at: {0}"),
MISSING_MANDATORY_ATTRIBUTE(400, "ATLAS-400-00-02B", "Mandatory field {0}.{1} has empty/null value"),
- RELATIONSHIPDEF_INSUFFICIENT_ENDS(400, "ATLAS-400-00-02C", "relationshipDef {0} creation attempted without 2 ends"),
- RELATIONSHIPDEF_DOUBLE_CONTAINERS(400, "ATLAS-400-00-02D", "relationshipDef {0} creation attempted with both ends as containers"),
- RELATIONSHIPDEF_UNSUPPORTED_ATTRIBUTE_TYPE(400, "ATLAS-400-00-02F", "Cannot set an Attribute with type {0} on relationship def {1}, as it is not a primitive type "),
- RELATIONSHIPDEF_ASSOCIATION_AND_CONTAINER(400, "ATLAS-400-00-030", "ASSOCIATION relationshipDef {0} creation attempted with an end specifying isContainer"),
- RELATIONSHIPDEF_COMPOSITION_NO_CONTAINER(400, "ATLAS-400-00-031", "COMPOSITION relationshipDef {0} creation attempted without an end specifying isContainer"),
- RELATIONSHIPDEF_AGGREGATION_NO_CONTAINER(400, "ATLAS-400-00-032", "AGGREGATION relationshipDef {0} creation attempted without an end specifying isContainer"),
- RELATIONSHIPDEF_COMPOSITION_MULTIPLE_PARENTS(400, "ATLAS-400-00-033", "COMPOSITION relationshipDef {0} can only have one parent; so cannot have SET cardinality on children"),
- RELATIONSHIPDEF_LIST_ON_END(400, "ATLAS-400-00-034", "relationshipDef {0} cannot have a LIST cardinality on an end"),
- RELATIONSHIPDEF_INVALID_END_TYPE(400, "ATLAS-400-00-035", "relationshipDef {0} has invalid end type {1}"),
+ RELATIONSHIPDEF_INSUFFICIENT_ENDS(400, "ATLAS-400-00-02C", "relationshipDef {0} creation attempted without 2 ends"),
+ RELATIONSHIPDEF_DOUBLE_CONTAINERS(400, "ATLAS-400-00-02D", "relationshipDef {0} creation attempted with both ends as containers"),
+ RELATIONSHIPDEF_UNSUPPORTED_ATTRIBUTE_TYPE(400, "ATLAS-400-00-02F", "Cannot set an Attribute with type {0} on relationship def {1}, as it is not a primitive type "),
+ RELATIONSHIPDEF_ASSOCIATION_AND_CONTAINER(400, "ATLAS-400-00-030", "ASSOCIATION relationshipDef {0} creation attempted with an end specifying isContainer"),
+ RELATIONSHIPDEF_COMPOSITION_NO_CONTAINER(400, "ATLAS-400-00-031", "COMPOSITION relationshipDef {0} creation attempted without an end specifying isContainer"),
+ RELATIONSHIPDEF_AGGREGATION_NO_CONTAINER(400, "ATLAS-400-00-032", "AGGREGATION relationshipDef {0} creation attempted without an end specifying isContainer"),
+ RELATIONSHIPDEF_COMPOSITION_MULTIPLE_PARENTS(400, "ATLAS-400-00-033", "COMPOSITION relationshipDef {0} can only have one parent; so cannot have SET cardinality on children"),
+ RELATIONSHIPDEF_LIST_ON_END(400, "ATLAS-400-00-034", "relationshipDef {0} cannot have a LIST cardinality on an end"),
+ RELATIONSHIPDEF_INVALID_END_TYPE(400, "ATLAS-400-00-035", "relationshipDef {0} has invalid end type {1}"),
INVALID_RELATIONSHIP_END_TYPE(400, "ATLAS-400-00-036", "invalid relationshipDef: {0}: end type 1: {1}, end type 2: {2}"),
RELATIONSHIPDEF_INVALID_END1_UPDATE(400, "ATLAS-400-00-037", "invalid update for relationshipDef {0}: new end1 {1}, existing end1 {2}"),
RELATIONSHIPDEF_INVALID_END2_UPDATE(400, "ATLAS-400-00-038", "invalid update for relationshipDef {0}: new end2 {1}, existing end2 {2}"),
@@ -100,12 +101,12 @@ public enum AtlasErrorCode {
CLASSIFICATIONDEF_INVALID_ENTITYTYPES(400, "ATLAS-400-00-052", "ClassificationDef ‘{0}‘ has invalid ‘{1}‘ in entityTypes"),
CLASSIFICATIONDEF_PARENTS_ENTITYTYPES_DISJOINT(400, "ATLAS-400-00-053", "ClassificationDef ‘{0}‘ has supertypes whose entityTypes are disjoint; e.g. 2 supertypes that are not related by inheritance specify different non empty entityType lists. This means the child cannot honour the restrictions specified in both parents."),
CLASSIFICATIONDEF_ENTITYTYPES_NOT_PARENTS_SUBSET(400, "ATLAS-400-00-054", "ClassificationDef ‘{0}‘ has entityTypes ‘{1}‘ which are not subsets of it's supertypes entityTypes"),
- INVALID_ENTITY_FOR_CLASSIFICATION (400, "ATLAS-400-00-055", "Entity (guid=‘{0}‘,typename=‘{1}‘) cannot be classified by Classification ‘{2}‘, because ‘{1}‘ is not in the ClassificationDef's restrictions."),
+ INVALID_ENTITY_FOR_CLASSIFICATION(400, "ATLAS-400-00-055", "Entity (guid=‘{0}‘,typename=‘{1}‘) cannot be classified by Classification ‘{2}‘, because ‘{1}‘ is not in the ClassificationDef's restrictions."),
SAVED_SEARCH_CHANGE_USER(400, "ATLAS-400-00-056", "saved-search {0} can not be moved from user {1} to {2}"),
- INVALID_QUERY_PARAM_LENGTH(400, "ATLAS-400-00-057" , "Length of query param {0} exceeds the limit"),
- INVALID_QUERY_LENGTH(400, "ATLAS-400-00-058" , "Invalid query length, update {0} to change the limit" ),
+ INVALID_QUERY_PARAM_LENGTH(400, "ATLAS-400-00-057", "Length of query param {0} exceeds the limit"),
+ INVALID_QUERY_LENGTH(400, "ATLAS-400-00-058", "Invalid query length, update {0} to change the limit"),
// DSL related error codes
- INVALID_DSL_QUERY(400, "ATLAS-400-00-059" , "Invalid DSL query: {0} | Reason: {1}. Please refer to Atlas DSL grammar for more information" ),
+ INVALID_DSL_QUERY(400, "ATLAS-400-00-059", "Invalid DSL query: {0} | Reason: {1}. Please refer to Atlas DSL grammar for more information"),
INVALID_DSL_GROUPBY(400, "ATLAS-400-00-05A", "DSL Semantic Error - GroupBy attribute {0} is non-primitive"),
INVALID_DSL_UNKNOWN_TYPE(400, "ATLAS-400-00-05B", "DSL Semantic Error - {0} type not found"),
INVALID_DSL_UNKNOWN_CLASSIFICATION(400, "ATLAS-400-00-05C", "DSL Semantic Error - {0} classification not found"),
@@ -168,7 +169,7 @@ public enum AtlasErrorCode {
BUSINESS_METADATA_ATTRIBUTE_DOES_NOT_EXIST(400, "ATLAS-400-00-096", "Business-metadata attribute does not exist in entity: {0}"),
BUSINESS_METADATA_ATTRIBUTE_ALREADY_EXISTS(400, "ATLAS-400-00-097", "Business-metadata attribute already exists in entity: {0}"),
INVALID_FILE_TYPE(400, "ATLAS-400-00-098", "The provided file type: {0} is not supported. Expected file formats are .csv and .xls."),
- INVALID_BUSINESS_ATTRIBUTES_IMPORT_DATA(400, "ATLAS-400-00-099","The uploaded file was not processed due to following errors : {0}"),
+ INVALID_BUSINESS_ATTRIBUTES_IMPORT_DATA(400, "ATLAS-400-00-099", "The uploaded file was not processed due to following errors : {0}"),
ATTRIBUTE_NAME_INVALID_CHARS(400, "ATLAS-400-00-09A", "{0}: invalid name. Attribute names must begin with a letter followed by a sequence of letters, numbers, or '_' characters"),
NO_DATA_FOUND(400, "ATLAS-400-00-09B", "No data found in the uploaded file"),
NOT_VALID_FILE(400, "ATLAS-400-00-09C", "Invalid {0} file"),
@@ -247,30 +248,29 @@ public enum AtlasErrorCode {
FAILED_TO_UPDATE_GLOSSARY_TERM(500, "ATLAS-500-00-017", "Error occurred while updating glossary term: {0}"),
NOTIFICATION_EXCEPTION(500, "ATLAS-500-00-018", "{0}");
- private String errorCode;
- private String errorMessage;
- private Response.Status httpCode;
-
private static final Logger LOG = LoggerFactory.getLogger(AtlasErrorCode.class);
+ private final String errorCode;
+ private final String errorMessage;
+ private final Response.Status httpCode;
AtlasErrorCode(int httpCode, String errorCode, String errorMessage) {
- this.httpCode = Response.Status.fromStatusCode(httpCode);
- this.errorCode = errorCode;
+ this.httpCode = Response.Status.fromStatusCode(httpCode);
+ this.errorCode = errorCode;
this.errorMessage = errorMessage;
-
}
public String getFormattedErrorMessage(String... params) {
if (LOG.isDebugEnabled()) {
- LOG.debug(String.format("<== AtlasErrorCode.getMessage(%s)", Arrays.toString(params)));
+ LOG.debug("<== AtlasErrorCode.getMessage({})", Arrays.toString(params));
}
- MessageFormat mf = new MessageFormat(errorMessage);
- String result = mf.format(params);
+ MessageFormat mf = new MessageFormat(errorMessage);
+ String result = mf.format(params);
if (LOG.isDebugEnabled()) {
- LOG.debug(String.format("==> AtlasErrorCode.getMessage(%s): %s", Arrays.toString(params), result));
+ LOG.debug("==> AtlasErrorCode.getMessage({}): {}", Arrays.toString(params), result);
}
+
return result;
}
diff --git a/intg/src/main/java/org/apache/atlas/AtlasException.java b/intg/src/main/java/org/apache/atlas/AtlasException.java
index 45d91d4fb..40a0ef190 100644
--- a/intg/src/main/java/org/apache/atlas/AtlasException.java
+++ b/intg/src/main/java/org/apache/atlas/AtlasException.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -21,7 +21,6 @@ package org.apache.atlas;
* Base Exception class for Atlas API.
*/
public class AtlasException extends Exception {
-
public AtlasException() {
}
diff --git a/intg/src/main/java/org/apache/atlas/DeleteType.java b/intg/src/main/java/org/apache/atlas/DeleteType.java
index 57294bf7a..fbc0006c1 100644
--- a/intg/src/main/java/org/apache/atlas/DeleteType.java
+++ b/intg/src/main/java/org/apache/atlas/DeleteType.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -26,7 +26,7 @@ public enum DeleteType {
HARD;
public static DeleteType from(String s) {
- if(StringUtils.isEmpty(s)) {
+ if (StringUtils.isEmpty(s)) {
return DEFAULT;
}
diff --git a/intg/src/main/java/org/apache/atlas/SortOrder.java b/intg/src/main/java/org/apache/atlas/SortOrder.java
index e3eef4e9f..4baecc57b 100644
--- a/intg/src/main/java/org/apache/atlas/SortOrder.java
+++ b/intg/src/main/java/org/apache/atlas/SortOrder.java
@@ -6,9 +6,9 @@
* 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.
@@ -19,4 +19,4 @@ package org.apache.atlas;
public enum SortOrder {
ASCENDING, DESCENDING
-}
\ No newline at end of file
+}
diff --git a/intg/src/main/java/org/apache/atlas/bulkimport/BulkImportResponse.java b/intg/src/main/java/org/apache/atlas/bulkimport/BulkImportResponse.java
index 5b95047e3..2a66ff628 100644
--- a/intg/src/main/java/org/apache/atlas/bulkimport/BulkImportResponse.java
+++ b/intg/src/main/java/org/apache/atlas/bulkimport/BulkImportResponse.java
@@ -27,7 +27,7 @@ import static org.apache.atlas.bulkimport.BulkImportResponse.ImportStatus.SUCCES
@AtlasJSON
public class BulkImportResponse implements Serializable {
- private List<ImportInfo> failedImportInfoList = new ArrayList<>();
+ private List<ImportInfo> failedImportInfoList = new ArrayList<>();
private List<ImportInfo> successImportInfoList = new ArrayList<>();
public BulkImportResponse() {}
@@ -64,10 +64,6 @@ public class BulkImportResponse implements Serializable {
successImportInfoList.add(importInfo);
}
- public enum ImportStatus {
- SUCCESS, FAILED
- }
-
@Override
public String toString() {
return "BulkImportResponse{" +
@@ -76,22 +72,25 @@ public class BulkImportResponse implements Serializable {
'}';
}
+ public enum ImportStatus {
+ SUCCESS, FAILED
+ }
public static class ImportInfo {
- private String parentObjectName;
- private String childObjectName;
+ private String parentObjectName;
+ private String childObjectName;
private ImportStatus importStatus;
- private String remarks;
- private Integer rowNumber;
+ private String remarks;
+ private Integer rowNumber;
- public ImportInfo(){ }
+ public ImportInfo() {}
public ImportInfo(String parentObjectName, String childObjectName, ImportStatus importStatus, String remarks, Integer rowNumber) {
this.parentObjectName = parentObjectName;
- this.childObjectName = childObjectName;
- this.importStatus = importStatus;
- this.remarks = remarks;
- this.rowNumber = rowNumber;
+ this.childObjectName = childObjectName;
+ this.importStatus = importStatus;
+ this.remarks = remarks;
+ this.rowNumber = rowNumber;
}
public ImportInfo(String parentObjectName, String childObjectName, ImportStatus importStatus) {
@@ -157,4 +156,4 @@ public class BulkImportResponse implements Serializable {
'}';
}
}
-}
\ No newline at end of file
+}
diff --git a/intg/src/main/java/org/apache/atlas/exception/AtlasBaseException.java b/intg/src/main/java/org/apache/atlas/exception/AtlasBaseException.java
index 88a26f4b4..e0f12af99 100644
--- a/intg/src/main/java/org/apache/atlas/exception/AtlasBaseException.java
+++ b/intg/src/main/java/org/apache/atlas/exception/AtlasBaseException.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -25,16 +25,17 @@ import java.util.List;
* Base Exception class for Atlas API.
*/
public class AtlasBaseException extends Exception {
+ private final AtlasErrorCode atlasErrorCode;
- private AtlasErrorCode atlasErrorCode;
-
- public AtlasBaseException(AtlasErrorCode errorCode, String ... params) {
+ public AtlasBaseException(AtlasErrorCode errorCode, String... params) {
super(errorCode.getFormattedErrorMessage(params));
+
this.atlasErrorCode = errorCode;
}
public AtlasBaseException(final AtlasErrorCode errorCode, final List<String> params) {
super(errorCode.getFormattedErrorMessage(params.toArray(new String[params.size()])));
+
this.atlasErrorCode = errorCode;
}
@@ -44,38 +45,43 @@ public class AtlasBaseException extends Exception {
public AtlasBaseException(String message) {
super(message);
+
this.atlasErrorCode = AtlasErrorCode.INTERNAL_ERROR;
}
public AtlasBaseException(AtlasErrorCode errorCode, Throwable cause, String... params) {
super(errorCode.getFormattedErrorMessage(params), cause);
+
this.atlasErrorCode = errorCode;
}
public AtlasBaseException(String message, Throwable cause) {
super(message, cause);
+
this.atlasErrorCode = AtlasErrorCode.INTERNAL_ERROR;
}
public AtlasBaseException(Throwable cause) {
super(cause);
+
this.atlasErrorCode = AtlasErrorCode.INTERNAL_ERROR;
}
- public AtlasBaseException(AtlasErrorCode errorCode, Throwable cause, boolean enableSuppression,
- boolean writableStackTrace, String ... params) {
+ public AtlasBaseException(AtlasErrorCode errorCode, Throwable cause, boolean enableSuppression, boolean writableStackTrace, String... params) {
super(errorCode.getFormattedErrorMessage(params), cause, enableSuppression, writableStackTrace);
+
this.atlasErrorCode = AtlasErrorCode.INTERNAL_ERROR;
}
- public AtlasBaseException(String message, Throwable cause, boolean enableSuppression,
- boolean writableStackTrace) {
+ public AtlasBaseException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
+
this.atlasErrorCode = AtlasErrorCode.INTERNAL_ERROR;
}
public AtlasBaseException(final AtlasErrorCode errorCode, Throwable cause, final List<String> params) {
super(errorCode.getFormattedErrorMessage(params.toArray(new String[params.size()])), cause);
+
this.atlasErrorCode = errorCode;
}
diff --git a/intg/src/main/java/org/apache/atlas/model/AtlasBaseModelObject.java b/intg/src/main/java/org/apache/atlas/model/AtlasBaseModelObject.java
index 25c0a5f33..43b98ea52 100644
--- a/intg/src/main/java/org/apache/atlas/model/AtlasBaseModelObject.java
+++ b/intg/src/main/java/org/apache/atlas/model/AtlasBaseModelObject.java
@@ -29,18 +29,18 @@ public abstract class AtlasBaseModelObject implements Serializable {
private static final long serialVersionUID = 1L;
@JsonIgnore
- private static AtomicLong s_nextId = new AtomicLong(System.nanoTime());
+ private static final AtomicLong s_nextId = new AtomicLong(System.nanoTime());
private String guid;
- protected void init() {
- setGuid("-" + Long.toString(s_nextId.incrementAndGet()));
- }
-
protected AtlasBaseModelObject() {
init();
}
+ public AtlasBaseModelObject(final AtlasBaseModelObject other) {
+ this.guid = other.guid;
+ }
+
public String getGuid() {
return this.guid;
}
@@ -49,8 +49,22 @@ public abstract class AtlasBaseModelObject implements Serializable {
this.guid = guid;
}
- public AtlasBaseModelObject(final AtlasBaseModelObject other) {
- this.guid = other.guid;
+ @Override
+ public int hashCode() {
+ return Objects.hash(guid);
+ }
+
+ @Override
+ public boolean equals(final Object o) {
+ if (this == o) {
+ return true;
+ } else if (!(o instanceof AtlasBaseModelObject)) {
+ return false;
+ }
+
+ AtlasBaseModelObject that = (AtlasBaseModelObject) o;
+
+ return Objects.equals(guid, that.guid);
}
@Override
@@ -64,18 +78,8 @@ public abstract class AtlasBaseModelObject implements Serializable {
return sb.toString();
}
- @Override
- public boolean equals(final Object o) {
- if (this == o) return true;
- if (!(o instanceof AtlasBaseModelObject)) return false;
- final AtlasBaseModelObject that = (AtlasBaseModelObject) o;
- return Objects.equals(guid, that.guid);
- }
-
- @Override
- public int hashCode() {
-
- return Objects.hash(guid);
+ protected void init() {
+ setGuid("-" + s_nextId.incrementAndGet());
}
protected abstract StringBuilder toString(StringBuilder sb);
diff --git a/intg/src/main/java/org/apache/atlas/model/Clearable.java b/intg/src/main/java/org/apache/atlas/model/Clearable.java
index 5f9f426b8..dfb913c67 100644
--- a/intg/src/main/java/org/apache/atlas/model/Clearable.java
+++ b/intg/src/main/java/org/apache/atlas/model/Clearable.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
diff --git a/intg/src/main/java/org/apache/atlas/model/PList.java b/intg/src/main/java/org/apache/atlas/model/PList.java
index 55239fb6c..b42f29966 100644
--- a/intg/src/main/java/org/apache/atlas/model/PList.java
+++ b/intg/src/main/java/org/apache/atlas/model/PList.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -17,39 +17,37 @@
*/
package org.apache.atlas.model;
-
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-
-import java.util.List;
-
+import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.atlas.model.SearchFilter.SortType;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
+import java.util.List;
+
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
/**
* Paginated-list, for returning search results.
*/
-@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown=true)
+@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class PList<T> implements java.io.Serializable {
private static final long serialVersionUID = 1L;
- private List<T> list = null;
- private long startIndex = 0;
- private int pageSize = 0;
- private long totalCount = 0;
- private String sortBy = null;
- private SortType sortType = null;
+ private List<T> list;
+ private long startIndex;
+ private int pageSize;
+ private long totalCount;
+ private String sortBy;
+ private SortType sortType;
public PList() {
}
@@ -67,9 +65,13 @@ public class PList<T> implements java.io.Serializable {
setSortBy(sortBy);
}
- public void setList(List<T> list) { this.list = list; }
+ public List<T> getList() {
+ return this.list;
+ }
- public List<T> getList() { return this.list; }
+ public void setList(List<T> list) {
+ this.list = list;
+ }
public long getStartIndex() {
return startIndex;
@@ -111,7 +113,6 @@ public class PList<T> implements java.io.Serializable {
this.sortBy = sortBy;
}
-
public StringBuilder toString(StringBuilder sb) {
if (sb == null) {
sb = new StringBuilder();
diff --git a/intg/src/main/java/org/apache/atlas/model/SearchFilter.java b/intg/src/main/java/org/apache/atlas/model/SearchFilter.java
index 741080032..97967968e 100644
--- a/intg/src/main/java/org/apache/atlas/model/SearchFilter.java
+++ b/intg/src/main/java/org/apache/atlas/model/SearchFilter.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -17,15 +17,16 @@
*/
package org.apache.atlas.model;
-import com.sun.jersey.core.util.MultivaluedMapImpl;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.sun.jersey.core.util.MultivaluedMapImpl;
import javax.ws.rs.core.MultivaluedMap;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
+
import java.util.List;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
@@ -34,9 +35,9 @@ import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_
/**
* Generic filter, to specify search criteria using name/value pairs.
*/
-@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown=true)
+@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class SearchFilter {
@@ -48,17 +49,12 @@ public class SearchFilter {
public static final String PARAM_NOT_SERVICETYPE = "notservicetype";
public static final String PARAM_NOT_NAME = "notname";
- /**
- * to specify whether the result should be sorted? If yes, whether asc or desc.
- */
- public enum SortType { NONE, ASC, DESC }
-
- private MultivaluedMap<String, String> params = null;
- private long startIndex = 0;
- private long maxRows = Long.MAX_VALUE;
- private boolean getCount = true;
- private String sortBy = null;
- private SortType sortType = null;
+ private MultivaluedMap<String, String> params;
+ private long startIndex;
+ private long maxRows = Long.MAX_VALUE;
+ private boolean getCount = true;
+ private String sortBy;
+ private SortType sortType;
public SearchFilter() {
setParams(null);
@@ -154,4 +150,9 @@ public class SearchFilter {
public void setSortType(SortType sortType) {
this.sortType = sortType;
}
+
+ /**
+ * to specify whether the result should be sorted? If yes, whether asc or desc.
+ */
+ public enum SortType { NONE, ASC, DESC }
}
diff --git a/intg/src/main/java/org/apache/atlas/model/TimeBoundary.java b/intg/src/main/java/org/apache/atlas/model/TimeBoundary.java
index 882a33c9d..3feeabca1 100644
--- a/intg/src/main/java/org/apache/atlas/model/TimeBoundary.java
+++ b/intg/src/main/java/org/apache/atlas/model/TimeBoundary.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -19,7 +19,7 @@ package org.apache.atlas.model;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.annotation.JsonInclude;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
@@ -34,9 +34,9 @@ import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_
/**
* Captures time-boundary details
*/
-@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown=true)
+@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class TimeBoundary implements Serializable {
@@ -90,31 +90,31 @@ public class TimeBoundary implements Serializable {
this.timeZone = timeZone;
}
+ @Override
+ public int hashCode() {
+ return Objects.hash(startTime, endTime, timeZone);
+ }
@Override
public boolean equals(Object o) {
- if (this == o) { return true; }
- if (o == null || getClass() != o.getClass()) { return false; }
+ if (this == o) {
+ return true;
+ } else if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
TimeBoundary that = (TimeBoundary) o;
- return Objects.equals(startTime, that.startTime) &&
- Objects.equals(endTime, that.endTime) &&
- Objects.equals(timeZone, that.timeZone);
- }
- @Override
- public int hashCode() {
- return Objects.hash(startTime, endTime, timeZone);
+ return Objects.equals(startTime, that.startTime) &&
+ Objects.equals(endTime, that.endTime) &&
+ Objects.equals(timeZone, that.timeZone);
}
@Override
public String toString() {
- final StringBuilder sb = new StringBuilder("TimeBoundary{");
-
- sb.append("startTime='").append(startTime)
- .append("; endTime='").append(endTime)
- .append("; timeZone='").append(timeZone)
- .append('}');
-
- return sb.toString();
+ return "TimeBoundary{" + "startTime='" + startTime +
+ "; endTime='" + endTime +
+ "; timeZone='" + timeZone +
+ '}';
}
}
diff --git a/intg/src/main/java/org/apache/atlas/model/TypeCategory.java b/intg/src/main/java/org/apache/atlas/model/TypeCategory.java
index 349a79d05..2e1e6c3c2 100644
--- a/intg/src/main/java/org/apache/atlas/model/TypeCategory.java
+++ b/intg/src/main/java/org/apache/atlas/model/TypeCategory.java
@@ -6,9 +6,9 @@
* 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.
diff --git a/intg/src/main/java/org/apache/atlas/model/annotation/AtlasJSON.java b/intg/src/main/java/org/apache/atlas/model/annotation/AtlasJSON.java
index 03d5603f7..1bab3fec7 100644
--- a/intg/src/main/java/org/apache/atlas/model/annotation/AtlasJSON.java
+++ b/intg/src/main/java/org/apache/atlas/model/annotation/AtlasJSON.java
@@ -30,7 +30,7 @@ import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_
@Retention(RetentionPolicy.RUNTIME)
@JacksonAnnotationsInside
-@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
+@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
-@JsonIgnoreProperties(ignoreUnknown=true)
-public @interface AtlasJSON {}
\ No newline at end of file
+@JsonIgnoreProperties(ignoreUnknown = true)
+public @interface AtlasJSON {}
diff --git a/intg/src/main/java/org/apache/atlas/model/audit/AtlasAuditEntry.java b/intg/src/main/java/org/apache/atlas/model/audit/AtlasAuditEntry.java
index 98eacfb5a..a103a1730 100644
--- a/intg/src/main/java/org/apache/atlas/model/audit/AtlasAuditEntry.java
+++ b/intg/src/main/java/org/apache/atlas/model/audit/AtlasAuditEntry.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -20,6 +20,7 @@ package org.apache.atlas.model.audit;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.AtlasBaseModelObject;
@@ -31,62 +32,28 @@ import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+@JsonSerialize
+@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class AtlasAuditEntry extends AtlasBaseModelObject implements Serializable {
private static final long serialVersionUID = 1L;
- public enum AuditOperation {
- PURGE("PURGE"),
- EXPORT("EXPORT"),
- IMPORT("IMPORT"),
- IMPORT_DELETE_REPL("IMPORT_DELETE_REPL"),
- TYPE_DEF_CREATE("TYPE_DEF_CREATE"),
- TYPE_DEF_UPDATE("TYPE_DEF_UPDATE"),
- TYPE_DEF_DELETE("TYPE_DEF_DELETE"),
- SERVER_START("SERVER_START"),
- SERVER_STATE_ACTIVE("SERVER_STATE_ACTIVE");
-
- private final String type;
-
- AuditOperation(String type) {
- this.type = type;
- }
-
- public EntityAuditEventV2.EntityAuditActionV2 toEntityAuditActionV2() throws AtlasBaseException {
- switch (this.type) {
- case "PURGE":
- return EntityAuditEventV2.EntityAuditActionV2.ENTITY_PURGE;
- default:
- try {
- return EntityAuditEventV2.EntityAuditActionV2.fromString(this.type);
- } catch (IllegalArgumentException e) {
- throw new AtlasBaseException("Invalid operation for Entity Audit Event V2: " + this.type);
- }
- }
- }
-
- public String getType() {
- return type;
- }
- }
-
- private String userName;
+ private String userName;
private AuditOperation operation;
- private String params;
- private Date startTime;
- private Date endTime;
- private String clientId;
- private String result;
- private long resultCount;
+ private String params;
+ private Date startTime;
+ private Date endTime;
+ private String clientId;
+ private String result;
+ private long resultCount;
public AtlasAuditEntry() {
}
public AtlasAuditEntry(AuditOperation operation, String userName, String clientId) {
this.operation = operation;
- this.userName = userName;
- this.clientId = clientId;
+ this.userName = userName;
+ this.clientId = clientId;
}
public AuditOperation getOperation() {
@@ -97,38 +64,38 @@ public class AtlasAuditEntry extends AtlasBaseModelObject implements Serializabl
this.operation = operation;
}
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
public String getUserName() {
return this.userName;
}
- public void setParams(String params) {
- this.params = params;
+ public void setUserName(String userName) {
+ this.userName = userName;
}
public String getParams() {
return this.params;
}
- public void setStartTime(Date startTime) {
- this.startTime = startTime;
+ public void setParams(String params) {
+ this.params = params;
}
public Date getStartTime() {
return startTime;
}
- public void setEndTime(Date endTime) {
- this.endTime = endTime;
+ public void setStartTime(Date startTime) {
+ this.startTime = startTime;
}
public Date getEndTime() {
return this.endTime;
}
+ public void setEndTime(Date endTime) {
+ this.endTime = endTime;
+ }
+
public String getClientId() {
return this.clientId;
}
@@ -166,4 +133,39 @@ public class AtlasAuditEntry extends AtlasBaseModelObject implements Serializabl
return sb;
}
+
+ public enum AuditOperation {
+ PURGE("PURGE"),
+ EXPORT("EXPORT"),
+ IMPORT("IMPORT"),
+ IMPORT_DELETE_REPL("IMPORT_DELETE_REPL"),
+ TYPE_DEF_CREATE("TYPE_DEF_CREATE"),
+ TYPE_DEF_UPDATE("TYPE_DEF_UPDATE"),
+ TYPE_DEF_DELETE("TYPE_DEF_DELETE"),
+ SERVER_START("SERVER_START"),
+ SERVER_STATE_ACTIVE("SERVER_STATE_ACTIVE");
+
+ private final String type;
+
+ AuditOperation(String type) {
+ this.type = type;
+ }
+
+ public EntityAuditEventV2.EntityAuditActionV2 toEntityAuditActionV2() throws AtlasBaseException {
+ switch (this.type) {
+ case "PURGE":
+ return EntityAuditEventV2.EntityAuditActionV2.ENTITY_PURGE;
+ default:
+ try {
+ return EntityAuditEventV2.EntityAuditActionV2.fromString(this.type);
+ } catch (IllegalArgumentException e) {
+ throw new AtlasBaseException("Invalid operation for Entity Audit Event V2: " + this.type);
+ }
+ }
+ }
+
+ public String getType() {
+ return type;
+ }
+ }
}
diff --git a/intg/src/main/java/org/apache/atlas/model/audit/AuditReductionCriteria.java b/intg/src/main/java/org/apache/atlas/model/audit/AuditReductionCriteria.java
index c956b3ac8..116cb6532 100644
--- a/intg/src/main/java/org/apache/atlas/model/audit/AuditReductionCriteria.java
+++ b/intg/src/main/java/org/apache/atlas/model/audit/AuditReductionCriteria.java
@@ -17,29 +17,28 @@
*/
package org.apache.atlas.model.audit;
-
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.annotation.JsonInclude;
import java.io.Serializable;
-import java.util.*;
+import java.util.Objects;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class AuditReductionCriteria implements Serializable {
private static final long serialVersionUID = 1L;
- private boolean auditAgingEnabled = false;
- private boolean defaultAgeoutEnabled = false;
- private boolean auditSweepoutEnabled = false;
- private boolean createEventsAgeoutAllowed = false;
- private boolean subTypesIncluded = true;
- private boolean ignoreDefaultAgeoutTTL = false;
+ private boolean auditAgingEnabled;
+ private boolean defaultAgeoutEnabled;
+ private boolean auditSweepoutEnabled;
+ private boolean createEventsAgeoutAllowed;
+ private boolean subTypesIncluded;
+ private boolean ignoreDefaultAgeoutTTL;
private int defaultAgeoutAuditCount;
private int defaultAgeoutTTLInDays;
@@ -164,12 +163,22 @@ public class AuditReductionCriteria implements Serializable {
this.sweepoutActionTypes = sweepoutActionTypes;
}
+ @Override
+ public int hashCode() {
+ return Objects.hash(auditAgingEnabled, defaultAgeoutEnabled, auditSweepoutEnabled, createEventsAgeoutAllowed, subTypesIncluded, ignoreDefaultAgeoutTTL, defaultAgeoutAuditCount, defaultAgeoutTTLInDays, customAgeoutAuditCount, customAgeoutTTLInDays,
+ customAgeoutEntityTypes, customAgeoutActionTypes, sweepoutEntityTypes, sweepoutActionTypes);
+ }
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ if (this == o) {
+ return true;
+ } else if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
AuditReductionCriteria that = (AuditReductionCriteria) o;
+
return auditAgingEnabled == that.auditAgingEnabled &&
defaultAgeoutEnabled == that.defaultAgeoutEnabled &&
auditSweepoutEnabled == that.auditSweepoutEnabled &&
@@ -187,9 +196,8 @@ public class AuditReductionCriteria implements Serializable {
}
@Override
- public int hashCode() {
- return Objects.hash(auditAgingEnabled, defaultAgeoutEnabled, auditSweepoutEnabled, createEventsAgeoutAllowed, subTypesIncluded, ignoreDefaultAgeoutTTL, defaultAgeoutAuditCount, defaultAgeoutTTLInDays, customAgeoutAuditCount, customAgeoutTTLInDays,
- customAgeoutEntityTypes, customAgeoutActionTypes, sweepoutEntityTypes, sweepoutActionTypes);
+ public String toString() {
+ return toString(new StringBuilder()).toString();
}
public StringBuilder toString(StringBuilder sb) {
@@ -216,11 +224,4 @@ public class AuditReductionCriteria implements Serializable {
return sb;
}
-
- @Override
- public String toString() {
- return toString(new StringBuilder()).toString();
- }
-
-
}
diff --git a/intg/src/main/java/org/apache/atlas/model/audit/AuditSearchParameters.java b/intg/src/main/java/org/apache/atlas/model/audit/AuditSearchParameters.java
index 912006270..e35afbac0 100644
--- a/intg/src/main/java/org/apache/atlas/model/audit/AuditSearchParameters.java
+++ b/intg/src/main/java/org/apache/atlas/model/audit/AuditSearchParameters.java
@@ -20,7 +20,7 @@ package org.apache.atlas.model.audit;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.atlas.SortOrder;
import org.apache.atlas.model.discovery.SearchParameters.FilterCriteria;
@@ -31,25 +31,27 @@ import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class AuditSearchParameters implements Serializable {
private static final long serialVersionUID = 1L;
- public static long getSerialVersionUID() {
- return serialVersionUID;
- }
-
- AuditSearchParameters() {}
-
private FilterCriteria auditFilters;
private int limit;
private int offset;
private String sortBy;
private SortOrder sortOrder;
+ AuditSearchParameters() {
+ }
+
+ public static long getSerialVersionUID() {
+ return serialVersionUID;
+ }
+
/**
* Entity attribute filters for the type (if type name is specified)
+ *
* @return
*/
public FilterCriteria getAuditFilters() {
@@ -58,6 +60,7 @@ public class AuditSearchParameters implements Serializable {
/**
* Filter the entities on this criteria
+ *
* @param auditFilters
*/
public void setAuditFilters(FilterCriteria auditFilters) {
@@ -73,6 +76,7 @@ public class AuditSearchParameters implements Serializable {
/**
* Restrict the results to the specified limit
+ *
* @param limit max number of results
*/
public void setLimit(int limit) {
@@ -96,13 +100,18 @@ public class AuditSearchParameters implements Serializable {
/**
* @return Attribute on which to sort the results
*/
- public String getSortBy() { return sortBy; }
+ public String getSortBy() {
+ return sortBy;
+ }
/**
* Sort the results based on sortBy attribute
+ *
* @param sortBy Attribute on which to sort the results
*/
- public void setSortBy(String sortBy) { this.sortBy = sortBy; }
+ public void setSortBy(String sortBy) {
+ this.sortBy = sortBy;
+ }
/**
* @return Sorting order of the results
@@ -113,15 +122,28 @@ public class AuditSearchParameters implements Serializable {
/**
* Sorting order to sort the results
+ *
* @param sortOrder ASCENDING vs DESCENDING
*/
- public void setSortOrder(SortOrder sortOrder) { this.sortOrder = sortOrder; }
+ public void setSortOrder(SortOrder sortOrder) {
+ this.sortOrder = sortOrder;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(auditFilters, limit, offset, sortBy, sortOrder);
+ }
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ if (this == o) {
+ return true;
+ } else if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
AuditSearchParameters that = (AuditSearchParameters) o;
+
return Objects.equals(auditFilters, that.auditFilters) &&
limit == that.limit &&
offset == that.offset &&
@@ -129,20 +151,13 @@ public class AuditSearchParameters implements Serializable {
Objects.equals(sortOrder, that.sortOrder);
}
- @Override
- public int hashCode() {
- return Objects.hash(auditFilters, limit, offset, sortBy, sortOrder);
- }
-
@Override
public String toString() {
- final StringBuilder sb = new StringBuilder("AuditSearchParameters{");
- sb.append("auditFilters=").append(auditFilters);
- sb.append(", limit=").append(limit);
- sb.append(", offset=").append(offset);
- sb.append(", sortBy='").append(sortBy).append('\'');
- sb.append(", sortOrder=").append(sortOrder);
- sb.append('}');
- return sb.toString();
+ return "AuditSearchParameters{" + "auditFilters=" + auditFilters +
+ ", limit=" + limit +
+ ", offset=" + offset +
+ ", sortBy='" + sortBy + '\'' +
+ ", sortOrder=" + sortOrder +
+ '}';
}
}
diff --git a/intg/src/main/java/org/apache/atlas/model/audit/EntityAuditEventV2.java b/intg/src/main/java/org/apache/atlas/model/audit/EntityAuditEventV2.java
index 3afd27e7d..76cf2e9df 100644
--- a/intg/src/main/java/org/apache/atlas/model/audit/EntityAuditEventV2.java
+++ b/intg/src/main/java/org/apache/atlas/model/audit/EntityAuditEventV2.java
@@ -20,7 +20,7 @@ package org.apache.atlas.model.audit;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.atlas.model.Clearable;
import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.instance.AtlasEntityHeader;
@@ -30,6 +30,7 @@ import org.apache.commons.lang.StringUtils;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
+
import java.io.Serializable;
import java.util.Comparator;
import java.util.List;
@@ -42,9 +43,9 @@ import static org.apache.atlas.model.audit.EntityAuditEventV2.EntityAuditType.EN
/**
* Structure of v2 entity audit event
*/
-@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
-@JsonSerialize(include=JsonSerialize.Inclusion.ALWAYS)
-@JsonIgnoreProperties(ignoreUnknown=true)
+@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
+@JsonInclude(JsonInclude.Include.ALWAYS)
+@JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class EntityAuditEventV2 implements Serializable, Clearable {
@@ -52,65 +53,6 @@ public class EntityAuditEventV2 implements Serializable, Clearable {
public static final String SORT_COLUMN_ACTION = "action";
public static final String SORT_COLUMN_TIMESTAMP = "timestamp";
- public enum EntityAuditType { ENTITY_AUDIT_V1, ENTITY_AUDIT_V2 }
-
- public enum EntityAuditActionV2 {
- ENTITY_CREATE, ENTITY_UPDATE, ENTITY_DELETE,
- ENTITY_IMPORT_CREATE, ENTITY_IMPORT_UPDATE, ENTITY_IMPORT_DELETE,
- CLASSIFICATION_ADD, CLASSIFICATION_DELETE, CLASSIFICATION_UPDATE,
- PROPAGATED_CLASSIFICATION_ADD, PROPAGATED_CLASSIFICATION_DELETE, PROPAGATED_CLASSIFICATION_UPDATE,
- TERM_ADD, TERM_DELETE, LABEL_ADD, LABEL_DELETE, ENTITY_PURGE,
- BUSINESS_ATTRIBUTE_UPDATE, CUSTOM_ATTRIBUTE_UPDATE;
-
- public static EntityAuditActionV2 fromString(String strValue) {
- switch (strValue) {
- case "ENTITY_CREATE":
- return ENTITY_CREATE;
- case "ENTITY_UPDATE":
- return ENTITY_UPDATE;
- case "ENTITY_DELETE":
- return ENTITY_DELETE;
- case "ENTITY_PURGE":
- return ENTITY_PURGE;
- case "ENTITY_IMPORT_CREATE":
- return ENTITY_IMPORT_CREATE;
- case "ENTITY_IMPORT_UPDATE":
- return ENTITY_IMPORT_UPDATE;
- case "ENTITY_IMPORT_DELETE":
- return ENTITY_IMPORT_DELETE;
- case "CLASSIFICATION_ADD":
- case "TAG_ADD":
- return CLASSIFICATION_ADD;
- case "CLASSIFICATION_DELETE":
- case "TAG_DELETE":
- return CLASSIFICATION_DELETE;
- case "CLASSIFICATION_UPDATE":
- case "TAG_UPDATE":
- return CLASSIFICATION_UPDATE;
- case "PROPAGATED_CLASSIFICATION_ADD":
- return PROPAGATED_CLASSIFICATION_ADD;
- case "PROPAGATED_CLASSIFICATION_DELETE":
- return PROPAGATED_CLASSIFICATION_DELETE;
- case "PROPAGATED_CLASSIFICATION_UPDATE":
- return PROPAGATED_CLASSIFICATION_UPDATE;
- case "TERM_ADD":
- return TERM_ADD;
- case "TERM_DELETE":
- return TERM_DELETE;
- case "LABEL_ADD":
- return LABEL_ADD;
- case "LABEL_DELETE":
- return LABEL_DELETE;
- case "BUSINESS_ATTRIBUTE_UPDATE":
- return BUSINESS_ATTRIBUTE_UPDATE;
- case "CUSTOM_ATTRIBUTE_UPDATE":
- return CUSTOM_ATTRIBUTE_UPDATE;
- }
-
- throw new IllegalArgumentException("No enum constant " + EntityAuditActionV2.class.getCanonicalName() + "." + strValue);
- }
- }
-
private String entityId;
private long timestamp;
private String user;
@@ -120,15 +62,14 @@ public class EntityAuditEventV2 implements Serializable, Clearable {
private AtlasEntity entity;
private EntityAuditType type;
- public EntityAuditEventV2() { }
+ public EntityAuditEventV2() {
+ }
- public EntityAuditEventV2(String entityId, long timestamp, String user, EntityAuditActionV2 action, String details,
- AtlasEntity entity) {
+ public EntityAuditEventV2(String entityId, long timestamp, String user, EntityAuditActionV2 action, String details, AtlasEntity entity) {
this(entityId, timestamp, user, action, details, entity, ENTITY_AUDIT_V2);
}
- public EntityAuditEventV2(String entityId, long timestamp, String user, EntityAuditActionV2 action, String details,
- AtlasEntity entity, EntityAuditType auditType) {
+ public EntityAuditEventV2(String entityId, long timestamp, String user, EntityAuditActionV2 action, String details, AtlasEntity entity, EntityAuditType auditType) {
setEntityId(entityId);
setTimestamp(timestamp);
setUser(user);
@@ -138,6 +79,27 @@ public class EntityAuditEventV2 implements Serializable, Clearable {
setType(auditType);
}
+ public static void sortEvents(List<EntityAuditEventV2> events, String sortByColumn, boolean sortOrderDesc) {
+ final Comparator<EntityAuditEventV2> comparator;
+
+ switch (sortByColumn.toLowerCase()) {
+ case SORT_COLUMN_USER:
+ comparator = new EntityAuditEventV2.UserComparator();
+ break;
+
+ case SORT_COLUMN_ACTION:
+ comparator = new EntityAuditEventV2.ActionComparator();
+ break;
+
+ case SORT_COLUMN_TIMESTAMP:
+ default:
+ comparator = new EntityAuditEventV2.TimestampComparator();
+ break;
+ }
+
+ events.sort(sortOrderDesc ? comparator.reversed() : comparator);
+ }
+
public String getEntityId() {
return entityId;
}
@@ -216,72 +178,76 @@ public class EntityAuditEventV2 implements Serializable, Clearable {
this.entity = AtlasType.fromJson(entityDefinition, AtlasEntity.class);
}
+ @Override
+ public int hashCode() {
+ return Objects.hash(entityId, timestamp, user, action, details, eventKey, entity, type);
+ }
+
@Override
public boolean equals(Object o) {
- if (this == o) { return true; }
- if (o == null || getClass() != o.getClass()) { return false; }
+ if (this == o) {
+ return true;
+ } else if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
EntityAuditEventV2 that = (EntityAuditEventV2) o;
return timestamp == that.timestamp &&
- Objects.equals(entityId, that.entityId) &&
- Objects.equals(user, that.user) &&
- action == that.action &&
- Objects.equals(details, that.details) &&
- Objects.equals(eventKey, that.eventKey) &&
- Objects.equals(entity, that.entity) &&
- Objects.equals(type, that.type);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(entityId, timestamp, user, action, details, eventKey, entity, type);
+ Objects.equals(entityId, that.entityId) &&
+ Objects.equals(user, that.user) &&
+ action == that.action &&
+ Objects.equals(details, that.details) &&
+ Objects.equals(eventKey, that.eventKey) &&
+ Objects.equals(entity, that.entity) &&
+ Objects.equals(type, that.type);
}
@Override
public String toString() {
- final StringBuilder sb = new StringBuilder("EntityAuditEventV2{");
-
- sb.append("entityId='").append(entityId).append('\'');
- sb.append(", timestamp=").append(timestamp);
- sb.append(", user='").append(user).append('\'');
- sb.append(", action=").append(action);
- sb.append(", details='").append(details).append('\'');
- sb.append(", eventKey='").append(eventKey).append('\'');
- sb.append(", entity=").append(entity);
- sb.append(", type=").append(type);
- sb.append('}');
-
- return sb.toString();
+ return "EntityAuditEventV2{" + "entityId='" + entityId + '\'' +
+ ", timestamp=" + timestamp +
+ ", user='" + user + '\'' +
+ ", action=" + action +
+ ", details='" + details + '\'' +
+ ", eventKey='" + eventKey + '\'' +
+ ", entity=" + entity +
+ ", type=" + type +
+ '}';
}
@JsonIgnore
public AtlasEntityHeader getEntityHeader() {
- AtlasEntityHeader ret = null;
- String jsonPartFromDetails = getJsonPartFromDetails();
- if(StringUtils.isNotEmpty(jsonPartFromDetails)) {
+ AtlasEntityHeader ret = null;
+ String jsonPartFromDetails = getJsonPartFromDetails();
+
+ if (StringUtils.isNotEmpty(jsonPartFromDetails)) {
ret = AtlasType.fromJson(jsonPartFromDetails, AtlasEntityHeader.class);
}
+
return ret;
}
@JsonIgnore
@Override
public void clear() {
- entityId = null;
+ entityId = null;
timestamp = 0L;
- user = null;
- action = null;
- details = null;
- eventKey = null;
- entity = null;
- type = null;
+ user = null;
+ action = null;
+ details = null;
+ eventKey = null;
+ entity = null;
+ type = null;
}
private String getJsonPartFromDetails() {
String ret = null;
- if(StringUtils.isNotEmpty(details)) {
+
+ if (StringUtils.isNotEmpty(details)) {
int bracketStartPosition = details.indexOf("{");
- if(bracketStartPosition != -1) {
+
+ if (bracketStartPosition != -1) {
ret = details.substring(bracketStartPosition);
}
}
@@ -289,6 +255,65 @@ public class EntityAuditEventV2 implements Serializable, Clearable {
return ret;
}
+ public enum EntityAuditType { ENTITY_AUDIT_V1, ENTITY_AUDIT_V2 }
+
+ public enum EntityAuditActionV2 {
+ ENTITY_CREATE, ENTITY_UPDATE, ENTITY_DELETE,
+ ENTITY_IMPORT_CREATE, ENTITY_IMPORT_UPDATE, ENTITY_IMPORT_DELETE,
+ CLASSIFICATION_ADD, CLASSIFICATION_DELETE, CLASSIFICATION_UPDATE,
+ PROPAGATED_CLASSIFICATION_ADD, PROPAGATED_CLASSIFICATION_DELETE, PROPAGATED_CLASSIFICATION_UPDATE,
+ TERM_ADD, TERM_DELETE, LABEL_ADD, LABEL_DELETE, ENTITY_PURGE,
+ BUSINESS_ATTRIBUTE_UPDATE, CUSTOM_ATTRIBUTE_UPDATE;
+
+ public static EntityAuditActionV2 fromString(String strValue) {
+ switch (strValue) {
+ case "ENTITY_CREATE":
+ return ENTITY_CREATE;
+ case "ENTITY_UPDATE":
+ return ENTITY_UPDATE;
+ case "ENTITY_DELETE":
+ return ENTITY_DELETE;
+ case "ENTITY_PURGE":
+ return ENTITY_PURGE;
+ case "ENTITY_IMPORT_CREATE":
+ return ENTITY_IMPORT_CREATE;
+ case "ENTITY_IMPORT_UPDATE":
+ return ENTITY_IMPORT_UPDATE;
+ case "ENTITY_IMPORT_DELETE":
+ return ENTITY_IMPORT_DELETE;
+ case "CLASSIFICATION_ADD":
+ case "TAG_ADD":
+ return CLASSIFICATION_ADD;
+ case "CLASSIFICATION_DELETE":
+ case "TAG_DELETE":
+ return CLASSIFICATION_DELETE;
+ case "CLASSIFICATION_UPDATE":
+ case "TAG_UPDATE":
+ return CLASSIFICATION_UPDATE;
+ case "PROPAGATED_CLASSIFICATION_ADD":
+ return PROPAGATED_CLASSIFICATION_ADD;
+ case "PROPAGATED_CLASSIFICATION_DELETE":
+ return PROPAGATED_CLASSIFICATION_DELETE;
+ case "PROPAGATED_CLASSIFICATION_UPDATE":
+ return PROPAGATED_CLASSIFICATION_UPDATE;
+ case "TERM_ADD":
+ return TERM_ADD;
+ case "TERM_DELETE":
+ return TERM_DELETE;
+ case "LABEL_ADD":
+ return LABEL_ADD;
+ case "LABEL_DELETE":
+ return LABEL_DELETE;
+ case "BUSINESS_ATTRIBUTE_UPDATE":
+ return BUSINESS_ATTRIBUTE_UPDATE;
+ case "CUSTOM_ATTRIBUTE_UPDATE":
+ return CUSTOM_ATTRIBUTE_UPDATE;
+ }
+
+ throw new IllegalArgumentException("No enum constant " + EntityAuditActionV2.class.getCanonicalName() + "." + strValue);
+ }
+ }
+
public static class UserComparator implements Comparator<EntityAuditEventV2> {
@Override
public int compare(EntityAuditEventV2 me, EntityAuditEventV2 other) {
@@ -321,25 +346,4 @@ public class EntityAuditEventV2 implements Serializable, Clearable {
return Long.compare(me.getTimestamp(), other.getTimestamp());
}
}
-
- public static void sortEvents(List<EntityAuditEventV2> events, String sortByColumn, boolean sortOrderDesc) {
- final Comparator<EntityAuditEventV2> comparator;
-
- switch (sortByColumn.toLowerCase()) {
- case SORT_COLUMN_USER:
- comparator = new EntityAuditEventV2.UserComparator();
- break;
-
- case SORT_COLUMN_ACTION:
- comparator = new EntityAuditEventV2.ActionComparator();
- break;
-
- case SORT_COLUMN_TIMESTAMP:
- default:
- comparator = new EntityAuditEventV2.TimestampComparator();
- break;
- }
-
- events.sort(sortOrderDesc ? comparator.reversed() : comparator);
- }
-}
\ No newline at end of file
+}
diff --git a/intg/src/main/java/org/apache/atlas/model/discovery/AtlasAggregationEntry.java b/intg/src/main/java/org/apache/atlas/model/discovery/AtlasAggregationEntry.java
index 7ac633cb6..31510f63b 100644
--- a/intg/src/main/java/org/apache/atlas/model/discovery/AtlasAggregationEntry.java
+++ b/intg/src/main/java/org/apache/atlas/model/discovery/AtlasAggregationEntry.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -17,10 +17,9 @@
*/
package org.apache.atlas.model.discovery;
-
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.annotation.JsonInclude;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
@@ -33,13 +32,13 @@ import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_
* An instance of an entity - like hive_table, hive_database.
*/
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class AtlasAggregationEntry {
private String name;
- private long count;
+ private long count;
public AtlasAggregationEntry() {
}
@@ -61,19 +60,21 @@ public class AtlasAggregationEntry {
this.count = count;
}
+ @Override
+ public int hashCode() {
+ return name.hashCode();
+ }
+
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ if (this == o) {
+ return true;
+ } else if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
AtlasAggregationEntry that = (AtlasAggregationEntry) o;
return name.equals(that.name);
-
- }
-
- @Override
- public int hashCode() {
- return name.hashCode();
}
-}
\ No newline at end of file
+}
diff --git a/intg/src/main/java/org/apache/atlas/model/discovery/AtlasQuickSearchResult.java b/intg/src/main/java/org/apache/atlas/model/discovery/AtlasQuickSearchResult.java
index dfd29773b..478c10dec 100644
--- a/intg/src/main/java/org/apache/atlas/model/discovery/AtlasQuickSearchResult.java
+++ b/intg/src/main/java/org/apache/atlas/model/discovery/AtlasQuickSearchResult.java
@@ -17,22 +17,22 @@
*/
package org.apache.atlas.model.discovery;
-
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.annotation.JsonInclude;
-import java.util.*;
+import java.util.List;
+import java.util.Map;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class AtlasQuickSearchResult {
- private AtlasSearchResult searchResults;
- private Map<String, List<AtlasAggregationEntry>> aggregationMetrics;
+ private AtlasSearchResult searchResults;
+ private Map<String, List<AtlasAggregationEntry>> aggregationMetrics;
public AtlasQuickSearchResult() {
}
diff --git a/intg/src/main/java/org/apache/atlas/model/discovery/AtlasSearchResult.java b/intg/src/main/java/org/apache/atlas/model/discovery/AtlasSearchResult.java
index c6027b101..8adc96a6d 100644
--- a/intg/src/main/java/org/apache/atlas/model/discovery/AtlasSearchResult.java
+++ b/intg/src/main/java/org/apache/atlas/model/discovery/AtlasSearchResult.java
@@ -17,11 +17,9 @@
*/
package org.apache.atlas.model.discovery;
-
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-
+import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.atlas.model.instance.AtlasEntityHeader;
import org.apache.atlas.model.instance.AtlasRelationshipHeader;
import org.apache.commons.collections.CollectionUtils;
@@ -30,9 +28,9 @@ import org.apache.commons.lang.StringUtils;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
+
import java.io.Serializable;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -41,7 +39,7 @@ import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class AtlasSearchResult implements Serializable {
private AtlasQueryType queryType;
@@ -57,7 +55,8 @@ public class AtlasSearchResult implements Serializable {
private long approximateCount = -1;
private String nextMarker;
- public AtlasSearchResult() {}
+ public AtlasSearchResult() {
+ }
public AtlasSearchResult(AtlasQueryType queryType) {
this(null, queryType);
@@ -88,9 +87,13 @@ public class AtlasSearchResult implements Serializable {
}
}
- public AtlasQueryType getQueryType() { return queryType; }
+ public AtlasQueryType getQueryType() {
+ return queryType;
+ }
- public void setQueryType(AtlasQueryType queryType) { this.queryType = queryType; }
+ public void setQueryType(AtlasQueryType queryType) {
+ this.queryType = queryType;
+ }
public SearchParameters getSearchParameters() {
return searchParameters;
@@ -100,21 +103,37 @@ public class AtlasSearchResult implements Serializable {
this.searchParameters = searchParameters;
}
- public String getQueryText() { return queryText; }
+ public String getQueryText() {
+ return queryText;
+ }
- public void setQueryText(String queryText) { this.queryText = queryText; }
+ public void setQueryText(String queryText) {
+ this.queryText = queryText;
+ }
- public String getType() { return type; }
+ public String getType() {
+ return type;
+ }
- public void setType(String type) { this.type = type; }
+ public void setType(String type) {
+ this.type = type;
+ }
- public String getClassification() { return classification; }
+ public String getClassification() {
+ return classification;
+ }
- public void setClassification(String classification) { this.classification = classification; }
+ public void setClassification(String classification) {
+ this.classification = classification;
+ }
- public List<AtlasEntityHeader> getEntities() { return entities; }
+ public List<AtlasEntityHeader> getEntities() {
+ return entities;
+ }
- public void setEntities(List<AtlasEntityHeader> entities) { this.entities = entities; }
+ public void setEntities(List<AtlasEntityHeader> entities) {
+ this.entities = entities;
+ }
public List<AtlasRelationshipHeader> getRelations() {
return relations;
@@ -124,13 +143,21 @@ public class AtlasSearchResult implements Serializable {
this.relations = relations;
}
- public AttributeSearchResult getAttributes() { return attributes; }
+ public AttributeSearchResult getAttributes() {
+ return attributes;
+ }
- public void setAttributes(AttributeSearchResult attributes) { this.attributes = attributes; }
+ public void setAttributes(AttributeSearchResult attributes) {
+ this.attributes = attributes;
+ }
- public List<AtlasFullTextResult> getFullTextResult() { return fullTextResult; }
+ public List<AtlasFullTextResult> getFullTextResult() {
+ return fullTextResult;
+ }
- public void setFullTextResult(List<AtlasFullTextResult> fullTextResult) { this.fullTextResult = fullTextResult; }
+ public void setFullTextResult(List<AtlasFullTextResult> fullTextResult) {
+ this.fullTextResult = fullTextResult;
+ }
public Map<String, AtlasEntityHeader> getReferredEntities() {
return referredEntities;
@@ -140,33 +167,66 @@ public class AtlasSearchResult implements Serializable {
this.referredEntities = referredEntities;
}
- public long getApproximateCount() { return approximateCount; }
+ public long getApproximateCount() {
+ return approximateCount;
+ }
- public void setApproximateCount(long approximateCount) { this.approximateCount = approximateCount; }
+ public void setApproximateCount(long approximateCount) {
+ this.approximateCount = approximateCount;
+ }
- public String getNextMarker() { return nextMarker; }
+ public String getNextMarker() {
+ return nextMarker;
+ }
- public void setNextMarker(String nextMarker) { this.nextMarker = nextMarker; }
+ public void setNextMarker(String nextMarker) {
+ this.nextMarker = nextMarker;
+ }
@Override
- public int hashCode() { return Objects.hash(queryType, searchParameters, queryText, type, classification, entities, relations, attributes, fullTextResult, referredEntities, nextMarker); }
+ public int hashCode() {
+ return Objects.hash(queryType, searchParameters, queryText, type, classification, entities, relations, attributes, fullTextResult, referredEntities, nextMarker);
+ }
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ if (this == o) {
+ return true;
+ } else if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
AtlasSearchResult that = (AtlasSearchResult) o;
+
return Objects.equals(queryType, that.queryType) &&
- Objects.equals(searchParameters, that.searchParameters) &&
- Objects.equals(queryText, that.queryText) &&
- Objects.equals(type, that.type) &&
- Objects.equals(classification, that.classification) &&
- Objects.equals(entities, that.entities) &&
- Objects.equals(relations, that.relations) &&
- Objects.equals(attributes, that.attributes) &&
- Objects.equals(fullTextResult, that.fullTextResult) &&
- Objects.equals(referredEntities, that.referredEntities) &&
- Objects.equals(nextMarker, that.nextMarker);
+ Objects.equals(searchParameters, that.searchParameters) &&
+ Objects.equals(queryText, that.queryText) &&
+ Objects.equals(type, that.type) &&
+ Objects.equals(classification, that.classification) &&
+ Objects.equals(entities, that.entities) &&
+ Objects.equals(relations, that.relations) &&
+ Objects.equals(attributes, that.attributes) &&
+ Objects.equals(fullTextResult, that.fullTextResult) &&
+ Objects.equals(referredEntities, that.referredEntities) &&
+ Objects.equals(nextMarker, that.nextMarker);
+ }
+
+ @Override
+ public String toString() {
+ return "AtlasSearchResult{" +
+ "queryType=" + queryType +
+ ", searchParameters='" + searchParameters + '\'' +
+ ", queryText='" + queryText + '\'' +
+ ", type=" + type +
+ ", classification=" + classification +
+ ", entities=" + entities +
+ ", relations=" + relations +
+ ", attributes=" + attributes +
+ ", fullTextResult=" + fullTextResult +
+ ", referredEntities=" + referredEntities +
+ ", approximateCount=" + approximateCount +
+ ", nextMarker=" + nextMarker +
+ '}';
}
public void addEntity(AtlasEntityHeader newEntity) {
@@ -186,13 +246,7 @@ public class AtlasSearchResult implements Serializable {
List<AtlasEntityHeader> entities = this.entities;
if (CollectionUtils.isNotEmpty(entities)) {
- Iterator<AtlasEntityHeader> iter = entities.iterator();
- while (iter.hasNext()) {
- AtlasEntityHeader currEntity = iter.next();
- if (StringUtils.equals(currEntity.getGuid(), entity.getGuid())) {
- iter.remove();
- }
- }
+ entities.removeIf(currEntity -> StringUtils.equals(currEntity.getGuid(), entity.getGuid()));
}
}
@@ -213,38 +267,14 @@ public class AtlasSearchResult implements Serializable {
List<AtlasRelationshipHeader> relations = this.relations;
if (CollectionUtils.isNotEmpty(relations)) {
- Iterator<AtlasRelationshipHeader> iter = relations.iterator();
- while (iter.hasNext()) {
- AtlasRelationshipHeader currEntity = iter.next();
- if (StringUtils.equals(currEntity.getGuid(), relation.getGuid())) {
- iter.remove();
- }
- }
+ relations.removeIf(currEntity -> StringUtils.equals(currEntity.getGuid(), relation.getGuid()));
}
}
- @Override
- public String toString() {
- return "AtlasSearchResult{" +
- "queryType=" + queryType +
- ", searchParameters='" + searchParameters + '\'' +
- ", queryText='" + queryText + '\'' +
- ", type=" + type +
- ", classification=" + classification +
- ", entities=" + entities +
- ", relations=" + relations +
- ", attributes=" + attributes +
- ", fullTextResult=" + fullTextResult +
- ", referredEntities=" + referredEntities +
- ", approximateCount=" + approximateCount +
- ", nextMarker=" + nextMarker +
- '}';
- }
-
public enum AtlasQueryType { DSL, FULL_TEXT, GREMLIN, BASIC, ATTRIBUTE, RELATIONSHIP }
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
- @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+ @JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
@@ -252,44 +282,60 @@ public class AtlasSearchResult implements Serializable {
private List<String> name;
private List<List<Object>> values;
- public AttributeSearchResult() { }
+ public AttributeSearchResult() {
+ }
public AttributeSearchResult(List<String> name, List<List<Object>> values) {
- this.name = name;
+ this.name = name;
this.values = values;
}
- public List<String> getName() { return name; }
+ public List<String> getName() {
+ return name;
+ }
- public void setName(List<String> name) { this.name = name; }
+ public void setName(List<String> name) {
+ this.name = name;
+ }
- public List<List<Object>> getValues() { return values; }
+ public List<List<Object>> getValues() {
+ return values;
+ }
- public void setValues(List<List<Object>> values) { this.values = values; }
+ public void setValues(List<List<Object>> values) {
+ this.values = values;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(name, values);
+ }
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ if (this == o) {
+ return true;
+ } else if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
AttributeSearchResult that = (AttributeSearchResult) o;
+
return Objects.equals(name, that.name) &&
Objects.equals(values, that.values);
}
- @Override
- public int hashCode() { return Objects.hash(name, values); }
-
@Override
public String toString() {
return "AttributeSearchResult{" +
- "name=" + name + ", " +
+ "name=" + name + ", " +
"values=" + values +
'}';
}
}
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
- @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+ @JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
@@ -297,33 +343,49 @@ public class AtlasSearchResult implements Serializable {
AtlasEntityHeader entity;
Double score;
- public AtlasFullTextResult() {}
+ public AtlasFullTextResult() {
+ }
public AtlasFullTextResult(AtlasEntityHeader entity, Double score) {
this.entity = entity;
this.score = score;
}
- public AtlasEntityHeader getEntity() { return entity; }
+ public AtlasEntityHeader getEntity() {
+ return entity;
+ }
- public void setEntity(AtlasEntityHeader entity) { this.entity = entity; }
+ public void setEntity(AtlasEntityHeader entity) {
+ this.entity = entity;
+ }
+
+ public Double getScore() {
+ return score;
+ }
- public Double getScore() { return score; }
+ public void setScore(Double score) {
+ this.score = score;
+ }
- public void setScore(Double score) { this.score = score; }
+ @Override
+ public int hashCode() {
+ return Objects.hash(entity, score);
+ }
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ if (this == o) {
+ return true;
+ } else if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
AtlasFullTextResult that = (AtlasFullTextResult) o;
+
return Objects.equals(entity, that.entity) &&
- Objects.equals(score, that.score);
+ Objects.equals(score, that.score);
}
- @Override
- public int hashCode() { return Objects.hash(entity, score); }
-
@Override
public String toString() {
return "AtlasFullTextResult{" +
diff --git a/intg/src/main/java/org/apache/atlas/model/discovery/AtlasSearchResultDownloadStatus.java b/intg/src/main/java/org/apache/atlas/model/discovery/AtlasSearchResultDownloadStatus.java
index f2f73e6c4..6a2986a0c 100644
--- a/intg/src/main/java/org/apache/atlas/model/discovery/AtlasSearchResultDownloadStatus.java
+++ b/intg/src/main/java/org/apache/atlas/model/discovery/AtlasSearchResultDownloadStatus.java
@@ -19,12 +19,13 @@ package org.apache.atlas.model.discovery;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.atlas.model.tasks.AtlasTask;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
+
import java.io.Serializable;
import java.util.Date;
import java.util.List;
@@ -33,10 +34,9 @@ import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class AtlasSearchResultDownloadStatus implements Serializable {
-
private List<AtlasSearchDownloadRecord> searchDownloadRecords;
public List<AtlasSearchDownloadRecord> getSearchDownloadRecords() {
@@ -48,24 +48,23 @@ public class AtlasSearchResultDownloadStatus implements Serializable {
}
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
- @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+ @JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public static class AtlasSearchDownloadRecord implements Serializable {
private AtlasTask.Status status;
- private String fileName;
- private String createdBy;
- private Date createdTime;
- private Date startTime;
-
+ private String fileName;
+ private String createdBy;
+ private Date createdTime;
+ private Date startTime;
public AtlasSearchDownloadRecord(AtlasTask.Status status, String fileName, String createdBy, Date createdTime, Date startTime) {
- this.status = status;
- this.fileName = fileName;
- this.createdBy = createdBy;
- this.createdTime = createdTime;
- this.startTime = startTime;
+ this.status = status;
+ this.fileName = fileName;
+ this.createdBy = createdBy;
+ this.createdTime = createdTime;
+ this.startTime = startTime;
}
public AtlasSearchDownloadRecord(AtlasTask.Status status, String fileName, String createdBy, Date createdTime) {
@@ -116,6 +115,7 @@ public class AtlasSearchResultDownloadStatus implements Serializable {
if (sb == null) {
sb = new StringBuilder();
}
+
sb.append("AtlasSearchDownloadRecord{");
sb.append("status=").append(status);
sb.append(", fileName=").append(fileName);
@@ -123,6 +123,7 @@ public class AtlasSearchResultDownloadStatus implements Serializable {
sb.append(", createTime=").append(createdTime);
sb.append(", startTime=").append(startTime);
sb.append("}");
+
return sb;
}
diff --git a/intg/src/main/java/org/apache/atlas/model/discovery/AtlasSuggestionsResult.java b/intg/src/main/java/org/apache/atlas/model/discovery/AtlasSuggestionsResult.java
index af574b88e..54120108c 100644
--- a/intg/src/main/java/org/apache/atlas/model/discovery/AtlasSuggestionsResult.java
+++ b/intg/src/main/java/org/apache/atlas/model/discovery/AtlasSuggestionsResult.java
@@ -20,7 +20,7 @@ package org.apache.atlas.model.discovery;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.List;
@@ -28,7 +28,7 @@ import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class AtlasSuggestionsResult {
private List<String> suggestions;
diff --git a/intg/src/main/java/org/apache/atlas/model/discovery/QuickSearchParameters.java b/intg/src/main/java/org/apache/atlas/model/discovery/QuickSearchParameters.java
index dcad83c01..2552a7ce4 100644
--- a/intg/src/main/java/org/apache/atlas/model/discovery/QuickSearchParameters.java
+++ b/intg/src/main/java/org/apache/atlas/model/discovery/QuickSearchParameters.java
@@ -17,11 +17,9 @@
*/
package org.apache.atlas.model.discovery;
-
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-
+import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.atlas.SortOrder;
import org.apache.atlas.model.discovery.SearchParameters.FilterCriteria;
@@ -32,7 +30,7 @@ import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
/**
* This is the root class representing the input for quick search puroposes.
@@ -58,16 +56,7 @@ public class QuickSearchParameters implements Serializable {
public QuickSearchParameters() {
}
- public QuickSearchParameters(String query,
- String typeName,
- FilterCriteria entityFilters,
- boolean includeSubTypes,
- boolean excludeDeletedEntities,
- int offset,
- int limit,
- Set<String> attributes,
- String sortBy,
- SortOrder sortOrder) {
+ public QuickSearchParameters(String query, String typeName, FilterCriteria entityFilters, boolean includeSubTypes, boolean excludeDeletedEntities, int offset, int limit, Set<String> attributes, String sortBy, SortOrder sortOrder) {
this.query = query;
this.typeName = typeName;
this.entityFilters = entityFilters;
diff --git a/intg/src/main/java/org/apache/atlas/model/discovery/RelationshipSearchParameters.java b/intg/src/main/java/org/apache/atlas/model/discovery/RelationshipSearchParameters.java
index 0f132514e..87c65e05d 100644
--- a/intg/src/main/java/org/apache/atlas/model/discovery/RelationshipSearchParameters.java
+++ b/intg/src/main/java/org/apache/atlas/model/discovery/RelationshipSearchParameters.java
@@ -19,31 +19,28 @@ package org.apache.atlas.model.discovery;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.atlas.SortOrder;
import java.io.Serializable;
-import java.util.Set;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class RelationshipSearchParameters implements Serializable {
-
private static final long serialVersionUID = 1L;
- private String relationshipName;
+ private String relationshipName;
private SearchParameters.FilterCriteria relationshipFilters;
- private boolean includeSubTypes;
- private int offset;
- private int limit;
- private String sortBy;
- private SortOrder sortOrder;
- private String marker;
-
+ private boolean includeSubTypes;
+ private int offset;
+ private int limit;
+ private String sortBy;
+ private SortOrder sortOrder;
+ private String marker;
public String getRelationshipName() {
return relationshipName;
diff --git a/intg/src/main/java/org/apache/atlas/model/discovery/SearchParameters.java b/intg/src/main/java/org/apache/atlas/model/discovery/SearchParameters.java
index 1de1f122b..5954dd038 100644
--- a/intg/src/main/java/org/apache/atlas/model/discovery/SearchParameters.java
+++ b/intg/src/main/java/org/apache/atlas/model/discovery/SearchParameters.java
@@ -17,12 +17,11 @@
*/
package org.apache.atlas.model.discovery;
-
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonValue;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.apache.atlas.SortOrder;
import java.io.Serializable;
@@ -36,39 +35,37 @@ import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class SearchParameters implements Serializable {
private static final long serialVersionUID = 1L;
- private String query;
- private String typeName;
- private String classification;
- private String relationshipName;
- private String termName;
- private String sortBy;
- private boolean excludeDeletedEntities;
- private boolean includeClassificationAttributes;
- private boolean includeSubTypes = true;
- private boolean includeSubClassifications = true;
- private boolean excludeHeaderAttributes = false;
-
- private int limit;
- private int offset;
- private String marker;
+ public static final String WILDCARD_CLASSIFICATIONS = "*";
+ public static final String ALL_CLASSIFICATIONS = "_CLASSIFIED";
+ public static final String NO_CLASSIFICATIONS = "_NOT_CLASSIFIED";
+ public static final String ALL_ENTITY_TYPES = "_ALL_ENTITY_TYPES";
+ public static final String ALL_CLASSIFICATION_TYPES = "_ALL_CLASSIFICATION_TYPES";
+ private String query;
+ private String typeName;
+ private String classification;
+ private String relationshipName;
+ private String termName;
+ private String sortBy;
+ private boolean excludeDeletedEntities;
+ private boolean includeClassificationAttributes;
+ private boolean includeSubTypes = true;
+ private boolean includeSubClassifications = true;
+ private boolean excludeHeaderAttributes;
+ private int limit;
+ private int offset;
+ private String marker;
private FilterCriteria entityFilters;
private FilterCriteria tagFilters;
private FilterCriteria relationshipFilters;
private Set<String> attributes;
private SortOrder sortOrder;
- public static final String WILDCARD_CLASSIFICATIONS = "*";
- public static final String ALL_CLASSIFICATIONS = "_CLASSIFIED";
- public static final String NO_CLASSIFICATIONS = "_NOT_CLASSIFIED";
- public static final String ALL_ENTITY_TYPES = "_ALL_ENTITY_TYPES";
- public static final String ALL_CLASSIFICATION_TYPES = "_ALL_CLASSIFICATION_TYPES";
-
/**
* @return The type of query
*/
@@ -78,6 +75,7 @@ public class SearchParameters implements Serializable {
/**
* Set query type
+ *
* @param query type
*/
public void setQuery(String query) {
@@ -93,6 +91,7 @@ public class SearchParameters implements Serializable {
/**
* Set the type name to search on
+ *
* @param typeName type name
*/
public void setTypeName(String typeName) {
@@ -100,7 +99,6 @@ public class SearchParameters implements Serializable {
}
/**
- *
* @return termName to search on
*/
public String getTermName() {
@@ -109,6 +107,7 @@ public class SearchParameters implements Serializable {
/**
* Set the classification/tag to search on
+ *
* @param termName classification/tag name
*/
public void setTermName(String termName) {
@@ -116,7 +115,6 @@ public class SearchParameters implements Serializable {
}
/**
- *
* @return Classification/tag to search on
*/
public String getClassification() {
@@ -125,6 +123,7 @@ public class SearchParameters implements Serializable {
/**
* Set the classification/tag to search on
+ *
* @param classification classification/tag name
*/
public void setClassification(String classification) {
@@ -148,6 +147,7 @@ public class SearchParameters implements Serializable {
/**
* Exclude deleted entities from search
+ *
* @param excludeDeletedEntities boolean flag
*/
public void setExcludeDeletedEntities(boolean excludeDeletedEntities) {
@@ -163,6 +163,7 @@ public class SearchParameters implements Serializable {
/**
* Include classificatio attributes in search result.
+ *
* @param includeClassificationAttributes boolean flag
*/
public void setIncludeClassificationAttributes(boolean includeClassificationAttributes) {
@@ -178,6 +179,7 @@ public class SearchParameters implements Serializable {
/**
* Include sub-type entities in search
+ *
* @param includeSubTypes boolean flag
*/
public void setIncludeSubTypes(boolean includeSubTypes) {
@@ -193,6 +195,7 @@ public class SearchParameters implements Serializable {
/**
* Include sub-classifications in search
+ *
* @param includeSubClassifications boolean flag
*/
public void setIncludeSubClassifications(boolean includeSubClassifications) {
@@ -208,6 +211,7 @@ public class SearchParameters implements Serializable {
/**
* Restrict the results to the specified limit
+ *
* @param limit max number of results
*/
public void setLimit(int limit) {
@@ -231,15 +235,20 @@ public class SearchParameters implements Serializable {
/**
* @return marker (offset of the next page)
*/
- public String getMarker() { return marker; }
+ public String getMarker() {
+ return marker;
+ }
/**
* @param marker
*/
- public void setMarker(String marker) { this.marker = marker; }
+ public void setMarker(String marker) {
+ this.marker = marker;
+ }
/**
* Entity attribute filters for the type (if type name is specified)
+ *
* @return
*/
public FilterCriteria getEntityFilters() {
@@ -248,6 +257,7 @@ public class SearchParameters implements Serializable {
/**
* Filter the entities on this criteria
+ *
* @param entityFilters
*/
public void setEntityFilters(FilterCriteria entityFilters) {
@@ -256,6 +266,7 @@ public class SearchParameters implements Serializable {
/**
* Tag attribute filters for the classification/tag (if tag name is specified)
+ *
* @return
*/
public FilterCriteria getTagFilters() {
@@ -264,6 +275,7 @@ public class SearchParameters implements Serializable {
/**
* Filter the tag/classification on this criteria
+ *
* @param tagFilters
*/
public void setTagFilters(FilterCriteria tagFilters) {
@@ -272,16 +284,21 @@ public class SearchParameters implements Serializable {
/**
* Relationship attribute filters for the relationship
+ *
* @return
*/
- public FilterCriteria getRelationshipFilters() { return relationshipFilters; }
+ public FilterCriteria getRelationshipFilters() {
+ return relationshipFilters;
+ }
/**
* Filter the relationship on this criteria
+ *
* @param relationshipFilters
*/
- public void setRelationshipFilters(FilterCriteria relationshipFilters) { this.relationshipFilters = relationshipFilters; }
-
+ public void setRelationshipFilters(FilterCriteria relationshipFilters) {
+ this.relationshipFilters = relationshipFilters;
+ }
public boolean getExcludeHeaderAttributes() {
return excludeHeaderAttributes;
@@ -293,6 +310,7 @@ public class SearchParameters implements Serializable {
/**
* Attribute values included in the results
+ *
* @return
*/
public Set<String> getAttributes() {
@@ -301,6 +319,7 @@ public class SearchParameters implements Serializable {
/**
* Return these attributes in the result response
+ *
* @param attributes
*/
public void setAttributes(Set<String> attributes) {
@@ -310,13 +329,18 @@ public class SearchParameters implements Serializable {
/**
* @return Attribute on which to sort the results
*/
- public String getSortBy() { return sortBy; }
+ public String getSortBy() {
+ return sortBy;
+ }
/**
* Sort the results based on sortBy attribute
+ *
* @param sortBy Attribute on which to sort the results
*/
- public void setSortBy(String sortBy) { this.sortBy = sortBy; }
+ public void setSortBy(String sortBy) {
+ this.sortBy = sortBy;
+ }
/**
* @return Sorting order of the results
@@ -327,15 +351,30 @@ public class SearchParameters implements Serializable {
/**
* Sorting order to sort the results
+ *
* @param sortOrder ASCENDING vs DESCENDING
*/
- public void setSortOrder(SortOrder sortOrder) { this.sortOrder = sortOrder; }
+ public void setSortOrder(SortOrder sortOrder) {
+ this.sortOrder = sortOrder;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(query, typeName, classification, termName, includeSubTypes, includeSubClassifications,
+ excludeDeletedEntities, includeClassificationAttributes, excludeHeaderAttributes, limit, offset, entityFilters,
+ tagFilters, attributes, sortBy, sortOrder);
+ }
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ if (this == o) {
+ return true;
+ } else if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
SearchParameters that = (SearchParameters) o;
+
return excludeDeletedEntities == that.excludeDeletedEntities &&
includeClassificationAttributes == that.includeClassificationAttributes &&
includeSubTypes == that.includeSubTypes &&
@@ -355,10 +394,8 @@ public class SearchParameters implements Serializable {
}
@Override
- public int hashCode() {
- return Objects.hash(query, typeName, classification, termName, includeSubTypes, includeSubClassifications,
- excludeDeletedEntities, includeClassificationAttributes, excludeHeaderAttributes, limit, offset, entityFilters,
- tagFilters, attributes, sortBy, sortOrder);
+ public String toString() {
+ return toString(new StringBuilder()).toString();
}
public StringBuilder toString(StringBuilder sb) {
@@ -388,19 +425,74 @@ public class SearchParameters implements Serializable {
return sb;
}
- @Override
- public String toString() {
- return toString(new StringBuilder()).toString();
+ /**
+ * NOTE : The names added in the String array should always contain first value in lower case
+ */
+ public enum Operator {
+ LT(new String[] {"<", "lt"}),
+ GT(new String[] {">", "gt"}),
+ LTE(new String[] {"<=", "lte"}),
+ GTE(new String[] {">=", "gte"}),
+ EQ(new String[] {"=", "eq"}),
+ NEQ(new String[] {"!=", "neq"}),
+ IN(new String[] {"in", "IN"}),
+ LIKE(new String[] {"like", "LIKE"}),
+ STARTS_WITH(new String[] {"startsWith", "STARTSWITH", "begins_with", "BEGINS_WITH"}),
+ ENDS_WITH(new String[] {"endsWith", "ENDSWITH", "ends_with", "ENDS_WITH"}),
+ CONTAINS(new String[] {"contains", "CONTAINS"}),
+ NOT_CONTAINS(new String[] {"not_contains", "NOT_CONTAINS"}),
+ CONTAINS_ANY(new String[] {"containsAny", "CONTAINSANY", "contains_any", "CONTAINS_ANY"}),
+ CONTAINS_ALL(new String[] {"containsAll", "CONTAINSALL", "contains_all", "CONTAINS_ALL"}),
+ IS_NULL(new String[] {"isNull", "ISNULL", "is_null", "IS_NULL"}),
+ NOT_NULL(new String[] {"notNull", "NOTNULL", "not_null", "NOT_NULL"}),
+ TIME_RANGE(new String[] {"timerange", "TIMERANGE", "time_range", "TIME_RANGE"}),
+ NOT_EMPTY(new String[] {"notEmpty", "NOTEMPTY", "not_empty", "NOT_EMPTY"});
+ static final Map<String, Operator> operatorsMap = new HashMap<>();
+
+ private final String[] symbols;
+
+ Operator(String[] symbols) {
+ this.symbols = symbols;
+ }
+
+ @JsonCreator
+ public static Operator fromString(String symbol) {
+ return operatorsMap.get(symbol);
+ }
+
+ @JsonValue
+ public String getSymbol() {
+ return symbols[0];
+ }
+
+ public String[] getSymbols() {
+ return symbols;
+ }
+
+ @Override
+ public String toString() {
+ return getSymbol();
+ }
+
+ static {
+ for (Operator operator : Operator.values()) {
+ for (String s : operator.symbols) {
+ operatorsMap.put(s, operator);
+ }
+ }
+ }
}
+ /**
+ * Supported search operations
+ * Logical comparision operators can only be used with numbers or dates
+ * IN, LIKE, startsWith, endsWith, CONTAINS can only be used with strings or text
+ */
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
- @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+ @JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public static class FilterCriteria {
- // Can be presented as a group of conditions or a single condition
- public enum Condition { AND, OR }
-
// Single condition
private String attributeName;
private Operator operator;
@@ -450,11 +542,21 @@ public class SearchParameters implements Serializable {
this.criterion = criterion;
}
+ @Override
+ public int hashCode() {
+ return Objects.hash(attributeName, operator, attributeValue, condition, criterion);
+ }
+
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ if (this == o) {
+ return true;
+ } else if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
FilterCriteria that = (FilterCriteria) o;
+
return Objects.equals(attributeName, that.attributeName) &&
Objects.equals(operator, that.operator) &&
Objects.equals(attributeValue, that.attributeValue) &&
@@ -463,8 +565,8 @@ public class SearchParameters implements Serializable {
}
@Override
- public int hashCode() {
- return Objects.hash(attributeName, operator, attributeValue, condition, criterion);
+ public String toString() {
+ return toString(new StringBuilder()).toString();
}
public StringBuilder toString(StringBuilder sb) {
@@ -483,75 +585,7 @@ public class SearchParameters implements Serializable {
return sb;
}
- @Override
- public String toString() {
- return toString(new StringBuilder()).toString();
- }
- }
-
- /**
- * Supported search operations
- * Logical comparision operators can only be used with numbers or dates
- * IN, LIKE, startsWith, endsWith, CONTAINS can only be used with strings or text
- */
-
- /**
- * NOTE : The names added in the String array should always contain first value in lower case
- */
- public enum Operator {
- LT(new String[]{"<", "lt"}),
- GT(new String[]{">", "gt"}),
- LTE(new String[]{"<=", "lte"}),
- GTE(new String[]{">=", "gte"}),
- EQ(new String[]{"=", "eq"}),
- NEQ(new String[]{"!=", "neq"}),
- IN(new String[]{"in", "IN"}),
- LIKE(new String[]{"like", "LIKE"}),
- STARTS_WITH(new String[]{"startsWith", "STARTSWITH", "begins_with", "BEGINS_WITH"}),
- ENDS_WITH(new String[]{"endsWith", "ENDSWITH", "ends_with", "ENDS_WITH"}),
- CONTAINS(new String[]{"contains", "CONTAINS"}),
- NOT_CONTAINS(new String[]{"not_contains", "NOT_CONTAINS"}),
- CONTAINS_ANY(new String[]{"containsAny", "CONTAINSANY", "contains_any", "CONTAINS_ANY"}),
- CONTAINS_ALL(new String[]{"containsAll", "CONTAINSALL", "contains_all", "CONTAINS_ALL"}),
- IS_NULL(new String[]{"isNull", "ISNULL", "is_null", "IS_NULL"}),
- NOT_NULL(new String[]{"notNull", "NOTNULL", "not_null", "NOT_NULL"}),
- TIME_RANGE(new String[]{"timerange", "TIMERANGE","time_range","TIME_RANGE"}),
- NOT_EMPTY(new String[]{"notEmpty", "NOTEMPTY", "not_empty", "NOT_EMPTY"})
- ;
- static final Map<String, Operator> operatorsMap = new HashMap<>();
-
- private String[] symbols;
-
- static {
- for (Operator operator : Operator.values()) {
- for (String s : operator.symbols) {
- operatorsMap.put(s, operator);
- }
- }
- }
-
- Operator(String[] symbols) {
- this.symbols = symbols;
- }
-
- @JsonCreator
- public static Operator fromString(String symbol) {
- return operatorsMap.get(symbol);
- }
-
- @JsonValue
- public String getSymbol() {
- return symbols[0];
- }
-
- public String[] getSymbols() {
- return symbols;
- }
-
- @Override
- public String toString() {
- return getSymbol();
- }
-
+ // Can be presented as a group of conditions or a single condition
+ public enum Condition { AND, OR }
}
}
diff --git a/intg/src/main/java/org/apache/atlas/model/glossary/AtlasGlossary.java b/intg/src/main/java/org/apache/atlas/model/glossary/AtlasGlossary.java
index b906066f9..312a0130d 100644
--- a/intg/src/main/java/org/apache/atlas/model/glossary/AtlasGlossary.java
+++ b/intg/src/main/java/org/apache/atlas/model/glossary/AtlasGlossary.java
@@ -29,6 +29,8 @@ import java.util.Map;
import java.util.Objects;
import java.util.Set;
+import static java.util.Objects.requireNonNull;
+
@AtlasJSON
public class AtlasGlossary extends AtlasGlossaryBaseObject {
private String language;
@@ -47,9 +49,9 @@ public class AtlasGlossary extends AtlasGlossaryBaseObject {
super.setName(other.name);
super.setShortDescription(other.shortDescription);
super.setLongDescription(other.longDescription);
- this.language = other.language;
- this.usage = other.usage;
- this.terms = other.terms;
+ this.language = other.language;
+ this.usage = other.usage;
+ this.terms = other.terms;
this.categories = other.categories;
}
@@ -88,7 +90,8 @@ public class AtlasGlossary extends AtlasGlossaryBaseObject {
@JsonIgnore
@Override
public void setAttribute(String attrName, String attrVal) {
- Objects.requireNonNull(attrName, "AtlasGlossary attribute name");
+ requireNonNull(attrName, "AtlasGlossary attribute name");
+
switch (attrName) {
case "name":
setName(attrVal);
@@ -110,23 +113,62 @@ public class AtlasGlossary extends AtlasGlossaryBaseObject {
}
}
+ @Override
+ public boolean equals(final Object o) {
+ if (this == o) {
+ return true;
+ } else if (!(o instanceof AtlasGlossary)) {
+ return false;
+ } else if (!super.equals(o)) {
+ return false;
+ }
+
+ AtlasGlossary glossary = (AtlasGlossary) o;
+
+ return Objects.equals(language, glossary.language) &&
+ Objects.equals(usage, glossary.usage) &&
+ Objects.equals(terms, glossary.terms) &&
+ Objects.equals(categories, glossary.categories);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(super.hashCode(), language, usage, terms, categories);
+ }
+
+ @Override
+ protected StringBuilder toString(final StringBuilder sb) {
+ sb.append(", language='").append(language).append('\'');
+ sb.append(", usage='").append(usage).append('\'');
+ sb.append(", terms=").append(terms);
+ sb.append(", categories=").append(categories);
+
+ return sb;
+ }
+
@JsonIgnore
public void addTerm(AtlasRelatedTermHeader relatedTermId) {
Set<AtlasRelatedTermHeader> terms = this.terms;
+
if (terms == null) {
terms = new HashSet<>();
}
+
terms.add(relatedTermId);
+
setTerms(terms);
}
@JsonIgnore
public void addCategory(AtlasRelatedCategoryHeader relatedCategoryId) {
Set<AtlasRelatedCategoryHeader> categories = this.categories;
+
if (categories == null) {
categories = new HashSet<>();
}
+
categories.add(relatedCategoryId);
+
setCategories(categories);
}
@@ -144,34 +186,6 @@ public class AtlasGlossary extends AtlasGlossaryBaseObject {
}
}
- @Override
- protected StringBuilder toString(final StringBuilder sb) {
- sb.append(", language='").append(language).append('\'');
- sb.append(", usage='").append(usage).append('\'');
- sb.append(", terms=").append(terms);
- sb.append(", categories=").append(categories);
-
- return sb;
- }
-
- @Override
- public boolean equals(final Object o) {
- if (this == o) return true;
- if (!(o instanceof AtlasGlossary)) return false;
- if (!super.equals(o)) return false;
- final AtlasGlossary glossary = (AtlasGlossary) o;
- return Objects.equals(language, glossary.language) &&
- Objects.equals(usage, glossary.usage) &&
- Objects.equals(terms, glossary.terms) &&
- Objects.equals(categories, glossary.categories);
- }
-
- @Override
- public int hashCode() {
-
- return Objects.hash(super.hashCode(), language, usage, terms, categories);
- }
-
@AtlasJSON
public static class AtlasGlossaryExtInfo extends AtlasGlossary {
private Map<String, AtlasGlossaryTerm> termInfo;
@@ -188,56 +202,61 @@ public class AtlasGlossary extends AtlasGlossaryBaseObject {
return termInfo;
}
+ public void setTermInfo(final Map<String, AtlasGlossaryTerm> termInfo) {
+ this.termInfo = termInfo;
+ }
+
public void addTermInfo(final AtlasGlossaryTerm term) {
if (termInfo == null) {
termInfo = new HashMap<>();
}
- termInfo.put(term.getGuid(), term);
- }
- public void setTermInfo(final Map<String, AtlasGlossaryTerm> termInfo) {
- this.termInfo = termInfo;
+ termInfo.put(term.getGuid(), term);
}
public Map<String, AtlasGlossaryCategory> getCategoryInfo() {
return categoryInfo;
}
+ public void setCategoryInfo(final Map<String, AtlasGlossaryCategory> categoryInfo) {
+ this.categoryInfo = categoryInfo;
+ }
+
public void addCategoryInfo(final AtlasGlossaryCategory category) {
if (categoryInfo == null) {
categoryInfo = new HashMap<>();
}
+
categoryInfo.put(category.getGuid(), category);
}
- public void setCategoryInfo(final Map<String, AtlasGlossaryCategory> categoryInfo) {
- this.categoryInfo = categoryInfo;
+ @Override
+ public StringBuilder toString(StringBuilder sb) {
+ sb.append(", termInfo=").append(termInfo);
+ sb.append(", categoryInfo=").append(categoryInfo);
+
+ return sb;
}
@Override
public boolean equals(final Object o) {
- if (this == o) return true;
- if (!(o instanceof AtlasGlossaryExtInfo)) return false;
- if (!super.equals(o)) return false;
- final AtlasGlossaryExtInfo that = (AtlasGlossaryExtInfo) o;
+ if (this == o) {
+ return true;
+ } else if (!(o instanceof AtlasGlossaryExtInfo)) {
+ return false;
+ } else if (!super.equals(o)) {
+ return false;
+ }
+
+ AtlasGlossaryExtInfo that = (AtlasGlossaryExtInfo) o;
+
return Objects.equals(termInfo, that.termInfo) &&
- Objects.equals(categoryInfo, that.categoryInfo);
+ Objects.equals(categoryInfo, that.categoryInfo);
}
@Override
public int hashCode() {
-
return Objects.hash(super.hashCode(), termInfo, categoryInfo);
}
-
- @Override
- public StringBuilder toString(StringBuilder sb) {
- sb.append(", termInfo=").append(termInfo);
- sb.append(", categoryInfo=").append(categoryInfo);
-
- return sb;
- }
-
-
}
}
diff --git a/intg/src/main/java/org/apache/atlas/model/glossary/AtlasGlossaryBaseObject.java b/intg/src/main/java/org/apache/atlas/model/glossary/AtlasGlossaryBaseObject.java
index 259bb9c48..c630390d7 100644
--- a/intg/src/main/java/org/apache/atlas/model/glossary/AtlasGlossaryBaseObject.java
+++ b/intg/src/main/java/org/apache/atlas/model/glossary/AtlasGlossaryBaseObject.java
@@ -24,32 +24,30 @@ import org.apache.commons.collections.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
-import java.util.Objects;
import java.util.Map;
-
+import java.util.Objects;
public abstract class AtlasGlossaryBaseObject extends AtlasBaseModelObject {
+ protected String name;
+ protected String shortDescription;
+ protected String longDescription;
+ protected List<AtlasClassification> classifications;
// Core attributes
- private String qualifiedName;
- protected String name;
- protected String shortDescription;
- protected String longDescription;
+ private String qualifiedName;
private Map<String, Object> additionalAttributes;
- // Classifications
- protected List<AtlasClassification> classifications;
-
public AtlasGlossaryBaseObject() {
}
public AtlasGlossaryBaseObject(final AtlasGlossaryBaseObject other) {
super(other);
- this.name = other.name;
- this.shortDescription = other.shortDescription;
- this.longDescription = other.longDescription;
- this.classifications = other.classifications;
- this.qualifiedName = other.qualifiedName;
+
+ this.name = other.name;
+ this.shortDescription = other.shortDescription;
+ this.longDescription = other.longDescription;
+ this.classifications = other.classifications;
+ this.qualifiedName = other.qualifiedName;
this.additionalAttributes = other.additionalAttributes;
}
@@ -93,7 +91,7 @@ public abstract class AtlasGlossaryBaseObject extends AtlasBaseModelObject {
this.longDescription = longDescription;
}
- abstract public void setAttribute(String attrName, String attrVal);
+ public abstract void setAttribute(String attrName, String attrVal);
public List<AtlasClassification> getClassifications() {
return classifications;
@@ -106,10 +104,13 @@ public abstract class AtlasGlossaryBaseObject extends AtlasBaseModelObject {
@JsonIgnore
public void addClassification(AtlasClassification classification) {
List<AtlasClassification> classifications = this.classifications;
+
if (classifications == null) {
classifications = new ArrayList<>();
}
+
classifications.add(classification);
+
setClassifications(classifications);
}
@@ -122,10 +123,16 @@ public abstract class AtlasGlossaryBaseObject extends AtlasBaseModelObject {
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- if (!super.equals(o)) return false;
+ if (this == o) {
+ return true;
+ } else if (o == null || getClass() != o.getClass()) {
+ return false;
+ } else if (!super.equals(o)) {
+ return false;
+ }
+
AtlasGlossaryBaseObject that = (AtlasGlossaryBaseObject) o;
+
return Objects.equals(qualifiedName, that.qualifiedName) &&
Objects.equals(name, that.name) &&
Objects.equals(shortDescription, that.shortDescription) &&
diff --git a/intg/src/main/java/org/apache/atlas/model/glossary/AtlasGlossaryCategory.java b/intg/src/main/java/org/apache/atlas/model/glossary/AtlasGlossaryCategory.java
index 1a906c4ee..0a6c396bc 100644
--- a/intg/src/main/java/org/apache/atlas/model/glossary/AtlasGlossaryCategory.java
+++ b/intg/src/main/java/org/apache/atlas/model/glossary/AtlasGlossaryCategory.java
@@ -28,6 +28,8 @@ import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
+import static java.util.Objects.requireNonNull;
+
@AtlasJSON
public class AtlasGlossaryCategory extends AtlasGlossaryBaseObject {
// Inherited attributes from relations
@@ -45,10 +47,11 @@ public class AtlasGlossaryCategory extends AtlasGlossaryBaseObject {
public AtlasGlossaryCategory(final AtlasGlossaryCategory other) {
super(other);
- this.anchor = other.anchor;
- this.parentCategory = other.parentCategory;
+
+ this.anchor = other.anchor;
+ this.parentCategory = other.parentCategory;
this.childrenCategories = other.childrenCategories;
- this.terms = other.terms;
+ this.terms = other.terms;
}
public AtlasGlossaryHeader getAnchor() {
@@ -85,11 +88,14 @@ public class AtlasGlossaryCategory extends AtlasGlossaryBaseObject {
@JsonIgnore
public void addChild(AtlasRelatedCategoryHeader child) {
- Set<AtlasRelatedCategoryHeader> children = this.childrenCategories ;
+ Set<AtlasRelatedCategoryHeader> children = this.childrenCategories;
+
if (children == null) {
children = new HashSet<>();
}
+
children.add(child);
+
setChildrenCategories(children);
}
@@ -103,10 +109,13 @@ public class AtlasGlossaryCategory extends AtlasGlossaryBaseObject {
@JsonIgnore
public void addTerm(AtlasRelatedTermHeader term) {
Set<AtlasRelatedTermHeader> terms = this.terms;
+
if (terms == null) {
terms = new HashSet<>();
}
+
terms.add(term);
+
setTerms(terms);
}
@@ -120,8 +129,8 @@ public class AtlasGlossaryCategory extends AtlasGlossaryBaseObject {
@JsonIgnore
@Override
public void setAttribute(String attrName, String attrVal) {
- Objects.requireNonNull(attrName, "AtlasGlossary attribute name");
- switch(attrName) {
+ requireNonNull(attrName, "AtlasGlossary attribute name");
+ switch (attrName) {
case "name":
setName(attrVal);
break;
@@ -137,30 +146,35 @@ public class AtlasGlossaryCategory extends AtlasGlossaryBaseObject {
}
@Override
- protected StringBuilder toString(final StringBuilder sb) {
- sb.append(", anchor=").append(anchor);
- sb.append(", parentCategory=").append(parentCategory);
- sb.append(", childrenCategories=").append(childrenCategories);
- sb.append(", terms=").append(terms);
+ public boolean equals(final Object o) {
+ if (this == o) {
+ return true;
+ } else if (!(o instanceof AtlasGlossaryCategory)) {
+ return false;
+ } else if (!super.equals(o)) {
+ return false;
+ }
- return sb;
- }
+ AtlasGlossaryCategory category = (AtlasGlossaryCategory) o;
- @Override
- public boolean equals(final Object o) {
- if (this == o) return true;
- if (!(o instanceof AtlasGlossaryCategory)) return false;
- if (!super.equals(o)) return false;
- final AtlasGlossaryCategory category = (AtlasGlossaryCategory) o;
return Objects.equals(anchor, category.anchor) &&
- Objects.equals(parentCategory, category.parentCategory) &&
- Objects.equals(childrenCategories, category.childrenCategories) &&
- Objects.equals(terms, category.terms);
+ Objects.equals(parentCategory, category.parentCategory) &&
+ Objects.equals(childrenCategories, category.childrenCategories) &&
+ Objects.equals(terms, category.terms);
}
@Override
public int hashCode() {
-
return Objects.hash(super.hashCode(), anchor, parentCategory, childrenCategories, terms);
}
+
+ @Override
+ protected StringBuilder toString(final StringBuilder sb) {
+ sb.append(", anchor=").append(anchor);
+ sb.append(", parentCategory=").append(parentCategory);
+ sb.append(", childrenCategories=").append(childrenCategories);
+ sb.append(", terms=").append(terms);
+
+ return sb;
+ }
}
diff --git a/intg/src/main/java/org/apache/atlas/model/glossary/AtlasGlossaryTerm.java b/intg/src/main/java/org/apache/atlas/model/glossary/AtlasGlossaryTerm.java
index f0f362b3e..2160b2504 100644
--- a/intg/src/main/java/org/apache/atlas/model/glossary/AtlasGlossaryTerm.java
+++ b/intg/src/main/java/org/apache/atlas/model/glossary/AtlasGlossaryTerm.java
@@ -34,6 +34,8 @@ import java.util.Map;
import java.util.Objects;
import java.util.Set;
+import static java.util.Objects.requireNonNull;
+
@AtlasJSON
public class AtlasGlossaryTerm extends AtlasGlossaryBaseObject {
// Core attributes
@@ -75,33 +77,33 @@ public class AtlasGlossaryTerm extends AtlasGlossaryBaseObject {
private Set<AtlasRelatedTermHeader> validValues;
private Set<AtlasRelatedTermHeader> validValuesFor;
- private boolean hasTerms = false;
+ private boolean hasTerms;
public AtlasGlossaryTerm() {
}
public AtlasGlossaryTerm(final AtlasGlossaryTerm other) {
super(other);
- this.examples = other.examples;
- this.abbreviation = other.abbreviation;
- this.usage = other.usage;
- this.anchor = other.anchor;
+ this.examples = other.examples;
+ this.abbreviation = other.abbreviation;
+ this.usage = other.usage;
+ this.anchor = other.anchor;
this.assignedEntities = other.assignedEntities;
- this.categories = other.categories;
- this.seeAlso = other.seeAlso;
- this.synonyms = other.synonyms;
- this.antonyms = other.antonyms;
- this.preferredTerms = other.preferredTerms;
+ this.categories = other.categories;
+ this.seeAlso = other.seeAlso;
+ this.synonyms = other.synonyms;
+ this.antonyms = other.antonyms;
+ this.preferredTerms = other.preferredTerms;
this.preferredToTerms = other.preferredToTerms;
this.replacementTerms = other.replacementTerms;
- this.replacedBy = other.replacedBy;
+ this.replacedBy = other.replacedBy;
this.translationTerms = other.translationTerms;
- this.translatedTerms = other.translatedTerms;
- this.isA = other.isA;
- this.classifies = other.classifies;
- this.validValues = other.validValues;
- this.validValuesFor = other.validValuesFor;
- this.hasTerms = other.hasTerms;
+ this.translatedTerms = other.translatedTerms;
+ this.isA = other.isA;
+ this.classifies = other.classifies;
+ this.validValues = other.validValues;
+ this.validValuesFor = other.validValuesFor;
+ this.hasTerms = other.hasTerms;
}
public List<String> getExamples() {
@@ -146,10 +148,13 @@ public class AtlasGlossaryTerm extends AtlasGlossaryBaseObject {
public void addCategory(final AtlasTermCategorizationHeader category) {
Set<AtlasTermCategorizationHeader> categories = this.categories;
+
if (categories == null) {
categories = new HashSet<>();
}
+
categories.add(category);
+
setCategories(categories);
}
@@ -163,10 +168,13 @@ public class AtlasGlossaryTerm extends AtlasGlossaryBaseObject {
public void addAssignedEntity(final AtlasRelatedObjectId atlasObjectId) {
Set<AtlasRelatedObjectId> assignedEntities = this.assignedEntities;
+
if (assignedEntities == null) {
assignedEntities = new HashSet<>();
}
+
assignedEntities.add(atlasObjectId);
+
setAssignedEntities(assignedEntities);
}
@@ -333,6 +341,7 @@ public class AtlasGlossaryTerm extends AtlasGlossaryBaseObject {
@JsonIgnore
public String toAuditString() {
AtlasGlossaryTerm t = new AtlasGlossaryTerm();
+
t.setGuid(this.getGuid());
t.setName(this.getName());
t.setQualifiedName(this.getQualifiedName());
@@ -348,7 +357,8 @@ public class AtlasGlossaryTerm extends AtlasGlossaryBaseObject {
@JsonIgnore
@Override
public void setAttribute(String attrName, String attrVal) {
- Objects.requireNonNull(attrName, "AtlasGlossaryTerm attribute name");
+ requireNonNull(attrName, "AtlasGlossaryTerm attribute name");
+
switch (attrName) {
case "name":
setName(attrVal);
@@ -370,6 +380,71 @@ public class AtlasGlossaryTerm extends AtlasGlossaryBaseObject {
}
}
+ @Override
+ public boolean equals(final Object o) {
+ if (this == o) {
+ return true;
+ } else if (!(o instanceof AtlasGlossaryTerm)) {
+ return false;
+ } else if (!super.equals(o)) {
+ return false;
+ }
+
+ AtlasGlossaryTerm that = (AtlasGlossaryTerm) o;
+
+ return Objects.equals(examples, that.examples) &&
+ Objects.equals(abbreviation, that.abbreviation) &&
+ Objects.equals(usage, that.usage) &&
+ Objects.equals(anchor, that.anchor) &&
+ Objects.equals(assignedEntities, that.assignedEntities) &&
+ Objects.equals(categories, that.categories) &&
+ Objects.equals(seeAlso, that.seeAlso) &&
+ Objects.equals(synonyms, that.synonyms) &&
+ Objects.equals(antonyms, that.antonyms) &&
+ Objects.equals(preferredTerms, that.preferredTerms) &&
+ Objects.equals(preferredToTerms, that.preferredToTerms) &&
+ Objects.equals(replacementTerms, that.replacementTerms) &&
+ Objects.equals(replacedBy, that.replacedBy) &&
+ Objects.equals(translationTerms, that.translationTerms) &&
+ Objects.equals(translatedTerms, that.translatedTerms) &&
+ Objects.equals(isA, that.isA) &&
+ Objects.equals(classifies, that.classifies) &&
+ Objects.equals(validValues, that.validValues) &&
+ Objects.equals(validValuesFor, that.validValuesFor);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(super.hashCode(), examples, abbreviation, usage, anchor, assignedEntities, categories,
+ seeAlso, synonyms, antonyms, preferredTerms, preferredToTerms, replacementTerms, replacedBy,
+ translationTerms, translatedTerms, isA, classifies, validValues, validValuesFor);
+ }
+
+ @Override
+ protected StringBuilder toString(final StringBuilder sb) {
+ sb.append("examples=").append(examples);
+ sb.append(", abbreviation='").append(abbreviation).append('\'');
+ sb.append(", usage='").append(usage).append('\'');
+ sb.append(", anchor=").append(anchor);
+ sb.append(", assignedEntities=").append(assignedEntities);
+ sb.append(", categories=").append(categories);
+ sb.append(", seeAlso=").append(seeAlso);
+ sb.append(", synonyms=").append(synonyms);
+ sb.append(", antonyms=").append(antonyms);
+ sb.append(", preferredTerms=").append(preferredTerms);
+ sb.append(", preferredToTerms=").append(preferredToTerms);
+ sb.append(", replacementTerms=").append(replacementTerms);
+ sb.append(", replacedBy=").append(replacedBy);
+ sb.append(", translationTerms=").append(translationTerms);
+ sb.append(", translatedTerms=").append(translatedTerms);
+ sb.append(", isA=").append(isA);
+ sb.append(", classifies=").append(classifies);
+ sb.append(", validValues=").append(validValues);
+ sb.append(", validValuesFor=").append(validValuesFor);
+
+ return sb;
+ }
+
@JsonIgnore
public Map<Relation, Set<AtlasRelatedTermHeader>> getRelatedTerms() {
Map<Relation, Set<AtlasRelatedTermHeader>> ret = new HashMap<>();
@@ -429,66 +504,6 @@ public class AtlasGlossaryTerm extends AtlasGlossaryBaseObject {
return ret;
}
- @Override
- protected StringBuilder toString(final StringBuilder sb) {
- sb.append("examples=").append(examples);
- sb.append(", abbreviation='").append(abbreviation).append('\'');
- sb.append(", usage='").append(usage).append('\'');
- sb.append(", anchor=").append(anchor);
- sb.append(", assignedEntities=").append(assignedEntities);
- sb.append(", categories=").append(categories);
- sb.append(", seeAlso=").append(seeAlso);
- sb.append(", synonyms=").append(synonyms);
- sb.append(", antonyms=").append(antonyms);
- sb.append(", preferredTerms=").append(preferredTerms);
- sb.append(", preferredToTerms=").append(preferredToTerms);
- sb.append(", replacementTerms=").append(replacementTerms);
- sb.append(", replacedBy=").append(replacedBy);
- sb.append(", translationTerms=").append(translationTerms);
- sb.append(", translatedTerms=").append(translatedTerms);
- sb.append(", isA=").append(isA);
- sb.append(", classifies=").append(classifies);
- sb.append(", validValues=").append(validValues);
- sb.append(", validValuesFor=").append(validValuesFor);
-
- return sb;
- }
-
- @Override
- public boolean equals(final Object o) {
- if (this == o) return true;
- if (!(o instanceof AtlasGlossaryTerm)) return false;
- if (!super.equals(o)) return false;
- final AtlasGlossaryTerm that = (AtlasGlossaryTerm) o;
- return Objects.equals(examples, that.examples) &&
- Objects.equals(abbreviation, that.abbreviation) &&
- Objects.equals(usage, that.usage) &&
- Objects.equals(anchor, that.anchor) &&
- Objects.equals(assignedEntities, that.assignedEntities) &&
- Objects.equals(categories, that.categories) &&
- Objects.equals(seeAlso, that.seeAlso) &&
- Objects.equals(synonyms, that.synonyms) &&
- Objects.equals(antonyms, that.antonyms) &&
- Objects.equals(preferredTerms, that.preferredTerms) &&
- Objects.equals(preferredToTerms, that.preferredToTerms) &&
- Objects.equals(replacementTerms, that.replacementTerms) &&
- Objects.equals(replacedBy, that.replacedBy) &&
- Objects.equals(translationTerms, that.translationTerms) &&
- Objects.equals(translatedTerms, that.translatedTerms) &&
- Objects.equals(isA, that.isA) &&
- Objects.equals(classifies, that.classifies) &&
- Objects.equals(validValues, that.validValues) &&
- Objects.equals(validValuesFor, that.validValuesFor);
- }
-
- @Override
- public int hashCode() {
-
- return Objects.hash(super.hashCode(), examples, abbreviation, usage, anchor, assignedEntities, categories,
- seeAlso, synonyms, antonyms, preferredTerms, preferredToTerms, replacementTerms, replacedBy,
- translationTerms, translatedTerms, isA, classifies, validValues, validValuesFor);
- }
-
public enum Relation {
SEE_ALSO("AtlasGlossaryRelatedTerm", "seeAlso"),
SYNONYMS("AtlasGlossarySynonym", "synonyms"),
@@ -502,20 +517,19 @@ public class AtlasGlossaryTerm extends AtlasGlossaryBaseObject {
ISA("AtlasGlossaryIsARelationship", "isA", true),
CLASSIFIES("AtlasGlossaryIsARelationship", "classifies"),
VALID_VALUES("AtlasGlossaryValidValue", "validValues", true),
- VALID_VALUES_FOR("AtlasGlossaryValidValue", "validValuesFor"),
- ;
+ VALID_VALUES_FOR("AtlasGlossaryValidValue", "validValuesFor");
- private String name;
- private String attrName;
- private boolean isEnd2Attr;
+ private final String name;
+ private final String attrName;
+ private final boolean isEnd2Attr;
Relation(final String name, final String attrName) {
this(name, attrName, false);
}
Relation(final String name, final String attrName, final boolean isEnd2Attr) {
- this.name = name;
- this.attrName = attrName;
+ this.name = name;
+ this.attrName = attrName;
this.isEnd2Attr = isEnd2Attr;
}
diff --git a/intg/src/main/java/org/apache/atlas/model/glossary/AtlasGlossaryTermHeader.java b/intg/src/main/java/org/apache/atlas/model/glossary/AtlasGlossaryTermHeader.java
index f807ba243..fd283c441 100644
--- a/intg/src/main/java/org/apache/atlas/model/glossary/AtlasGlossaryTermHeader.java
+++ b/intg/src/main/java/org/apache/atlas/model/glossary/AtlasGlossaryTermHeader.java
@@ -31,19 +31,10 @@ public class AtlasGlossaryTermHeader {
}
public AtlasGlossaryTermHeader(String termGuid, String qualifiedName) {
- this.termGuid = termGuid;
+ this.termGuid = termGuid;
this.qualifiedName = qualifiedName;
}
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder("AtlasGlossaryTermHeader{");
- sb.append("termGuid='").append(termGuid).append('\'');
- sb.append(", qualifiedName='").append(qualifiedName).append('\'');
- sb.append('}');
- return sb.toString();
- }
-
public AtlasGlossaryTermHeader() {
}
@@ -63,18 +54,29 @@ public class AtlasGlossaryTermHeader {
this.qualifiedName = qualifiedName;
}
+ @Override
+ public int hashCode() {
+ return Objects.hash(termGuid, qualifiedName);
+ }
+
@Override
public boolean equals(final Object o) {
- if (this == o) return true;
- if (!(o instanceof org.apache.atlas.model.glossary.AtlasGlossaryTermHeader)) return false;
- final org.apache.atlas.model.glossary.AtlasGlossaryTermHeader that = (org.apache.atlas.model.glossary.AtlasGlossaryTermHeader) o;
+ if (this == o) {
+ return true;
+ } else if (!(o instanceof org.apache.atlas.model.glossary.AtlasGlossaryTermHeader)) {
+ return false;
+ }
+
+ org.apache.atlas.model.glossary.AtlasGlossaryTermHeader that = (org.apache.atlas.model.glossary.AtlasGlossaryTermHeader) o;
+
return Objects.equals(termGuid, that.termGuid) &&
Objects.equals(qualifiedName, that.qualifiedName);
}
@Override
- public int hashCode() {
- return Objects.hash(termGuid, qualifiedName);
+ public String toString() {
+ return "AtlasGlossaryTermHeader{" + "termGuid='" + termGuid + '\'' +
+ ", qualifiedName='" + qualifiedName + '\'' +
+ '}';
}
-
}
diff --git a/intg/src/main/java/org/apache/atlas/model/glossary/enums/AtlasTermAssignmentStatus.java b/intg/src/main/java/org/apache/atlas/model/glossary/enums/AtlasTermAssignmentStatus.java
index 0753d0243..594cd9835 100644
--- a/intg/src/main/java/org/apache/atlas/model/glossary/enums/AtlasTermAssignmentStatus.java
+++ b/intg/src/main/java/org/apache/atlas/model/glossary/enums/AtlasTermAssignmentStatus.java
@@ -24,10 +24,9 @@ public enum AtlasTermAssignmentStatus {
VALIDATED(3),
DEPRECATED(4),
OBSOLETE(5),
- OTHER(6),
- ;
+ OTHER(6);
- private int value;
+ private final int value;
AtlasTermAssignmentStatus(final int value) {
this.value = value;
diff --git a/intg/src/main/java/org/apache/atlas/model/glossary/enums/AtlasTermRelationshipStatus.java b/intg/src/main/java/org/apache/atlas/model/glossary/enums/AtlasTermRelationshipStatus.java
index 4c31c6a81..e68c6b594 100644
--- a/intg/src/main/java/org/apache/atlas/model/glossary/enums/AtlasTermRelationshipStatus.java
+++ b/intg/src/main/java/org/apache/atlas/model/glossary/enums/AtlasTermRelationshipStatus.java
@@ -22,10 +22,9 @@ public enum AtlasTermRelationshipStatus {
ACTIVE(1),
DEPRECATED(2),
OBSOLETE(3),
- OTHER(99)
- ;
+ OTHER(99);
- private int value;
+ private final int value;
AtlasTermRelationshipStatus(final int value) {
this.value = value;
diff --git a/intg/src/main/java/org/apache/atlas/model/glossary/relations/AtlasGlossaryHeader.java b/intg/src/main/java/org/apache/atlas/model/glossary/relations/AtlasGlossaryHeader.java
index da1a3f1b7..c6267682e 100644
--- a/intg/src/main/java/org/apache/atlas/model/glossary/relations/AtlasGlossaryHeader.java
+++ b/intg/src/main/java/org/apache/atlas/model/glossary/relations/AtlasGlossaryHeader.java
@@ -51,28 +51,30 @@ public class AtlasGlossaryHeader {
}
@Override
- public boolean equals(final Object o) {
- if (this == o) return true;
- if (!(o instanceof AtlasGlossaryHeader)) return false;
- final AtlasGlossaryHeader that = (AtlasGlossaryHeader) o;
- return Objects.equals(glossaryGuid, that.glossaryGuid) &&
- Objects.equals(relationGuid, that.relationGuid);
+ public int hashCode() {
+ return Objects.hash(glossaryGuid, relationGuid);
}
@Override
- public int hashCode() {
+ public boolean equals(final Object o) {
+ if (this == o) {
+ return true;
+ } else if (!(o instanceof AtlasGlossaryHeader)) {
+ return false;
+ }
- return Objects.hash(glossaryGuid, relationGuid);
+ AtlasGlossaryHeader that = (AtlasGlossaryHeader) o;
+
+ return Objects.equals(glossaryGuid, that.glossaryGuid) &&
+ Objects.equals(relationGuid, that.relationGuid);
}
@Override
public String toString() {
- final StringBuilder sb = new StringBuilder("AtlasGlossaryId{");
- sb.append("glossaryGuid='").append(glossaryGuid).append('\'');
- sb.append(", relationGuid='").append(relationGuid).append('\'');
- sb.append(", displayText='").append(displayText).append('\'');
- sb.append('}');
- return sb.toString();
+ return "AtlasGlossaryId{" + "glossaryGuid='" + glossaryGuid + '\'' +
+ ", relationGuid='" + relationGuid + '\'' +
+ ", displayText='" + displayText + '\'' +
+ '}';
}
public String getRelationGuid() {
diff --git a/intg/src/main/java/org/apache/atlas/model/glossary/relations/AtlasRelatedCategoryHeader.java b/intg/src/main/java/org/apache/atlas/model/glossary/relations/AtlasRelatedCategoryHeader.java
index 596481a4a..ef93c51e2 100644
--- a/intg/src/main/java/org/apache/atlas/model/glossary/relations/AtlasRelatedCategoryHeader.java
+++ b/intg/src/main/java/org/apache/atlas/model/glossary/relations/AtlasRelatedCategoryHeader.java
@@ -57,35 +57,36 @@ public class AtlasRelatedCategoryHeader {
}
@Override
- public boolean equals(final Object o) {
- if (this == o) return true;
- if (!(o instanceof AtlasRelatedCategoryHeader)) return false;
- final AtlasRelatedCategoryHeader that = (AtlasRelatedCategoryHeader) o;
- return Objects.equals(categoryGuid, that.categoryGuid) &&
- Objects.equals(parentCategoryGuid, that.parentCategoryGuid) &&
- Objects.equals(relationGuid, that.relationGuid) &&
- Objects.equals(description, that.description);
+ public int hashCode() {
+ return Objects.hash(categoryGuid, parentCategoryGuid, relationGuid, description);
}
@Override
- public int hashCode() {
+ public boolean equals(final Object o) {
+ if (this == o) {
+ return true;
+ } else if (!(o instanceof AtlasRelatedCategoryHeader)) {
+ return false;
+ }
- return Objects.hash(categoryGuid, parentCategoryGuid, relationGuid, description);
+ AtlasRelatedCategoryHeader that = (AtlasRelatedCategoryHeader) o;
+
+ return Objects.equals(categoryGuid, that.categoryGuid) &&
+ Objects.equals(parentCategoryGuid, that.parentCategoryGuid) &&
+ Objects.equals(relationGuid, that.relationGuid) &&
+ Objects.equals(description, that.description);
}
@Override
public String toString() {
- final StringBuilder sb = new StringBuilder("AtlasRelatedCategoryId{");
- sb.append("categoryGuid='").append(categoryGuid).append('\'');
- sb.append(", parentCategoryGuid='").append(parentCategoryGuid).append('\'');
- sb.append(", relationGuid='").append(relationGuid).append('\'');
- sb.append(", displayText='").append(displayText).append('\'');
- sb.append(", description='").append(description).append('\'');
- sb.append('}');
- return sb.toString();
+ return "AtlasRelatedCategoryId{" + "categoryGuid='" + categoryGuid + '\'' +
+ ", parentCategoryGuid='" + parentCategoryGuid + '\'' +
+ ", relationGuid='" + relationGuid + '\'' +
+ ", displayText='" + displayText + '\'' +
+ ", description='" + description + '\'' +
+ '}';
}
-
public String getRelationGuid() {
return relationGuid;
}
diff --git a/intg/src/main/java/org/apache/atlas/model/glossary/relations/AtlasRelatedTermHeader.java b/intg/src/main/java/org/apache/atlas/model/glossary/relations/AtlasRelatedTermHeader.java
index 5cacefe6e..405a8cb20 100644
--- a/intg/src/main/java/org/apache/atlas/model/glossary/relations/AtlasRelatedTermHeader.java
+++ b/intg/src/main/java/org/apache/atlas/model/glossary/relations/AtlasRelatedTermHeader.java
@@ -33,7 +33,7 @@ public class AtlasRelatedTermHeader {
private String source;
private AtlasTermRelationshipStatus status;
- private String qualifiedName;
+ private String qualifiedName;
public AtlasRelatedTermHeader() {
}
@@ -87,39 +87,41 @@ public class AtlasRelatedTermHeader {
}
@Override
- public boolean equals(final Object o) {
- if (this == o) return true;
- if (!(o instanceof AtlasRelatedTermHeader)) return false;
- final AtlasRelatedTermHeader that = (AtlasRelatedTermHeader) o;
- return Objects.equals(termGuid, that.termGuid) &&
- Objects.equals(relationGuid, that.relationGuid) &&
- Objects.equals(description, that.description) &&
- Objects.equals(expression, that.expression) &&
- Objects.equals(steward, that.steward) &&
- Objects.equals(source, that.source) &&
- status == that.status;
+ public int hashCode() {
+ return Objects.hash(termGuid, relationGuid, description, expression, steward, source, status);
}
@Override
- public int hashCode() {
+ public boolean equals(final Object o) {
+ if (this == o) {
+ return true;
+ } else if (!(o instanceof AtlasRelatedTermHeader)) {
+ return false;
+ }
- return Objects.hash(termGuid, relationGuid, description, expression, steward, source, status);
+ AtlasRelatedTermHeader that = (AtlasRelatedTermHeader) o;
+
+ return Objects.equals(termGuid, that.termGuid) &&
+ Objects.equals(relationGuid, that.relationGuid) &&
+ Objects.equals(description, that.description) &&
+ Objects.equals(expression, that.expression) &&
+ Objects.equals(steward, that.steward) &&
+ Objects.equals(source, that.source) &&
+ status == that.status;
}
@Override
public String toString() {
- final StringBuffer sb = new StringBuffer("AtlasRelatedTermId{");
- sb.append("termGuid='").append(termGuid).append('\'');
- sb.append(", relationGuid='").append(relationGuid).append('\'');
- sb.append(", description='").append(description).append('\'');
- sb.append(", displayText='").append(displayText).append('\'');
- sb.append(", qualifiedName='").append(qualifiedName).append('\'');
- sb.append(", expression='").append(expression).append('\'');
- sb.append(", steward='").append(steward).append('\'');
- sb.append(", source='").append(source).append('\'');
- sb.append(", status=").append(status);
- sb.append('}');
- return sb.toString();
+ return "AtlasRelatedTermId{" + "termGuid='" + termGuid + '\'' +
+ ", relationGuid='" + relationGuid + '\'' +
+ ", description='" + description + '\'' +
+ ", displayText='" + displayText + '\'' +
+ ", qualifiedName='" + qualifiedName + '\'' +
+ ", expression='" + expression + '\'' +
+ ", steward='" + steward + '\'' +
+ ", source='" + source + '\'' +
+ ", status=" + status +
+ '}';
}
public String getDisplayText() {
@@ -137,7 +139,12 @@ public class AtlasRelatedTermHeader {
public void setRelationGuid(final String relationGuid) {
this.relationGuid = relationGuid;
}
- public String getQualifiedName() { return qualifiedName; }
- public void setQualifiedName(String qualifiedName) { this.qualifiedName = qualifiedName; }
+ public String getQualifiedName() {
+ return qualifiedName;
+ }
+
+ public void setQualifiedName(String qualifiedName) {
+ this.qualifiedName = qualifiedName;
+ }
}
diff --git a/intg/src/main/java/org/apache/atlas/model/glossary/relations/AtlasTermAssignmentHeader.java b/intg/src/main/java/org/apache/atlas/model/glossary/relations/AtlasTermAssignmentHeader.java
index ef9588920..e3f8ed4f0 100644
--- a/intg/src/main/java/org/apache/atlas/model/glossary/relations/AtlasTermAssignmentHeader.java
+++ b/intg/src/main/java/org/apache/atlas/model/glossary/relations/AtlasTermAssignmentHeader.java
@@ -24,17 +24,17 @@ import java.util.Objects;
@AtlasJSON
public class AtlasTermAssignmentHeader {
- private String termGuid;
- private String relationGuid;
- private String description;
- private String displayText;
- private String expression;
- private String createdBy;
- private String steward;
- private String source;
- private int confidence;
+ private String termGuid;
+ private String relationGuid;
+ private String description;
+ private String displayText;
+ private String expression;
+ private String createdBy;
+ private String steward;
+ private String source;
+ private int confidence;
private AtlasTermAssignmentStatus status;
- private String qualifiedName;
+ private String qualifiedName;
public AtlasTermAssignmentHeader() {
}
@@ -111,51 +111,56 @@ public class AtlasTermAssignmentHeader {
this.displayText = displayText;
}
- public String getQualifiedName() { return qualifiedName; }
+ public String getQualifiedName() {
+ return qualifiedName;
+ }
- public void setQualifiedName(String qualifiedName) { this.qualifiedName = qualifiedName; }
+ public void setQualifiedName(String qualifiedName) {
+ this.qualifiedName = qualifiedName;
+ }
@Override
- public boolean equals(final Object o) {
- if (this == o) return true;
- if (!(o instanceof AtlasTermAssignmentHeader)) return false;
- final AtlasTermAssignmentHeader that = (AtlasTermAssignmentHeader) o;
- return confidence == that.confidence &&
- Objects.equals(termGuid, that.termGuid) &&
- Objects.equals(relationGuid, that.relationGuid) &&
- Objects.equals(description, that.description) &&
- Objects.equals(expression, that.expression) &&
- Objects.equals(createdBy, that.createdBy) &&
- Objects.equals(steward, that.steward) &&
- Objects.equals(source, that.source) &&
- status == that.status;
+ public int hashCode() {
+ return Objects.hash(termGuid, relationGuid, description, expression, createdBy, steward, source, confidence, status);
}
@Override
- public int hashCode() {
+ public boolean equals(final Object o) {
+ if (this == o) {
+ return true;
+ } else if (!(o instanceof AtlasTermAssignmentHeader)) {
+ return false;
+ }
- return Objects.hash(termGuid, relationGuid, description, expression, createdBy, steward, source, confidence, status);
+ AtlasTermAssignmentHeader that = (AtlasTermAssignmentHeader) o;
+
+ return confidence == that.confidence &&
+ Objects.equals(termGuid, that.termGuid) &&
+ Objects.equals(relationGuid, that.relationGuid) &&
+ Objects.equals(description, that.description) &&
+ Objects.equals(expression, that.expression) &&
+ Objects.equals(createdBy, that.createdBy) &&
+ Objects.equals(steward, that.steward) &&
+ Objects.equals(source, that.source) &&
+ status == that.status;
}
@Override
public String toString() {
- final StringBuilder sb = new StringBuilder("AtlasTermAssignmentId{");
- sb.append("termGuid='").append(termGuid).append('\'');
- sb.append(", relationGuid='").append(relationGuid).append('\'');
- sb.append(", description='").append(description).append('\'');
- sb.append(", displayText='").append(displayText).append('\'');
- sb.append(", qualifiedName='").append(qualifiedName).append('\'');
- sb.append(", expression='").append(expression).append('\'');
- sb.append(", createdBy='").append(createdBy).append('\'');
- sb.append(", steward='").append(steward).append('\'');
- sb.append(", source='").append(source).append('\'');
- sb.append(", confidence=").append(confidence).append('\'');;
- sb.append(", status=").append(status);
- sb.append('}');
- return sb.toString();
+ return "AtlasTermAssignmentId{" + "termGuid='" + termGuid + '\'' +
+ ", relationGuid='" + relationGuid + '\'' +
+ ", description='" + description + '\'' +
+ ", displayText='" + displayText + '\'' +
+ ", qualifiedName='" + qualifiedName + '\'' +
+ ", expression='" + expression + '\'' +
+ ", createdBy='" + createdBy + '\'' +
+ ", steward='" + steward + '\'' +
+ ", source='" + source + '\'' +
+ ", confidence=" + confidence + '\'' +
+ ", status=" + status +
+ '}';
}
-
public String getRelationGuid() {
return relationGuid;
}
diff --git a/intg/src/main/java/org/apache/atlas/model/glossary/relations/AtlasTermCategorizationHeader.java b/intg/src/main/java/org/apache/atlas/model/glossary/relations/AtlasTermCategorizationHeader.java
index 7c6008beb..23c249708 100644
--- a/intg/src/main/java/org/apache/atlas/model/glossary/relations/AtlasTermCategorizationHeader.java
+++ b/intg/src/main/java/org/apache/atlas/model/glossary/relations/AtlasTermCategorizationHeader.java
@@ -67,35 +67,36 @@ public class AtlasTermCategorizationHeader {
}
@Override
- public boolean equals(final Object o) {
- if (this == o) return true;
- if (!(o instanceof AtlasTermCategorizationHeader)) return false;
- final AtlasTermCategorizationHeader that = (AtlasTermCategorizationHeader) o;
- return Objects.equals(categoryGuid, that.categoryGuid) &&
- Objects.equals(relationGuid, that.relationGuid) &&
- Objects.equals(description, that.description) &&
- status == that.status;
+ public int hashCode() {
+ return Objects.hash(categoryGuid, relationGuid, description, status);
}
@Override
- public int hashCode() {
+ public boolean equals(final Object o) {
+ if (this == o) {
+ return true;
+ } else if (!(o instanceof AtlasTermCategorizationHeader)) {
+ return false;
+ }
- return Objects.hash(categoryGuid, relationGuid, description, status);
+ AtlasTermCategorizationHeader that = (AtlasTermCategorizationHeader) o;
+
+ return Objects.equals(categoryGuid, that.categoryGuid) &&
+ Objects.equals(relationGuid, that.relationGuid) &&
+ Objects.equals(description, that.description) &&
+ status == that.status;
}
@Override
public String toString() {
- final StringBuilder sb = new StringBuilder("AtlasTermCategorizationId{");
- sb.append("categoryGuid='").append(categoryGuid).append('\'');
- sb.append(", relationGuid='").append(relationGuid).append('\'');
- sb.append(", description='").append(description).append('\'');
- sb.append(", displayText='").append(displayText).append('\'');
- sb.append(", status=").append(status);
- sb.append('}');
- return sb.toString();
+ return "AtlasTermCategorizationId{" + "categoryGuid='" + categoryGuid + '\'' +
+ ", relationGuid='" + relationGuid + '\'' +
+ ", description='" + description + '\'' +
+ ", displayText='" + displayText + '\'' +
+ ", status=" + status +
+ '}';
}
-
public String getRelationGuid() {
return relationGuid;
}
diff --git a/intg/src/main/java/org/apache/atlas/model/impexp/AtlasExportRequest.java b/intg/src/main/java/org/apache/atlas/model/impexp/AtlasExportRequest.java
index fc4d11d54..504e19bad 100644
--- a/intg/src/main/java/org/apache/atlas/model/impexp/AtlasExportRequest.java
+++ b/intg/src/main/java/org/apache/atlas/model/impexp/AtlasExportRequest.java
@@ -17,11 +17,10 @@
*/
package org.apache.atlas.model.impexp;
-
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.atlas.model.instance.AtlasObjectId;
import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
import org.apache.commons.collections.MapUtils;
@@ -30,6 +29,7 @@ import org.apache.commons.lang.StringUtils;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
+
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
@@ -39,34 +39,32 @@ import java.util.Map;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
-
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class AtlasExportRequest implements Serializable {
-
private static final long serialVersionUID = 1L;
- public static final String OPTION_FETCH_TYPE = "fetchType";
- public static final String OPTION_ATTR_MATCH_TYPE = "matchType";
- public static final String OPTION_SKIP_LINEAGE = "skipLineage";
- public static final String OPTION_KEY_REPLICATED_TO = "replicatedTo";
+ public static final String OPTION_FETCH_TYPE = "fetchType";
+ public static final String OPTION_ATTR_MATCH_TYPE = "matchType";
+ public static final String OPTION_SKIP_LINEAGE = "skipLineage";
+ public static final String OPTION_KEY_REPLICATED_TO = "replicatedTo";
public static final String OPTION_KEY_SKIP_UPDATE_REPLICATION_ATTR = "skipUpdateReplicationAttr";
- public static final String FETCH_TYPE_FULL = "full";
- public static final String FETCH_TYPE_CONNECTED = "connected";
- public static final String FETCH_TYPE_INCREMENTAL = "incremental";
- public static final String FETCH_TYPE_INCREMENTAL_CHANGE_MARKER = "changeMarker";
- public static final String MATCH_TYPE_STARTS_WITH = "startsWith";
- public static final String MATCH_TYPE_ENDS_WITH = "endsWith";
- public static final String MATCH_TYPE_CONTAINS = "contains";
- public static final String MATCH_TYPE_MATCHES = "matches";
- public static final String MATCH_TYPE_FOR_TYPE = "forType";
- public static final String OMIT_ZIP_RESPONSE_FOR_EMPTY_EXPORT = "omitZipResponseForEmptyExport";
+ public static final String FETCH_TYPE_FULL = "full";
+ public static final String FETCH_TYPE_CONNECTED = "connected";
+ public static final String FETCH_TYPE_INCREMENTAL = "incremental";
+ public static final String FETCH_TYPE_INCREMENTAL_CHANGE_MARKER = "changeMarker";
+ public static final String MATCH_TYPE_STARTS_WITH = "startsWith";
+ public static final String MATCH_TYPE_ENDS_WITH = "endsWith";
+ public static final String MATCH_TYPE_CONTAINS = "contains";
+ public static final String MATCH_TYPE_MATCHES = "matches";
+ public static final String MATCH_TYPE_FOR_TYPE = "forType";
+ public static final String OMIT_ZIP_RESPONSE_FOR_EMPTY_EXPORT = "omitZipResponseForEmptyExport";
private List<AtlasObjectId> itemsToExport = new ArrayList<>();
- private Map<String, Object> options = new HashMap<>();
+ private Map<String, Object> options = new HashMap<>();
public List<AtlasObjectId> getItemsToExport() {
return itemsToExport;
@@ -90,6 +88,7 @@ public class AtlasExportRequest implements Serializable {
}
Object o = getOptions().get(OPTION_FETCH_TYPE);
+
if (o instanceof String) {
return (String) o;
}
@@ -98,17 +97,15 @@ public class AtlasExportRequest implements Serializable {
}
public boolean getSkipLineageOptionValue() {
- if (MapUtils.isEmpty(getOptions()) ||
- !getOptions().containsKey(AtlasExportRequest.OPTION_SKIP_LINEAGE)) {
+ if (MapUtils.isEmpty(getOptions()) || !getOptions().containsKey(AtlasExportRequest.OPTION_SKIP_LINEAGE)) {
return false;
}
Object o = getOptions().get(AtlasExportRequest.OPTION_SKIP_LINEAGE);
+
if (o instanceof String) {
return Boolean.parseBoolean((String) o);
- }
-
- if (o instanceof Boolean) {
+ } else if (o instanceof Boolean) {
return (Boolean) o;
}
@@ -128,9 +125,7 @@ public class AtlasExportRequest implements Serializable {
}
public long getChangeTokenFromOptions() {
- if (MapUtils.isEmpty(getOptions()) ||
- !getFetchTypeOptionValue().equalsIgnoreCase(FETCH_TYPE_INCREMENTAL) ||
- !getOptions().containsKey(AtlasExportRequest.FETCH_TYPE_INCREMENTAL_CHANGE_MARKER)) {
+ if (MapUtils.isEmpty(getOptions()) || !getFetchTypeOptionValue().equalsIgnoreCase(FETCH_TYPE_INCREMENTAL) || !getOptions().containsKey(AtlasExportRequest.FETCH_TYPE_INCREMENTAL_CHANGE_MARKER)) {
return 0L;
}
@@ -145,17 +140,15 @@ public class AtlasExportRequest implements Serializable {
@JsonIgnore
public boolean skipUpdateReplicationAttr() {
if (MapUtils.isNotEmpty(getOptions()) && getOptions().containsKey(OPTION_KEY_SKIP_UPDATE_REPLICATION_ATTR)) {
-
Object o = getOptions().get(AtlasExportRequest.OPTION_KEY_SKIP_UPDATE_REPLICATION_ATTR);
+
if (o instanceof String) {
return Boolean.parseBoolean((String) o);
- }
-
- if (o instanceof Boolean) {
+ } else if (o instanceof Boolean) {
return (Boolean) o;
}
-
}
+
return false;
}
@@ -171,18 +164,15 @@ public class AtlasExportRequest implements Serializable {
}
public Boolean getOmitZipResponseForEmptyExport() {
-
- if (MapUtils.isEmpty(getOptions()) ||
- !getOptions().containsKey(AtlasExportRequest.OMIT_ZIP_RESPONSE_FOR_EMPTY_EXPORT)) {
+ if (MapUtils.isEmpty(getOptions()) || !getOptions().containsKey(AtlasExportRequest.OMIT_ZIP_RESPONSE_FOR_EMPTY_EXPORT)) {
return false;
}
Object o = getOptions().get(AtlasExportRequest.OMIT_ZIP_RESPONSE_FOR_EMPTY_EXPORT);
+
if (o instanceof String) {
return Boolean.parseBoolean((String) o);
- }
-
- if (o instanceof Boolean) {
+ } else if (o instanceof Boolean) {
return (Boolean) o;
}
diff --git a/intg/src/main/java/org/apache/atlas/model/impexp/AtlasExportResult.java b/intg/src/main/java/org/apache/atlas/model/impexp/AtlasExportResult.java
index c1431208d..ee38f4f9a 100644
--- a/intg/src/main/java/org/apache/atlas/model/impexp/AtlasExportResult.java
+++ b/intg/src/main/java/org/apache/atlas/model/impexp/AtlasExportResult.java
@@ -6,9 +6,9 @@
* 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.
@@ -17,18 +17,16 @@
*/
package org.apache.atlas.model.impexp;
-
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-
-import org.apache.atlas.model.instance.AtlasEntity;
+import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
import org.apache.atlas.model.typedef.AtlasTypesDef;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
+
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
@@ -38,20 +36,15 @@ import java.util.Map;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
-
-@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown=true)
+@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class AtlasExportResult implements Serializable {
private static final long serialVersionUID = 1L;
- public final static String ENTITY_COUNT = "entityCount";
-
- public enum OperationStatus {
- SUCCESS, PARTIAL_SUCCESS, INPROGRESS, FAIL
- }
+ public static final String ENTITY_COUNT = "entityCount";
private AtlasExportRequest request;
private String userName;
@@ -68,9 +61,7 @@ public class AtlasExportResult implements Serializable {
this(null, null, null, null, System.currentTimeMillis(), 0L);
}
- public AtlasExportResult(AtlasExportRequest request,
- String userName, String clientIpAddress, String hostName, long timeStamp,
- long changeMarker) {
+ public AtlasExportResult(AtlasExportRequest request, String userName, String clientIpAddress, String hostName, long timeStamp, long changeMarker) {
this.request = request;
this.userName = userName;
this.clientIpAddress = clientIpAddress;
@@ -138,14 +129,14 @@ public class AtlasExportResult implements Serializable {
this.data = data;
}
- public void setChangeMarker(long changeMarker) {
- this.changeMarker = changeMarker;
- }
-
public long getChangeMarker() {
return this.changeMarker;
}
+ public void setChangeMarker(long changeMarker) {
+ this.changeMarker = changeMarker;
+ }
+
public OperationStatus getOperationStatus() {
return operationStatus;
}
@@ -157,6 +148,7 @@ public class AtlasExportResult implements Serializable {
public void setMetric(String key, int value) {
metrics.put(key, value);
}
+
public String getSourceClusterName() {
return sourceClusterName;
}
@@ -170,7 +162,7 @@ public class AtlasExportResult implements Serializable {
}
public void incrementMeticsCounter(String key, int incrementBy) {
- int currentValue = metrics.containsKey(key) ? metrics.get(key) : 0;
+ int currentValue = metrics.getOrDefault(key, 0);
metrics.put(key, currentValue + incrementBy);
}
@@ -204,39 +196,50 @@ public class AtlasExportResult implements Serializable {
}
public void clear() {
- if(this.data != null) {
+ if (this.data != null) {
this.data.clear();
}
- if(this.metrics != null) {
+ if (this.metrics != null) {
this.metrics.clear();
}
}
- @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
- @JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
- @JsonIgnoreProperties(ignoreUnknown=true)
+ public enum OperationStatus {
+ SUCCESS, PARTIAL_SUCCESS, INPROGRESS, FAIL
+ }
+
+ @JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ @JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
- public static class AtlasExportData implements Serializable{
+ public static class AtlasExportData implements Serializable {
private static final long serialVersionUID = 1L;
- private AtlasTypesDef typesDef;
- private List<String> entityCreationOrder;
-
+ private AtlasTypesDef typesDef;
+ private List<String> entityCreationOrder;
public AtlasExportData() {
typesDef = new AtlasTypesDef();
entityCreationOrder = new ArrayList<>();
}
- public AtlasTypesDef getTypesDef() { return typesDef; }
+ public AtlasTypesDef getTypesDef() {
+ return typesDef;
+ }
- public void setTypesDef(AtlasTypesDef typesDef) { this.typesDef = typesDef; }
+ public void setTypesDef(AtlasTypesDef typesDef) {
+ this.typesDef = typesDef;
+ }
- public List<String> getEntityCreationOrder() { return entityCreationOrder; }
+ public List<String> getEntityCreationOrder() {
+ return entityCreationOrder;
+ }
- public void setEntityCreationOrder(List<String> entityCreationOrder) { this.entityCreationOrder = entityCreationOrder; }
+ public void setEntityCreationOrder(List<String> entityCreationOrder) {
+ this.entityCreationOrder = entityCreationOrder;
+ }
public StringBuilder toString(StringBuilder sb) {
if (sb == null) {
@@ -261,13 +264,13 @@ public class AtlasExportResult implements Serializable {
}
public void clear() {
- if(this.typesDef!= null) {
+ if (this.typesDef != null) {
this.typesDef.clear();
}
- if(this.entityCreationOrder != null) {
+ if (this.entityCreationOrder != null) {
this.entityCreationOrder.clear();
}
}
}
-}
\ No newline at end of file
+}
diff --git a/intg/src/main/java/org/apache/atlas/model/impexp/AtlasImportRequest.java b/intg/src/main/java/org/apache/atlas/model/impexp/AtlasImportRequest.java
index 12945ca2a..8809b050d 100644
--- a/intg/src/main/java/org/apache/atlas/model/impexp/AtlasImportRequest.java
+++ b/intg/src/main/java/org/apache/atlas/model/impexp/AtlasImportRequest.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -21,8 +21,7 @@ import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-
+import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.StringUtils;
@@ -34,27 +33,28 @@ import java.util.Map;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
-@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown=true)
+@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
public class AtlasImportRequest implements Serializable {
- private static final long serialVersionUID = 1L;
-
- public static final String TRANSFORMS_KEY = "transforms";
- public static final String TRANSFORMERS_KEY = "transformers";
- public static final String OPTION_KEY_REPLICATED_FROM = "replicatedFrom";
- public static final String OPTION_KEY_SKIP_UPDATE_REPLICATION_ATTR = "skipUpdateReplicationAttr";
- public static final String OPTION_KEY_MIGRATION_FILE_NAME = "migrationFileName";
- public static final String OPTION_KEY_MIGRATION = "migration";
- public static final String OPTION_KEY_NUM_WORKERS = "numWorkers";
- public static final String OPTION_KEY_BATCH_SIZE = "batchSize";
- public static final String OPTION_KEY_FORMAT = "format";
- public static final String OPTION_KEY_FORMAT_ZIP_DIRECT = "zipDirect";
- public static final String START_POSITION_KEY = "startPosition";
- public static final String UPDATE_TYPE_DEFINITION_KEY = "updateTypeDefinition";
- private static final String START_GUID_KEY = "startGuid";
- private static final String FILE_NAME_KEY = "fileName";
- private static final String OPTION_KEY_STREAM_SIZE = "size";
+ private static final long serialVersionUID = 1L;
+
+ public static final String TRANSFORMS_KEY = "transforms";
+ public static final String TRANSFORMERS_KEY = "transformers";
+ public static final String OPTION_KEY_REPLICATED_FROM = "replicatedFrom";
+ public static final String OPTION_KEY_SKIP_UPDATE_REPLICATION_ATTR = "skipUpdateReplicationAttr";
+ public static final String OPTION_KEY_MIGRATION_FILE_NAME = "migrationFileName";
+ public static final String OPTION_KEY_MIGRATION = "migration";
+ public static final String OPTION_KEY_NUM_WORKERS = "numWorkers";
+ public static final String OPTION_KEY_BATCH_SIZE = "batchSize";
+ public static final String OPTION_KEY_FORMAT = "format";
+ public static final String OPTION_KEY_FORMAT_ZIP_DIRECT = "zipDirect";
+ public static final String START_POSITION_KEY = "startPosition";
+ public static final String UPDATE_TYPE_DEFINITION_KEY = "updateTypeDefinition";
+
+ private static final String START_GUID_KEY = "startGuid";
+ private static final String FILE_NAME_KEY = "fileName";
+ private static final String OPTION_KEY_STREAM_SIZE = "size";
private Map<String, String> options;
@@ -62,9 +62,13 @@ public class AtlasImportRequest implements Serializable {
this.options = new HashMap<>();
}
- public Map<String, String> getOptions() { return options; }
+ public Map<String, String> getOptions() {
+ return options;
+ }
- public void setOptions(Map<String, String> options) { this.options = options; }
+ public void setOptions(Map<String, String> options) {
+ this.options = options;
+ }
public StringBuilder toString(StringBuilder sb) {
if (sb == null) {
@@ -110,14 +114,6 @@ public class AtlasImportRequest implements Serializable {
return getOptionForKey(UPDATE_TYPE_DEFINITION_KEY);
}
- private String getOptionForKey(String key) {
- if (MapUtils.isEmpty(this.options) || !this.options.containsKey(key)) {
- return null;
- }
-
- return this.options.get(key);
- }
-
@JsonIgnore
public boolean isReplicationOptionSet() {
return MapUtils.isNotEmpty(options) && options.containsKey(OPTION_KEY_REPLICATED_FROM);
@@ -126,17 +122,13 @@ public class AtlasImportRequest implements Serializable {
@JsonIgnore
public boolean skipUpdateReplicationAttr() {
if (MapUtils.isNotEmpty(getOptions()) && getOptions().containsKey(OPTION_KEY_SKIP_UPDATE_REPLICATION_ATTR)) {
+ String o = getOptions().get(AtlasExportRequest.OPTION_KEY_SKIP_UPDATE_REPLICATION_ATTR);
- Object o = getOptions().get(AtlasExportRequest.OPTION_KEY_SKIP_UPDATE_REPLICATION_ATTR);
- if (o instanceof String) {
- return Boolean.parseBoolean((String) o);
- }
-
- if (o instanceof Boolean) {
- return (Boolean) o;
+ if (o != null) {
+ return Boolean.parseBoolean(o);
}
-
}
+
return false;
}
@@ -155,31 +147,38 @@ public class AtlasImportRequest implements Serializable {
return getOptionsValue(OPTION_KEY_BATCH_SIZE, 1);
}
- private int getOptionsValue(String optionKeyBatchSize, int defaultValue) {
- String optionsValue = getOptionForKey(optionKeyBatchSize);
-
- return StringUtils.isEmpty(optionsValue) ?
- defaultValue :
- Integer.valueOf(optionsValue);
- }
-
@JsonAnySetter
public void setOption(String key, String value) {
if (null == options) {
options = new HashMap<>();
}
+
options.put(key, value);
}
+ public int getSizeOption() {
+ if (!this.options.containsKey(OPTION_KEY_STREAM_SIZE)) {
+ return 1;
+ }
+
+ return Integer.parseInt(this.options.get(OPTION_KEY_STREAM_SIZE));
+ }
+
public void setSizeOption(int size) {
setOption(OPTION_KEY_STREAM_SIZE, Integer.toString(size));
}
- public int getSizeOption() {
- if (!this.options.containsKey(OPTION_KEY_STREAM_SIZE)) {
- return 1;
+ private String getOptionForKey(String key) {
+ if (MapUtils.isEmpty(this.options) || !this.options.containsKey(key)) {
+ return null;
}
- return Integer.valueOf(this.options.get(OPTION_KEY_STREAM_SIZE));
+ return this.options.get(key);
+ }
+
+ private int getOptionsValue(String optionKeyBatchSize, int defaultValue) {
+ String optionsValue = getOptionForKey(optionKeyBatchSize);
+
+ return StringUtils.isEmpty(optionsValue) ? defaultValue : Integer.parseInt(optionsValue);
}
}
diff --git a/intg/src/main/java/org/apache/atlas/model/impexp/AtlasImportResult.java b/intg/src/main/java/org/apache/atlas/model/impexp/AtlasImportResult.java
index 212517baa..4c1a7159a 100644
--- a/intg/src/main/java/org/apache/atlas/model/impexp/AtlasImportResult.java
+++ b/intg/src/main/java/org/apache/atlas/model/impexp/AtlasImportResult.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -18,16 +18,16 @@
package org.apache.atlas.model.impexp;
-
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-
+import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
+
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -36,18 +36,14 @@ import java.util.Map;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
-@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown=true)
+@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
-public class AtlasImportResult {
+public class AtlasImportResult implements Serializable {
private static final long serialVersionUID = 1L;
- public enum OperationStatus {
- SUCCESS, PARTIAL_SUCCESS, FAIL
- }
-
private AtlasImportRequest request;
private String userName;
private String clientIpAddress;
@@ -62,8 +58,7 @@ public class AtlasImportResult {
this(null, null, null, null, System.currentTimeMillis());
}
- public AtlasImportResult(AtlasImportRequest request, String userName,
- String clientIpAddress, String hostName, long timeStamp) {
+ public AtlasImportResult(AtlasImportRequest request, String userName, String clientIpAddress, String hostName, long timeStamp) {
this.request = request;
this.userName = userName;
this.clientIpAddress = clientIpAddress;
@@ -135,14 +130,18 @@ public class AtlasImportResult {
}
public void incrementMeticsCounter(String key, int incrementBy) {
- int currentValue = metrics.containsKey(key) ? metrics.get(key) : 0;
+ int currentValue = metrics.getOrDefault(key, 0);
metrics.put(key, currentValue + incrementBy);
}
- public void setProcessedEntities(List<String> processedEntities) { this.processedEntities = processedEntities; }
+ public List<String> getProcessedEntities() {
+ return this.processedEntities;
+ }
- public List<String> getProcessedEntities() { return this.processedEntities; }
+ public void setProcessedEntities(List<String> processedEntities) {
+ this.processedEntities = processedEntities;
+ }
public AtlasExportResult getExportResult() {
return exportResultWithoutData;
@@ -180,4 +179,8 @@ public class AtlasImportResult {
public String toString() {
return toString(new StringBuilder()).toString();
}
+
+ public enum OperationStatus {
+ SUCCESS, PARTIAL_SUCCESS, FAIL
+ }
}
diff --git a/intg/src/main/java/org/apache/atlas/model/impexp/AtlasServer.java b/intg/src/main/java/org/apache/atlas/model/impexp/AtlasServer.java
index 517a23eaf..0360b1988 100644
--- a/intg/src/main/java/org/apache/atlas/model/impexp/AtlasServer.java
+++ b/intg/src/main/java/org/apache/atlas/model/impexp/AtlasServer.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -19,7 +19,7 @@ package org.apache.atlas.model.impexp;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.atlas.model.AtlasBaseModelObject;
import org.apache.atlas.type.AtlasType;
@@ -33,7 +33,7 @@ import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class AtlasServer extends AtlasBaseModelObject implements Serializable {
private static final long serialVersionUID = 1L;
@@ -59,14 +59,14 @@ public class AtlasServer extends AtlasBaseModelObject implements Serializable {
this.fullName = fullName;
}
- public void setName(String name) {
- this.name = name;
- }
-
public String getName() {
return this.name;
}
+ public void setName(String name) {
+ this.name = name;
+ }
+
public String getFullName() {
return fullName;
}
@@ -83,26 +83,25 @@ public class AtlasServer extends AtlasBaseModelObject implements Serializable {
this.displayName = displayName;
}
- public void setAdditionalInfo(Map<String, String> additionalInfo) {
- this.additionalInfo = additionalInfo;
- }
-
public Map<String, String> getAdditionalInfo() {
return this.additionalInfo;
}
- public String getAdditionalInfo(String key) {
- return additionalInfo.get(key);
+ public void setAdditionalInfo(Map<String, String> additionalInfo) {
+ this.additionalInfo = additionalInfo;
}
- public void setUrls(List<String> urls) {
- this.urls = urls;
+ public String getAdditionalInfo(String key) {
+ return additionalInfo.get(key);
}
public List<String> getUrls() {
return this.urls;
}
+ public void setUrls(List<String> urls) {
+ this.urls = urls;
+ }
public void setAdditionalInfo(String key, String value) {
if (additionalInfo == null) {
diff --git a/intg/src/main/java/org/apache/atlas/model/impexp/AttributeTransform.java b/intg/src/main/java/org/apache/atlas/model/impexp/AttributeTransform.java
index 621f5f3a0..e0f4dde72 100644
--- a/intg/src/main/java/org/apache/atlas/model/impexp/AttributeTransform.java
+++ b/intg/src/main/java/org/apache/atlas/model/impexp/AttributeTransform.java
@@ -17,14 +17,15 @@
*/
package org.apache.atlas.model.impexp;
-import org.apache.commons.lang.StringUtils;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import org.apache.commons.lang.StringUtils;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
+
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
@@ -32,17 +33,16 @@ import java.util.Map;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
-
-@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown=true)
+@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class AttributeTransform implements Serializable {
private Map<String, String> conditions;
private Map<String, String> action;
- public AttributeTransform() { }
+ public AttributeTransform() {}
public AttributeTransform(Map<String, String> conditions, Map<String, String> action) {
this.conditions = conditions;
@@ -84,4 +84,4 @@ public class AttributeTransform implements Serializable {
action.put(attributeName, actionValue);
}
}
-}
\ No newline at end of file
+}
diff --git a/intg/src/main/java/org/apache/atlas/model/impexp/ExportImportAuditEntry.java b/intg/src/main/java/org/apache/atlas/model/impexp/ExportImportAuditEntry.java
index 90f4296f5..be2cfbde2 100644
--- a/intg/src/main/java/org/apache/atlas/model/impexp/ExportImportAuditEntry.java
+++ b/intg/src/main/java/org/apache/atlas/model/impexp/ExportImportAuditEntry.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -20,7 +20,7 @@ package org.apache.atlas.model.impexp;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.atlas.model.AtlasBaseModelObject;
import java.io.Serializable;
@@ -29,30 +29,30 @@ import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ExportImportAuditEntry extends AtlasBaseModelObject implements Serializable {
private static final long serialVersionUID = 1L;
- public static final String OPERATION_EXPORT = "EXPORT";
- public static final String OPERATION_IMPORT = "IMPORT";
+
+ public static final String OPERATION_EXPORT = "EXPORT";
+ public static final String OPERATION_IMPORT = "IMPORT";
public static final String OPERATION_IMPORT_DELETE_REPL = "IMPORT_DELETE_REPL";
private String userName;
private String operation;
private String operationParams;
- private long startTime;
- private long endTime;
+ private long startTime;
+ private long endTime;
private String resultSummary;
private String sourceClusterName;
private String targetClusterName;
public ExportImportAuditEntry() {
-
}
public ExportImportAuditEntry(String sourceClusterName, String operation) {
this.sourceClusterName = sourceClusterName;
- this.operation = operation;
+ this.operation = operation;
}
public String getOperation() {
@@ -63,41 +63,46 @@ public class ExportImportAuditEntry extends AtlasBaseModelObject implements Seri
this.operation = operation;
}
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
public String getUserName() {
return this.userName;
}
- public void setOperationParams(String operationParams) {
- this.operationParams = operationParams;
+
+ public void setUserName(String userName) {
+ this.userName = userName;
}
public String getOperationParams() {
return this.operationParams;
}
- public void setStartTime(long startTime) {
- this.startTime = startTime;
+ public void setOperationParams(String operationParams) {
+ this.operationParams = operationParams;
}
public long getStartTime() {
return startTime;
}
- public void setEndTime(long endTime) {
- this.endTime = endTime;
+ public void setStartTime(long startTime) {
+ this.startTime = startTime;
}
public long getEndTime() {
return this.endTime;
}
+ public void setEndTime(long endTime) {
+ this.endTime = endTime;
+ }
+
public String getTargetServerName() {
return this.targetClusterName;
}
+ public void setTargetServerName(String targetClusterName) {
+ this.targetClusterName = targetClusterName;
+ }
+
public String getSourceServerName() {
return this.sourceClusterName;
}
@@ -106,10 +111,6 @@ public class ExportImportAuditEntry extends AtlasBaseModelObject implements Seri
this.sourceClusterName = sourceClusterName;
}
- public void setTargetServerName(String targetClusterName) {
- this.targetClusterName = targetClusterName;
- }
-
public String getResultSummary() {
return resultSummary;
}
diff --git a/intg/src/main/java/org/apache/atlas/model/impexp/MigrationStatus.java b/intg/src/main/java/org/apache/atlas/model/impexp/MigrationStatus.java
index 0a92c5e6f..7b31a6576 100644
--- a/intg/src/main/java/org/apache/atlas/model/impexp/MigrationStatus.java
+++ b/intg/src/main/java/org/apache/atlas/model/impexp/MigrationStatus.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -20,7 +20,7 @@ package org.apache.atlas.model.impexp;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.annotation.JsonInclude;
import java.io.Serializable;
import java.util.Date;
@@ -29,7 +29,7 @@ import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class MigrationStatus implements Serializable {
private static final long serialVersionUID = 1L;
@@ -41,53 +41,55 @@ public class MigrationStatus implements Serializable {
private long currentCounter;
private long totalCount;
+ public String getOperationStatus() {
+ return operationStatus;
+ }
+
public void setOperationStatus(String operationStatus) {
this.operationStatus = operationStatus;
}
- public String getOperationStatus() {
- return operationStatus;
+ public Date getStartTime() {
+ return startTime;
}
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
- public Date getStartTime() {
- return startTime;
+ public Date getEndTime() {
+ return endTime;
}
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
- public Date getEndTime() {
- return endTime;
+ public long getCurrentIndex() {
+ return currentIndex;
}
public void setCurrentIndex(long currentIndex) {
this.currentIndex = currentIndex;
}
- public long getCurrentIndex() {
- return currentIndex;
+ public long getTotalCount() {
+ return this.totalCount;
}
public void setTotalCount(long totalCount) {
this.totalCount = totalCount;
}
- public long getTotalCount() {
- return this.totalCount;
+ public Long getCurrentCounter() {
+ return this.currentCounter;
}
public void setCurrentCounter(long value) {
this.currentCounter = value;
}
- public Long getCurrentCounter() { return this.currentCounter; }
-
- public StringBuilder toString(StringBuilder sb) {
+ public StringBuilder toString(StringBuilder sb) {
sb.append(", operationStatus=").append(operationStatus);
sb.append(", startTime=").append(startTime);
sb.append(", endTime=").append(endTime);
diff --git a/intg/src/main/java/org/apache/atlas/model/instance/AtlasCheckStateRequest.java b/intg/src/main/java/org/apache/atlas/model/instance/AtlasCheckStateRequest.java
index d3878bb2a..739c0254b 100644
--- a/intg/src/main/java/org/apache/atlas/model/instance/AtlasCheckStateRequest.java
+++ b/intg/src/main/java/org/apache/atlas/model/instance/AtlasCheckStateRequest.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -17,27 +17,27 @@
*/
package org.apache.atlas.model.instance;
-import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
+
import java.io.Serializable;
import java.util.Set;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
-
/**
* Request to run state-check of entities
*/
-@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown=true)
+@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class AtlasCheckStateRequest implements Serializable {
@@ -47,7 +47,6 @@ public class AtlasCheckStateRequest implements Serializable {
private Set<String> entityTypes;
private boolean fixIssues;
-
public AtlasCheckStateRequest() {
}
@@ -75,7 +74,6 @@ public class AtlasCheckStateRequest implements Serializable {
this.fixIssues = fixIssues;
}
-
public StringBuilder toString(StringBuilder sb) {
if (sb == null) {
sb = new StringBuilder();
diff --git a/intg/src/main/java/org/apache/atlas/model/instance/AtlasCheckStateResult.java b/intg/src/main/java/org/apache/atlas/model/instance/AtlasCheckStateResult.java
index 35665ad47..2b4cffb68 100644
--- a/intg/src/main/java/org/apache/atlas/model/instance/AtlasCheckStateResult.java
+++ b/intg/src/main/java/org/apache/atlas/model/instance/AtlasCheckStateResult.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -17,14 +17,15 @@
*/
package org.apache.atlas.model.instance;
-import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
+
import java.io.Serializable;
import java.util.List;
import java.util.Map;
@@ -32,28 +33,24 @@ import java.util.Map;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
-
/**
* Result of Atlas state check run.
*/
-@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown=true)
+@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class AtlasCheckStateResult implements Serializable {
private static final long serialVersionUID = 1L;
- public enum State { OK, FIXED, PARTIALLY_FIXED, NOT_FIXED}
-
- private int entitiesScanned = 0;
- private int entitiesOk = 0;
- private int entitiesFixed = 0;
- private int entitiesPartiallyFixed = 0;
- private int entitiesNotFixed = 0;
- private State state = State.OK;
- private Map<String, AtlasEntityState> entities = null;
-
+ private int entitiesScanned;
+ private int entitiesOk;
+ private int entitiesFixed;
+ private int entitiesPartiallyFixed;
+ private int entitiesNotFixed;
+ private State state = State.OK;
+ private Map<String, AtlasEntityState> entities;
public AtlasCheckStateResult() {
}
@@ -66,7 +63,9 @@ public class AtlasCheckStateResult implements Serializable {
this.entitiesScanned = entitiesScanned;
}
- public void incrEntitiesScanned() { entitiesScanned++; }
+ public void incrEntitiesScanned() {
+ entitiesScanned++;
+ }
public int getEntitiesOk() {
return entitiesOk;
@@ -76,7 +75,9 @@ public class AtlasCheckStateResult implements Serializable {
this.entitiesOk = entitiesOk;
}
- public void incrEntitiesOk() { entitiesOk++; }
+ public void incrEntitiesOk() {
+ entitiesOk++;
+ }
public int getEntitiesFixed() {
return entitiesFixed;
@@ -86,7 +87,9 @@ public class AtlasCheckStateResult implements Serializable {
this.entitiesFixed = entitiesFixed;
}
- public void incrEntitiesFixed() { entitiesFixed++; }
+ public void incrEntitiesFixed() {
+ entitiesFixed++;
+ }
public int getEntitiesPartiallyFixed() {
return entitiesPartiallyFixed;
@@ -96,7 +99,9 @@ public class AtlasCheckStateResult implements Serializable {
this.entitiesPartiallyFixed = entitiesPartiallyFixed;
}
- public void incrEntitiesPartiallyFixed() { entitiesPartiallyFixed++; }
+ public void incrEntitiesPartiallyFixed() {
+ entitiesPartiallyFixed++;
+ }
public int getEntitiesNotFixed() {
return entitiesNotFixed;
@@ -106,7 +111,9 @@ public class AtlasCheckStateResult implements Serializable {
this.entitiesNotFixed = entitiesNotFixed;
}
- public void incrEntitiesNotFixed() { entitiesNotFixed++; }
+ public void incrEntitiesNotFixed() {
+ entitiesNotFixed++;
+ }
public State getState() {
return state;
@@ -139,6 +146,7 @@ public class AtlasCheckStateResult implements Serializable {
sb.append("entities=[");
if (entities != null) {
boolean isFirst = true;
+
for (Map.Entry<String, AtlasEntityState> entry : entities.entrySet()) {
if (isFirst) {
isFirst = false;
@@ -162,9 +170,11 @@ public class AtlasCheckStateResult implements Serializable {
return toString(new StringBuilder()).toString();
}
- @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
- @JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
- @JsonIgnoreProperties(ignoreUnknown=true)
+ public enum State { OK, FIXED, PARTIALLY_FIXED, NOT_FIXED }
+
+ @JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ @JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public static class AtlasEntityState implements Serializable {
@@ -177,7 +187,6 @@ public class AtlasCheckStateResult implements Serializable {
private State state = State.OK;
private List<String> issues;
-
public AtlasEntityState() {
}
@@ -213,7 +222,6 @@ public class AtlasCheckStateResult implements Serializable {
this.status = status;
}
-
public State getState() {
return state;
}
diff --git a/intg/src/main/java/org/apache/atlas/model/instance/AtlasClassification.java b/intg/src/main/java/org/apache/atlas/model/instance/AtlasClassification.java
index 1edf4eeaf..a15be6d75 100644
--- a/intg/src/main/java/org/apache/atlas/model/instance/AtlasClassification.java
+++ b/intg/src/main/java/org/apache/atlas/model/instance/AtlasClassification.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -17,48 +17,45 @@
*/
package org.apache.atlas.model.instance;
-
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import org.apache.atlas.model.PList;
+import org.apache.atlas.model.SearchFilter.SortType;
+import org.apache.atlas.model.TimeBoundary;
+import org.apache.atlas.model.instance.AtlasEntity.Status;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
-import org.apache.atlas.model.PList;
-import org.apache.atlas.model.SearchFilter.SortType;
-import org.apache.atlas.model.TimeBoundary;
-import org.apache.atlas.model.instance.AtlasEntity.Status;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
-
/**
* An instance of a classification; it doesn't have an identity, this object exists only when associated with an entity.
*/
-@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown=true)
+@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class AtlasClassification extends AtlasStruct implements Serializable {
private static final long serialVersionUID = 1L;
- private String entityGuid = null;
- private Status entityStatus = Status.ACTIVE;
- private Boolean propagate = null;
- private List<TimeBoundary> validityPeriods = null;
- private Boolean removePropagationsOnEntityDelete = null;
+ private String entityGuid;
+ private Status entityStatus = Status.ACTIVE;
+ private Boolean propagate;
+ private List<TimeBoundary> validityPeriods;
+ private Boolean removePropagationsOnEntityDelete;
public AtlasClassification() {
this(null, null);
@@ -150,27 +147,35 @@ public class AtlasClassification extends AtlasStruct implements Serializable {
}
@Override
- public boolean equals(Object o) {
- if (this == o) { return true; }
- if (o == null || getClass() != o.getClass()) { return false; }
- if (!super.equals(o)) { return false; }
- AtlasClassification that = (AtlasClassification) o;
- return Objects.equals(propagate, that.propagate) &&
- Objects.equals(removePropagationsOnEntityDelete, that.removePropagationsOnEntityDelete) &&
- Objects.equals(entityGuid, that.entityGuid) &&
- entityStatus == that.entityStatus &&
- Objects.equals(validityPeriods, that.validityPeriods);
+ public int hashCode() {
+ return Objects.hash(super.hashCode(), entityGuid, entityStatus, propagate, removePropagationsOnEntityDelete);
}
@Override
- public int hashCode() {
- return Objects.hash(super.hashCode(), entityGuid, entityStatus, propagate, removePropagationsOnEntityDelete);
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ } else if (o == null || getClass() != o.getClass()) {
+ return false;
+ } else if (!super.equals(o)) {
+ return false;
+ }
+
+ AtlasClassification that = (AtlasClassification) o;
+
+ return Objects.equals(propagate, that.propagate) &&
+ Objects.equals(removePropagationsOnEntityDelete, that.removePropagationsOnEntityDelete) &&
+ Objects.equals(entityGuid, that.entityGuid) &&
+ entityStatus == that.entityStatus &&
+ Objects.equals(validityPeriods, that.validityPeriods);
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("AtlasClassification{");
+
super.toString(sb);
+
sb.append("entityGuid='").append(entityGuid).append('\'');
sb.append(", entityStatus=").append(entityStatus);
sb.append(", propagate=").append(propagate);
@@ -178,15 +183,16 @@ public class AtlasClassification extends AtlasStruct implements Serializable {
sb.append(", validityPeriods=").append(validityPeriods);
sb.append(", validityPeriods=").append(validityPeriods);
sb.append('}');
+
return sb.toString();
}
/**
* REST serialization friendly list.
*/
- @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
- @JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
- @JsonIgnoreProperties(ignoreUnknown=true)
+ @JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ @JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
@XmlSeeAlso(AtlasClassification.class)
@@ -201,8 +207,7 @@ public class AtlasClassification extends AtlasStruct implements Serializable {
super(list);
}
- public AtlasClassifications(List list, long startIndex, int pageSize, long totalCount,
- SortType sortType, String sortBy) {
+ public AtlasClassifications(List<AtlasClassification> list, long startIndex, int pageSize, long totalCount, SortType sortType, String sortBy) {
super(list, startIndex, pageSize, totalCount, sortType, sortBy);
}
}
diff --git a/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntity.java b/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntity.java
index 5f8c6e888..75970eb48 100644
--- a/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntity.java
+++ b/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntity.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -17,11 +17,10 @@
*/
package org.apache.atlas.model.instance;
-
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.atlas.model.PList;
import org.apache.atlas.model.SearchFilter.SortType;
import org.apache.atlas.model.glossary.relations.AtlasTermAssignmentHeader;
@@ -34,9 +33,10 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
+
import java.io.Serializable;
import java.util.ArrayList;
-import java.util.Arrays;
+import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@@ -48,13 +48,12 @@ import java.util.concurrent.atomic.AtomicLong;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
-
/**
* An instance of an entity - like hive_table, hive_database.
*/
-@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown=true)
+@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class AtlasEntity extends AtlasStruct implements Serializable {
@@ -72,22 +71,20 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
public static final String KEY_UPDATE_TIME = "updateTime";
public static final String KEY_VERSION = "version";
- /**
- * Status of the entity - can be active or deleted. Deleted entities are not removed from Atlas store.
- */
- public enum Status { ACTIVE, DELETED, PURGED }
+ @JsonIgnore
+ private static final AtomicLong s_nextId = new AtomicLong(System.nanoTime());
- private String guid = null;
- private String homeId = null;
+ private String guid;
+ private String homeId;
private Boolean isProxy = Boolean.FALSE;
private Boolean isIncomplete = Boolean.FALSE;
- private Integer provenanceType = 0;
+ private Integer provenanceType;
private Status status = Status.ACTIVE;
- private String createdBy = null;
- private String updatedBy = null;
- private Date createTime = null;
- private Date updateTime = null;
- private Long version = 0L;
+ private String createdBy;
+ private String updatedBy;
+ private Date createTime;
+ private Date updateTime;
+ private Long version;
private Map<String, Object> relationshipAttributes;
private List<AtlasClassification> classifications;
@@ -97,9 +94,6 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
private Set<String> labels;
private Set<String> pendingTasks; // read-only field i.e. value provided is ignored during entity create/update
- @JsonIgnore
- private static AtomicLong s_nextId = new AtomicLong(System.nanoTime());
-
public AtlasEntity() {
this(null, null);
}
@@ -137,17 +131,17 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
super(map);
if (map != null) {
- Object oGuid = map.get(KEY_GUID);
- Object homeId = map.get(KEY_HOME_ID);
- Object isProxy = map.get(KEY_IS_PROXY);
- Object isIncomplete = map.get(KEY_IS_INCOMPLETE);
- Object provenanceType = map.get(KEY_PROVENANCE_TYPE);
- Object status = map.get(KEY_STATUS);
- Object createdBy = map.get(KEY_CREATED_BY);
- Object updatedBy = map.get(KEY_UPDATED_BY);
- Object createTime = map.get(KEY_CREATE_TIME);
- Object updateTime = map.get(KEY_UPDATE_TIME);
- Object version = map.get(KEY_VERSION);
+ Object oGuid = map.get(KEY_GUID);
+ Object homeId = map.get(KEY_HOME_ID);
+ Object isProxy = map.get(KEY_IS_PROXY);
+ Object isIncomplete = map.get(KEY_IS_INCOMPLETE);
+ Object provenanceType = map.get(KEY_PROVENANCE_TYPE);
+ Object status = map.get(KEY_STATUS);
+ Object createdBy = map.get(KEY_CREATED_BY);
+ Object updatedBy = map.get(KEY_UPDATED_BY);
+ Object createTime = map.get(KEY_CREATE_TIME);
+ Object updateTime = map.get(KEY_UPDATE_TIME);
+ Object version = map.get(KEY_VERSION);
if (oGuid != null) {
setGuid(oGuid.toString());
@@ -158,9 +152,8 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
}
if (isProxy != null) {
- setIsProxy((Boolean)isProxy);
- }
- else {
+ setIsProxy((Boolean) isProxy);
+ } else {
setIsProxy(Boolean.FALSE);
}
@@ -313,7 +306,9 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
this.version = version;
}
- public Map<String, Object> getRelationshipAttributes() { return relationshipAttributes; }
+ public Map<String, Object> getRelationshipAttributes() {
+ return relationshipAttributes;
+ }
public void setRelationshipAttributes(Map<String, Object> relationshipAttributes) {
this.relationshipAttributes = relationshipAttributes;
@@ -326,6 +321,7 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
r.put(name, value);
} else {
r = new HashMap<>();
+
r.put(name, value);
this.relationshipAttributes = r;
@@ -341,7 +337,7 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
public boolean hasRelationshipAttribute(String name) {
Map<String, Object> r = this.relationshipAttributes;
- return r != null ? r.containsKey(name) : false;
+ return r != null && r.containsKey(name);
}
public Map<String, String> getCustomAttributes() {
@@ -369,13 +365,7 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
this.businessAttributes = businessAttributes;
}
- Map<String, Object> businessAttributeMap = businessAttributes.get(nsName);
-
- if (businessAttributeMap == null) {
- businessAttributeMap = new HashMap<>();
-
- businessAttributes.put(nsName, businessAttributeMap);
- }
+ Map<String, Object> businessAttributeMap = businessAttributes.computeIfAbsent(nsName, k -> new HashMap<>());
businessAttributeMap.put(nsAttrName, nsValue);
}
@@ -403,9 +393,13 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
this.pendingTasks = pendingTasks;
}
- public List<AtlasClassification> getClassifications() { return classifications; }
+ public List<AtlasClassification> getClassifications() {
+ return classifications;
+ }
- public void setClassifications(List<AtlasClassification> classifications) { this.classifications = classifications; }
+ public void setClassifications(List<AtlasClassification> classifications) {
+ this.classifications = classifications;
+ }
public void addClassifications(List<AtlasClassification> classifications) {
List<AtlasClassification> c = this.classifications;
@@ -437,29 +431,6 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
setMeanings(meanings);
}
- private void init() {
- setGuid(nextInternalId());
- setHomeId(null);
- setIsProxy(Boolean.FALSE);
- setIsIncomplete(Boolean.FALSE);
- setProvenanceType(0);
- setStatus(null);
- setCreatedBy(null);
- setUpdatedBy(null);
- setCreateTime(null);
- setUpdateTime(null);
- setClassifications(null);
- setMeanings(null);
- setCustomAttributes(null);
- setBusinessAttributes(null);
- setLabels(null);
- setPendingTasks(null);
- }
-
- private static String nextInternalId() {
- return "-" + Long.toString(s_nextId.getAndIncrement());
- }
-
@Override
public StringBuilder toString(StringBuilder sb) {
if (sb == null) {
@@ -507,11 +478,16 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
@Override
public boolean equals(Object o) {
- if (this == o) { return true; }
- if (o == null || getClass() != o.getClass()) { return false; }
- if (!super.equals(o)) { return false; }
+ if (this == o) {
+ return true;
+ } else if (o == null || getClass() != o.getClass()) {
+ return false;
+ } else if (!super.equals(o)) {
+ return false;
+ }
AtlasEntity that = (AtlasEntity) o;
+
return Objects.equals(guid, that.guid) &&
Objects.equals(homeId, that.homeId) &&
Objects.equals(isProxy, that.isProxy) &&
@@ -541,12 +517,40 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
return toString(new StringBuilder()).toString();
}
+ private void init() {
+ setGuid(nextInternalId());
+ setHomeId(null);
+ setIsProxy(Boolean.FALSE);
+ setIsIncomplete(Boolean.FALSE);
+ setProvenanceType(0);
+ setStatus(null);
+ setCreatedBy(null);
+ setUpdatedBy(null);
+ setCreateTime(null);
+ setUpdateTime(null);
+ setClassifications(null);
+ setMeanings(null);
+ setCustomAttributes(null);
+ setBusinessAttributes(null);
+ setLabels(null);
+ setPendingTasks(null);
+ }
+
+ private static String nextInternalId() {
+ return "-" + s_nextId.getAndIncrement();
+ }
+
+ /**
+ * Status of the entity - can be active or deleted. Deleted entities are not removed from Atlas store.
+ */
+ public enum Status { ACTIVE, DELETED, PURGED }
+
/**
* An instance of an entity along with extended info - like hive_table, hive_database.
*/
- @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
- @JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
- @JsonIgnoreProperties(ignoreUnknown=true)
+ @JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ @JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public static class AtlasEntityExtInfo implements Serializable {
@@ -554,7 +558,6 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
private Map<String, AtlasEntity> referredEntities;
-
public AtlasEntityExtInfo() {
setReferredEntities(null);
}
@@ -573,9 +576,13 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
}
}
- public Map<String, AtlasEntity> getReferredEntities() { return referredEntities; }
+ public Map<String, AtlasEntity> getReferredEntities() {
+ return referredEntities;
+ }
- public void setReferredEntities(Map<String, AtlasEntity> referredEntities) { this.referredEntities = referredEntities; }
+ public void setReferredEntities(Map<String, AtlasEntity> referredEntities) {
+ this.referredEntities = referredEntities;
+ }
@JsonIgnore
public final void addReferredEntity(AtlasEntity entity) {
@@ -629,7 +636,7 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
if (entity != null) {
entity.setGuid(newGuid);
- if(removeEntity(oldGuid) != null) {
+ if (removeEntity(oldGuid) != null) {
addReferredEntity(newGuid, entity);
}
}
@@ -657,23 +664,22 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
return sb;
}
+ @Override
+ public int hashCode() {
+ return Objects.hash(referredEntities);
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
- }
-
- if (o == null || getClass() != o.getClass()) {
+ } else if (o == null || getClass() != o.getClass()) {
return false;
}
AtlasEntityExtInfo that = (AtlasEntityExtInfo) o;
- return Objects.equals(referredEntities, that.referredEntities);
- }
- @Override
- public int hashCode() {
- return Objects.hash(referredEntities);
+ return Objects.equals(referredEntities, that.referredEntities);
}
@Override
@@ -682,9 +688,9 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
}
}
- @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
- @JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
- @JsonIgnoreProperties(ignoreUnknown=true)
+ @JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ @JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public static class AtlasEntityWithExtInfo extends AtlasEntityExtInfo {
@@ -706,9 +712,13 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
this.entity = entity;
}
- public AtlasEntity getEntity() { return entity; }
+ public AtlasEntity getEntity() {
+ return entity;
+ }
- public void setEntity(AtlasEntity entity) { this.entity = entity; }
+ public void setEntity(AtlasEntity entity) {
+ this.entity = entity;
+ }
@JsonIgnore
@Override
@@ -753,13 +763,14 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
public boolean equals(Object o) {
if (this == o) {
return true;
- }
-
- if (o == null || getClass() != o.getClass()) {
+ } else if (o == null || getClass() != o.getClass()) {
+ return false;
+ } else if (!super.equals(o)) {
return false;
}
AtlasEntityWithExtInfo that = (AtlasEntityWithExtInfo) o;
+
return Objects.equals(entity, that.entity);
}
@@ -769,9 +780,9 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
}
}
- @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
- @JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
- @JsonIgnoreProperties(ignoreUnknown=true)
+ @JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ @JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public static class AtlasEntitiesWithExtInfo extends AtlasEntityExtInfo {
@@ -783,7 +794,8 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
this(null, null);
}
- public AtlasEntitiesWithExtInfo(AtlasEntity entity) { this(Arrays.asList(entity), null);
+ public AtlasEntitiesWithExtInfo(AtlasEntity entity) {
+ this(Collections.singletonList(entity), null);
}
public AtlasEntitiesWithExtInfo(List<AtlasEntity> entities) {
@@ -791,7 +803,7 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
}
public AtlasEntitiesWithExtInfo(AtlasEntityWithExtInfo entity) {
- this(Arrays.asList(entity.getEntity()), entity);
+ this(Collections.singletonList(entity.getEntity()), entity);
}
public AtlasEntitiesWithExtInfo(List<AtlasEntity> entities, AtlasEntityExtInfo extInfo) {
@@ -800,9 +812,13 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
this.entities = entities;
}
- public List<AtlasEntity> getEntities() { return entities; }
+ public List<AtlasEntity> getEntities() {
+ return entities;
+ }
- public void setEntities(List<AtlasEntity> entities) { this.entities = entities; }
+ public void setEntities(List<AtlasEntity> entities) {
+ this.entities = entities;
+ }
@JsonIgnore
@Override
@@ -822,26 +838,6 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
return ret;
}
- public void addEntity(AtlasEntity entity) {
- List<AtlasEntity> entities = this.entities;
-
- if (entities == null) {
- entities = new ArrayList<>();
-
- this.entities = entities;
- }
-
- entities.add(entity);
- }
-
- public void removeEntity(AtlasEntity entity) {
- List<AtlasEntity> entities = this.entities;
-
- if (entity != null && entities != null) {
- entities.remove(entity);
- }
- }
-
@Override
public void compact() {
super.compact();
@@ -874,13 +870,14 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
public boolean equals(Object o) {
if (this == o) {
return true;
- }
-
- if (o == null || getClass() != o.getClass()) {
+ } else if (o == null || getClass() != o.getClass()) {
+ return false;
+ } else if (!super.equals(o)) {
return false;
}
AtlasEntitiesWithExtInfo that = (AtlasEntitiesWithExtInfo) o;
+
return Objects.equals(entities, that.entities);
}
@@ -888,14 +885,34 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
public int hashCode() {
return Objects.hash(super.hashCode(), entities);
}
+
+ public void addEntity(AtlasEntity entity) {
+ List<AtlasEntity> entities = this.entities;
+
+ if (entities == null) {
+ entities = new ArrayList<>();
+
+ this.entities = entities;
+ }
+
+ entities.add(entity);
+ }
+
+ public void removeEntity(AtlasEntity entity) {
+ List<AtlasEntity> entities = this.entities;
+
+ if (entity != null && entities != null) {
+ entities.remove(entity);
+ }
+ }
}
/**
* REST serialization friendly list.
*/
- @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
- @JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
- @JsonIgnoreProperties(ignoreUnknown=true)
+ @JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ @JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
@XmlSeeAlso(AtlasEntity.class)
@@ -910,9 +927,8 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
super(list);
}
- public AtlasEntities(List list, long startIndex, int pageSize, long totalCount,
- SortType sortType, String sortBy) {
+ public AtlasEntities(List<AtlasEntity> list, long startIndex, int pageSize, long totalCount, SortType sortType, String sortBy) {
super(list, startIndex, pageSize, totalCount, sortType, sortBy);
}
}
-}
\ No newline at end of file
+}
diff --git a/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntityHeader.java b/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntityHeader.java
index 7d2476a64..3853fadfe 100644
--- a/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntityHeader.java
+++ b/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntityHeader.java
@@ -17,10 +17,9 @@
*/
package org.apache.atlas.model.instance;
-
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.atlas.model.PList;
import org.apache.atlas.model.SearchFilter.SortType;
import org.apache.atlas.model.glossary.relations.AtlasTermAssignmentHeader;
@@ -32,6 +31,7 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
+
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@@ -42,27 +42,26 @@ import java.util.Set;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
-
/**
* An instance of an entity - like hive_table, hive_database.
*/
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class AtlasEntityHeader extends AtlasStruct implements Serializable {
private static final long serialVersionUID = 1L;
- private String guid = null;
+ private String guid;
private AtlasEntity.Status status = AtlasEntity.Status.ACTIVE;
- private String displayText = null;
- private List<String> classificationNames = null;
- private List<AtlasClassification> classifications = null;
- private List<String> meaningNames = null;
- private List<AtlasTermAssignmentHeader> meanings = null;
+ private String displayText;
+ private List<String> classificationNames;
+ private List<AtlasClassification> classifications;
+ private List<String> meaningNames;
+ private List<AtlasTermAssignmentHeader> meanings;
private Boolean isIncomplete = Boolean.FALSE;
- private Set<String> labels = null;
+ private Set<String> labels;
public AtlasEntityHeader() {
this(null, null);
@@ -84,7 +83,6 @@ public class AtlasEntityHeader extends AtlasStruct implements Serializable {
setLabels(null);
}
-
public AtlasEntityHeader(String typeName, String guid, Map<String, Object> attributes) {
super(typeName, attributes);
setGuid(guid);
@@ -93,7 +91,6 @@ public class AtlasEntityHeader extends AtlasStruct implements Serializable {
setLabels(null);
}
-
public AtlasEntityHeader(AtlasEntityHeader other) {
super(other);
@@ -103,6 +100,8 @@ public class AtlasEntityHeader extends AtlasStruct implements Serializable {
setDisplayText(other.getDisplayText());
setClassificationNames(other.getClassificationNames());
setClassifications(other.getClassifications());
+ setMeanings(other.getMeanings());
+ setMeaningNames(other.getMeaningNames());
setIsIncomplete(other.getIsIncomplete());
setLabels(other.getLabels());
}
@@ -211,25 +210,31 @@ public class AtlasEntityHeader extends AtlasStruct implements Serializable {
}
@Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- if (!super.equals(o)) return false;
- AtlasEntityHeader that = (AtlasEntityHeader) o;
- return Objects.equals(guid, that.guid) &&
- status == that.status &&
- Objects.equals(displayText, that.displayText) &&
- Objects.equals(classificationNames, that.classificationNames) &&
- Objects.equals(meaningNames, that.classificationNames) &&
- Objects.equals(classifications, that.classifications) &&
- Objects.equals(labels, that.labels) &&
- Objects.equals(isIncomplete, that.isIncomplete) &&
- Objects.equals(meanings, that.meanings);
+ public int hashCode() {
+ return Objects.hash(super.hashCode(), guid, status, displayText, classificationNames, classifications, meaningNames, meanings, isIncomplete, labels);
}
@Override
- public int hashCode() {
- return Objects.hash(super.hashCode(), guid, status, displayText, classificationNames, classifications, meaningNames, meanings, isIncomplete, labels);
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ } else if (o == null || getClass() != o.getClass()) {
+ return false;
+ } else if (!super.equals(o)) {
+ return false;
+ }
+
+ AtlasEntityHeader that = (AtlasEntityHeader) o;
+
+ return Objects.equals(guid, that.guid) &&
+ status == that.status &&
+ Objects.equals(displayText, that.displayText) &&
+ Objects.equals(classificationNames, that.classificationNames) &&
+ Objects.equals(meaningNames, that.classificationNames) &&
+ Objects.equals(classifications, that.classifications) &&
+ Objects.equals(labels, that.labels) &&
+ Objects.equals(isIncomplete, that.isIncomplete) &&
+ Objects.equals(meanings, that.meanings);
}
@Override
@@ -257,7 +262,7 @@ public class AtlasEntityHeader extends AtlasStruct implements Serializable {
* REST serialization friendly list.
*/
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
- @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+ @JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
@@ -273,8 +278,7 @@ public class AtlasEntityHeader extends AtlasStruct implements Serializable {
super(list);
}
- public AtlasEntityHeaders(List list, long startIndex, int pageSize, long totalCount,
- SortType sortType, String sortBy) {
+ public AtlasEntityHeaders(List<AtlasEntityHeader> list, long startIndex, int pageSize, long totalCount, SortType sortType, String sortBy) {
super(list, startIndex, pageSize, totalCount, sortType, sortBy);
}
}
diff --git a/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntityHeaders.java b/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntityHeaders.java
index 11c6fc785..2b39fbd7e 100644
--- a/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntityHeaders.java
+++ b/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntityHeaders.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -20,23 +20,26 @@ package org.apache.atlas.model.instance;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.annotation.JsonInclude;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
import java.util.Map;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
-@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown=true)
+@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
-public class AtlasEntityHeaders {
+public class AtlasEntityHeaders implements Serializable {
+ private static final long serialVersionUID = 1L;
+
Map<String, AtlasEntityHeader> guidHeaderMap;
public AtlasEntityHeaders() {
@@ -46,11 +49,11 @@ public class AtlasEntityHeaders {
guidHeaderMap = guidEntityHeaderMap;
}
- public void setGuidHeaderMap(Map<String, AtlasEntityHeader> guidHeaderMap) {
- this.guidHeaderMap = guidHeaderMap;
- }
-
public Map<String, AtlasEntityHeader> getGuidHeaderMap() {
return guidHeaderMap;
}
+
+ public void setGuidHeaderMap(Map<String, AtlasEntityHeader> guidHeaderMap) {
+ this.guidHeaderMap = guidHeaderMap;
+ }
}
diff --git a/intg/src/main/java/org/apache/atlas/model/instance/AtlasObjectId.java b/intg/src/main/java/org/apache/atlas/model/instance/AtlasObjectId.java
index a8958a83f..d8a844006 100644
--- a/intg/src/main/java/org/apache/atlas/model/instance/AtlasObjectId.java
+++ b/intg/src/main/java/org/apache/atlas/model/instance/AtlasObjectId.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -17,24 +17,24 @@
*/
package org.apache.atlas.model.instance;
-import java.io.Serializable;
-import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Objects;
-
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import org.apache.atlas.model.PList;
+import org.apache.atlas.model.SearchFilter.SortType;
+import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
+import org.apache.commons.lang.StringUtils;
+
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
-import org.apache.atlas.model.PList;
-import org.apache.atlas.model.SearchFilter.SortType;
-import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
-import org.apache.commons.lang.StringUtils;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
@@ -42,12 +42,12 @@ import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_
/**
* Reference to an object-instance of an Atlas type - like entity.
*/
-@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown=true)
+@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
-public class AtlasObjectId implements Serializable {
+public class AtlasObjectId implements Serializable {
private static final long serialVersionUID = 1L;
public static final String KEY_GUID = "guid";
@@ -58,17 +58,16 @@ public class AtlasObjectId implements Serializable {
private String typeName;
private Map<String, Object> uniqueAttributes;
-
public AtlasObjectId() {
- this(null, null, (Map<String, Object>)null);
+ this(null, null, null);
}
public AtlasObjectId(String guid) {
- this(guid, null, (Map<String, Object>)null);
+ this(guid, null, null);
}
public AtlasObjectId(String guid, String typeName) {
- this(guid, typeName, (Map<String, Object>)null);
+ this(guid, typeName, null);
}
public AtlasObjectId(String typeName, Map<String, Object> uniqueAttributes) {
@@ -76,7 +75,7 @@ public class AtlasObjectId implements Serializable {
}
public AtlasObjectId(String typeName, final String attrName, final Object attrValue) {
- this(null, typeName, new HashMap<String, Object>() {{ put(attrName, attrValue); }});
+ this(null, typeName, createMap(attrName, attrValue));
}
public AtlasObjectId(String guid, String typeName, Map<String, Object> uniqueAttributes) {
@@ -107,8 +106,8 @@ public class AtlasObjectId implements Serializable {
setTypeName(t.toString());
}
- if (u != null && u instanceof Map) {
- setUniqueAttributes((Map)u);
+ if (u instanceof Map) {
+ setUniqueAttributes((Map) u);
}
}
}
@@ -153,6 +152,11 @@ public class AtlasObjectId implements Serializable {
return sb;
}
+ @Override
+ public int hashCode() {
+ return guid != null ? Objects.hash(guid) : Objects.hash(typeName, uniqueAttributes);
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) {
@@ -173,22 +177,25 @@ public class AtlasObjectId implements Serializable {
}
}
- @Override
- public int hashCode() {
- return guid != null ? Objects.hash(guid) : Objects.hash(typeName, uniqueAttributes);
- }
-
@Override
public String toString() {
return toString(new StringBuilder()).toString();
}
+ private static Map<String, Object> createMap(String key, Object val) {
+ Map<String, Object> ret = new HashMap<>();
+
+ ret.put(key, val);
+
+ return ret;
+ }
+
/**
* REST serialization friendly list.
*/
- @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
- @JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
- @JsonIgnoreProperties(ignoreUnknown=true)
+ @JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ @JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
@XmlSeeAlso(AtlasObjectId.class)
@@ -203,8 +210,7 @@ public class AtlasObjectId implements Serializable {
super(list);
}
- public AtlasObjectIds(List list, long startIndex, int pageSize, long totalCount,
- SortType sortType, String sortBy) {
+ public AtlasObjectIds(List<AtlasObjectId> list, long startIndex, int pageSize, long totalCount, SortType sortType, String sortBy) {
super(list, startIndex, pageSize, totalCount, sortType, sortBy);
}
}
diff --git a/intg/src/main/java/org/apache/atlas/model/instance/AtlasRelatedObjectId.java b/intg/src/main/java/org/apache/atlas/model/instance/AtlasRelatedObjectId.java
index d640d21f5..d19d387a5 100644
--- a/intg/src/main/java/org/apache/atlas/model/instance/AtlasRelatedObjectId.java
+++ b/intg/src/main/java/org/apache/atlas/model/instance/AtlasRelatedObjectId.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -17,14 +17,14 @@
*/
package org.apache.atlas.model.instance;
-
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.annotation.JsonInclude;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
+
import java.io.Serializable;
import java.util.Map;
import java.util.Objects;
@@ -35,9 +35,9 @@ import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_
/**
* Reference to an object-instance of AtlasEntity type used in relationship attribute values
*/
-@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown=true)
+@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class AtlasRelatedObjectId extends AtlasObjectId implements Serializable {
@@ -48,18 +48,17 @@ public class AtlasRelatedObjectId extends AtlasObjectId implements Serializable
public static final String KEY_RELATIONSHIP_STATUS = "relationshipStatus";
public static final String KEY_RELATIONSHIP_ATTRIBUTES = "relationshipAttributes";
- private AtlasEntity.Status entityStatus = null;
- private String displayText = null;
- private String relationshipType = null;
- private String relationshipGuid = null;
- private AtlasRelationship.Status relationshipStatus = null;
- private AtlasStruct relationshipAttributes = null;
- private String qualifiedName = null;
+ private AtlasEntity.Status entityStatus;
+ private String displayText;
+ private String relationshipType;
+ private String relationshipGuid;
+ private AtlasRelationship.Status relationshipStatus;
+ private AtlasStruct relationshipAttributes;
+ private String qualifiedName;
- public AtlasRelatedObjectId() { }
+ public AtlasRelatedObjectId() {}
- public AtlasRelatedObjectId(String guid, String typeName, AtlasEntity.Status entityStatus, String relationshipGuid,
- AtlasRelationship.Status relationshipStatus, AtlasStruct relationshipAttributes) {
+ public AtlasRelatedObjectId(String guid, String typeName, AtlasEntity.Status entityStatus, String relationshipGuid, AtlasRelationship.Status relationshipStatus, AtlasStruct relationshipAttributes) {
super(guid, typeName);
setEntityStatus(entityStatus);
@@ -68,9 +67,7 @@ public class AtlasRelatedObjectId extends AtlasObjectId implements Serializable
setRelationshipAttributes(relationshipAttributes);
}
- public AtlasRelatedObjectId(String guid, String typeName, AtlasEntity.Status entityStatus, Map<String, Object> uniqueAttributes, String displayText,
- String relationshipGuid, AtlasRelationship.Status relationshipStatus,
- AtlasStruct relationshipAttributes) {
+ public AtlasRelatedObjectId(String guid, String typeName, AtlasEntity.Status entityStatus, Map<String, Object> uniqueAttributes, String displayText, String relationshipGuid, AtlasRelationship.Status relationshipStatus, AtlasStruct relationshipAttributes) {
super(guid, typeName, uniqueAttributes);
setEntityStatus(entityStatus);
@@ -90,7 +87,7 @@ public class AtlasRelatedObjectId extends AtlasObjectId implements Serializable
setRelationshipType(relationshipType);
}
- public AtlasRelatedObjectId(Map objIdMap) {
+ public AtlasRelatedObjectId(Map<?, ?> objIdMap) {
super(objIdMap);
if (objIdMap != null) {
@@ -127,17 +124,29 @@ public class AtlasRelatedObjectId extends AtlasObjectId implements Serializable
this.entityStatus = entityStatus;
}
- public String getDisplayText() { return displayText; }
+ public String getDisplayText() {
+ return displayText;
+ }
- public void setDisplayText(String displayText) { this.displayText = displayText; }
+ public void setDisplayText(String displayText) {
+ this.displayText = displayText;
+ }
- public String getRelationshipType() { return relationshipType; }
+ public String getRelationshipType() {
+ return relationshipType;
+ }
- public void setRelationshipType(String relationshipType) { this.relationshipType = relationshipType; }
+ public void setRelationshipType(String relationshipType) {
+ this.relationshipType = relationshipType;
+ }
- public String getRelationshipGuid() { return relationshipGuid; }
+ public String getRelationshipGuid() {
+ return relationshipGuid;
+ }
- public void setRelationshipGuid(String relationshipGuid) { this.relationshipGuid = relationshipGuid; }
+ public void setRelationshipGuid(String relationshipGuid) {
+ this.relationshipGuid = relationshipGuid;
+ }
public AtlasRelationship.Status getRelationshipStatus() {
return relationshipStatus;
@@ -147,7 +156,9 @@ public class AtlasRelatedObjectId extends AtlasObjectId implements Serializable
this.relationshipStatus = relationshipStatus;
}
- public AtlasStruct getRelationshipAttributes() { return relationshipAttributes; }
+ public AtlasStruct getRelationshipAttributes() {
+ return relationshipAttributes;
+ }
public void setRelationshipAttributes(AtlasStruct relationshipAttributes) {
this.relationshipAttributes = relationshipAttributes;
@@ -156,6 +167,7 @@ public class AtlasRelatedObjectId extends AtlasObjectId implements Serializable
setRelationshipType(relationshipAttributes.getTypeName());
}
}
+
public String getQualifiedName() {
return qualifiedName;
}
@@ -164,30 +176,6 @@ public class AtlasRelatedObjectId extends AtlasObjectId implements Serializable
this.qualifiedName = qualifiedName;
}
- @Override
- public boolean equals(Object o) {
- if (this == o) { return true; }
- if (o == null || getClass() != o.getClass()) { return false; }
- if (!super.equals(o)) { return false; }
- AtlasRelatedObjectId that = (AtlasRelatedObjectId) o;
- return Objects.equals(entityStatus, that.entityStatus) &&
- Objects.equals(displayText, that.displayText) &&
- Objects.equals(relationshipType, that.relationshipType) &&
- Objects.equals(relationshipGuid, that.relationshipGuid) &&
- Objects.equals(relationshipStatus, that.relationshipStatus) &&
- Objects.equals(relationshipAttributes, that.relationshipAttributes);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(super.hashCode(), displayText, relationshipType, relationshipGuid, relationshipStatus, relationshipAttributes);
- }
-
- @Override
- public String toString() {
- return toString(new StringBuilder()).toString();
- }
-
@Override
public StringBuilder toString(StringBuilder sb) {
if (sb == null) {
@@ -207,4 +195,34 @@ public class AtlasRelatedObjectId extends AtlasObjectId implements Serializable
return sb;
}
-}
\ No newline at end of file
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(super.hashCode(), displayText, relationshipType, relationshipGuid, relationshipStatus, relationshipAttributes);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ } else if (o == null || getClass() != o.getClass()) {
+ return false;
+ } else if (!super.equals(o)) {
+ return false;
+ }
+
+ AtlasRelatedObjectId that = (AtlasRelatedObjectId) o;
+
+ return Objects.equals(entityStatus, that.entityStatus) &&
+ Objects.equals(displayText, that.displayText) &&
+ Objects.equals(relationshipType, that.relationshipType) &&
+ Objects.equals(relationshipGuid, that.relationshipGuid) &&
+ Objects.equals(relationshipStatus, that.relationshipStatus) &&
+ Objects.equals(relationshipAttributes, that.relationshipAttributes);
+ }
+
+ @Override
+ public String toString() {
+ return toString(new StringBuilder()).toString();
+ }
+}
diff --git a/intg/src/main/java/org/apache/atlas/model/instance/AtlasRelationship.java b/intg/src/main/java/org/apache/atlas/model/instance/AtlasRelationship.java
index 8681cfd90..87ebbb871 100644
--- a/intg/src/main/java/org/apache/atlas/model/instance/AtlasRelationship.java
+++ b/intg/src/main/java/org/apache/atlas/model/instance/AtlasRelationship.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -17,11 +17,10 @@
*/
package org.apache.atlas.model.instance;
-
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.atlas.model.typedef.AtlasRelationshipDef;
import org.apache.atlas.model.typedef.AtlasRelationshipDef.PropagateTags;
import org.apache.commons.collections.CollectionUtils;
@@ -29,6 +28,7 @@ import org.apache.commons.collections.CollectionUtils;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
+
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
@@ -42,57 +42,52 @@ import java.util.concurrent.atomic.AtomicLong;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
-
/**
* Atlas relationship instance.
*/
-@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown=true)
+@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class AtlasRelationship extends AtlasStruct implements Serializable {
private static final long serialVersionUID = 1L;
- public static final String KEY_GUID = "guid";
- public static final String KEY_HOME_ID = "homeId";
+ public static final String KEY_GUID = "guid";
+ public static final String KEY_HOME_ID = "homeId";
public static final String KEY_PROVENANCE_TYPE = "provenanceType";
- public static final String KEY_STATUS = "status";
- public static final String KEY_CREATED_BY = "createdBy";
- public static final String KEY_UPDATED_BY = "updatedBy";
- public static final String KEY_CREATE_TIME = "createTime";
- public static final String KEY_UPDATE_TIME = "updateTime";
- public static final String KEY_VERSION = "version";
- public static final String KEY_END1 = "end1";
- public static final String KEY_END2 = "end2";
- public static final String KEY_LABEL = "label";
- public static final String KEY_PROPAGATE_TAGS = "propagateTags";
-
+ public static final String KEY_STATUS = "status";
+ public static final String KEY_CREATED_BY = "createdBy";
+ public static final String KEY_UPDATED_BY = "updatedBy";
+ public static final String KEY_CREATE_TIME = "createTime";
+ public static final String KEY_UPDATE_TIME = "updateTime";
+ public static final String KEY_VERSION = "version";
+ public static final String KEY_END1 = "end1";
+ public static final String KEY_END2 = "end2";
+ public static final String KEY_LABEL = "label";
+ public static final String KEY_PROPAGATE_TAGS = "propagateTags";
public static final String KEY_BLOCKED_PROPAGATED_CLASSIFICATIONS = "blockedPropagatedClassifications";
public static final String KEY_PROPAGATED_CLASSIFICATIONS = "propagatedClassifications";
- private String guid = null;
- private String homeId = null;
- private Integer provenanceType = null;
- private AtlasObjectId end1 = null;
- private AtlasObjectId end2 = null;
- private String label = null;
- private PropagateTags propagateTags = PropagateTags.NONE;
- private Status status = Status.ACTIVE;
- private String createdBy = null;
- private String updatedBy = null;
- private Date createTime = null;
- private Date updateTime = null;
- private Long version = 0L;
-
- public enum Status { ACTIVE, DELETED }
-
+ @JsonIgnore
+ private static final AtomicLong s_nextId = new AtomicLong(System.nanoTime());
+
+ private String guid;
+ private String homeId;
+ private Integer provenanceType;
+ private AtlasObjectId end1;
+ private AtlasObjectId end2;
+ private String label;
+ private PropagateTags propagateTags = PropagateTags.NONE;
+ private Status status = Status.ACTIVE;
+ private String createdBy;
+ private String updatedBy;
+ private Date createTime;
+ private Date updateTime;
+ private Long version;
private Set<AtlasClassification> propagatedClassifications;
private Set<AtlasClassification> blockedPropagatedClassifications;
- @JsonIgnore
- private static AtomicLong s_nextId = new AtomicLong(System.nanoTime());
-
public AtlasRelationship() {
super();
@@ -131,7 +126,7 @@ public class AtlasRelationship extends AtlasStruct implements Serializable {
this(relationshipDef != null ? relationshipDef.getName() : null);
}
- public AtlasRelationship(Map map) {
+ public AtlasRelationship(Map<?, ?> map) {
super(map);
if (map != null) {
@@ -212,10 +207,10 @@ public class AtlasRelationship extends AtlasStruct implements Serializable {
setVersion(((Number) version).longValue());
}
- if (CollectionUtils.isNotEmpty((List) propagatedClassifications)) {
+ if (CollectionUtils.isNotEmpty((List<?>) propagatedClassifications)) {
this.propagatedClassifications = new HashSet<>();
- for (Object elem : (List) propagatedClassifications) {
+ for (Object elem : (List<?>) propagatedClassifications) {
if (elem instanceof AtlasClassification) {
this.propagatedClassifications.add((AtlasClassification) elem);
} else if (elem instanceof Map) {
@@ -224,10 +219,10 @@ public class AtlasRelationship extends AtlasStruct implements Serializable {
}
}
- if (CollectionUtils.isNotEmpty((List) blockedPropagatedClassifications)) {
+ if (CollectionUtils.isNotEmpty((List<?>) blockedPropagatedClassifications)) {
this.blockedPropagatedClassifications = new HashSet<>();
- for (Object elem : (List) blockedPropagatedClassifications) {
+ for (Object elem : (List<?>) blockedPropagatedClassifications) {
if (elem instanceof AtlasClassification) {
this.blockedPropagatedClassifications.add((AtlasClassification) elem);
} else if (elem instanceof Map) {
@@ -243,7 +238,7 @@ public class AtlasRelationship extends AtlasStruct implements Serializable {
if (other != null) {
init(other.guid, other.homeId, other.provenanceType, other.end1, other.end2, other.label, other.propagateTags, other.status, other.createdBy, other.updatedBy,
- other.createTime, other.updateTime, other.version, other.propagatedClassifications, other.blockedPropagatedClassifications);
+ other.createTime, other.updateTime, other.version, other.propagatedClassifications, other.blockedPropagatedClassifications);
}
}
@@ -267,7 +262,9 @@ public class AtlasRelationship extends AtlasStruct implements Serializable {
return provenanceType;
}
- public void setProvenanceType(Integer provenanceType) { this.provenanceType = provenanceType; }
+ public void setProvenanceType(Integer provenanceType) {
+ this.provenanceType = provenanceType;
+ }
public Status getStatus() {
return status;
@@ -317,24 +314,36 @@ public class AtlasRelationship extends AtlasStruct implements Serializable {
this.version = version;
}
- public AtlasObjectId getEnd1() { return end1; }
-
- public void setEnd1(AtlasObjectId end1) { this.end1 = end1; }
+ public AtlasObjectId getEnd1() {
+ return end1;
+ }
- public AtlasObjectId getEnd2() { return end2; }
+ public void setEnd1(AtlasObjectId end1) {
+ this.end1 = end1;
+ }
- public void setEnd2(AtlasObjectId end2) { this.end2 = end2; }
+ public AtlasObjectId getEnd2() {
+ return end2;
+ }
- public String getLabel() { return label; }
+ public void setEnd2(AtlasObjectId end2) {
+ this.end2 = end2;
+ }
- public void setLabel(String label) { this.label = label; }
+ public String getLabel() {
+ return label;
+ }
- public PropagateTags getPropagateTags() { return propagateTags; }
+ public void setLabel(String label) {
+ this.label = label;
+ }
- public void setPropagateTags(PropagateTags propagateTags) { this.propagateTags = propagateTags; }
+ public PropagateTags getPropagateTags() {
+ return propagateTags;
+ }
- private static String nextInternalId() {
- return "-" + Long.toString(s_nextId.getAndIncrement());
+ public void setPropagateTags(PropagateTags propagateTags) {
+ this.propagateTags = propagateTags;
}
public Set<AtlasClassification> getPropagatedClassifications() {
@@ -353,30 +362,6 @@ public class AtlasRelationship extends AtlasStruct implements Serializable {
this.blockedPropagatedClassifications = blockedPropagatedClassifications;
}
- private void init() {
- init(nextInternalId(), null, 0 ,null, null, null, null, null, null, null, null, null, 0L, null, null);
- }
-
- private void init(String guid, String homeId, Integer provenanceType, AtlasObjectId end1, AtlasObjectId end2, String label, PropagateTags propagateTags,
- Status status, String createdBy, String updatedBy, Date createTime, Date updateTime, Long version,
- Set<AtlasClassification> propagatedClassifications, Set<AtlasClassification> blockedPropagatedClassifications) {
- setGuid(guid);
- setHomeId(homeId);
- setProvenanceType(provenanceType);
- setEnd1(end1);
- setEnd2(end2);
- setLabel(label);
- setPropagateTags(propagateTags);
- setStatus(status);
- setCreatedBy(createdBy);
- setUpdatedBy(updatedBy);
- setCreateTime(createTime);
- setUpdateTime(updateTime);
- setVersion(version);
- setPropagatedClassifications(propagatedClassifications);
- setBlockedPropagatedClassifications(blockedPropagatedClassifications);
- }
-
@Override
public StringBuilder toString(StringBuilder sb) {
if (sb == null) {
@@ -409,13 +394,24 @@ public class AtlasRelationship extends AtlasStruct implements Serializable {
return sb;
}
+ @Override
+ public int hashCode() {
+ return Objects.hash(super.hashCode(), guid, homeId, provenanceType, end1, end2, label, propagateTags, status, createdBy, updatedBy,
+ createTime, updateTime, version, propagatedClassifications, blockedPropagatedClassifications);
+ }
+
@Override
public boolean equals(Object o) {
- if (this == o) { return true; }
- if (o == null || getClass() != o.getClass()) { return false; }
- if (!super.equals(o)) { return false; }
+ if (this == o) {
+ return true;
+ } else if (o == null || getClass() != o.getClass()) {
+ return false;
+ } else if (!super.equals(o)) {
+ return false;
+ }
AtlasRelationship that = (AtlasRelationship) o;
+
return Objects.equals(guid, that.guid) &&
Objects.equals(homeId, that.homeId) &&
Objects.equals(provenanceType, that.provenanceType) &&
@@ -433,20 +429,44 @@ public class AtlasRelationship extends AtlasStruct implements Serializable {
Objects.equals(blockedPropagatedClassifications, that.blockedPropagatedClassifications);
}
- @Override
- public int hashCode() {
- return Objects.hash(super.hashCode(), guid, homeId, provenanceType, end1, end2, label, propagateTags, status, createdBy, updatedBy,
- createTime, updateTime, version, propagatedClassifications, blockedPropagatedClassifications);
- }
-
@Override
public String toString() {
return toString(new StringBuilder()).toString();
}
- @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
- @JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
- @JsonIgnoreProperties(ignoreUnknown=true)
+ private static String nextInternalId() {
+ return "-" + s_nextId.getAndIncrement();
+ }
+
+ private void init() {
+ init(nextInternalId(), null, 0, null, null, null, null, null, null, null, null, null, 0L, null, null);
+ }
+
+ private void init(String guid, String homeId, Integer provenanceType, AtlasObjectId end1, AtlasObjectId end2, String label, PropagateTags propagateTags,
+ Status status, String createdBy, String updatedBy, Date createTime, Date updateTime, Long version,
+ Set<AtlasClassification> propagatedClassifications, Set<AtlasClassification> blockedPropagatedClassifications) {
+ setGuid(guid);
+ setHomeId(homeId);
+ setProvenanceType(provenanceType);
+ setEnd1(end1);
+ setEnd2(end2);
+ setLabel(label);
+ setPropagateTags(propagateTags);
+ setStatus(status);
+ setCreatedBy(createdBy);
+ setUpdatedBy(updatedBy);
+ setCreateTime(createTime);
+ setUpdateTime(updateTime);
+ setVersion(version);
+ setPropagatedClassifications(propagatedClassifications);
+ setBlockedPropagatedClassifications(blockedPropagatedClassifications);
+ }
+
+ public enum Status { ACTIVE, DELETED }
+
+ @JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ @JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public static class AtlasRelationshipWithExtInfo implements Serializable {
@@ -477,7 +497,7 @@ public class AtlasRelationship extends AtlasStruct implements Serializable {
}
public boolean referredEntitiesContains(String guid) {
- return (referredEntities != null) ? referredEntities.containsKey(guid) : false;
+ return referredEntities != null && referredEntities.containsKey(guid);
}
@JsonIgnore
@@ -502,30 +522,30 @@ public class AtlasRelationship extends AtlasStruct implements Serializable {
return r != null && guid != null ? r.remove(guid) : null;
}
+ @Override
+ public int hashCode() {
+ return Objects.hash(super.hashCode(), relationship, referredEntities);
+ }
+
@Override
public boolean equals(Object o) {
- if (this == o) { return true; }
- if (o == null || getClass() != o.getClass()) { return false; }
- if (!super.equals(o)) { return false; }
+ if (this == o) {
+ return true;
+ } else if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
AtlasRelationshipWithExtInfo that = (AtlasRelationshipWithExtInfo) o;
return Objects.equals(relationship, that.relationship) &&
- Objects.equals(referredEntities, that.referredEntities);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(super.hashCode(), relationship, referredEntities);
+ Objects.equals(referredEntities, that.referredEntities);
}
@Override
public String toString() {
- final StringBuilder sb = new StringBuilder("AtlasRelationshipWithExtInfo{");
- sb.append("relationship=").append(relationship);
- sb.append(", referredEntities=").append(referredEntities);
- sb.append('}');
-
- return sb.toString();
+ return "AtlasRelationshipWithExtInfo{" + "relationship=" + relationship +
+ ", referredEntities=" + referredEntities +
+ '}';
}
}
-}
\ No newline at end of file
+}
diff --git a/intg/src/main/java/org/apache/atlas/model/instance/AtlasRelationshipHeader.java b/intg/src/main/java/org/apache/atlas/model/instance/AtlasRelationshipHeader.java
index 524a29d85..959405b3e 100644
--- a/intg/src/main/java/org/apache/atlas/model/instance/AtlasRelationshipHeader.java
+++ b/intg/src/main/java/org/apache/atlas/model/instance/AtlasRelationshipHeader.java
@@ -17,10 +17,9 @@
*/
package org.apache.atlas.model.instance;
-
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.atlas.model.PList;
import org.apache.atlas.model.SearchFilter.SortType;
import org.apache.atlas.model.typedef.AtlasRelationshipDef;
@@ -29,6 +28,7 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
+
import java.io.Serializable;
import java.util.List;
import java.util.Objects;
@@ -36,24 +36,22 @@ import java.util.Objects;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
-
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class AtlasRelationshipHeader extends AtlasStruct implements Serializable {
private static final long serialVersionUID = 1L;
- private String guid = null;
- private AtlasEntity.Status status = AtlasEntity.Status.ACTIVE;
- private AtlasRelationshipDef.PropagateTags propagateTags = AtlasRelationshipDef.PropagateTags.NONE;
- private String label = null;
- private AtlasObjectId end1 = null;
- private AtlasObjectId end2 = null;
+ private String guid;
+ private AtlasEntity.Status status = AtlasEntity.Status.ACTIVE;
+ private AtlasRelationshipDef.PropagateTags propagateTags = AtlasRelationshipDef.PropagateTags.NONE;
+ private String label;
+ private AtlasObjectId end1;
+ private AtlasObjectId end2;
public AtlasRelationshipHeader() {
-
}
public AtlasRelationshipHeader(String typeName, String guid) {
@@ -63,7 +61,9 @@ public class AtlasRelationshipHeader extends AtlasStruct implements Serializable
public AtlasRelationshipHeader(String typeName, String guid, AtlasObjectId end1, AtlasObjectId end2, AtlasRelationshipDef.PropagateTags propagateTags) {
this(typeName, guid);
+
this.propagateTags = propagateTags;
+
setEnd1(end1);
setEnd2(end2);
}
@@ -72,6 +72,7 @@ public class AtlasRelationshipHeader extends AtlasStruct implements Serializable
this(relationship.getTypeName(), relationship.getGuid(), relationship.getEnd1(), relationship.getEnd2(), relationship.getPropagateTags());
setLabel(relationship.getLabel());
+
switch (relationship.getStatus()) {
case ACTIVE:
setStatus(AtlasEntity.Status.ACTIVE);
@@ -91,7 +92,6 @@ public class AtlasRelationshipHeader extends AtlasStruct implements Serializable
}
}
-
public String getGuid() {
return guid;
}
@@ -159,22 +159,28 @@ public class AtlasRelationshipHeader extends AtlasStruct implements Serializable
}
@Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- if (!super.equals(o)) return false;
- AtlasRelationshipHeader that = (AtlasRelationshipHeader) o;
- return Objects.equals(guid, that.guid) &&
- status == that.status &&
- Objects.equals(label, that.label) &&
- Objects.equals(propagateTags, that.propagateTags) &&
- Objects.equals(end1, that.end1) &&
- Objects.equals(end2, that.end2);
+ public int hashCode() {
+ return Objects.hash(super.hashCode(), guid, status, label, propagateTags, end1, end2);
}
@Override
- public int hashCode() {
- return Objects.hash(super.hashCode(), guid, status, label, propagateTags, end1, end2);
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ } else if (o == null || getClass() != o.getClass()) {
+ return false;
+ } else if (!super.equals(o)) {
+ return false;
+ }
+
+ AtlasRelationshipHeader that = (AtlasRelationshipHeader) o;
+
+ return Objects.equals(guid, that.guid) &&
+ status == that.status &&
+ Objects.equals(label, that.label) &&
+ Objects.equals(propagateTags, that.propagateTags) &&
+ Objects.equals(end1, that.end1) &&
+ Objects.equals(end2, that.end2);
}
@Override
@@ -186,7 +192,7 @@ public class AtlasRelationshipHeader extends AtlasStruct implements Serializable
* REST serialization friendly list.
*/
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
- @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+ @JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
@@ -202,8 +208,7 @@ public class AtlasRelationshipHeader extends AtlasStruct implements Serializable
super(list);
}
- public AtlasRelationshipHeaders(List list, long startIndex, int pageSize, long totalCount,
- SortType sortType, String sortBy) {
+ public AtlasRelationshipHeaders(List<AtlasRelationshipHeader> list, long startIndex, int pageSize, long totalCount, SortType sortType, String sortBy) {
super(list, startIndex, pageSize, totalCount, sortType, sortBy);
}
}
diff --git a/intg/src/main/java/org/apache/atlas/model/instance/AtlasStruct.java b/intg/src/main/java/org/apache/atlas/model/instance/AtlasStruct.java
index 027b1607c..e16488e30 100644
--- a/intg/src/main/java/org/apache/atlas/model/instance/AtlasStruct.java
+++ b/intg/src/main/java/org/apache/atlas/model/instance/AtlasStruct.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -17,10 +17,19 @@
*/
package org.apache.atlas.model.instance;
-
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import org.apache.atlas.model.PList;
+import org.apache.atlas.model.SearchFilter.SortType;
+import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.collections.MapUtils;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlSeeAlso;
import java.io.Serializable;
import java.text.DateFormat;
@@ -32,38 +41,26 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlSeeAlso;
-
-import org.apache.atlas.model.PList;
-import org.apache.atlas.model.SearchFilter.SortType;
-import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.collections.MapUtils;
-
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
-
/**
* Captures details of struct contents. Not instantiated directly, used only via AtlasEntity, AtlasClassification.
*/
-@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown=true)
+@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class AtlasStruct implements Serializable {
private static final long serialVersionUID = 1L;
- public static final String KEY_TYPENAME = "typeName";
- public static final String KEY_ATTRIBUTES = "attributes";
+ public static final String KEY_TYPENAME = "typeName";
+ public static final String KEY_ATTRIBUTES = "attributes";
+ public static final String SERIALIZED_DATE_FORMAT_STR = "yyyyMMdd-HH:mm:ss.SSS-Z";
- public static final String SERIALIZED_DATE_FORMAT_STR = "yyyyMMdd-HH:mm:ss.SSS-Z";
@Deprecated
- public static final DateFormat DATE_FORMATTER = new SimpleDateFormat(SERIALIZED_DATE_FORMAT_STR);
+ public static final DateFormat DATE_FORMATTER = new SimpleDateFormat(SERIALIZED_DATE_FORMAT_STR);
private String typeName;
private Map<String, Object> attributes;
@@ -106,6 +103,81 @@ public class AtlasStruct implements Serializable {
}
}
+ public static StringBuilder dumpModelObjects(Collection<? extends AtlasStruct> objList, StringBuilder sb) {
+ if (sb == null) {
+ sb = new StringBuilder();
+ }
+
+ if (CollectionUtils.isNotEmpty(objList)) {
+ int i = 0;
+
+ for (AtlasStruct obj : objList) {
+ if (i > 0) {
+ sb.append(", ");
+ }
+
+ obj.toString(sb);
+ i++;
+ }
+ }
+
+ return sb;
+ }
+
+ public static StringBuilder dumpObjects(Collection<?> objects, StringBuilder sb) {
+ if (sb == null) {
+ sb = new StringBuilder();
+ }
+
+ if (CollectionUtils.isNotEmpty(objects)) {
+ int i = 0;
+
+ for (Object obj : objects) {
+ if (i > 0) {
+ sb.append(", ");
+ }
+
+ sb.append(obj);
+ i++;
+ }
+ }
+
+ return sb;
+ }
+
+ public static StringBuilder dumpObjects(Map<?, ?> objects, StringBuilder sb) {
+ if (sb == null) {
+ sb = new StringBuilder();
+ }
+
+ if (MapUtils.isNotEmpty(objects)) {
+ int i = 0;
+
+ for (Map.Entry<?, ?> e : objects.entrySet()) {
+ if (i > 0) {
+ sb.append(", ");
+ }
+
+ sb.append(e.getKey()).append(":").append(e.getValue());
+ i++;
+ }
+ }
+
+ return sb;
+ }
+
+ public static StringBuilder dumpDateField(String prefix, Date value, StringBuilder sb) {
+ sb.append(prefix);
+
+ if (value == null) {
+ sb.append(value);
+ } else {
+ sb.append(AtlasBaseTypeDef.getDateFormatter().format(value));
+ }
+
+ return sb;
+ }
+
public String getTypeName() {
return typeName;
}
@@ -125,7 +197,7 @@ public class AtlasStruct implements Serializable {
public boolean hasAttribute(String name) {
Map<String, Object> a = this.attributes;
- return a != null ? a.containsKey(name) : false;
+ return a != null && a.containsKey(name);
}
public Object getAttribute(String name) {
@@ -141,6 +213,7 @@ public class AtlasStruct implements Serializable {
a.put(name, value);
} else {
a = new HashMap<>();
+
a.put(name, value);
this.attributes = a;
@@ -168,19 +241,23 @@ public class AtlasStruct implements Serializable {
return sb;
}
+ @Override
+ public int hashCode() {
+ return Objects.hash(typeName, attributes);
+ }
+
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ if (this == o) {
+ return true;
+ } else if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
AtlasStruct that = (AtlasStruct) o;
return Objects.equals(typeName, that.typeName) &&
- Objects.equals(attributes, that.attributes);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(typeName, attributes);
+ Objects.equals(attributes, that.attributes);
}
@Override
@@ -188,13 +265,12 @@ public class AtlasStruct implements Serializable {
return toString(new StringBuilder()).toString();
}
-
/**
* REST serialization friendly list.
*/
- @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
- @JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
- @JsonIgnoreProperties(ignoreUnknown=true)
+ @JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ @JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
@XmlSeeAlso(AtlasStruct.class)
@@ -209,82 +285,8 @@ public class AtlasStruct implements Serializable {
super(list);
}
- public AtlasStructs(List list, long startIndex, int pageSize, long totalCount,
- SortType sortType, String sortBy) {
+ public AtlasStructs(List<AtlasStruct> list, long startIndex, int pageSize, long totalCount, SortType sortType, String sortBy) {
super(list, startIndex, pageSize, totalCount, sortType, sortBy);
}
}
-
-
- public static StringBuilder dumpModelObjects(Collection<? extends AtlasStruct> objList, StringBuilder sb) {
- if (sb == null) {
- sb = new StringBuilder();
- }
-
- if (CollectionUtils.isNotEmpty(objList)) {
- int i = 0;
- for (AtlasStruct obj : objList) {
- if (i > 0) {
- sb.append(", ");
- }
-
- obj.toString(sb);
- i++;
- }
- }
-
- return sb;
- }
-
- public static StringBuilder dumpObjects(Collection<?> objects, StringBuilder sb) {
- if (sb == null) {
- sb = new StringBuilder();
- }
-
- if (CollectionUtils.isNotEmpty(objects)) {
- int i = 0;
- for (Object obj : objects) {
- if (i > 0) {
- sb.append(", ");
- }
-
- sb.append(obj);
- i++;
- }
- }
-
- return sb;
- }
-
- public static StringBuilder dumpObjects(Map<?, ?> objects, StringBuilder sb) {
- if (sb == null) {
- sb = new StringBuilder();
- }
-
- if (MapUtils.isNotEmpty(objects)) {
- int i = 0;
- for (Map.Entry<?, ?> e : objects.entrySet()) {
- if (i > 0) {
- sb.append(", ");
- }
-
- sb.append(e.getKey()).append(":").append(e.getValue());
- i++;
- }
- }
-
- return sb;
- }
-
- public static StringBuilder dumpDateField(String prefix, Date value, StringBuilder sb) {
- sb.append(prefix);
-
- if (value == null) {
- sb.append(value);
- } else {
- sb.append(AtlasBaseTypeDef.getDateFormatter().format(value));
- }
-
- return sb;
- }
}
diff --git a/intg/src/main/java/org/apache/atlas/model/instance/ClassificationAssociateRequest.java b/intg/src/main/java/org/apache/atlas/model/instance/ClassificationAssociateRequest.java
index f22521364..899a83abe 100644
--- a/intg/src/main/java/org/apache/atlas/model/instance/ClassificationAssociateRequest.java
+++ b/intg/src/main/java/org/apache/atlas/model/instance/ClassificationAssociateRequest.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -17,11 +17,9 @@
*/
package org.apache.atlas.model.instance;
-
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-
+import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
import org.apache.commons.collections.CollectionUtils;
@@ -29,23 +27,26 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
-import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
-import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
-
+import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.Objects;
-@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown=true)
+import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
+import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
+
+@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
-public class ClassificationAssociateRequest {
- private AtlasClassification classification;
- private List<String> entityGuids;
- private List<Map<String, Object>> entitiesUniqueAttributes;
- private String entityTypeName;
+public class ClassificationAssociateRequest implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private AtlasClassification classification;
+ private List<String> entityGuids;
+ private List<Map<String, Object>> entitiesUniqueAttributes;
+ private String entityTypeName;
public ClassificationAssociateRequest() {
this(null, null);
@@ -85,19 +86,34 @@ public class ClassificationAssociateRequest {
this.entitiesUniqueAttributes = entitiesUniqueAttributes;
}
- public AtlasClassification getClassification() { return classification; }
+ public AtlasClassification getClassification() {
+ return classification;
+ }
- public void setClassification(AtlasClassification classification) { this.classification = classification; }
+ public void setClassification(AtlasClassification classification) {
+ this.classification = classification;
+ }
- public List<String> getEntityGuids() { return entityGuids; }
+ public List<String> getEntityGuids() {
+ return entityGuids;
+ }
- public void setEntityGuids(List<String> entityGuids) { this.entityGuids = entityGuids; }
+ public void setEntityGuids(List<String> entityGuids) {
+ this.entityGuids = entityGuids;
+ }
@Override
- public boolean equals(Object o) {
- if (this == o) { return true; }
+ public int hashCode() {
+ return Objects.hash(classification, entityGuids, entitiesUniqueAttributes);
+ }
- if (o == null || getClass() != o.getClass()) { return false; }
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ } else if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
ClassificationAssociateRequest that = (ClassificationAssociateRequest) o;
@@ -105,8 +121,8 @@ public class ClassificationAssociateRequest {
}
@Override
- public int hashCode() {
- return Objects.hash(classification, entityGuids, entitiesUniqueAttributes);
+ public String toString() {
+ return toString(new StringBuilder()).toString();
}
public StringBuilder toString(StringBuilder sb) {
@@ -134,9 +150,4 @@ public class ClassificationAssociateRequest {
return sb;
}
-
- @Override
- public String toString() {
- return toString(new StringBuilder()).toString();
- }
}
diff --git a/intg/src/main/java/org/apache/atlas/model/instance/EntityMutationResponse.java b/intg/src/main/java/org/apache/atlas/model/instance/EntityMutationResponse.java
index aa5e8a3e6..ff3150e64 100644
--- a/intg/src/main/java/org/apache/atlas/model/instance/EntityMutationResponse.java
+++ b/intg/src/main/java/org/apache/atlas/model/instance/EntityMutationResponse.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -17,11 +17,10 @@
*/
package org.apache.atlas.model.instance;
-
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.atlas.model.instance.EntityMutations.EntityOperation;
import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
import org.apache.commons.collections.CollectionUtils;
@@ -30,18 +29,25 @@ import org.apache.commons.lang.StringUtils;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
-import java.util.*;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
import java.util.stream.Collectors;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
-@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown=true)
+@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
-public class EntityMutationResponse {
+public class EntityMutationResponse implements Serializable {
+ private static final long serialVersionUID = 1L;
private Map<EntityOperation, List<AtlasEntityHeader>> mutatedEntities;
private Map<String, String> guidAssignments;
@@ -61,80 +67,86 @@ public class EntityMutationResponse {
this.mutatedEntities = mutatedEntities;
}
- public void setGuidAssignments(Map<String,String> guidAssignments) {
- this.guidAssignments = guidAssignments;
- }
-
- public Map<String,String> getGuidAssignments() {
+ public Map<String, String> getGuidAssignments() {
return guidAssignments;
}
+ public void setGuidAssignments(Map<String, String> guidAssignments) {
+ this.guidAssignments = guidAssignments;
+ }
@JsonIgnore
public List<AtlasEntityHeader> getEntitiesByOperation(EntityOperation op) {
- if ( mutatedEntities != null) {
+ if (mutatedEntities != null) {
return mutatedEntities.get(op);
}
+
return null;
}
@JsonIgnore
public List<AtlasEntityHeader> getCreatedEntities() {
- if ( mutatedEntities != null) {
+ if (mutatedEntities != null) {
return mutatedEntities.get(EntityOperation.CREATE);
}
+
return null;
}
@JsonIgnore
public List<AtlasEntityHeader> getUpdatedEntities() {
- if ( mutatedEntities != null) {
+ if (mutatedEntities != null) {
return mutatedEntities.get(EntityOperation.UPDATE);
}
+
return null;
}
public List<AtlasEntityHeader> getPartialUpdatedEntities() {
- if ( mutatedEntities != null) {
+ if (mutatedEntities != null) {
return mutatedEntities.get(EntityOperation.PARTIAL_UPDATE);
}
+
return null;
}
@JsonIgnore
public List<AtlasEntityHeader> getDeletedEntities() {
- if ( mutatedEntities != null) {
+ if (mutatedEntities != null) {
return mutatedEntities.get(EntityOperation.DELETE);
}
+
return null;
}
@JsonIgnore
public List<AtlasEntityHeader> getPurgedEntities() {
- if ( mutatedEntities != null) {
+ if (mutatedEntities != null) {
return mutatedEntities.get(EntityOperation.PURGE);
}
+
return null;
}
@JsonIgnore
public String getPurgedEntitiesIds() {
- String ret = null;
+ String ret = null;
List<AtlasEntityHeader> purgedEntities = getPurgedEntities();
if (CollectionUtils.isNotEmpty(purgedEntities)) {
- List<String> entityIds = purgedEntities.stream().map(entity -> entity.getGuid()).collect(Collectors.toList());
+ List<String> entityIds = purgedEntities.stream().map(AtlasEntityHeader::getGuid).collect(Collectors.toList());
ret = String.join(",", entityIds);
}
- return ret;
+ return ret;
}
@JsonIgnore
public AtlasEntityHeader getFirstEntityCreated() {
final List<AtlasEntityHeader> entitiesByOperation = getEntitiesByOperation(EntityOperation.CREATE);
- if ( entitiesByOperation != null && entitiesByOperation.size() > 0) {
+
+ if (entitiesByOperation != null && !entitiesByOperation.isEmpty()) {
return entitiesByOperation.get(0);
}
@@ -145,7 +157,7 @@ public class EntityMutationResponse {
public AtlasEntityHeader getFirstEntityUpdated() {
final List<AtlasEntityHeader> entitiesByOperation = getEntitiesByOperation(EntityOperation.UPDATE);
- if ( entitiesByOperation != null && entitiesByOperation.size() > 0) {
+ if (entitiesByOperation != null && !entitiesByOperation.isEmpty()) {
return entitiesByOperation.get(0);
}
@@ -155,7 +167,8 @@ public class EntityMutationResponse {
@JsonIgnore
public AtlasEntityHeader getFirstEntityPartialUpdated() {
final List<AtlasEntityHeader> entitiesByOperation = getEntitiesByOperation(EntityOperation.PARTIAL_UPDATE);
- if ( entitiesByOperation != null && entitiesByOperation.size() > 0) {
+
+ if (entitiesByOperation != null && !entitiesByOperation.isEmpty()) {
return entitiesByOperation.get(0);
}
@@ -226,35 +239,15 @@ public class EntityMutationResponse {
mutatedEntities = new HashMap<>();
}
- List<AtlasEntityHeader> opEntities = mutatedEntities.get(op);
-
- if (opEntities == null) {
- opEntities = new ArrayList<>();
- mutatedEntities.put(op, opEntities);
- }
+ List<AtlasEntityHeader> opEntities = mutatedEntities.computeIfAbsent(op, k -> new ArrayList<>());
if (!entityHeaderExists(opEntities, header.getGuid())) {
opEntities.add(header);
}
}
- private boolean entityHeaderExists(List<AtlasEntityHeader> entityHeaders, String guid) {
- boolean ret = false;
-
- if (CollectionUtils.isNotEmpty(entityHeaders) && guid != null) {
- for (AtlasEntityHeader entityHeader : entityHeaders) {
- if (StringUtils.equals(entityHeader.getGuid(), guid)) {
- ret = true;
- break;
- }
- }
- }
-
- return ret;
- }
-
public StringBuilder toString(StringBuilder sb) {
- if ( sb == null) {
+ if (sb == null) {
sb = new StringBuilder();
}
@@ -264,17 +257,22 @@ public class EntityMutationResponse {
}
@Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- EntityMutationResponse that = (EntityMutationResponse) o;
- return Objects.equals(mutatedEntities, that.mutatedEntities) &&
- Objects.equals(guidAssignments, that.guidAssignments);
+ public int hashCode() {
+ return Objects.hash(mutatedEntities, guidAssignments);
}
@Override
- public int hashCode() {
- return Objects.hash(mutatedEntities, guidAssignments);
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ } else if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ EntityMutationResponse that = (EntityMutationResponse) o;
+
+ return Objects.equals(mutatedEntities, that.mutatedEntities) &&
+ Objects.equals(guidAssignments, that.guidAssignments);
}
@Override
@@ -282,32 +280,49 @@ public class EntityMutationResponse {
return toString(new StringBuilder()).toString();
}
+ private boolean entityHeaderExists(List<AtlasEntityHeader> entityHeaders, String guid) {
+ boolean ret = false;
+
+ if (CollectionUtils.isNotEmpty(entityHeaders) && guid != null) {
+ for (AtlasEntityHeader entityHeader : entityHeaders) {
+ if (StringUtils.equals(entityHeader.getGuid(), guid)) {
+ ret = true;
+ break;
+ }
+ }
+ }
+
+ return ret;
+ }
+
private AtlasEntityHeader getFirstEntityByType(List<AtlasEntityHeader> entitiesByOperation, String typeName) {
- if ( entitiesByOperation != null && entitiesByOperation.size() > 0) {
+ if (entitiesByOperation != null && !entitiesByOperation.isEmpty()) {
for (AtlasEntityHeader header : entitiesByOperation) {
- if ( header.getTypeName().equals(typeName)) {
+ if (header.getTypeName().equals(typeName)) {
return header;
}
}
}
+
return null;
}
private List<AtlasEntityHeader> getEntitiesByType(List<AtlasEntityHeader> entitiesByOperation, String typeName) {
List<AtlasEntityHeader> ret = new ArrayList<>();
- if ( entitiesByOperation != null && entitiesByOperation.size() > 0) {
+ if (entitiesByOperation != null && !entitiesByOperation.isEmpty()) {
for (AtlasEntityHeader header : entitiesByOperation) {
- if ( header.getTypeName().equals(typeName)) {
+ if (header.getTypeName().equals(typeName)) {
ret.add(header);
}
}
}
+
return ret;
}
private AtlasEntityHeader getEntityByTypeAndUniqueAttribute(List<AtlasEntityHeader> entitiesByOperation, String typeName, String attrName, String attrVal) {
- if (entitiesByOperation != null && entitiesByOperation.size() > 0) {
+ if (entitiesByOperation != null && !entitiesByOperation.isEmpty()) {
for (AtlasEntityHeader header : entitiesByOperation) {
if (header.getTypeName().equals(typeName)) {
if (attrVal != null && attrVal.equals(header.getAttribute(attrName))) {
@@ -316,6 +331,7 @@ public class EntityMutationResponse {
}
}
}
+
return null;
}
}
diff --git a/intg/src/main/java/org/apache/atlas/model/instance/EntityMutations.java b/intg/src/main/java/org/apache/atlas/model/instance/EntityMutations.java
index 1dd5aa01b..5af2b1f97 100644
--- a/intg/src/main/java/org/apache/atlas/model/instance/EntityMutations.java
+++ b/intg/src/main/java/org/apache/atlas/model/instance/EntityMutations.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -17,32 +17,80 @@
*/
package org.apache.atlas.model.instance;
-
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-
+import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.commons.collections.CollectionUtils;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
+
import java.io.Serializable;
-import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
-@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown=true)
+@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class EntityMutations implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private List<EntityMutation> entityMutations;
+
+ public EntityMutations(List<EntityMutation> entityMutations) {
+ this.entityMutations = entityMutations;
+ }
+
+ public StringBuilder toString(StringBuilder sb) {
+ if (sb == null) {
+ sb = new StringBuilder();
+ }
+
+ sb.append("EntityMutations{");
- private List<EntityMutation> entityMutations = new ArrayList<>();
+ if (CollectionUtils.isNotEmpty(entityMutations)) {
+ for (int i = 0; i < entityMutations.size(); i++) {
+ if (i > 0) {
+ sb.append(",");
+ }
+
+ entityMutations.get(i).toString(sb);
+ }
+ }
+
+ sb.append("}");
+
+ return sb;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(entityMutations);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ } else if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ EntityMutations that = (EntityMutations) o;
+
+ return Objects.equals(entityMutations, that.entityMutations);
+ }
+
+ @Override
+ public String toString() {
+ return toString(new StringBuilder()).toString();
+ }
public enum EntityOperation {
CREATE,
@@ -53,89 +101,53 @@ public class EntityMutations implements Serializable {
}
public static final class EntityMutation implements Serializable {
- private EntityOperation op;
- private AtlasEntity entity;
+ private final EntityOperation op;
+ private final AtlasEntity entity;
public EntityMutation(EntityOperation op, AtlasEntity entity) {
- this.op = op;
+ this.op = op;
this.entity = entity;
}
public StringBuilder toString(StringBuilder sb) {
- if ( sb == null) {
+ if (sb == null) {
sb = new StringBuilder();
}
+
sb.append("EntityMutation {");
sb.append("op=").append(op);
+
if (entity != null) {
sb.append(", entity=");
entity.toString(sb);
}
+
sb.append("}");
return sb;
}
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- EntityMutation that = (EntityMutation) o;
- return op == that.op &&
- Objects.equals(entity, that.entity);
- }
-
@Override
public int hashCode() {
return Objects.hash(op, entity);
}
@Override
- public String toString() {
- return toString(new StringBuilder()).toString();
- }
- }
-
- public EntityMutations(List<EntityMutation> entityMutations) {
- this.entityMutations = entityMutations;
- }
-
- public StringBuilder toString(StringBuilder sb) {
- if ( sb == null) {
- sb = new StringBuilder();
- }
- sb.append("EntityMutations{");
- if (CollectionUtils.isNotEmpty(entityMutations)) {
- for (int i = 0; i < entityMutations.size(); i++) {
- if (i > 0) {
- sb.append(",");
- }
- entityMutations.get(i).toString(sb);
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ } else if (o == null || getClass() != o.getClass()) {
+ return false;
}
- }
- sb.append("}");
-
- return sb;
- }
-
- @Override
- public String toString() {
- return toString(new StringBuilder()).toString();
- }
+ EntityMutation that = (EntityMutation) o;
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- EntityMutations that = (EntityMutations) o;
- return Objects.equals(entityMutations, that.entityMutations);
- }
+ return op == that.op && Objects.equals(entity, that.entity);
+ }
- @Override
- public int hashCode() {
- return Objects.hash(entityMutations);
+ @Override
+ public String toString() {
+ return toString(new StringBuilder()).toString();
+ }
}
}
-
-
diff --git a/intg/src/main/java/org/apache/atlas/model/instance/GuidMapping.java b/intg/src/main/java/org/apache/atlas/model/instance/GuidMapping.java
index c3cec85a0..48b4d6a31 100644
--- a/intg/src/main/java/org/apache/atlas/model/instance/GuidMapping.java
+++ b/intg/src/main/java/org/apache/atlas/model/instance/GuidMapping.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -17,53 +17,48 @@
*/
package org.apache.atlas.model.instance;
-
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-
-import java.util.Map;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
-import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
+import java.io.Serializable;
+import java.util.Map;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
-
/**
* This stores a mapping of guid assignments that were made during the processing
* of a create or update entity request.
*.
*/
-@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown=true)
+@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
-public class GuidMapping {
+public class GuidMapping implements Serializable {
private static final long serialVersionUID = 1L;
-
- private Map<String,String> guidAssignments;
-
+ private Map<String, String> guidAssignments;
public GuidMapping() {
}
- public GuidMapping(Map<String,String> guidAssignments) {
+ public GuidMapping(Map<String, String> guidAssignments) {
this.guidAssignments = guidAssignments;
}
-
- public Map<String,String> getGuidAssignments() {
+ public Map<String, String> getGuidAssignments() {
return guidAssignments;
}
- public void setGuidAssignments(Map<String,String> guidAssignments) {
+ public void setGuidAssignments(Map<String, String> guidAssignments) {
this.guidAssignments = guidAssignments;
}
@@ -85,4 +80,4 @@ public class GuidMapping {
public String toString() {
return toString(new StringBuilder()).toString();
}
-}
\ No newline at end of file
+}
diff --git a/intg/src/main/java/org/apache/atlas/model/legacy/EntityResult.java b/intg/src/main/java/org/apache/atlas/model/legacy/EntityResult.java
index 52b9ec5b8..82d3ff770 100644
--- a/intg/src/main/java/org/apache/atlas/model/legacy/EntityResult.java
+++ b/intg/src/main/java/org/apache/atlas/model/legacy/EntityResult.java
@@ -17,14 +17,13 @@
*/
package org.apache.atlas.model.legacy;
-
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-
+import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.atlas.type.AtlasType;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -33,10 +32,12 @@ import java.util.Map;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
-@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown=true)
-public class EntityResult {
+@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class EntityResult implements Serializable {
+ private static final long serialVersionUID = 1L;
+
public static final String OP_CREATED = "created";
public static final String OP_UPDATED = "updated";
public static final String OP_DELETED = "deleted";
@@ -53,25 +54,21 @@ public class EntityResult {
set(OP_DELETED, deleted);
}
- public void set(String type, List<String> list) {
- if (list != null && list.size() > 0) {
- entities.put(type, list);
- }
+ public static EntityResult fromString(String json) {
+ return AtlasType.fromV1Json(json, EntityResult.class);
}
- private List<String> get(String type) {
- List<String> list = entities.get(type);
- if (list == null) {
- list = new ArrayList<>();
+ public void set(String type, List<String> list) {
+ if (list != null && !list.isEmpty()) {
+ entities.put(type, list);
}
- return list;
}
- public Map<String, List<String>> getEntities(){
+ public Map<String, List<String>> getEntities() {
return entities;
}
- public void setEntities(Map<String, List<String>> entities){
+ public void setEntities(Map<String, List<String>> entities) {
this.entities = entities;
}
@@ -91,9 +88,17 @@ public class EntityResult {
}
@Override
- public String toString() { return AtlasType.toV1Json(this); }
+ public String toString() {
+ return AtlasType.toV1Json(this);
+ }
- public static EntityResult fromString(String json) {
- return AtlasType.fromV1Json(json, EntityResult.class);
+ private List<String> get(String type) {
+ List<String> list = entities.get(type);
+
+ if (list == null) {
+ list = new ArrayList<>();
+ }
+
+ return list;
}
}
diff --git a/intg/src/main/java/org/apache/atlas/model/lineage/AtlasLineageInfo.java b/intg/src/main/java/org/apache/atlas/model/lineage/AtlasLineageInfo.java
index 9ae6039f1..49d65966a 100644
--- a/intg/src/main/java/org/apache/atlas/model/lineage/AtlasLineageInfo.java
+++ b/intg/src/main/java/org/apache/atlas/model/lineage/AtlasLineageInfo.java
@@ -17,17 +17,16 @@
*/
package org.apache.atlas.model.lineage;
-
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-
import org.apache.atlas.model.instance.AtlasEntityHeader;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
+
import java.io.Serializable;
import java.util.Map;
import java.util.Objects;
@@ -37,11 +36,12 @@ import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true, value = {"visitedEdges"})
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true, value = "visitedEdges")
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class AtlasLineageInfo implements Serializable {
+ private static final long serialVersionUID = 1L;
private String baseEntityGuid;
private LineageDirection lineageDirection;
@@ -52,33 +52,30 @@ public class AtlasLineageInfo implements Serializable {
private Map<String, LineageInfoOnDemand> relationsOnDemand;
private Map<String, LineageOnDemandConstraints> lineageOnDemandPayload;
- public AtlasLineageInfo() {}
-
- public enum LineageDirection { INPUT, OUTPUT, BOTH }
+ public AtlasLineageInfo() {
+ }
/**
* Captures lineage information for an entity instance like hive_table
-
+ *
* @param baseEntityGuid guid of the lineage entity .
* @param lineageDirection direction of lineage, can be INPUT, OUTPUT or INPUT_AND_OUTPUT
- * @param lineageDepth lineage depth to be fetched.
+ * @param lineageDepth lineage depth to be fetched.
* @param guidEntityMap map of entity guid to AtlasEntityHeader (minimal entity info)
* @param relations list of lineage relations for the entity (fromEntityId -> toEntityId)
*/
- public AtlasLineageInfo(String baseEntityGuid, Map<String, AtlasEntityHeader> guidEntityMap,
- Set<LineageRelation> relations, LineageDirection lineageDirection, int lineageDepth) {
+ public AtlasLineageInfo(String baseEntityGuid, Map<String, AtlasEntityHeader> guidEntityMap, Set<LineageRelation> relations, LineageDirection lineageDirection, int lineageDepth) {
this(baseEntityGuid, guidEntityMap, relations, null, null, lineageDirection, lineageDepth);
}
- public AtlasLineageInfo(String baseEntityGuid, Map<String, AtlasEntityHeader> guidEntityMap,
- Set<LineageRelation> relations, Set<String> visitedEdges, Map<String, LineageInfoOnDemand> relationsOnDemand, LineageDirection lineageDirection, int lineageDepth) {
- this.baseEntityGuid = baseEntityGuid;
- this.lineageDirection = lineageDirection;
- this.lineageDepth = lineageDepth;
- this.guidEntityMap = guidEntityMap;
- this.relations = relations;
- this.visitedEdges = visitedEdges;
- this.relationsOnDemand = relationsOnDemand;
+ public AtlasLineageInfo(String baseEntityGuid, Map<String, AtlasEntityHeader> guidEntityMap, Set<LineageRelation> relations, Set<String> visitedEdges, Map<String, LineageInfoOnDemand> relationsOnDemand, LineageDirection lineageDirection, int lineageDepth) {
+ this.baseEntityGuid = baseEntityGuid;
+ this.lineageDirection = lineageDirection;
+ this.lineageDepth = lineageDepth;
+ this.guidEntityMap = guidEntityMap;
+ this.relations = relations;
+ this.visitedEdges = visitedEdges;
+ this.relationsOnDemand = relationsOnDemand;
}
public String getBaseEntityGuid() {
@@ -145,11 +142,21 @@ public class AtlasLineageInfo implements Serializable {
this.lineageOnDemandPayload = lineageOnDemandPayload;
}
+ @Override
+ public int hashCode() {
+ return Objects.hash(baseEntityGuid, lineageDirection, lineageDepth, guidEntityMap, relations);
+ }
+
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ if (this == o) {
+ return true;
+ } else if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
AtlasLineageInfo that = (AtlasLineageInfo) o;
+
return lineageDepth == that.lineageDepth &&
Objects.equals(baseEntityGuid, that.baseEntityGuid) &&
lineageDirection == that.lineageDirection &&
@@ -157,11 +164,6 @@ public class AtlasLineageInfo implements Serializable {
Objects.equals(relations, that.relations);
}
- @Override
- public int hashCode() {
- return Objects.hash(baseEntityGuid, lineageDirection, lineageDepth, guidEntityMap, relations);
- }
-
@Override
public String toString() {
return "AtlasLineageInfo{" +
@@ -174,21 +176,26 @@ public class AtlasLineageInfo implements Serializable {
'}';
}
+ public enum LineageDirection { INPUT, OUTPUT, BOTH }
+
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
- @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+ @JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
- public static class LineageRelation {
+ public static class LineageRelation implements Serializable {
+ private static final long serialVersionUID = 1L;
+
private String fromEntityId;
private String toEntityId;
private String relationshipId;
- public LineageRelation() { }
+ public LineageRelation() {
+ }
public LineageRelation(String fromEntityId, String toEntityId, final String relationshipId) {
- this.fromEntityId = fromEntityId;
- this.toEntityId = toEntityId;
+ this.fromEntityId = fromEntityId;
+ this.toEntityId = toEntityId;
this.relationshipId = relationshipId;
}
@@ -216,21 +223,26 @@ public class AtlasLineageInfo implements Serializable {
this.relationshipId = relationshipId;
}
+ @Override
+ public int hashCode() {
+ return Objects.hash(fromEntityId, toEntityId, relationshipId);
+ }
+
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ if (this == o) {
+ return true;
+ } else if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
LineageRelation that = (LineageRelation) o;
+
return Objects.equals(fromEntityId, that.fromEntityId) &&
Objects.equals(toEntityId, that.toEntityId) &&
Objects.equals(relationshipId, that.relationshipId);
}
- @Override
- public int hashCode() {
- return Objects.hash(fromEntityId, toEntityId, relationshipId);
- }
-
@Override
public String toString() {
return "LineageRelation{" +
@@ -242,22 +254,27 @@ public class AtlasLineageInfo implements Serializable {
}
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
- @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+ @JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true, value = {"inputRelationsReachedLimit", "outputRelationsReachedLimit"})
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
- public static class LineageInfoOnDemand {
+ public static class LineageInfoOnDemand implements Serializable {
+ private static final long serialVersionUID = 1L;
+
@JsonProperty
- boolean hasMoreInputs;
+ boolean hasMoreInputs;
+
@JsonProperty
- boolean hasMoreOutputs;
+ boolean hasMoreOutputs;
+
int inputRelationsCount;
int outputRelationsCount;
boolean isInputRelationsReachedLimit;
boolean isOutputRelationsReachedLimit;
LineageOnDemandConstraints onDemandConstraints;
- public LineageInfoOnDemand() { }
+ public LineageInfoOnDemand() {
+ }
public LineageInfoOnDemand(LineageOnDemandConstraints onDemandConstraints) {
this.onDemandConstraints = onDemandConstraints;
@@ -319,7 +336,6 @@ public class AtlasLineageInfo implements Serializable {
if (inputRelationsCount == onDemandConstraints.getInputRelationsLimit()) {
this.setInputRelationsReachedLimit(true);
- return;
}
}
@@ -341,7 +357,6 @@ public class AtlasLineageInfo implements Serializable {
if (outputRelationsCount == onDemandConstraints.getOutputRelationsLimit()) {
this.setOutputRelationsReachedLimit(true);
- return;
}
}
@@ -354,7 +369,5 @@ public class AtlasLineageInfo implements Serializable {
", outputRelationsCount='" + outputRelationsCount + '\'' +
'}';
}
-
}
-
-}
\ No newline at end of file
+}
diff --git a/intg/src/main/java/org/apache/atlas/model/lineage/LineageOnDemandConstraints.java b/intg/src/main/java/org/apache/atlas/model/lineage/LineageOnDemandConstraints.java
index 0b3ea2418..6d40b395b 100644
--- a/intg/src/main/java/org/apache/atlas/model/lineage/LineageOnDemandConstraints.java
+++ b/intg/src/main/java/org/apache/atlas/model/lineage/LineageOnDemandConstraints.java
@@ -17,10 +17,9 @@
*/
package org.apache.atlas.model.lineage;
-
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.atlas.AtlasConfiguration;
import org.apache.atlas.model.lineage.AtlasLineageInfo.LineageDirection;
@@ -30,7 +29,7 @@ import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
/**
* This is the root class representing the input for lineage search on-demand.
@@ -38,14 +37,14 @@ import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_
public class LineageOnDemandConstraints implements Serializable {
private static final long serialVersionUID = 1L;
+ private static final int LINEAGE_ON_DEMAND_DEFAULT_NODE_COUNT = AtlasConfiguration.LINEAGE_ON_DEMAND_DEFAULT_NODE_COUNT.getInt();
+ private static final int LINEAGE_ON_DEMAND_DEFAULT_DEPTH = 3;
+
private LineageDirection direction;
private int inputRelationsLimit;
private int outputRelationsLimit;
private int depth;
- private static final int LINEAGE_ON_DEMAND_DEFAULT_NODE_COUNT = AtlasConfiguration.LINEAGE_ON_DEMAND_DEFAULT_NODE_COUNT.getInt();
- private static final int LINEAGE_ON_DEMAND_DEFAULT_DEPTH = 3;
-
public LineageOnDemandConstraints() {
this(LineageDirection.BOTH, LINEAGE_ON_DEMAND_DEFAULT_NODE_COUNT, LINEAGE_ON_DEMAND_DEFAULT_NODE_COUNT, LINEAGE_ON_DEMAND_DEFAULT_DEPTH);
}
@@ -88,5 +87,4 @@ public class LineageOnDemandConstraints implements Serializable {
public void setDepth(int depth) {
this.depth = depth;
}
-
}
diff --git a/intg/src/main/java/org/apache/atlas/model/metrics/AtlasMetrics.java b/intg/src/main/java/org/apache/atlas/model/metrics/AtlasMetrics.java
index c968302b7..f50876e48 100644
--- a/intg/src/main/java/org/apache/atlas/model/metrics/AtlasMetrics.java
+++ b/intg/src/main/java/org/apache/atlas/model/metrics/AtlasMetrics.java
@@ -17,12 +17,12 @@
*/
package org.apache.atlas.model.metrics;
-
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
@@ -32,10 +32,12 @@ import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_
/**
* Atlas metrics
*/
-@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown=true)
-public class AtlasMetrics {
+@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class AtlasMetrics implements Serializable {
+ private static final long serialVersionUID = 1L;
+
public static final String PREFIX_CONNECTION_STATUS = "ConnectionStatus:";
public static final String PREFIX_NOTIFICATION = "Notification:";
public static final String PREFIX_SERVER = "Server:";
diff --git a/intg/src/main/java/org/apache/atlas/model/metrics/AtlasMetricsMapToChart.java b/intg/src/main/java/org/apache/atlas/model/metrics/AtlasMetricsMapToChart.java
index 6e74f6575..2a72f8373 100644
--- a/intg/src/main/java/org/apache/atlas/model/metrics/AtlasMetricsMapToChart.java
+++ b/intg/src/main/java/org/apache/atlas/model/metrics/AtlasMetricsMapToChart.java
@@ -19,8 +19,9 @@ package org.apache.atlas.model.metrics;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import java.io.Serializable;
import java.util.List;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
@@ -34,10 +35,12 @@ import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_
* The second element is the Atlas Metrics entity's count. It is used for rendering y-axis of the chart.
*/
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
-public class AtlasMetricsMapToChart {
- private String key;
+public class AtlasMetricsMapToChart implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private String key;
private List<long[]> values;
public AtlasMetricsMapToChart(String key, List<long[]> values) {
@@ -45,7 +48,9 @@ public class AtlasMetricsMapToChart {
this.values = values;
}
- public String getKey() { return key; }
+ public String getKey() {
+ return key;
+ }
public void setKey(String key) {
this.key = key;
@@ -58,5 +63,4 @@ public class AtlasMetricsMapToChart {
public void setValues(List<long[]> values) {
this.values = values;
}
-
-}
\ No newline at end of file
+}
diff --git a/intg/src/main/java/org/apache/atlas/model/metrics/AtlasMetricsStat.java b/intg/src/main/java/org/apache/atlas/model/metrics/AtlasMetricsStat.java
index 5a30cad06..f6baa0249 100644
--- a/intg/src/main/java/org/apache/atlas/model/metrics/AtlasMetricsStat.java
+++ b/intg/src/main/java/org/apache/atlas/model/metrics/AtlasMetricsStat.java
@@ -17,11 +17,9 @@
*/
package org.apache.atlas.model.metrics;
-
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.apache.atlas.AtlasConfiguration;
import org.apache.atlas.model.AtlasBaseModelObject;
import org.apache.atlas.utils.AtlasEntityUtil;
@@ -37,22 +35,22 @@ import java.util.concurrent.TimeUnit;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
-
/**
* Atlas MetricsStat which includes Metrics' collection time and time to live (TTL).
*/
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class AtlasMetricsStat extends AtlasBaseModelObject implements Serializable {
+ private static final long serialVersionUID = 1L;
- public static final String METRICS_CATEGORY_GENERAL_PROPERTY = "general";
- public static final String METRICS_COLLECTION_TIME_PROPERTY = "collectionTime";
- public static final String METRICS_ID_PREFIX_PROPERTY = "atlas_metrics_";
+ public static final String METRICS_CATEGORY_GENERAL_PROPERTY = "general";
+ public static final String METRICS_COLLECTION_TIME_PROPERTY = "collectionTime";
+ public static final String METRICS_ID_PREFIX_PROPERTY = "atlas_metrics_";
- private String metricsId;
- private long collectionTime;
- private long timeToLiveMillis;
+ private String metricsId;
+ private long collectionTime;
+ private long timeToLiveMillis;
private Map<String, Object> typeData;
@@ -66,32 +64,28 @@ public class AtlasMetricsStat extends AtlasBaseModelObject implements Serializab
setGuid(guid);
}
- public AtlasMetricsStat(AtlasMetrics metrics){
+ public AtlasMetricsStat(AtlasMetrics metrics) {
this(metrics, null);
}
- public AtlasMetricsStat(AtlasMetrics metrics,List<String> listOfTypeNames) {
- this(metrics, TimeUnit.HOURS.toMillis(AtlasConfiguration.METRICS_TIME_TO_LIVE_HOURS.getInt()),listOfTypeNames);
-
+ public AtlasMetricsStat(AtlasMetrics metrics, List<String> listOfTypeNames) {
+ this(metrics, TimeUnit.HOURS.toMillis(AtlasConfiguration.METRICS_TIME_TO_LIVE_HOURS.getInt()), listOfTypeNames);
}
public AtlasMetricsStat(AtlasMetrics metrics, long timeToLiveMillis, List<String> listOfTypeNames) {
- collectionTime = metrics == null ?
- System.currentTimeMillis() : (long) metrics.getMetric(METRICS_CATEGORY_GENERAL_PROPERTY, METRICS_COLLECTION_TIME_PROPERTY);
- setCollectionTime(collectionTime);
+ collectionTime = metrics == null ? System.currentTimeMillis() : (long) metrics.getMetric(METRICS_CATEGORY_GENERAL_PROPERTY, METRICS_COLLECTION_TIME_PROPERTY);
+ setCollectionTime(collectionTime);
setMetricsId(METRICS_ID_PREFIX_PROPERTY + getCollectionTime() + "@" + AtlasEntityUtil.getMetadataNamespace());
-
setTimeToLiveMillis(timeToLiveMillis);
setMetrics(metrics);
setGuid(getGuid());
this.typeData = CollectionUtils.isEmpty(listOfTypeNames) ? null : new HashMap<>();
+
AtlasEntityUtil.metricsToTypeData(metrics, listOfTypeNames, typeData);
}
-
-
public String getMetricsId() {
return metricsId;
}
@@ -130,10 +124,16 @@ public class AtlasMetricsStat extends AtlasBaseModelObject implements Serializab
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- if (!super.equals(o)) return false;
+ if (this == o) {
+ return true;
+ } else if (o == null || getClass() != o.getClass()) {
+ return false;
+ } else if (!super.equals(o)) {
+ return false;
+ }
+
AtlasMetricsStat that = (AtlasMetricsStat) o;
+
return Objects.equals(metrics, that.metrics);
}
@@ -147,6 +147,7 @@ public class AtlasMetricsStat extends AtlasBaseModelObject implements Serializab
sb.append(", metricsId=").append(metricsId);
sb.append(", collectionTime=").append(collectionTime);
sb.append(", timeToLiveMillis=").append(timeToLiveMillis);
+
sb.append(", metrics=");
if (metrics == null) {
sb.append("null");
@@ -156,4 +157,4 @@ public class AtlasMetricsStat extends AtlasBaseModelObject implements Serializab
return sb;
}
-}
\ No newline at end of file
+}
diff --git a/intg/src/main/java/org/apache/atlas/model/migration/MigrationImportStatus.java b/intg/src/main/java/org/apache/atlas/model/migration/MigrationImportStatus.java
index 1db5f2006..2b832cd1d 100644
--- a/intg/src/main/java/org/apache/atlas/model/migration/MigrationImportStatus.java
+++ b/intg/src/main/java/org/apache/atlas/model/migration/MigrationImportStatus.java
@@ -20,16 +20,20 @@ package org.apache.atlas.model.migration;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.atlas.model.impexp.MigrationStatus;
+import java.io.Serializable;
+
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
-public class MigrationImportStatus extends MigrationStatus {
+public class MigrationImportStatus extends MigrationStatus implements Serializable {
+ private static final long serialVersionUID = 1L;
+
private String name;
private String fileHash;
@@ -50,24 +54,22 @@ public class MigrationImportStatus extends MigrationStatus {
return name;
}
- public String getFileHash() {
- return fileHash;
- }
-
public void setName(String name) {
this.name = name;
}
+ public String getFileHash() {
+ return fileHash;
+ }
+
public void setFileHash(String fileHash) {
this.fileHash = fileHash;
}
@Override
public String toString() {
- final StringBuilder sb = new StringBuilder("MigrationImportStatus{");
- sb.append("name='").append(name).append('\'');
- sb.append(", fileHash='").append(fileHash).append('\'');
- sb.append('}');
- return sb.toString();
+ return "MigrationImportStatus{" + "name='" + name + '\'' +
+ ", fileHash='" + fileHash + '\'' +
+ '}';
}
}
diff --git a/intg/src/main/java/org/apache/atlas/model/notification/AtlasNotificationBaseMessage.java b/intg/src/main/java/org/apache/atlas/model/notification/AtlasNotificationBaseMessage.java
index 97fcbac6a..b3793491f 100644
--- a/intg/src/main/java/org/apache/atlas/model/notification/AtlasNotificationBaseMessage.java
+++ b/intg/src/main/java/org/apache/atlas/model/notification/AtlasNotificationBaseMessage.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -20,8 +20,7 @@ package org.apache.atlas.model.notification;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-
+import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.atlas.AtlasConfiguration;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.binary.StringUtils;
@@ -32,37 +31,37 @@ import org.slf4j.LoggerFactory;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.io.Serializable;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
-
-@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown=true)
+@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
-public class AtlasNotificationBaseMessage {
+public class AtlasNotificationBaseMessage implements Serializable {
+ private static final long serialVersionUID = 1L;
+
private static final Logger LOG = LoggerFactory.getLogger(AtlasNotificationBaseMessage.class);
public static final int MESSAGE_MAX_LENGTH_BYTES = AtlasConfiguration.NOTIFICATION_MESSAGE_MAX_LENGTH_BYTES.getInt() - 512; // 512 bytes for envelop;
public static final boolean MESSAGE_COMPRESSION_ENABLED = AtlasConfiguration.NOTIFICATION_MESSAGE_COMPRESSION_ENABLED.getBoolean();
- public enum CompressionKind { NONE, GZIP };
-
- private MessageSource source = null;
- private MessageVersion version = null;
- private String msgId = null;
+ private MessageSource source;
+ private MessageVersion version;
+ private String msgId;
private CompressionKind msgCompressionKind = CompressionKind.NONE;
private int msgSplitIdx = 1;
private int msgSplitCount = 1;
-
public AtlasNotificationBaseMessage() {
}
@@ -71,11 +70,11 @@ public class AtlasNotificationBaseMessage {
}
public AtlasNotificationBaseMessage(MessageVersion version, String msgId, CompressionKind msgCompressionKind) {
- this (version, msgId, msgCompressionKind, null);
+ this(version, msgId, msgCompressionKind, null);
}
public AtlasNotificationBaseMessage(MessageVersion version, MessageSource source) {
- this (version, null, CompressionKind.NONE, source);
+ this(version, null, CompressionKind.NONE, source);
}
public AtlasNotificationBaseMessage(MessageVersion version, String msgId, CompressionKind msgCompressionKind, MessageSource source) {
@@ -93,67 +92,6 @@ public class AtlasNotificationBaseMessage {
this.msgSplitCount = msgSplitCount;
}
- public void setVersion(MessageVersion version) {
- this.version = version;
- }
-
- public MessageVersion getVersion() {
- return version;
- }
-
- public void setSource(MessageSource source) {
- this.source = source;
- }
-
- public MessageSource getSource() {
- return source;
- }
-
- public String getMsgId() {
- return msgId;
- }
-
- public void setMsgId(String msgId) {
- this.msgId = msgId;
- }
-
- public CompressionKind getMsgCompressionKind() {
- return msgCompressionKind;
- }
-
- public void setMsgCompressed(CompressionKind msgCompressionKind) {
- this.msgCompressionKind = msgCompressionKind;
- }
-
- public int getMsgSplitIdx() {
- return msgSplitIdx;
- }
-
- public void setMsgSplitIdx(int msgSplitIdx) {
- this.msgSplitIdx = msgSplitIdx;
- }
-
- public int getMsgSplitCount() {
- return msgSplitCount;
- }
-
- public void setMsgSplitCount(int msgSplitCount) {
- this.msgSplitCount = msgSplitCount;
- }
-
- /**
- * Compare the version of this message with the given version.
- *
- * @param compareToVersion the version to compare to
- *
- * @return a negative integer, zero, or a positive integer as this message's version is less than, equal to,
- * or greater than the given version.
- */
- public int compareVersion(MessageVersion compareToVersion) {
- return version.compareTo(compareToVersion);
- }
-
-
public static byte[] getBytesUtf8(String str) {
return StringUtils.getBytesUtf8(str);
}
@@ -222,5 +160,66 @@ public class AtlasNotificationBaseMessage {
return out.toByteArray();
}
-}
+ public MessageVersion getVersion() {
+ return version;
+ }
+
+ public void setVersion(MessageVersion version) {
+ this.version = version;
+ }
+
+ public MessageSource getSource() {
+ return source;
+ }
+
+ public void setSource(MessageSource source) {
+ this.source = source;
+ }
+
+ public String getMsgId() {
+ return msgId;
+ }
+
+ public void setMsgId(String msgId) {
+ this.msgId = msgId;
+ }
+
+ public CompressionKind getMsgCompressionKind() {
+ return msgCompressionKind;
+ }
+
+ public void setMsgCompressed(CompressionKind msgCompressionKind) {
+ this.msgCompressionKind = msgCompressionKind;
+ }
+
+ public int getMsgSplitIdx() {
+ return msgSplitIdx;
+ }
+
+ public void setMsgSplitIdx(int msgSplitIdx) {
+ this.msgSplitIdx = msgSplitIdx;
+ }
+
+ public int getMsgSplitCount() {
+ return msgSplitCount;
+ }
+
+ public void setMsgSplitCount(int msgSplitCount) {
+ this.msgSplitCount = msgSplitCount;
+ }
+
+ /**
+ * Compare the version of this message with the given version.
+ *
+ * @param compareToVersion the version to compare to
+ *
+ * @return a negative integer, zero, or a positive integer as this message's version is less than, equal to,
+ * or greater than the given version.
+ */
+ public int compareVersion(MessageVersion compareToVersion) {
+ return version.compareTo(compareToVersion);
+ }
+
+ public enum CompressionKind { NONE, GZIP }
+}
diff --git a/intg/src/main/java/org/apache/atlas/model/notification/AtlasNotificationMessage.java b/intg/src/main/java/org/apache/atlas/model/notification/AtlasNotificationMessage.java
index 42032b409..60b600c6e 100644
--- a/intg/src/main/java/org/apache/atlas/model/notification/AtlasNotificationMessage.java
+++ b/intg/src/main/java/org/apache/atlas/model/notification/AtlasNotificationMessage.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -18,14 +18,15 @@
package org.apache.atlas.model.notification;
-
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.annotation.JsonInclude;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
+
+import java.io.Serializable;
import java.util.Date;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
@@ -34,12 +35,14 @@ import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_
/**
* Represents a notification message that is associated with a version.
*/
-@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown=true)
+@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
-public class AtlasNotificationMessage<T> extends AtlasNotificationBaseMessage {
+public class AtlasNotificationMessage<T> extends AtlasNotificationBaseMessage implements Serializable {
+ private static final long serialVersionUID = 1L;
+
private String msgSourceIP;
private String msgCreatedBy;
private long msgCreationTime;
@@ -50,7 +53,6 @@ public class AtlasNotificationMessage<T> extends AtlasNotificationBaseMessage {
*/
private T message;
-
// ----- Constructors ----------------------------------------------------
public AtlasNotificationMessage() {
}
@@ -109,11 +111,11 @@ public class AtlasNotificationMessage<T> extends AtlasNotificationBaseMessage {
this.message = message;
}
- public void setSpooled(boolean val) {
- this.spooled = val;
- }
-
public boolean getSpooled() {
return spooled;
}
+
+ public void setSpooled(boolean val) {
+ this.spooled = val;
+ }
}
diff --git a/intg/src/main/java/org/apache/atlas/model/notification/AtlasNotificationStringMessage.java b/intg/src/main/java/org/apache/atlas/model/notification/AtlasNotificationStringMessage.java
index bc8442785..57df351db 100644
--- a/intg/src/main/java/org/apache/atlas/model/notification/AtlasNotificationStringMessage.java
+++ b/intg/src/main/java/org/apache/atlas/model/notification/AtlasNotificationStringMessage.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -18,25 +18,28 @@
package org.apache.atlas.model.notification;
-
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.annotation.JsonInclude;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
-@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown=true)
+@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
-public class AtlasNotificationStringMessage extends AtlasNotificationBaseMessage {
- private String message = null;
+public class AtlasNotificationStringMessage extends AtlasNotificationBaseMessage implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private String message;
public AtlasNotificationStringMessage() {
super(MessageVersion.CURRENT_VERSION);
@@ -72,11 +75,11 @@ public class AtlasNotificationStringMessage extends AtlasNotificationBaseMessage
this.message = new String(encodedBytes, offset, length);
}
- public void setMessage(String message) {
- this.message = message;
- }
-
public String getMessage() {
return message;
}
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
}
diff --git a/intg/src/main/java/org/apache/atlas/model/notification/EntityNotification.java b/intg/src/main/java/org/apache/atlas/model/notification/EntityNotification.java
index 74ea79c7b..4501c5d09 100644
--- a/intg/src/main/java/org/apache/atlas/model/notification/EntityNotification.java
+++ b/intg/src/main/java/org/apache/atlas/model/notification/EntityNotification.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -19,13 +19,14 @@ package org.apache.atlas.model.notification;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.atlas.model.instance.AtlasEntityHeader;
import org.apache.atlas.model.instance.AtlasRelationshipHeader;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
+
import java.io.Serializable;
import java.util.Objects;
@@ -36,21 +37,14 @@ import static org.apache.atlas.model.notification.EntityNotification.EntityNotif
/**
* Base type of hook message.
*/
-@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
-@JsonSerialize(include=JsonSerialize.Inclusion.ALWAYS)
-@JsonIgnoreProperties(ignoreUnknown=true)
+@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
+@JsonInclude(JsonInclude.Include.ALWAYS)
+@JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class EntityNotification implements Serializable {
private static final long serialVersionUID = 1L;
- /**
- * Type of the hook message.
- */
- public enum EntityNotificationType {
- ENTITY_NOTIFICATION_V1, ENTITY_NOTIFICATION_V2
- }
-
protected EntityNotificationType type;
public EntityNotification() {
@@ -69,7 +63,7 @@ public class EntityNotification implements Serializable {
this.type = type;
}
- public void normalize() { }
+ public void normalize() {}
@Override
public String toString() {
@@ -88,27 +82,28 @@ public class EntityNotification implements Serializable {
return sb;
}
+ /**
+ * Type of the hook message.
+ */
+ public enum EntityNotificationType {
+ ENTITY_NOTIFICATION_V1, ENTITY_NOTIFICATION_V2
+ }
+
/**
* Entity v2 notification
*/
- @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
- @JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
- @JsonIgnoreProperties(ignoreUnknown=true)
+ @JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ @JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public static class EntityNotificationV2 extends EntityNotification implements Serializable {
private static final long serialVersionUID = 1L;
- public enum OperationType {
- ENTITY_CREATE, ENTITY_UPDATE, ENTITY_DELETE,
- CLASSIFICATION_ADD, CLASSIFICATION_DELETE, CLASSIFICATION_UPDATE,
- RELATIONSHIP_CREATE, RELATIONSHIP_UPDATE, RELATIONSHIP_DELETE
- }
-
- private AtlasEntityHeader entity;
+ private AtlasEntityHeader entity;
private AtlasRelationshipHeader relationship;
- private OperationType operationType;
- private long eventTime;
+ private OperationType operationType;
+ private long eventTime;
public EntityNotificationV2() {
super(ENTITY_NOTIFICATION_V2);
@@ -171,18 +166,23 @@ public class EntityNotification implements Serializable {
}
@Override
- public boolean equals(Object o) {
- if (this == o) { return true; }
- if (o == null || getClass() != o.getClass()) { return false; }
- EntityNotificationV2 that = (EntityNotificationV2) o;
- return Objects.equals(type, that.type) &&
- Objects.equals(entity, that.entity) &&
- operationType == that.operationType;
+ public int hashCode() {
+ return Objects.hash(type, entity, operationType);
}
@Override
- public int hashCode() {
- return Objects.hash(type, entity, operationType);
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ } else if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ EntityNotificationV2 that = (EntityNotificationV2) o;
+
+ return Objects.equals(type, that.type) &&
+ Objects.equals(entity, that.entity) &&
+ operationType == that.operationType;
}
@Override
@@ -205,5 +205,11 @@ public class EntityNotification implements Serializable {
return sb;
}
+
+ public enum OperationType {
+ ENTITY_CREATE, ENTITY_UPDATE, ENTITY_DELETE,
+ CLASSIFICATION_ADD, CLASSIFICATION_DELETE, CLASSIFICATION_UPDATE,
+ RELATIONSHIP_CREATE, RELATIONSHIP_UPDATE, RELATIONSHIP_DELETE
+ }
}
}
diff --git a/intg/src/main/java/org/apache/atlas/model/notification/HookNotification.java b/intg/src/main/java/org/apache/atlas/model/notification/HookNotification.java
index 5b5fa04e2..625654399 100644
--- a/intg/src/main/java/org/apache/atlas/model/notification/HookNotification.java
+++ b/intg/src/main/java/org/apache/atlas/model/notification/HookNotification.java
... 20713 lines suppressed ...
(atlas) 02/03: ATLAS-4957: checkstyle compliance updates - atlas-common module (#272)
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
madhan pushed a commit to branch atlas-2.5
in repository https://gitbox.apache.org/repos/asf/atlas.git
commit 55655786bbce673d9c94e696e8d0d4b4a17dbace
Author: Madhan Neethiraj <ma...@apache.org>
AuthorDate: Thu Jan 23 23:44:22 2025 -0800
ATLAS-4957: checkstyle compliance updates - atlas-common module (#272)
(cherry picked from commit 155c854c6cb113e190740e17665179526a079f1f)
---
common/pom.xml | 5 +
.../main/java/org/apache/atlas/AtlasConstants.java | 16 +-
.../annotation/ConditionalOnAtlasProperty.java | 3 +-
.../java/org/apache/atlas/annotation/Timed.java | 11 +-
.../atlas/groovy/AbstractFunctionExpression.java | 22 +-
.../atlas/groovy/AbstractGroovyExpression.java | 15 +-
.../apache/atlas/groovy/ArithmeticExpression.java | 46 ++--
.../org/apache/atlas/groovy/BinaryExpression.java | 21 +-
.../org/apache/atlas/groovy/CastExpression.java | 20 +-
.../org/apache/atlas/groovy/ClosureExpression.java | 85 ++++---
.../apache/atlas/groovy/ComparisonExpression.java | 51 ++--
.../atlas/groovy/ComparisonOperatorExpression.java | 8 +-
.../org/apache/atlas/groovy/FieldExpression.java | 13 +-
.../atlas/groovy/FunctionCallExpression.java | 51 ++--
.../org/apache/atlas/groovy/GroovyExpression.java | 8 +-
.../atlas/groovy/GroovyGenerationContext.java | 20 +-
.../apache/atlas/groovy/IdentifierExpression.java | 27 +-
.../org/apache/atlas/groovy/LabeledExpression.java | 15 +-
.../org/apache/atlas/groovy/ListExpression.java | 18 +-
.../org/apache/atlas/groovy/LiteralExpression.java | 99 ++++----
.../org/apache/atlas/groovy/LogicalExpression.java | 38 +--
.../org/apache/atlas/groovy/RangeExpression.java | 24 +-
.../atlas/groovy/StatementListExpression.java | 31 ++-
.../atlas/groovy/TernaryOperatorExpression.java | 37 ++-
.../org/apache/atlas/groovy/TraversalStepType.java | 6 +-
.../atlas/groovy/TypeCoersionExpression.java | 18 +-
.../atlas/groovy/VariableAssignmentExpression.java | 25 +-
.../java/org/apache/atlas/ha/HAConfiguration.java | 154 ++++++------
.../java/org/apache/atlas/pc/StatusReporter.java | 42 ++--
.../java/org/apache/atlas/pc/WorkItemBuilder.java | 6 +-
.../java/org/apache/atlas/pc/WorkItemConsumer.java | 20 +-
.../java/org/apache/atlas/pc/WorkItemManager.java | 67 ++---
.../org/apache/atlas/repository/Constants.java | 105 ++++----
.../java/org/apache/atlas/service/Service.java | 7 +-
.../java/org/apache/atlas/service/Services.java | 4 +-
.../apache/atlas/utils/AtlasPathExtractorUtil.java | 181 ++++++--------
.../org/apache/atlas/utils/AtlasPerfMetrics.java | 44 ++--
.../org/apache/atlas/utils/AtlasPerfTracer.java | 28 +--
.../atlas/utils/HdfsNameServiceResolver.java | 77 +++---
.../java/org/apache/atlas/utils/KafkaUtils.java | 277 +++++++++------------
.../main/java/org/apache/atlas/utils/LruCache.java | 44 ++--
.../atlas/utils/OnAtlasPropertyCondition.java | 21 +-
.../java/org/apache/atlas/utils/ParamChecker.java | 19 +-
.../apache/atlas/utils/PathExtractorContext.java | 8 +-
.../org/apache/atlas/utils/PropertiesUtil.java | 100 +++++---
.../java/org/apache/atlas/utils/SHA256Utils.java | 48 ++--
.../org/apache/atlas/ha/HAConfigurationTest.java | 24 +-
.../atlas/utils/AtlasPathExtractorUtilTest.java | 240 +++++++++---------
.../atlas/utils/HdfsNameServiceResolverTest.java | 4 +-
.../org/apache/atlas/utils/KafkaUtilsTest.java | 209 ++++++++--------
.../java/org/apache/atlas/utils/LruCacheTest.java | 71 +++---
.../org/apache/atlas/pc/StatusReporterTest.java | 36 ++-
.../org/apache/atlas/pc/WorkItemManagerTest.java | 14 +-
.../atlas/pc/WorkItemManagerWithResultsTest.java | 41 +--
54 files changed, 1291 insertions(+), 1333 deletions(-)
diff --git a/common/pom.xml b/common/pom.xml
index b76b4478d..ce96c69a4 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -31,6 +31,11 @@
<name>Apache Atlas Common</name>
<description>Apache Atlas Common</description>
+ <properties>
+ <checkstyle.failOnViolation>true</checkstyle.failOnViolation>
+ <checkstyle.skip>false</checkstyle.skip>
+ </properties>
+
<dependencies>
<dependency>
diff --git a/common/src/main/java/org/apache/atlas/AtlasConstants.java b/common/src/main/java/org/apache/atlas/AtlasConstants.java
index ce0dbd0b4..cc0d50763 100644
--- a/common/src/main/java/org/apache/atlas/AtlasConstants.java
+++ b/common/src/main/java/org/apache/atlas/AtlasConstants.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -22,9 +22,6 @@ package org.apache.atlas;
* Constants used in Atlas configuration.
*/
public final class AtlasConstants {
- private AtlasConstants() {
- }
-
public static final String CLUSTER_NAME_KEY = "atlas.cluster.name";
public static final String METADATA_NAMESPACE_KEY = "atlas.metadata.namespace";
public static final String DEFAULT_CLUSTER_NAME = "primary";
@@ -32,10 +29,13 @@ public final class AtlasConstants {
public static final String ATLAS_REST_ADDRESS_KEY = "atlas.rest.address";
public static final String ATLAS_MIGRATION_MODE_FILENAME = "atlas.migration.data.filename";
public static final String ATLAS_SERVICES_ENABLED = "atlas.services.enabled";
-
public static final String CLUSTER_NAME_ATTRIBUTE = "clusterName";
public static final String DEFAULT_APP_PORT_STR = "21000";
public static final String DEFAULT_ATLAS_REST_ADDRESS = "http://localhost:21000";
public static final String DEFAULT_TYPE_VERSION = "1.0";
public static final int ATLAS_SHUTDOWN_HOOK_PRIORITY = 30;
-}
\ No newline at end of file
+
+ private AtlasConstants() {
+ // to block instantiation
+ }
+}
diff --git a/common/src/main/java/org/apache/atlas/annotation/ConditionalOnAtlasProperty.java b/common/src/main/java/org/apache/atlas/annotation/ConditionalOnAtlasProperty.java
index 427e3a8f8..db038fa79 100644
--- a/common/src/main/java/org/apache/atlas/annotation/ConditionalOnAtlasProperty.java
+++ b/common/src/main/java/org/apache/atlas/annotation/ConditionalOnAtlasProperty.java
@@ -25,12 +25,13 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-@Target({ ElementType.TYPE, ElementType.METHOD })
+@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Conditional(OnAtlasPropertyCondition.class)
public @interface ConditionalOnAtlasProperty {
// Configured atlas property
String property();
+
// The default interface implementation should declare this as true
boolean isDefault() default false;
}
diff --git a/common/src/main/java/org/apache/atlas/annotation/Timed.java b/common/src/main/java/org/apache/atlas/annotation/Timed.java
index b892a16c7..0403dcd94 100644
--- a/common/src/main/java/org/apache/atlas/annotation/Timed.java
+++ b/common/src/main/java/org/apache/atlas/annotation/Timed.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -17,16 +17,15 @@
*/
package org.apache.atlas.annotation;
-
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-@Target({ElementType.METHOD})
+@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface Timed {
String value() default "";
-}
\ No newline at end of file
+}
diff --git a/common/src/main/java/org/apache/atlas/groovy/AbstractFunctionExpression.java b/common/src/main/java/org/apache/atlas/groovy/AbstractFunctionExpression.java
index 2e2307c0d..185f79c75 100644
--- a/common/src/main/java/org/apache/atlas/groovy/AbstractFunctionExpression.java
+++ b/common/src/main/java/org/apache/atlas/groovy/AbstractFunctionExpression.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -21,9 +21,8 @@ package org.apache.atlas.groovy;
* Base class for all expression that can have a caller.
*/
public abstract class AbstractFunctionExpression extends AbstractGroovyExpression {
-
// null for global functions
- private GroovyExpression caller;
+ private GroovyExpression caller;
private TraversalStepType type = TraversalStepType.NONE;
public AbstractFunctionExpression(GroovyExpression target) {
@@ -32,10 +31,10 @@ public abstract class AbstractFunctionExpression extends AbstractGroovyExpressio
public AbstractFunctionExpression(TraversalStepType type, GroovyExpression target) {
this.caller = target;
- this.type = type;
+ this.type = type;
}
- public GroovyExpression getCaller() {
+ public GroovyExpression getCaller() {
return caller;
}
@@ -43,15 +42,12 @@ public abstract class AbstractFunctionExpression extends AbstractGroovyExpressio
caller = expr;
}
-
- public void setType(TraversalStepType type) {
- this.type = type;
- }
-
@Override
public TraversalStepType getType() {
return type;
}
-
+ public void setType(TraversalStepType type) {
+ this.type = type;
+ }
}
diff --git a/common/src/main/java/org/apache/atlas/groovy/AbstractGroovyExpression.java b/common/src/main/java/org/apache/atlas/groovy/AbstractGroovyExpression.java
index e4a778109..327f75e8c 100644
--- a/common/src/main/java/org/apache/atlas/groovy/AbstractGroovyExpression.java
+++ b/common/src/main/java/org/apache/atlas/groovy/AbstractGroovyExpression.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -24,7 +24,6 @@ package org.apache.atlas.groovy;
*
*/
public abstract class AbstractGroovyExpression implements GroovyExpression {
-
@Override
public String toString() {
GroovyGenerationContext ctx = new GroovyGenerationContext();
@@ -34,12 +33,12 @@ public abstract class AbstractGroovyExpression implements GroovyExpression {
}
@Override
- public TraversalStepType getType() {
- return TraversalStepType.NONE;
+ public GroovyExpression copy() {
+ return copy(getChildren());
}
@Override
- public GroovyExpression copy() {
- return copy(getChildren());
+ public TraversalStepType getType() {
+ return TraversalStepType.NONE;
}
}
diff --git a/common/src/main/java/org/apache/atlas/groovy/ArithmeticExpression.java b/common/src/main/java/org/apache/atlas/groovy/ArithmeticExpression.java
index fff104b7c..715da801d 100644
--- a/common/src/main/java/org/apache/atlas/groovy/ArithmeticExpression.java
+++ b/common/src/main/java/org/apache/atlas/groovy/ArithmeticExpression.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -25,47 +25,47 @@ import java.util.List;
* Represents an arithmetic expression such as a+b.
*/
public class ArithmeticExpression extends BinaryExpression {
+ public ArithmeticExpression(GroovyExpression left, ArithmeticOperator op, GroovyExpression right) {
+ super(left, op.getGroovyValue(), right);
+ }
+
+ private ArithmeticExpression(GroovyExpression left, String op, GroovyExpression right) {
+ super(left, op, right);
+ }
+
+ @Override
+ public GroovyExpression copy(List<GroovyExpression> newChildren) {
+ return new ArithmeticExpression(newChildren.get(0), op, newChildren.get(1));
+ }
/**
* Allowed arithmetic operators.
*/
- public enum ArithmeticOperator {
+ public enum ArithmeticOperator {
PLUS("+"),
MINUS("-"),
TIMES("*"),
DIVIDE("/"),
MODULUS("%");
- private String groovyValue;
+ private final String groovyValue;
+
ArithmeticOperator(String groovyValue) {
this.groovyValue = groovyValue;
}
- public String getGroovyValue() {
- return groovyValue;
- }
public static ArithmeticOperator lookup(String groovyValue) throws AtlasException {
- for(ArithmeticOperator op : ArithmeticOperator.values()) {
+ for (ArithmeticOperator op : ArithmeticOperator.values()) {
if (op.getGroovyValue().equals(groovyValue)) {
return op;
}
}
+
throw new AtlasException("Unknown Operator:" + groovyValue);
}
- }
-
- public ArithmeticExpression(GroovyExpression left, ArithmeticOperator op, GroovyExpression right) {
- super(left, op.getGroovyValue(), right);
- }
-
- private ArithmeticExpression(GroovyExpression left, String op, GroovyExpression right) {
- super(left, op, right);
- }
-
- @Override
- public GroovyExpression copy(List<GroovyExpression> newChildren) {
- assert newChildren.size() == 2;
- return new ArithmeticExpression(newChildren.get(0), op, newChildren.get(1));
+ public String getGroovyValue() {
+ return groovyValue;
+ }
}
}
diff --git a/common/src/main/java/org/apache/atlas/groovy/BinaryExpression.java b/common/src/main/java/org/apache/atlas/groovy/BinaryExpression.java
index 852845ea3..417c6321c 100644
--- a/common/src/main/java/org/apache/atlas/groovy/BinaryExpression.java
+++ b/common/src/main/java/org/apache/atlas/groovy/BinaryExpression.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -29,25 +29,24 @@ import java.util.List;
*
*/
public abstract class BinaryExpression extends AbstractGroovyExpression {
-
-
- private GroovyExpression left;
- private GroovyExpression right;
- protected String op;
+ protected String op;
+ private final GroovyExpression left;
+ private final GroovyExpression right;
public BinaryExpression(GroovyExpression left, String op, GroovyExpression right) {
- this.left = left;
- this.op = op;
+ this.left = left;
+ this.op = op;
this.right = right;
}
@Override
public void generateGroovy(GroovyGenerationContext context) {
-
left.generateGroovy(context);
+
context.append(" ");
context.append(op);
context.append(" ");
+
right.generateGroovy(context);
}
diff --git a/common/src/main/java/org/apache/atlas/groovy/CastExpression.java b/common/src/main/java/org/apache/atlas/groovy/CastExpression.java
index 808f327f9..c820ae587 100644
--- a/common/src/main/java/org/apache/atlas/groovy/CastExpression.java
+++ b/common/src/main/java/org/apache/atlas/groovy/CastExpression.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -25,22 +25,22 @@ import java.util.List;
* Groovy expression that represents a cast.
*/
public class CastExpression extends AbstractGroovyExpression {
-
- private GroovyExpression expr;
- private String className;
+ private final GroovyExpression expr;
+ private final String className;
public CastExpression(GroovyExpression expr, String className) {
- this.expr = expr;
- this.className = className;
+ this.expr = expr;
+ this.className = className;
}
@Override
public void generateGroovy(GroovyGenerationContext context) {
-
context.append("((");
context.append(className);
context.append(")");
+
expr.generateGroovy(context);
+
context.append(")");
}
@@ -48,9 +48,9 @@ public class CastExpression extends AbstractGroovyExpression {
public List<GroovyExpression> getChildren() {
return Collections.singletonList(expr);
}
+
@Override
public GroovyExpression copy(List<GroovyExpression> newChildren) {
- assert newChildren.size() == 1;
return new CastExpression(newChildren.get(0), className);
}
}
diff --git a/common/src/main/java/org/apache/atlas/groovy/ClosureExpression.java b/common/src/main/java/org/apache/atlas/groovy/ClosureExpression.java
index a5ca0b6fd..a85c86648 100644
--- a/common/src/main/java/org/apache/atlas/groovy/ClosureExpression.java
+++ b/common/src/main/java/org/apache/atlas/groovy/ClosureExpression.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -28,34 +28,8 @@ import java.util.List;
* Groovy expression that represents a Groovy closure.
*/
public class ClosureExpression extends AbstractGroovyExpression {
-
- /**
- * Variable declaration in a closure.
- */
- public static class VariableDeclaration {
- private String type;
- private String varName;
-
- public VariableDeclaration(String type, String varName) {
- super();
- this.type = type;
- this.varName = varName;
- }
-
- public VariableDeclaration(String varName) {
- this.varName = varName;
- }
-
- public void append(GroovyGenerationContext context) {
- if (type != null) {
- context.append(type);
- context.append(" ");
- }
- context.append(varName);
- }
- }
- private List<VariableDeclaration> vars = new ArrayList<>();
- private StatementListExpression body = new StatementListExpression();
+ private final List<VariableDeclaration> vars = new ArrayList<>();
+ private final StatementListExpression body = new StatementListExpression();
public ClosureExpression(String... varNames) {
this(null, varNames);
@@ -69,6 +43,7 @@ public class ClosureExpression extends AbstractGroovyExpression {
if (initialStmt != null) {
this.body.addStatement(initialStmt);
}
+
for (String varName : varNames) {
vars.add(new VariableDeclaration(varName));
}
@@ -78,6 +53,7 @@ public class ClosureExpression extends AbstractGroovyExpression {
if (initialStmt != null) {
this.body.addStatement(initialStmt);
}
+
vars.addAll(varNames);
}
@@ -95,35 +71,66 @@ public class ClosureExpression extends AbstractGroovyExpression {
@Override
public void generateGroovy(GroovyGenerationContext context) {
-
context.append("{");
+
if (!vars.isEmpty()) {
- Iterator<VariableDeclaration> varIt = vars.iterator();
- while(varIt.hasNext()) {
+ for (Iterator<VariableDeclaration> varIt = vars.iterator(); varIt.hasNext(); ) {
VariableDeclaration var = varIt.next();
+
var.append(context);
+
if (varIt.hasNext()) {
context.append(", ");
}
}
+
context.append("->");
}
+
body.generateGroovy(context);
+
context.append("}");
}
@Override
public List<GroovyExpression> getChildren() {
- return Collections.<GroovyExpression>singletonList(body);
+ return Collections.singletonList(body);
+ }
+
+ @Override
+ public GroovyExpression copy(List<GroovyExpression> newChildren) {
+ return new ClosureExpression(newChildren.get(0), vars);
}
public List<GroovyExpression> getStatements() {
return body.getStatements();
}
- @Override
- public GroovyExpression copy(List<GroovyExpression> newChildren) {
- assert newChildren.size() == 1;
- return new ClosureExpression(newChildren.get(0), vars);
+ /**
+ * Variable declaration in a closure.
+ */
+ public static class VariableDeclaration {
+ private final String type;
+ private final String varName;
+
+ public VariableDeclaration(String type, String varName) {
+ super();
+
+ this.type = type;
+ this.varName = varName;
+ }
+
+ public VariableDeclaration(String varName) {
+ this(null, varName);
+ }
+
+ public void append(GroovyGenerationContext context) {
+ if (type != null) {
+ context.append(type);
+ context.append(" ");
+ }
+
+ context.append(varName);
+ }
}
}
diff --git a/common/src/main/java/org/apache/atlas/groovy/ComparisonExpression.java b/common/src/main/java/org/apache/atlas/groovy/ComparisonExpression.java
index b64533f46..11bd83c1f 100644
--- a/common/src/main/java/org/apache/atlas/groovy/ComparisonExpression.java
+++ b/common/src/main/java/org/apache/atlas/groovy/ComparisonExpression.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -17,23 +17,34 @@
*/
package org.apache.atlas.groovy;
-import java.util.List;
-
import org.apache.atlas.AtlasException;
+import java.util.List;
+
/**
* Represents an expression that compares two expressions
* using a comparison operator (==, <, >, etc).
*
*/
public class ComparisonExpression extends BinaryExpression {
+ public ComparisonExpression(GroovyExpression left, ComparisonOperator op, GroovyExpression right) {
+ super(left, op.getGroovyValue(), right);
+ }
+
+ private ComparisonExpression(GroovyExpression left, String op, GroovyExpression right) {
+ super(left, op, right);
+ }
+
+ @Override
+ public GroovyExpression copy(List<GroovyExpression> newChildren) {
+ return new ComparisonExpression(newChildren.get(0), op, newChildren.get(1));
+ }
/**
* Allowed comparison operators.
*
*/
- public enum ComparisonOperator {
-
+ public enum ComparisonOperator {
GREATER_THAN_EQ_(">="),
GREATER_THAN(">"),
EQUALS("=="),
@@ -41,36 +52,24 @@ public class ComparisonExpression extends BinaryExpression {
LESS_THAN("<"),
LESS_THAN_EQ("<=");
- private String groovyValue;
+ private final String groovyValue;
+
ComparisonOperator(String groovyValue) {
this.groovyValue = groovyValue;
}
- public String getGroovyValue() {
- return groovyValue;
- }
public static ComparisonOperator lookup(String groovyValue) throws AtlasException {
- for(ComparisonOperator op : ComparisonOperator.values()) {
+ for (ComparisonOperator op : ComparisonOperator.values()) {
if (op.getGroovyValue().equals(groovyValue)) {
return op;
}
}
+
throw new AtlasException("Unknown Operator:" + groovyValue);
}
- }
-
- public ComparisonExpression(GroovyExpression left, ComparisonOperator op, GroovyExpression right) {
- super(left, op.getGroovyValue(), right);
- }
-
- private ComparisonExpression(GroovyExpression left, String op, GroovyExpression right) {
- super(left, op, right);
- }
-
- @Override
- public GroovyExpression copy(List<GroovyExpression> newChildren) {
- assert newChildren.size() == 2;
- return new ComparisonExpression(newChildren.get(0), op, newChildren.get(1));
+ public String getGroovyValue() {
+ return groovyValue;
+ }
}
}
diff --git a/common/src/main/java/org/apache/atlas/groovy/ComparisonOperatorExpression.java b/common/src/main/java/org/apache/atlas/groovy/ComparisonOperatorExpression.java
index c9e363e11..7753b962d 100644
--- a/common/src/main/java/org/apache/atlas/groovy/ComparisonOperatorExpression.java
+++ b/common/src/main/java/org/apache/atlas/groovy/ComparisonOperatorExpression.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -27,14 +27,12 @@ import java.util.List;
*
*/
public class ComparisonOperatorExpression extends BinaryExpression {
-
public ComparisonOperatorExpression(GroovyExpression left, GroovyExpression right) {
super(left, "<=>", right);
}
@Override
public GroovyExpression copy(List<GroovyExpression> newChildren) {
- assert newChildren.size() == 2;
return new ComparisonOperatorExpression(newChildren.get(0), newChildren.get(1));
}
}
diff --git a/common/src/main/java/org/apache/atlas/groovy/FieldExpression.java b/common/src/main/java/org/apache/atlas/groovy/FieldExpression.java
index 6a182ad6d..e79ea7b05 100644
--- a/common/src/main/java/org/apache/atlas/groovy/FieldExpression.java
+++ b/common/src/main/java/org/apache/atlas/groovy/FieldExpression.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -25,19 +25,19 @@ import java.util.List;
* Groovy expression that accesses a field in an object.
*/
public class FieldExpression extends AbstractFunctionExpression {
-
- private String fieldName;
+ private final String fieldName;
public FieldExpression(GroovyExpression target, String fieldName) {
super(target);
+
this.fieldName = fieldName;
}
@Override
public void generateGroovy(GroovyGenerationContext context) {
getCaller().generateGroovy(context);
- context.append(".'");
+ context.append(".'");
context.append(fieldName);
context.append("'");
}
@@ -49,7 +49,6 @@ public class FieldExpression extends AbstractFunctionExpression {
@Override
public GroovyExpression copy(List<GroovyExpression> newChildren) {
- assert newChildren.size() == 1;
return new FieldExpression(newChildren.get(0), fieldName);
}
}
diff --git a/common/src/main/java/org/apache/atlas/groovy/FunctionCallExpression.java b/common/src/main/java/org/apache/atlas/groovy/FunctionCallExpression.java
index ad09e3f96..1521cfa52 100644
--- a/common/src/main/java/org/apache/atlas/groovy/FunctionCallExpression.java
+++ b/common/src/main/java/org/apache/atlas/groovy/FunctionCallExpression.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -28,45 +28,54 @@ import java.util.List;
* Groovy expression that calls a method on an object.
*/
public class FunctionCallExpression extends AbstractFunctionExpression {
-
- private String functionName;
- private List<GroovyExpression> arguments = new ArrayList<>();
+ private final String functionName;
+ private final List<GroovyExpression> arguments = new ArrayList<>();
public FunctionCallExpression(TraversalStepType type, String functionName, GroovyExpression... arguments) {
super(type, null);
+
this.functionName = functionName;
+
this.arguments.addAll(Arrays.asList(arguments));
}
public FunctionCallExpression(String functionName, GroovyExpression... arguments) {
super(null);
+
this.functionName = functionName;
+
this.arguments.addAll(Arrays.asList(arguments));
}
public FunctionCallExpression(TraversalStepType type, String functionName, List<GroovyExpression> arguments) {
super(type, null);
+
this.functionName = functionName;
+
this.arguments.addAll(arguments);
}
public FunctionCallExpression(GroovyExpression target, String functionName, GroovyExpression... arguments) {
super(target);
+
this.functionName = functionName;
+
this.arguments.addAll(Arrays.asList(arguments));
}
- public FunctionCallExpression(TraversalStepType type, GroovyExpression target, String functionName,
- List<? extends GroovyExpression> arguments) {
+ public FunctionCallExpression(TraversalStepType type, GroovyExpression target, String functionName, List<? extends GroovyExpression> arguments) {
super(type, target);
+
this.functionName = functionName;
+
this.arguments.addAll(arguments);
}
- public FunctionCallExpression(TraversalStepType type, GroovyExpression target, String functionName,
- GroovyExpression... arguments) {
+ public FunctionCallExpression(TraversalStepType type, GroovyExpression target, String functionName, GroovyExpression... arguments) {
super(type, target);
+
this.functionName = functionName;
+
this.arguments.addAll(Arrays.asList(arguments));
}
@@ -78,63 +87,69 @@ public class FunctionCallExpression extends AbstractFunctionExpression {
return Collections.unmodifiableList(arguments);
}
-
public String getFunctionName() {
return functionName;
}
@Override
public void generateGroovy(GroovyGenerationContext context) {
-
if (getCaller() != null) {
getCaller().generateGroovy(context);
context.append(".");
}
+
context.append(functionName);
context.append("(");
- Iterator<GroovyExpression> it = arguments.iterator();
- while (it.hasNext()) {
+
+ for (Iterator<GroovyExpression> it = arguments.iterator(); it.hasNext(); ) {
GroovyExpression expr = it.next();
+
expr.generateGroovy(context);
+
if (it.hasNext()) {
context.append(",");
}
}
+
context.append(")");
}
@Override
public List<GroovyExpression> getChildren() {
List<GroovyExpression> result = new ArrayList<>(arguments.size() + 1);
+
if (getCaller() != null) {
result.add(getCaller());
}
+
result.addAll(arguments);
+
return result;
}
@Override
public GroovyExpression copy(List<GroovyExpression> newChildren) {
-
if (getCaller() == null) {
return new FunctionCallExpression(getType(), functionName, newChildren);
}
- GroovyExpression newTarget = newChildren.get(0);
- List<GroovyExpression> args = null;
+ GroovyExpression newTarget = newChildren.get(0);
+ List<GroovyExpression> args;
+
if (newChildren.size() > 1) {
args = newChildren.subList(1, newChildren.size());
} else {
args = Collections.emptyList();
}
- return new FunctionCallExpression(getType(), newTarget, functionName, args);
+ return new FunctionCallExpression(getType(), newTarget, functionName, args);
}
public void setArgument(int index, GroovyExpression value) {
if (index < 0 || index >= arguments.size()) {
throw new IllegalArgumentException("Invalid argIndex " + index);
}
+
arguments.set(index, value);
}
}
diff --git a/common/src/main/java/org/apache/atlas/groovy/GroovyExpression.java b/common/src/main/java/org/apache/atlas/groovy/GroovyExpression.java
index 839914729..43d3a5e17 100644
--- a/common/src/main/java/org/apache/atlas/groovy/GroovyExpression.java
+++ b/common/src/main/java/org/apache/atlas/groovy/GroovyExpression.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -24,7 +24,7 @@ import java.util.List;
* Represents an expression in the Groovy programming language, which
* is the language that Gremlin scripts are written and interpreted in.
*/
-public interface GroovyExpression {
+public interface GroovyExpression {
/**
* Generates a Groovy script from the expression.
*
diff --git a/common/src/main/java/org/apache/atlas/groovy/GroovyGenerationContext.java b/common/src/main/java/org/apache/atlas/groovy/GroovyGenerationContext.java
index a4e485b70..023f95d63 100644
--- a/common/src/main/java/org/apache/atlas/groovy/GroovyGenerationContext.java
+++ b/common/src/main/java/org/apache/atlas/groovy/GroovyGenerationContext.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -29,13 +29,12 @@ import java.util.Map;
*
*/
public class GroovyGenerationContext {
-
- private boolean parametersAllowed = true;
- private int parameterCount = 0;
- private Map<String, Object> parameterValues = new HashMap<>();
+ private boolean parametersAllowed = true;
+ private final Map<String, Object> parameterValues = new HashMap<>();
+ private int parameterCount;
//used to build up the groovy script
- private StringBuilder generatedQuery = new StringBuilder();
+ private final StringBuilder generatedQuery = new StringBuilder();
public void setParametersAllowed(boolean value) {
this.parametersAllowed = value;
@@ -44,17 +43,22 @@ public class GroovyGenerationContext {
public GroovyExpression addParameter(Object value) {
if (this.parametersAllowed) {
String parameterName = "p" + (++parameterCount);
+
this.parameterValues.put(parameterName, value);
+
return new IdentifierExpression(parameterName);
} else {
LiteralExpression expr = new LiteralExpression(value);
+
expr.setTranslateToParameter(false);
+
return expr;
}
}
public StringBuilder append(String gremlin) {
this.generatedQuery.append(gremlin);
+
return generatedQuery;
}
diff --git a/common/src/main/java/org/apache/atlas/groovy/IdentifierExpression.java b/common/src/main/java/org/apache/atlas/groovy/IdentifierExpression.java
index 4c0694a40..a4c256a3b 100644
--- a/common/src/main/java/org/apache/atlas/groovy/IdentifierExpression.java
+++ b/common/src/main/java/org/apache/atlas/groovy/IdentifierExpression.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -26,20 +26,18 @@ import java.util.List;
*
*/
public class IdentifierExpression extends AbstractGroovyExpression {
-
- private TraversalStepType type = TraversalStepType.NONE;
- private String varName;
+ private TraversalStepType type = TraversalStepType.NONE;
+ private final String varName;
public IdentifierExpression(String varName) {
this.varName = varName;
}
public IdentifierExpression(TraversalStepType type, String varName) {
+ this.type = type;
this.varName = varName;
- this.type = type;
}
-
public String getVariableName() {
return varName;
}
@@ -56,18 +54,15 @@ public class IdentifierExpression extends AbstractGroovyExpression {
@Override
public GroovyExpression copy(List<GroovyExpression> newChildren) {
- assert newChildren.isEmpty();
- IdentifierExpression result = new IdentifierExpression(varName);
- result.setType(type);
- return result;
- }
-
- public void setType(TraversalStepType type) {
- this.type = type;
+ return new IdentifierExpression(type, varName);
}
@Override
public TraversalStepType getType() {
return type;
}
+
+ public void setType(TraversalStepType type) {
+ this.type = type;
+ }
}
diff --git a/common/src/main/java/org/apache/atlas/groovy/LabeledExpression.java b/common/src/main/java/org/apache/atlas/groovy/LabeledExpression.java
index a99341024..e58a68811 100644
--- a/common/src/main/java/org/apache/atlas/groovy/LabeledExpression.java
+++ b/common/src/main/java/org/apache/atlas/groovy/LabeledExpression.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -25,19 +25,19 @@ import java.util.List;
* Represents a Groovy expression that has a label.
*/
public class LabeledExpression extends AbstractGroovyExpression {
-
- private String label;
- private GroovyExpression expr;
+ private final String label;
+ private final GroovyExpression expr;
public LabeledExpression(String label, GroovyExpression expr) {
this.label = label;
- this.expr = expr;
+ this.expr = expr;
}
@Override
public void generateGroovy(GroovyGenerationContext context) {
context.append(label);
context.append(":");
+
expr.generateGroovy(context);
}
@@ -48,7 +48,6 @@ public class LabeledExpression extends AbstractGroovyExpression {
@Override
public GroovyExpression copy(List<GroovyExpression> newChildren) {
- assert newChildren.size() == 1;
return new LabeledExpression(label, newChildren.get(0));
}
}
diff --git a/common/src/main/java/org/apache/atlas/groovy/ListExpression.java b/common/src/main/java/org/apache/atlas/groovy/ListExpression.java
index 796942601..873c3d9ab 100644
--- a/common/src/main/java/org/apache/atlas/groovy/ListExpression.java
+++ b/common/src/main/java/org/apache/atlas/groovy/ListExpression.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -28,10 +28,8 @@ import java.util.List;
* Groovy expression that represents a list literal.
*/
public class ListExpression extends AbstractGroovyExpression {
-
private List<GroovyExpression> values = new ArrayList<>();
-
public ListExpression(GroovyExpression... values) {
this.values = Arrays.asList(values);
}
@@ -45,16 +43,18 @@ public class ListExpression extends AbstractGroovyExpression {
}
public void generateGroovy(GroovyGenerationContext context) {
-
context.append("[");
- Iterator<GroovyExpression> it = values.iterator();
- while(it.hasNext()) {
+
+ for (Iterator<GroovyExpression> it = values.iterator(); it.hasNext(); ) {
GroovyExpression expr = it.next();
+
expr.generateGroovy(context);
+
if (it.hasNext()) {
context.append(", ");
}
}
+
context.append("]");
}
@@ -67,6 +67,4 @@ public class ListExpression extends AbstractGroovyExpression {
public GroovyExpression copy(List<GroovyExpression> newChildren) {
return new ListExpression(newChildren);
}
-
-
}
diff --git a/common/src/main/java/org/apache/atlas/groovy/LiteralExpression.java b/common/src/main/java/org/apache/atlas/groovy/LiteralExpression.java
index 14074994f..c55f25e85 100644
--- a/common/src/main/java/org/apache/atlas/groovy/LiteralExpression.java
+++ b/common/src/main/java/org/apache/atlas/groovy/LiteralExpression.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -27,96 +27,97 @@ import java.util.regex.Pattern;
* Represents a literal value.
*/
public class LiteralExpression extends AbstractGroovyExpression {
-
- public static final LiteralExpression TRUE = new LiteralExpression(true);
+ public static final LiteralExpression TRUE = new LiteralExpression(true);
public static final LiteralExpression FALSE = new LiteralExpression(false);
- public static final LiteralExpression NULL = new LiteralExpression(null);
+ public static final LiteralExpression NULL = new LiteralExpression(null);
- private Object value;
- private boolean translateToParameter = true;
- private boolean addTypeSuffix = false;
+ private final Object value;
+ private boolean translateToParameter;
+ private boolean addTypeSuffix;
public LiteralExpression(Object value, boolean addTypeSuffix) {
- this.value = value;
+ this.value = value;
this.translateToParameter = value instanceof String;
- this.addTypeSuffix = addTypeSuffix;
+ this.addTypeSuffix = addTypeSuffix;
}
public LiteralExpression(Object value, boolean addTypeSuffix, boolean translateToParameter) {
- this.value = value;
+ this.value = value;
this.translateToParameter = translateToParameter;
- this.addTypeSuffix = addTypeSuffix;
+ this.addTypeSuffix = addTypeSuffix;
}
public LiteralExpression(Object value) {
- this.value = value;
+ this.value = value;
this.translateToParameter = value instanceof String;
}
- private String getTypeSuffix() {
- if (!addTypeSuffix) {
- return "";
- }
- if (value.getClass() == Long.class) {
- return "L";
- }
-
- if (value.getClass() == Float.class) {
- return "f";
- }
-
- if (value.getClass() == Double.class) {
- return "d";
- }
-
- return "";
- }
-
@Override
public void generateGroovy(GroovyGenerationContext context) {
-
if (translateToParameter) {
GroovyExpression result = context.addParameter(value);
+
result.generateGroovy(context);
+
return;
}
if (value instanceof String) {
String escapedValue = getEscapedValue();
+
context.append("'");
context.append(escapedValue);
context.append("'");
-
} else {
context.append(String.valueOf(value));
context.append(getTypeSuffix());
}
+ }
+ @Override
+ public List<GroovyExpression> getChildren() {
+ return Collections.emptyList();
}
- public Object getValue() {
- return value;
+ @Override
+ public GroovyExpression copy(List<GroovyExpression> newChildren) {
+ return new LiteralExpression(value, addTypeSuffix, translateToParameter);
}
- private String getEscapedValue() {
- String escapedValue = (String)value;
- escapedValue = escapedValue.replaceAll(Pattern.quote("\\"), Matcher.quoteReplacement("\\\\"));
- escapedValue = escapedValue.replaceAll(Pattern.quote("'"), Matcher.quoteReplacement("\\'"));
- return escapedValue;
+ public Object getValue() {
+ return value;
}
public void setTranslateToParameter(boolean translateToParameter) {
this.translateToParameter = translateToParameter;
}
- @Override
- public List<GroovyExpression> getChildren() {
- return Collections.emptyList();
+ private String getTypeSuffix() {
+ if (!addTypeSuffix) {
+ return "";
+ }
+
+ if (value.getClass() == Long.class) {
+ return "L";
+ }
+
+ if (value.getClass() == Float.class) {
+ return "f";
+ }
+
+ if (value.getClass() == Double.class) {
+ return "d";
+ }
+
+ return "";
}
- @Override
- public GroovyExpression copy(List<GroovyExpression> newChildren) {
- assert newChildren.size() == 0;
- return new LiteralExpression(value, addTypeSuffix, translateToParameter);
+ private String getEscapedValue() {
+ String escapedValue = (String) value;
+
+ escapedValue = escapedValue.replaceAll(Pattern.quote("\\"), Matcher.quoteReplacement("\\\\"));
+ escapedValue = escapedValue.replaceAll(Pattern.quote("'"), Matcher.quoteReplacement("\\'"));
+
+ return escapedValue;
}
}
diff --git a/common/src/main/java/org/apache/atlas/groovy/LogicalExpression.java b/common/src/main/java/org/apache/atlas/groovy/LogicalExpression.java
index 68e6847a0..0f50154ed 100644
--- a/common/src/main/java/org/apache/atlas/groovy/LogicalExpression.java
+++ b/common/src/main/java/org/apache/atlas/groovy/LogicalExpression.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -24,35 +24,35 @@ import java.util.List;
*
*/
public class LogicalExpression extends BinaryExpression {
+ public LogicalExpression(GroovyExpression left, LogicalOperator op, GroovyExpression right) {
+ super(left, op.getGroovyValue(), right);
+ }
+
+ private LogicalExpression(GroovyExpression left, String op, GroovyExpression right) {
+ super(left, op, right);
+ }
+
+ @Override
+ public GroovyExpression copy(List<GroovyExpression> newChildren) {
+ return new LogicalExpression(newChildren.get(0), op, newChildren.get(1));
+ }
/**
* Allowed logical operators.
*
*/
- public enum LogicalOperator {
+ public enum LogicalOperator {
AND("&&"),
OR("||");
- private String groovyValue;
+ private final String groovyValue;
+
LogicalOperator(String groovyValue) {
this.groovyValue = groovyValue;
}
+
public String getGroovyValue() {
return groovyValue;
}
}
-
- public LogicalExpression(GroovyExpression left, LogicalOperator op, GroovyExpression right) {
- super(left, op.getGroovyValue(), right);
- }
-
- private LogicalExpression(GroovyExpression left, String op, GroovyExpression right) {
- super(left, op, right);
- }
-
- @Override
- public GroovyExpression copy(List<GroovyExpression> newChildren) {
- assert newChildren.size() == 2;
- return new LogicalExpression(newChildren.get(0), op, newChildren.get(1));
- }
}
diff --git a/common/src/main/java/org/apache/atlas/groovy/RangeExpression.java b/common/src/main/java/org/apache/atlas/groovy/RangeExpression.java
index 977adb6b0..be449dbd0 100644
--- a/common/src/main/java/org/apache/atlas/groovy/RangeExpression.java
+++ b/common/src/main/java/org/apache/atlas/groovy/RangeExpression.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -25,21 +25,22 @@ import java.util.List;
* Represents an "exclusive" range expression, e.g. [0..<10].
*/
public class RangeExpression extends AbstractFunctionExpression {
-
- private TraversalStepType stepType;
- private int startIndex;
- private int endIndex;
+ private final TraversalStepType stepType;
+ private int startIndex;
+ private int endIndex;
public RangeExpression(TraversalStepType stepType, GroovyExpression parent, int offset, int count) {
super(parent);
+
this.startIndex = offset;
- this.endIndex = count;
- this.stepType = stepType;
+ this.endIndex = count;
+ this.stepType = stepType;
}
@Override
public void generateGroovy(GroovyGenerationContext context) {
getCaller().generateGroovy(context);
+
context.append(" [");
new LiteralExpression(startIndex).generateGroovy(context);
context.append("..<");
@@ -54,7 +55,6 @@ public class RangeExpression extends AbstractFunctionExpression {
@Override
public GroovyExpression copy(List<GroovyExpression> newChildren) {
- assert newChildren.size() == 1;
return new RangeExpression(stepType, newChildren.get(0), startIndex, endIndex);
}
@@ -64,22 +64,18 @@ public class RangeExpression extends AbstractFunctionExpression {
}
public int getStartIndex() {
-
return startIndex;
}
public void setStartIndex(int startIndex) {
-
this.startIndex = startIndex;
}
public int getEndIndex() {
-
return endIndex;
}
public void setEndIndex(int endIndex) {
-
this.endIndex = endIndex;
}
}
diff --git a/common/src/main/java/org/apache/atlas/groovy/StatementListExpression.java b/common/src/main/java/org/apache/atlas/groovy/StatementListExpression.java
index f9c88ec11..2d10fa41f 100644
--- a/common/src/main/java/org/apache/atlas/groovy/StatementListExpression.java
+++ b/common/src/main/java/org/apache/atlas/groovy/StatementListExpression.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -27,11 +27,9 @@ import java.util.List;
* Represents a semi-colon delimited list of Groovy expressions.
*/
public class StatementListExpression extends AbstractGroovyExpression {
-
- private List<GroovyExpression> stmts = new ArrayList<>();
+ private final List<GroovyExpression> stmts = new ArrayList<>();
public StatementListExpression() {
-
}
/**
@@ -43,36 +41,31 @@ public class StatementListExpression extends AbstractGroovyExpression {
public void addStatement(GroovyExpression expr) {
if (expr instanceof StatementListExpression) {
- stmts.addAll(((StatementListExpression)expr).getStatements());
+ stmts.addAll(((StatementListExpression) expr).getStatements());
} else {
stmts.add(expr);
}
}
public void addStatements(List<GroovyExpression> exprs) {
- for(GroovyExpression expr : exprs) {
+ for (GroovyExpression expr : exprs) {
addStatement(expr);
}
}
@Override
public void generateGroovy(GroovyGenerationContext context) {
-
- Iterator<GroovyExpression> stmtIt = stmts.iterator();
- while(stmtIt.hasNext()) {
+ for (Iterator<GroovyExpression> stmtIt = stmts.iterator(); stmtIt.hasNext(); ) {
GroovyExpression stmt = stmtIt.next();
+
stmt.generateGroovy(context);
+
if (stmtIt.hasNext()) {
context.append(";");
}
}
}
-
- public List<GroovyExpression> getStatements() {
- return stmts;
- }
-
@Override
public List<GroovyExpression> getChildren() {
return Collections.unmodifiableList(stmts);
@@ -83,13 +76,17 @@ public class StatementListExpression extends AbstractGroovyExpression {
return new StatementListExpression(newChildren);
}
+ public List<GroovyExpression> getStatements() {
+ return stmts;
+ }
+
@Override
public TraversalStepType getType() {
return TraversalStepType.NONE;
}
/**
- * @param oldExpr
+ * @param index
* @param newExpr
*/
public void replaceStatement(int index, GroovyExpression newExpr) {
diff --git a/common/src/main/java/org/apache/atlas/groovy/TernaryOperatorExpression.java b/common/src/main/java/org/apache/atlas/groovy/TernaryOperatorExpression.java
index 8835dd2f3..3b0177129 100644
--- a/common/src/main/java/org/apache/atlas/groovy/TernaryOperatorExpression.java
+++ b/common/src/main/java/org/apache/atlas/groovy/TernaryOperatorExpression.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -26,22 +26,18 @@ import java.util.List;
* falseValue)
*/
public class TernaryOperatorExpression extends AbstractGroovyExpression {
+ private final GroovyExpression booleanExpr;
+ private final GroovyExpression trueValue;
+ private final GroovyExpression falseValue;
- private GroovyExpression booleanExpr;
- private GroovyExpression trueValue;
- private GroovyExpression falseValue;
-
- public TernaryOperatorExpression(GroovyExpression booleanExpr, GroovyExpression trueValue,
- GroovyExpression falseValue) {
-
+ public TernaryOperatorExpression(GroovyExpression booleanExpr, GroovyExpression trueValue, GroovyExpression falseValue) {
this.booleanExpr = booleanExpr;
- this.trueValue = trueValue;
- this.falseValue = falseValue;
+ this.trueValue = trueValue;
+ this.falseValue = falseValue;
}
@Override
public void generateGroovy(GroovyGenerationContext context) {
-
context.append("((");
booleanExpr.generateGroovy(context);
context.append(")?(");
@@ -51,12 +47,6 @@ public class TernaryOperatorExpression extends AbstractGroovyExpression {
context.append("))");
}
- public String toString() {
- GroovyGenerationContext context = new GroovyGenerationContext();
- generateGroovy(context);
- return context.getQuery();
- }
-
@Override
public List<GroovyExpression> getChildren() {
return Arrays.asList(booleanExpr, trueValue, falseValue);
@@ -64,10 +54,17 @@ public class TernaryOperatorExpression extends AbstractGroovyExpression {
@Override
public GroovyExpression copy(List<GroovyExpression> newChildren) {
- assert newChildren.size() == 3;
return new TernaryOperatorExpression(newChildren.get(0), newChildren.get(1), newChildren.get(2));
}
+ public String toString() {
+ GroovyGenerationContext context = new GroovyGenerationContext();
+
+ generateGroovy(context);
+
+ return context.getQuery();
+ }
+
@Override
public TraversalStepType getType() {
return trueValue.getType();
diff --git a/common/src/main/java/org/apache/atlas/groovy/TraversalStepType.java b/common/src/main/java/org/apache/atlas/groovy/TraversalStepType.java
index fde88147c..bf39b2bd8 100644
--- a/common/src/main/java/org/apache/atlas/groovy/TraversalStepType.java
+++ b/common/src/main/java/org/apache/atlas/groovy/TraversalStepType.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
diff --git a/common/src/main/java/org/apache/atlas/groovy/TypeCoersionExpression.java b/common/src/main/java/org/apache/atlas/groovy/TypeCoersionExpression.java
index 956dafa0d..94a14be33 100644
--- a/common/src/main/java/org/apache/atlas/groovy/TypeCoersionExpression.java
+++ b/common/src/main/java/org/apache/atlas/groovy/TypeCoersionExpression.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -25,18 +25,16 @@ import java.util.List;
* Groovy expression that represents a type coersion (e.g obj as Set).
*/
public class TypeCoersionExpression extends AbstractGroovyExpression {
-
- private GroovyExpression expr;
- private String className;
+ private final GroovyExpression expr;
+ private final String className;
public TypeCoersionExpression(GroovyExpression expr, String className) {
- this.expr = expr;
- this.className = className;
+ this.expr = expr;
+ this.className = className;
}
@Override
public void generateGroovy(GroovyGenerationContext context) {
-
context.append("((");
expr.generateGroovy(context);
context.append(")");
@@ -52,8 +50,6 @@ public class TypeCoersionExpression extends AbstractGroovyExpression {
@Override
public GroovyExpression copy(List<GroovyExpression> newChildren) {
- assert newChildren.size() == 1;
return new TypeCoersionExpression(newChildren.get(0), className);
}
-
}
diff --git a/common/src/main/java/org/apache/atlas/groovy/VariableAssignmentExpression.java b/common/src/main/java/org/apache/atlas/groovy/VariableAssignmentExpression.java
index 1aa74435d..6ef656b86 100644
--- a/common/src/main/java/org/apache/atlas/groovy/VariableAssignmentExpression.java
+++ b/common/src/main/java/org/apache/atlas/groovy/VariableAssignmentExpression.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -25,18 +25,18 @@ import java.util.List;
* Groovy statement that assigns a value to a variable.
*/
public class VariableAssignmentExpression extends AbstractGroovyExpression {
-
- private String type = null;
- private String name;
- private GroovyExpression value;
+ private final String type;
+ private final String name;
+ private final GroovyExpression value;
/**
- * @param string
+ * @param type
+ * @param name
* @param v
*/
public VariableAssignmentExpression(String type, String name, GroovyExpression v) {
- this.type = type;
- this.name = name;
+ this.type = type;
+ this.name = name;
this.value = v;
}
@@ -52,10 +52,11 @@ public class VariableAssignmentExpression extends AbstractGroovyExpression {
context.append(type);
context.append(" ");
}
+
context.append(name);
context.append("=");
- value.generateGroovy(context);
+ value.generateGroovy(context);
}
@Override
@@ -65,8 +66,6 @@ public class VariableAssignmentExpression extends AbstractGroovyExpression {
@Override
public GroovyExpression copy(List<GroovyExpression> newChildren) {
- assert newChildren.size() == 1;
return new VariableAssignmentExpression(name, newChildren.get(0));
}
-
}
diff --git a/common/src/main/java/org/apache/atlas/ha/HAConfiguration.java b/common/src/main/java/org/apache/atlas/ha/HAConfiguration.java
index 91fd4e107..c75b9ebe0 100644
--- a/common/src/main/java/org/apache/atlas/ha/HAConfiguration.java
+++ b/common/src/main/java/org/apache/atlas/ha/HAConfiguration.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -30,38 +30,34 @@ import java.util.Objects;
* A wrapper for getting configuration entries related to HighAvailability.
*/
public final class HAConfiguration {
-
-
- public static final String ATLAS_SERVER_ZK_ROOT_DEFAULT = "/apache_atlas";
+ public static final String ATLAS_SERVER_ZK_ROOT_DEFAULT = "/apache_atlas";
+ public static final String ATLAS_SERVER_HA_PREFIX = "atlas.server.ha.";
+ public static final String ZOOKEEPER_PREFIX = "zookeeper.";
+ public static final String ATLAS_SERVER_HA_ZK_ROOT_KEY = ATLAS_SERVER_HA_PREFIX + ZOOKEEPER_PREFIX + "zkroot";
+ public static final String ATLAS_SERVER_HA_ENABLED_KEY = ATLAS_SERVER_HA_PREFIX + "enabled";
+ public static final String ATLAS_SERVER_ADDRESS_PREFIX = "atlas.server.address.";
+ public static final String ATLAS_SERVER_IDS = "atlas.server.ids";
+ public static final String HA_ZOOKEEPER_CONNECT = ATLAS_SERVER_HA_PREFIX + ZOOKEEPER_PREFIX + "connect";
+ public static final int DEFAULT_ZOOKEEPER_CONNECT_SLEEPTIME_MILLIS = 1000;
+ public static final String HA_ZOOKEEPER_RETRY_SLEEPTIME_MILLIS = ATLAS_SERVER_HA_PREFIX + ZOOKEEPER_PREFIX + "retry.sleeptime.ms";
+ public static final String HA_ZOOKEEPER_NUM_RETRIES = ATLAS_SERVER_HA_PREFIX + ZOOKEEPER_PREFIX + "num.retries";
+ public static final int DEFAULT_ZOOKEEPER_CONNECT_NUM_RETRIES = 3;
+ public static final String HA_ZOOKEEPER_SESSION_TIMEOUT_MS = ATLAS_SERVER_HA_PREFIX + ZOOKEEPER_PREFIX + "session.timeout.ms";
+ public static final int DEFAULT_ZOOKEEPER_SESSION_TIMEOUT_MILLIS = 20000;
+ public static final String HA_ZOOKEEPER_ACL = ATLAS_SERVER_HA_PREFIX + ZOOKEEPER_PREFIX + "acl";
+ public static final String HA_ZOOKEEPER_AUTH = ATLAS_SERVER_HA_PREFIX + ZOOKEEPER_PREFIX + "auth";
private HAConfiguration() {
+ // to block instantiation
}
- public static final String ATLAS_SERVER_HA_PREFIX = "atlas.server.ha.";
- public static final String ZOOKEEPER_PREFIX = "zookeeper.";
- public static final String ATLAS_SERVER_HA_ZK_ROOT_KEY = ATLAS_SERVER_HA_PREFIX + ZOOKEEPER_PREFIX + "zkroot";
- public static final String ATLAS_SERVER_HA_ENABLED_KEY = ATLAS_SERVER_HA_PREFIX + "enabled";
- public static final String ATLAS_SERVER_ADDRESS_PREFIX = "atlas.server.address.";
- public static final String ATLAS_SERVER_IDS = "atlas.server.ids";
- public static final String HA_ZOOKEEPER_CONNECT = ATLAS_SERVER_HA_PREFIX + ZOOKEEPER_PREFIX + "connect";
- public static final int DEFAULT_ZOOKEEPER_CONNECT_SLEEPTIME_MILLIS = 1000;
- public static final String HA_ZOOKEEPER_RETRY_SLEEPTIME_MILLIS =
- ATLAS_SERVER_HA_PREFIX + ZOOKEEPER_PREFIX + "retry.sleeptime.ms";
- public static final String HA_ZOOKEEPER_NUM_RETRIES = ATLAS_SERVER_HA_PREFIX + ZOOKEEPER_PREFIX + "num.retries";
- public static final int DEFAULT_ZOOKEEPER_CONNECT_NUM_RETRIES = 3;
- public static final String HA_ZOOKEEPER_SESSION_TIMEOUT_MS =
- ATLAS_SERVER_HA_PREFIX + ZOOKEEPER_PREFIX + "session.timeout.ms";
- public static final int DEFAULT_ZOOKEEPER_SESSION_TIMEOUT_MILLIS = 20000;
- public static final String HA_ZOOKEEPER_ACL = ATLAS_SERVER_HA_PREFIX + ZOOKEEPER_PREFIX + "acl";
- public static final String HA_ZOOKEEPER_AUTH = ATLAS_SERVER_HA_PREFIX + ZOOKEEPER_PREFIX + "auth";
-
/**
* Return whether HA is enabled or not.
* @param configuration underlying configuration instance
* @return
*/
public static boolean isHAEnabled(Configuration configuration) {
- boolean ret = false;
+ boolean ret;
if (configuration.containsKey(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)) {
ret = configuration.getBoolean(ATLAS_SERVER_HA_ENABLED_KEY);
@@ -85,42 +81,63 @@ public final class HAConfiguration {
* @return
*/
public static String getBoundAddressForId(Configuration configuration, String serverId) {
- String hostPort = configuration.getString(ATLAS_SERVER_ADDRESS_PREFIX +serverId);
+ String hostPort = configuration.getString(ATLAS_SERVER_ADDRESS_PREFIX + serverId);
boolean isSecure = configuration.getBoolean(SecurityProperties.TLS_ENABLED);
- String protocol = (isSecure) ? "https://" : "http://";
+ String protocol = (isSecure) ? "https://" : "http://";
+
return protocol + hostPort;
}
public static List<String> getServerInstances(Configuration configuration) {
- String[] serverIds = configuration.getStringArray(ATLAS_SERVER_IDS);
+ String[] serverIds = configuration.getStringArray(ATLAS_SERVER_IDS);
List<String> serverInstances = new ArrayList<>(serverIds.length);
+
for (String serverId : serverIds) {
serverInstances.add(getBoundAddressForId(configuration, serverId));
}
+
return serverInstances;
}
+ public static ZookeeperProperties getZookeeperProperties(Configuration configuration) {
+ String[] zkServers;
+
+ if (configuration.containsKey(HA_ZOOKEEPER_CONNECT)) {
+ zkServers = configuration.getStringArray(HA_ZOOKEEPER_CONNECT);
+ } else {
+ zkServers = configuration.getStringArray("atlas.kafka." + ZOOKEEPER_PREFIX + "connect");
+ }
+
+ String zkRoot = configuration.getString(ATLAS_SERVER_HA_ZK_ROOT_KEY, ATLAS_SERVER_ZK_ROOT_DEFAULT);
+ int retriesSleepTimeMillis = configuration.getInt(HA_ZOOKEEPER_RETRY_SLEEPTIME_MILLIS, DEFAULT_ZOOKEEPER_CONNECT_SLEEPTIME_MILLIS);
+ int numRetries = configuration.getInt(HA_ZOOKEEPER_NUM_RETRIES, DEFAULT_ZOOKEEPER_CONNECT_NUM_RETRIES);
+ int sessionTimeout = configuration.getInt(HA_ZOOKEEPER_SESSION_TIMEOUT_MS, DEFAULT_ZOOKEEPER_SESSION_TIMEOUT_MILLIS);
+ String acl = configuration.getString(HA_ZOOKEEPER_ACL);
+ String auth = configuration.getString(HA_ZOOKEEPER_AUTH);
+
+ return new ZookeeperProperties(StringUtils.join(zkServers, ','), zkRoot, retriesSleepTimeMillis, numRetries, sessionTimeout, acl, auth);
+ }
+
/**
* A collection of Zookeeper specific configuration that is used by High Availability code.
*/
public static class ZookeeperProperties {
- private String connectString;
- private String zkRoot;
- private int retriesSleepTimeMillis;
- private int numRetries;
- private int sessionTimeout;
- private String acl;
- private String auth;
-
- public ZookeeperProperties(String connectString, String zkRoot, int retriesSleepTimeMillis, int numRetries,
- int sessionTimeout, String acl, String auth) {
- this.connectString = connectString;
- this.zkRoot = zkRoot;
+ private final String connectString;
+ private final String zkRoot;
+ private final int retriesSleepTimeMillis;
+ private final int numRetries;
+ private final int sessionTimeout;
+ private final String acl;
+ private final String auth;
+
+ public ZookeeperProperties(String connectString, String zkRoot, int retriesSleepTimeMillis, int numRetries, int sessionTimeout, String acl, String auth) {
+ this.connectString = connectString;
+ this.zkRoot = zkRoot;
this.retriesSleepTimeMillis = retriesSleepTimeMillis;
- this.numRetries = numRetries;
- this.sessionTimeout = sessionTimeout;
- this.acl = acl;
- this.auth = auth;
+ this.numRetries = numRetries;
+ this.sessionTimeout = sessionTimeout;
+ this.acl = acl;
+ this.auth = auth;
}
public String getConnectString() {
@@ -151,11 +168,21 @@ public final class HAConfiguration {
return zkRoot;
}
+ @Override
+ public int hashCode() {
+ return Objects.hash(connectString, zkRoot, retriesSleepTimeMillis, numRetries, sessionTimeout, acl, auth);
+ }
+
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ if (this == o) {
+ return true;
+ } else if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
ZookeeperProperties that = (ZookeeperProperties) o;
+
return retriesSleepTimeMillis == that.retriesSleepTimeMillis &&
numRetries == that.numRetries &&
sessionTimeout == that.sessionTimeout &&
@@ -165,43 +192,12 @@ public final class HAConfiguration {
Objects.equals(auth, that.auth);
}
- @Override
- public int hashCode() {
- return Objects.hash(connectString, zkRoot, retriesSleepTimeMillis, numRetries, sessionTimeout, acl, auth);
- }
-
public boolean hasAcl() {
- return getAcl()!=null;
+ return getAcl() != null;
}
public boolean hasAuth() {
- return getAuth()!=null;
- }
- }
-
- public static ZookeeperProperties getZookeeperProperties(Configuration configuration) {
- String[] zkServers;
- if (configuration.containsKey(HA_ZOOKEEPER_CONNECT)) {
- zkServers = configuration.getStringArray(HA_ZOOKEEPER_CONNECT);
- } else {
- zkServers = configuration.getStringArray("atlas.kafka." + ZOOKEEPER_PREFIX + "connect");
+ return getAuth() != null;
}
-
- String zkRoot = configuration.getString(ATLAS_SERVER_HA_ZK_ROOT_KEY, ATLAS_SERVER_ZK_ROOT_DEFAULT);
- int retriesSleepTimeMillis = configuration.getInt(HA_ZOOKEEPER_RETRY_SLEEPTIME_MILLIS,
- DEFAULT_ZOOKEEPER_CONNECT_SLEEPTIME_MILLIS);
-
- int numRetries = configuration.getInt(HA_ZOOKEEPER_NUM_RETRIES, DEFAULT_ZOOKEEPER_CONNECT_NUM_RETRIES);
-
- int sessionTimeout = configuration.getInt(HA_ZOOKEEPER_SESSION_TIMEOUT_MS,
- DEFAULT_ZOOKEEPER_SESSION_TIMEOUT_MILLIS);
-
- String acl = configuration.getString(HA_ZOOKEEPER_ACL);
- String auth = configuration.getString(HA_ZOOKEEPER_AUTH);
-
- return new ZookeeperProperties(StringUtils.join(zkServers, ','),
- zkRoot,
- retriesSleepTimeMillis, numRetries,
- sessionTimeout, acl, auth);
}
}
diff --git a/common/src/main/java/org/apache/atlas/pc/StatusReporter.java b/common/src/main/java/org/apache/atlas/pc/StatusReporter.java
index 507e842b8..147fd4e13 100644
--- a/common/src/main/java/org/apache/atlas/pc/StatusReporter.java
+++ b/common/src/main/java/org/apache/atlas/pc/StatusReporter.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -30,10 +30,10 @@ import java.util.Set;
public class StatusReporter<T, U> {
private static final Logger LOG = LoggerFactory.getLogger(StatusReporter.class);
- private Map<T,U> producedItems = new LinkedHashMap<>();
- private Set<T> processedSet = new HashSet<>();
- private long timeoutDuration;
- private long lastAck;
+ private final Map<T, U> producedItems = new LinkedHashMap<>();
+ private final Set<T> processedSet = new HashSet<>();
+ private final long timeoutDuration;
+ private long lastAck;
public StatusReporter() {
this.timeoutDuration = -1;
@@ -58,17 +58,29 @@ public class StatusReporter<T, U> {
public U ack() {
U ack = null;
U ret;
+
do {
Map.Entry<T, U> firstElement = getFirstElement(this.producedItems);
+
ret = completionIndex(firstElement);
+
if (ret != null) {
ack = ret;
}
- } while(ret != null);
+ }
+ while (ret != null);
return ack;
}
+ public int getProducedCount() {
+ return this.producedItems.size();
+ }
+
+ public int getProcessedCount() {
+ return this.processedSet.size();
+ }
+
private Map.Entry<T, U> getFirstElement(Map<T, U> map) {
if (map.isEmpty()) {
return null;
@@ -79,12 +91,14 @@ public class StatusReporter<T, U> {
private U completionIndex(Map.Entry<T, U> lookFor) {
U ack = null;
+
if (lookFor == null) {
return ack;
}
if (hasTimeoutDurationReached(System.currentTimeMillis())) {
LOG.warn("Ack: Timeout: {} - {}", lookFor.getKey(), lookFor.getValue());
+
return acknowledged(lookFor);
}
@@ -97,22 +111,18 @@ public class StatusReporter<T, U> {
private U acknowledged(Map.Entry<T, U> lookFor) {
U ack = lookFor.getValue();
+
producedItems.remove(lookFor.getKey());
processedSet.remove(lookFor.getKey());
+
return ack;
}
private boolean hasTimeoutDurationReached(long now) {
boolean b = (this.timeoutDuration > -1) && (this.lastAck != 0) && ((now - this.lastAck) >= timeoutDuration);
- lastAck = System.currentTimeMillis();
- return b;
- }
- public int getProducedCount() {
- return this.producedItems.size();
- }
+ lastAck = System.currentTimeMillis();
- public int getProcessedCount() {
- return this.processedSet.size();
+ return b;
}
}
diff --git a/common/src/main/java/org/apache/atlas/pc/WorkItemBuilder.java b/common/src/main/java/org/apache/atlas/pc/WorkItemBuilder.java
index 6dcb29d6a..c3b6fd7b9 100644
--- a/common/src/main/java/org/apache/atlas/pc/WorkItemBuilder.java
+++ b/common/src/main/java/org/apache/atlas/pc/WorkItemBuilder.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
diff --git a/common/src/main/java/org/apache/atlas/pc/WorkItemConsumer.java b/common/src/main/java/org/apache/atlas/pc/WorkItemConsumer.java
index dd76697a5..2bcc4bab5 100644
--- a/common/src/main/java/org/apache/atlas/pc/WorkItemConsumer.java
+++ b/common/src/main/java/org/apache/atlas/pc/WorkItemConsumer.java
@@ -37,8 +37,8 @@ public abstract class WorkItemConsumer<T> implements Runnable {
private final BlockingQueue<T> queue;
private final AtomicBoolean isDirty = new AtomicBoolean(false);
private final AtomicLong maxCommitTimeInMs = new AtomicLong(DEFAULT_COMMIT_TIME_IN_MS);
- private CountDownLatch countdownLatch;
- private Queue<Object> results;
+ private CountDownLatch countdownLatch;
+ private Queue<Object> results;
public WorkItemConsumer(BlockingQueue<T> queue) {
this.queue = queue;
@@ -76,6 +76,14 @@ public abstract class WorkItemConsumer<T> implements Runnable {
return ((commitTime > DEFAULT_COMMIT_TIME_IN_MS) ? commitTime : DEFAULT_COMMIT_TIME_IN_MS);
}
+ public void setCountDownLatch(CountDownLatch countdownLatch) {
+ this.countdownLatch = countdownLatch;
+ }
+
+ public <V> void setResults(Queue<Object> queue) {
+ this.results = queue;
+ }
+
protected void commitDirty() {
if (!isDirty.get()) {
return;
@@ -110,12 +118,4 @@ public abstract class WorkItemConsumer<T> implements Runnable {
this.maxCommitTimeInMs.set(commitTime);
}
}
-
- public void setCountDownLatch(CountDownLatch countdownLatch) {
- this.countdownLatch = countdownLatch;
- }
-
- public <V> void setResults(Queue<Object> queue) {
- this.results = queue;
- }
}
diff --git a/common/src/main/java/org/apache/atlas/pc/WorkItemManager.java b/common/src/main/java/org/apache/atlas/pc/WorkItemManager.java
index 351421e8e..c1f79e417 100644
--- a/common/src/main/java/org/apache/atlas/pc/WorkItemManager.java
+++ b/common/src/main/java/org/apache/atlas/pc/WorkItemManager.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -17,6 +17,7 @@
*/
package org.apache.atlas.pc;
+
import org.apache.curator.shaded.com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -24,19 +25,25 @@ import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.Queue;
-import java.util.concurrent.*;
-
-public class WorkItemManager<T, U extends WorkItemConsumer> {
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+
+public class WorkItemManager<T, U extends WorkItemConsumer<T>> {
private static final Logger LOG = LoggerFactory.getLogger(WorkItemManager.class);
private final int numWorkers;
private final BlockingQueue<T> workQueue;
private final ExecutorService service;
private final List<U> consumers = new ArrayList<>();
- private CountDownLatch countdownLatch;
- private Queue<Object> resultsQueue;
+ private CountDownLatch countdownLatch;
+ private Queue<Object> resultsQueue;
- public WorkItemManager(WorkItemBuilder builder, String namePrefix, int batchSize, int numWorkers, boolean collectResults) {
+ public WorkItemManager(WorkItemBuilder<U, T> builder, String namePrefix, int batchSize, int numWorkers, boolean collectResults) {
this.numWorkers = numWorkers;
this.workQueue = new LinkedBlockingQueue<>(batchSize * numWorkers);
this.service = Executors.newFixedThreadPool(numWorkers, new ThreadFactoryBuilder().setNameFormat(namePrefix + "-%d").build());
@@ -46,7 +53,7 @@ public class WorkItemManager<T, U extends WorkItemConsumer> {
start();
}
- public WorkItemManager(WorkItemBuilder builder, int batchSize, int numWorkers) {
+ public WorkItemManager(WorkItemBuilder<U, T> builder, int batchSize, int numWorkers) {
this(builder, "workItemConsumer", batchSize, numWorkers, false);
}
@@ -54,22 +61,6 @@ public class WorkItemManager<T, U extends WorkItemConsumer> {
this.resultsQueue = resultsQueue;
}
- private void createConsumers(WorkItemBuilder builder, int numWorkers, boolean collectResults) {
- if (collectResults) {
- setResultsCollection(new ConcurrentLinkedQueue<>());
- }
-
- for (int i = 0; i < numWorkers; i++) {
- U c = (U) builder.build(workQueue);
-
- consumers.add(c);
-
- if (collectResults) {
- c.setResults(resultsQueue);
- }
- }
- }
-
public void start() {
this.countdownLatch = new CountDownLatch(numWorkers);
@@ -107,7 +98,9 @@ public class WorkItemManager<T, U extends WorkItemConsumer> {
}
LOG.debug("Drain: Stated! Queue size: {}", workQueue.size());
+
this.countdownLatch.await();
+
LOG.debug("Drain: Done! Queue size: {}", workQueue.size());
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
@@ -125,17 +118,33 @@ public class WorkItemManager<T, U extends WorkItemConsumer> {
LOG.info("WorkItemManager: Shutdown done!");
}
- public Queue getResults() {
+ public Queue<Object> getResults() {
return this.resultsQueue;
}
+ private void createConsumers(WorkItemBuilder<U, T> builder, int numWorkers, boolean collectResults) {
+ if (collectResults) {
+ setResultsCollection(new ConcurrentLinkedQueue<>());
+ }
+
+ for (int i = 0; i < numWorkers; i++) {
+ U c = builder.build(workQueue);
+
+ consumers.add(c);
+
+ if (collectResults) {
+ c.setResults(resultsQueue);
+ }
+ }
+ }
+
private int getAvgCommitTimeSeconds() {
- int commitTimeSeconds = 0;
+ long commitTimeSeconds = 0;
for (U c : consumers) {
commitTimeSeconds += c.getMaxCommitTimeInMs();
}
- return (commitTimeSeconds / consumers.size()) / 1000;
+ return (int) ((commitTimeSeconds / consumers.size()) / 1000);
}
}
diff --git a/common/src/main/java/org/apache/atlas/repository/Constants.java b/common/src/main/java/org/apache/atlas/repository/Constants.java
index 2134133f5..3addbcd0d 100644
--- a/common/src/main/java/org/apache/atlas/repository/Constants.java
+++ b/common/src/main/java/org/apache/atlas/repository/Constants.java
@@ -26,10 +26,8 @@ import static org.apache.atlas.type.AtlasStructType.AtlasAttribute.encodePropert
/**
* Repository Constants.
- *
*/
public final class Constants {
-
/**
* Globally Unique identifier property key.
*/
@@ -45,12 +43,12 @@ public final class Constants {
/**
* Entity type name property key.
*/
- public static final String ENTITY_TYPE_PROPERTY_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "typeName");
+ public static final String ENTITY_TYPE_PROPERTY_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "typeName");
public static final String RELATIONSHIP_TYPE_PROPERTY_KEY = encodePropertyKey(RELATIONSHIP_PROPERTY_KEY_PREFIX + ENTITY_TYPE_PROPERTY_KEY);
- public static final String TYPE_NAME_INTERNAL = INTERNAL_PROPERTY_KEY_PREFIX + "internal";
- public static final String ASSET_ENTITY_TYPE = "Asset";
- public static final String OWNER_ATTRIBUTE = "owner";
+ public static final String TYPE_NAME_INTERNAL = INTERNAL_PROPERTY_KEY_PREFIX + "internal";
+ public static final String ASSET_ENTITY_TYPE = "Asset";
+ public static final String OWNER_ATTRIBUTE = "owner";
/**
* Entity type's super types property key.
@@ -84,20 +82,20 @@ public final class Constants {
/**
* Trait names property key and index name.
*/
- public static final String TRAIT_NAMES_PROPERTY_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "traitNames");
- public static final String PROPAGATED_TRAIT_NAMES_PROPERTY_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "propagatedTraitNames");
-
- public static final String VERSION_PROPERTY_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "version");
- public static final String STATE_PROPERTY_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "state");
- public static final String CREATED_BY_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "createdBy");
- public static final String MODIFIED_BY_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "modifiedBy");
- public static final String CLASSIFICATION_TEXT_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "classificationsText");
- public static final String CLASSIFICATION_NAMES_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "classificationNames");
- public static final String PROPAGATED_CLASSIFICATION_NAMES_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "propagatedClassificationNames");
- public static final String CUSTOM_ATTRIBUTES_PROPERTY_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "customAttributes");
- public static final String LABELS_PROPERTY_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "labels");
- public static final String EDGE_PENDING_TASKS_PROPERTY_KEY = encodePropertyKey(RELATIONSHIP_PROPERTY_KEY_PREFIX + "__pendingTasks");
+ public static final String TRAIT_NAMES_PROPERTY_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "traitNames");
+ public static final String PROPAGATED_TRAIT_NAMES_PROPERTY_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "propagatedTraitNames");
+ public static final String VERSION_PROPERTY_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "version");
+ public static final String STATE_PROPERTY_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "state");
+ public static final String CLASSIFICATION_EDGE_STATE_PROPERTY_KEY = STATE_PROPERTY_KEY;
+ public static final String CREATED_BY_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "createdBy");
+ public static final String MODIFIED_BY_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "modifiedBy");
+ public static final String CLASSIFICATION_TEXT_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "classificationsText");
+ public static final String CLASSIFICATION_NAMES_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "classificationNames");
+ public static final String PROPAGATED_CLASSIFICATION_NAMES_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "propagatedClassificationNames");
+ public static final String CUSTOM_ATTRIBUTES_PROPERTY_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "customAttributes");
+ public static final String LABELS_PROPERTY_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "labels");
+ public static final String EDGE_PENDING_TASKS_PROPERTY_KEY = encodePropertyKey(RELATIONSHIP_PROPERTY_KEY_PREFIX + "__pendingTasks");
/**
* Patch vertices property keys.
*/
@@ -106,7 +104,6 @@ public final class Constants {
public static final String PATCH_TYPE_PROPERTY_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "patch.type");
public static final String PATCH_ACTION_PROPERTY_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "patch.action");
public static final String PATCH_STATE_PROPERTY_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "patch.state");
-
/**
* The homeId field is used when saving into Atlas a copy of an object that is being imported from another
* repository. The homeId will be set to a String that identifies the other repository. The specific format
@@ -118,75 +115,60 @@ public final class Constants {
* should only be updated via the notifications and calls from Open Metadata Repository Services.
*/
public static final String HOME_ID_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "homeId");
-
/**
* The isProxy field is used when saving into Atlas a proxy of an entity - i.e. it is not a whole entity, but
* a partial representation of an entity that is referred to by a relationship end.
* The isProxy field will be set to true if the entity is a proxy. The field is used during retrieval of an
* entity (proxy) from Atlas to indicate that the entity does not contain full entity detail.
*/
- public static final String IS_PROXY_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "isProxy");
-
+ public static final String IS_PROXY_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "isProxy");
/**
* The provenanceType field is used to record the provenance of an instance of an entity or relationship - this
* indicates how the instance was created. This corresponds to the InstanceProvenanceType enum defined in ODPi.
* To avoid creating a hard dependency on the ODPi class, the value is stored as an int corresponding to the
* ordinal in the ODPi enum.
*/
- public static final String PROVENANCE_TYPE_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "provenanceType");
-
+ public static final String PROVENANCE_TYPE_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "provenanceType");
public static final String TIMESTAMP_PROPERTY_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "timestamp");
-
public static final String ENTITY_DELETED_TIMESTAMP_PROPERTY_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "entityDeletedTimestamp");
-
public static final String MODIFICATION_TIMESTAMP_PROPERTY_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "modificationTimestamp");
-
public static final String IS_INCOMPLETE_PROPERTY_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "isIncomplete");
-
/**
* search backing index name.
*/
public static final String BACKING_INDEX = "search";
-
/**
* search backing index name for vertex keys.
*/
public static final String VERTEX_INDEX = "vertex_index";
-
/**
* search backing index name for edge labels.
*/
public static final String EDGE_INDEX = "edge_index";
-
public static final String FULLTEXT_INDEX = "fulltext_index";
-
public static final String QUALIFIED_NAME = "Referenceable.qualifiedName";
public static final String TYPE_NAME_PROPERTY_KEY = INTERNAL_PROPERTY_KEY_PREFIX + "typeName";
+ public static final String CLASSIFICATION_VERTEX_NAME_KEY = encodePropertyKey(TYPE_NAME_PROPERTY_KEY);
public static final String INDEX_SEARCH_MAX_RESULT_SET_SIZE = "atlas.graph.index.search.max-result-set-size";
public static final String INDEX_SEARCH_TYPES_MAX_QUERY_STR_LENGTH = "atlas.graph.index.search.types.max-query-str-length";
public static final String INDEX_SEARCH_TAGS_MAX_QUERY_STR_LENGTH = "atlas.graph.index.search.tags.max-query-str-length";
public static final String INDEX_SEARCH_VERTEX_PREFIX_PROPERTY = "atlas.graph.index.search.vertex.prefix";
public static final String INDEX_SEARCH_VERTEX_PREFIX_DEFAULT = "$v$";
-
public static final String MAX_FULLTEXT_QUERY_STR_LENGTH = "atlas.graph.fulltext-max-query-str-length";
public static final String MAX_DSL_QUERY_STR_LENGTH = "atlas.graph.dsl-max-query-str-length";
-
public static final String ATTRIBUTE_NAME_GUID = "guid";
public static final String ATTRIBUTE_NAME_TYPENAME = "typeName";
public static final String ATTRIBUTE_NAME_SUPERTYPENAMES = "superTypeNames";
public static final String ATTRIBUTE_NAME_STATE = "state";
public static final String ATTRIBUTE_NAME_VERSION = "version";
public static final String TEMP_STRUCT_NAME_PREFIX = "__tempQueryResultStruct";
-
public static final String CLASSIFICATION_ENTITY_GUID = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "entityGuid");
public static final String CLASSIFICATION_ENTITY_STATUS = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "entityStatus");
public static final String CLASSIFICATION_VALIDITY_PERIODS_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "validityPeriods");
public static final String CLASSIFICATION_VERTEX_PROPAGATE_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "propagate");
public static final String CLASSIFICATION_VERTEX_REMOVE_PROPAGATIONS_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "removePropagations");
- public static final String CLASSIFICATION_VERTEX_NAME_KEY = encodePropertyKey(TYPE_NAME_PROPERTY_KEY);
public static final String CLASSIFICATION_EDGE_NAME_PROPERTY_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "name");
public static final String CLASSIFICATION_EDGE_IS_PROPAGATED_PROPERTY_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "isPropagated");
- public static final String CLASSIFICATION_EDGE_STATE_PROPERTY_KEY = STATE_PROPERTY_KEY;
public static final String CLASSIFICATION_LABEL = "classifiedAs";
public static final String CLASSIFICATION_NAME_DELIMITER = "|";
public static final String LABEL_NAME_DELIMITER = CLASSIFICATION_NAME_DELIMITER;
@@ -205,19 +187,18 @@ public final class Constants {
public static final String ATTR_NAME_REFERENCEABLE = "Referenceable.";
public static final String ATTR_NAME_REPLICATED_TO = "replicatedTo";
public static final String ATTR_NAME_REPLICATED_FROM = "replicatedFrom";
- public static final Integer INCOMPLETE_ENTITY_VALUE = Integer.valueOf(1);
+ public static final Integer INCOMPLETE_ENTITY_VALUE = 1;
/*
* typedef patch constants
*/
- public static final String TYPEDEF_PATCH_ADD_MANDATORY_ATTRIBUTE = "ADD_MANDATORY_ATTRIBUTE";
+ public static final String TYPEDEF_PATCH_ADD_MANDATORY_ATTRIBUTE = "ADD_MANDATORY_ATTRIBUTE";
/*
* Task related constants
*/
public static final String TASK_PREFIX = INTERNAL_PROPERTY_KEY_PREFIX + "task_";
public static final String TASK_TYPE_PROPERTY_KEY = encodePropertyKey(TASK_PREFIX + "v_type");
- public static final String TASK_TYPE_NAME = INTERNAL_PROPERTY_KEY_PREFIX + "AtlasTaskDef";
public static final String TASK_GUID = encodePropertyKey(TASK_PREFIX + "guid");
public static final String TASK_TYPE = encodePropertyKey(TASK_PREFIX + "type");
public static final String TASK_CREATED_TIME = encodePropertyKey(TASK_PREFIX + "timestamp");
@@ -229,7 +210,7 @@ public final class Constants {
public static final String TASK_ERROR_MESSAGE = encodePropertyKey(TASK_PREFIX + "errorMessage");
public static final String TASK_START_TIME = encodePropertyKey(TASK_PREFIX + "startTime");
public static final String TASK_END_TIME = encodePropertyKey(TASK_PREFIX + "endTime");
-
+ public static final String TASK_TYPE_NAME = INTERNAL_PROPERTY_KEY_PREFIX + "AtlasTaskDef";
/**
* Index Recovery vertex property keys.
*/
@@ -248,19 +229,14 @@ public final class Constants {
public static final String PROPERTY_KEY_GUIDS_TO_AGEOUT_BY_CUSTOM = encodePropertyKey(AUDIT_REDUCTION_PREFIX + "custom");
public static final String PROPERTY_KEY_GUIDS_TO_SWEEPOUT = encodePropertyKey(AUDIT_REDUCTION_PREFIX + "sweepout");
- public static final String SQOOP_SOURCE = "sqoop";
- public static final String FALCON_SOURCE = "falcon";
- public static final String HBASE_SOURCE = "hbase";
- public static final String HS2_SOURCE = "hive_server2";
- public static final String HMS_SOURCE = "hive_metastore";
- public static final String IMPALA_SOURCE = "impala";
- public static final String STORM_SOURCE = "storm";
- public static final String FILE_SPOOL_SOURCE = "file_spool";
-
- /**
- * Audit Reduction related constants
- */
- public enum AtlasAuditAgingType { DEFAULT, CUSTOM, SWEEP }
+ public static final String SQOOP_SOURCE = "sqoop";
+ public static final String FALCON_SOURCE = "falcon";
+ public static final String HBASE_SOURCE = "hbase";
+ public static final String HS2_SOURCE = "hive_server2";
+ public static final String HMS_SOURCE = "hive_metastore";
+ public static final String IMPALA_SOURCE = "impala";
+ public static final String STORM_SOURCE = "storm";
+ public static final String FILE_SPOOL_SOURCE = "file_spool";
public static final String AUDIT_REDUCTION_TYPE_NAME = "__auditReductionInfo";
public static final String AUDIT_AGING_TYPE_KEY = "auditAgingType";
public static final String AUDIT_AGING_TTL_KEY = "ttl";
@@ -271,11 +247,6 @@ public final class Constants {
public static final String CREATE_EVENTS_AGEOUT_ALLOWED_KEY = "createEventsAgeoutAllowed";
public static final String AUDIT_AGING_SUBTYPES_INCLUDED_KEY = "subTypesIncluded";
- /*
- * All supported file-format extensions for Bulk Imports through file upload
- */
- public enum SupportedFileExtensions { XLSX, XLS, CSV }
-
private Constants() {
}
@@ -283,9 +254,7 @@ public final class Constants {
try {
Configuration configuration = ApplicationProperties.get();
- if (configuration.containsKey("atlas.graph.index.search.backend") &&
- configuration.getString("atlas.graph.index.search.backend").equals("elasticsearch")) {
-
+ if (configuration.containsKey("atlas.graph.index.search.backend") && configuration.getString("atlas.graph.index.search.backend").equals("elasticsearch")) {
return defaultKey.replaceAll("\\.", "_");
}
@@ -294,4 +263,14 @@ public final class Constants {
return encodePropertyKey(defaultKey);
}
}
+
+ /**
+ * Audit Reduction related constants
+ */
+ public enum AtlasAuditAgingType { DEFAULT, CUSTOM, SWEEP }
+
+ /*
+ * All supported file-format extensions for Bulk Imports through file upload
+ */
+ public enum SupportedFileExtensions { XLSX, XLS, CSV }
}
diff --git a/common/src/main/java/org/apache/atlas/service/Service.java b/common/src/main/java/org/apache/atlas/service/Service.java
index c87a240fa..6e7865941 100644
--- a/common/src/main/java/org/apache/atlas/service/Service.java
+++ b/common/src/main/java/org/apache/atlas/service/Service.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -23,7 +23,6 @@ import org.apache.atlas.AtlasException;
* Service interface to start any background jobs.
*/
public interface Service {
-
void start() throws AtlasException;
void stop() throws AtlasException;
diff --git a/common/src/main/java/org/apache/atlas/service/Services.java b/common/src/main/java/org/apache/atlas/service/Services.java
index 2d548467f..01a644c3d 100644
--- a/common/src/main/java/org/apache/atlas/service/Services.java
+++ b/common/src/main/java/org/apache/atlas/service/Services.java
@@ -27,6 +27,7 @@ import org.springframework.context.annotation.Profile;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
+
import java.util.List;
import static org.apache.atlas.AtlasConstants.ATLAS_MIGRATION_MODE_FILENAME;
@@ -39,8 +40,9 @@ import static org.apache.atlas.AtlasConstants.ATLAS_SERVICES_ENABLED;
@Profile("!test")
public class Services {
public static final Logger LOG = LoggerFactory.getLogger(Services.class);
+
private static final String DATA_MIGRATION_CLASS_NAME_DEFAULT = "DataMigrationService";
- private static final String FILE_EXTENSION_ZIP = ".zip";
+ private static final String FILE_EXTENSION_ZIP = ".zip";
private final List<Service> services;
private final String dataMigrationClassName;
diff --git a/common/src/main/java/org/apache/atlas/utils/AtlasPathExtractorUtil.java b/common/src/main/java/org/apache/atlas/utils/AtlasPathExtractorUtil.java
index ecdf8c5d1..a60da1ec5 100644
--- a/common/src/main/java/org/apache/atlas/utils/AtlasPathExtractorUtil.java
+++ b/common/src/main/java/org/apache/atlas/utils/AtlasPathExtractorUtil.java
@@ -29,11 +29,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.URI;
-import java.util.stream.IntStream;
+import java.util.Arrays;
public class AtlasPathExtractorUtil {
- private static final Logger LOG = LoggerFactory.getLogger(AtlasPathExtractorUtil.class);
-
// Common
public static final char QNAME_SEP_METADATA_NAMESPACE = '@';
public static final char QNAME_SEP_ENTITY_NAME = '.';
@@ -41,13 +39,11 @@ public class AtlasPathExtractorUtil {
public static final String ATTRIBUTE_QUALIFIED_NAME = "qualifiedName";
public static final String ATTRIBUTE_NAME = "name";
public static final String ATTRIBUTE_BUCKET = "bucket";
-
// HDFS
public static final String HDFS_TYPE_PATH = "hdfs_path";
public static final String ATTRIBUTE_PATH = "path";
public static final String ATTRIBUTE_CLUSTER_NAME = "clusterName";
public static final String ATTRIBUTE_NAMESERVICE_ID = "nameServiceId";
-
// AWS S3
public static final String AWS_S3_ATLAS_MODEL_VERSION_V2 = "v2";
public static final String AWS_S3_BUCKET = "aws_s3_bucket";
@@ -60,49 +56,50 @@ public class AtlasPathExtractorUtil {
public static final String ATTRIBUTE_OBJECT_PREFIX = "objectPrefix";
public static final String RELATIONSHIP_AWS_S3_BUCKET_S3_PSEUDO_DIRS = "aws_s3_bucket_aws_s3_pseudo_dirs";
public static final String RELATIONSHIP_AWS_S3_V2_CONTAINER_CONTAINED = "aws_s3_v2_container_contained";
-
// ADLS Gen2
- public static final String ADLS_GEN2_ACCOUNT = "adls_gen2_account";
- public static final String ADLS_GEN2_CONTAINER = "adls_gen2_container";
- public static final String ADLS_GEN2_DIRECTORY = "adls_gen2_directory";
- public static final String ADLS_GEN2_ACCOUNT_HOST_SUFFIX = ".dfs.core.windows.net";
- public static final String ABFS_SCHEME = "abfs" + SCHEME_SEPARATOR;
- public static final String ABFSS_SCHEME = "abfss" + SCHEME_SEPARATOR;
- public static final String ATTRIBUTE_ACCOUNT = "account";
- public static final String ATTRIBUTE_PARENT = "parent";
- public static final String RELATIONSHIP_ADLS_GEN2_ACCOUNT_CONTAINERS = "adls_gen2_account_containers";
- public static final String RELATIONSHIP_ADLS_GEN2_PARENT_CHILDREN = "adls_gen2_parent_children";
-
+ public static final String ADLS_GEN2_ACCOUNT = "adls_gen2_account";
+ public static final String ADLS_GEN2_CONTAINER = "adls_gen2_container";
+ public static final String ADLS_GEN2_DIRECTORY = "adls_gen2_directory";
+ public static final String ADLS_GEN2_ACCOUNT_HOST_SUFFIX = ".dfs.core.windows.net";
+ public static final String ABFS_SCHEME = "abfs" + SCHEME_SEPARATOR;
+ public static final String ABFSS_SCHEME = "abfss" + SCHEME_SEPARATOR;
+ public static final String ATTRIBUTE_ACCOUNT = "account";
+ public static final String ATTRIBUTE_PARENT = "parent";
+ public static final String RELATIONSHIP_ADLS_GEN2_ACCOUNT_CONTAINERS = "adls_gen2_account_containers";
+ public static final String RELATIONSHIP_ADLS_GEN2_PARENT_CHILDREN = "adls_gen2_parent_children";
// Ozone
- public static final String OZONE_VOLUME = "ozone_volume";
- public static final String OZONE_BUCKET = "ozone_bucket";
- public static final String OZONE_KEY = "ozone_key";
- public static final String OZONE_SCHEME = "ofs" + SCHEME_SEPARATOR;
- public static final String OZONE_3_SCHEME = "o3fs" + SCHEME_SEPARATOR;
- public static final String ATTRIBUTE_VOLUME = "volume";
- public static final String RELATIONSHIP_OZONE_VOLUME_BUCKET = "ozone_volume_buckets";
- public static final String RELATIONSHIP_OZONE_PARENT_CHILDREN = "ozone_parent_children";
- public static final String OZONE_SCHEME_NAME = "ofs";
-
+ public static final String OZONE_VOLUME = "ozone_volume";
+ public static final String OZONE_BUCKET = "ozone_bucket";
+ public static final String OZONE_KEY = "ozone_key";
+ public static final String OZONE_SCHEME = "ofs" + SCHEME_SEPARATOR;
+ public static final String OZONE_3_SCHEME = "o3fs" + SCHEME_SEPARATOR;
+ public static final String ATTRIBUTE_VOLUME = "volume";
+ public static final String RELATIONSHIP_OZONE_VOLUME_BUCKET = "ozone_volume_buckets";
+ public static final String RELATIONSHIP_OZONE_PARENT_CHILDREN = "ozone_parent_children";
+ public static final String OZONE_SCHEME_NAME = "ofs";
//Google Cloud Storage
public static final String GCS_SCHEME = "gs" + SCHEME_SEPARATOR;
public static final String GCS_BUCKET = "gcp_storage_bucket";
public static final String GCS_VIRTUAL_DIR = "gcp_storage_virtual_directory";
public static final String ATTRIBUTE_GCS_PARENT = "parent";
public static final String RELATIONSHIP_GCS_PARENT_CHILDREN = "gcp_storage_parent_children";
+ private static final Logger LOG = LoggerFactory.getLogger(AtlasPathExtractorUtil.class);
+
+ private AtlasPathExtractorUtil() {
+ // to block instantiation
+ }
public static AtlasEntityWithExtInfo getPathEntity(Path path, PathExtractorContext context) {
AtlasEntityWithExtInfo entityWithExtInfo = new AtlasEntityWithExtInfo();
- AtlasEntity ret;
- String strPath = path.toString();
+ String strPath = path.toString();
+ AtlasEntity ret;
if (context.isConvertPathToLowerCase()) {
strPath = strPath.toLowerCase();
}
if (isS3Path(strPath)) {
- ret = isAwsS3AtlasModelVersionV2(context) ? addS3PathEntityV2(path, entityWithExtInfo, context) :
- addS3PathEntityV1(path, entityWithExtInfo, context);
+ ret = isAwsS3AtlasModelVersionV2(context) ? addS3PathEntityV2(path, entityWithExtInfo, context) : addS3PathEntityV1(path, entityWithExtInfo, context);
} else if (isAbfsPath(strPath)) {
ret = addAbfsPathEntity(path, entityWithExtInfo, context);
} else if (isOzonePath(strPath)) {
@@ -119,8 +116,7 @@ public class AtlasPathExtractorUtil {
}
private static boolean isAwsS3AtlasModelVersionV2(PathExtractorContext context) {
- return StringUtils.isNotEmpty(context.getAwsS3AtlasModelVersion()) &&
- StringUtils.equalsIgnoreCase(context.getAwsS3AtlasModelVersion(), AWS_S3_ATLAS_MODEL_VERSION_V2);
+ return StringUtils.isNotEmpty(context.getAwsS3AtlasModelVersion()) && StringUtils.equalsIgnoreCase(context.getAwsS3AtlasModelVersion(), AWS_S3_ATLAS_MODEL_VERSION_V2);
}
private static boolean isS3Path(String strPath) {
@@ -142,9 +138,7 @@ public class AtlasPathExtractorUtil {
private static AtlasEntity addS3PathEntityV1(Path path, AtlasEntityExtInfo extInfo, PathExtractorContext context) {
String strPath = path.toString();
- if (LOG.isDebugEnabled()) {
- LOG.debug("==> addS3PathEntityV1(strPath={})", strPath);
- }
+ LOG.debug("==> addS3PathEntityV1(strPath={})", strPath);
String metadataNamespace = context.getMetadataNamespace();
String bucketName = path.toUri().getAuthority();
@@ -175,9 +169,7 @@ public class AtlasPathExtractorUtil {
context.putEntity(pathQualifiedName, ret);
}
- if (LOG.isDebugEnabled()) {
- LOG.debug("<== addS3PathEntityV1(strPath={})", strPath);
- }
+ LOG.debug("<== addS3PathEntityV1(strPath={})", strPath);
return ret;
}
@@ -185,9 +177,7 @@ public class AtlasPathExtractorUtil {
private static AtlasEntity addS3PathEntityV2(Path path, AtlasEntityExtInfo extInfo, PathExtractorContext context) {
String strPath = path.toString();
- if (LOG.isDebugEnabled()) {
- LOG.debug("==> addS3PathEntityV2(strPath={})", strPath);
- }
+ LOG.debug("==> addS3PathEntityV2(strPath={})", strPath);
String metadataNamespace = context.getMetadataNamespace();
String pathQualifiedName = strPath + QNAME_SEP_METADATA_NAMESPACE + metadataNamespace;
@@ -205,9 +195,7 @@ public class AtlasPathExtractorUtil {
bucketEntity.setAttribute(ATTRIBUTE_QUALIFIED_NAME, bucketQualifiedName);
bucketEntity.setAttribute(ATTRIBUTE_NAME, bucketName);
- if (LOG.isDebugEnabled()) {
- LOG.debug("adding entity: typeName={}, qualifiedName={}", bucketEntity.getTypeName(), bucketEntity.getAttribute(ATTRIBUTE_QUALIFIED_NAME));
- }
+ LOG.debug("adding entity: typeName={}, qualifiedName={}", bucketEntity.getTypeName(), bucketEntity.getAttribute(ATTRIBUTE_QUALIFIED_NAME));
context.putEntity(bucketQualifiedName, bucketEntity);
}
@@ -240,9 +228,7 @@ public class AtlasPathExtractorUtil {
ret.setAttribute(ATTRIBUTE_QUALIFIED_NAME, subDirQualifiedName);
ret.setAttribute(ATTRIBUTE_NAME, subDirName);
- if (LOG.isDebugEnabled()) {
- LOG.debug("adding entity: typeName={}, qualifiedName={}", ret.getTypeName(), ret.getAttribute(ATTRIBUTE_QUALIFIED_NAME));
- }
+ LOG.debug("adding entity: typeName={}, qualifiedName={}", ret.getTypeName(), ret.getAttribute(ATTRIBUTE_QUALIFIED_NAME));
context.putEntity(subDirQualifiedName, ret);
}
@@ -256,9 +242,7 @@ public class AtlasPathExtractorUtil {
}
}
- if (LOG.isDebugEnabled()) {
- LOG.debug("<== addS3PathEntityV2(strPath={})", strPath);
- }
+ LOG.debug("<== addS3PathEntityV2(strPath={})", strPath);
return ret;
}
@@ -266,9 +250,7 @@ public class AtlasPathExtractorUtil {
private static AtlasEntity addAbfsPathEntity(Path path, AtlasEntityExtInfo extInfo, PathExtractorContext context) {
String strPath = path.toString();
- if (LOG.isDebugEnabled()) {
- LOG.debug("==> addAbfsPathEntity(strPath={})", strPath);
- }
+ LOG.debug("==> addAbfsPathEntity(strPath={})", strPath);
String metadataNamespace = context.getMetadataNamespace();
String pathQualifiedName = strPath + QNAME_SEP_METADATA_NAMESPACE + metadataNamespace;
@@ -288,9 +270,7 @@ public class AtlasPathExtractorUtil {
storageAcctEntity.setAttribute(ATTRIBUTE_QUALIFIED_NAME, storageAcctQualifiedName);
storageAcctEntity.setAttribute(ATTRIBUTE_NAME, storageAcctName);
- if (LOG.isDebugEnabled()) {
- LOG.debug("adding entity: typeName={}, qualifiedName={}", storageAcctEntity.getTypeName(), storageAcctEntity.getAttribute(ATTRIBUTE_QUALIFIED_NAME));
- }
+ LOG.debug("adding entity: typeName={}, qualifiedName={}", storageAcctEntity.getTypeName(), storageAcctEntity.getAttribute(ATTRIBUTE_QUALIFIED_NAME));
context.putEntity(storageAcctQualifiedName, storageAcctEntity);
}
@@ -312,9 +292,7 @@ public class AtlasPathExtractorUtil {
containerEntity.setAttribute(ATTRIBUTE_NAME, containerName);
containerEntity.setRelationshipAttribute(ATTRIBUTE_ACCOUNT, storageAcctObjId);
- if (LOG.isDebugEnabled()) {
- LOG.debug("adding entity: typeName={}, qualifiedName={}", containerEntity.getTypeName(), containerEntity.getAttribute(ATTRIBUTE_QUALIFIED_NAME));
- }
+ LOG.debug("adding entity: typeName={}, qualifiedName={}", containerEntity.getTypeName(), containerEntity.getAttribute(ATTRIBUTE_QUALIFIED_NAME));
context.putEntity(containerQualifiedName, containerEntity);
}
@@ -347,9 +325,7 @@ public class AtlasPathExtractorUtil {
ret.setAttribute(ATTRIBUTE_QUALIFIED_NAME, subDirQualifiedName);
ret.setAttribute(ATTRIBUTE_NAME, subDirName);
- if (LOG.isDebugEnabled()) {
- LOG.debug("adding entity: typeName={}, qualifiedName={}", ret.getTypeName(), ret.getAttribute(ATTRIBUTE_QUALIFIED_NAME));
- }
+ LOG.debug("adding entity: typeName={}, qualifiedName={}", ret.getTypeName(), ret.getAttribute(ATTRIBUTE_QUALIFIED_NAME));
context.putEntity(subDirQualifiedName, ret);
}
@@ -363,9 +339,7 @@ public class AtlasPathExtractorUtil {
}
}
- if (LOG.isDebugEnabled()) {
- LOG.debug("<== addAbfsPathEntity(strPath={})", strPath);
- }
+ LOG.debug("<== addAbfsPathEntity(strPath={})", strPath);
return ret;
}
@@ -373,9 +347,7 @@ public class AtlasPathExtractorUtil {
private static AtlasEntity addOzonePathEntity(Path path, AtlasEntityExtInfo extInfo, PathExtractorContext context) {
String strPath = path.toString();
- if (LOG.isDebugEnabled()) {
- LOG.debug("==> addOzonePathEntity(strPath={})", strPath);
- }
+ LOG.debug("==> addOzonePathEntity(strPath={})", strPath);
String metadataNamespace = context.getMetadataNamespace();
String ozoneScheme = path.toUri().getScheme();
@@ -394,9 +366,7 @@ public class AtlasPathExtractorUtil {
volumeEntity.setAttribute(ATTRIBUTE_QUALIFIED_NAME, volumeQualifiedName);
volumeEntity.setAttribute(ATTRIBUTE_NAME, volumeName);
- if (LOG.isDebugEnabled()) {
- LOG.debug("adding entity: typeName={}, qualifiedName={}", volumeEntity.getTypeName(), volumeEntity.getAttribute(ATTRIBUTE_QUALIFIED_NAME));
- }
+ LOG.debug("adding entity: typeName={}, qualifiedName={}", volumeEntity.getTypeName(), volumeEntity.getAttribute(ATTRIBUTE_QUALIFIED_NAME));
context.putEntity(volumeQualifiedName, volumeEntity);
}
@@ -413,11 +383,9 @@ public class AtlasPathExtractorUtil {
bucketEntity.setAttribute(ATTRIBUTE_QUALIFIED_NAME, bucketQualifiedName);
bucketEntity.setAttribute(ATTRIBUTE_NAME, bucketName);
- bucketEntity.setRelationshipAttribute( ATTRIBUTE_VOLUME, AtlasTypeUtil.getAtlasRelatedObjectId(volumeEntity, RELATIONSHIP_OZONE_VOLUME_BUCKET));
+ bucketEntity.setRelationshipAttribute(ATTRIBUTE_VOLUME, AtlasTypeUtil.getAtlasRelatedObjectId(volumeEntity, RELATIONSHIP_OZONE_VOLUME_BUCKET));
- if (LOG.isDebugEnabled()) {
- LOG.debug("adding entity: typeName={}, qualifiedName={}", bucketEntity.getTypeName(), bucketEntity.getAttribute(ATTRIBUTE_QUALIFIED_NAME));
- }
+ LOG.debug("adding entity: typeName={}, qualifiedName={}", bucketEntity.getTypeName(), bucketEntity.getAttribute(ATTRIBUTE_QUALIFIED_NAME));
context.putEntity(bucketQualifiedName, bucketEntity);
}
@@ -433,30 +401,30 @@ public class AtlasPathExtractorUtil {
}
String keyQNamePrefix = ozoneScheme + SCHEME_SEPARATOR + path.toUri().getAuthority();
-
-
- String[] subDirNames = dirPath.split(Path.SEPARATOR);
+ String[] subDirNames = dirPath.split(Path.SEPARATOR);
String[] subDirNameArr = subDirNames;
+
if (ozoneScheme.equals(OZONE_SCHEME_NAME)) {
- subDirNames = IntStream.range(3, subDirNameArr.length)
- .mapToObj(i -> subDirNameArr[i])
- .toArray(String[]::new);
+ subDirNames = Arrays.stream(subDirNameArr, 3, subDirNameArr.length).toArray(String[]::new);
}
boolean volumeBucketAdded = false;
+
for (String subDirName : subDirNames) {
if (StringUtils.isEmpty(subDirName)) {
continue;
}
String subDirPath;
+
if (ozoneScheme.equals(OZONE_SCHEME_NAME) && !volumeBucketAdded) {
- subDirPath = "%s%s" + Path.SEPARATOR + "%s" + Path.SEPARATOR + "%s";
- subDirPath = String.format(subDirPath, parentPath, subDirNameArr[1], subDirNameArr[2], subDirName);
+ subDirPath = "%s%s" + Path.SEPARATOR + "%s" + Path.SEPARATOR + "%s";
+ subDirPath = String.format(subDirPath, parentPath, subDirNameArr[1], subDirNameArr[2], subDirName);
volumeBucketAdded = true;
} else {
subDirPath = parentPath + subDirName;
}
+
String subDirQualifiedName = keyQNamePrefix + subDirPath + QNAME_SEP_METADATA_NAMESPACE + metadataNamespace;
ret = context.getEntity(subDirQualifiedName);
@@ -468,21 +436,17 @@ public class AtlasPathExtractorUtil {
ret.setAttribute(ATTRIBUTE_QUALIFIED_NAME, subDirQualifiedName);
ret.setAttribute(ATTRIBUTE_NAME, subDirName);
- if (LOG.isDebugEnabled()) {
- LOG.debug("adding entity: typeName={}, qualifiedName={}", ret.getTypeName(), ret.getAttribute(ATTRIBUTE_QUALIFIED_NAME));
- }
+ LOG.debug("adding entity: typeName={}, qualifiedName={}", ret.getTypeName(), ret.getAttribute(ATTRIBUTE_QUALIFIED_NAME));
context.putEntity(subDirQualifiedName, ret);
}
parentObjId = AtlasTypeUtil.getAtlasRelatedObjectId(ret, RELATIONSHIP_OZONE_PARENT_CHILDREN);
- parentPath = subDirPath + Path.SEPARATOR;;
+ parentPath = subDirPath + Path.SEPARATOR;
}
}
- if (LOG.isDebugEnabled()) {
- LOG.debug("<== addOzonePathEntity(strPath={})", strPath);
- }
+ LOG.debug("<== addOzonePathEntity(strPath={})", strPath);
return ret;
}
@@ -490,9 +454,7 @@ public class AtlasPathExtractorUtil {
private static AtlasEntity addGCSPathEntity(Path path, AtlasEntityExtInfo extInfo, PathExtractorContext context) {
String strPath = path.toString();
- if (LOG.isDebugEnabled()) {
- LOG.debug("==> addGCSPathEntity(strPath={})", strPath);
- }
+ LOG.debug("==> addGCSPathEntity(strPath={})", strPath);
String metadataNamespace = context.getMetadataNamespace();
String pathQualifiedName = strPath + QNAME_SEP_METADATA_NAMESPACE + metadataNamespace;
@@ -510,9 +472,7 @@ public class AtlasPathExtractorUtil {
bucketEntity.setAttribute(ATTRIBUTE_QUALIFIED_NAME, bucketQualifiedName);
bucketEntity.setAttribute(ATTRIBUTE_NAME, bucketName);
- if (LOG.isDebugEnabled()) {
- LOG.debug("adding entity: typeName={}, qualifiedName={}", bucketEntity.getTypeName(), bucketEntity.getAttribute(ATTRIBUTE_QUALIFIED_NAME));
- }
+ LOG.debug("adding entity: typeName={}, qualifiedName={}", bucketEntity.getTypeName(), bucketEntity.getAttribute(ATTRIBUTE_QUALIFIED_NAME));
context.putEntity(bucketQualifiedName, bucketEntity);
}
@@ -545,9 +505,7 @@ public class AtlasPathExtractorUtil {
ret.setAttribute(ATTRIBUTE_QUALIFIED_NAME, subDirQualifiedName);
ret.setAttribute(ATTRIBUTE_NAME, subDirName);
- if (LOG.isDebugEnabled()) {
- LOG.debug("adding entity: typeName={}, qualifiedName={}", ret.getTypeName(), ret.getAttribute(ATTRIBUTE_QUALIFIED_NAME));
- }
+ LOG.debug("adding entity: typeName={}, qualifiedName={}", ret.getTypeName(), ret.getAttribute(ATTRIBUTE_QUALIFIED_NAME));
context.putEntity(subDirQualifiedName, ret);
}
@@ -561,9 +519,7 @@ public class AtlasPathExtractorUtil {
}
}
- if (LOG.isDebugEnabled()) {
- LOG.debug("<== addGCSPathEntity(strPath={})", strPath);
- }
+ LOG.debug("<== addGCSPathEntity(strPath={})", strPath);
return ret;
}
@@ -575,9 +531,7 @@ public class AtlasPathExtractorUtil {
strPath = strPath.toLowerCase();
}
- if (LOG.isDebugEnabled()) {
- LOG.debug("==> addHDFSPathEntity(strPath={})", strPath);
- }
+ LOG.debug("==> addHDFSPathEntity(strPath={})", strPath);
String nameServiceID = HdfsNameServiceResolver.getNameServiceIDForPath(strPath);
String attrPath = StringUtils.isEmpty(nameServiceID) ? strPath : HdfsNameServiceResolver.getPathWithNameServiceID(strPath);
@@ -605,9 +559,7 @@ public class AtlasPathExtractorUtil {
context.putEntity(pathQualifiedName, ret);
}
- if (LOG.isDebugEnabled()) {
- LOG.debug("<== addHDFSPathEntity(strPath={})", strPath);
- }
+ LOG.debug("<== addHDFSPathEntity(strPath={})", strPath);
return ret;
}
@@ -625,32 +577,39 @@ public class AtlasPathExtractorUtil {
}
private static String getOzoneVolumeName(Path path) {
- String strPath = path.toString();
+ String strPath = path.toString();
String volumeName = StringUtils.EMPTY;
+
if (strPath.startsWith(OZONE_3_SCHEME)) {
String pathAuthority = path.toUri().getAuthority();
volumeName = pathAuthority.split("\\.")[1];
} else if (strPath.startsWith(OZONE_SCHEME)) {
strPath = strPath.replaceAll(OZONE_SCHEME, StringUtils.EMPTY);
+
if (strPath.split(Path.SEPARATOR).length >= 2) {
volumeName = strPath.split(Path.SEPARATOR)[1];
}
}
+
return volumeName;
}
private static String getOzoneBucketName(Path path) {
- String strPath = path.toString();
+ String strPath = path.toString();
String bucketName = StringUtils.EMPTY;
+
if (strPath.startsWith(OZONE_3_SCHEME)) {
String pathAuthority = path.toUri().getAuthority();
+
bucketName = pathAuthority.split("\\.")[0];
} else if (strPath.startsWith(OZONE_SCHEME)) {
strPath = strPath.replaceAll(OZONE_SCHEME, StringUtils.EMPTY);
+
if (strPath.split(Path.SEPARATOR).length >= 3) {
bucketName = strPath.split(Path.SEPARATOR)[2];
}
}
+
return bucketName;
}
diff --git a/common/src/main/java/org/apache/atlas/utils/AtlasPerfMetrics.java b/common/src/main/java/org/apache/atlas/utils/AtlasPerfMetrics.java
index a65dc8606..11a25b5cf 100644
--- a/common/src/main/java/org/apache/atlas/utils/AtlasPerfMetrics.java
+++ b/common/src/main/java/org/apache/atlas/utils/AtlasPerfMetrics.java
@@ -18,15 +18,13 @@
package org.apache.atlas.utils;
-
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
public class AtlasPerfMetrics {
- private final Map<String, Metric> metrics = new LinkedHashMap<>();
- private long startTimeMs = -1;
-
+ private final Map<String, Metric> metrics = new LinkedHashMap<>();
+ private long startTimeMs = -1;
public MetricRecorder getMetricRecorder(String name) {
return new MetricRecorder(name);
@@ -41,13 +39,7 @@ public class AtlasPerfMetrics {
startTimeMs = System.currentTimeMillis();
}
- Metric metric = metrics.get(name);
-
- if (metric == null) {
- metric = new Metric(name);
-
- metrics.put(name, metric);
- }
+ Metric metric = metrics.computeIfAbsent(name, Metric::new);
metric.invocations++;
metric.totalTimeMSecs += timeTaken;
@@ -91,23 +83,10 @@ public class AtlasPerfMetrics {
return sb.toString();
}
- public class MetricRecorder {
- private final String name;
- private final long startTimeMs = System.currentTimeMillis();
-
- MetricRecorder(String name) {
- this.name = name;
- }
-
- long getElapsedTime() {
- return System.currentTimeMillis() - startTimeMs;
- }
- }
-
public static class Metric {
private final String name;
- private short invocations = 0;
- private long totalTimeMSecs = 0;
+ private short invocations;
+ private long totalTimeMSecs;
public Metric(String name) {
this.name = name;
@@ -125,4 +104,17 @@ public class AtlasPerfMetrics {
return totalTimeMSecs;
}
}
+
+ public static class MetricRecorder {
+ private final String name;
+ private final long startTimeMs = System.currentTimeMillis();
+
+ MetricRecorder(String name) {
+ this.name = name;
+ }
+
+ long getElapsedTime() {
+ return System.currentTimeMillis() - startTimeMs;
+ }
+ }
}
diff --git a/common/src/main/java/org/apache/atlas/utils/AtlasPerfTracer.java b/common/src/main/java/org/apache/atlas/utils/AtlasPerfTracer.java
index a2baa65b0..1a4b92fda 100644
--- a/common/src/main/java/org/apache/atlas/utils/AtlasPerfTracer.java
+++ b/common/src/main/java/org/apache/atlas/utils/AtlasPerfTracer.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -20,16 +20,21 @@ package org.apache.atlas.utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
/**
* Handles logging of performance measurements.
*/
public final class AtlasPerfTracer {
- protected final Logger logger;
- protected final String tag;
- private final long startTimeMs;
+ private static final long reportingThresholdMs = 0L;
+
+ private final Logger logger;
+ private final String tag;
+ private final long startTimeMs;
- private static long reportingThresholdMs = 0L;
+ private AtlasPerfTracer(Logger logger, String tag) {
+ this.logger = logger;
+ this.tag = tag;
+ startTimeMs = System.currentTimeMillis();
+ }
public static Logger getPerfLogger(String name) {
return LoggerFactory.getLogger("org.apache.atlas.perf." + name);
@@ -53,12 +58,6 @@ public final class AtlasPerfTracer {
}
}
- private AtlasPerfTracer(Logger logger, String tag) {
- this.logger = logger;
- this.tag = tag;
- startTimeMs = System.currentTimeMillis();
- }
-
public String getTag() {
return tag;
}
@@ -73,6 +72,7 @@ public final class AtlasPerfTracer {
public void log() {
long elapsedTime = getElapsedTime();
+
if (elapsedTime > reportingThresholdMs) {
logger.debug("PERF|{}|{}", tag, elapsedTime);
}
diff --git a/common/src/main/java/org/apache/atlas/utils/HdfsNameServiceResolver.java b/common/src/main/java/org/apache/atlas/utils/HdfsNameServiceResolver.java
index 4b9d0bef2..fc4c622e8 100644
--- a/common/src/main/java/org/apache/atlas/utils/HdfsNameServiceResolver.java
+++ b/common/src/main/java/org/apache/atlas/utils/HdfsNameServiceResolver.java
@@ -28,11 +28,10 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
-
public class HdfsNameServiceResolver {
private static final Logger LOG = LoggerFactory.getLogger(HdfsNameServiceResolver.class);
- public static final String HDFS_SCHEME = "hdfs://";
+ public static final String HDFS_SCHEME = "hdfs://";
private static final int DEFAULT_PORT = 8020;
private static final String HDFS_NAMESERVICE_PROPERTY_KEY = "dfs.nameservices";
@@ -43,20 +42,18 @@ public class HdfsNameServiceResolver {
private static final Map<String, String> hostToNameServiceMap = new HashMap<>();
- static {
- init();
+ private HdfsNameServiceResolver() {
+ // to block instantiation
}
public static String getPathWithNameServiceID(String path) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("==> HdfsNameServiceResolver.getPathWithNameServiceID({})", path);
- }
+ LOG.debug("==> HdfsNameServiceResolver.getPathWithNameServiceID({})", path);
String ret = path;
// Only handle URLs that begin with hdfs://
if (path != null && path.indexOf(HDFS_SCHEME) == 0) {
- URI uri = new Path(path).toUri();
+ URI uri = new Path(path).toUri();
String nsId;
if (uri.getPort() != -1) {
@@ -70,18 +67,13 @@ public class HdfsNameServiceResolver {
}
}
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("<== HdfsNameServiceResolver.getPathWithNameServiceID({}) = {}", path, ret);
- }
+ LOG.debug("<== HdfsNameServiceResolver.getPathWithNameServiceID({}) = {}", path, ret);
return ret;
}
public static String getNameServiceIDForPath(String path) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("==> HdfsNameServiceResolver.getNameServiceIDForPath({})", path);
- }
+ LOG.debug("==> HdfsNameServiceResolver.getNameServiceIDForPath({})", path);
String ret = "";
@@ -110,64 +102,53 @@ public class HdfsNameServiceResolver {
}
}
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("<== HdfsNameServiceResolver.getNameServiceIDForPath({}) = {}", path, ret);
- }
+ LOG.debug("<== HdfsNameServiceResolver.getNameServiceIDForPath({}) = {}", path, ret);
return ret;
}
private static String getNameServiceID(String host, int port) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("==> HdfsNameServiceResolver.getNameServiceID({}, {})", host, port);
- }
+ LOG.debug("==> HdfsNameServiceResolver.getNameServiceID({}, {})", host, port);
String ret = hostToNameServiceMap.getOrDefault(host + ":" + port, "");
- if (LOG.isDebugEnabled()) {
- LOG.debug("<== HdfsNameServiceResolver.getNameServiceID({}, {}) = {}", host, port, ret);
- }
+ LOG.debug("<== HdfsNameServiceResolver.getNameServiceID({}, {}) = {}", host, port, ret);
return ret;
}
private static void init() {
- if (LOG.isDebugEnabled()) {
- LOG.debug("==> HdfsNameServiceResolver.init()");
- }
+ LOG.debug("==> HdfsNameServiceResolver.init()");
+
HdfsConfiguration hdfsConfiguration = new HdfsConfiguration(true);
// Determine all available nameServiceIDs
String[] nameServiceIDs = hdfsConfiguration.getTrimmedStrings(HDFS_INTERNAL_NAMESERVICE_PROPERTY_KEY);
+
if (Objects.isNull(nameServiceIDs) || nameServiceIDs.length == 0) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("NSID not found for {}, looking under {}", HDFS_INTERNAL_NAMESERVICE_PROPERTY_KEY, HDFS_NAMESERVICE_PROPERTY_KEY);
- }
+ LOG.debug("NSID not found for {}, looking under {}", HDFS_INTERNAL_NAMESERVICE_PROPERTY_KEY, HDFS_NAMESERVICE_PROPERTY_KEY);
+
// Attempt another lookup using internal name service IDs key
nameServiceIDs = hdfsConfiguration.getTrimmedStrings(HDFS_NAMESERVICE_PROPERTY_KEY);
}
if (Objects.nonNull(nameServiceIDs) && nameServiceIDs.length > 0) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("NSIDs = {}", nameServiceIDs);
- }
+ LOG.debug("NSIDs = {}", (Object) nameServiceIDs);
boolean isHA;
+
for (String nameServiceID : nameServiceIDs) {
// Find NameNode addresses and map to the NameServiceID
String[] nameNodes = hdfsConfiguration.getTrimmedStrings(HDFS_NAMENODES_HA_NODES_PREFIX + nameServiceID);
+
isHA = nameNodes != null && nameNodes.length > 0;
- String nameNodeMappingKey, nameNodeAddress;
if (isHA) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Processing HA node info");
- }
+ LOG.debug("Processing HA node info");
for (String nameNode : nameNodes) {
- nameNodeMappingKey = String.format(HDFS_NAMENODE_HA_ADDRESS_TEMPLATE, nameServiceID, nameNode);
- nameNodeAddress = hdfsConfiguration.get(nameNodeMappingKey, "");
+ String nameNodeMappingKey = String.format(HDFS_NAMENODE_HA_ADDRESS_TEMPLATE, nameServiceID, nameNode);
+ String nameNodeAddress = hdfsConfiguration.get(nameNodeMappingKey, "");
// Add a mapping only if found
if (StringUtils.isNotEmpty(nameNodeAddress)) {
@@ -175,8 +156,8 @@ public class HdfsNameServiceResolver {
}
}
} else {
- nameNodeMappingKey = String.format(HDFS_NAMENODE_ADDRESS_TEMPLATE, nameServiceID);
- nameNodeAddress = hdfsConfiguration.get(nameNodeMappingKey, "");
+ String nameNodeMappingKey = String.format(HDFS_NAMENODE_ADDRESS_TEMPLATE, nameServiceID);
+ String nameNodeAddress = hdfsConfiguration.get(nameNodeMappingKey, "");
// Add a mapping only if found
if (StringUtils.isNotEmpty(nameNodeAddress)) {
@@ -185,13 +166,13 @@ public class HdfsNameServiceResolver {
}
}
} else {
- if (LOG.isDebugEnabled()) {
- LOG.debug("No NSID could be resolved");
- }
+ LOG.debug("No NSID could be resolved");
}
- if (LOG.isDebugEnabled()) {
- LOG.debug("<== HdfsNameServiceResolver.init()");
- }
+ LOG.debug("<== HdfsNameServiceResolver.init()");
+ }
+
+ static {
+ init();
}
}
diff --git a/common/src/main/java/org/apache/atlas/utils/KafkaUtils.java b/common/src/main/java/org/apache/atlas/utils/KafkaUtils.java
index 672caa8e6..97f738e16 100644
--- a/common/src/main/java/org/apache/atlas/utils/KafkaUtils.java
+++ b/common/src/main/java/org/apache/atlas/utils/KafkaUtils.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -26,10 +26,10 @@ import org.apache.hadoop.security.UserGroupInformation;
import org.apache.kafka.clients.admin.AdminClient;
import org.apache.kafka.clients.admin.CreateTopicsResult;
import org.apache.kafka.clients.admin.DescribeTopicsResult;
+import org.apache.kafka.clients.admin.ListTopicsOptions;
import org.apache.kafka.clients.admin.ListTopicsResult;
import org.apache.kafka.clients.admin.NewTopic;
import org.apache.kafka.clients.admin.TopicDescription;
-import org.apache.kafka.clients.admin.ListTopicsOptions;
import org.apache.kafka.common.KafkaFuture;
import org.apache.kafka.common.TopicPartitionInfo;
import org.apache.kafka.common.errors.TopicExistsException;
@@ -44,12 +44,16 @@ import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
+
import static org.apache.atlas.security.SecurityProperties.HADOOP_SECURITY_CREDENTIAL_PROVIDER_PATH;
public class KafkaUtils implements AutoCloseable {
-
private static final Logger LOG = LoggerFactory.getLogger(KafkaUtils.class);
+ public static final String ATLAS_KAFKA_PROPERTY_PREFIX = "atlas.kafka";
+ public static final String KAFKA_SASL_JAAS_CONFIG_PROPERTY = "sasl.jaas.config";
+ public static final String JAAS_PASSWORD_SUFFIX = "password";
+
private static final String JAAS_CONFIG_PREFIX_PARAM = "atlas.jaas";
private static final String JAAS_CONFIG_LOGIN_MODULE_NAME_PARAM = "loginModuleName";
private static final String JAAS_CONFIG_LOGIN_MODULE_CONTROL_FLAG_PARAM = "loginModuleControlFlag";
@@ -60,21 +64,14 @@ public class KafkaUtils implements AutoCloseable {
private static final String JAAS_DEFAULT_CLIENT_NAME = "KafkaClient";
private static final String JAAS_TICKET_BASED_CLIENT_NAME = "ticketBased-KafkaClient";
private static final String IMPORT_INTERNAL_TOPICS = "atlas.kafka.bridge.enable.internal.topics.import";
+ private static final String JAAS_MASK_PASSWORD = "********";
- public static final String ATLAS_KAFKA_PROPERTY_PREFIX = "atlas.kafka";
- public static final String KAFKA_SASL_JAAS_CONFIG_PROPERTY = "sasl.jaas.config";
-
- public static final String JAAS_PASSWORD_SUFFIX = "password";
- private static final String JAAS_MASK_PASSWORD = "********";
-
- final protected Properties kafkaConfiguration;
- final protected AdminClient adminClient;
- final protected boolean importInternalTopics;
+ protected final Properties kafkaConfiguration;
+ protected final AdminClient adminClient;
+ protected final boolean importInternalTopics;
public KafkaUtils(Configuration atlasConfiguration) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("==> KafkaUtils() ");
- }
+ LOG.debug("==> KafkaUtils() ");
this.kafkaConfiguration = ApplicationProperties.getSubsetAsProperties(atlasConfiguration, ATLAS_KAFKA_PROPERTY_PREFIX);
@@ -83,124 +80,11 @@ public class KafkaUtils implements AutoCloseable {
adminClient = AdminClient.create(this.kafkaConfiguration);
importInternalTopics = atlasConfiguration.getBoolean(IMPORT_INTERNAL_TOPICS, false);
- if (LOG.isDebugEnabled()) {
- LOG.debug("<== KafkaUtils() ");
- }
- }
-
- public void createTopics(List<String> topicNames, int numPartitions, int replicationFactor)
- throws TopicExistsException, ExecutionException, InterruptedException {
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("==> createTopics() ");
- }
-
- List<NewTopic> newTopicList = topicNames.stream()
- .map(topicName -> new NewTopic(topicName, numPartitions, (short) replicationFactor))
- .collect(Collectors.toList());
-
- CreateTopicsResult createTopicsResult = adminClient.createTopics(newTopicList);
- Map<String, KafkaFuture<Void>> futureMap = createTopicsResult.values();
-
- for (Map.Entry<String, KafkaFuture<Void>> futureEntry : futureMap.entrySet()) {
- KafkaFuture<Void> future = futureEntry.getValue();
-
- future.get();
- }
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("<== createTopics() ");
- }
- }
-
- public List<String> listAllTopics() throws ExecutionException, InterruptedException {
- if (LOG.isDebugEnabled()) {
- LOG.debug("==> KafkaUtils.listAllTopics() ");
- }
-
- ListTopicsResult listTopicsResult = adminClient.listTopics((new ListTopicsOptions()).listInternal(importInternalTopics));
- List<String> ret = new ArrayList<>(listTopicsResult.names().get());
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("<== KafkaUtils.listAllTopics() ");
- }
-
- return ret;
- }
-
- public Integer getPartitionCount(String topicName) throws ExecutionException, InterruptedException {
- if (LOG.isDebugEnabled()) {
- LOG.debug("==> KafkaUtils.getPartitionCount({})", topicName);
- }
-
- Integer ret = null;
- List<TopicPartitionInfo> partitionList = getPartitionList(topicName);
-
- if (partitionList != null) {
- ret = partitionList.size();
- }
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("<== KafkaUtils.getPartitionCount returning for topic {} with count {}", topicName, ret);
- }
-
- return ret;
- }
-
- public Integer getReplicationFactor(String topicName) throws ExecutionException, InterruptedException {
- if (LOG.isDebugEnabled()) {
- LOG.debug("==> KafkaUtils.getReplicationFactor({})", topicName);
- }
-
- Integer ret = null;
- List<TopicPartitionInfo> partitionList = getPartitionList(topicName);
-
- if (partitionList != null) {
- ret = partitionList.stream().mapToInt(x -> x.replicas().size()).max().getAsInt();
- }
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("<== KafkaUtils.getReplicationFactor returning for topic {} with replicationFactor {}", topicName, ret);
- }
-
- return ret;
- }
-
- private List<TopicPartitionInfo> getPartitionList(String topicName) throws ExecutionException, InterruptedException {
- List<TopicPartitionInfo> ret = null;
- DescribeTopicsResult describeTopicsResult = adminClient.describeTopics(Collections.singleton(topicName));
-
- if (describeTopicsResult != null) {
- Map<String, KafkaFuture<TopicDescription>> futureMap = describeTopicsResult.values();
-
- for (Map.Entry<String, KafkaFuture<TopicDescription>> futureEntry : futureMap.entrySet()) {
- KafkaFuture<TopicDescription> topicDescriptionFuture = futureEntry.getValue();
- TopicDescription topicDescription = topicDescriptionFuture.get();
-
- ret = topicDescription.partitions();
- }
- }
-
- return ret;
- }
-
- public void close() {
- if (LOG.isDebugEnabled()) {
- LOG.debug("==> KafkaUtils.close()");
- }
- if (adminClient != null) {
- adminClient.close();
- }
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("<== KafkaUtils.close()");
- }
+ LOG.debug("<== KafkaUtils() ");
}
public static void setKafkaJAASProperties(Configuration configuration, Properties kafkaProperties) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("==> KafkaUtils.setKafkaJAASProperties()");
- }
+ LOG.debug("==> KafkaUtils.setKafkaJAASProperties()");
if (kafkaProperties.containsKey(KAFKA_SASL_JAAS_CONFIG_PROPERTY)) {
LOG.debug("JAAS config is already set, returning");
@@ -216,18 +100,14 @@ public class KafkaUtils implements AutoCloseable {
// Required for backward compatability for Hive CLI
if (!isLoginKeytabBased() && isLoginTicketBased()) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Checking if ticketBased-KafkaClient is set");
- }
+ LOG.debug("Checking if ticketBased-KafkaClient is set");
// if ticketBased-KafkaClient property is not specified then use the default client name
String ticketBasedConfigPrefix = JAAS_CONFIG_PREFIX_PARAM + "." + JAAS_TICKET_BASED_CLIENT_NAME;
Configuration ticketBasedConfig = configuration.subset(ticketBasedConfigPrefix);
if (ticketBasedConfig != null && !ticketBasedConfig.isEmpty()) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("ticketBased-KafkaClient JAAS configuration is set, using it");
- }
+ LOG.debug("ticketBased-KafkaClient JAAS configuration is set, using it");
jaasClientName = JAAS_TICKET_BASED_CLIENT_NAME;
} else {
@@ -257,11 +137,11 @@ public class KafkaUtils implements AutoCloseable {
LOG.warn("Unknown JAAS configuration value for ({}) = [{}], valid value are [{}] using the default value, REQUIRED", keyParam, controlFlag, validValues);
}
- String optionPrefix = keyPrefix + JAAS_CONFIG_LOGIN_OPTIONS_PREFIX + ".";
- String principalOptionKey = optionPrefix + JAAS_PRINCIPAL_PROP;
- String passwordOptionKey = optionPrefix + JAAS_PASSWORD_SUFFIX;
- int optionPrefixLen = optionPrefix.length();
- StringBuffer optionStringBuffer = new StringBuffer();
+ String optionPrefix = keyPrefix + JAAS_CONFIG_LOGIN_OPTIONS_PREFIX + ".";
+ String principalOptionKey = optionPrefix + JAAS_PRINCIPAL_PROP;
+ String passwordOptionKey = optionPrefix + JAAS_PASSWORD_SUFFIX;
+ int optionPrefixLen = optionPrefix.length();
+ StringBuilder optionStringBuffer = new StringBuilder();
for (String key : jaasConfig.stringPropertyNames()) {
if (key.startsWith(optionPrefix)) {
@@ -277,8 +157,10 @@ public class KafkaUtils implements AutoCloseable {
} catch (IOException e) {
LOG.warn("Failed to build serverPrincipal. Using provided value:[{}]", optionVal);
}
+
if (key.equalsIgnoreCase(passwordOptionKey)) {
String jaasKafkaClientConfigurationProperty = "atlas.jaas.KafkaClient.option.password";
+
if (JAAS_MASK_PASSWORD.equals(configuration.getString(jaasKafkaClientConfigurationProperty))) {
try {
optionVal = SecurityUtil.getPassword(configuration, jaasKafkaClientConfigurationProperty, HADOOP_SECURITY_CREDENTIAL_PROVIDER_PATH);
@@ -287,6 +169,7 @@ public class KafkaUtils implements AutoCloseable {
}
}
}
+
optionVal = surroundWithQuotes(optionVal);
optionStringBuffer.append(String.format(" %s=%s", key.substring(optionPrefixLen), optionVal));
@@ -294,35 +177,33 @@ public class KafkaUtils implements AutoCloseable {
}
}
- String newJaasProperty = String.format("%s %s %s ;", loginModuleName.trim(), controlFlag, optionStringBuffer.toString());
+ String newJaasProperty = String.format("%s %s %s ;", loginModuleName.trim(), controlFlag, optionStringBuffer);
kafkaProperties.put(KAFKA_SASL_JAAS_CONFIG_PROPERTY, newJaasProperty);
}
- if (LOG.isDebugEnabled()) {
- LOG.debug("<== KafkaUtils.setKafkaJAASProperties()");
- }
+ LOG.debug("<== KafkaUtils.setKafkaJAASProperties()");
}
- static boolean isLoginKeytabBased() {
+ public static boolean isLoginTicketBased() {
boolean ret = false;
try {
- ret = UserGroupInformation.isLoginKeytabBased();
+ ret = UserGroupInformation.isLoginTicketBased();
} catch (Exception excp) {
- LOG.warn("Error in determining keytab for KafkaClient-JAAS config", excp);
+ LOG.warn("Error in determining ticket-cache for KafkaClient-JAAS config", excp);
}
return ret;
}
- public static boolean isLoginTicketBased() {
+ static boolean isLoginKeytabBased() {
boolean ret = false;
try {
- ret = UserGroupInformation.isLoginTicketBased();
+ ret = UserGroupInformation.isLoginKeytabBased();
} catch (Exception excp) {
- LOG.warn("Error in determining ticket-cache for KafkaClient-JAAS config", excp);
+ LOG.warn("Error in determining keytab for KafkaClient-JAAS config", excp);
}
return ret;
@@ -338,4 +219,92 @@ public class KafkaUtils implements AutoCloseable {
String doubleQuoteEscaped = optionVal.replace("\"", "\\\"");
return String.format("\"%s\"", doubleQuoteEscaped);
}
-}
\ No newline at end of file
+
+ public void createTopics(List<String> topicNames, int numPartitions, int replicationFactor) throws TopicExistsException, ExecutionException, InterruptedException {
+ LOG.debug("==> createTopics() ");
+
+ List<NewTopic> newTopicList = topicNames.stream()
+ .map(topicName -> new NewTopic(topicName, numPartitions, (short) replicationFactor))
+ .collect(Collectors.toList());
+
+ CreateTopicsResult createTopicsResult = adminClient.createTopics(newTopicList);
+ Map<String, KafkaFuture<Void>> futureMap = createTopicsResult.values();
+
+ for (Map.Entry<String, KafkaFuture<Void>> futureEntry : futureMap.entrySet()) {
+ KafkaFuture<Void> future = futureEntry.getValue();
+
+ future.get();
+ }
+
+ LOG.debug("<== createTopics() ");
+ }
+
+ public List<String> listAllTopics() throws ExecutionException, InterruptedException {
+ LOG.debug("==> KafkaUtils.listAllTopics() ");
+
+ ListTopicsResult listTopicsResult = adminClient.listTopics((new ListTopicsOptions()).listInternal(importInternalTopics));
+ List<String> ret = new ArrayList<>(listTopicsResult.names().get());
+
+ LOG.debug("<== KafkaUtils.listAllTopics() ");
+
+ return ret;
+ }
+
+ public Integer getPartitionCount(String topicName) throws ExecutionException, InterruptedException {
+ LOG.debug("==> KafkaUtils.getPartitionCount({})", topicName);
+
+ Integer ret = null;
+ List<TopicPartitionInfo> partitionList = getPartitionList(topicName);
+
+ if (partitionList != null) {
+ ret = partitionList.size();
+ }
+
+ LOG.debug("<== KafkaUtils.getPartitionCount returning for topic {} with count {}", topicName, ret);
+
+ return ret;
+ }
+
+ public Integer getReplicationFactor(String topicName) throws ExecutionException, InterruptedException {
+ LOG.debug("==> KafkaUtils.getReplicationFactor({})", topicName);
+
+ Integer ret = null;
+ List<TopicPartitionInfo> partitionList = getPartitionList(topicName);
+
+ if (partitionList != null) {
+ ret = partitionList.stream().mapToInt(x -> x.replicas().size()).max().orElse(1);
+ }
+
+ LOG.debug("<== KafkaUtils.getReplicationFactor returning for topic {} with replicationFactor {}", topicName, ret);
+
+ return ret;
+ }
+
+ public void close() {
+ LOG.debug("==> KafkaUtils.close()");
+
+ if (adminClient != null) {
+ adminClient.close();
+ }
+
+ LOG.debug("<== KafkaUtils.close()");
+ }
+
+ private List<TopicPartitionInfo> getPartitionList(String topicName) throws ExecutionException, InterruptedException {
+ List<TopicPartitionInfo> ret = null;
+ DescribeTopicsResult describeTopicsResult = adminClient.describeTopics(Collections.singleton(topicName));
+
+ if (describeTopicsResult != null) {
+ Map<String, KafkaFuture<TopicDescription>> futureMap = describeTopicsResult.values();
+
+ for (Map.Entry<String, KafkaFuture<TopicDescription>> futureEntry : futureMap.entrySet()) {
+ KafkaFuture<TopicDescription> topicDescriptionFuture = futureEntry.getValue();
+ TopicDescription topicDescription = topicDescriptionFuture.get();
+
+ ret = topicDescription.partitions();
+ }
+ }
+
+ return ret;
+ }
+}
diff --git a/common/src/main/java/org/apache/atlas/utils/LruCache.java b/common/src/main/java/org/apache/atlas/utils/LruCache.java
index dcaffef6d..01185703f 100644
--- a/common/src/main/java/org/apache/atlas/utils/LruCache.java
+++ b/common/src/main/java/org/apache/atlas/utils/LruCache.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -17,39 +17,37 @@
*/
package org.apache.atlas.utils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.text.DateFormat;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
/**
* Fixed size LRU Cache.
*
*/
-public class LruCache<K, V> extends LinkedHashMap<K, V>{
+public class LruCache<K, V> extends LinkedHashMap<K, V> {
+ private static final Logger LOGGER = LoggerFactory.getLogger(LruCache.class.getName());
private static final long serialVersionUID = 8715233786643882558L;
- private static final Logger LOGGER = LoggerFactory.getLogger(LruCache.class.getName());
-
/**
* Specifies the number evictions that pass before a warning is logged.
*/
private final int evictionWarningThrottle;
+ // The maximum number of entries the cache holds.
+ private final int capacity;
+
// The number of evictions since the last warning was logged.
- private long evictionsSinceWarning = 0;
+ private long evictionsSinceWarning;
// When the last eviction warning was issued.
private Date lastEvictionWarning = new Date();
- // The maximum number of entries the cache holds.
- private final int capacity;
-
-
/**
*
* @param cacheSize The size of the cache.
@@ -57,16 +55,19 @@ public class LruCache<K, V> extends LinkedHashMap<K, V>{
*/
public LruCache(int cacheSize, int evictionWarningThrottle) {
super(cacheSize, 0.75f, true);
+
this.evictionWarningThrottle = evictionWarningThrottle;
- this.capacity = cacheSize;
+ this.capacity = cacheSize;
}
@Override
- protected boolean removeEldestEntry(Map.Entry<K,V> eldest) {
- if( size() > capacity) {
+ protected boolean removeEldestEntry(Map.Entry<K, V> eldest) {
+ if (size() > capacity) {
evictionWarningIfNeeded();
+
return true;
}
+
return false;
}
@@ -84,14 +85,13 @@ public class LruCache<K, V> extends LinkedHashMap<K, V>{
if (evictionsSinceWarning >= evictionWarningThrottle) {
DateFormat dateFormat = DateFormat.getDateTimeInstance();
+
if (LOGGER.isInfoEnabled()) {
- LOGGER.info("There have been " + evictionsSinceWarning
- + " evictions from the cache since "
- + dateFormat.format(lastEvictionWarning));
+ LOGGER.info("There have been {} evictions from the cache since {}", evictionsSinceWarning, dateFormat.format(lastEvictionWarning));
}
+
evictionsSinceWarning = 0;
- lastEvictionWarning = new Date();
+ lastEvictionWarning = new Date();
}
}
-
}
diff --git a/common/src/main/java/org/apache/atlas/utils/OnAtlasPropertyCondition.java b/common/src/main/java/org/apache/atlas/utils/OnAtlasPropertyCondition.java
index 7259036be..f70157c6a 100644
--- a/common/src/main/java/org/apache/atlas/utils/OnAtlasPropertyCondition.java
+++ b/common/src/main/java/org/apache/atlas/utils/OnAtlasPropertyCondition.java
@@ -30,26 +30,31 @@ import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.core.type.AnnotationMetadata;
public class OnAtlasPropertyCondition implements Condition {
- private final Logger LOG = LoggerFactory.getLogger(OnAtlasPropertyCondition.class);
+ private static final Logger LOG = LoggerFactory.getLogger(OnAtlasPropertyCondition.class);
@Override
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
- boolean matches = false;
- String propertyName = (String) metadata.getAnnotationAttributes(ConditionalOnAtlasProperty.class.getName()).get("property");
- boolean isDefault = (Boolean) metadata.getAnnotationAttributes(ConditionalOnAtlasProperty.class.getName()).get("isDefault");
- if (metadata instanceof AnnotatedTypeMetadata) {
+ boolean matches = false;
+ String propertyName = (String) metadata.getAnnotationAttributes(ConditionalOnAtlasProperty.class.getName()).get("property");
+ boolean isDefault = (Boolean) metadata.getAnnotationAttributes(ConditionalOnAtlasProperty.class.getName()).get("isDefault");
+
+ if (metadata instanceof AnnotationMetadata) {
String className = ((AnnotationMetadata) metadata).getClassName();
try {
- Configuration configuration = ApplicationProperties.get();
- String configuredProperty = configuration.getString(propertyName);
+ Configuration configuration = ApplicationProperties.get();
+ String configuredProperty = configuration.getString(propertyName);
+
if (StringUtils.isNotEmpty(configuredProperty)) {
matches = configuredProperty.equals(className);
- } else if (isDefault) matches = true;
+ } else if (isDefault) {
+ matches = true;
+ }
} catch (AtlasException e) {
LOG.error("Unable to load atlas properties. Dependent bean configuration may fail");
}
}
+
return matches;
}
}
diff --git a/common/src/main/java/org/apache/atlas/utils/ParamChecker.java b/common/src/main/java/org/apache/atlas/utils/ParamChecker.java
index c8d7464dc..e0a50dfb1 100644
--- a/common/src/main/java/org/apache/atlas/utils/ParamChecker.java
+++ b/common/src/main/java/org/apache/atlas/utils/ParamChecker.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -24,7 +24,6 @@ import java.util.Collection;
* Utilities for checking parameters.
*/
public final class ParamChecker {
-
private ParamChecker() {
}
@@ -39,6 +38,7 @@ public final class ParamChecker {
if (obj == null) {
throw new IllegalArgumentException(name + " cannot be null");
}
+
return obj;
}
@@ -50,9 +50,11 @@ public final class ParamChecker {
*/
public static <T> Collection<T> notNullElements(Collection<T> list, String name) {
notEmpty(list, name);
+
for (T ele : list) {
notNull(ele, String.format("Collection %s element %s", name, ele));
}
+
return list;
}
@@ -64,9 +66,11 @@ public final class ParamChecker {
*/
public static <T> T[] notNullElements(T[] array, String name) {
notEmpty(Arrays.asList(array), name);
+
for (T ele : array) {
notNull(ele, String.format("Collection %s element %s", name, ele));
}
+
return array;
}
@@ -77,9 +81,11 @@ public final class ParamChecker {
*/
public static <T> Collection<T> notEmpty(Collection<T> list, String name) {
notNull(list, name);
+
if (list.isEmpty()) {
throw new IllegalArgumentException(String.format("Collection %s is empty", name));
}
+
return list;
}
@@ -117,9 +123,10 @@ public final class ParamChecker {
return value;
}
- if (value.trim().length() == 0) {
+ if (value.trim().isEmpty()) {
throw new IllegalArgumentException(name + " cannot be empty" + (info == null ? "" : ", " + info));
}
+
return value.trim();
}
@@ -135,6 +142,7 @@ public final class ParamChecker {
if (value == null) {
throw new IllegalArgumentException(name + " cannot be null" + (info == null ? "" : ", " + info));
}
+
return notEmptyIfNotNull(value, name, info);
}
@@ -148,6 +156,7 @@ public final class ParamChecker {
if (value <= 0) {
throw new IllegalArgumentException(name + " should be > 0, current value " + value);
}
+
if (value > maxValue) {
throw new IllegalArgumentException(name + " should be <= " + maxValue + ", current value " + value);
}
diff --git a/common/src/main/java/org/apache/atlas/utils/PathExtractorContext.java b/common/src/main/java/org/apache/atlas/utils/PathExtractorContext.java
index ce688e4e4..b6bb3622d 100644
--- a/common/src/main/java/org/apache/atlas/utils/PathExtractorContext.java
+++ b/common/src/main/java/org/apache/atlas/utils/PathExtractorContext.java
@@ -30,15 +30,15 @@ public class PathExtractorContext {
private final String awsS3AtlasModelVersion;
public PathExtractorContext(String metadataNamespace) {
- this(metadataNamespace, new HashMap<>(), false, null) ;
+ this(metadataNamespace, new HashMap<>(), false, null);
}
public PathExtractorContext(String metadataNamespace, String awsS3AtlasModelVersion) {
- this(metadataNamespace, new HashMap<>(), false, awsS3AtlasModelVersion) ;
+ this(metadataNamespace, new HashMap<>(), false, awsS3AtlasModelVersion);
}
public PathExtractorContext(String metadataNamespace, boolean isConvertPathToLowerCase, String awsS3AtlasModelVersion) {
- this(metadataNamespace, new HashMap<>(), isConvertPathToLowerCase, awsS3AtlasModelVersion) ;
+ this(metadataNamespace, new HashMap<>(), isConvertPathToLowerCase, awsS3AtlasModelVersion);
}
public PathExtractorContext(String metadataNamespace, Map<String, AtlasEntity> knownEntities, boolean isConvertPathToLowerCase, String awsS3AtlasModelVersion) {
@@ -71,4 +71,4 @@ public class PathExtractorContext {
public String getAwsS3AtlasModelVersion() {
return awsS3AtlasModelVersion;
}
-}
\ No newline at end of file
+}
diff --git a/common/src/main/java/org/apache/atlas/utils/PropertiesUtil.java b/common/src/main/java/org/apache/atlas/utils/PropertiesUtil.java
index e7c4b9448..a3943e478 100644
--- a/common/src/main/java/org/apache/atlas/utils/PropertiesUtil.java
+++ b/common/src/main/java/org/apache/atlas/utils/PropertiesUtil.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -18,64 +18,41 @@
package org.apache.atlas.utils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
+
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
-import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
-
/**
* Util class for Properties.
*/
public final class PropertiesUtil extends PropertyPlaceholderConfigurer {
- private static Map<String, String> propertiesMap = new HashMap<>();
- private static Logger logger = LoggerFactory.getLogger(PropertiesUtil.class);
- protected List<String> xmlPropertyConfigurer = new ArrayList<>();
-
- private PropertiesUtil() {
+ private static final Logger logger = LoggerFactory.getLogger(PropertiesUtil.class);
- }
+ private static final Map<String, String> propertiesMap = new HashMap<>();
- @Override
- protected void processProperties(ConfigurableListableBeanFactory beanFactory, Properties props) {
+ private final List<String> xmlPropertyConfigurer = new ArrayList<>();
- Properties sysProps = System.getProperties();
- if (sysProps != null) {
- for (String key : sysProps.stringPropertyNames()) {
- String value = sysProps.getProperty(key);
- if (value != null) {
- value = value.trim();
- }
- propertiesMap.put(key, value);
- }
- }
-
- if (props != null) {
- for (String key : props.stringPropertyNames()) {
- String value = props.getProperty(key);
- if (value != null) {
- value = value.trim();
- }
- propertiesMap.put(key, value);
- }
- }
-
- super.processProperties(beanFactory, props);
+ private PropertiesUtil() {
}
public static String getProperty(String key, String defaultValue) {
if (key == null) {
return null;
}
+
String rtrnVal = propertiesMap.get(key);
+
if (rtrnVal == null) {
rtrnVal = defaultValue;
}
+
return rtrnVal;
}
@@ -83,6 +60,7 @@ public final class PropertiesUtil extends PropertyPlaceholderConfigurer {
if (key == null) {
return null;
}
+
return propertiesMap.get(key);
}
@@ -90,13 +68,17 @@ public final class PropertiesUtil extends PropertyPlaceholderConfigurer {
if (key == null) {
return null;
}
+
String value = propertiesMap.get(key);
+
if (value != null) {
- String[] splitValues = value.split(",");
+ String[] splitValues = value.split(",");
String[] returnValues = new String[splitValues.length];
+
for (int i = 0; i < splitValues.length; i++) {
returnValues[i] = splitValues[i].trim();
}
+
return returnValues;
} else {
return new String[0];
@@ -107,10 +89,13 @@ public final class PropertiesUtil extends PropertyPlaceholderConfigurer {
if (key == null) {
return null;
}
+
String rtrnVal = propertiesMap.get(key);
+
if (rtrnVal == null) {
return defaultValue;
}
+
return Integer.valueOf(rtrnVal);
}
@@ -118,10 +103,13 @@ public final class PropertiesUtil extends PropertyPlaceholderConfigurer {
if (key == null) {
return null;
}
+
String rtrnVal = propertiesMap.get(key);
+
if (rtrnVal == null) {
return null;
}
+
return Integer.valueOf(rtrnVal);
}
@@ -129,10 +117,44 @@ public final class PropertiesUtil extends PropertyPlaceholderConfigurer {
if (key == null) {
return defaultValue;
}
+
String value = getProperty(key);
+
if (value == null) {
return defaultValue;
}
+
return Boolean.parseBoolean(value);
}
+
+ @Override
+ protected void processProperties(ConfigurableListableBeanFactory beanFactory, Properties props) {
+ Properties sysProps = System.getProperties();
+
+ if (sysProps != null) {
+ for (String key : sysProps.stringPropertyNames()) {
+ String value = sysProps.getProperty(key);
+
+ if (value != null) {
+ value = value.trim();
+ }
+
+ propertiesMap.put(key, value);
+ }
+ }
+
+ if (props != null) {
+ for (String key : props.stringPropertyNames()) {
+ String value = props.getProperty(key);
+
+ if (value != null) {
+ value = value.trim();
+ }
+
+ propertiesMap.put(key, value);
+ }
+ }
+
+ super.processProperties(beanFactory, props);
+ }
}
diff --git a/common/src/main/java/org/apache/atlas/utils/SHA256Utils.java b/common/src/main/java/org/apache/atlas/utils/SHA256Utils.java
index 0b570685a..9944dec8d 100644
--- a/common/src/main/java/org/apache/atlas/utils/SHA256Utils.java
+++ b/common/src/main/java/org/apache/atlas/utils/SHA256Utils.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -18,24 +18,21 @@
package org.apache.atlas.utils;
-
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
-public class SHA256Utils{
-
+public class SHA256Utils {
+ private static final ThreadLocal<MessageDigest> DIGESTER_FACTORY = ThreadLocal.withInitial(() -> {
+ try {
+ return MessageDigest.getInstance("SHA-256");
+ } catch (NoSuchAlgorithmException e) {
+ throw new RuntimeException(e);
+ }
+ });
- private static final ThreadLocal<MessageDigest> DIGESTER_FACTORY =
- new ThreadLocal<MessageDigest>() {
- @Override
- protected MessageDigest initialValue() {
- try {
- return MessageDigest.getInstance("SHA-256");
- } catch (NoSuchAlgorithmException e) {
- throw new RuntimeException(e);
- }
- }
- };
+ private SHA256Utils() {
+ // to block instanations
+ }
/**
* Create a thread local SHA256 digester.
@@ -43,26 +40,29 @@ public class SHA256Utils{
public static MessageDigest getDigester() {
MessageDigest digester = DIGESTER_FACTORY.get();
+
digester.reset();
+
return digester;
}
public static String toString(byte[] hash) {
- try{
- StringBuffer hexString = new StringBuffer();
+ try {
+ StringBuilder hexString = new StringBuilder();
for (int i = 0; i < hash.length; i++) {
String hex = Integer.toHexString(0xff & hash[i]);
- if(hex.length() == 1) hexString.append('0');
+
+ if (hex.length() == 1) {
+ hexString.append('0');
+ }
+
hexString.append(hex);
}
return hexString.toString();
- } catch(Exception ex){
+ } catch (Exception ex) {
throw new RuntimeException(ex);
}
}
-
-
-
}
diff --git a/common/src/test/java/org/apache/atlas/ha/HAConfigurationTest.java b/common/src/test/java/org/apache/atlas/ha/HAConfigurationTest.java
index b1188f914..66bd2bb34 100644
--- a/common/src/test/java/org/apache/atlas/ha/HAConfigurationTest.java
+++ b/common/src/test/java/org/apache/atlas/ha/HAConfigurationTest.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -34,8 +34,7 @@ import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
public class HAConfigurationTest {
-
- private static final String[] TEST_ATLAS_SERVER_IDS_HA = new String[] { "id1", "id2" };
+ private static final String[] TEST_ATLAS_SERVER_IDS_HA = new String[] {"id1", "id2"};
@Mock
private Configuration configuration;
@@ -43,6 +42,7 @@ public class HAConfigurationTest {
@BeforeMethod
public void setup() {
MockitoAnnotations.initMocks(this);
+
System.setProperty(AtlasConstants.SYSTEM_PROPERTY_APP_PORT, AtlasConstants.DEFAULT_APP_PORT_STR);
}
@@ -68,14 +68,14 @@ public class HAConfigurationTest {
assertTrue(isHAEnabled);
// restore
- when(configuration.getStringArray(HAConfiguration.ATLAS_SERVER_IDS)).thenReturn(new String[] { "id1"});
+ when(configuration.getStringArray(HAConfiguration.ATLAS_SERVER_IDS)).thenReturn(new String[] {"id1"});
isHAEnabled = HAConfiguration.isHAEnabled(configuration);
assertFalse(isHAEnabled);
}
@Test
public void testShouldReturnHTTPSBoundAddress() {
- when(configuration.getString(HAConfiguration.ATLAS_SERVER_ADDRESS_PREFIX +"id1")).thenReturn("127.0.0.1:21443");
+ when(configuration.getString(HAConfiguration.ATLAS_SERVER_ADDRESS_PREFIX + "id1")).thenReturn("127.0.0.1:21443");
when(configuration.getBoolean(SecurityProperties.TLS_ENABLED)).thenReturn(true);
String address = HAConfiguration.getBoundAddressForId(configuration, "id1");
@@ -86,8 +86,8 @@ public class HAConfigurationTest {
@Test
public void testShouldReturnListOfAddressesInConfig() {
when(configuration.getStringArray(HAConfiguration.ATLAS_SERVER_IDS)).thenReturn(TEST_ATLAS_SERVER_IDS_HA);
- when(configuration.getString(HAConfiguration.ATLAS_SERVER_ADDRESS_PREFIX +"id1")).thenReturn("127.0.0.1:21000");
- when(configuration.getString(HAConfiguration.ATLAS_SERVER_ADDRESS_PREFIX +"id2")).thenReturn("127.0.0.1:31000");
+ when(configuration.getString(HAConfiguration.ATLAS_SERVER_ADDRESS_PREFIX + "id1")).thenReturn("127.0.0.1:21000");
+ when(configuration.getString(HAConfiguration.ATLAS_SERVER_ADDRESS_PREFIX + "id2")).thenReturn("127.0.0.1:31000");
List<String> serverInstances = HAConfiguration.getServerInstances(configuration);
assertEquals(serverInstances.size(), 2);
@@ -99,8 +99,7 @@ public class HAConfigurationTest {
public void testShouldGetZookeeperAcl() {
when(configuration.getString(HAConfiguration.HA_ZOOKEEPER_ACL)).thenReturn("sasl:myclient@EXAMPLE.COM");
- HAConfiguration.ZookeeperProperties zookeeperProperties =
- HAConfiguration.getZookeeperProperties(configuration);
+ HAConfiguration.ZookeeperProperties zookeeperProperties = HAConfiguration.getZookeeperProperties(configuration);
assertTrue(zookeeperProperties.hasAcl());
}
@@ -108,8 +107,7 @@ public class HAConfigurationTest {
public void testShouldGetZookeeperAuth() {
when(configuration.getString(HAConfiguration.HA_ZOOKEEPER_AUTH)).thenReturn("sasl:myclient@EXAMPLE.COM");
- HAConfiguration.ZookeeperProperties zookeeperProperties =
- HAConfiguration.getZookeeperProperties(configuration);
+ HAConfiguration.ZookeeperProperties zookeeperProperties = HAConfiguration.getZookeeperProperties(configuration);
assertTrue(zookeeperProperties.hasAuth());
}
}
diff --git a/common/src/test/java/org/apache/atlas/utils/AtlasPathExtractorUtilTest.java b/common/src/test/java/org/apache/atlas/utils/AtlasPathExtractorUtilTest.java
index c232a7ac8..6b95fd30c 100644
--- a/common/src/test/java/org/apache/atlas/utils/AtlasPathExtractorUtilTest.java
+++ b/common/src/test/java/org/apache/atlas/utils/AtlasPathExtractorUtilTest.java
@@ -20,115 +20,82 @@ package org.apache.atlas.utils;
import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo;
+import org.apache.hadoop.fs.Path;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
-import org.apache.hadoop.fs.Path;
import java.util.HashMap;
import java.util.Map;
-import static org.testng.Assert.*;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
public class AtlasPathExtractorUtilTest {
private static final Logger LOG = LoggerFactory.getLogger(AtlasPathExtractorUtilTest.class);
// Common
- private static final String METADATA_NAMESPACE = "metaspace";
- private static final String QNAME_METADATA_NAMESPACE = '@' + METADATA_NAMESPACE;
- private static final String SCHEME_SEPARATOR = "://";
- private static final String ATTRIBUTE_NAME = "name";
- private static final String ATTRIBUTE_QUALIFIED_NAME = "qualifiedName";
+ private static final String METADATA_NAMESPACE = "metaspace";
+ private static final String QNAME_METADATA_NAMESPACE = '@' + METADATA_NAMESPACE;
+ private static final String SCHEME_SEPARATOR = "://";
+ private static final String ATTRIBUTE_NAME = "name";
+ private static final String ATTRIBUTE_QUALIFIED_NAME = "qualifiedName";
// HDFS
- private static final String HDFS_PATH_TYPE = "hdfs_path";
- private static final String ATTRIBUTE_PATH = "path";
- private static final String ATTRIBUTE_CLUSTER_NAME = "clusterName";
+ private static final String HDFS_PATH_TYPE = "hdfs_path";
+ private static final String ATTRIBUTE_PATH = "path";
+ private static final String ATTRIBUTE_CLUSTER_NAME = "clusterName";
// Ozone
- private static final String OZONE_VOLUME = "ozone_volume";
- private static final String OZONE_BUCKET = "ozone_bucket";
- private static final String OZONE_KEY = "ozone_key";
- private static final String OZONE_SCHEME = "ofs" + SCHEME_SEPARATOR;
- private static final String OZONE_3_SCHEME = "o3fs" + SCHEME_SEPARATOR;
+ private static final String OZONE_VOLUME = "ozone_volume";
+ private static final String OZONE_BUCKET = "ozone_bucket";
+ private static final String OZONE_KEY = "ozone_key";
+ private static final String OZONE_SCHEME = "ofs" + SCHEME_SEPARATOR;
+ private static final String OZONE_3_SCHEME = "o3fs" + SCHEME_SEPARATOR;
// HDFS
- private static final String HDFS_SCHEME = "hdfs" + SCHEME_SEPARATOR;
- private static final String HDFS_PATH = HDFS_SCHEME + "host_name:8020/warehouse/tablespace/external/hive/taBlE_306";
+ private static final String HDFS_SCHEME = "hdfs" + SCHEME_SEPARATOR;
+ private static final String HDFS_PATH = HDFS_SCHEME + "host_name:8020/warehouse/tablespace/external/hive/taBlE_306";
// ADLS Gen2
- private static final String ADLS_GEN2_ACCOUNT = "adls_gen2_account";
- private static final String ADLS_GEN2_CONTAINER = "adls_gen2_container";
- private static final String ADLS_GEN2_DIRECTORY = "adls_gen2_directory";
- private static final String ABFS_SCHEME = "abfs" + SCHEME_SEPARATOR;
- private static final String ABFSS_SCHEME = "abfss" + SCHEME_SEPARATOR;
- private static final String ABFS_PATH = ABFS_SCHEME + "data@razrangersan.dfs.core.windows.net/tmp/cdp-demo/sample.csv";
- private static final String ABFSS_PATH = ABFSS_SCHEME + "data@razrangersan.dfs.core.windows.net/tmp/cdp-demo/sample.csv";
+ private static final String ADLS_GEN2_ACCOUNT = "adls_gen2_account";
+ private static final String ADLS_GEN2_CONTAINER = "adls_gen2_container";
+ private static final String ADLS_GEN2_DIRECTORY = "adls_gen2_directory";
+ private static final String ABFS_SCHEME = "abfs" + SCHEME_SEPARATOR;
+ private static final String ABFS_PATH = ABFS_SCHEME + "data@razrangersan.dfs.core.windows.net/tmp/cdp-demo/sample.csv";
+ private static final String ABFSS_SCHEME = "abfss" + SCHEME_SEPARATOR;
+ private static final String ABFSS_PATH = ABFSS_SCHEME + "data@razrangersan.dfs.core.windows.net/tmp/cdp-demo/sample.csv";
// AWS S3
- private static final String AWS_S3_ATLAS_MODEL_VERSION_V2 = "V2";
- private static final String AWS_S3_BUCKET = "aws_s3_bucket";
- private static final String AWS_S3_PSEUDO_DIR = "aws_s3_pseudo_dir";
- private static final String AWS_S3_V2_BUCKET = "aws_s3_v2_bucket";
- private static final String AWS_S3_V2_PSEUDO_DIR = "aws_s3_v2_directory";
- private static final String S3_SCHEME = "s3" + SCHEME_SEPARATOR;
- private static final String S3A_SCHEME = "s3a" + SCHEME_SEPARATOR;
- private static final String ATTRIBUTE_OBJECT_PREFIX = "objectPrefix";
- private static final String S3_PATH = S3_SCHEME + "aws_my_bucket1/1234567890/renders/Irradiance_A.csv";
- private static final String S3A_PATH = S3A_SCHEME + "aws_my_bucket1/1234567890/renders/Irradiance_A.csv";
-
+ private static final String AWS_S3_ATLAS_MODEL_VERSION_V2 = "V2";
+ private static final String AWS_S3_BUCKET = "aws_s3_bucket";
+ private static final String AWS_S3_PSEUDO_DIR = "aws_s3_pseudo_dir";
+ private static final String AWS_S3_V2_BUCKET = "aws_s3_v2_bucket";
+ private static final String AWS_S3_V2_PSEUDO_DIR = "aws_s3_v2_directory";
+ private static final String S3_SCHEME = "s3" + SCHEME_SEPARATOR;
+ private static final String S3_PATH = S3_SCHEME + "aws_my_bucket1/1234567890/renders/Irradiance_A.csv";
+ private static final String S3A_SCHEME = "s3a" + SCHEME_SEPARATOR;
+ private static final String S3A_PATH = S3A_SCHEME + "aws_my_bucket1/1234567890/renders/Irradiance_A.csv";
+ private static final String ATTRIBUTE_OBJECT_PREFIX = "objectPrefix";
// Google Cloud Storage
- private static final String GCS_VIRTUAL_DIR = "gcp_storage_virtual_directory";
- private static final String GCS_BUCKET = "gcp_storage_bucket";
- private static final String GCS_SCHEME = "gs" + SCHEME_SEPARATOR;
- private static final String GCS_PATH = GCS_SCHEME + "gcs_test_bucket1/1234567890/data";
-
- @DataProvider(name = "ozonePathProvider")
- private Object[][] ozonePathProvider(){
- return new Object[][]{
- { new OzoneKeyValidator(OZONE_SCHEME, "ozone1.com/volume1/bucket1/files/file.txt",
- "files", "ozone1.com/volume1/bucket1/files",
- "file.txt", "ozone1.com/volume1/bucket1/files/file.txt")},
-
- { new OzoneKeyValidator(OZONE_SCHEME, "ozone1:1234/volume1/bucket1/file21.txt",
- "file21.txt", "ozone1:1234/volume1/bucket1/file21.txt")},
-
- { new OzoneKeyValidator(OZONE_SCHEME, "ozone1/volume1/bucket1/quarter_one/sales",
- "quarter_one", "ozone1/volume1/bucket1/quarter_one",
- "sales", "ozone1/volume1/bucket1/quarter_one/sales")},
-
- { new OzoneKeyValidator(OZONE_SCHEME, "ozone1/volume1/bucket1/quarter_one/sales/",
- "quarter_one", "ozone1/volume1/bucket1/quarter_one",
- "sales", "ozone1/volume1/bucket1/quarter_one/sales")},
-
- { new OzoneKeyValidator(OZONE_3_SCHEME, "bucket1.volume1.ozone1/files/file.txt",
- "files", "bucket1.volume1.ozone1/files",
- "file.txt", "bucket1.volume1.ozone1/files/file.txt") },
-
- { new OzoneKeyValidator(OZONE_3_SCHEME, "bucket1.volume1.ozone1/file21.txt",
- "file21.txt", "bucket1.volume1.ozone1/file21.txt") },
-
- { new OzoneKeyValidator(OZONE_3_SCHEME, "bucket1.volume1.ozone1/quarter_one/sales",
- "quarter_one", "bucket1.volume1.ozone1/quarter_one",
- "sales", "bucket1.volume1.ozone1/quarter_one/sales") },
-
- { new OzoneKeyValidator(OZONE_3_SCHEME, "bucket1.volume1.ozone1/quarter_one/sales/",
- "quarter_one", "bucket1.volume1.ozone1/quarter_one",
- "sales", "bucket1.volume1.ozone1/quarter_one/sales") },
- };
- }
+ private static final String GCS_VIRTUAL_DIR = "gcp_storage_virtual_directory";
+ private static final String GCS_BUCKET = "gcp_storage_bucket";
+ private static final String GCS_SCHEME = "gs" + SCHEME_SEPARATOR;
+ private static final String GCS_PATH = GCS_SCHEME + "gcs_test_bucket1/1234567890/data";
@Test(dataProvider = "ozonePathProvider")
public void testGetPathEntityOzone3Path(OzoneKeyValidator validator) {
- String scheme = validator.scheme;
+ String scheme = validator.scheme;
String ozonePath = scheme + validator.location;
PathExtractorContext extractorContext = new PathExtractorContext(METADATA_NAMESPACE);
- Path path = new Path(ozonePath);
+ Path path = new Path(ozonePath);
AtlasEntityWithExtInfo entityWithExtInfo = AtlasPathExtractorUtil.getPathEntity(path, extractorContext);
- AtlasEntity entity = entityWithExtInfo.getEntity();
+ AtlasEntity entity = entityWithExtInfo.getEntity();
assertNotNull(entity);
verifyOzoneKeyEntity(entity, validator);
@@ -144,9 +111,9 @@ public class AtlasPathExtractorUtilTest {
public void testGetPathEntityHdfsPath() {
PathExtractorContext extractorContext = new PathExtractorContext(METADATA_NAMESPACE);
- Path path = new Path(HDFS_PATH);
+ Path path = new Path(HDFS_PATH);
AtlasEntityWithExtInfo entityWithExtInfo = AtlasPathExtractorUtil.getPathEntity(path, extractorContext);
- AtlasEntity entity = entityWithExtInfo.getEntity();
+ AtlasEntity entity = entityWithExtInfo.getEntity();
assertNotNull(entity);
assertEquals(entity.getTypeName(), HDFS_PATH_TYPE);
@@ -161,9 +128,9 @@ public class AtlasPathExtractorUtilTest {
public void testGetPathEntityHdfsPathLowerCase() {
PathExtractorContext extractorContext = new PathExtractorContext(METADATA_NAMESPACE, true, null);
- Path path = new Path(HDFS_PATH);
+ Path path = new Path(HDFS_PATH);
AtlasEntityWithExtInfo entityWithExtInfo = AtlasPathExtractorUtil.getPathEntity(path, extractorContext);
- AtlasEntity entity = entityWithExtInfo.getEntity();
+ AtlasEntity entity = entityWithExtInfo.getEntity();
assertNotNull(entity);
assertEquals(entity.getTypeName(), HDFS_PATH_TYPE);
@@ -178,9 +145,9 @@ public class AtlasPathExtractorUtilTest {
public void testGetPathEntityABFSPath() {
PathExtractorContext extractorContext = new PathExtractorContext(METADATA_NAMESPACE);
- Path path = new Path(ABFS_PATH);
+ Path path = new Path(ABFS_PATH);
AtlasEntityWithExtInfo entityWithExtInfo = AtlasPathExtractorUtil.getPathEntity(path, extractorContext);
- AtlasEntity entity = entityWithExtInfo.getEntity();
+ AtlasEntity entity = entityWithExtInfo.getEntity();
assertNotNull(entity);
assertEquals(entity.getTypeName(), ADLS_GEN2_DIRECTORY);
@@ -194,9 +161,9 @@ public class AtlasPathExtractorUtilTest {
public void testGetPathEntityABFSSPath() {
PathExtractorContext extractorContext = new PathExtractorContext(METADATA_NAMESPACE);
- Path path = new Path(ABFSS_PATH);
+ Path path = new Path(ABFSS_PATH);
AtlasEntityWithExtInfo entityWithExtInfo = AtlasPathExtractorUtil.getPathEntity(path, extractorContext);
- AtlasEntity entity = entityWithExtInfo.getEntity();
+ AtlasEntity entity = entityWithExtInfo.getEntity();
assertNotNull(entity);
assertEquals(entity.getTypeName(), ADLS_GEN2_DIRECTORY);
@@ -210,9 +177,9 @@ public class AtlasPathExtractorUtilTest {
public void testGetPathEntityS3V2Path() {
PathExtractorContext extractorContext = new PathExtractorContext(METADATA_NAMESPACE, AWS_S3_ATLAS_MODEL_VERSION_V2);
- Path path = new Path(S3_PATH);
+ Path path = new Path(S3_PATH);
AtlasEntityWithExtInfo entityWithExtInfo = AtlasPathExtractorUtil.getPathEntity(path, extractorContext);
- AtlasEntity entity = entityWithExtInfo.getEntity();
+ AtlasEntity entity = entityWithExtInfo.getEntity();
assertNotNull(entity);
assertEquals(entity.getTypeName(), AWS_S3_V2_PSEUDO_DIR);
@@ -226,9 +193,9 @@ public class AtlasPathExtractorUtilTest {
public void testGetPathEntityS3AV2Path() {
PathExtractorContext extractorContext = new PathExtractorContext(METADATA_NAMESPACE, AWS_S3_ATLAS_MODEL_VERSION_V2);
- Path path = new Path(S3A_PATH);
+ Path path = new Path(S3A_PATH);
AtlasEntityWithExtInfo entityWithExtInfo = AtlasPathExtractorUtil.getPathEntity(path, extractorContext);
- AtlasEntity entity = entityWithExtInfo.getEntity();
+ AtlasEntity entity = entityWithExtInfo.getEntity();
assertNotNull(entity);
assertEquals(entity.getTypeName(), AWS_S3_V2_PSEUDO_DIR);
@@ -242,9 +209,9 @@ public class AtlasPathExtractorUtilTest {
public void testGetPathEntityS3Path() {
PathExtractorContext extractorContext = new PathExtractorContext(METADATA_NAMESPACE);
- Path path = new Path(S3_PATH);
+ Path path = new Path(S3_PATH);
AtlasEntityWithExtInfo entityWithExtInfo = AtlasPathExtractorUtil.getPathEntity(path, extractorContext);
- AtlasEntity entity = entityWithExtInfo.getEntity();
+ AtlasEntity entity = entityWithExtInfo.getEntity();
assertNotNull(entity);
assertEquals(entity.getTypeName(), AWS_S3_PSEUDO_DIR);
@@ -258,9 +225,9 @@ public class AtlasPathExtractorUtilTest {
public void testGetPathEntityS3APath() {
PathExtractorContext extractorContext = new PathExtractorContext(METADATA_NAMESPACE);
- Path path = new Path(S3A_PATH);
+ Path path = new Path(S3A_PATH);
AtlasEntityWithExtInfo entityWithExtInfo = AtlasPathExtractorUtil.getPathEntity(path, extractorContext);
- AtlasEntity entity = entityWithExtInfo.getEntity();
+ AtlasEntity entity = entityWithExtInfo.getEntity();
assertNotNull(entity);
assertEquals(entity.getTypeName(), AWS_S3_PSEUDO_DIR);
@@ -274,9 +241,9 @@ public class AtlasPathExtractorUtilTest {
public void testGetPathEntityGCSPath() {
PathExtractorContext extractorContext = new PathExtractorContext(METADATA_NAMESPACE);
- Path path = new Path(GCS_PATH);
+ Path path = new Path(GCS_PATH);
AtlasEntityWithExtInfo entityWithExtInfo = AtlasPathExtractorUtil.getPathEntity(path, extractorContext);
- AtlasEntity entity = entityWithExtInfo.getEntity();
+ AtlasEntity entity = entityWithExtInfo.getEntity();
assertNotNull(entity);
assertEquals(entity.getTypeName(), GCS_VIRTUAL_DIR);
@@ -286,9 +253,44 @@ public class AtlasPathExtractorUtilTest {
verifyGCSKnownEntities(GCS_SCHEME, GCS_PATH, extractorContext.getKnownEntities());
}
+ @DataProvider(name = "ozonePathProvider")
+ private Object[][] ozonePathProvider() {
+ return new Object[][] {
+ {new OzoneKeyValidator(OZONE_SCHEME, "ozone1.com/volume1/bucket1/files/file.txt",
+ "files", "ozone1.com/volume1/bucket1/files",
+ "file.txt", "ozone1.com/volume1/bucket1/files/file.txt")},
+
+ {new OzoneKeyValidator(OZONE_SCHEME, "ozone1:1234/volume1/bucket1/file21.txt",
+ "file21.txt", "ozone1:1234/volume1/bucket1/file21.txt")},
+
+ {new OzoneKeyValidator(OZONE_SCHEME, "ozone1/volume1/bucket1/quarter_one/sales",
+ "quarter_one", "ozone1/volume1/bucket1/quarter_one",
+ "sales", "ozone1/volume1/bucket1/quarter_one/sales")},
+
+ {new OzoneKeyValidator(OZONE_SCHEME, "ozone1/volume1/bucket1/quarter_one/sales/",
+ "quarter_one", "ozone1/volume1/bucket1/quarter_one",
+ "sales", "ozone1/volume1/bucket1/quarter_one/sales")},
+
+ {new OzoneKeyValidator(OZONE_3_SCHEME, "bucket1.volume1.ozone1/files/file.txt",
+ "files", "bucket1.volume1.ozone1/files",
+ "file.txt", "bucket1.volume1.ozone1/files/file.txt")},
+
+ {new OzoneKeyValidator(OZONE_3_SCHEME, "bucket1.volume1.ozone1/file21.txt",
+ "file21.txt", "bucket1.volume1.ozone1/file21.txt")},
+
+ {new OzoneKeyValidator(OZONE_3_SCHEME, "bucket1.volume1.ozone1/quarter_one/sales",
+ "quarter_one", "bucket1.volume1.ozone1/quarter_one",
+ "sales", "bucket1.volume1.ozone1/quarter_one/sales")},
+
+ {new OzoneKeyValidator(OZONE_3_SCHEME, "bucket1.volume1.ozone1/quarter_one/sales/",
+ "quarter_one", "bucket1.volume1.ozone1/quarter_one",
+ "sales", "bucket1.volume1.ozone1/quarter_one/sales")},
+ };
+ }
+
private void verifyOzoneEntities(Map<String, AtlasEntity> knownEntities, OzoneKeyValidator validator) {
for (AtlasEntity knownEntity : knownEntities.values()) {
- switch (knownEntity.getTypeName()){
+ switch (knownEntity.getTypeName()) {
case OZONE_KEY:
verifyOzoneKeyEntity(knownEntity, validator);
break;
@@ -325,15 +327,15 @@ public class AtlasPathExtractorUtilTest {
}
}
- private void verifyABFSAdlsGen2Dir(String abfsScheme, String path, AtlasEntity entity){
- String pathQName = abfsScheme + "data@razrangersan/tmp/cdp-demo/sample.csv" + QNAME_METADATA_NAMESPACE;
+ private void verifyABFSAdlsGen2Dir(String abfsScheme, String path, AtlasEntity entity) {
+ String pathQName = abfsScheme + "data@razrangersan/tmp/cdp-demo/sample.csv" + QNAME_METADATA_NAMESPACE;
String entityQName = (String) entity.getAttribute(ATTRIBUTE_QUALIFIED_NAME);
- if (pathQName.equalsIgnoreCase(entityQName)){
+ if (pathQName.equalsIgnoreCase(entityQName)) {
assertEquals(entity.getAttribute(ATTRIBUTE_NAME), "sample.csv");
} else {
pathQName = abfsScheme + "data@razrangersan/tmp/cdp-demo" + QNAME_METADATA_NAMESPACE;
- if (pathQName.equalsIgnoreCase(entityQName)){
+ if (pathQName.equalsIgnoreCase(entityQName)) {
assertEquals(entity.getAttribute(ATTRIBUTE_NAME), "cdp-demo");
} else {
assertEquals(entity.getAttribute(ATTRIBUTE_QUALIFIED_NAME), abfsScheme + "data@razrangersan/tmp" + QNAME_METADATA_NAMESPACE);
@@ -346,7 +348,7 @@ public class AtlasPathExtractorUtilTest {
assertEquals(knownEntities.size(), 5);
int directoryCount = 0;
for (AtlasEntity knownEntity : knownEntities.values()) {
- switch (knownEntity.getTypeName()){
+ switch (knownEntity.getTypeName()) {
case ADLS_GEN2_DIRECTORY:
verifyABFSAdlsGen2Dir(scheme, path, knownEntity);
directoryCount++;
@@ -366,16 +368,16 @@ public class AtlasPathExtractorUtilTest {
assertEquals(directoryCount, 3);
}
- private void verifyS3V2PseudoDir(String s3Scheme, String path, AtlasEntity entity){
- String pathQName = path + "/" + QNAME_METADATA_NAMESPACE;
+ private void verifyS3V2PseudoDir(String s3Scheme, String path, AtlasEntity entity) {
+ String pathQName = path + "/" + QNAME_METADATA_NAMESPACE;
String entityQName = (String) entity.getAttribute(ATTRIBUTE_QUALIFIED_NAME);
- if (pathQName.equalsIgnoreCase(entityQName)){
+ if (pathQName.equalsIgnoreCase(entityQName)) {
assertEquals(entity.getAttribute(ATTRIBUTE_NAME), "Irradiance_A.csv");
assertEquals(entity.getAttribute(ATTRIBUTE_OBJECT_PREFIX), "/1234567890/renders/Irradiance_A.csv/");
} else {
pathQName = s3Scheme + "aws_my_bucket1/1234567890/" + QNAME_METADATA_NAMESPACE;
- if (pathQName.equalsIgnoreCase(entityQName)){
+ if (pathQName.equalsIgnoreCase(entityQName)) {
assertEquals(entity.getAttribute(ATTRIBUTE_NAME), "1234567890");
assertEquals(entity.getAttribute(ATTRIBUTE_OBJECT_PREFIX), "/1234567890/");
} else {
@@ -387,10 +389,10 @@ public class AtlasPathExtractorUtilTest {
}
private void verifyGCSVirtualDir(String s3Scheme, String path, AtlasEntity entity) {
- String pathQName = path + "/" + QNAME_METADATA_NAMESPACE;
+ String pathQName = path + "/" + QNAME_METADATA_NAMESPACE;
String entityQName = (String) entity.getAttribute(ATTRIBUTE_QUALIFIED_NAME);
- if (pathQName.equalsIgnoreCase(entityQName)){
+ if (pathQName.equalsIgnoreCase(entityQName)) {
assertEquals(entity.getAttribute(ATTRIBUTE_NAME), "data");
assertEquals(entity.getAttribute(ATTRIBUTE_OBJECT_PREFIX), "/1234567890/");
} else {
@@ -405,7 +407,7 @@ public class AtlasPathExtractorUtilTest {
assertEquals(knownEntities.size(), 4);
int dirCount = 0;
for (AtlasEntity knownEntity : knownEntities.values()) {
- switch (knownEntity.getTypeName()){
+ switch (knownEntity.getTypeName()) {
case AWS_S3_V2_PSEUDO_DIR:
verifyS3V2PseudoDir(scheme, path, knownEntity);
dirCount++;
@@ -419,7 +421,7 @@ public class AtlasPathExtractorUtilTest {
assertEquals(dirCount, 3);
}
- private void verifyS3PseudoDir(String path, AtlasEntity entity){
+ private void verifyS3PseudoDir(String path, AtlasEntity entity) {
assertEquals(entity.getAttribute(ATTRIBUTE_QUALIFIED_NAME), path.toLowerCase() + QNAME_METADATA_NAMESPACE);
assertEquals(entity.getAttribute(ATTRIBUTE_NAME), "/1234567890/renders/irradiance_a.csv");
assertEquals(entity.getAttribute(ATTRIBUTE_OBJECT_PREFIX), "/1234567890/renders/irradiance_a.csv");
@@ -429,7 +431,7 @@ public class AtlasPathExtractorUtilTest {
assertEquals(knownEntities.size(), 2);
int dirCount = 0;
for (AtlasEntity knownEntity : knownEntities.values()) {
- switch (knownEntity.getTypeName()){
+ switch (knownEntity.getTypeName()) {
case AWS_S3_PSEUDO_DIR:
verifyS3PseudoDir(path, knownEntity);
dirCount++;
@@ -452,7 +454,7 @@ public class AtlasPathExtractorUtilTest {
assertEquals(knownEntities.size(), 3);
int dirCount = 0;
for (AtlasEntity knownEntity : knownEntities.values()) {
- switch (knownEntity.getTypeName()){
+ switch (knownEntity.getTypeName()) {
case GCS_VIRTUAL_DIR:
verifyGCSVirtualDir(scheme, path, knownEntity);
dirCount++;
@@ -471,7 +473,7 @@ public class AtlasPathExtractorUtilTest {
assertEquals(entity.getAttribute(ATTRIBUTE_NAME), "gcs_test_bucket1");
}
- private class OzoneKeyValidator {
+ private static class OzoneKeyValidator {
private final String scheme;
private final String location;
private final int knownEntitiesCount;
@@ -484,25 +486,23 @@ public class AtlasPathExtractorUtilTest {
this.knownEntitiesCount = nameQNamePairs.size() + 2;
}
- public boolean validateNameQName(AtlasEntity entity){
+ public boolean validateNameQName(AtlasEntity entity) {
String name = (String) entity.getAttribute(ATTRIBUTE_NAME);
- if (this.nameQNamePairs.containsKey(name)){
+ if (this.nameQNamePairs.containsKey(name)) {
String qName = (String) entity.getAttribute(ATTRIBUTE_QUALIFIED_NAME);
- if (qName.equals(this.nameQNamePairs.get(name))) {
- return true;
- }
+ return qName.equals(this.nameQNamePairs.get(name));
}
return false;
}
- private Map<String, String> getPairMap(String scheme, String... pairs){
- Map< String, String > ret = new HashMap<>();
+ private Map<String, String> getPairMap(String scheme, String... pairs) {
+ Map<String, String> ret = new HashMap<>();
for (int i = 0; i < pairs.length; i += 2) {
- ret.put(pairs[i], scheme + pairs[i+1] + QNAME_METADATA_NAMESPACE);
+ ret.put(pairs[i], scheme + pairs[i + 1] + QNAME_METADATA_NAMESPACE);
}
return ret;
diff --git a/common/src/test/java/org/apache/atlas/utils/HdfsNameServiceResolverTest.java b/common/src/test/java/org/apache/atlas/utils/HdfsNameServiceResolverTest.java
index 30bc2e1a3..9dc369e83 100644
--- a/common/src/test/java/org/apache/atlas/utils/HdfsNameServiceResolverTest.java
+++ b/common/src/test/java/org/apache/atlas/utils/HdfsNameServiceResolverTest.java
@@ -22,7 +22,6 @@ import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;
public class HdfsNameServiceResolverTest {
-
@Test
public void testResolution() {
// assertEquals(HdfsNameServiceResolver.getNameServiceID("test"), "");
@@ -50,6 +49,5 @@ public class HdfsNameServiceResolverTest {
assertEquals(HdfsNameServiceResolver.getPathWithNameServiceID("hdfs://mycluster/tmp/xyz"), "hdfs://mycluster/tmp/xyz");
assertEquals(HdfsNameServiceResolver.getNameServiceIDForPath("hdfs://mycluster/tmp/xyz"), "mycluster");
-
}
-}
\ No newline at end of file
+}
diff --git a/common/src/test/java/org/apache/atlas/utils/KafkaUtilsTest.java b/common/src/test/java/org/apache/atlas/utils/KafkaUtilsTest.java
index 9b4f093e7..dc6dc4825 100644
--- a/common/src/test/java/org/apache/atlas/utils/KafkaUtilsTest.java
+++ b/common/src/test/java/org/apache/atlas/utils/KafkaUtilsTest.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -31,7 +31,6 @@ import org.mockito.MockedStatic;
import org.mockito.Mockito;
import org.testng.annotations.Test;
-import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.HashMap;
@@ -43,142 +42,139 @@ import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
public class KafkaUtilsTest {
+ protected static final String JAAS_MASKED_PASSWORD = "keypass";
- protected Path jksPath;
+ protected Path jksPath;
protected String providerUrl;
- protected static final String JAAS_MASKED_PASSWORD = "keypass";
-
@Test
public void testSetKafkaJAASPropertiesForAllProperValues() {
- Properties properties = new Properties();
+ Properties properties = new Properties();
Configuration configuration = new PropertiesConfiguration();
- final String loginModuleName = "com.sun.security.auth.module.Krb5LoginModule";
+ final String loginModuleName = "com.sun.security.auth.module.Krb5LoginModule";
final String loginModuleControlFlag = "required";
- final String optionUseKeyTab = "false";
- final String optionStoreKey = "true";
- final String optionServiceName = "kafka";
+ final String optionUseKeyTab = "false";
+ final String optionStoreKey = "true";
+ final String optionServiceName = "kafka";
- configuration.setProperty("atlas.jaas.KafkaClient.loginModuleName",loginModuleName);
+ configuration.setProperty("atlas.jaas.KafkaClient.loginModuleName", loginModuleName);
configuration.setProperty("atlas.jaas.KafkaClient.loginModuleControlFlag", loginModuleControlFlag);
configuration.setProperty("atlas.jaas.KafkaClient.option.useKeyTab", optionUseKeyTab);
configuration.setProperty("atlas.jaas.KafkaClient.option.storeKey", optionStoreKey);
- configuration.setProperty("atlas.jaas.KafkaClient.option.serviceName",optionServiceName);
+ configuration.setProperty("atlas.jaas.KafkaClient.option.serviceName", optionServiceName);
KafkaUtils.setKafkaJAASProperties(configuration, properties);
+
String newPropertyValue = properties.getProperty(KafkaUtils.KAFKA_SASL_JAAS_CONFIG_PROPERTY);
assertTrue(newPropertyValue.contains(loginModuleName), "loginModuleName not present in new property");
- assertTrue(newPropertyValue.contains(loginModuleControlFlag),"loginModuleControlFlag not present in new property");
+ assertTrue(newPropertyValue.contains(loginModuleControlFlag), "loginModuleControlFlag not present in new property");
assertTrue(newPropertyValue.contains("useKeyTab=\"" + optionUseKeyTab + "\""), "useKeyTab not present in new property or value doesn't match");
- assertTrue(newPropertyValue.contains("storeKey=\""+ optionStoreKey + "\""), "storeKey not present in new property or value doesn't match");
+ assertTrue(newPropertyValue.contains("storeKey=\"" + optionStoreKey + "\""), "storeKey not present in new property or value doesn't match");
assertTrue(newPropertyValue.contains("serviceName=\"" + optionServiceName + "\""), "serviceName not present in new property or value doesn't match");
assertJaaSConfigLoadable(newPropertyValue);
-
}
@Test
public void testSetKafkaJAASPropertiesForMissingControlFlag() {
- Properties properties = new Properties();
+ Properties properties = new Properties();
Configuration configuration = new PropertiesConfiguration();
- final String loginModuleName = "com.sun.security.auth.module.Krb5LoginModule";
+ final String loginModuleName = "com.sun.security.auth.module.Krb5LoginModule";
final String loginModuleControlFlag = "required";
- final String optionUseKeyTab = "false";
- final String optionStoreKey = "true";
- final String optionServiceName = "kafka";
+ final String optionUseKeyTab = "false";
+ final String optionStoreKey = "true";
+ final String optionServiceName = "kafka";
- configuration.setProperty("atlas.jaas.KafkaClient.loginModuleName",loginModuleName);
+ configuration.setProperty("atlas.jaas.KafkaClient.loginModuleName", loginModuleName);
configuration.setProperty("atlas.jaas.KafkaClient.option.useKeyTab", optionUseKeyTab);
configuration.setProperty("atlas.jaas.KafkaClient.option.storeKey", optionStoreKey);
- configuration.setProperty("atlas.jaas.KafkaClient.option.serviceName",optionServiceName);
+ configuration.setProperty("atlas.jaas.KafkaClient.option.serviceName", optionServiceName);
KafkaUtils.setKafkaJAASProperties(configuration, properties);
+
String newPropertyValue = properties.getProperty(KafkaUtils.KAFKA_SASL_JAAS_CONFIG_PROPERTY);
assertTrue(newPropertyValue.contains(loginModuleName), "loginModuleName not present in new property");
- assertTrue(newPropertyValue.contains(loginModuleControlFlag),"loginModuleControlFlag not present in new property");
+ assertTrue(newPropertyValue.contains(loginModuleControlFlag), "loginModuleControlFlag not present in new property");
assertTrue(newPropertyValue.contains("useKeyTab=\"" + optionUseKeyTab + "\""), "useKeyTab not present in new property or value doesn't match");
- assertTrue(newPropertyValue.contains("storeKey=\""+ optionStoreKey + "\""), "storeKey not present in new property or value doesn't match");
+ assertTrue(newPropertyValue.contains("storeKey=\"" + optionStoreKey + "\""), "storeKey not present in new property or value doesn't match");
assertTrue(newPropertyValue.contains("serviceName=\"" + optionServiceName + "\""), "serviceName not present in new property or value doesn't match");
assertJaaSConfigLoadable(newPropertyValue);
-
}
@Test
public void testSetKafkaJAASPropertiesForMissingLoginModuleName() {
- Properties properties = new Properties();
+ Properties properties = new Properties();
Configuration configuration = new PropertiesConfiguration();
final String loginModuleControlFlag = "required";
- final String optionUseKeyTab = "false";
- final String optionStoreKey = "true";
- final String optionServiceName = "kafka";
+ final String optionUseKeyTab = "false";
+ final String optionStoreKey = "true";
+ final String optionServiceName = "kafka";
configuration.setProperty("atlas.jaas.KafkaClient.loginModuleControlFlag", loginModuleControlFlag);
configuration.setProperty("atlas.jaas.KafkaClient.option.useKeyTab", optionUseKeyTab);
configuration.setProperty("atlas.jaas.KafkaClient.option.storeKey", optionStoreKey);
- configuration.setProperty("atlas.jaas.KafkaClient.option.serviceName",optionServiceName);
+ configuration.setProperty("atlas.jaas.KafkaClient.option.serviceName", optionServiceName);
KafkaUtils.setKafkaJAASProperties(configuration, properties);
+
String newPropertyValue = properties.getProperty(KafkaUtils.KAFKA_SASL_JAAS_CONFIG_PROPERTY);
assertNull(newPropertyValue);
-
}
@Test
public void testSetKafkaJAASPropertiesWithSpecialCharacters() {
- Properties properties = new Properties();
+ Properties properties = new Properties();
Configuration configuration = new PropertiesConfiguration();
- final String loginModuleName = "com.sun.security.auth.module.Krb5LoginModule";
+ final String loginModuleName = "com.sun.security.auth.module.Krb5LoginModule";
final String loginModuleControlFlag = "required";
- final String optionKeyTabPath = "/path/to/file.keytab";
- final String optionPrincipal = "test/_HOST@EXAMPLE.COM";
+ final String optionKeyTabPath = "/path/to/file.keytab";
+ final String optionPrincipal = "test/_HOST@EXAMPLE.COM";
- configuration.setProperty("atlas.jaas.KafkaClient.loginModuleName",loginModuleName);
+ configuration.setProperty("atlas.jaas.KafkaClient.loginModuleName", loginModuleName);
configuration.setProperty("atlas.jaas.KafkaClient.loginModuleControlFlag", loginModuleControlFlag);
configuration.setProperty("atlas.jaas.KafkaClient.option.keyTabPath", optionKeyTabPath);
configuration.setProperty("atlas.jaas.KafkaClient.option.principal", optionPrincipal);
try {
KafkaUtils.setKafkaJAASProperties(configuration, properties);
- String newPropertyValue = properties.getProperty(KafkaUtils.KAFKA_SASL_JAAS_CONFIG_PROPERTY);
+ String newPropertyValue = properties.getProperty(KafkaUtils.KAFKA_SASL_JAAS_CONFIG_PROPERTY);
String updatedPrincipalValue = org.apache.hadoop.security.SecurityUtil.getServerPrincipal(optionPrincipal, (String) null);
assertTrue(newPropertyValue.contains(loginModuleName), "loginModuleName not present in new property");
- assertTrue(newPropertyValue.contains(loginModuleControlFlag),"loginModuleControlFlag not present in new property");
+ assertTrue(newPropertyValue.contains(loginModuleControlFlag), "loginModuleControlFlag not present in new property");
assertTrue(newPropertyValue.contains("keyTabPath=\"" + optionKeyTabPath + "\""));
- assertTrue(newPropertyValue.contains("principal=\""+ updatedPrincipalValue + "\""));
+ assertTrue(newPropertyValue.contains("principal=\"" + updatedPrincipalValue + "\""));
assertJaaSConfigLoadable(newPropertyValue);
-
} catch (IOException e) {
fail("Failed while getting updated principal value with exception : " + e.getMessage());
}
-
}
@Test
public void testSetKafkaJAASPropertiesForTicketBasedLoginConfig() {
- Properties properties = new Properties();
+ Properties properties = new Properties();
Configuration configuration = new PropertiesConfiguration();
- final String loginModuleName = "com.sun.security.auth.module.Krb5LoginModule";
+ final String loginModuleName = "com.sun.security.auth.module.Krb5LoginModule";
final String loginModuleControlFlag = "required";
- final String optionUseKeyTab = "false";
- final String optionStoreKey = "true";
- final String optionServiceName = "kafka";
+ final String optionUseKeyTab = "false";
+ final String optionStoreKey = "true";
+ final String optionServiceName = "kafka";
configuration.setProperty("atlas.kafka.bootstrap.servers", "localhost:9100");
- configuration.setProperty("atlas.jaas.ticketBased-KafkaClient.loginModuleName",loginModuleName);
+ configuration.setProperty("atlas.jaas.ticketBased-KafkaClient.loginModuleName", loginModuleName);
configuration.setProperty("atlas.jaas.ticketBased-KafkaClient.loginModuleControlFlag", loginModuleControlFlag);
configuration.setProperty("atlas.jaas.ticketBased-KafkaClient.option.useKeyTab", optionUseKeyTab);
configuration.setProperty("atlas.jaas.ticketBased-KafkaClient.option.storeKey", optionStoreKey);
- configuration.setProperty("atlas.jaas.ticketBased-KafkaClient.option.serviceName",optionServiceName);
+ configuration.setProperty("atlas.jaas.ticketBased-KafkaClient.option.serviceName", optionServiceName);
- try (MockedStatic mockedKafkaUtilsClass = Mockito.mockStatic(KafkaUtils.class)) {
+ try (MockedStatic<KafkaUtils> mockedKafkaUtilsClass = Mockito.mockStatic(KafkaUtils.class)) {
mockedKafkaUtilsClass.when(KafkaUtils::isLoginKeytabBased).thenReturn(false);
mockedKafkaUtilsClass.when(KafkaUtils::isLoginTicketBased).thenReturn(true);
mockedKafkaUtilsClass.when(() -> KafkaUtils.surroundWithQuotes(Mockito.anyString())).thenCallRealMethod();
@@ -187,6 +183,7 @@ public class KafkaUtilsTest {
KafkaUtils.setKafkaJAASProperties(configuration, properties);
String newPropertyValue = properties.getProperty(KafkaUtils.KAFKA_SASL_JAAS_CONFIG_PROPERTY);
+
assertTrue(newPropertyValue.contains(loginModuleName), "loginModuleName not present in new property");
assertTrue(newPropertyValue.contains(loginModuleControlFlag), "loginModuleControlFlag not present in new property");
assertTrue(newPropertyValue.contains("useKeyTab=\"" + optionUseKeyTab + "\""), "useKeyTab not present in new property or value doesn't match");
@@ -198,22 +195,22 @@ public class KafkaUtilsTest {
@Test
public void testSetKafkaJAASPropertiesForTicketBasedLoginFallback() {
- Properties properties = new Properties();
+ Properties properties = new Properties();
Configuration configuration = new PropertiesConfiguration();
- final String loginModuleName = "com.sun.security.auth.module.Krb5LoginModule";
+ final String loginModuleName = "com.sun.security.auth.module.Krb5LoginModule";
final String loginModuleControlFlag = "required";
- final String optionUseKeyTab = "false";
- final String optionStoreKey = "true";
- final String optionServiceName = "kafka";
+ final String optionUseKeyTab = "false";
+ final String optionStoreKey = "true";
+ final String optionServiceName = "kafka";
- configuration.setProperty("atlas.jaas.KafkaClient.loginModuleName",loginModuleName);
+ configuration.setProperty("atlas.jaas.KafkaClient.loginModuleName", loginModuleName);
configuration.setProperty("atlas.jaas.KafkaClient.loginModuleControlFlag", loginModuleControlFlag);
configuration.setProperty("atlas.jaas.KafkaClient.option.useKeyTab", optionUseKeyTab);
configuration.setProperty("atlas.jaas.KafkaClient.option.storeKey", optionStoreKey);
- configuration.setProperty("atlas.jaas.KafkaClient.option.serviceName",optionServiceName);
+ configuration.setProperty("atlas.jaas.KafkaClient.option.serviceName", optionServiceName);
- try (MockedStatic mockedKafkaUtilsClass = Mockito.mockStatic(KafkaUtils.class)) {
+ try (MockedStatic<KafkaUtils> mockedKafkaUtilsClass = Mockito.mockStatic(KafkaUtils.class)) {
mockedKafkaUtilsClass.when(KafkaUtils::isLoginKeytabBased).thenReturn(false);
mockedKafkaUtilsClass.when(KafkaUtils::isLoginTicketBased).thenReturn(true);
mockedKafkaUtilsClass.when(() -> KafkaUtils.surroundWithQuotes(Mockito.anyString())).thenCallRealMethod();
@@ -222,6 +219,7 @@ public class KafkaUtilsTest {
KafkaUtils.setKafkaJAASProperties(configuration, properties);
String newPropertyValue = properties.getProperty(KafkaUtils.KAFKA_SASL_JAAS_CONFIG_PROPERTY);
+
assertTrue(newPropertyValue.contains(loginModuleName), "loginModuleName not present in new property");
assertTrue(newPropertyValue.contains(loginModuleControlFlag), "loginModuleControlFlag not present in new property");
assertTrue(newPropertyValue.contains("useKeyTab=\"" + optionUseKeyTab + "\""), "useKeyTab not present in new property or value doesn't match");
@@ -233,20 +231,20 @@ public class KafkaUtilsTest {
@Test
public void testSetKafkaJAASPropertiesForTokenAuthConfig() {
- Properties properties = new Properties();
+ Properties properties = new Properties();
Configuration configuration = new PropertiesConfiguration();
- final String loginModuleName = "org.apache.kafka.common.security.scram.ScramLoginModule";
+ final String loginModuleName = "org.apache.kafka.common.security.scram.ScramLoginModule";
final String loginModuleControlFlag = "required";
- final String optionUseKeyTab = "false";
- final String optionStoreKey = "false";
- final String optionServiceName = "kafka";
- final String optionTokenAuth = "true";
- final String optionUsername = "30CQ4q1hQMy0dB6X0eXfxQ";
- final String optionPassword = "KdaUQ4FlKWlDxwQrAeFGUVbb6sR0P+zoqOZDZjtIRP1wseXbSbhiTjz3QI9Ur9o4LTYZSv8TE1QqUC4FSwnoTA==";
+ final String optionUseKeyTab = "false";
+ final String optionStoreKey = "false";
+ final String optionServiceName = "kafka";
+ final String optionTokenAuth = "true";
+ final String optionUsername = "30CQ4q1hQMy0dB6X0eXfxQ";
+ final String optionPassword = "KdaUQ4FlKWlDxwQrAeFGUVbb6sR0P+zoqOZDZjtIRP1wseXbSbhiTjz3QI9Ur9o4LTYZSv8TE1QqUC4FSwnoTA==";
configuration.setProperty("atlas.kafka.bootstrap.servers", "localhost:9100");
- configuration.setProperty("atlas.jaas.KafkaClient.loginModuleName",loginModuleName);
+ configuration.setProperty("atlas.jaas.KafkaClient.loginModuleName", loginModuleName);
configuration.setProperty("atlas.jaas.KafkaClient.loginModuleControlFlag", loginModuleControlFlag);
configuration.setProperty("atlas.jaas.KafkaClient.option.useKeyTab", optionUseKeyTab);
configuration.setProperty("atlas.jaas.KafkaClient.option.storeKey", optionStoreKey);
@@ -255,13 +253,14 @@ public class KafkaUtilsTest {
configuration.setProperty("atlas.jaas.KafkaClient.option.username", optionUsername);
configuration.setProperty("atlas.jaas.KafkaClient.option.password", optionPassword);
- try (MockedStatic mockedKafkaUtilsClass = Mockito.mockStatic(KafkaUtils.class)) {
+ try (MockedStatic<KafkaUtils> mockedKafkaUtilsClass = Mockito.mockStatic(KafkaUtils.class)) {
mockedKafkaUtilsClass.when(() -> KafkaUtils.surroundWithQuotes(Mockito.anyString())).thenCallRealMethod();
mockedKafkaUtilsClass.when(() -> KafkaUtils.setKafkaJAASProperties(configuration, properties)).thenCallRealMethod();
KafkaUtils.setKafkaJAASProperties(configuration, properties);
String newPropertyValue = properties.getProperty(KafkaUtils.KAFKA_SASL_JAAS_CONFIG_PROPERTY);
+
assertTrue(newPropertyValue.contains(loginModuleName), "loginModuleName not present in new property");
assertTrue(newPropertyValue.contains(loginModuleControlFlag), "loginModuleControlFlag not present in new property");
assertTrue(newPropertyValue.contains("useKeyTab=\"" + optionUseKeyTab + "\""), "useKeyTab not present in new property or value doesn't match");
@@ -276,20 +275,22 @@ public class KafkaUtilsTest {
@Test
public void testSetKafkaJAASPropertiesForClearTextPassword() throws Exception {
- Properties properties = new Properties();
+ Properties properties = new Properties();
Configuration configuration = new PropertiesConfiguration();
+
setupCredentials();
- final String loginModuleName = "org.apache.kafka.common.security.scram.ScramLoginModule";
+
+ final String loginModuleName = "org.apache.kafka.common.security.scram.ScramLoginModule";
final String loginModuleControlFlag = "required";
- final String optionUseKeyTab = "false";
- final String optionStoreKey = "false";
- final String optionServiceName = "kafka";
- final String optionTokenAuth = "true";
- final String optionUsername = "30CQ4q1hQMy0dB6X0eXfxQ";
- final String optionPassword = "admin123";
+ final String optionUseKeyTab = "false";
+ final String optionStoreKey = "false";
+ final String optionServiceName = "kafka";
+ final String optionTokenAuth = "true";
+ final String optionUsername = "30CQ4q1hQMy0dB6X0eXfxQ";
+ final String optionPassword = "admin123";
configuration.setProperty("atlas.kafka.bootstrap.servers", "localhost:9100");
- configuration.setProperty("atlas.jaas.KafkaClient.loginModuleName",loginModuleName);
+ configuration.setProperty("atlas.jaas.KafkaClient.loginModuleName", loginModuleName);
configuration.setProperty("atlas.jaas.KafkaClient.loginModuleControlFlag", loginModuleControlFlag);
configuration.setProperty("atlas.jaas.KafkaClient.option.useKeyTab", optionUseKeyTab);
configuration.setProperty("atlas.jaas.KafkaClient.option.storeKey", optionStoreKey);
@@ -299,13 +300,14 @@ public class KafkaUtilsTest {
configuration.setProperty("atlas.jaas.KafkaClient.option.password", optionPassword);
configuration.setProperty("hadoop.security.credential.provider.path", providerUrl);
- try (MockedStatic mockedKafkaUtilsClass = Mockito.mockStatic(KafkaUtils.class)) {
+ try (MockedStatic<KafkaUtils> mockedKafkaUtilsClass = Mockito.mockStatic(KafkaUtils.class)) {
mockedKafkaUtilsClass.when(() -> KafkaUtils.surroundWithQuotes(Mockito.anyString())).thenCallRealMethod();
mockedKafkaUtilsClass.when(() -> KafkaUtils.setKafkaJAASProperties(configuration, properties)).thenCallRealMethod();
KafkaUtils.setKafkaJAASProperties(configuration, properties);
String newPropertyValue = properties.getProperty(KafkaUtils.KAFKA_SASL_JAAS_CONFIG_PROPERTY);
+
assertTrue(newPropertyValue.contains(loginModuleName), "loginModuleName not present in new property");
assertTrue(newPropertyValue.contains(loginModuleControlFlag), "loginModuleControlFlag not present in new property");
assertTrue(newPropertyValue.contains("useKeyTab=\"" + optionUseKeyTab + "\""), "useKeyTab not present in new property or value doesn't match");
@@ -320,20 +322,22 @@ public class KafkaUtilsTest {
@Test
public void testSetKafkaJAASPropertiesForPasswordEncryption() throws Exception {
- Properties properties = new Properties();
+ Properties properties = new Properties();
Configuration configuration = new PropertiesConfiguration();
+
setupCredentials();
- final String loginModuleName = "org.apache.kafka.common.security.scram.ScramLoginModule";
+
+ final String loginModuleName = "org.apache.kafka.common.security.scram.ScramLoginModule";
final String loginModuleControlFlag = "required";
- final String optionUseKeyTab = "false";
- final String optionStoreKey = "false";
- final String optionServiceName = "kafka";
- final String optionTokenAuth = "true";
- final String optionUsername = "30CQ4q1hQMy0dB6X0eXfxQ";
- final String optionPassword = "********";
+ final String optionUseKeyTab = "false";
+ final String optionStoreKey = "false";
+ final String optionServiceName = "kafka";
+ final String optionTokenAuth = "true";
+ final String optionUsername = "30CQ4q1hQMy0dB6X0eXfxQ";
+ final String optionPassword = "********";
configuration.setProperty("atlas.kafka.bootstrap.servers", "localhost:9100");
- configuration.setProperty("atlas.jaas.KafkaClient.loginModuleName",loginModuleName);
+ configuration.setProperty("atlas.jaas.KafkaClient.loginModuleName", loginModuleName);
configuration.setProperty("atlas.jaas.KafkaClient.loginModuleControlFlag", loginModuleControlFlag);
configuration.setProperty("atlas.jaas.KafkaClient.option.useKeyTab", optionUseKeyTab);
configuration.setProperty("atlas.jaas.KafkaClient.option.storeKey", optionStoreKey);
@@ -343,13 +347,14 @@ public class KafkaUtilsTest {
configuration.setProperty("atlas.jaas.KafkaClient.option.password", optionPassword);
configuration.setProperty("hadoop.security.credential.provider.path", providerUrl);
- try (MockedStatic mockedKafkaUtilsClass = Mockito.mockStatic(KafkaUtils.class)) {
+ try (MockedStatic<KafkaUtils> mockedKafkaUtilsClass = Mockito.mockStatic(KafkaUtils.class)) {
mockedKafkaUtilsClass.when(() -> KafkaUtils.surroundWithQuotes(Mockito.anyString())).thenCallRealMethod();
mockedKafkaUtilsClass.when(() -> KafkaUtils.setKafkaJAASProperties(configuration, properties)).thenCallRealMethod();
KafkaUtils.setKafkaJAASProperties(configuration, properties);
String newPropertyValue = properties.getProperty(KafkaUtils.KAFKA_SASL_JAAS_CONFIG_PROPERTY);
+
assertTrue(newPropertyValue.contains(loginModuleName), "loginModuleName not present in new property");
assertTrue(newPropertyValue.contains(loginModuleControlFlag), "loginModuleControlFlag not present in new property");
assertTrue(newPropertyValue.contains("useKeyTab=\"" + optionUseKeyTab + "\""), "useKeyTab not present in new property or value doesn't match");
@@ -362,20 +367,10 @@ public class KafkaUtilsTest {
}
}
- private void assertJaaSConfigLoadable(String jaasConfig) {
- // Ensure that JaaS config can be loaded
- Map<String, Password> jaasConfigs = new HashMap<>();
- jaasConfigs.put(SaslConfigs.SASL_JAAS_CONFIG, new Password(jaasConfig));
- try {
- JaasContext.loadClientContext(jaasConfigs);
- } catch (IllegalArgumentException e) {
- fail(String.format("JaaS config '%s' can not be loaded", jaasConfig), e);
- }
- }
-
protected void setupCredentials() throws Exception {
- jksPath = new Path(Files.createTempDirectory("tempproviders").toString(), "kafka.jceks");
+ jksPath = new Path(Files.createTempDirectory("tempproviders").toString(), "kafka.jceks");
providerUrl = JavaKeyStoreProvider.SCHEME_NAME + "://file/" + jksPath.toUri();
+
org.apache.hadoop.conf.Configuration conf = new org.apache.hadoop.conf.Configuration(false);
conf.set(CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH, providerUrl);
@@ -386,7 +381,6 @@ public class KafkaUtilsTest {
try {
provider.createCredentialEntry("atlas.jaas.KafkaClient.option.password", JAAS_MASKED_PASSWORD.toCharArray());
-
// write out so that it can be found in checks
provider.flush();
} catch (Exception e) {
@@ -395,5 +389,16 @@ public class KafkaUtilsTest {
}
}
+ private void assertJaaSConfigLoadable(String jaasConfig) {
+ // Ensure that JaaS config can be loaded
+ Map<String, Password> jaasConfigs = new HashMap<>();
+
+ jaasConfigs.put(SaslConfigs.SASL_JAAS_CONFIG, new Password(jaasConfig));
+ try {
+ JaasContext.loadClientContext(jaasConfigs);
+ } catch (IllegalArgumentException e) {
+ fail(String.format("JaaS config '%s' can not be loaded", jaasConfig), e);
+ }
+ }
}
diff --git a/common/src/test/java/org/apache/atlas/utils/LruCacheTest.java b/common/src/test/java/org/apache/atlas/utils/LruCacheTest.java
index 24d62f5b4..72cb12c54 100644
--- a/common/src/test/java/org/apache/atlas/utils/LruCacheTest.java
+++ b/common/src/test/java/org/apache/atlas/utils/LruCacheTest.java
@@ -6,9 +6,9 @@
* 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
- *
+ * <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.
@@ -17,29 +17,27 @@
*/
package org.apache.atlas.utils;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
+import org.apache.commons.lang.RandomStringUtils;
+import org.testng.annotations.Test;
import java.util.HashMap;
import java.util.Map;
-import org.apache.commons.lang.RandomStringUtils;
-import org.testng.annotations.Test;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
/**
* Tests the LruCache.
*/
@Test
public class LruCacheTest {
-
/**
* Tests the basic operations on the cache.
*/
@Test
- public void testBasicOps() throws Exception {
-
+ public void testBasicOps() {
LruCache<String, String> cache = new LruCache<>(1000, 0);
// Get the static cache and populate it. Its size and other
// characteristics depend on the bootstrap properties that are hard to
@@ -107,8 +105,8 @@ public class LruCacheTest {
@Test
public void testMapOperations() {
-
Map<String, String> reference = new HashMap<>();
+
reference.put("name", "Fred");
reference.put("occupation", "student");
reference.put("height", "5'11");
@@ -116,29 +114,32 @@ public class LruCacheTest {
reference.put("State", "MA");
LruCache<String, String> map = new LruCache<>(10, 10);
+
map.putAll(reference);
assertEquals(map.size(), reference.size());
- assertEquals(map.keySet().size(), reference.keySet().size());
+ assertEquals(map.size(), reference.size());
assertTrue(map.keySet().containsAll(reference.keySet()));
assertTrue(reference.keySet().containsAll(map.keySet()));
- assertEquals(reference.entrySet().size(), map.entrySet().size());
- for(Map.Entry<String, String> entry : map.entrySet()) {
+ assertEquals(reference.size(), map.size());
+
+ for (Map.Entry<String, String> entry : map.entrySet()) {
assertTrue(reference.containsKey(entry.getKey()));
assertEquals(entry.getValue(), reference.get(entry.getKey()));
assertTrue(map.containsKey(entry.getKey()));
assertTrue(map.containsValue(entry.getValue()));
- assertTrue(map.values().contains(entry.getValue()));
+ assertTrue(map.containsValue(entry.getValue()));
}
- assertTrue(reference.equals(map));
- assertTrue(map.equals(reference));
+ assertEquals(map, reference);
+ assertEquals(reference, map);
}
@Test
public void testReplaceValueInMap() {
LruCache<String, String> map = new LruCache<>(10, 10);
+
map.put("name", "Fred");
map.put("name", "George");
@@ -146,17 +147,17 @@ public class LruCacheTest {
assertEquals(map.size(), 1);
}
-
-
@Test
public void testOrderUpdatedWhenAddExisting() {
LruCache<String, String> map = new LruCache<>(2, 10);
+
map.put("name", "Fred");
map.put("age", "15");
map.put("name", "George");
//age should be evicted
map.put("height", "5'3\"");
+
//age is now least recently used
assertFalse(map.containsKey("age"));
}
@@ -164,34 +165,32 @@ public class LruCacheTest {
@Test
public void testMapRemove() {
LruCache<String, String> map = new LruCache<>(10, 10);
+
map.put("name", "Fred");
map.put("occupation", "student");
map.put("height", "5'11");
map.put("City", "Littleton");
map.put("State", "MA");
+
assertMapHasSize(map, 5);
assertTrue(map.containsKey("State"));
+
map.remove("State");
+
assertMapHasSize(map, 4);
assertFalse(map.containsKey("State"));
-
- }
-
- private void assertMapHasSize(LruCache<String, String> map, int size) {
- assertEquals(map.size(), size);
- assertEquals(map.keySet().size(), size);
- assertEquals(map.values().size(), size);
- assertEquals(map.entrySet().size(), size);
}
@Test
public void testEvict() {
LruCache<String, String> map = new LruCache<>(5, 10);
+
map.put("name", "Fred");
map.put("occupation", "student");
map.put("height", "5'11");
map.put("City", "Littleton");
map.put("State", "MA");
+
assertMapHasSize(map, 5);
//name should be evicted next
@@ -208,11 +207,18 @@ public class LruCacheTest {
assertMapHasSize(map, 5);
}
+ private void assertMapHasSize(LruCache<String, String> map, int size) {
+ assertEquals(map.size(), size);
+ assertEquals(map.size(), size);
+ assertEquals(map.size(), size);
+ assertEquals(map.size(), size);
+ }
+
/**
* Create a fake query handle for testing.
*
- * @param queryPrefix
- * @param pkgPrefix
+ * @param s1
+ * @param s2
* @return a new query handle.
*/
private String createHandle(String s1, String s2) {
@@ -223,11 +229,8 @@ public class LruCacheTest {
* Create a mock IInternalQuery.
*
* @return a mock IInternalQuery.
- * @throws QueryException
*/
private String createQuery() {
return RandomStringUtils.randomAlphabetic(10);
}
-
-
}
diff --git a/repository/src/test/java/org/apache/atlas/pc/StatusReporterTest.java b/repository/src/test/java/org/apache/atlas/pc/StatusReporterTest.java
index a0c399b44..bfe272f11 100644
--- a/repository/src/test/java/org/apache/atlas/pc/StatusReporterTest.java
+++ b/repository/src/test/java/org/apache/atlas/pc/StatusReporterTest.java
@@ -28,7 +28,8 @@ import static org.testng.Assert.assertNull;
public class StatusReporterTest {
private static class IntegerConsumer extends WorkItemConsumer<Integer> {
- private static ThreadLocal<Integer> payload = new ThreadLocal<Integer>();
+ private static final ThreadLocal<Integer> payload = new ThreadLocal<>();
+
private Integer current;
public IntegerConsumer(BlockingQueue<Integer> queue) {
@@ -44,7 +45,9 @@ public class StatusReporterTest {
protected void processItem(Integer item) {
try {
this.current = item;
+
Thread.sleep(20 + RandomUtils.nextInt(5, 7));
+
super.commit();
} catch (InterruptedException e) {
e.printStackTrace();
@@ -52,47 +55,52 @@ public class StatusReporterTest {
}
}
- private class IntegerConsumerBuilder implements WorkItemBuilder<IntegerConsumer, Integer> {
+ private static class IntegerConsumerBuilder implements WorkItemBuilder<WorkItemConsumer<Integer>, Integer> {
@Override
public IntegerConsumer build(BlockingQueue<Integer> queue) {
return new IntegerConsumer(queue);
}
}
- private WorkItemManager<Integer, WorkItemConsumer> getWorkItemManger(IntegerConsumerBuilder cb, int numWorkers) {
- return new WorkItemManager<>(cb, "IntegerConsumer", 5, numWorkers, true);
+ private WorkItemManager<Integer, WorkItemConsumer<Integer>> getWorkItemManger(WorkItemBuilder<WorkItemConsumer<Integer>, Integer> cb, int numWorkers) {
+ return new WorkItemManager<Integer, WorkItemConsumer<Integer>>(cb, "IntegerConsumer", 5, numWorkers, true);
}
@Test
public void statusReporting() throws InterruptedException {
- final int maxItems = 50;
-
- IntegerConsumerBuilder cb = new IntegerConsumerBuilder();
- WorkItemManager<Integer, WorkItemConsumer> wi = getWorkItemManger(cb, 5);
- StatusReporter<Integer, Integer> statusReporter = new StatusReporter<>();
+ final int maxItems = 50;
+ WorkItemBuilder<WorkItemConsumer<Integer>, Integer> cb = new IntegerConsumerBuilder();
+ WorkItemManager<Integer, WorkItemConsumer<Integer>> wi = getWorkItemManger(cb, 5);
+ StatusReporter<Integer, Integer> statusReporter = new StatusReporter<>();
for (int i = 0; i < maxItems; i++) {
wi.produce(i);
+
statusReporter.produced(i, i);
extractResults(wi, statusReporter);
}
wi.drain();
+
extractResults(wi, statusReporter);
+
assertEquals(statusReporter.ack().intValue(), (maxItems - 1));
+
wi.shutdown();
assertEquals(statusReporter.getProducedCount(), 0);
assertEquals(statusReporter.getProcessedCount(), 0);
}
- private void extractResults(WorkItemManager<Integer, WorkItemConsumer> wi, StatusReporter<Integer, Integer> statusReporter) {
- Object result = null;
+ private void extractResults(WorkItemManager<Integer, WorkItemConsumer<Integer>> wi, StatusReporter<Integer, Integer> statusReporter) {
+ Object result;
+
while((result = wi.getResults().poll()) != null) {
- if (result == null || !(result instanceof Integer)) {
+ if (!(result instanceof Integer)) {
continue;
}
+
statusReporter.processed((Integer) result);
}
}
@@ -104,11 +112,15 @@ public class StatusReporterTest {
statusReporter.produced(2, 200);
statusReporter.processed(2);
+
Integer ack = statusReporter.ack();
+
assertNull(ack);
Thread.sleep(3000);
+
ack = statusReporter.ack();
+
assertNotNull(ack);
assertEquals(ack, Integer.valueOf(200));
}
diff --git a/repository/src/test/java/org/apache/atlas/pc/WorkItemManagerTest.java b/repository/src/test/java/org/apache/atlas/pc/WorkItemManagerTest.java
index e72bdd027..62034eca0 100644
--- a/repository/src/test/java/org/apache/atlas/pc/WorkItemManagerTest.java
+++ b/repository/src/test/java/org/apache/atlas/pc/WorkItemManagerTest.java
@@ -32,19 +32,19 @@ import static org.testng.Assert.assertEquals;
public class WorkItemManagerTest {
private static final Logger LOG = LoggerFactory.getLogger(WorkItemManagerTest.class);
- private class IntegerConsumer extends WorkItemConsumer<Integer> {
-
+ private static class IntegerConsumer extends WorkItemConsumer<Integer> {
private final ConcurrentLinkedQueue<Integer> target;
public IntegerConsumer(BlockingQueue<Integer> queue, ConcurrentLinkedQueue<Integer> target) {
super(queue);
+
this.target = target;
}
@Override
protected void doCommit() {
try {
- Thread.sleep(20 * RandomUtils.nextInt(10, 15));
+ Thread.sleep(20L * RandomUtils.nextInt(10, 15));
} catch (InterruptedException e) {
e.printStackTrace();
}
@@ -57,7 +57,7 @@ public class WorkItemManagerTest {
}
}
- private class IntegerConsumerBuilder implements WorkItemBuilder<IntegerConsumer, Integer> {
+ private static class IntegerConsumerBuilder implements WorkItemBuilder<WorkItemConsumer<Integer>, Integer> {
ConcurrentLinkedQueue<Integer> integers = new ConcurrentLinkedQueue<>();
@Override
@@ -71,7 +71,7 @@ public class WorkItemManagerTest {
IntegerConsumerBuilder cb = new IntegerConsumerBuilder();
int numberOfItems = 10;
try {
- WorkItemManager<Integer, WorkItemConsumer> wi = getWorkItemManger(cb, 1);
+ WorkItemManager<Integer, WorkItemConsumer<Integer>> wi = getWorkItemManger(cb, 1);
for (int i = 0; i < numberOfItems; i++) {
wi.produce(i);
}
@@ -94,7 +94,7 @@ public class WorkItemManagerTest {
IntegerConsumerBuilder cb = new IntegerConsumerBuilder();
int numberOfItems = 100;
try {
- WorkItemManager<Integer, WorkItemConsumer> wi = getWorkItemManger(cb, 5);
+ WorkItemManager<Integer, WorkItemConsumer<Integer>> wi = getWorkItemManger(cb, 5);
for (int i = 0; i < numberOfItems; i++) {
wi.produce(i);
}
@@ -107,7 +107,7 @@ public class WorkItemManagerTest {
assertEquals(cb.integers.size(), numberOfItems);
}
- private WorkItemManager<Integer, WorkItemConsumer> getWorkItemManger(IntegerConsumerBuilder cb, int numWorkers) {
+ private WorkItemManager<Integer, WorkItemConsumer<Integer>> getWorkItemManger(IntegerConsumerBuilder cb, int numWorkers) {
return new WorkItemManager<>(cb, 5, numWorkers);
}
}
diff --git a/repository/src/test/java/org/apache/atlas/pc/WorkItemManagerWithResultsTest.java b/repository/src/test/java/org/apache/atlas/pc/WorkItemManagerWithResultsTest.java
index a12b59728..d6605defe 100644
--- a/repository/src/test/java/org/apache/atlas/pc/WorkItemManagerWithResultsTest.java
+++ b/repository/src/test/java/org/apache/atlas/pc/WorkItemManagerWithResultsTest.java
@@ -34,7 +34,7 @@ public class WorkItemManagerWithResultsTest {
private static final Logger LOG = LoggerFactory.getLogger(WorkItemManagerWithResultsTest.class);
private static class IntegerConsumer extends WorkItemConsumer<Integer> {
- private static ThreadLocal<Integer> payload = new ThreadLocal<Integer>();
+ private static final ThreadLocal<Integer> payload = new ThreadLocal<>();
public IntegerConsumer(BlockingQueue<Integer> queue) {
super(queue);
@@ -44,6 +44,7 @@ public class WorkItemManagerWithResultsTest {
protected void doCommit() {
if (getPayload() == -1) {
LOG.debug("Skipping:");
+
return;
}
@@ -56,8 +57,10 @@ public class WorkItemManagerWithResultsTest {
@Override
protected void processItem(Integer item) {
try {
- setPayload(item.intValue());
+ setPayload(item);
+
Thread.sleep(20 + RandomUtils.nextInt(5, 7));
+
super.commit();
} catch (InterruptedException e) {
e.printStackTrace();
@@ -77,31 +80,33 @@ public class WorkItemManagerWithResultsTest {
}
}
- private class IntegerConsumerBuilder implements WorkItemBuilder<IntegerConsumer, Integer> {
+ private static class IntegerConsumerBuilder implements WorkItemBuilder<WorkItemConsumer<Integer>, Integer> {
@Override
public IntegerConsumer build(BlockingQueue<Integer> queue) {
return new IntegerConsumer(queue);
}
}
- private WorkItemManager<Integer, WorkItemConsumer> getWorkItemManger(IntegerConsumerBuilder cb, int numWorkers) {
+ private WorkItemManager<Integer, WorkItemConsumer<Integer>> getWorkItemManger(IntegerConsumerBuilder cb, int numWorkers) {
return new WorkItemManager<>(cb, "IntegerConsumer", 5, numWorkers, true);
}
@Test
public void drainTest() throws InterruptedException {
- final int maxItems = 50;
-
- IntegerConsumerBuilder cb = new IntegerConsumerBuilder();
- WorkItemManager<Integer, WorkItemConsumer> wi = getWorkItemManger(cb, 5);
+ final int maxItems = 50;
+ IntegerConsumerBuilder cb = new IntegerConsumerBuilder();
+ WorkItemManager<Integer, WorkItemConsumer<Integer>> wi = getWorkItemManger(cb, 5);
for (int i = 0; i < maxItems; i++) {
wi.produce(i);
}
wi.drain();
+
assertEquals(wi.getResults().size(), maxItems);
- Set<Integer> set = new HashSet<Integer>(wi.getResults());
+
+ Set<Object> set = new HashSet<>(wi.getResults());
+
assertEquals(set.size(), maxItems);
wi.shutdown();
@@ -109,8 +114,8 @@ public class WorkItemManagerWithResultsTest {
@Test
public void drainCheckProduceTest() throws InterruptedException {
- IntegerConsumerBuilder cb = new IntegerConsumerBuilder();
- WorkItemManager<Integer, WorkItemConsumer> wi = getWorkItemManger(cb, 2);
+ IntegerConsumerBuilder cb = new IntegerConsumerBuilder();
+ WorkItemManager<Integer, WorkItemConsumer<Integer>> wi = getWorkItemManger(cb, 2);
for (int i = 0; i < 5; i++) {
repeatedDrainAndProduce(i, wi);
@@ -119,19 +124,22 @@ public class WorkItemManagerWithResultsTest {
wi.shutdown();
}
- private void repeatedDrainAndProduce(int runCount, WorkItemManager<Integer, WorkItemConsumer> wi) {
+ private void repeatedDrainAndProduce(int runCount, WorkItemManager<Integer, WorkItemConsumer<Integer>> wi) {
final int maxItems = 100;
- int halfWay = maxItems / 2;
+ int halfWay = maxItems / 2;
LOG.info("Run: {}", runCount);
+
wi.getResults().clear();
for (int i = 0; i < maxItems; i++) {
if (i == halfWay) {
wi.drain();
- Set<Integer> set = new HashSet<Integer>(wi.getResults());
+ Set<Object> set = new HashSet<>(wi.getResults());
+
assertEquals(wi.getResults().size(), halfWay, "halfWay: total count");
+
assertEquals(set.size(), halfWay, "halfWay: set match");
}
@@ -139,8 +147,11 @@ public class WorkItemManagerWithResultsTest {
}
wi.drain();
+
assertEquals(wi.getResults().size(), maxItems, "total count");
- Set<Integer> set = new HashSet<Integer>(wi.getResults());
+
+ Set<Object> set = new HashSet<>(wi.getResults());
+
assertEquals(set.size(), maxItems, "set count");
for (int i = 100; i < 100 + maxItems; i++) {