incubator-atlas git commit: ATLAS-1948: export fix to correct the import order

2017-07-19 Thread madhan
Repository: incubator-atlas
Updated Branches:
  refs/heads/0.8-incubating 7592bd4f3 -> 40d59a32d


ATLAS-1948: export fix to correct the import order

Signed-off-by: Madhan Neethiraj 
(cherry picked from commit 24a106b4e1a1581b266a453cc6c920bcd06d7a9b)


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

Branch: refs/heads/0.8-incubating
Commit: 40d59a32dddbfa2a263f79e4fa217a59a928d376
Parents: 7592bd4
Author: ashutoshm 
Authored: Tue Jul 18 17:08:34 2017 -0700
Committer: Madhan Neethiraj 
Committed: Wed Jul 19 00:56:08 2017 -0700

--
 .../atlas/repository/impexp/ExportService.java  |  22 ++--
 .../atlas/repository/impexp/ZipSource.java  |   2 +-
 .../store/graph/v1/AtlasEntityStoreV1.java  | 119 ++-
 .../repository/impexp/ImportServiceTest.java|  24 +++-
 repository/src/test/resources/ctas.zip  | Bin 0 -> 7674 bytes
 5 files changed, 124 insertions(+), 43 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/40d59a32/repository/src/main/java/org/apache/atlas/repository/impexp/ExportService.java
--
diff --git 
a/repository/src/main/java/org/apache/atlas/repository/impexp/ExportService.java
 
b/repository/src/main/java/org/apache/atlas/repository/impexp/ExportService.java
index 8f45e9f..de48573 100644
--- 
a/repository/src/main/java/org/apache/atlas/repository/impexp/ExportService.java
+++ 
b/repository/src/main/java/org/apache/atlas/repository/impexp/ExportService.java
@@ -98,7 +98,6 @@ public class ExportService {
 AtlasExportResult.OperationStatus[] statuses = 
processItems(request, context);
 
 processTypesDef(context);
-
 updateSinkWithOperationMetrics(context, statuses, 
getOperationDuration(startTime));
 } catch(Exception ex) {
 LOG.error("Operation failed: ", ex);
@@ -113,6 +112,7 @@ public class ExportService {
 }
 
 private void updateSinkWithOperationMetrics(ExportContext context, 
AtlasExportResult.OperationStatus[] statuses, int duration) throws 
AtlasBaseException {
+
context.result.getData().getEntityCreationOrder().addAll(context.lineageProcessed);
 
context.sink.setExportOrder(context.result.getData().getEntityCreationOrder());
 context.sink.setTypesDef(context.result.getData().getTypesDef());
 clearContextData(context);
@@ -201,9 +201,10 @@ public class ExportService {
 processEntity(guid, context);
 }
 
-if (!context.guidsLineageToProcess.isEmpty()) {
-
context.guidsToProcess.addAll(context.guidsLineageToProcess);
-context.guidsLineageToProcess.clear();
+if (!context.lineageToProcess.isEmpty()) {
+context.guidsToProcess.addAll(context.lineageToProcess);
+
context.lineageProcessed.addAll(context.lineageToProcess.getList());
+context.lineageToProcess.clear();
 }
 }
 } catch (AtlasBaseException excp) {
@@ -295,7 +296,9 @@ public class ExportService {
 TraversalDirection  direction = 
context.guidDirection.get(guid);
 AtlasEntityWithExtInfo  entityWithExtInfo = 
entityGraphRetriever.toAtlasEntityWithExtInfo(guid);
 
-
context.result.getData().getEntityCreationOrder().add(entityWithExtInfo.getEntity().getGuid());
+if(!context.lineageProcessed.contains(guid)) {
+
context.result.getData().getEntityCreationOrder().add(entityWithExtInfo.getEntity().getGuid());
+}
 
 addEntity(entityWithExtInfo, context);
 addTypes(entityWithExtInfo.getEntity(), context);
@@ -651,13 +654,18 @@ public class ExportService {
 list.clear();
 set.clear();
 }
+
+public List getList() {
+return list;
+}
 }
 
 
 private class ExportContext {
 final Set guidsProcessed = new HashSet<>();
 final UniqueList  guidsToProcess = new 
UniqueList<>();
-final UniqueList  guidsLineageToProcess = new 
UniqueList<>();
+final UniqueList  lineageToProcess = new 
UniqueList<>();
+final Set lineageProcessed = new 
HashSet<>();
 final Map guidDirection  = new HashMap<>();
 final Set entityTypes = new 
HashSet<>();

incubator-atlas git commit: ATLAS-1948: export fix to correct the import order

2017-07-19 Thread madhan
Repository: incubator-atlas
Updated Branches:
  refs/heads/master cfb6b84f4 -> 24a106b4e


ATLAS-1948: export fix to correct the import order

Signed-off-by: Madhan Neethiraj 


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

Branch: refs/heads/master
Commit: 24a106b4e1a1581b266a453cc6c920bcd06d7a9b
Parents: cfb6b84
Author: ashutoshm 
Authored: Tue Jul 18 17:08:34 2017 -0700
Committer: Madhan Neethiraj 
Committed: Wed Jul 19 00:50:14 2017 -0700

--
 .../atlas/repository/impexp/ExportService.java  |  22 ++--
 .../atlas/repository/impexp/ZipSource.java  |   2 +-
 .../store/graph/v1/AtlasEntityStoreV1.java  | 119 ++-
 .../repository/impexp/ImportServiceTest.java|  24 +++-
 repository/src/test/resources/ctas.zip  | Bin 0 -> 7674 bytes
 5 files changed, 124 insertions(+), 43 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/24a106b4/repository/src/main/java/org/apache/atlas/repository/impexp/ExportService.java
--
diff --git 
a/repository/src/main/java/org/apache/atlas/repository/impexp/ExportService.java
 
b/repository/src/main/java/org/apache/atlas/repository/impexp/ExportService.java
index 8f45e9f..de48573 100644
--- 
a/repository/src/main/java/org/apache/atlas/repository/impexp/ExportService.java
+++ 
b/repository/src/main/java/org/apache/atlas/repository/impexp/ExportService.java
@@ -98,7 +98,6 @@ public class ExportService {
 AtlasExportResult.OperationStatus[] statuses = 
processItems(request, context);
 
 processTypesDef(context);
-
 updateSinkWithOperationMetrics(context, statuses, 
getOperationDuration(startTime));
 } catch(Exception ex) {
 LOG.error("Operation failed: ", ex);
@@ -113,6 +112,7 @@ public class ExportService {
 }
 
 private void updateSinkWithOperationMetrics(ExportContext context, 
AtlasExportResult.OperationStatus[] statuses, int duration) throws 
AtlasBaseException {
+
context.result.getData().getEntityCreationOrder().addAll(context.lineageProcessed);
 
context.sink.setExportOrder(context.result.getData().getEntityCreationOrder());
 context.sink.setTypesDef(context.result.getData().getTypesDef());
 clearContextData(context);
@@ -201,9 +201,10 @@ public class ExportService {
 processEntity(guid, context);
 }
 
-if (!context.guidsLineageToProcess.isEmpty()) {
-
context.guidsToProcess.addAll(context.guidsLineageToProcess);
-context.guidsLineageToProcess.clear();
+if (!context.lineageToProcess.isEmpty()) {
+context.guidsToProcess.addAll(context.lineageToProcess);
+
context.lineageProcessed.addAll(context.lineageToProcess.getList());
+context.lineageToProcess.clear();
 }
 }
 } catch (AtlasBaseException excp) {
@@ -295,7 +296,9 @@ public class ExportService {
 TraversalDirection  direction = 
context.guidDirection.get(guid);
 AtlasEntityWithExtInfo  entityWithExtInfo = 
entityGraphRetriever.toAtlasEntityWithExtInfo(guid);
 
-
context.result.getData().getEntityCreationOrder().add(entityWithExtInfo.getEntity().getGuid());
+if(!context.lineageProcessed.contains(guid)) {
+
context.result.getData().getEntityCreationOrder().add(entityWithExtInfo.getEntity().getGuid());
+}
 
 addEntity(entityWithExtInfo, context);
 addTypes(entityWithExtInfo.getEntity(), context);
@@ -651,13 +654,18 @@ public class ExportService {
 list.clear();
 set.clear();
 }
+
+public List getList() {
+return list;
+}
 }
 
 
 private class ExportContext {
 final Set guidsProcessed = new HashSet<>();
 final UniqueList  guidsToProcess = new 
UniqueList<>();
-final UniqueList  guidsLineageToProcess = new 
UniqueList<>();
+final UniqueList  lineageToProcess = new 
UniqueList<>();
+final Set lineageProcessed = new 
HashSet<>();
 final Map guidDirection  = new HashMap<>();
 final Set entityTypes = new 
HashSet<>();
 final Set classificationTypes = new 
HashSet<>();
@@ -719,7