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
420983d5
Commit
420983d5
authored
Dec 01, 2020
by
Deep Singh
Committed by
Sarath Subramanian
Dec 02, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-3966 Consider newer value for atlas.metadata.namespace if defined multiple times
Signed-off-by:
Sarath Subramanian
<
sarath@apache.org
>
parent
cbc34271
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
60 additions
and
11 deletions
+60
-11
HBaseBridge.java
.../main/java/org/apache/atlas/hbase/bridge/HBaseBridge.java
+2
-1
HiveMetaStoreBridge.java
...ava/org/apache/atlas/hive/bridge/HiveMetaStoreBridge.java
+2
-1
KafkaBridge.java
.../main/java/org/apache/atlas/kafka/bridge/KafkaBridge.java
+2
-1
SqoopHook.java
.../src/main/java/org/apache/atlas/sqoop/hook/SqoopHook.java
+3
-1
AtlasConfigurationUtil.java
...n/java/org/apache/atlas/utils/AtlasConfigurationUtil.java
+36
-0
ApplicationPropertiesTest.java
...test/java/org/apache/atlas/ApplicationPropertiesTest.java
+10
-5
test.properties
intg/src/test/resources/test.properties
+3
-0
AtlasHook.java
...cation/src/main/java/org/apache/atlas/hook/AtlasHook.java
+2
-2
No files found.
addons/hbase-bridge/src/main/java/org/apache/atlas/hbase/bridge/HBaseBridge.java
View file @
420983d5
...
...
@@ -28,6 +28,7 @@ import org.apache.atlas.model.instance.AtlasEntityHeader;
import
org.apache.atlas.model.instance.AtlasObjectId
;
import
org.apache.atlas.model.instance.EntityMutationResponse
;
import
org.apache.atlas.type.AtlasTypeUtil
;
import
org.apache.atlas.utils.AtlasConfigurationUtil
;
import
org.apache.atlas.utils.AuthenticationUtil
;
import
org.apache.commons.cli.BasicParser
;
import
org.apache.commons.cli.CommandLine
;
...
...
@@ -222,7 +223,7 @@ public class HBaseBridge {
}
private
String
getMetadataNamespace
(
Configuration
config
)
{
return
config
.
getString
(
HBASE_METADATA_NAMESPACE
,
getClusterName
(
config
));
return
AtlasConfigurationUtil
.
getRecentString
(
config
,
HBASE_METADATA_NAMESPACE
,
getClusterName
(
config
));
}
private
String
getClusterName
(
Configuration
config
)
{
...
...
addons/hive-bridge/src/main/java/org/apache/atlas/hive/bridge/HiveMetaStoreBridge.java
View file @
420983d5
...
...
@@ -36,6 +36,7 @@ import org.apache.atlas.model.instance.EntityMutations;
import
org.apache.atlas.utils.AtlasPathExtractorUtil
;
import
org.apache.atlas.utils.AuthenticationUtil
;
import
org.apache.atlas.utils.HdfsNameServiceResolver
;
import
org.apache.atlas.utils.AtlasConfigurationUtil
;
import
org.apache.atlas.model.instance.AtlasEntity
;
import
org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo
;
import
org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo
;
...
...
@@ -264,7 +265,7 @@ public class HiveMetaStoreBridge {
}
public
String
getMetadataNamespace
(
Configuration
config
)
{
return
config
.
getString
(
HIVE_METADATA_NAMESPACE
,
getClusterName
(
config
));
return
AtlasConfigurationUtil
.
getRecentString
(
config
,
HIVE_METADATA_NAMESPACE
,
getClusterName
(
config
));
}
private
String
getClusterName
(
Configuration
config
)
{
...
...
addons/kafka-bridge/src/main/java/org/apache/atlas/kafka/bridge/KafkaBridge.java
View file @
420983d5
...
...
@@ -26,6 +26,7 @@ import org.apache.atlas.model.instance.AtlasEntity;
import
org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo
;
import
org.apache.atlas.model.instance.AtlasEntityHeader
;
import
org.apache.atlas.model.instance.EntityMutationResponse
;
import
org.apache.atlas.utils.AtlasConfigurationUtil
;
import
org.apache.atlas.utils.AuthenticationUtil
;
import
org.apache.atlas.utils.KafkaUtils
;
import
org.apache.commons.cli.BasicParser
;
...
...
@@ -167,7 +168,7 @@ public class KafkaBridge {
}
private
String
getMetadataNamespace
(
Configuration
config
)
{
return
config
.
getString
(
KAFKA_METADATA_NAMESPACE
,
getClusterName
(
config
));
return
AtlasConfigurationUtil
.
getRecentString
(
config
,
KAFKA_METADATA_NAMESPACE
,
getClusterName
(
config
));
}
private
String
getClusterName
(
Configuration
config
)
{
...
...
addons/sqoop-bridge/src/main/java/org/apache/atlas/sqoop/hook/SqoopHook.java
View file @
420983d5
...
...
@@ -33,6 +33,7 @@ import org.apache.atlas.model.notification.HookNotification.EntityCreateRequestV
import
org.apache.atlas.model.instance.AtlasObjectId
;
import
org.apache.atlas.sqoop.model.SqoopDataTypes
;
import
org.apache.atlas.type.AtlasTypeUtil
;
import
org.apache.atlas.utils.AtlasConfigurationUtil
;
import
org.apache.commons.configuration.Configuration
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.sqoop.SqoopJobDataPublisher
;
...
...
@@ -86,7 +87,8 @@ public class SqoopHook extends SqoopJobDataPublisher {
public
void
publish
(
SqoopJobDataPublisher
.
Data
data
)
throws
AtlasHookException
{
try
{
Configuration
atlasProperties
=
ApplicationProperties
.
get
();
String
metadataNamespace
=
atlasProperties
.
getString
(
ATLAS_METADATA_NAMESPACE
,
getClusterName
(
atlasProperties
));
String
metadataNamespace
=
AtlasConfigurationUtil
.
getRecentString
(
atlasProperties
,
ATLAS_METADATA_NAMESPACE
,
getClusterName
(
atlasProperties
));
AtlasEntity
entDbStore
=
toSqoopDBStoreEntity
(
data
);
AtlasEntity
entHiveDb
=
toHiveDatabaseEntity
(
metadataNamespace
,
data
.
getHiveDB
());
...
...
intg/src/main/java/org/apache/atlas/utils/AtlasConfigurationUtil.java
0 → 100644
View file @
420983d5
/**
* 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
.
utils
;
import
org.apache.commons.configuration.Configuration
;
public
class
AtlasConfigurationUtil
{
public
static
String
getRecentString
(
Configuration
config
,
String
key
)
{
return
getRecentString
(
config
,
key
,
null
);
}
public
static
String
getRecentString
(
Configuration
config
,
String
key
,
String
defaultValue
)
{
String
ret
=
defaultValue
;
String
[]
arr
=
config
.
getStringArray
(
key
);
if
(
arr
.
length
>
0
)
{
ret
=
arr
[
arr
.
length
-
1
];
}
return
ret
;
}
}
intg/src/test/java/org/apache/atlas/ApplicationPropertiesTest.java
View file @
420983d5
...
...
@@ -18,14 +18,10 @@
package
org
.
apache
.
atlas
;
import
java.io.InputStream
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
import
java.util.AbstractMap
;
import
com.sun.jersey.json.impl.provider.entity.JSONArrayProvider
;
import
org.apache.atlas.utils.AtlasConfigurationUtil
;
import
org.apache.commons.configuration.Configuration
;
import
org.apache.commons.configuration.ConfigurationException
;
import
org.springframework.cache.interceptor.SimpleKey
;
import
org.testng.annotations.Test
;
import
static
org
.
testng
.
Assert
.*;
...
...
@@ -147,4 +143,13 @@ public class ApplicationPropertiesTest {
aProps
.
setDefault
(
defaultKV
,
""
);
assertEquals
(
props
.
getString
(
someKey
),
defaultValue
);
}
@Test
public
void
verifyGetLatesttString
()
throws
AtlasException
{
String
key
=
"atlas.metadata.namespace"
,
old_val
=
"nm-sp-1"
,
new_val
=
"nm-sp-2"
;
Configuration
atlasConf
=
ApplicationProperties
.
get
(
"test.properties"
);
assertEquals
(
atlasConf
.
getString
(
key
),
old_val
);
assertEquals
(
AtlasConfigurationUtil
.
getRecentString
(
atlasConf
,
key
,
old_val
),
new_val
);
assertEquals
(
AtlasConfigurationUtil
.
getRecentString
(
atlasConf
,
"garbage"
,
old_val
),
old_val
);
}
}
intg/src/test/resources/test.properties
View file @
420983d5
...
...
@@ -17,3 +17,6 @@
#
jaas.properties.file
=
atlas-jaas.properties
atlas.metadata.namespace
=
nm-sp-1
atlas.metadata.namespace
=
nm-sp-2
notification/src/main/java/org/apache/atlas/hook/AtlasHook.java
View file @
420983d5
...
...
@@ -26,7 +26,7 @@ import org.apache.atlas.kafka.NotificationProvider;
import
org.apache.atlas.model.notification.HookNotification
;
import
org.apache.atlas.notification.NotificationException
;
import
org.apache.atlas.notification.NotificationInterface
;
import
org.apache.atlas.
security.InMemoryJAASConfiguration
;
import
org.apache.atlas.
utils.AtlasConfigurationUtil
;
import
org.apache.commons.configuration.Configuration
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.hadoop.security.UserGroupInformation
;
...
...
@@ -292,7 +292,7 @@ public abstract class AtlasHook {
}
private
static
String
getMetadataNamespace
(
Configuration
config
)
{
return
config
.
getString
(
CONF_METADATA_NAMESPACE
,
getClusterName
(
config
));
return
AtlasConfigurationUtil
.
getRecentString
(
config
,
CONF_METADATA_NAMESPACE
,
getClusterName
(
config
));
}
private
static
String
getClusterName
(
Configuration
config
)
{
...
...
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