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
92b96657
Commit
92b96657
authored
Feb 17, 2018
by
rmani
Committed by
Madhan Neethiraj
Feb 17, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-2235: code improvements suggested by static code analysis
Signed-off-by:
Madhan Neethiraj
<
madhan@apache.org
>
parent
3fd57d75
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
5 deletions
+29
-5
HBaseAtlasHook.java
...in/java/org/apache/atlas/hbase/bridge/HBaseAtlasHook.java
+15
-3
HBaseAtlasHookIT.java
...rc/test/java/org/apache/atlas/hbase/HBaseAtlasHookIT.java
+14
-2
No files found.
addons/hbase-bridge/src/main/java/org/apache/atlas/hbase/bridge/HBaseAtlasHook.java
View file @
92b96657
...
...
@@ -374,8 +374,12 @@ public class HBaseAtlasHook extends AtlasHook {
* @return Unique qualified name to identify the Table instance in Atlas.
*/
public
static
String
getColumnFamilyQualifiedName
(
String
clusterName
,
String
nameSpace
,
String
tableName
,
String
columnFamily
)
{
if
(
clusterName
==
null
||
nameSpace
==
null
||
tableName
==
null
||
columnFamily
==
null
)
{
return
null
;
}
else
{
return
String
.
format
(
"%s.%s.%s@%s"
,
nameSpace
.
toLowerCase
(),
stripNameSpace
(
tableName
.
toLowerCase
()),
columnFamily
.
toLowerCase
(),
clusterName
);
}
}
/**
* Construct the qualified name used to uniquely identify a Table instance in Atlas.
...
...
@@ -386,8 +390,12 @@ public class HBaseAtlasHook extends AtlasHook {
* @return Unique qualified name to identify the Table instance in Atlas.
*/
public
static
String
getTableQualifiedName
(
String
clusterName
,
String
nameSpace
,
String
tableName
)
{
if
(
clusterName
==
null
||
nameSpace
==
null
||
tableName
==
null
)
{
return
null
;
}
else
{
return
String
.
format
(
"%s.%s@%s"
,
nameSpace
.
toLowerCase
(),
stripNameSpace
(
tableName
.
toLowerCase
()),
clusterName
);
}
}
/**
* Construct the qualified name used to uniquely identify a HBase NameSpace instance in Atlas.
...
...
@@ -397,8 +405,12 @@ public class HBaseAtlasHook extends AtlasHook {
* @return Unique qualified name to identify the HBase NameSpace instance in Atlas.
*/
public
static
String
getNameSpaceQualifiedName
(
String
clusterName
,
String
nameSpace
)
{
if
(
clusterName
==
null
||
nameSpace
==
null
)
{
return
null
;
}
else
{
return
String
.
format
(
"%s@%s"
,
nameSpace
.
toLowerCase
(),
clusterName
);
}
}
private
static
String
stripNameSpace
(
String
tableName
)
{
return
tableName
.
substring
(
tableName
.
indexOf
(
":"
)
+
1
);
...
...
@@ -765,7 +777,7 @@ public class HBaseAtlasHook extends AtlasHook {
UserGroupInformation
ugi
=
getUGI
();
User
user
=
getActiveUser
();
String
userName
=
user
.
getShortName
()
;
String
userName
=
(
user
!=
null
)
?
user
.
getShortName
()
:
null
;
HBaseOperationContext
hbaseOperationContext
=
new
HBaseOperationContext
(
namespaceDescriptor
,
nameSpace
,
operation
,
ugi
,
userName
,
userName
);
createAtlasInstances
(
hbaseOperationContext
);
...
...
@@ -784,7 +796,7 @@ public class HBaseAtlasHook extends AtlasHook {
UserGroupInformation
ugi
=
getUGI
();
User
user
=
getActiveUser
();
String
userName
=
user
.
getShortName
()
;
String
userName
=
(
user
!=
null
)
?
user
.
getShortName
()
:
null
;
Map
<
String
,
String
>
hbaseConf
=
null
;
String
owner
=
null
;
String
tableNameSpace
=
null
;
...
...
@@ -827,7 +839,7 @@ public class HBaseAtlasHook extends AtlasHook {
UserGroupInformation
ugi
=
getUGI
();
User
user
=
getActiveUser
();
String
userName
=
user
.
getShortName
()
;
String
userName
=
(
user
!=
null
)
?
user
.
getShortName
()
:
null
;
String
owner
=
userName
;
Map
<
String
,
String
>
hbaseConf
=
null
;
...
...
addons/hbase-bridge/src/test/java/org/apache/atlas/hbase/HBaseAtlasHookIT.java
View file @
92b96657
...
...
@@ -91,10 +91,16 @@ public class HBaseAtlasHookIT {
//assert on qualified name
String
nameSpace
=
assertNameSpaceIsRegistered
(
ns
.
getName
());
AtlasEntityWithExtInfo
nameSpaceRef
=
getAtlasClient
().
getEntityByGuid
(
nameSpace
);
AtlasClientV2
atlasClient
=
getAtlasClient
();
if
(
atlasClient
!=
null
)
{
AtlasEntityWithExtInfo
nameSpaceRef
=
atlasClient
.
getEntityByGuid
(
nameSpace
);
String
nameSpaceQualifiedName
=
HBaseAtlasHook
.
getNameSpaceQualifiedName
(
CLUSTER_NAME
,
ns
.
getName
());
Assert
.
assertEquals
(
nameSpaceRef
.
getEntity
().
getAttribute
(
AtlasClient
.
REFERENCEABLE_ATTRIBUTE_NAME
),
nameSpaceQualifiedName
);
}
else
{
Assert
.
fail
(
"Unable to create AtlasClient for Testing"
);
}
}
@Test
...
...
@@ -125,10 +131,16 @@ public class HBaseAtlasHookIT {
//assert on qualified name
String
table
=
assertTableIsRegistered
(
namespace
,
tablename
);
AtlasEntityWithExtInfo
tableRef
=
getAtlasClient
().
getEntityByGuid
(
table
);
AtlasClientV2
atlasClient
=
getAtlasClient
();
if
(
atlasClient
!=
null
)
{
AtlasEntityWithExtInfo
tableRef
=
atlasClient
.
getEntityByGuid
(
table
);
String
entityName
=
HBaseAtlasHook
.
getTableQualifiedName
(
CLUSTER_NAME
,
namespace
,
tablename
);
Assert
.
assertEquals
(
tableRef
.
getEntity
().
getAttribute
(
AtlasClient
.
REFERENCEABLE_ATTRIBUTE_NAME
),
entityName
);
}
else
{
Assert
.
fail
(
"Unable to create AtlasClient for Testing"
);
}
}
// Methods for creating HBase
...
...
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