You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by am...@apache.org on 2018/09/27 02:24:26 UTC
atlas git commit: ATLAS-2895: Server full name processing
Repository: atlas
Updated Branches:
refs/heads/branch-0.8 20215f3dd -> ab6425e35
ATLAS-2895: Server full name processing
Project: http://git-wip-us.apache.org/repos/asf/atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/atlas/commit/ab6425e3
Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/ab6425e3
Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/ab6425e3
Branch: refs/heads/branch-0.8
Commit: ab6425e35ea781273afca6846677993288e463c9
Parents: 20215f3
Author: Ashutosh Mestry <am...@hortonworks.com>
Authored: Wed Sep 26 14:24:13 2018 -0700
Committer: Ashutosh Mestry <am...@hortonworks.com>
Committed: Wed Sep 26 19:23:40 2018 -0700
----------------------------------------------------------------------
.../apache/atlas/model/impexp/AtlasExportRequest.java | 14 ++++++++------
.../apache/atlas/repository/impexp/AuditsWriter.java | 9 ++++++++-
.../impexp/ReplicationEntityAttributeTest.java | 12 ++++++++++++
3 files changed, 28 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/atlas/blob/ab6425e3/intg/src/main/java/org/apache/atlas/model/impexp/AtlasExportRequest.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/model/impexp/AtlasExportRequest.java b/intg/src/main/java/org/apache/atlas/model/impexp/AtlasExportRequest.java
index 298645b..be726a8 100644
--- a/intg/src/main/java/org/apache/atlas/model/impexp/AtlasExportRequest.java
+++ b/intg/src/main/java/org/apache/atlas/model/impexp/AtlasExportRequest.java
@@ -81,7 +81,7 @@ public class AtlasExportRequest implements Serializable {
}
public String getFetchTypeOptionValue() {
- if(getOptions() == null || !getOptions().containsKey(OPTION_FETCH_TYPE)) {
+ if(MapUtils.isEmpty(getOptions()) || !getOptions().containsKey(OPTION_FETCH_TYPE)) {
return FETCH_TYPE_FULL;
}
@@ -94,7 +94,8 @@ public class AtlasExportRequest implements Serializable {
}
public boolean getSkipLineageOptionValue() {
- if(!getOptions().containsKey(AtlasExportRequest.OPTION_SKIP_LINEAGE)) {
+ if(MapUtils.isEmpty(getOptions()) ||
+ !getOptions().containsKey(AtlasExportRequest.OPTION_SKIP_LINEAGE)) {
return false;
}
@@ -123,12 +124,13 @@ public class AtlasExportRequest implements Serializable {
}
public long getChangeTokenFromOptions() {
- if(getFetchTypeOptionValue().equalsIgnoreCase(FETCH_TYPE_INCREMENTAL) &&
- getOptions().containsKey(AtlasExportRequest.FETCH_TYPE_INCREMENTAL_CHANGE_MARKER)) {
- return Long.parseLong(getOptions().get(AtlasExportRequest.FETCH_TYPE_INCREMENTAL_CHANGE_MARKER).toString());
+ if (MapUtils.isEmpty(getOptions()) ||
+ !getFetchTypeOptionValue().equalsIgnoreCase(FETCH_TYPE_INCREMENTAL) ||
+ !getOptions().containsKey(AtlasExportRequest.FETCH_TYPE_INCREMENTAL_CHANGE_MARKER)) {
+ return 0L;
}
- return 0L;
+ return Long.parseLong(getOptions().get(AtlasExportRequest.FETCH_TYPE_INCREMENTAL_CHANGE_MARKER).toString());
}
public StringBuilder toString(StringBuilder sb) {
http://git-wip-us.apache.org/repos/asf/atlas/blob/ab6425e3/repository/src/main/java/org/apache/atlas/repository/impexp/AuditsWriter.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/impexp/AuditsWriter.java b/repository/src/main/java/org/apache/atlas/repository/impexp/AuditsWriter.java
index 80d1b4f..20f94dd 100644
--- a/repository/src/main/java/org/apache/atlas/repository/impexp/AuditsWriter.java
+++ b/repository/src/main/java/org/apache/atlas/repository/impexp/AuditsWriter.java
@@ -127,7 +127,14 @@ public class AuditsWriter {
return fullName;
}
- return StringUtils.split(fullName, "$")[1];
+ String[] splits = StringUtils.split(fullName, DC_SERVER_NAME_SEPARATOR);
+ if (splits == null || splits.length < 1) {
+ return "";
+ } else if (splits.length >= 2) {
+ return splits[1];
+ } else {
+ return splits[0];
+ }
}
private void saveCurrentServer() throws AtlasBaseException {
http://git-wip-us.apache.org/repos/asf/atlas/blob/ab6425e3/repository/src/test/java/org/apache/atlas/repository/impexp/ReplicationEntityAttributeTest.java
----------------------------------------------------------------------
diff --git a/repository/src/test/java/org/apache/atlas/repository/impexp/ReplicationEntityAttributeTest.java b/repository/src/test/java/org/apache/atlas/repository/impexp/ReplicationEntityAttributeTest.java
index 9b9bdd9..7c89a04 100644
--- a/repository/src/test/java/org/apache/atlas/repository/impexp/ReplicationEntityAttributeTest.java
+++ b/repository/src/test/java/org/apache/atlas/repository/impexp/ReplicationEntityAttributeTest.java
@@ -123,6 +123,18 @@ public class ReplicationEntityAttributeTest extends ExportImportTestBase {
assertReplicationAttribute(Constants.ATTR_NAME_REPLICATED_TO);
}
+ @Test
+ public void fullServerName() {
+ final String expectedClusterName = "cl1";
+
+ assertEquals(AuditsWriter.getServerNameFromFullName(""), "");
+ assertEquals(AuditsWriter.getServerNameFromFullName(expectedClusterName), expectedClusterName);
+ assertEquals(AuditsWriter.getServerNameFromFullName("SFO$cl1"), expectedClusterName);
+ assertEquals(AuditsWriter.getServerNameFromFullName("cl1$"), expectedClusterName);
+ assertEquals(AuditsWriter.getServerNameFromFullName("$cl1"), expectedClusterName);
+ }
+
+
@Test(dependsOnMethods = "exportWithReplicationToOption_AddsClusterObjectIdToReplicatedFromAttribute")
public void importWithReplicationFromOption_AddsClusterObjectIdToReplicatedFromAttribute() throws AtlasBaseException, IOException {
AtlasImportRequest request = getImportRequestWithReplicationOption();