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/24 15:43:56 UTC

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

Repository: atlas
Updated Branches:
  refs/heads/branch-0.8 ba717c6e4 -> c0dd78d52


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/c0dd78d5
Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/c0dd78d5
Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/c0dd78d5

Branch: refs/heads/branch-0.8
Commit: c0dd78d52e0322b6fdc5381b971e72a828d9872f
Parents: ba717c6
Author: Ashutosh Mestry <am...@hortonworks.com>
Authored: Sun Sep 23 22:51:08 2018 -0700
Committer: Ashutosh Mestry <am...@hortonworks.com>
Committed: Sun Sep 23 22:51:08 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/c0dd78d5/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 f3f49c9..80d1b4f 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;
-        }
     }
 }