usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [13/18] usergrid git commit: Merge branch 'release-2.1.1' into usergrid-1268-akka-211
Date Mon, 02 May 2016 21:42:25 GMT
Merge branch 'release-2.1.1' into usergrid-1268-akka-211

Conflicts:
	stack/core/src/main/java/org/apache/usergrid/corepersistence/index/CollectionSettingsCacheImpl.java
	stack/rest/src/main/java/org/apache/usergrid/rest/applications/CollectionResource.java
	stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java


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

Branch: refs/heads/usergrid-1268-akka-211
Commit: 6eec0d2fed1c6e293c7e9315cdfe66bcc6f3106c
Parents: f770666 2622690
Author: Dave Johnson <snoopdave@apache.org>
Authored: Mon Apr 25 16:37:39 2016 -0400
Committer: Dave Johnson <snoopdave@apache.org>
Committed: Mon Apr 25 16:37:39 2016 -0400

----------------------------------------------------------------------
 .../usergrid/corepersistence/CoreModule.java    |   2 +-
 .../corepersistence/CpEntityManager.java        |   4 +-
 .../index/CollectionSettingsCacheFactory.java   |   4 +-
 .../index/CollectionSettingsCacheFig.java       |  39 +++++
 .../index/CollectionSettingsCacheImpl.java      |   6 +-
 .../index/IndexSchemaCacheFig.java              |  39 -----
 .../org/apache/usergrid/utils/StringUtils.java  |   8 ++
 .../usergrid/persistence/queue/QueueFig.java    |   4 +-
 .../org/apache/usergrid/rest/RootResource.java  |  25 ++++
 .../rest/applications/CollectionResource.java   |   4 -
 .../apache/usergrid/rest/NotificationsIT.java   |   6 +-
 .../collection/CollectionsResourceIT.java       |  27 +---
 .../events/ApplicationRequestCounterIT.java     |  48 +++++++
 .../notifications/NotificationsService.java     |   5 +-
 .../services/notifications/TaskManager.java     | 117 ++++++++-------
 .../impl/ApplicationQueueManagerImpl.java       | 143 +++++++++++++------
 .../gcm/NotificationsServiceIT.java             |  77 ++++++++++
 17 files changed, 382 insertions(+), 176 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/6eec0d2f/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
----------------------------------------------------------------------
diff --cc stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
index ffdeaca,2d57131..ac51e9b
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
@@@ -141,7 -181,7 +141,7 @@@ public class CoreModule extends Abstrac
  
          install( new GuicyFigModule( ApplicationIdCacheFig.class ) );
  
--        install( new GuicyFigModule( IndexSchemaCacheFig.class ) );
++        install( new GuicyFigModule( CollectionSettingsCacheFig.class ) );
  
          install( new GuicyFigModule( EntityManagerFig.class ) );
  

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6eec0d2f/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6eec0d2f/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/CollectionSettingsCacheFactory.java
----------------------------------------------------------------------
diff --cc stack/core/src/main/java/org/apache/usergrid/corepersistence/index/CollectionSettingsCacheFactory.java
index 6c720ef,0000000..981f4ab
mode 100644,000000..100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/CollectionSettingsCacheFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/CollectionSettingsCacheFactory.java
@@@ -1,44 -1,0 +1,44 @@@
 +/*
 + * Licensed to the Apache Software Foundation (ASF) under one or more
 + * contributor license agreements.  See the NOTICE file distributed with
 + * this work for additional information regarding copyright ownership.
 + * The ASF licenses this file to You under the Apache License, Version 2.0
 + * (the "License"); you may not use this file except in compliance with
 + * the License.  You may obtain a copy of the License at
 + *
 + *      http://www.apache.org/licenses/LICENSE-2.0
 + *
 + * Unless required by applicable law or agreed to in writing, software
 + * distributed under the License is distributed on an "AS IS" BASIS,
 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 + * See the License for the specific language governing permissions and
 + * limitations under the License.
 + */
 +
 +package org.apache.usergrid.corepersistence.index;
 +
 +
 +import org.apache.usergrid.persistence.map.MapManager;
 +
 +import com.google.inject.Inject;
 +import com.google.inject.Singleton;
 +
 +
 +/**
 + * This can only be implemented after we have the impl for the application cache.
 + */
 +@Singleton
 +public class CollectionSettingsCacheFactory {
-     private final IndexSchemaCacheFig fig;
++    private final CollectionSettingsCacheFig fig;
 +
 +    @Inject
-     public CollectionSettingsCacheFactory(IndexSchemaCacheFig fig){
++    public CollectionSettingsCacheFactory(CollectionSettingsCacheFig fig){
 +        this.fig = fig;
 +    }
 +
 +    public CollectionSettingsCache getInstance(MapManager mapManager ){
 +        return new CollectionSettingsCacheImpl( mapManager,fig );
 +    }
 +
 +
 +}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6eec0d2f/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/CollectionSettingsCacheFig.java
----------------------------------------------------------------------
diff --cc stack/core/src/main/java/org/apache/usergrid/corepersistence/index/CollectionSettingsCacheFig.java
index 0000000,0000000..ddc4117
new file mode 100644
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/CollectionSettingsCacheFig.java
@@@ -1,0 -1,0 +1,39 @@@
++package org.apache.usergrid.corepersistence.index;/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements.  See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache License, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License.  You may obtain a copy of the License at
++ *
++ *      http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the License for the specific language governing permissions and
++ * limitations under the License.
++ */
++
++
++import org.safehaus.guicyfig.Default;
++import org.safehaus.guicyfig.FigSingleton;
++import org.safehaus.guicyfig.GuicyFig;
++import org.safehaus.guicyfig.Key;
++
++
++/**
++ * Collection settings cache config
++ */
++@FigSingleton
++public interface CollectionSettingsCacheFig extends GuicyFig {
++
++    @Key( "usergrid.collection_settings_cache_size" )
++    @Default( "5000" )
++    int getCacheSize();
++
++    @Key( "usergrid.collection_settings_cache_timeout_ms" )
++    @Default( "15000" )
++    int getCacheTimeout();
++
++}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6eec0d2f/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/CollectionSettingsCacheImpl.java
----------------------------------------------------------------------
diff --cc stack/core/src/main/java/org/apache/usergrid/corepersistence/index/CollectionSettingsCacheImpl.java
index 1cd81b9,0000000..d08e89a
mode 100644,000000..100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/CollectionSettingsCacheImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/CollectionSettingsCacheImpl.java
@@@ -1,122 -1,0 +1,122 @@@
 +/*
 + * Licensed to the Apache Software Foundation (ASF) under one or more
 + * contributor license agreements.  See the NOTICE file distributed with
 + * this work for additional information regarding copyright ownership.
 + * The ASF licenses this file to You under the Apache License, Version 2.0
 + * (the "License"); you may not use this file except in compliance with
 + * the License.  You may obtain a copy of the License at
 + *
 + *      http://www.apache.org/licenses/LICENSE-2.0
 + *
 + * Unless required by applicable law or agreed to in writing, software
 + * distributed under the License is distributed on an "AS IS" BASIS,
 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 + * See the License for the specific language governing permissions and
 + * limitations under the License.
 + */
 +
 +package org.apache.usergrid.corepersistence.index;
 +
 +
 +import com.google.common.base.Optional;
 +import com.google.common.cache.CacheBuilder;
 +import com.google.common.cache.CacheLoader;
 +import com.google.common.cache.LoadingCache;
 +import com.google.inject.Singleton;
 +import org.apache.usergrid.persistence.map.MapManager;
 +import org.apache.usergrid.utils.JsonUtils;
 +import org.slf4j.Logger;
 +import org.slf4j.LoggerFactory;
 +
 +import java.util.Map;
++import java.util.concurrent.TimeUnit;
 +
 +
 +/**
 + * Cache collection settings to reduce load on Cassandra.
 + */
 +@Singleton
 +public class CollectionSettingsCacheImpl implements CollectionSettingsCache {
 +    private static final Logger logger = LoggerFactory.getLogger(CollectionSettingsCacheImpl.class
);
 +
 +    private final LoadingCache<String,Optional<Map<String, Object>>> indexSchemaCache;
 +    private final MapManager mapManager;
 +
 +
-     public CollectionSettingsCacheImpl( MapManager mapManager, IndexSchemaCacheFig indexSchemaCacheFig)
{
++    public CollectionSettingsCacheImpl( MapManager mapManager, CollectionSettingsCacheFig
indexSchemaCacheFig) {
 +        this.mapManager = mapManager;
 +
 +        indexSchemaCache = CacheBuilder.newBuilder()
 +            .maximumSize( indexSchemaCacheFig.getCacheSize() )
-             // I don't think we want this to expire this quickly:
-             //.expireAfterWrite( indexSchemaCacheFig.getCacheTimeout(), TimeUnit.MILLISECONDS
)
++            .expireAfterWrite( indexSchemaCacheFig.getCacheTimeout(), TimeUnit.MILLISECONDS
)
 +            .build( new CacheLoader<String, Optional<Map<String, Object>>>()
{
 +                @Override
 +                public Optional<Map<String, Object>> load( final String collectionName
) throws Exception {
 +                    return Optional.fromNullable( retrieveCollectionSchema( collectionName
) );
 +                }
 +            } );
 +    }
 +
 +    private Map retrieveCollectionSchema( final String collectionName ){
 +        String collectionIndexingSchema = mapManager.getString( collectionName );
 +        Map parsedCollectionIndexingSchema = null;
 +        if(collectionIndexingSchema!=null){
 +            return (Map) JsonUtils.parse( collectionIndexingSchema );
 +
 +        }
 +        return parsedCollectionIndexingSchema;
 +    }
 +
 +
 +    @Override
 +    public Optional<Map<String, Object>> getCollectionSettings(final String
collectionName ) {
 +
 +        try {
 +            Optional<Map<String, Object>> optionalCollectionSchema = indexSchemaCache.get(
collectionName );
 +            if(!optionalCollectionSchema.isPresent()){
 +                indexSchemaCache.invalidate( collectionName );
 +                return Optional.absent();
 +            }
 +            return optionalCollectionSchema;
 +
 +        } catch ( Exception e ) {
 +            if(logger.isDebugEnabled()){
 +                logger.debug( "Returning for collection name: {} "
 +                    + "resulted in the following failure: {}",collectionName,e );
 +            }
 +        }
 +        return null;
 +    }
 +
 +    @Override
 +    public void putCollectionSettings(final String collectionName, final String collectionSchema
){
 +        mapManager.putString( collectionName, collectionSchema );
 +        evictCollectionSettings( collectionName );
 +    }
 +
 +
 +    @Override
 +    public void deleteCollectionSettings(final String collectionName){
 +        mapManager.delete( collectionName );
 +        evictCollectionSettings( collectionName );
 +    }
 +
 +
 +    @Override
 +    public void evictCollectionSettings(final String collectionName ) {
 +        indexSchemaCache.invalidate( collectionName );
 +        if(logger.isDebugEnabled() ){
 +            logger.debug( "Invalidated key {}",collectionName );
 +        }
 +
 +    }
 +
 +
 +    @Override
 +    public void evictCache() {
 +        indexSchemaCache.invalidateAll();
 +        if(logger.isDebugEnabled()){
 +            logger.debug( "Invalidated all keys" );
 +        }
 +    }
 +}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6eec0d2f/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexSchemaCacheFig.java
----------------------------------------------------------------------
diff --cc stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexSchemaCacheFig.java
index 0953abd,a99b48e..0000000
deleted file mode 100644,100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexSchemaCacheFig.java
+++ /dev/null
@@@ -1,39 -1,39 +1,0 @@@
--package org.apache.usergrid.corepersistence.index;/*
-- * Licensed to the Apache Software Foundation (ASF) under one or more
-- * contributor license agreements.  See the NOTICE file distributed with
-- * this work for additional information regarding copyright ownership.
-- * The ASF licenses this file to You under the Apache License, Version 2.0
-- * (the "License"); you may not use this file except in compliance with
-- * the License.  You may obtain a copy of the License at
-- *
-- *      http://www.apache.org/licenses/LICENSE-2.0
-- *
-- * Unless required by applicable law or agreed to in writing, software
-- * distributed under the License is distributed on an "AS IS" BASIS,
-- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- * See the License for the specific language governing permissions and
-- * limitations under the License.
-- */
--
--
--import org.safehaus.guicyfig.Default;
--import org.safehaus.guicyfig.FigSingleton;
--import org.safehaus.guicyfig.GuicyFig;
--import org.safehaus.guicyfig.Key;
--
--
--/**
-- * Index schema configuration.
-- */
--@FigSingleton
--public interface IndexSchemaCacheFig extends GuicyFig {
--
--    @Key( "usergrid.index_schema_cache_size" )
--    @Default( "5000" )
--    int getCacheSize();
--
--    @Key( "usergrid.index_schema_cache_timeout_ms" )
-     @Default( "60000" )
 -    @Default( "15000" )
--    int getCacheTimeout();
--
--}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6eec0d2f/stack/rest/src/main/java/org/apache/usergrid/rest/applications/CollectionResource.java
----------------------------------------------------------------------
diff --cc stack/rest/src/main/java/org/apache/usergrid/rest/applications/CollectionResource.java
index 9373b4d,1e94832..898eb3b
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/CollectionResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/CollectionResource.java
@@@ -222,13 -222,8 +222,9 @@@ public class CollectionResource extend
  
          addItemToServiceContext( ui, itemName );
  
- //        final ReIndexRequestBuilder request =
- //            createRequest().withApplicationId( services.getApplicationId() ).withCollection(
- //                String.valueOf( getServiceParameters().get( 0 ) ) ).withDelay( 50, TimeUnit.MILLISECONDS
);
- //
          IndexResource indexResource = new IndexResource(injector);
 -        return indexResource.rebuildIndexesPost( services.getApplicationId().toString(),itemName.getPath(),false,callback
);
 +        return indexResource.rebuildIndexesPost(
 +            services.getApplicationId().toString(),itemName.getPath(),false,callback );
      }
  
  }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6eec0d2f/stack/rest/src/test/java/org/apache/usergrid/rest/NotificationsIT.java
----------------------------------------------------------------------
diff --cc stack/rest/src/test/java/org/apache/usergrid/rest/NotificationsIT.java
index 1655846,1655846..fa68350
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/NotificationsIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/NotificationsIT.java
@@@ -80,13 -80,13 +80,11 @@@ public class NotificationsIT extends or
      public void testPaging() throws Exception {
  
          // this test should work even with indexing turned off for notificaitons collection
--        ArrayList<String> indexingArray = new ArrayList<>(  );
--        indexingArray.add( "none" );
          Entity payload = new Entity();
--        payload.put( "fields", indexingArray);
++        payload.put( "fields", "none");
  
          String unIndexedCollectionName = "notifications";
--        app().collection( unIndexedCollectionName ).collection( "_indexes" ).post( payload
);
++        app().collection( unIndexedCollectionName ).collection( "_settings" ).post( payload
);
          refreshIndex();
  
          // create notifier

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6eec0d2f/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
----------------------------------------------------------------------
diff --cc stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
index 2c8e305,db07c3f..c212fff
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
@@@ -18,20 -18,20 +18,12 @@@ package org.apache.usergrid.rest.applic
  
  
  import com.fasterxml.jackson.databind.JsonNode;
--
  import org.apache.commons.lang.RandomStringUtils;
  import org.apache.usergrid.persistence.Schema;
  import org.apache.usergrid.persistence.entities.Application;
--
  import org.apache.usergrid.rest.test.resource.AbstractRestIT;
--import org.apache.usergrid.rest.test.resource.model.ApiResponse;
++import org.apache.usergrid.rest.test.resource.model.*;
  import org.apache.usergrid.rest.test.resource.model.Collection;
--import org.apache.usergrid.rest.test.resource.model.Credentials;
--import org.apache.usergrid.rest.test.resource.model.Entity;
--import org.apache.usergrid.rest.test.resource.model.QueryParameters;
--import org.apache.usergrid.rest.test.resource.model.Token;
--import org.apache.usergrid.services.ServiceParameter;
--
  import org.junit.Ignore;
  import org.junit.Test;
  import org.slf4j.Logger;
@@@ -39,14 -39,14 +31,9 @@@ import org.slf4j.LoggerFactory
  
  import javax.ws.rs.BadRequestException;
  import javax.ws.rs.ClientErrorException;
--import javax.ws.rs.client.Invocation;
--import javax.ws.rs.core.MediaType;
--
  import java.io.IOException;
  import java.util.*;
  
--import org.apache.commons.lang.NullArgumentException;
--
  import static org.junit.Assert.*;
  
  
@@@ -967,14 -1002,14 +954,12 @@@ public class CollectionsResourceIT exte
  
          // create entities in an un-indexed collection
  
--        ArrayList<String> indexingArray = new ArrayList<>(  );
--        indexingArray.add( "!" );
          Entity payload = new Entity();
--        payload.put( "fields", indexingArray);
++        payload.put( "fields", "none");
  
          String randomizer = RandomStringUtils.randomAlphanumeric(10);
          String unIndexedCollectionName = "col_" + randomizer;
-         app().collection( unIndexedCollectionName ).collection( "_indexes" ).post( payload
);
 -        app().collection( unIndexedCollectionName ).collection( "_index" ).post( payload
);
++        app().collection( unIndexedCollectionName ).collection( "_settings" ).post( payload
);
          refreshIndex();
  
          String entityName1 = "unindexed1";
@@@ -1029,13 -1064,13 +1014,11 @@@
  
          // create an un-indexed entity
  
--        ArrayList<String> indexingArray = new ArrayList<>(  );
--        indexingArray.add( "!" );
          Entity payload = new Entity();
--        payload.put( "fields", indexingArray);
++        payload.put( "fields", "none");
  
          String unIndexedCollectionName = "col_" + randomizer;
-         app().collection( unIndexedCollectionName ).collection( "_indexes" ).post( payload
);
 -        app().collection( unIndexedCollectionName ).collection( "_index" ).post( payload
);
++        app().collection( unIndexedCollectionName ).collection( "_settings" ).post( payload
);
          refreshIndex();
  
          String entityName1 = "unindexed1";


Mime
View raw message