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/10/07 15:28:02 UTC

[1/5] git commit: Import clean-up and formatting only.

Repository: incubator-usergrid
Updated Branches:
  refs/heads/two-dot-o c40aecb2a -> 43f19302a


Import clean-up and formatting only.


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

Branch: refs/heads/two-dot-o
Commit: 7752cb9967749ad9ccbade0f5855b28045995eb2
Parents: 9c4b26e
Author: Dave Johnson <dm...@apigee.com>
Authored: Tue Oct 7 07:12:24 2014 -0400
Committer: Dave Johnson <dm...@apigee.com>
Committed: Tue Oct 7 07:12:24 2014 -0400

----------------------------------------------------------------------
 .../usergrid/persistence/map/MapManager.java    |   1 -
 .../persistence/map/impl/MapManagerImpl.java    |  24 ---
 .../persistence/map/impl/MapScopeImpl.java      |   1 -
 .../map/impl/MapSerializationImpl.java          |  48 +++--
 .../index/impl/EsEntityIndexImpl.java           | 208 ++++++++++---------
 5 files changed, 140 insertions(+), 142 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/7752cb99/stack/corepersistence/map/src/main/java/org/apache/usergrid/persistence/map/MapManager.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/map/src/main/java/org/apache/usergrid/persistence/map/MapManager.java b/stack/corepersistence/map/src/main/java/org/apache/usergrid/persistence/map/MapManager.java
index 58b0153..e6d8125 100644
--- a/stack/corepersistence/map/src/main/java/org/apache/usergrid/persistence/map/MapManager.java
+++ b/stack/corepersistence/map/src/main/java/org/apache/usergrid/persistence/map/MapManager.java
@@ -20,7 +20,6 @@ package org.apache.usergrid.persistence.map;
 
 import java.util.UUID;
 
-import org.apache.usergrid.persistence.core.migration.Migration;
 
 
 /**

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/7752cb99/stack/corepersistence/map/src/main/java/org/apache/usergrid/persistence/map/impl/MapManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/map/src/main/java/org/apache/usergrid/persistence/map/impl/MapManagerImpl.java b/stack/corepersistence/map/src/main/java/org/apache/usergrid/persistence/map/impl/MapManagerImpl.java
index e58d8aa..e582e55 100644
--- a/stack/corepersistence/map/src/main/java/org/apache/usergrid/persistence/map/impl/MapManagerImpl.java
+++ b/stack/corepersistence/map/src/main/java/org/apache/usergrid/persistence/map/impl/MapManagerImpl.java
@@ -18,37 +18,13 @@
 package org.apache.usergrid.persistence.map.impl;
 
 
-import java.util.Arrays;
-import java.util.Collection;
 import java.util.UUID;
 
-import org.apache.cassandra.db.marshal.BytesType;
-import org.apache.cassandra.db.marshal.ReversedType;
-import org.apache.cassandra.db.marshal.UTF8Type;
-import org.apache.cassandra.db.marshal.UUIDType;
-
-import org.apache.usergrid.persistence.core.astyanax.CompositeFieldSerializer;
-import org.apache.usergrid.persistence.core.astyanax.MultiTennantColumnFamily;
-import org.apache.usergrid.persistence.core.astyanax.MultiTennantColumnFamilyDefinition;
-import org.apache.usergrid.persistence.core.astyanax.OrganizationScopedRowKeySerializer;
-import org.apache.usergrid.persistence.core.astyanax.ScopedRowKey;
-import org.apache.usergrid.persistence.core.migration.Migration;
-import org.apache.usergrid.persistence.core.scope.ApplicationScope;
 import org.apache.usergrid.persistence.map.MapManager;
 import org.apache.usergrid.persistence.map.MapScope;
 
 import com.google.inject.Inject;
 import com.google.inject.assistedinject.Assisted;
-import com.netflix.astyanax.Keyspace;
-import com.netflix.astyanax.MutationBatch;
-import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
-import com.netflix.astyanax.connectionpool.exceptions.NotFoundException;
-import com.netflix.astyanax.model.Column;
-import com.netflix.astyanax.model.ColumnFamily;
-import com.netflix.astyanax.model.CompositeBuilder;
-import com.netflix.astyanax.model.CompositeParser;
-import com.netflix.astyanax.serializers.BooleanSerializer;
-import com.netflix.astyanax.serializers.StringSerializer;
 ;
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/7752cb99/stack/corepersistence/map/src/main/java/org/apache/usergrid/persistence/map/impl/MapScopeImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/map/src/main/java/org/apache/usergrid/persistence/map/impl/MapScopeImpl.java b/stack/corepersistence/map/src/main/java/org/apache/usergrid/persistence/map/impl/MapScopeImpl.java
index e18f8b4..a366446 100644
--- a/stack/corepersistence/map/src/main/java/org/apache/usergrid/persistence/map/impl/MapScopeImpl.java
+++ b/stack/corepersistence/map/src/main/java/org/apache/usergrid/persistence/map/impl/MapScopeImpl.java
@@ -37,7 +37,6 @@ public class MapScopeImpl implements MapScope {
     }
 
 
-
     @Override
     public Id getApplication() {
         return owner;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/7752cb99/stack/corepersistence/map/src/main/java/org/apache/usergrid/persistence/map/impl/MapSerializationImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/map/src/main/java/org/apache/usergrid/persistence/map/impl/MapSerializationImpl.java b/stack/corepersistence/map/src/main/java/org/apache/usergrid/persistence/map/impl/MapSerializationImpl.java
index af7b02d..f95d53f 100644
--- a/stack/corepersistence/map/src/main/java/org/apache/usergrid/persistence/map/impl/MapSerializationImpl.java
+++ b/stack/corepersistence/map/src/main/java/org/apache/usergrid/persistence/map/impl/MapSerializationImpl.java
@@ -68,8 +68,9 @@ public class MapSerializationImpl implements MapSerialization {
         /**
          * CFs where the row key contains the source node id
          */
-        private static final MultiTennantColumnFamily<ApplicationScope, MapEntryKey, Boolean> MAP_ENTRIES =
-                new MultiTennantColumnFamily<>( "Map_Entries", MAP_ENTRY_SERIALIZER, BOOLEAN_SERIALIZER );
+        private static final MultiTennantColumnFamily<ApplicationScope, MapEntryKey, Boolean> 
+            MAP_ENTRIES = new MultiTennantColumnFamily<>( 
+                "Map_Entries", MAP_ENTRY_SERIALIZER, BOOLEAN_SERIALIZER );
 
 
         /**
@@ -89,7 +90,7 @@ public class MapSerializationImpl implements MapSerialization {
 
     @Override
     public String getString( final MapScope scope, final String key ) {
-        Column<Boolean> col = getValue(scope, key);
+        Column<Boolean> col = getValue(scope, key); // TODO: why boolean?
         return (col !=null) ?  col.getStringValue(): null;
     }
 
@@ -213,26 +214,34 @@ public class MapSerializationImpl implements MapSerialization {
 
 
     @Override
-    public Collection<MultiTennantColumnFamilyDefinition> getColumnFamilies()
-    {
-        final MultiTennantColumnFamilyDefinition mapEntries = new MultiTennantColumnFamilyDefinition( MAP_ENTRIES,
-                       BytesType.class.getSimpleName(), BytesType.class.getSimpleName(), BytesType.class.getSimpleName(), MultiTennantColumnFamilyDefinition.CacheOption.KEYS );
-
-
-        final MultiTennantColumnFamilyDefinition mapKeys = new MultiTennantColumnFamilyDefinition( MAP_KEYS,
-                               BytesType.class.getSimpleName(), UTF8Type.class.getSimpleName(), BytesType.class.getSimpleName(), MultiTennantColumnFamilyDefinition.CacheOption.KEYS );
+    public Collection<MultiTennantColumnFamilyDefinition> getColumnFamilies() {
+
+        final MultiTennantColumnFamilyDefinition mapEntries = 
+                new MultiTennantColumnFamilyDefinition( MAP_ENTRIES,
+                       BytesType.class.getSimpleName(), 
+                       BytesType.class.getSimpleName(), 
+                       BytesType.class.getSimpleName(), 
+                       MultiTennantColumnFamilyDefinition.CacheOption.KEYS );
+
+        final MultiTennantColumnFamilyDefinition mapKeys = 
+                new MultiTennantColumnFamilyDefinition( MAP_KEYS,
+                        BytesType.class.getSimpleName(), 
+                        UTF8Type.class.getSimpleName(), 
+                        BytesType.class.getSimpleName(), 
+                        MultiTennantColumnFamilyDefinition.CacheOption.KEYS );
 
         return Arrays.asList( mapEntries, mapKeys );
     }
 
+
     private  Column<Boolean> getValue(MapScope scope, String key) {
+
         //add it to the entry
         final ScopedRowKey<ApplicationScope, MapEntryKey> entryRowKey = MapEntryKey.fromKey(scope, key);
 
-
         try {
-            final Column<Boolean> result =
-                    keyspace.prepareQuery( MAP_ENTRIES ).getKey( entryRowKey ).getColumn( true ).execute().getResult();
+            final Column<Boolean> result = keyspace.prepareQuery( MAP_ENTRIES )
+                    .getKey( entryRowKey ).getColumn( true ).execute().getResult();
 
             return result;
         }
@@ -245,6 +254,7 @@ public class MapSerializationImpl implements MapSerialization {
         }
     }
 
+
     private void executeBatch(MutationBatch batch) {
         try {
             batch.execute();
@@ -252,9 +262,6 @@ public class MapSerializationImpl implements MapSerialization {
             throw new RuntimeException("Unable to connect to cassandra", e);
         }
     }
-    /**
-     * Inner class to serialize and edgeIdTypeKey
-     */
 
 
     /**
@@ -320,8 +327,11 @@ public class MapSerializationImpl implements MapSerialization {
         /**
          * Create a scoped row key from the key
          */
-        public static ScopedRowKey<ApplicationScope, MapEntryKey> fromKey( final MapScope mapScope, final String key ) {
-            return ScopedRowKey.fromKey( ( ApplicationScope ) mapScope, new MapEntryKey( mapScope.getName(), key ) );
+        public static ScopedRowKey<ApplicationScope, MapEntryKey> fromKey( 
+                final MapScope mapScope, final String key ) {
+
+            return ScopedRowKey.fromKey( 
+                    ( ApplicationScope ) mapScope, new MapEntryKey( mapScope.getName(), key ) );
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/7752cb99/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
index 264eb1d..23717b1 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
@@ -17,7 +17,6 @@
  */
 package org.apache.usergrid.persistence.index.impl;
 
-
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
@@ -75,7 +74,7 @@ import static org.apache.usergrid.persistence.index.impl.IndexingUtils.createInd
  */
 public class EsEntityIndexImpl implements EntityIndex {
 
-    private static final Logger log = LoggerFactory.getLogger( EsEntityIndexImpl.class );
+    private static final Logger log = LoggerFactory.getLogger(EsEntityIndexImpl.class);
 
     private final String indexName;
 
@@ -89,92 +88,84 @@ public class EsEntityIndexImpl implements EntityIndex {
 
     private final int cursorTimeout;
 
-
     private final IndexFig config;
 
-
     @Inject
-    public EsEntityIndexImpl( @Assisted final ApplicationScope applicationScope, final IndexFig config, final EsProvider provider ) {
+    public EsEntityIndexImpl(@Assisted final ApplicationScope applicationScope, 
+            final IndexFig config, final EsProvider provider) {
 
-        ValidationUtils.validateApplicationScope( applicationScope );
+        ValidationUtils.validateApplicationScope(applicationScope);
 
         try {
             this.applicationScope = applicationScope;
 
             this.client = provider.getClient();
 
-            this.indexName = createIndexName( config.getIndexPrefix(), applicationScope );
+            this.indexName = createIndexName(config.getIndexPrefix(), applicationScope);
             this.cursorTimeout = config.getQueryCursorTimeout();
 
             this.config = config;
-        }
-        catch ( Exception e ) {
-            log.error( "Error setting up index", e );
+        } catch (Exception e) {
+            log.error("Error setting up index", e);
             throw e;
         }
 
         AdminClient admin = client.admin();
         try {
-            CreateIndexResponse r = admin.indices().prepareCreate( indexName ).execute().actionGet();
-            log.debug( "Created new Index Name [{}] ACK=[{}]", indexName, r.isAcknowledged() );
+            CreateIndexResponse r = admin.indices().prepareCreate(indexName).execute().actionGet();
+            log.debug("Created new Index Name [{}] ACK=[{}]", indexName, r.isAcknowledged());
 
-            client.admin().indices().prepareRefresh( indexName ).execute().actionGet();
+            client.admin().indices().prepareRefresh(indexName).execute().actionGet();
 
             try {
                 // TODO: figure out what refresh above is not enough to ensure index is ready
-                Thread.sleep( 500 );
-            }
-            catch ( InterruptedException ex ) {
+                Thread.sleep(500);
+            } catch (InterruptedException ex) {
             }
-        }
-        catch ( IndexAlreadyExistsException ignored ) {
+        } catch (IndexAlreadyExistsException ignored) {
             // expected
         }
     }
 
-
     @Override
     public EntityIndexBatch createBatch() {
-        return new EsEntityIndexBatchImpl( applicationScope, client, config, knownTypes, 1000 );
+        return new EsEntityIndexBatchImpl(applicationScope, client, config, knownTypes, 1000);
     }
 
-
     @Override
-    public CandidateResults search( final IndexScope indexScope, final Query query ) {
+    public CandidateResults search(final IndexScope indexScope, final Query query) {
 
-        final String indexType = createCollectionScopeTypeName( indexScope );
+        final String indexType = createCollectionScopeTypeName(indexScope);
 
         QueryBuilder qb = query.createQueryBuilder();
 
-        if ( log.isDebugEnabled() ) {
-            log.debug( "Searching index {}\n   type {}\n   query {} limit {}", new Object[] {
-                            this.indexName, indexType, qb.toString().replace( "\n", " " ), query.getLimit()
-                    } );
+        if (log.isDebugEnabled()) {
+            log.debug("Searching index {}\n   type {}\n   query {} limit {}", new Object[]{
+                this.indexName, indexType, qb.toString().replace("\n", " "), query.getLimit()
+            });
         }
 
         SearchResponse searchResponse;
-        if ( query.getCursor() == null ) {
+        if (query.getCursor() == null) {
 
-
-            SearchRequestBuilder srb =
-                    client.prepareSearch( indexName ).setTypes( indexType ).setScroll( cursorTimeout + "m" )
-                          .setQuery( qb );
+            SearchRequestBuilder srb
+                    = client.prepareSearch(indexName).setTypes(indexType).setScroll(cursorTimeout + "m")
+                    .setQuery(qb);
 
             FilterBuilder fb = query.createFilterBuilder();
-            if ( fb != null ) {
-                log.debug( "   Filter: {} ", fb.toString() );
-                srb = srb.setPostFilter( fb );
+            if (fb != null) {
+                log.debug("   Filter: {} ", fb.toString());
+                srb = srb.setPostFilter(fb);
             }
 
-            srb = srb.setFrom( 0 ).setSize( query.getLimit() );
+            srb = srb.setFrom(0).setSize(query.getLimit());
 
-            for ( Query.SortPredicate sp : query.getSortPredicates() ) {
+            for (Query.SortPredicate sp : query.getSortPredicates()) {
 
                 final SortOrder order;
-                if ( sp.getDirection().equals( Query.SortDirection.ASCENDING ) ) {
+                if (sp.getDirection().equals(Query.SortDirection.ASCENDING)) {
                     order = SortOrder.ASC;
-                }
-                else {
+                } else {
                     order = SortOrder.DESC;
                 }
 
@@ -182,73 +173,70 @@ public class EsEntityIndexImpl implements EntityIndex {
                 // type prefix to use. So, here we add an order by clause for every possible type 
                 // that you can order by: string, number and boolean and we ask ElasticSearch 
                 // to ignore any fields that are not present.
-
                 final String stringFieldName = STRING_PREFIX + sp.getPropertyName();
-                final FieldSortBuilder stringSort =
-                        SortBuilders.fieldSort( stringFieldName ).order( order ).ignoreUnmapped( true );
-                srb.addSort( stringSort );
-                log.debug( "   Sort: {} order by {}", stringFieldName, order.toString() );
+                final FieldSortBuilder stringSort
+                        = SortBuilders.fieldSort(stringFieldName).order(order).ignoreUnmapped(true);
+                srb.addSort(stringSort);
+                log.debug("   Sort: {} order by {}", stringFieldName, order.toString());
 
                 final String numberFieldName = NUMBER_PREFIX + sp.getPropertyName();
-                final FieldSortBuilder numberSort =
-                        SortBuilders.fieldSort( numberFieldName ).order( order ).ignoreUnmapped( true );
-                srb.addSort( numberSort );
-                log.debug( "   Sort: {} order by {}", numberFieldName, order.toString() );
+                final FieldSortBuilder numberSort
+                        = SortBuilders.fieldSort(numberFieldName).order(order).ignoreUnmapped(true);
+                srb.addSort(numberSort);
+                log.debug("   Sort: {} order by {}", numberFieldName, order.toString());
 
                 final String booleanFieldName = BOOLEAN_PREFIX + sp.getPropertyName();
-                final FieldSortBuilder booleanSort =
-                        SortBuilders.fieldSort( booleanFieldName ).order( order ).ignoreUnmapped( true );
-                srb.addSort( booleanSort );
-                log.debug( "   Sort: {} order by {}", booleanFieldName, order.toString() );
+                final FieldSortBuilder booleanSort
+                        = SortBuilders.fieldSort(booleanFieldName).order(order).ignoreUnmapped(true);
+                srb.addSort(booleanSort);
+                log.debug("   Sort: {} order by {}", booleanFieldName, order.toString());
             }
 
             searchResponse = srb.execute().actionGet();
-        }
-        else {
+        } else {
             String scrollId = query.getCursor();
-            if ( scrollId.startsWith( "\"" ) ) {
-                scrollId = scrollId.substring( 1 );
+            if (scrollId.startsWith("\"")) {
+                scrollId = scrollId.substring(1);
             }
-            if ( scrollId.endsWith( "\"" ) ) {
-                scrollId = scrollId.substring( 0, scrollId.length() - 1 );
+            if (scrollId.endsWith("\"")) {
+                scrollId = scrollId.substring(0, scrollId.length() - 1);
             }
-            log.debug( "Executing query with cursor: {} ", scrollId );
+            log.debug("Executing query with cursor: {} ", scrollId);
 
-            SearchScrollRequestBuilder ssrb = client.prepareSearchScroll( scrollId ).setScroll( cursorTimeout + "m" );
+            SearchScrollRequestBuilder ssrb = client.prepareSearchScroll(scrollId).setScroll(cursorTimeout + "m");
             searchResponse = ssrb.execute().actionGet();
         }
 
         SearchHits hits = searchResponse.getHits();
-        log.debug( "   Hit count: {} Total hits: {}", hits.getHits().length, hits.getTotalHits() );
+        log.debug("   Hit count: {} Total hits: {}", hits.getHits().length, hits.getTotalHits());
 
         List<CandidateResult> candidates = new ArrayList<CandidateResult>();
 
-        for ( SearchHit hit : hits.getHits() ) {
+        for (SearchHit hit : hits.getHits()) {
 
-            String[] idparts = hit.getId().split( DOC_ID_SEPARATOR_SPLITTER );
+            String[] idparts = hit.getId().split(DOC_ID_SEPARATOR_SPLITTER);
             String id = idparts[0];
             String type = idparts[1];
             String version = idparts[2];
 
-            Id entityId = new SimpleId( UUID.fromString( id ), type );
+            Id entityId = new SimpleId(UUID.fromString(id), type);
 
-            candidates.add( new CandidateResult( entityId, UUID.fromString( version ) ) );
+            candidates.add(new CandidateResult(entityId, UUID.fromString(version)));
         }
 
-        CandidateResults candidateResults = new CandidateResults( query, candidates );
+        CandidateResults candidateResults = new CandidateResults(query, candidates);
 
-        if ( candidates.size() >= query.getLimit() ) {
-            candidateResults.setCursor( searchResponse.getScrollId() );
-            log.debug( "   Cursor = " + searchResponse.getScrollId() );
+        if (candidates.size() >= query.getLimit()) {
+            candidateResults.setCursor(searchResponse.getScrollId());
+            log.debug("   Cursor = " + searchResponse.getScrollId());
         }
 
         return candidateResults;
     }
 
-
     /**
-     * Build mappings for data to be indexed. Setup String fields as not_analyzed and analyzed, where the analyzed field
-     * is named {name}_ug_analyzed
+     * Build mappings for data to be indexed. Setup String fields as not_analyzed and analyzed,
+     * where the analyzed field is named {name}_ug_analyzed
      *
      * @param builder Add JSON object to this builder.
      * @param type ElasticSearch type of entity.
@@ -260,38 +248,66 @@ public class EsEntityIndexImpl implements EntityIndex {
     public static XContentBuilder createDoubleStringIndexMapping( XContentBuilder builder, String type )
             throws IOException {
 
-        builder = builder.startObject().startObject( type ).startArray( "dynamic_templates" )
+        builder = builder
+
+            .startObject()
+
+                .startObject( type )
+
+                    .startArray( "dynamic_templates" )
+
+                        // any string with field name that starts with sa_ gets analyzed
+                        .startObject()
+                            .startObject( "template_1" )
+                                .field( "match", ANALYZED_STRING_PREFIX + "*" )
+                                .field( "match_mapping_type", "string" )
+                                .startObject( "mapping" ).field( "type", "string" )
+                                    .field( "index", "analyzed" )
+                                .endObject()
+                            .endObject()
+                        .endObject()
+
+                            // all other strings are not analyzed
+                        .startObject()
+                            .startObject( "template_2" )
+                                .field( "match", "*" )
+                                .field( "match_mapping_type", "string" )
+                                .startObject( "mapping" )
+                                    .field( "type", "string" )
+                                    .field( "index", "not_analyzed" )
+                                .endObject()
+                            .endObject()
+                        .endObject()
 
-                // any string with field name that starts with sa_ gets analyzed
-                .startObject().startObject( "template_1" ).field( "match", ANALYZED_STRING_PREFIX + "*" )
-                .field( "match_mapping_type", "string" ).startObject( "mapping" ).field( "type", "string" )
-                .field( "index", "analyzed" ).endObject().endObject().endObject()
+                        // fields names starting with go_ get geo-indexed
+                        .startObject()
+                            .startObject( "template_3" )
+                                .field( "match", GEO_PREFIX + "location" )
+                                .startObject( "mapping" )
+                                    .field( "type", "geo_point" )
+                                .endObject()
+                            .endObject()
+                        .endObject()
 
-                        // all other strings are not analyzed
-                .startObject().startObject( "template_2" ).field( "match", "*" ).field( "match_mapping_type", "string" )
-                .startObject( "mapping" ).field( "type", "string" ).field( "index", "not_analyzed" ).endObject()
-                .endObject().endObject()
+                    .endArray()
 
-                        // fields names starting with go_ get geo-indexed
-                .startObject().startObject( "template_3" ).field( "match", GEO_PREFIX + "location" )
-                .startObject( "mapping" ).field( "type", "geo_point" ).endObject().endObject().endObject()
+                .endObject()
 
-                .endArray().endObject().endObject();
+            .endObject();
 
         return builder;
     }
 
-
     public void refresh() {
-        client.admin().indices().prepareRefresh( indexName ).execute().actionGet();
+        client.admin().indices().prepareRefresh(indexName).execute().actionGet();
         log.debug("Refreshed index: " + indexName);
     }
 
     @Override
-    public CandidateResults getEntityVersions( final IndexScope scope, final Id id ) {
+    public CandidateResults getEntityVersions(final IndexScope scope, final Id id) {
         Query query = new Query();
-        query.addEqualityFilter( ENTITYID_FIELDNAME, id.getUuid().toString() );
-        CandidateResults results = search( scope, query );
+        query.addEqualityFilter(ENTITYID_FIELDNAME, id.getUuid().toString());
+        CandidateResults results = search(scope, query);
         return results;
     }
 
@@ -300,14 +316,12 @@ public class EsEntityIndexImpl implements EntityIndex {
      */
     public void deleteIndex() {
         AdminClient adminClient = client.admin();
-        DeleteIndexResponse response = adminClient.indices().prepareDelete( indexName ).get();
-        if ( response.isAcknowledged() ) {
-            log.info("Deleted index: " + indexName );
+        DeleteIndexResponse response = adminClient.indices().prepareDelete(indexName).get();
+        if (response.isAcknowledged()) {
+            log.info("Deleted index: " + indexName);
         } else {
-            log.info("Failed to delete index " + indexName );
+            log.info("Failed to delete index " + indexName);
         }
     }
 
-
-
 }


[5/5] git commit: Merge branch 'two-dot-o' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into two-dot-o

Posted by sn...@apache.org.
Merge branch 'two-dot-o' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into two-dot-o

Conflicts:
	stack/core/pom.xml
	stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceModule.java


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

Branch: refs/heads/two-dot-o
Commit: 43f19302afd9947a27af31ca2bf5d5398ab19b52
Parents: 5ad79e3 c40aecb
Author: Dave Johnson <dm...@apigee.com>
Authored: Tue Oct 7 09:27:45 2014 -0400
Committer: Dave Johnson <dm...@apigee.com>
Committed: Tue Oct 7 09:27:45 2014 -0400

----------------------------------------------------------------------
 stack/core/pom.xml                              |  16 +-
 .../usergrid/corepersistence/GuiceModule.java   |   1 +
 stack/corepersistence/map/pom.xml               |  16 ++
 stack/corepersistence/pom.xml                   |  17 ++
 stack/corepersistence/queue/pom.xml             |  92 ++++++++
 .../usergrid/persistence/queue/Queue.java       |  31 +++
 .../usergrid/persistence/queue/QueueFig.java    |  16 ++
 .../persistence/queue/QueueManager.java         |  64 +++++
 .../persistence/queue/QueueManagerFactory.java  |  23 ++
 .../persistence/queue/QueueMessage.java         |  42 ++++
 .../usergrid/persistence/queue/QueueScope.java  |  31 +++
 .../persistence/queue/guice/QueueModule.java    |  51 ++++
 .../persistence/queue/impl/QueueScopeImpl.java  |  87 +++++++
 .../queue/impl/SQSQueueManagerImpl.java         | 234 +++++++++++++++++++
 .../persistence/queue/QueueManagerTest.java     | 100 ++++++++
 .../queue/guice/TestQueueModule.java            |  33 +++
 stack/pom.xml                                   |   8 +-
 .../apache/usergrid/rest/SystemResource.java    |  67 ++++--
 .../notifications/ApplicationQueueManager.java  |  96 +++-----
 .../notifications/ApplicationQueueMessage.java  |  67 ++----
 .../notifications/NotificationsService.java     |  15 +-
 .../services/notifications/QueueListener.java   |  69 +++---
 .../services/notifications/QueueManager.java    |  31 ---
 .../services/notifications/TaskManager.java     |  54 ++---
 .../apns/NotificationsServiceIT.java            |  47 ++--
 .../gcm/NotificationsServiceIT.java             |   2 +-
 .../java/org/apache/usergrid/tools/ApiDoc.java  |   5 +-
 27 files changed, 1066 insertions(+), 249 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/43f19302/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceModule.java
----------------------------------------------------------------------


[4/5] git commit: Use new Core Persistence Map Module to look up Entity Types by UUID (from Cassandra) instead of relying entirely on the Query Index module (and ElasticSearch).

Posted by sn...@apache.org.
Use new Core Persistence Map Module to look up Entity Types by UUID (from Cassandra) instead of relying entirely on the Query Index module (and ElasticSearch).


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

Branch: refs/heads/two-dot-o
Commit: 5ad79e304d31b4a2f30014f7bab9ca5a6c62fcc2
Parents: 79bebe6
Author: Dave Johnson <dm...@apigee.com>
Authored: Tue Oct 7 09:19:16 2014 -0400
Committer: Dave Johnson <dm...@apigee.com>
Committed: Tue Oct 7 09:19:16 2014 -0400

----------------------------------------------------------------------
 stack/core/pom.xml                              |  7 +++
 .../corepersistence/CpEntityManager.java        | 45 +++++++++++++++-----
 .../corepersistence/CpEntityManagerFactory.java |  5 ++-
 .../corepersistence/CpManagerCache.java         | 29 +++++++++++--
 .../usergrid/corepersistence/GuiceModule.java   | 10 ++---
 5 files changed, 76 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5ad79e30/stack/core/pom.xml
----------------------------------------------------------------------
diff --git a/stack/core/pom.xml b/stack/core/pom.xml
index 6cd5dac..ea37fce 100644
--- a/stack/core/pom.xml
+++ b/stack/core/pom.xml
@@ -526,6 +526,13 @@
 	    <type>jar</type>
     </dependency>
 
+    <dependency>
+	    <groupId>org.apache.usergrid</groupId>
+	    <artifactId>map</artifactId>
+	    <version>2.0.0-SNAPSHOT</version>
+	    <type>jar</type>
+    </dependency>
+
     <!--<dependency>-->
       <!--<artifactId>lucene-core</artifactId>-->
       <!--<groupId>org.apache.lucene</groupId>-->

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5ad79e30/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
index d7f3a3b..1a8f17c 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
@@ -133,6 +133,9 @@ import org.apache.usergrid.persistence.index.query.Identifier;
 import org.apache.usergrid.persistence.index.query.Query;
 import org.apache.usergrid.persistence.index.query.Query.Level;
 import static org.apache.usergrid.persistence.index.query.Query.Level.REFS;
+import org.apache.usergrid.persistence.map.MapManager;
+import org.apache.usergrid.persistence.map.MapScope;
+import org.apache.usergrid.persistence.map.impl.MapScopeImpl;
 import org.apache.usergrid.persistence.model.entity.Id;
 import org.apache.usergrid.persistence.model.entity.SimpleId;
 import org.apache.usergrid.persistence.model.field.Field;
@@ -181,6 +184,8 @@ public class CpEntityManager implements EntityManager {
 
     private boolean skipAggregateCounters;
 
+    private String TYPES_BY_UUID_MAP = "zzz_typesbyuuid_zzz";
+
 
     public CpEntityManager() {}
 
@@ -482,8 +487,8 @@ public class CpEntityManager implements EntityManager {
 //                ecm.load( entityId ).toBlockingObservable().last();
 
 
-        org.apache.usergrid.persistence.model.entity.Entity cpEntity = new org.apache.usergrid.persistence.model
-                .entity.Entity( entityId );
+        org.apache.usergrid.persistence.model.entity.Entity cpEntity = 
+                new org.apache.usergrid.persistence.model.entity.Entity( entityId );
 
         cpEntity = CpEntityMapUtils.fromMap(
                 cpEntity, entity.getProperties(), entity.getType(), true );
@@ -2187,13 +2192,30 @@ public class CpEntityManager implements EntityManager {
 
 
     @Override
-    public Entity get( UUID id ) throws Exception {
+    public Entity get( UUID uuid ) throws Exception {
+
+        Id mapOwner = new SimpleId( applicationId, TYPE_APPLICATION );
+        MapScope ms = new MapScopeImpl( mapOwner, TYPES_BY_UUID_MAP );
+        MapManager mm = managerCache.getMapManager( ms );
+        String entityType = mm.getString(uuid.toString() );
+
+        final Entity entity;
 
-        Query q = Query.fromQL("select * where " + PROPERTY_UUID + " = '" + id.toString() + "'");
-        q.setResultsLevel( Level.ALL_PROPERTIES );
-        Results r = getRelationManager( getApplication() ).searchConnectedEntities( q );
+        if ( entityType == null ) {
 
-        return r.getEntity();
+            Query q = Query.fromQL(
+                "select * where " + PROPERTY_UUID + " = '" + uuid.toString() + "'");
+            q.setResultsLevel( Level.ALL_PROPERTIES );
+            Results r = getRelationManager( getApplication() ).searchConnectedEntities( q );
+            entity = r.getEntity();
+
+            mm.putString(uuid.toString(), entity.getType() );
+        
+        } else { 
+            entity = get(new SimpleEntityRef( entityType, uuid ));
+        }
+
+        return entity;
     } 
 
 
@@ -2505,7 +2527,8 @@ public class CpEntityManager implements EntityManager {
 //            if ( entity.getType().equals("group")) {
 //                logger.debug("Writing Group");
 //                for ( Field field : cpEntity.getFields() ) {
-//                    logger.debug("   Writing Group name={} value={}", field.getName(), field.getValue() );
+//                    logger.debug(
+//                        "   Writing Group name={} value={}", field.getName(), field.getValue() );
 //                }
 //            }
         }
@@ -2839,7 +2862,7 @@ public class CpEntityManager implements EntityManager {
                             CollectionScope collScope = new CollectionScopeImpl(
                                 applicationScope.getApplication(),
                                 applicationScope.getApplication(),
-                                    CpNamingUtils.getCollectionScopeNameFromEntityType( entity.getType() ));
+                                CpNamingUtils.getCollectionScopeNameFromEntityType( entity.getType()));
                             EntityCollectionManager collMgr = 
                                 managerCache.getEntityCollectionManager(collScope);
 
@@ -2905,7 +2928,7 @@ public class CpEntityManager implements EntityManager {
                             CollectionScope sourceScope = new CollectionScopeImpl(
                                 applicationScope.getApplication(),
                                 applicationScope.getApplication(),
-                                    CpNamingUtils.getCollectionScopeNameFromEntityType( sourceEntityType ));
+                                CpNamingUtils.getCollectionScopeNameFromEntityType( sourceEntityType ));
                             EntityCollectionManager sourceEcm = 
                                 managerCache.getEntityCollectionManager(sourceScope);
 
@@ -2928,7 +2951,7 @@ public class CpEntityManager implements EntityManager {
                             CollectionScope targetScope = new CollectionScopeImpl(
                                 applicationScope.getApplication(),
                                 applicationScope.getApplication(),
-                                    CpNamingUtils.getCollectionScopeNameFromEntityType( targetEntityType ));
+                                CpNamingUtils.getCollectionScopeNameFromEntityType( targetEntityType ));
                             EntityCollectionManager targetEcm = 
                                 managerCache.getEntityCollectionManager(targetScope);
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5ad79e30/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
index 26f4234..f44eac3 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
@@ -53,6 +53,7 @@ import org.apache.usergrid.persistence.graph.SearchByEdgeType;
 import org.apache.usergrid.persistence.graph.impl.SimpleSearchByEdgeType;
 import org.apache.usergrid.persistence.index.EntityIndexFactory;
 import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.map.MapManagerFactory;
 import org.apache.usergrid.persistence.model.entity.Id;
 import org.apache.usergrid.persistence.model.entity.SimpleId;
 import org.apache.usergrid.utils.UUIDUtils;
@@ -154,12 +155,14 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
             EntityCollectionManagerFactory ecmf;
             EntityIndexFactory eif;
             GraphManagerFactory gmf;
+            MapManagerFactory mmf;
 
             ecmf = injector.getInstance( EntityCollectionManagerFactory.class );
             eif = injector.getInstance( EntityIndexFactory.class );
             gmf = injector.getInstance( GraphManagerFactory.class );
+            mmf = injector.getInstance( MapManagerFactory.class );
 
-            managerCache = new CpManagerCache( ecmf, eif, gmf );
+            managerCache = new CpManagerCache( ecmf, eif, gmf, mmf );
         }
         return managerCache;
     }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5ad79e30/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpManagerCache.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpManagerCache.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpManagerCache.java
index 0e7c084..d10025c 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpManagerCache.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpManagerCache.java
@@ -23,7 +23,9 @@ import org.apache.usergrid.persistence.graph.GraphManager;
 import org.apache.usergrid.persistence.graph.GraphManagerFactory;
 import org.apache.usergrid.persistence.index.EntityIndex;
 import org.apache.usergrid.persistence.index.EntityIndexFactory;
-import org.apache.usergrid.persistence.index.IndexScope;
+import org.apache.usergrid.persistence.map.MapManager;
+import org.apache.usergrid.persistence.map.MapManagerFactory;
+import org.apache.usergrid.persistence.map.MapScope;
 import org.apache.usergrid.utils.LRUCache2;
 
 class CpManagerCache {
@@ -31,8 +33,10 @@ class CpManagerCache {
     private final EntityCollectionManagerFactory ecmf;
     private final EntityIndexFactory eif;
     private final GraphManagerFactory gmf;
+    private final MapManagerFactory mmf;
 
     // TODO: consider making these cache sizes and timeouts configurable
+    // TODO: replace with Guava cache
     private final LRUCache2<CollectionScope, EntityCollectionManager> ecmCache
             = new LRUCache2<CollectionScope, EntityCollectionManager>(50, 1 * 60 * 60 * 1000);
 
@@ -42,12 +46,20 @@ class CpManagerCache {
     private final LRUCache2<ApplicationScope, GraphManager> gmCache
             = new LRUCache2<ApplicationScope, GraphManager>(50, 1 * 60 * 60 * 1000);
 
+    private final LRUCache2<MapScope, MapManager> mmCache
+            = new LRUCache2<MapScope, MapManager>(50, 1 * 60 * 60 * 1000);
+
+
     public CpManagerCache(
-            EntityCollectionManagerFactory ecmf, EntityIndexFactory eif, GraphManagerFactory gmf) {
+            EntityCollectionManagerFactory ecmf, 
+            EntityIndexFactory eif, 
+            GraphManagerFactory gmf,
+            MapManagerFactory mmf) {
+
         this.ecmf = ecmf;
         this.eif = eif;
         this.gmf = gmf;
-
+        this.mmf = mmf;
     }
 
     public EntityCollectionManager getEntityCollectionManager(CollectionScope scope) {
@@ -83,6 +95,17 @@ class CpManagerCache {
         return gm;
     }
 
+    public MapManager getMapManager( MapScope mapScope) {
+
+        MapManager mm = mmCache.get(mapScope);
+
+        if (mm == null) {
+            mm = mmf.createMapManager(mapScope);
+            mmCache.put(mapScope, mm);
+        }
+        return mm;
+    }
+
     void flush() {
         gmCache.purge();
         ecmCache.purge();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5ad79e30/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceModule.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceModule.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceModule.java
index 1f3d615..f85c508 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceModule.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceModule.java
@@ -17,15 +17,14 @@
 package org.apache.usergrid.corepersistence;
 
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
+import com.google.inject.AbstractModule;
 import org.apache.usergrid.persistence.collection.guice.CollectionModule;
 import org.apache.usergrid.persistence.core.guice.CommonModule;
 import org.apache.usergrid.persistence.graph.guice.GraphModule;
 import org.apache.usergrid.persistence.index.guice.IndexModule;
-
-import com.google.inject.AbstractModule;
+import org.apache.usergrid.persistence.map.guice.MapModule;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 /**
@@ -41,6 +40,7 @@ public class GuiceModule  extends AbstractModule {
         install(new CollectionModule());
         install(new GraphModule());
         install(new IndexModule());
+        install(new MapModule());
 
         bind(CpEntityDeleteListener.class).asEagerSingleton();
         bind(CpEntityIndexDeleteListener.class).asEagerSingleton();


[2/5] git commit: Rename getMapManager() to createMapManager() for consistency with other CP managers.

Posted by sn...@apache.org.
Rename getMapManager() to createMapManager() for consistency with other CP managers.


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

Branch: refs/heads/two-dot-o
Commit: 6ea99402f75f86a19fd206edd8dc46a42b454c65
Parents: 7752cb9
Author: Dave Johnson <dm...@apigee.com>
Authored: Tue Oct 7 07:21:19 2014 -0400
Committer: Dave Johnson <dm...@apigee.com>
Committed: Tue Oct 7 07:21:19 2014 -0400

----------------------------------------------------------------------
 .../persistence/map/MapManagerFactory.java      |  2 +-
 .../persistence/map/MapManagerTest.java         | 21 ++++++++++----------
 2 files changed, 11 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6ea99402/stack/corepersistence/map/src/main/java/org/apache/usergrid/persistence/map/MapManagerFactory.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/map/src/main/java/org/apache/usergrid/persistence/map/MapManagerFactory.java b/stack/corepersistence/map/src/main/java/org/apache/usergrid/persistence/map/MapManagerFactory.java
index 1575765..a60cdfc 100644
--- a/stack/corepersistence/map/src/main/java/org/apache/usergrid/persistence/map/MapManagerFactory.java
+++ b/stack/corepersistence/map/src/main/java/org/apache/usergrid/persistence/map/MapManagerFactory.java
@@ -26,5 +26,5 @@ public interface MapManagerFactory {
     /**
      * Get the map manager
      */
-    public MapManager getMapManager( final MapScope scope );
+    public MapManager createMapManager( final MapScope scope );
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6ea99402/stack/corepersistence/map/src/test/java/org/apache/usergrid/persistence/map/MapManagerTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/map/src/test/java/org/apache/usergrid/persistence/map/MapManagerTest.java b/stack/corepersistence/map/src/test/java/org/apache/usergrid/persistence/map/MapManagerTest.java
index 09942a5..f1cc519 100644
--- a/stack/corepersistence/map/src/test/java/org/apache/usergrid/persistence/map/MapManagerTest.java
+++ b/stack/corepersistence/map/src/test/java/org/apache/usergrid/persistence/map/MapManagerTest.java
@@ -20,7 +20,6 @@
 package org.apache.usergrid.persistence.map;
 
 
-import org.apache.usergrid.persistence.collection.UUIDComparatorTest;
 import org.jukito.UseModules;
 import org.junit.Before;
 import org.junit.Rule;
@@ -65,7 +64,7 @@ public class MapManagerTest {
 
     @Test
     public void writeReadString() {
-        MapManager mm = mmf.getMapManager( this.scope );
+        MapManager mm = mmf.createMapManager( this.scope );
 
         final String key = "key";
         final String value = "value";
@@ -79,7 +78,7 @@ public class MapManagerTest {
 
     @Test
     public void writeReadUUID() {
-        MapManager mm = mmf.getMapManager( this.scope );
+        MapManager mm = mmf.createMapManager( this.scope );
 
         final String key = "key";
         final UUID value = UUID.randomUUID();
@@ -93,7 +92,7 @@ public class MapManagerTest {
 
     @Test
     public void writeReadLong() {
-        MapManager mm = mmf.getMapManager( this.scope );
+        MapManager mm = mmf.createMapManager( this.scope );
 
         final String key = "key";
         final Long value = 1234L;
@@ -108,7 +107,7 @@ public class MapManagerTest {
 
     @Test
     public void readMissingEntry() {
-        MapManager mm = mmf.getMapManager( this.scope );
+        MapManager mm = mmf.createMapManager( this.scope );
 
         final String returned = mm.getString( "key" );
 
@@ -126,7 +125,7 @@ public class MapManagerTest {
 
     @Test
     public void deleteString() {
-        MapManager mm = mmf.getMapManager( this.scope );
+        MapManager mm = mmf.createMapManager( this.scope );
 
         final String key = "key";
         final String value = "value";
@@ -146,7 +145,7 @@ public class MapManagerTest {
 
     @Test
     public void deleteUUID() {
-        MapManager mm = mmf.getMapManager( this.scope );
+        MapManager mm = mmf.createMapManager( this.scope );
 
         final String key = "key";
         final UUID value = UUID.randomUUID();
@@ -166,7 +165,7 @@ public class MapManagerTest {
 
     @Test
     public void deleteLong() {
-        MapManager mm = mmf.getMapManager( this.scope );
+        MapManager mm = mmf.createMapManager( this.scope );
 
         final String key = "key";
         final Long value = 1L;
@@ -187,20 +186,20 @@ public class MapManagerTest {
 
     @Test( expected = NullPointerException.class )
     public void nullInputString() {
-        MapManager mm = mmf.getMapManager( this.scope );
+        MapManager mm = mmf.createMapManager( this.scope );
 
         mm.putString( null, null );
     }
 
     @Test( expected = NullPointerException.class )
     public void nullInputLong() {
-        MapManager mm = mmf.getMapManager( this.scope );
+        MapManager mm = mmf.createMapManager( this.scope );
 
         mm.putLong( null, null );
     }
     @Test( expected = NullPointerException.class )
      public void nullInputUUID() {
-        MapManager mm = mmf.getMapManager( this.scope );
+        MapManager mm = mmf.createMapManager( this.scope );
 
         mm.putUuid( null, null );
     }


[3/5] git commit: Formatting and import cleanup only.

Posted by sn...@apache.org.
Formatting and import cleanup only.


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

Branch: refs/heads/two-dot-o
Commit: 79bebe6736b2d94141550de265535b097c71ef0b
Parents: 6ea9940
Author: Dave Johnson <dm...@apigee.com>
Authored: Tue Oct 7 07:21:43 2014 -0400
Committer: Dave Johnson <dm...@apigee.com>
Committed: Tue Oct 7 07:21:43 2014 -0400

----------------------------------------------------------------------
 .../CpEntityIndexDeleteListener.java            | 23 +++++++++++++-------
 1 file changed, 15 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/79bebe67/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityIndexDeleteListener.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityIndexDeleteListener.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityIndexDeleteListener.java
index 3d4d661..125b90b 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityIndexDeleteListener.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityIndexDeleteListener.java
@@ -42,6 +42,7 @@ import rx.Observable;
 import rx.functions.Func1;
 import rx.schedulers.Schedulers;
 
+
 /**
  * Listener for cleans up old indexes and deletes from indexer
  */
@@ -51,6 +52,7 @@ public class CpEntityIndexDeleteListener {
     private final SerializationFig serializationFig;
     private final EntityIndexFactory entityIndexFactory;
 
+
     @Inject
     public CpEntityIndexDeleteListener(final EntityIndexFactory entityIndexFactory,
                                        SerializationFig serializationFig) {
@@ -60,32 +62,37 @@ public class CpEntityIndexDeleteListener {
 
 
     public Observable<EntityVersion> receive(final MvccEntityDeleteEvent event) {
+
         final CollectionScope collectionScope = event.getCollectionScope();
-        final IndexScope indexScope = new IndexScopeImpl(collectionScope.getOwner(), collectionScope.getName());
-        final EntityIndex entityIndex = entityIndexFactory.createEntityIndex(new ApplicationScopeImpl( collectionScope.getApplication()));
+        final IndexScope indexScope = 
+                new IndexScopeImpl(collectionScope.getOwner(), collectionScope.getName());
+        final EntityIndex entityIndex = entityIndexFactory.createEntityIndex(
+                new ApplicationScopeImpl( collectionScope.getApplication()));
+
         return Observable.create(new ObservableIterator<CandidateResult>("deleteEsIndexVersions") {
             @Override
             protected Iterator<CandidateResult> getIterator() {
-                CandidateResults results = entityIndex.getEntityVersions(indexScope, event.getEntity().getId());
+                CandidateResults results = 
+                        entityIndex.getEntityVersions(indexScope, event.getEntity().getId());
                 return results.iterator();
             }
         }).subscribeOn(Schedulers.io())
                 .buffer(serializationFig.getBufferSize())
                 .flatMap(new Func1<List<CandidateResult>, Observable<? extends EntityVersion>>() {
+
                     @Override
-                    public Observable<? extends EntityVersion> call(List<CandidateResult> candidateResults) {
+                    public Observable<? extends EntityVersion> call(List<CandidateResult> crs) {
                         List<EntityVersion> versions = new ArrayList<>();
-                        for (CandidateResult entity : candidateResults) {
+                        for (CandidateResult entity : crs) {
                             //filter find entities <= current version
                             if (entity.getVersion().timestamp() <= event.getVersion().timestamp()) {
                                 versions.add(entity);
-                                entityIndex.createBatch().deindex(indexScope, entity.getId(), entity.getVersion());
+                                entityIndex.createBatch()
+                                        .deindex(indexScope, entity.getId(), entity.getVersion());
                             }
                         }
                         return Observable.from(versions);
                     }
                 });
     }
-
-
 }