Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
atlas
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dataplatform
atlas
Commits
0b85d5a0
Commit
0b85d5a0
authored
Oct 31, 2016
by
Suma Shivaprasad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1240 Adding Change listeners to react on changes in TypesDef (apoorvnaik via sumasai)
parent
9dc4cfbc
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
27 changed files
with
370 additions
and
183 deletions
+370
-183
pom.xml
intg/pom.xml
+5
-0
AtlasErrorCode.java
intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
+4
-1
AtlasBaseException.java
...n/java/org/apache/atlas/exception/AtlasBaseException.java
+13
-1
ChangedTypeDefs.java
.../main/java/org/apache/atlas/listener/ChangedTypeDefs.java
+70
-0
TypeDefChangeListener.java
...java/org/apache/atlas/listener/TypeDefChangeListener.java
+24
-0
AtlasTypeUtil.java
intg/src/main/java/org/apache/atlas/type/AtlasTypeUtil.java
+9
-9
TestAtlasStructDef.java
...va/org/apache/atlas/model/typedef/TestAtlasStructDef.java
+2
-3
release-log.txt
release-log.txt
+1
-0
RepositoryMetadataModule.java
.../main/java/org/apache/atlas/RepositoryMetadataModule.java
+7
-0
GraphBackedSearchIndexer.java
...ache/atlas/repository/graph/GraphBackedSearchIndexer.java
+0
-0
AtlasTypeDefGraphStore.java
.../atlas/repository/store/graph/AtlasTypeDefGraphStore.java
+0
-0
AtlasTypeDefGraphStoreV1.java
...s/repository/store/graph/v1/AtlasTypeDefGraphStoreV1.java
+4
-2
DefaultMetadataService.java
...ava/org/apache/atlas/services/DefaultMetadataService.java
+38
-18
BaseRepositoryTest.java
...ry/src/test/java/org/apache/atlas/BaseRepositoryTest.java
+5
-2
TestUtils.java
repository/src/test/java/org/apache/atlas/TestUtils.java
+22
-21
GraphBackedDiscoveryServiceTest.java
...ache/atlas/discovery/GraphBackedDiscoveryServiceTest.java
+19
-18
GraphBackedMetadataRepositoryDeleteTestBase.java
...ry/graph/GraphBackedMetadataRepositoryDeleteTestBase.java
+28
-27
GraphBackedMetadataRepositoryTest.java
...s/repository/graph/GraphBackedMetadataRepositoryTest.java
+23
-22
GraphBackedSearchIndexerMockTest.java
...as/repository/graph/GraphBackedSearchIndexerMockTest.java
+11
-7
GraphHelperTest.java
...va/org/apache/atlas/repository/graph/GraphHelperTest.java
+19
-15
GraphRepoMapperScaleTest.java
...ache/atlas/repository/graph/GraphRepoMapperScaleTest.java
+9
-8
DefaultMetadataServiceTest.java
.../org/apache/atlas/service/DefaultMetadataServiceTest.java
+46
-26
QueryTestsUtils.scala
...c/test/scala/org/apache/atlas/query/QueryTestsUtils.scala
+2
-1
pom.xml
typesystem/pom.xml
+4
-0
TypeSystem.java
...in/java/org/apache/atlas/typesystem/types/TypeSystem.java
+3
-1
TypesREST.java
...pp/src/main/java/org/apache/atlas/web/rest/TypesREST.java
+0
-1
ActiveInstanceElectorModule.java
...apache/atlas/web/service/ActiveInstanceElectorModule.java
+2
-0
No files found.
intg/pom.xml
View file @
0b85d5a0
...
...
@@ -55,6 +55,11 @@
<version>
${codehaus.jackson.version}
</version>
</dependency>
<dependency>
<groupId>
javax.inject
</groupId>
<artifactId>
javax.inject
</artifactId>
<version>
${javax-inject.version}
</version>
</dependency>
<dependency>
<groupId>
org.testng
</groupId>
...
...
intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
View file @
0b85d5a0
...
...
@@ -51,7 +51,10 @@ public enum AtlasErrorCode {
TYPE_HAS_REFERENCES
(
409
,
"ATLAS4092E"
,
"Given type {0} has references"
),
TYPE_MATCH_FAILED
(
409
,
"ATLAS4093E"
,
"Given type {0} doesn't match {1}"
),
INTERNAL_ERROR
(
500
,
"ATLAS5001E"
,
"Internal server error {0}"
);
INTERNAL_ERROR
(
500
,
"ATLAS5001E"
,
"Internal server error {0}"
),
INDEX_CREATION_FAILED
(
500
,
"ATLAS5002E"
,
"Index creation failed for {0}"
),
INDEX_ROLLBACK_FAILED
(
500
,
"ATLAS5003E"
,
"Index rollback failed for {0}"
)
;
private
String
errorCode
;
private
String
errorMessage
;
...
...
intg/src/main/java/org/apache/atlas/exception/AtlasBaseException.java
View file @
0b85d5a0
...
...
@@ -42,6 +42,11 @@ public class AtlasBaseException extends Exception {
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
;
...
...
@@ -52,7 +57,14 @@ public class AtlasBaseException extends Exception {
this
.
atlasErrorCode
=
AtlasErrorCode
.
INTERNAL_ERROR
;
}
public
AtlasBaseException
(
String
message
,
Throwable
cause
,
boolean
enableSuppression
,
boolean
writableStackTrace
)
{
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
)
{
super
(
message
,
cause
,
enableSuppression
,
writableStackTrace
);
this
.
atlasErrorCode
=
AtlasErrorCode
.
INTERNAL_ERROR
;
}
...
...
intg/src/main/java/org/apache/atlas/listener/ChangedTypeDefs.java
0 → 100644
View file @
0b85d5a0
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
apache
.
atlas
.
listener
;
import
org.apache.atlas.model.typedef.AtlasBaseTypeDef
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
ChangedTypeDefs
{
private
List
<?
extends
AtlasBaseTypeDef
>
createTypeDefs
;
private
List
<?
extends
AtlasBaseTypeDef
>
updatedTypeDefs
;
private
List
<?
extends
AtlasBaseTypeDef
>
deletedTypeDefs
;
public
ChangedTypeDefs
(
List
<?
extends
AtlasBaseTypeDef
>
createTypeDefs
,
List
<?
extends
AtlasBaseTypeDef
>
updatedTypeDefs
,
List
<?
extends
AtlasBaseTypeDef
>
deletedTypeDefs
)
{
this
.
createTypeDefs
=
createTypeDefs
;
this
.
updatedTypeDefs
=
updatedTypeDefs
;
this
.
deletedTypeDefs
=
deletedTypeDefs
;
}
public
ChangedTypeDefs
()
{
createTypeDefs
=
new
ArrayList
<>();
updatedTypeDefs
=
new
ArrayList
<>();
deletedTypeDefs
=
new
ArrayList
<>();
}
public
List
<?
extends
AtlasBaseTypeDef
>
getCreateTypeDefs
()
{
return
createTypeDefs
;
}
public
ChangedTypeDefs
setCreateTypeDefs
(
List
<?
extends
AtlasBaseTypeDef
>
createTypeDefs
)
{
this
.
createTypeDefs
=
createTypeDefs
;
return
this
;
}
public
List
<?
extends
AtlasBaseTypeDef
>
getUpdatedTypeDefs
()
{
return
updatedTypeDefs
;
}
public
ChangedTypeDefs
setUpdatedTypeDefs
(
List
<?
extends
AtlasBaseTypeDef
>
updatedTypeDefs
)
{
this
.
updatedTypeDefs
=
updatedTypeDefs
;
return
this
;
}
public
List
<?
extends
AtlasBaseTypeDef
>
getDeletedTypeDefs
()
{
return
deletedTypeDefs
;
}
public
ChangedTypeDefs
setDeletedTypeDefs
(
List
<?
extends
AtlasBaseTypeDef
>
deletedTypeDefs
)
{
this
.
deletedTypeDefs
=
deletedTypeDefs
;
return
this
;
}
}
intg/src/main/java/org/apache/atlas/listener/TypeDefChangeListener.java
0 → 100644
View file @
0b85d5a0
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
apache
.
atlas
.
listener
;
import
org.apache.atlas.exception.AtlasBaseException
;
public
interface
TypeDefChangeListener
{
void
onChange
(
ChangedTypeDefs
changedTypeDefs
)
throws
AtlasBaseException
;
}
intg/src/main/java/org/apache/atlas/type/AtlasTypeUtil.java
View file @
0b85d5a0
...
...
@@ -18,17 +18,19 @@
package
org
.
apache
.
atlas
.
type
;
import
org.apache.atlas.model.typedef.AtlasBaseTypeDef
;
import
static
org
.
apache
.
atlas
.
model
.
typedef
.
AtlasBaseTypeDef
.
ATLAS_TYPE_ARRAY_PREFIX
;
import
static
org
.
apache
.
atlas
.
model
.
typedef
.
AtlasBaseTypeDef
.
ATLAS_TYPE_ARRAY_SUFFIX
;
import
static
org
.
apache
.
atlas
.
model
.
typedef
.
AtlasBaseTypeDef
.
ATLAS_TYPE_MAP_PREFIX
;
import
static
org
.
apache
.
atlas
.
model
.
typedef
.
AtlasBaseTypeDef
.
ATLAS_TYPE_MAP_SUFFIX
;
import
static
org
.
apache
.
atlas
.
model
.
typedef
.
AtlasBaseTypeDef
.
ATLAS_TYPE_MAP_KEY_VAL_SEP
;
import
org.apache.commons.lang.StringUtils
;
import
java.util.Collections
;
import
java.util.HashSet
;
import
java.util.Map
;
import
java.util.Set
;
import
static
org
.
apache
.
atlas
.
model
.
typedef
.
AtlasBaseTypeDef
.
ATLAS_TYPE_ARRAY_PREFIX
;
import
static
org
.
apache
.
atlas
.
model
.
typedef
.
AtlasBaseTypeDef
.
ATLAS_TYPE_ARRAY_SUFFIX
;
import
static
org
.
apache
.
atlas
.
model
.
typedef
.
AtlasBaseTypeDef
.
ATLAS_TYPE_MAP_KEY_VAL_SEP
;
import
static
org
.
apache
.
atlas
.
model
.
typedef
.
AtlasBaseTypeDef
.
ATLAS_TYPE_MAP_PREFIX
;
import
static
org
.
apache
.
atlas
.
model
.
typedef
.
AtlasBaseTypeDef
.
ATLAS_TYPE_MAP_SUFFIX
;
/**
* Utility methods for AtlasType/AtlasTypeDef.
*/
...
...
@@ -36,9 +38,7 @@ public class AtlasTypeUtil {
private
static
final
Set
<
String
>
ATLAS_BUILTIN_TYPENAMES
=
new
HashSet
<
String
>();
static
{
for
(
String
typeName
:
AtlasBaseTypeDef
.
ATLAS_BUILTIN_TYPES
)
{
ATLAS_BUILTIN_TYPENAMES
.
add
(
typeName
);
}
Collections
.
addAll
(
ATLAS_BUILTIN_TYPENAMES
,
AtlasBaseTypeDef
.
ATLAS_BUILTIN_TYPES
);
}
public
static
Set
<
String
>
getReferencedTypeNames
(
String
typeName
)
{
...
...
@@ -63,6 +63,7 @@ public class AtlasTypeUtil {
&&
StringUtils
.
endsWith
(
typeName
,
ATLAS_TYPE_MAP_SUFFIX
);
}
public
static
String
getStringValue
(
Map
map
,
Object
key
)
{
Object
ret
=
map
!=
null
?
map
.
get
(
key
)
:
null
;
...
...
@@ -90,6 +91,5 @@ public class AtlasTypeUtil {
referencedTypeNames
.
add
(
typeName
);
}
}
}
}
intg/src/test/java/org/apache/atlas/model/typedef/TestAtlasStructDef.java
View file @
0b85d5a0
...
...
@@ -17,17 +17,16 @@
*/
package
org
.
apache
.
atlas
.
model
.
typedef
;
import
java.util.List
;
import
org.apache.atlas.model.ModelTestUtil
;
import
org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef
;
import
org.apache.atlas.type.AtlasType
;
import
org.testng.annotations.Test
;
import
java.util.List
;
import
static
org
.
testng
.
Assert
.
assertEquals
;
import
static
org
.
testng
.
Assert
.
assertTrue
;
import
static
org
.
testng
.
Assert
.
assertFalse
;
import
static
org
.
testng
.
Assert
.
assertTrue
;
public
class
TestAtlasStructDef
{
...
...
release-log.txt
View file @
0b85d5a0
...
...
@@ -9,6 +9,7 @@ ATLAS-1060 Add composite indexes for exact match performance improvements for al
ATLAS-1127 Modify creation and modification timestamps to Date instead of Long(sumasai)
ALL CHANGES:
ATLAS-1240 Adding Change listeners to react on changes in TypesDef (apoorvnaik via sumasai)
ATLAS-1239 when stopping Atlas on the command line it should explicitly say when it has stopped (ayubkhan via sumasai)
ATLAS-1253 Extract error codes into AtlasErrorCode Enum (apoorvnaik via sumasai)
ATLAS-1195 Clean up DSL Translation (jnhagelb via dkantor)
...
...
repository/src/main/java/org/apache/atlas/RepositoryMetadataModule.java
View file @
0b85d5a0
...
...
@@ -29,6 +29,7 @@ import org.apache.atlas.discovery.DiscoveryService;
import
org.apache.atlas.discovery.LineageService
;
import
org.apache.atlas.discovery.graph.GraphBackedDiscoveryService
;
import
org.apache.atlas.listener.EntityChangeListener
;
import
org.apache.atlas.listener.TypeDefChangeListener
;
import
org.apache.atlas.listener.TypesChangeListener
;
import
org.apache.atlas.repository.MetadataRepository
;
import
org.apache.atlas.repository.audit.EntityAuditListener
;
...
...
@@ -76,6 +77,12 @@ public class RepositoryMetadataModule extends com.google.inject.AbstractModule {
Multibinder
.
newSetBinder
(
binder
(),
TypesChangeListener
.
class
);
typesChangeListenerBinder
.
addBinding
().
to
(
GraphBackedSearchIndexer
.
class
).
asEagerSingleton
();
// New typesdef/instance change listener should also be bound to the corresponding implementation
Multibinder
<
TypeDefChangeListener
>
typeDefChangeListenerMultibinder
=
Multibinder
.
newSetBinder
(
binder
(),
TypeDefChangeListener
.
class
);
typeDefChangeListenerMultibinder
.
addBinding
().
to
(
DefaultMetadataService
.
class
);
typeDefChangeListenerMultibinder
.
addBinding
().
to
(
GraphBackedSearchIndexer
.
class
).
asEagerSingleton
();
// bind the MetadataService interface to an implementation
bind
(
MetadataService
.
class
).
to
(
DefaultMetadataService
.
class
).
asEagerSingleton
();
...
...
repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexer.java
View file @
0b85d5a0
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java
View file @
0b85d5a0
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasTypeDefGraphStoreV1.java
View file @
0b85d5a0
...
...
@@ -22,6 +22,7 @@ import com.google.inject.Inject;
import
org.apache.atlas.AtlasErrorCode
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.listener.TypeDefChangeListener
;
import
org.apache.atlas.model.typedef.AtlasBaseTypeDef
;
import
org.apache.atlas.model.typedef.AtlasClassificationDef
;
import
org.apache.atlas.model.typedef.AtlasEntityDef
;
...
...
@@ -65,8 +66,9 @@ public class AtlasTypeDefGraphStoreV1 extends AtlasTypeDefGraphStore {
protected
final
AtlasGraph
atlasGraph
=
AtlasGraphProvider
.
getGraphInstance
();
@Inject
public
AtlasTypeDefGraphStoreV1
(
AtlasTypeRegistry
typeRegistry
)
{
super
(
typeRegistry
);
public
AtlasTypeDefGraphStoreV1
(
AtlasTypeRegistry
typeRegistry
,
Set
<
TypeDefChangeListener
>
typeDefChangeListeners
)
{
super
(
typeRegistry
,
typeDefChangeListeners
);
LOG
.
info
(
"==> AtlasTypeDefGraphStoreV1()"
);
...
...
repository/src/main/java/org/apache/atlas/services/DefaultMetadataService.java
View file @
0b85d5a0
...
...
@@ -18,29 +18,25 @@
package
org
.
apache
.
atlas
.
services
;
import
static
org
.
apache
.
atlas
.
AtlasClient
.
PROCESS_ATTRIBUTE_INPUTS
;
import
static
org
.
apache
.
atlas
.
AtlasClient
.
PROCESS_ATTRIBUTE_OUTPUTS
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.LinkedHashSet
;
import
java.util.List
;
import
java.util.Map
;
import
javax.inject.Inject
;
import
javax.inject.Singleton
;
import
com.google.common.base.Preconditions
;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.ImmutableSet
;
import
com.google.inject.Provider
;
import
org.apache.atlas.ApplicationProperties
;
import
org.apache.atlas.AtlasClient
;
import
org.apache.atlas.AtlasErrorCode
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.EntityAuditEvent
;
import
org.apache.atlas.RequestContext
;
import
org.apache.atlas.classification.InterfaceAudience
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.ha.HAConfiguration
;
import
org.apache.atlas.listener.ActiveStateChangeHandler
;
import
org.apache.atlas.listener.ChangedTypeDefs
;
import
org.apache.atlas.listener.EntityChangeListener
;
import
org.apache.atlas.listener.TypeDefChangeListener
;
import
org.apache.atlas.listener.TypesChangeListener
;
import
org.apache.atlas.query.QueryParser
;
import
org.apache.atlas.repository.MetadataRepository
;
import
org.apache.atlas.repository.RepositoryException
;
import
org.apache.atlas.repository.audit.EntityAuditRepository
;
...
...
@@ -72,17 +68,23 @@ import org.apache.atlas.typesystem.types.TypeSystem;
import
org.apache.atlas.typesystem.types.cache.TypeCache
;
import
org.apache.atlas.typesystem.types.utils.TypesUtil
;
import
org.apache.atlas.utils.ParamChecker
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.configuration.Configuration
;
import
org.codehaus.jettison.json.JSONException
;
import
org.codehaus.jettison.json.JSONObject
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
com.google.common.base.Preconditions
;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.ImmutableSet
;
import
com.google.inject.Provider
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.LinkedHashSet
;
import
java.util.List
;
import
java.util.Map
;
import
javax.inject.Inject
;
import
javax.inject.Singleton
;
import
static
org
.
apache
.
atlas
.
AtlasClient
.
PROCESS_ATTRIBUTE_INPUTS
;
import
static
org
.
apache
.
atlas
.
AtlasClient
.
PROCESS_ATTRIBUTE_OUTPUTS
;
...
...
@@ -91,7 +93,7 @@ import com.google.inject.Provider;
* for listening to changes to the repository.
*/
@Singleton
public
class
DefaultMetadataService
implements
MetadataService
,
ActiveStateChangeHandler
{
public
class
DefaultMetadataService
implements
MetadataService
,
ActiveStateChangeHandler
,
TypeDefChangeListener
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
DefaultMetadataService
.
class
);
private
final
short
maxAuditResults
;
...
...
@@ -774,4 +776,22 @@ public class DefaultMetadataService implements MetadataService, ActiveStateChang
public
void
instanceIsPassive
()
{
LOG
.
info
(
"Reacting to passive state: no action right now"
);
}
@Override
public
void
onChange
(
ChangedTypeDefs
changedTypeDefs
)
throws
AtlasBaseException
{
// All we need here is a restore of the type-system
LOG
.
info
(
"TypeSystem reset invoked by TypeRegistry changes"
);
try
{
TypesDef
typesDef
=
typeStore
.
restore
();
typeSystem
.
reset
();
TypeSystem
.
TransientTypeSystem
transientTypeSystem
=
typeSystem
.
createTransientTypeSystem
(
typesDef
,
false
);
Map
<
String
,
IDataType
>
typesAdded
=
transientTypeSystem
.
getTypesAdded
();
LOG
.
info
(
"Number of types got from transient type system: "
+
typesAdded
.
size
());
typeSystem
.
commitTypes
(
typesAdded
);
}
catch
(
AtlasException
e
)
{
LOG
.
error
(
"Failed to restore type-system after TypeRegistry changes"
,
e
);
throw
new
AtlasBaseException
(
AtlasErrorCode
.
INTERNAL_ERROR
,
e
);
}
}
}
repository/src/test/java/org/apache/atlas/BaseRepositoryTest.java
View file @
0b85d5a0
...
...
@@ -20,10 +20,12 @@ package org.apache.atlas;
import
com.google.common.base.Preconditions
;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.ImmutableSet
;
import
org.apache.atlas.repository.MetadataRepository
;
import
org.apache.atlas.repository.graph.AtlasGraphProvider
;
import
org.apache.atlas.repository.graph.GraphBackedSearchIndexer
;
import
org.apache.atlas.services.MetadataService
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.atlas.typesystem.ITypedReferenceableInstance
;
import
org.apache.atlas.typesystem.Referenceable
;
import
org.apache.atlas.typesystem.TypesDef
;
...
...
@@ -42,11 +44,12 @@ import org.apache.atlas.typesystem.types.TypeSystem;
import
org.apache.atlas.typesystem.types.utils.TypesUtil
;
import
org.testng.annotations.Guice
;
import
javax.inject.Inject
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
javax.inject.Inject
;
/**
* Base Class to set up hive types and instances for tests
*/
...
...
@@ -65,7 +68,7 @@ public class BaseRepositoryTest {
//force graph initialization / built in type registration
TestUtils
.
getGraph
();
setUpTypes
();
new
GraphBackedSearchIndexer
();
new
GraphBackedSearchIndexer
(
new
AtlasTypeRegistry
()
);
TestUtils
.
resetRequestContext
();
setupInstances
();
TestUtils
.
dumpGraph
(
TestUtils
.
getGraph
());
...
...
repository/src/test/java/org/apache/atlas/TestUtils.java
View file @
0b85d5a0
...
...
@@ -18,23 +18,9 @@
package
org
.
apache
.
atlas
;
import
static
org
.
apache
.
atlas
.
typesystem
.
types
.
utils
.
TypesUtil
.
createClassTypeDef
;
import
static
org
.
apache
.
atlas
.
typesystem
.
types
.
utils
.
TypesUtil
.
createOptionalAttrDef
;
import
static
org
.
apache
.
atlas
.
typesystem
.
types
.
utils
.
TypesUtil
.
createRequiredAttrDef
;
import
static
org
.
apache
.
atlas
.
typesystem
.
types
.
utils
.
TypesUtil
.
createStructTypeDef
;
import
static
org
.
apache
.
atlas
.
typesystem
.
types
.
utils
.
TypesUtil
.
createTraitTypeDef
;
import
static
org
.
apache
.
atlas
.
typesystem
.
types
.
utils
.
TypesUtil
.
createUniqueRequiredAttrDef
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.math.BigDecimal
;
import
java.math.BigInteger
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.List
;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.ImmutableSet
;
import
com.google.inject.Provider
;
import
org.apache.atlas.listener.EntityChangeListener
;
import
org.apache.atlas.listener.TypesChangeListener
;
...
...
@@ -48,6 +34,7 @@ import org.apache.atlas.repository.typestore.ITypeStore;
import
org.apache.atlas.services.DefaultMetadataService
;
import
org.apache.atlas.services.MetadataService
;
import
org.apache.atlas.services.ReservedTypesRegistrar
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.atlas.typesystem.ITypedReferenceableInstance
;
import
org.apache.atlas.typesystem.Referenceable
;
import
org.apache.atlas.typesystem.TypesDef
;
...
...
@@ -73,9 +60,23 @@ import org.apache.commons.lang.RandomStringUtils;
import
org.codehaus.jettison.json.JSONArray
;
import
org.testng.Assert
;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.ImmutableSet
;
import
com.google.inject.Provider
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.math.BigDecimal
;
import
java.math.BigInteger
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.List
;
import
static
org
.
apache
.
atlas
.
typesystem
.
types
.
utils
.
TypesUtil
.
createClassTypeDef
;
import
static
org
.
apache
.
atlas
.
typesystem
.
types
.
utils
.
TypesUtil
.
createOptionalAttrDef
;
import
static
org
.
apache
.
atlas
.
typesystem
.
types
.
utils
.
TypesUtil
.
createRequiredAttrDef
;
import
static
org
.
apache
.
atlas
.
typesystem
.
types
.
utils
.
TypesUtil
.
createStructTypeDef
;
import
static
org
.
apache
.
atlas
.
typesystem
.
types
.
utils
.
TypesUtil
.
createTraitTypeDef
;
import
static
org
.
apache
.
atlas
.
typesystem
.
types
.
utils
.
TypesUtil
.
createUniqueRequiredAttrDef
;
/**
* Test utility class.
...
...
@@ -513,7 +514,7 @@ public final class TestUtils {
catch
(
Throwable
t
)
{
typeCache
=
new
DefaultTypeCache
();
}
final
GraphBackedSearchIndexer
indexer
=
new
GraphBackedSearchIndexer
();
final
GraphBackedSearchIndexer
indexer
=
new
GraphBackedSearchIndexer
(
new
AtlasTypeRegistry
()
);
Provider
<
TypesChangeListener
>
indexerProvider
=
new
Provider
<
TypesChangeListener
>()
{
@Override
...
...
repository/src/test/java/org/apache/atlas/discovery/GraphBackedDiscoveryServiceTest.java
View file @
0b85d5a0
...
...
@@ -18,22 +18,7 @@
package
org
.
apache
.
atlas
.
discovery
;
import
static
org
.
apache
.
atlas
.
typesystem
.
types
.
utils
.
TypesUtil
.
createClassTypeDef
;
import
static
org
.
apache
.
atlas
.
typesystem
.
types
.
utils
.
TypesUtil
.
createOptionalAttrDef
;
import
static
org
.
apache
.
atlas
.
typesystem
.
types
.
utils
.
TypesUtil
.
createRequiredAttrDef
;
import
static
org
.
testng
.
Assert
.
assertEquals
;
import
static
org
.
testng
.
Assert
.
assertNotNull
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
javax.inject.Inject
;
import
com.google.common.collect.ImmutableSet
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.BaseRepositoryTest
;
...
...
@@ -46,6 +31,7 @@ import org.apache.atlas.repository.Constants;
import
org.apache.atlas.repository.MetadataRepository
;
import
org.apache.atlas.repository.graph.AtlasGraphProvider
;
import
org.apache.atlas.repository.graph.GraphBackedSearchIndexer
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.atlas.typesystem.ITypedReferenceableInstance
;
import
org.apache.atlas.typesystem.Referenceable
;
import
org.apache.atlas.typesystem.persistence.Id
;
...
...
@@ -65,7 +51,22 @@ import org.testng.annotations.DataProvider;
import
org.testng.annotations.Guice
;
import
org.testng.annotations.Test
;
import
com.google.common.collect.ImmutableSet
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
javax.inject.Inject
;
import
static
org
.
apache
.
atlas
.
typesystem
.
types
.
utils
.
TypesUtil
.
createClassTypeDef
;
import
static
org
.
apache
.
atlas
.
typesystem
.
types
.
utils
.
TypesUtil
.
createOptionalAttrDef
;
import
static
org
.
apache
.
atlas
.
typesystem
.
types
.
utils
.
TypesUtil
.
createRequiredAttrDef
;
import
static
org
.
testng
.
Assert
.
assertEquals
;
import
static
org
.
testng
.
Assert
.
assertNotNull
;
@Guice
(
modules
=
RepositoryMetadataModule
.
class
)
public
class
GraphBackedDiscoveryServiceTest
extends
BaseRepositoryTest
{
...
...
@@ -119,7 +120,7 @@ public class GraphBackedDiscoveryServiceTest extends BaseRepositoryTest {
//We need to commit the transaction before creating the indices to release the locks held by the transaction.
//otherwise, the index commit will fail while waiting for the those locks to be released.
AtlasGraphProvider
.
getGraphInstance
().
commit
();
GraphBackedSearchIndexer
idx
=
new
GraphBackedSearchIndexer
();
GraphBackedSearchIndexer
idx
=
new
GraphBackedSearchIndexer
(
new
AtlasTypeRegistry
()
);
idx
.
onAdd
(
newTypes
);
}
...
...
repository/src/test/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepositoryDeleteTestBase.java
View file @
0b85d5a0
...
...
@@ -18,30 +18,8 @@
package
org
.
apache
.
atlas
.
repository
.
graph
;
import
static
org
.
apache
.
atlas
.
TestUtils
.
COLUMNS_ATTR_NAME
;
import
static
org
.
apache
.
atlas
.
TestUtils
.
COLUMN_TYPE
;
import
static
org
.
apache
.
atlas
.
TestUtils
.
NAME
;
import
static
org
.
apache
.
atlas
.
TestUtils
.
PII
;
import
static
org
.
apache
.
atlas
.
TestUtils
.
PROCESS_TYPE
;
import
static
org
.
apache
.
atlas
.
TestUtils
.
TABLE_TYPE
;
import
static
org
.
apache
.
atlas
.
TestUtils
.
createColumnEntity
;
import
static
org
.
apache
.
atlas
.
TestUtils
.
createDBEntity
;
import
static
org
.
apache
.
atlas
.
TestUtils
.
createTableEntity
;
import
static
org
.
testng
.
Assert
.
assertEquals
;
import
static
org
.
testng
.
Assert
.
assertNotEquals
;
import
static
org
.
testng
.
Assert
.
assertTrue
;
import
static
org
.
testng
.
Assert
.
fail
;
import
java.lang.reflect.InvocationHandler
;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Proxy
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.ImmutableSet
;
import
org.apache.atlas.AtlasClient
;
import
org.apache.atlas.AtlasClient.EntityResult
;
...
...
@@ -55,6 +33,7 @@ import org.apache.atlas.repository.MetadataRepository;
import
org.apache.atlas.repository.RepositoryException
;
import
org.apache.atlas.repository.graphdb.AtlasGraph
;
import
org.apache.atlas.repository.graphdb.AtlasVertex
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.atlas.typesystem.IReferenceableInstance
;
import
org.apache.atlas.typesystem.IStruct
;
import
org.apache.atlas.typesystem.ITypedReferenceableInstance
;
...
...
@@ -84,8 +63,30 @@ import org.testng.annotations.BeforeMethod;
import
org.testng.annotations.Guice
;
import
org.testng.annotations.Test
;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.ImmutableSet
;
import
java.lang.reflect.InvocationHandler
;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Proxy
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
static
org
.
apache
.
atlas
.
TestUtils
.
COLUMNS_ATTR_NAME
;
import
static
org
.
apache
.
atlas
.
TestUtils
.
COLUMN_TYPE
;
import
static
org
.
apache
.
atlas
.
TestUtils
.
NAME
;
import
static
org
.
apache
.
atlas
.
TestUtils
.
PII
;
import
static
org
.
apache
.
atlas
.
TestUtils
.
PROCESS_TYPE
;
import
static
org
.
apache
.
atlas
.
TestUtils
.
TABLE_TYPE
;
import
static
org
.
apache
.
atlas
.
TestUtils
.
createColumnEntity
;
import
static
org
.
apache
.
atlas
.
TestUtils
.
createDBEntity
;
import
static
org
.
apache
.
atlas
.
TestUtils
.
createTableEntity
;
import
static
org
.
testng
.
Assert
.
assertEquals
;
import
static
org
.
testng
.
Assert
.
assertNotEquals
;
import
static
org
.
testng
.
Assert
.
assertTrue
;
import
static
org
.
testng
.
Assert
.
fail
;
/**
* Test for GraphBackedMetadataRepository.deleteEntities
...
...
@@ -110,7 +111,7 @@ public abstract class GraphBackedMetadataRepositoryDeleteTestBase {
typeSystem
=
TypeSystem
.
getInstance
();
typeSystem
.
reset
();
new
GraphBackedSearchIndexer
();
new
GraphBackedSearchIndexer
(
new
AtlasTypeRegistry
()
);
final
GraphBackedMetadataRepository
delegate
=
new
GraphBackedMetadataRepository
(
getDeleteHandler
(
typeSystem
));
repositoryService
=
(
MetadataRepository
)
Proxy
.
newProxyInstance
(
Thread
.
currentThread
().
getContextClassLoader
(),
...
...
repository/src/test/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepositoryTest.java
View file @
0b85d5a0
...
...
@@ -18,25 +18,8 @@
package
org
.
apache
.
atlas
.
repository
.
graph
;
import
static
org
.
apache
.
atlas
.
typesystem
.
types
.
utils
.
TypesUtil
.
createClassTypeDef
;
import
static
org
.
apache
.
atlas
.
typesystem
.
types
.
utils
.
TypesUtil
.
createUniqueRequiredAttrDef
;
import
static
org
.
testng
.
Assert
.
assertEquals
;
import
static
org
.
testng
.
Assert
.
assertNotEquals
;
import
static
org
.
testng
.
Assert
.
assertNotNull
;
import
static
org
.
testng
.
Assert
.
assertTrue
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.UUID
;
import
java.util.concurrent.Callable
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.Future
;
import
javax.inject.Inject
;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.ImmutableSet
;
import
org.apache.atlas.GraphTransaction
;
import
org.apache.atlas.RepositoryMetadataModule
;
...
...
@@ -52,6 +35,7 @@ import org.apache.atlas.repository.graphdb.AtlasGraph;
import
org.apache.atlas.repository.graphdb.AtlasGraphQuery
;
import
org.apache.atlas.repository.graphdb.AtlasGraphQuery.ComparisionOperator
;
import
org.apache.atlas.repository.graphdb.AtlasVertex
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.atlas.typesystem.IStruct
;
import
org.apache.atlas.typesystem.ITypedReferenceableInstance
;
import
org.apache.atlas.typesystem.ITypedStruct
;
...
...
@@ -78,11 +62,28 @@ import org.testng.annotations.BeforeMethod;
import
org.testng.annotations.Guice
;
import
org.testng.annotations.Test
;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.ImmutableSet
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.UUID
;
import
java.util.concurrent.Callable
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.Future
;
import
javax.inject.Inject
;
import
scala.actors.threadpool.Arrays
;
import
static
org
.
apache
.
atlas
.
typesystem
.
types
.
utils
.
TypesUtil
.
createClassTypeDef
;
import
static
org
.
apache
.
atlas
.
typesystem
.
types
.
utils
.
TypesUtil
.
createUniqueRequiredAttrDef
;
import
static
org
.
testng
.
Assert
.
assertEquals
;
import
static
org
.
testng
.
Assert
.
assertNotEquals
;
import
static
org
.
testng
.
Assert
.
assertNotNull
;
import
static
org
.
testng
.
Assert
.
assertTrue
;
/**
* GraphBackedMetadataRepository test
*
...
...
@@ -107,7 +108,7 @@ public class GraphBackedMetadataRepositoryTest {
typeSystem
=
TypeSystem
.
getInstance
();
typeSystem
.
reset
();
new
GraphBackedSearchIndexer
();
new
GraphBackedSearchIndexer
(
new
AtlasTypeRegistry
()
);
TestUtils
.
defineDeptEmployeeTypes
(
typeSystem
);
TestUtils
.
createHiveTypes
(
typeSystem
);
...
...
repository/src/test/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexerMockTest.java
View file @
0b85d5a0
...
...
@@ -18,10 +18,6 @@
package
org
.
apache
.
atlas
.
repository
.
graph
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
verifyZeroInteractions
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.ha.HAConfiguration
;
import
org.apache.atlas.repository.Constants
;
...
...
@@ -29,12 +25,17 @@ import org.apache.atlas.repository.IndexException;
import
org.apache.atlas.repository.RepositoryException
;
import
org.apache.atlas.repository.graphdb.AtlasGraph
;
import
org.apache.atlas.repository.graphdb.AtlasGraphManagement
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.commons.configuration.Configuration
;
import
org.mockito.Mock
;
import
org.mockito.MockitoAnnotations
;
import
org.testng.annotations.BeforeMethod
;
import
org.testng.annotations.Test
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
verifyZeroInteractions
;
import
static
org
.
mockito
.
Mockito
.
when
;
public
class
GraphBackedSearchIndexerMockTest
implements
IAtlasGraphProvider
{
@Mock
...
...
@@ -46,6 +47,9 @@ public class GraphBackedSearchIndexerMockTest implements IAtlasGraphProvider {
@Mock
private
AtlasGraphManagement
management
;
@Mock
private
AtlasTypeRegistry
typeRegistry
;
@BeforeMethod
public
void
setup
()
{
MockitoAnnotations
.
initMocks
(
this
);
...
...
@@ -57,7 +61,7 @@ public class GraphBackedSearchIndexerMockTest implements IAtlasGraphProvider {
when
(
graph
.
getManagementSystem
()).
thenReturn
(
management
);
when
(
management
.
containsPropertyKey
(
Constants
.
VERTEX_TYPE_PROPERTY_KEY
)).
thenReturn
(
true
);
GraphBackedSearchIndexer
graphBackedSearchIndexer
=
new
GraphBackedSearchIndexer
(
this
,
configuration
);
GraphBackedSearchIndexer
graphBackedSearchIndexer
=
new
GraphBackedSearchIndexer
(
this
,
configuration
,
typeRegistry
);
verify
(
management
).
containsPropertyKey
(
Constants
.
VERTEX_TYPE_PROPERTY_KEY
);
}
...
...
@@ -69,7 +73,7 @@ public class GraphBackedSearchIndexerMockTest implements IAtlasGraphProvider {
when
(
graph
.
getManagementSystem
()).
thenReturn
(
management
);
when
(
management
.
containsPropertyKey
(
Constants
.
VERTEX_TYPE_PROPERTY_KEY
)).
thenReturn
(
true
);
new
GraphBackedSearchIndexer
(
this
,
configuration
);
new
GraphBackedSearchIndexer
(
this
,
configuration
,
typeRegistry
);
verifyZeroInteractions
(
management
);
}
...
...
@@ -81,7 +85,7 @@ public class GraphBackedSearchIndexerMockTest implements IAtlasGraphProvider {
when
(
graph
.
getManagementSystem
()).
thenReturn
(
management
);
when
(
management
.
containsPropertyKey
(
Constants
.
VERTEX_TYPE_PROPERTY_KEY
)).
thenReturn
(
true
);
GraphBackedSearchIndexer
graphBackedSearchIndexer
=
new
GraphBackedSearchIndexer
(
this
,
configuration
);
GraphBackedSearchIndexer
graphBackedSearchIndexer
=
new
GraphBackedSearchIndexer
(
this
,
configuration
,
typeRegistry
);
graphBackedSearchIndexer
.
instanceIsActive
();
verify
(
management
).
containsPropertyKey
(
Constants
.
VERTEX_TYPE_PROPERTY_KEY
);
...
...
repository/src/test/java/org/apache/atlas/repository/graph/GraphHelperTest.java
View file @
0b85d5a0
...
...
@@ -18,26 +18,13 @@
package
org
.
apache
.
atlas
.
repository
.
graph
;
import
static
org
.
testng
.
Assert
.
assertEquals
;
import
static
org
.
testng
.
Assert
.
assertFalse
;
import
static
org
.
testng
.
Assert
.
assertNotNull
;
import
static
org
.
testng
.
Assert
.
assertNull
;
import
static
org
.
testng
.
Assert
.
assertTrue
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Set
;
import
javax.inject.Inject
;
import
org.apache.atlas.RepositoryMetadataModule
;
import
org.apache.atlas.TestUtils
;
import
org.apache.atlas.repository.graph.GraphHelper.VertexInfo
;
import
org.apache.atlas.repository.graphdb.AtlasEdge
;
import
org.apache.atlas.repository.graphdb.AtlasGraph
;
import
org.apache.atlas.repository.graphdb.AtlasVertex
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.atlas.typesystem.ITypedReferenceableInstance
;
import
org.apache.atlas.typesystem.types.TypeSystem
;
import
org.testng.Assert
;
...
...
@@ -47,6 +34,20 @@ import org.testng.annotations.DataProvider;
import
org.testng.annotations.Guice
;
import
org.testng.annotations.Test
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Set
;
import
javax.inject.Inject
;
import
static
org
.
testng
.
Assert
.
assertEquals
;
import
static
org
.
testng
.
Assert
.
assertFalse
;
import
static
org
.
testng
.
Assert
.
assertNotNull
;
import
static
org
.
testng
.
Assert
.
assertNull
;
import
static
org
.
testng
.
Assert
.
assertTrue
;
@Guice
(
modules
=
RepositoryMetadataModule
.
class
)
public
class
GraphHelperTest
{
...
...
@@ -72,12 +73,15 @@ public class GraphHelperTest {
private
TypeSystem
typeSystem
;
@Inject
private
AtlasTypeRegistry
typeRegistry
;
@BeforeClass
public
void
setUp
()
throws
Exception
{
typeSystem
=
TypeSystem
.
getInstance
();
typeSystem
.
reset
();
new
GraphBackedSearchIndexer
();
new
GraphBackedSearchIndexer
(
typeRegistry
);
TestUtils
.
defineDeptEmployeeTypes
(
typeSystem
);
}
...
...
repository/src/test/java/org/apache/atlas/repository/graph/GraphRepoMapperScaleTest.java
View file @
0b85d5a0
...
...
@@ -18,13 +18,6 @@
package
org
.
apache
.
atlas
.
repository
.
graph
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Date
;
import
java.util.Iterator
;
import
javax.inject.Inject
;
import
org.apache.atlas.ApplicationProperties
;
import
org.apache.atlas.GraphTransaction
;
import
org.apache.atlas.RepositoryMetadataModule
;
...
...
@@ -35,6 +28,7 @@ import org.apache.atlas.repository.graphdb.AtlasGraphQuery;
import
org.apache.atlas.repository.graphdb.AtlasGraphQuery.ComparisionOperator
;
import
org.apache.atlas.repository.graphdb.AtlasIndexQuery
;
import
org.apache.atlas.repository.graphdb.AtlasVertex
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.atlas.typesystem.ITypedReferenceableInstance
;
import
org.apache.atlas.typesystem.Referenceable
;
import
org.apache.atlas.typesystem.Struct
;
...
...
@@ -50,6 +44,13 @@ import org.testng.annotations.BeforeMethod;
import
org.testng.annotations.Guice
;
import
org.testng.annotations.Test
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Date
;
import
java.util.Iterator
;
import
javax.inject.Inject
;
@Test
@Guice
(
modules
=
RepositoryMetadataModule
.
class
)
public
class
GraphRepoMapperScaleTest
{
...
...
@@ -72,7 +73,7 @@ public class GraphRepoMapperScaleTest {
public
void
setUp
()
throws
Exception
{
//force up front graph initialization
TestUtils
.
getGraph
();
searchIndexer
=
new
GraphBackedSearchIndexer
(
new
AtlasGraphProvider
(),
ApplicationProperties
.
get
());
searchIndexer
=
new
GraphBackedSearchIndexer
(
new
AtlasGraphProvider
(),
ApplicationProperties
.
get
()
,
new
AtlasTypeRegistry
()
);
//Make sure we can cleanup the index directory
Collection
<
IDataType
>
typesAdded
=
TestUtils
.
createHiveTypes
(
typeSystem
);
searchIndexer
.
onAdd
(
typesAdded
);
...
...
repository/src/test/java/org/apache/atlas/service/DefaultMetadataServiceTest.java
View file @
0b85d5a0
...
...
@@ -18,29 +18,9 @@
package
org
.
apache
.
atlas
.
service
;
import
static
org
.
apache
.
atlas
.
TestUtils
.
COLUMNS_ATTR_NAME
;
import
static
org
.
apache
.
atlas
.
TestUtils
.
COLUMN_TYPE
;
import
static
org
.
apache
.
atlas
.
TestUtils
.
PII
;
import
static
org
.
apache
.
atlas
.
TestUtils
.
TABLE_TYPE
;
import
static
org
.
apache
.
atlas
.
TestUtils
.
createColumnEntity
;
import
static
org
.
apache
.
atlas
.
TestUtils
.
createDBEntity
;
import
static
org
.
apache
.
atlas
.
TestUtils
.
createInstance
;
import
static
org
.
apache
.
atlas
.
TestUtils
.
createTableEntity
;
import
static
org
.
apache
.
atlas
.
TestUtils
.
randomString
;
import
static
org
.
apache
.
atlas
.
typesystem
.
types
.
utils
.
TypesUtil
.
createClassTypeDef
;
import
static
org
.
apache
.
atlas
.
typesystem
.
types
.
utils
.
TypesUtil
.
createOptionalAttrDef
;
import
static
org
.
testng
.
Assert
.
assertEquals
;
import
static
org
.
testng
.
Assert
.
assertNotNull
;
import
static
org
.
testng
.
Assert
.
assertNull
;
import
static
org
.
testng
.
Assert
.
assertTrue
;
import
static
org
.
testng
.
Assert
.
fail
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.ImmutableSet
;
import
com.google.inject.Inject
;
import
org.apache.atlas.AtlasClient
;
import
org.apache.atlas.AtlasException
;
...
...
@@ -49,12 +29,15 @@ import org.apache.atlas.RepositoryMetadataModule;
import
org.apache.atlas.RequestContext
;
import
org.apache.atlas.TestUtils
;
import
org.apache.atlas.discovery.graph.GraphBackedDiscoveryService
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.listener.ChangedTypeDefs
;
import
org.apache.atlas.listener.EntityChangeListener
;
import
org.apache.atlas.query.QueryParams
;
import
org.apache.atlas.repository.audit.EntityAuditRepository
;
import
org.apache.atlas.repository.audit.HBaseBasedAuditRepository
;
import
org.apache.atlas.repository.audit.HBaseTestUtils
;
import
org.apache.atlas.repository.graph.AtlasGraphProvider
;
import
org.apache.atlas.services.DefaultMetadataService
;
import
org.apache.atlas.services.MetadataService
;
import
org.apache.atlas.typesystem.IReferenceableInstance
;
import
org.apache.atlas.typesystem.IStruct
;
...
...
@@ -75,6 +58,7 @@ import org.apache.atlas.typesystem.types.HierarchicalTypeDefinition;
import
org.apache.atlas.typesystem.types.Multiplicity
;
import
org.apache.atlas.typesystem.types.TypeSystem
;
import
org.apache.atlas.typesystem.types.ValueConversionException
;
import
org.apache.atlas.typesystem.types.cache.TypeCache
;
import
org.apache.atlas.typesystem.types.utils.TypesUtil
;
import
org.apache.atlas.utils.ParamChecker
;
import
org.apache.commons.lang.RandomStringUtils
;
...
...
@@ -87,9 +71,29 @@ import org.testng.annotations.BeforeTest;
import
org.testng.annotations.Guice
;
import
org.testng.annotations.Test
;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.ImmutableSet
;
import
com.google.inject.Inject
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
static
org
.
apache
.
atlas
.
TestUtils
.
COLUMNS_ATTR_NAME
;
import
static
org
.
apache
.
atlas
.
TestUtils
.
COLUMN_TYPE
;
import
static
org
.
apache
.
atlas
.
TestUtils
.
PII
;
import
static
org
.
apache
.
atlas
.
TestUtils
.
TABLE_TYPE
;
import
static
org
.
apache
.
atlas
.
TestUtils
.
createColumnEntity
;
import
static
org
.
apache
.
atlas
.
TestUtils
.
createDBEntity
;
import
static
org
.
apache
.
atlas
.
TestUtils
.
createInstance
;
import
static
org
.
apache
.
atlas
.
TestUtils
.
createTableEntity
;
import
static
org
.
apache
.
atlas
.
TestUtils
.
randomString
;
import
static
org
.
apache
.
atlas
.
typesystem
.
types
.
utils
.
TypesUtil
.
createClassTypeDef
;
import
static
org
.
apache
.
atlas
.
typesystem
.
types
.
utils
.
TypesUtil
.
createOptionalAttrDef
;
import
static
org
.
testng
.
Assert
.
assertEquals
;
import
static
org
.
testng
.
Assert
.
assertNotNull
;
import
static
org
.
testng
.
Assert
.
assertNull
;
import
static
org
.
testng
.
Assert
.
assertTrue
;
import
static
org
.
testng
.
Assert
.
fail
;
@Guice
(
modules
=
RepositoryMetadataModule
.
class
)
public
class
DefaultMetadataServiceTest
{
...
...
@@ -1131,6 +1135,22 @@ public class DefaultMetadataServiceTest {
}
}
@Test
public
void
testOnChangeRefresh
()
{
try
{
List
<
String
>
beforeChangeTypeNames
=
metadataService
.
getTypeNames
(
new
HashMap
<
TypeCache
.
TYPE_FILTER
,
String
>());
((
DefaultMetadataService
)
metadataService
).
onChange
(
new
ChangedTypeDefs
());
List
<
String
>
afterChangeTypeNames
=
metadataService
.
getTypeNames
(
new
HashMap
<
TypeCache
.
TYPE_FILTER
,
String
>());
assertEquals
(
afterChangeTypeNames
,
beforeChangeTypeNames
);
}
catch
(
AtlasBaseException
e
)
{
fail
(
"Should've succeeded"
,
e
);
}
catch
(
AtlasException
e
)
{
fail
(
"getTypeNames should've succeeded"
,
e
);
}
}
private
static
class
EntitiesChangeListener
implements
EntityChangeListener
{
private
List
<
String
>
deletedEntities
=
new
ArrayList
<>();
private
List
<
String
>
updatedEntities
=
new
ArrayList
<>();
...
...
repository/src/test/scala/org/apache/atlas/query/QueryTestsUtils.scala
View file @
0b85d5a0
...
...
@@ -74,7 +74,8 @@ trait GraphUtils {
object
QueryTestsUtils
extends
GraphUtils
{
def
setupTypesAndIndices
()
:
Unit
=
{
val
indexer
=
new
GraphBackedSearchIndexer
();
// FIXME: Do we need to init the AtlasTypeRegistry here ?
val
indexer
=
new
GraphBackedSearchIndexer
(
null
);
val
typesDef
:
TypesDef
=
defineTypes
;
val
newTypes
=
TypeSystem
.
getInstance
.
defineTypes
(
typesDef
);
indexer
.
onAdd
(
newTypes
.
values
());
...
...
typesystem/pom.xml
View file @
0b85d5a0
...
...
@@ -116,6 +116,10 @@
<groupId>
org.apache.commons
</groupId>
<artifactId>
commons-lang3
</artifactId>
</dependency>
<dependency>
<groupId>
org.apache.atlas
</groupId>
<artifactId>
atlas-intg
</artifactId>
</dependency>
</dependencies>
<build>
...
...
typesystem/src/main/java/org/apache/atlas/typesystem/types/TypeSystem.java
View file @
0b85d5a0
...
...
@@ -20,6 +20,7 @@ package org.apache.atlas.typesystem.types;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.ImmutableSet
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.classification.InterfaceAudience
;
import
org.apache.atlas.typesystem.TypesDef
;
...
...
@@ -30,7 +31,6 @@ import org.apache.atlas.typesystem.types.cache.TypeCache;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
javax.inject.Singleton
;
import
java.lang.reflect.Constructor
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
...
...
@@ -41,6 +41,8 @@ import java.util.Set;
import
java.util.TimeZone
;
import
java.util.concurrent.ConcurrentHashMap
;
import
javax.inject.Singleton
;
@Singleton
@InterfaceAudience
.
Private
public
class
TypeSystem
{
...
...
webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java
View file @
0b85d5a0
...
...
@@ -31,7 +31,6 @@ import org.apache.atlas.model.typedef.AtlasStructDef;
import
org.apache.atlas.model.typedef.AtlasStructDef.AtlasStructDefs
;
import
org.apache.atlas.model.typedef.AtlasTypesDef
;
import
org.apache.atlas.store.AtlasTypeDefStore
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.atlas.web.util.Servlets
;
import
org.apache.http.annotation.Experimental
;
import
org.slf4j.Logger
;
...
...
webapp/src/main/java/org/apache/atlas/web/service/ActiveInstanceElectorModule.java
View file @
0b85d5a0
...
...
@@ -24,6 +24,7 @@ import org.apache.atlas.listener.ActiveStateChangeHandler;
import
org.apache.atlas.notification.NotificationHookConsumer
;
import
org.apache.atlas.repository.audit.HBaseBasedAuditRepository
;
import
org.apache.atlas.repository.graph.GraphBackedSearchIndexer
;
import
org.apache.atlas.repository.store.graph.v1.AtlasTypeDefGraphStoreV1
;
import
org.apache.atlas.service.Service
;
import
org.apache.atlas.services.DefaultMetadataService
;
...
...
@@ -41,6 +42,7 @@ public class ActiveInstanceElectorModule extends AbstractModule {
activeStateChangeHandlerBinder
.
addBinding
().
to
(
DefaultMetadataService
.
class
);
activeStateChangeHandlerBinder
.
addBinding
().
to
(
NotificationHookConsumer
.
class
);
activeStateChangeHandlerBinder
.
addBinding
().
to
(
HBaseBasedAuditRepository
.
class
);
activeStateChangeHandlerBinder
.
addBinding
().
to
(
AtlasTypeDefGraphStoreV1
.
class
);
Multibinder
<
Service
>
serviceBinder
=
Multibinder
.
newSetBinder
(
binder
(),
Service
.
class
);
serviceBinder
.
addBinding
().
to
(
ActiveInstanceElectorService
.
class
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment