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
7 years ago
by
rmani
Committed by
Madhan Neethiraj
7 years ago
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
master
No related merge requests found
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
14 deletions
+38
-14
HBaseAtlasHook.java
...in/java/org/apache/atlas/hbase/bridge/HBaseAtlasHook.java
+18
-6
HBaseAtlasHookIT.java
...rc/test/java/org/apache/atlas/hbase/HBaseAtlasHookIT.java
+20
-8
No files found.
addons/hbase-bridge/src/main/java/org/apache/atlas/hbase/bridge/HBaseAtlasHook.java
View file @
92b96657
...
...
@@ -374,7 +374,11 @@ 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
)
{
return
String
.
format
(
"%s.%s.%s@%s"
,
nameSpace
.
toLowerCase
(),
stripNameSpace
(
tableName
.
toLowerCase
()),
columnFamily
.
toLowerCase
(),
clusterName
);
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
);
}
}
/**
...
...
@@ -386,7 +390,11 @@ 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
)
{
return
String
.
format
(
"%s.%s@%s"
,
nameSpace
.
toLowerCase
(),
stripNameSpace
(
tableName
.
toLowerCase
()),
clusterName
);
if
(
clusterName
==
null
||
nameSpace
==
null
||
tableName
==
null
)
{
return
null
;
}
else
{
return
String
.
format
(
"%s.%s@%s"
,
nameSpace
.
toLowerCase
(),
stripNameSpace
(
tableName
.
toLowerCase
()),
clusterName
);
}
}
/**
...
...
@@ -397,7 +405,11 @@ 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
)
{
return
String
.
format
(
"%s@%s"
,
nameSpace
.
toLowerCase
(),
clusterName
);
if
(
clusterName
==
null
||
nameSpace
==
null
)
{
return
null
;
}
else
{
return
String
.
format
(
"%s@%s"
,
nameSpace
.
toLowerCase
(),
clusterName
);
}
}
private
static
String
stripNameSpace
(
String
tableName
)
{
...
...
@@ -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
;
...
...
This diff is collapsed.
Click to expand it.
addons/hbase-bridge/src/test/java/org/apache/atlas/hbase/HBaseAtlasHookIT.java
View file @
92b96657
...
...
@@ -90,11 +90,17 @@ public class HBaseAtlasHookIT {
admin
.
createNamespace
(
ns
);
//assert on qualified name
String
nameSpace
=
assertNameSpaceIsRegistered
(
ns
.
getName
());
AtlasEntityWithExtInfo
nameSpaceRef
=
getAtlasClient
().
getEntityByGuid
(
nameSpace
);
String
nameSpaceQualifiedName
=
HBaseAtlasHook
.
getNameSpaceQualifiedName
(
CLUSTER_NAME
,
ns
.
getName
());
String
nameSpace
=
assertNameSpaceIsRegistered
(
ns
.
getName
());
AtlasClientV2
atlasClient
=
getAtlasClient
();
Assert
.
assertEquals
(
nameSpaceRef
.
getEntity
().
getAttribute
(
AtlasClient
.
REFERENCEABLE_ATTRIBUTE_NAME
),
nameSpaceQualifiedName
);
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
...
...
@@ -124,11 +130,17 @@ public class HBaseAtlasHookIT {
}
//assert on qualified name
String
table
=
assertTableIsRegistered
(
namespace
,
tablename
);
AtlasEntityWithExtInfo
tableRef
=
getAtlasClient
().
getEntityByGuid
(
table
);
String
entityName
=
HBaseAtlasHook
.
getTableQualifiedName
(
CLUSTER_NAME
,
namespace
,
tablename
);
String
table
=
assertTableIsRegistered
(
namespace
,
tablename
);
AtlasClientV2
atlasClient
=
getAtlasClient
();
Assert
.
assertEquals
(
tableRef
.
getEntity
().
getAttribute
(
AtlasClient
.
REFERENCEABLE_ATTRIBUTE_NAME
),
entityName
);
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
...
...
This diff is collapsed.
Click to expand it.
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