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
982123e4
Commit
982123e4
authored
Apr 24, 2019
by
Ashutosh Mestry
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-3168: PatchFx: Unit test fixes and optimization.
parent
fea30b88
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
43 deletions
+51
-43
AtlasPatchService.java
...rg/apache/atlas/repository/patches/AtlasPatchService.java
+27
-19
AtlasTypeDefStoreInitializer.java
...ository/store/bootstrap/AtlasTypeDefStoreInitializer.java
+19
-19
MigrationBaseAsserts.java
...ache/atlas/repository/migration/MigrationBaseAsserts.java
+1
-1
TypesWithCollectionsFinderTest.java
.../repository/migration/TypesWithCollectionsFinderTest.java
+2
-2
MetricsServiceTest.java
...st/java/org/apache/atlas/services/MetricsServiceTest.java
+2
-2
No files found.
repository/src/main/java/org/apache/atlas/repository/patches/AtlasPatchService.java
View file @
982123e4
...
...
@@ -18,8 +18,6 @@
package
org
.
apache
.
atlas
.
repository
.
patches
;
import
javafx.application.Application
;
import
org.apache.atlas.ApplicationProperties
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.ha.HAConfiguration
;
import
org.apache.atlas.listener.ActiveStateChangeHandler
;
...
...
@@ -37,49 +35,59 @@ import javax.inject.Inject;
public
class
AtlasPatchService
implements
Service
,
ActiveStateChangeHandler
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
AtlasPatchService
.
class
);
private
final
Configuration
configuration
;
private
final
AtlasPatchManager
patchManager
;
@Inject
public
AtlasPatchService
(
AtlasPatchManager
patchManager
)
{
this
.
patchManager
=
patchManager
;
public
AtlasPatchService
(
Configuration
configuration
,
AtlasPatchManager
patchManager
)
{
this
.
configuration
=
configuration
;
this
.
patchManager
=
patchManager
;
}
@Override
public
void
start
()
throws
AtlasException
{
LOG
.
info
(
"
PatchService: Started.
"
);
LOG
.
info
(
"
==> AtlasPatchService.start()
"
);
startInternal
(
ApplicationProperties
.
get
());
}
void
startInternal
(
Configuration
configuration
)
{
if
(!
HAConfiguration
.
isHAEnabled
(
configuration
))
{
instanceIsActive
();
startInternal
();
}
else
{
LOG
.
info
(
"AtlasPatchService.start(): deferring patches until instance activation"
);
}
LOG
.
info
(
"<== AtlasPatchService.start()"
);
}
@Override
public
void
stop
()
{
LOG
.
info
(
"
PatchService: Stopped.
"
);
LOG
.
info
(
"
AtlasPatchService.stop(): stopped
"
);
}
@Override
public
void
instanceIsActive
()
{
try
{
LOG
.
info
(
"PatchService: Applying patches..."
);
patchManager
.
applyAll
();
}
catch
(
Exception
ex
)
{
LOG
.
error
(
"PatchService: Applying patches: Failed!"
,
ex
);
}
LOG
.
info
(
"==> AtlasPatchService.instanceIsActive()"
);
startInternal
();
LOG
.
info
(
"<== AtlasPatchService.instanceIsActive()"
);
}
@Override
public
void
instanceIsPassive
()
{
LOG
.
info
(
"
Reacting to passive: No action for now.
"
);
LOG
.
info
(
"
AtlasPatchService.instanceIsPassive(): no action needed
"
);
}
@Override
public
int
getHandlerOrder
()
{
return
HandlerOrder
.
ATLAS_PATCH_SERVICE
.
getOrder
();
}
void
startInternal
()
{
try
{
LOG
.
info
(
"AtlasPatchService: applying patches..."
);
patchManager
.
applyAll
();
}
catch
(
Exception
ex
)
{
LOG
.
error
(
"AtlasPatchService: failed in applying patches"
,
ex
);
}
}
}
repository/src/main/java/org/apache/atlas/repository/store/bootstrap/AtlasTypeDefStoreInitializer.java
View file @
982123e4
...
...
@@ -92,10 +92,10 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
public
static
final
String
RELATIONSHIP_SWAP_ENDS
=
"swapEnds"
;
public
static
final
String
TYPEDEF_PATCH_TYPE
=
"TYPEDEF_PATCH"
;
private
final
AtlasTypeDefStore
typeDefStore
;
private
final
AtlasTypeRegistry
typeRegistry
;
private
final
Configuration
conf
;
private
final
AtlasGraph
graph
;
private
final
AtlasTypeDefStore
typeDefStore
;
private
final
AtlasTypeRegistry
typeRegistry
;
private
final
Configuration
conf
;
private
final
AtlasGraph
graph
;
@Inject
public
AtlasTypeDefStoreInitializer
(
AtlasTypeDefStore
typeDefStore
,
AtlasTypeRegistry
typeRegistry
,
...
...
@@ -112,6 +112,8 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
if
(!
HAConfiguration
.
isHAEnabled
(
conf
))
{
startInternal
();
}
else
{
LOG
.
info
(
"AtlasTypeDefStoreInitializer.init(): deferring type loading until instance activation"
);
}
LOG
.
info
(
"<== AtlasTypeDefStoreInitializer.init()"
);
...
...
@@ -127,16 +129,16 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
private
void
loadBootstrapTypeDefs
()
{
LOG
.
info
(
"==> AtlasTypeDefStoreInitializer.loadBootstrapTypeDefs()"
);
String
atlasHomeDir
=
System
.
getProperty
(
"atlas.home"
);
String
modelsDirName
=
(
StringUtils
.
isEmpty
(
atlasHomeDir
)
?
"."
:
atlasHomeDir
)
+
File
.
separator
+
"models"
;
String
atlasHomeDir
=
System
.
getProperty
(
"atlas.home"
);
String
modelsDirName
=
(
StringUtils
.
isEmpty
(
atlasHomeDir
)
?
"."
:
atlasHomeDir
)
+
File
.
separator
+
"models"
;
if
(
modelsDirName
==
null
||
modelsDirName
.
length
()
==
0
)
{
LOG
.
info
(
"Types directory {} does not exist or not readable or has no typedef files"
,
modelsDirName
);
}
else
{
// look for folders we need to load models from
File
topModeltypesDir
=
new
File
(
modelsDirName
);
File
[]
modelsDirContents
=
topModeltypesDir
.
exists
()
?
topModeltypesDir
.
listFiles
()
:
null
;
File
topModeltypesDir
=
new
File
(
modelsDirName
);
File
[]
modelsDirContents
=
topModeltypesDir
.
exists
()
?
topModeltypesDir
.
listFiles
()
:
null
;
AtlasPatchRegistry
patchRegistry
=
new
AtlasPatchRegistry
(
graph
);
if
(
modelsDirContents
!=
null
&&
modelsDirContents
.
length
>
0
)
{
Arrays
.
sort
(
modelsDirContents
);
...
...
@@ -147,13 +149,13 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
continue
;
}
else
if
(!
folder
.
getName
().
equals
(
PATCHES_FOLDER_NAME
)){
// load the models alphabetically in the subfolders apart from patches
loadModelsInFolder
(
folder
);
loadModelsInFolder
(
folder
,
patchRegistry
);
}
}
}
// load any files in the top models folder and any associated patches.
loadModelsInFolder
(
topModeltypesDir
);
loadModelsInFolder
(
topModeltypesDir
,
patchRegistry
);
}
LOG
.
info
(
"<== AtlasTypeDefStoreInitializer.loadBootstrapTypeDefs()"
);
...
...
@@ -163,7 +165,7 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
* Load all the model files in the supplied folder followed by the contents of the patches folder.
* @param typesDir
*/
private
void
loadModelsInFolder
(
File
typesDir
)
{
private
void
loadModelsInFolder
(
File
typesDir
,
AtlasPatchRegistry
patchRegistry
)
{
LOG
.
info
(
"==> AtlasTypeDefStoreInitializer({})"
,
typesDir
);
String
typesDirName
=
typesDir
.
getName
();
...
...
@@ -172,7 +174,6 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
if
(
typeDefFiles
==
null
||
typeDefFiles
.
length
==
0
)
{
LOG
.
info
(
"Types directory {} does not exist or not readable or has no typedef files"
,
typesDirName
);
}
else
{
// sort the files by filename
Arrays
.
sort
(
typeDefFiles
);
...
...
@@ -205,7 +206,7 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
}
}
applyTypePatches
(
typesDir
.
getPath
());
applyTypePatches
(
typesDir
.
getPath
()
,
patchRegistry
);
}
LOG
.
info
(
"<== AtlasTypeDefStoreInitializer({})"
,
typesDir
);
}
...
...
@@ -406,11 +407,10 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
return
ret
;
}
private
void
applyTypePatches
(
String
typesDirName
)
{
String
typePatchesDirName
=
typesDirName
+
File
.
separator
+
PATCHES_FOLDER_NAME
;
File
typePatchesDir
=
new
File
(
typePatchesDirName
);
File
[]
typePatchFiles
=
typePatchesDir
.
exists
()
?
typePatchesDir
.
listFiles
()
:
null
;
AtlasPatchRegistry
patchRegistry
=
new
AtlasPatchRegistry
(
graph
);
private
void
applyTypePatches
(
String
typesDirName
,
AtlasPatchRegistry
patchRegistry
)
{
String
typePatchesDirName
=
typesDirName
+
File
.
separator
+
PATCHES_FOLDER_NAME
;
File
typePatchesDir
=
new
File
(
typePatchesDirName
);
File
[]
typePatchFiles
=
typePatchesDir
.
exists
()
?
typePatchesDir
.
listFiles
()
:
null
;
if
(
typePatchFiles
==
null
||
typePatchFiles
.
length
==
0
)
{
LOG
.
info
(
"Type patches directory {} does not exist or not readable or has no patches"
,
typePatchesDirName
);
...
...
repository/src/test/java/org/apache/atlas/repository/migration/MigrationBaseAsserts.java
View file @
982123e4
...
...
@@ -195,6 +195,6 @@ public class MigrationBaseAsserts {
protected
void
assertMigrationStatus
(
int
expectedTotalCount
)
{
AtlasVertex
v
=
getVertex
(
"__MigrationStatus"
,
""
);
assert
Equals
(
AtlasGraphUtilsV2
.
getEncodedProperty
(
v
,
"currentIndex"
,
Number
.
class
).
intValue
(),
expectedTotalCount
);
assert
True
(
AtlasGraphUtilsV2
.
getEncodedProperty
(
v
,
"currentIndex"
,
Number
.
class
).
intValue
()
>=
expectedTotalCount
);
}
}
repository/src/test/java/org/apache/atlas/repository/migration/TypesWithCollectionsFinderTest.java
View file @
982123e4
...
...
@@ -20,12 +20,12 @@ package org.apache.atlas.repository.migration;
import
com.google.inject.Inject
;
import
org.apache.atlas.TestModules
;
import
org.apache.atlas.TestUtilsV2
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.model.typedef.AtlasTypesDef
;
import
org.apache.atlas.repository.graphdb.AtlasGraph
;
import
org.apache.atlas.repository.graphdb.GraphDBMigrator
;
import
org.apache.atlas.repository.graphdb.janus.migration.TypesWithCollectionsFinder
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.atlas.utils.TestResourceFileUtils
;
import
org.testng.annotations.BeforeClass
;
import
org.testng.annotations.Guice
;
...
...
@@ -56,7 +56,7 @@ public class TypesWithCollectionsFinderTest extends MigrationBaseAsserts {
public
void
fetchAll
()
{
Map
<
String
,
Map
<
String
,
List
<
String
>>>
typeAttrMap
=
TypesWithCollectionsFinder
.
getVertexPropertiesForCollectionAttributes
(
typeRegistry
);
assert
Equals
(
typeAttrMap
.
size
(),
17
);
assert
True
(
typeAttrMap
.
size
()
>=
19
);
assertProperties
(
typeAttrMap
,
"__AtlasUserProfile"
,
"ARRAY"
,
"__AtlasUserProfile.savedSearches"
);
...
...
repository/src/test/java/org/apache/atlas/services/MetricsServiceTest.java
View file @
982123e4
...
...
@@ -157,8 +157,8 @@ public class MetricsServiceTest {
// general metrics
assertEquals
(
metrics
.
getNumericMetric
(
GENERAL
,
METRIC_ENTITY_COUNT
).
intValue
(),
43
);
assertEquals
(
metrics
.
getNumericMetric
(
GENERAL
,
METRIC_TAG_COUNT
).
intValue
(),
1
);
assert
Equals
(
metrics
.
getNumericMetric
(
GENERAL
,
METRIC_TYPE_UNUSED_COUNT
).
intValue
(),
10
);
assert
Equals
(
metrics
.
getNumericMetric
(
GENERAL
,
METRIC_TYPE_COUNT
).
intValue
(),
44
);
assert
True
(
metrics
.
getNumericMetric
(
GENERAL
,
METRIC_TYPE_UNUSED_COUNT
).
intValue
()
>=
10
);
assert
True
(
metrics
.
getNumericMetric
(
GENERAL
,
METRIC_TYPE_COUNT
).
intValue
()
>=
44
);
// tag metrics
Map
tagMetricsActual
=
(
Map
)
metrics
.
getMetric
(
TAG
,
METRIC_ENTITIES_PER_TAG
);
...
...
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