ATLAS-2888: Export & Import Process: Change Marker Removed Inadvertently


Project: http://git-wip-us.apache.org/repos/asf/atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/atlas/commit/9b586e20
Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/9b586e20
Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/9b586e20

Branch: refs/heads/branch-1.0
Commit: 9b586e20b7978e8d60173917c3ad20d7ed463ca7
Parents: 4e7a99c
Author: Ashutosh Mestry <ames...@hortonworks.com>
Authored: Sun Sep 23 22:51:08 2018 -0700
Committer: Ashutosh Mestry <ames...@hortonworks.com>
Committed: Thu Nov 1 15:42:56 2018 -0700

----------------------------------------------------------------------
 .../atlas/repository/impexp/AuditsWriter.java   | 38 ++++++--------------
 1 file changed, 10 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/atlas/blob/9b586e20/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 f72de56..cc10660 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
@@ -130,6 +130,10 @@ public class AuditsWriter {
         return StringUtils.split(fullName, "$")[1];
     }
 
+    private void saveCurrentServer() throws AtlasBaseException {
+        saveServer(getCurrentClusterName(), getCurrentClusterName());
+    }
+
     private class ExportAudits {
         private AtlasExportRequest request;
         private String targetServerName;
@@ -144,8 +148,10 @@ public class AuditsWriter {
             request = result.getRequest();
             replicationOptionState = 
isReplicationOptionSet(request.getOptions(), optionKeyReplicatedTo);
 
-            saveServers();
+            saveCurrentServer();
 
+            targetServerFullName = 
getClusterNameFromOptions(request.getOptions(), optionKeyReplicatedTo);
+            targetServerName = getServerNameFromFullName(targetServerFullName);
             auditService.add(userName, getCurrentClusterName(), 
targetServerName,
                     ExportImportAuditEntry.OPERATION_EXPORT,
                     AtlasType.toJson(result), startTime, endTime, 
!entityGuids.isEmpty());
@@ -157,16 +163,6 @@ public class AuditsWriter {
             updateReplicationAttribute(replicationOptionState, 
targetServerName, targetServerFullName,
                     entityGuids, Constants.ATTR_NAME_REPLICATED_TO, 
result.getChangeMarker());
         }
-
-        private void saveServers() throws AtlasBaseException {
-            saveServer(getCurrentClusterName(), getCurrentClusterName());
-
-            targetServerFullName = 
getClusterNameFromOptions(request.getOptions(), optionKeyReplicatedTo);
-            targetServerName = getServerNameFromFullName(targetServerFullName);
-            if(StringUtils.isNotEmpty(targetServerName)) {
-                saveServer(targetServerName, targetServerFullName);
-            }
-        }
     }
 
     private class ImportAudits {
@@ -183,8 +179,10 @@ public class AuditsWriter {
             request = result.getRequest();
             replicationOptionState = 
isReplicationOptionSet(request.getOptions(), optionKeyReplicatedFrom);
 
-            saveServers();
+            saveCurrentServer();
 
+            sourceServerFullName = 
getClusterNameFromOptions(request.getOptions(), optionKeyReplicatedFrom);
+            sourceServerName = getServerNameFromFullName(sourceServerFullName);
             auditService.add(userName,
                     sourceServerName, getCurrentClusterName(),
                     ExportImportAuditEntry.OPERATION_IMPORT,
@@ -197,21 +195,5 @@ public class AuditsWriter {
             updateReplicationAttribute(replicationOptionState, 
sourceServerName, sourceServerFullName, entityGuids,
                     Constants.ATTR_NAME_REPLICATED_FROM, 
result.getExportResult().getChangeMarker());
         }
-
-        private void saveServers() throws AtlasBaseException {
-            saveServer(getCurrentClusterName(), getCurrentClusterName());
-
-            sourceServerFullName = getClusterNameFromOptionsState();
-            sourceServerName = getServerNameFromFullName(sourceServerFullName);
-            if(StringUtils.isNotEmpty(sourceServerName)) {
-                saveServer(sourceServerName, sourceServerFullName);
-            }
-        }
-
-        private String getClusterNameFromOptionsState() {
-            return replicationOptionState
-                    ? getClusterNameFromOptions(request.getOptions(), 
optionKeyReplicatedFrom)
-                    : StringUtils.EMPTY;
-        }
     }
 }

Reply via email to