You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2014/03/27 05:21:05 UTC

[2/3] git commit: Reduced entity count for test so it is not so system intensive. Fixed brackets and new naming method errors.

Reduced entity count for test so it is not so system intensive. Fixed brackets and new naming method errors.


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

Branch: refs/pull/82/merge
Commit: 9f632688e0b215f26ccc9c55388245af45e3bcb3
Parents: 548570c
Author: grey <gr...@apigee.com>
Authored: Wed Mar 26 21:10:13 2014 -0700
Committer: grey <gr...@apigee.com>
Committed: Wed Mar 26 21:10:13 2014 -0700

----------------------------------------------------------------------
 .../management/export/ExportServiceImpl.java    | 72 +++++++++++---------
 .../cassandra/ManagementServiceIT.java          |  2 +-
 2 files changed, 41 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9f632688/stack/services/src/main/java/org/apache/usergrid/management/export/ExportServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/export/ExportServiceImpl.java b/stack/services/src/main/java/org/apache/usergrid/management/export/ExportServiceImpl.java
index 78d1e48..674ac59 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/export/ExportServiceImpl.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/export/ExportServiceImpl.java
@@ -195,12 +195,18 @@ public class ExportServiceImpl implements ExportService {
                 em.update( export );
                 return;
             }
-            exportApplicationsForOrg( ( UUID ) config.get( "organizationId" ), ( UUID ) config.get( "ApplicationId" ),
+            exportApplicationsForOrg( ( UUID ) config.get( "organizationId" ), ( UUID ) config.get( "applicationId" ),
                     config, jobExecution );
         }
         else {
             try {
                 //exports all the applications for a single organization
+                if ( config.get( "organizationId" ) == null ) {
+                    logger.error( "No organization could be found" );
+                    export.setState( Export.State.FAILED );
+                    em.update( export );
+                    return;
+                }
                 exportApplicationForOrg( ( UUID ) config.get( "organizationId" ),
                         ( UUID ) config.get( "applicationId" ), config, jobExecution );
             }
@@ -262,7 +268,7 @@ public class ExportServiceImpl implements ExportService {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
 
         ApplicationInfo application = managementService.getApplicationInfo( applicationId );
-        String appFileName = prepareOutputFileName( "application", application.getName(), null );
+        String appFileName = prepareOutputFileName( "application", application.getName(), "" );
 
         JsonGenerator jg = getJsonGenerator( baos );
 
@@ -302,22 +308,22 @@ public class ExportServiceImpl implements ExportService {
                     jg.writeEndObject();
                 }
             }
+        }
 
-            // Close writer and file for this application.
-            jg.writeEndArray();
-            jg.close();
-            baos.flush();
-            baos.close();
+        // Close writer and file for this application.
+        jg.writeEndArray();
+        jg.close();
+        baos.flush();
+        baos.close();
 
-            //sets up the Inputstream for copying the method to s3.
-            InputStream is = new ByteArrayInputStream( baos.toByteArray() );
-            try {
-                s3Export.copyToS3( is, config, appFileName );
-            }
-            catch ( Exception e ) {
-                export.setState( Export.State.FAILED );
-                return;
-            }
+        //sets up the Inputstream for copying the method to s3.
+        InputStream is = new ByteArrayInputStream( baos.toByteArray() );
+        try {
+            s3Export.copyToS3( is, config, appFileName );
+        }
+        catch ( Exception e ) {
+            export.setState( Export.State.FAILED );
+            return;
         }
     }
 
@@ -344,6 +350,8 @@ public class ExportServiceImpl implements ExportService {
 
         Map<String, Object> metadata = em.getApplicationCollectionMetadata();
         long starting_time = System.currentTimeMillis();
+        String appFileName = prepareOutputFileName( "application", application.getName(),
+                ( String ) config.get( "collectionName" ) );
 
         // Loop through the collections. This is the only way to loop
         // through the entities in the application (former namespace).
@@ -369,24 +377,24 @@ public class ExportServiceImpl implements ExportService {
                     jg.writeEndObject();
                 }
             }
+        }
 
-            // Close writer and file for this application.
-            jg.writeEndArray();
-            jg.close();
-            baos.flush();
-            baos.close();
+        // Close writer and file for this application.
+        jg.writeEndArray();
+        jg.close();
+        baos.flush();
+        baos.close();
 
-            //sets up the Inputstream for copying the method to s3.
-            InputStream is = new ByteArrayInputStream( baos.toByteArray() );
-            String appFileName = prepareOutputFileName( "application", application.getName(), collectionName );
+        //sets up the Inputstream for copying the method to s3.
+        InputStream is = new ByteArrayInputStream( baos.toByteArray() );
 
-            try {
-                s3Export.copyToS3( is, config, appFileName );
-            }
-            catch ( Exception e ) {
-                export.setState( Export.State.FAILED );
-                return;
-            }
+
+        try {
+            s3Export.copyToS3( is, config, appFileName );
+        }
+        catch ( Exception e ) {
+            export.setState( Export.State.FAILED );
+            return;
         }
     }
 
@@ -534,7 +542,7 @@ public class ExportServiceImpl implements ExportService {
         StringBuilder str = new StringBuilder();
         str.append( name );
         str.append( "." );
-        if ( CollectionName != null ) {
+        if ( !CollectionName.equals( "" ) ) {
             str.append( CollectionName );
             str.append( "." );
         }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9f632688/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
index 1edc59e..120c9dc 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
@@ -1237,7 +1237,7 @@ public class ManagementServiceIT {
     public void testExportOneCollection() throws Exception {
 
         File f = null;
-        int entitiesToCreate = 10000;
+        int entitiesToCreate = 5;
 
         try {
             f = new File( "exportOneCollection.json" );