You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sf...@apache.org on 2015/09/15 01:06:19 UTC
[1/3] usergrid git commit: handle errors
Repository: usergrid
Updated Branches:
refs/heads/two-dot-o-dev 2faa80567 -> 723ee3ab1
handle errors
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/001a7e38
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/001a7e38
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/001a7e38
Branch: refs/heads/two-dot-o-dev
Commit: 001a7e385f3e96d9d6a43b99344aa128c64f87c0
Parents: 5680173
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Sep 14 13:34:04 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Sep 14 13:34:04 2015 -0600
----------------------------------------------------------------------
.../rx/impl/AllApplicationsObservableImpl.java | 36 +++-----
.../migration/MvccEntityDataMigrationImpl.java | 94 +++++++++++---------
.../model/entity/MapToEntityConverter.java | 4 +-
3 files changed, 66 insertions(+), 68 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/001a7e38/stack/core/src/main/java/org/apache/usergrid/corepersistence/rx/impl/AllApplicationsObservableImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/rx/impl/AllApplicationsObservableImpl.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/rx/impl/AllApplicationsObservableImpl.java
index 9c766a8..e54da0c 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/rx/impl/AllApplicationsObservableImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/rx/impl/AllApplicationsObservableImpl.java
@@ -93,37 +93,27 @@ public class AllApplicationsObservableImpl implements AllApplicationsObservable
//we have app infos. For each of these app infos, we have to load the application itself
Observable<ApplicationScope> appIds = gm.loadEdgesFromSource(
new SimpleSearchByEdgeType( rootAppId, edgeType, Long.MAX_VALUE, SearchByEdgeType.Order.DESCENDING,
- Optional.absent() ) ).flatMap( new Func1<Edge, Observable<ApplicationScope>>() {
- @Override
- public Observable<ApplicationScope> call( final Edge edge ) {
-
- //get the app info and load it
- final Id appInfo = edge.getTargetNode();
-
- return collectionManager.load( appInfo )
- //filter out null entities
- .filter( new Func1<Entity, Boolean>() {
- @Override
- public Boolean call( final Entity entity ) {
+ Optional.absent() ) ).flatMap(edge -> {
+
+ //get the app info and load it
+ final Id appInfo = edge.getTargetNode();
+
+ return collectionManager.load( appInfo )
+ //filter out null entities
+ .filter(entity -> {
if ( entity == null ) {
logger.warn( "Encountered a null application info for id {}", appInfo );
return false;
}
return true;
- }
- } )
- //get the id from the entity
- .map( new Func1<Entity, ApplicationScope>() {
-
- @Override
- public ApplicationScope call( final Entity entity ) {
+ })
+ //get the id from the entity
+ .map(entity -> {
final UUID uuid =entity.getId().getUuid();
return getApplicationScope( uuid );
- }
- } );
- }
- } );
+ });
+ });
return Observable.merge( systemIds, appIds );
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/001a7e38/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/MvccEntityDataMigrationImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/MvccEntityDataMigrationImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/MvccEntityDataMigrationImpl.java
index e825bbc..86fd701 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/MvccEntityDataMigrationImpl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/MvccEntityDataMigrationImpl.java
@@ -142,9 +142,13 @@ public class MvccEntityDataMigrationImpl implements DataMigration<EntityIdScope>
EntityToSaveMessage> subscriber ) {
while ( allVersions.hasNext() ) {
- final EntityToSaveMessage message =
- new EntityToSaveMessage( currentScope, allVersions.next() );
- subscriber.onNext( message );
+ try {
+ final EntityToSaveMessage message =
+ new EntityToSaveMessage(currentScope, allVersions.next());
+ subscriber.onNext(message);
+ }catch (Exception e){
+ LOGGER.error("Failed to load entity " +entityIdScope.getId(),e);
+ }
}
subscriber.onCompleted();
@@ -159,62 +163,66 @@ public class MvccEntityDataMigrationImpl implements DataMigration<EntityIdScope>
for ( EntityToSaveMessage message : entities ) {
- final MutationBatch entityRewrite = migration.to.write( message.scope, message.entity );
+ try {
+ final MutationBatch entityRewrite = migration.to.write(message.scope, message.entity);
- //add to
- // the
- // total
- // batch
- totalBatch.mergeShallow( entityRewrite );
+ //add to
+ // the
+ // total
+ // batch
+ totalBatch.mergeShallow(entityRewrite);
- //write
- // the
- // unique values
+ //write
+ // the
+ // unique values
- if ( !message.entity.getEntity().isPresent() ) {
- return;
- }
+ if (!message.entity.getEntity().isPresent()) {
+ return;
+ }
- final Entity entity = message.entity.getEntity().get();
+ final Entity entity = message.entity.getEntity().get();
- final Id entityId = entity.getId();
+ final Id entityId = entity.getId();
- final UUID version = message.entity.getVersion();
+ final UUID version = message.entity.getVersion();
- toSaveIds.add( entityId );
+ toSaveIds.add(entityId);
- // re-write the unique
- // values
- // but this
- // time with
- // no TTL so that cleanup can clean up
- // older values
- for (final Field field : EntityUtils.getUniqueFields( message.entity.getEntity().get() ) ) {
+ // re-write the unique
+ // values
+ // but this
+ // time with
+ // no TTL so that cleanup can clean up
+ // older values
+ for (final Field field : EntityUtils.getUniqueFields(message.entity.getEntity().get())) {
- final UniqueValue written = new UniqueValueImpl( field, entityId, version );
+ final UniqueValue written = new UniqueValueImpl(field, entityId, version);
- final MutationBatch mb = uniqueValueSerializationStrategy.write( message.scope, written );
+ final MutationBatch mb = uniqueValueSerializationStrategy.write(message.scope, written);
- // merge into our
- // existing mutation
- // batch
- totalBatch.mergeShallow( mb );
- }
+ // merge into our
+ // existing mutation
+ // batch
+ totalBatch.mergeShallow(mb);
+ }
- //add all our log entries
- final List<MvccLogEntry> logEntries = mvccLogEntrySerializationStrategy.load( message.scope,
- message.entity.getId(), version, 1000 );
+ //add all our log entries
+ final List<MvccLogEntry> logEntries = mvccLogEntrySerializationStrategy.load(message.scope,
+ message.entity.getId(), version, 1000);
- /**
- * Migrate the log entry to the new format
- */
- for(final MvccLogEntry entry: logEntries){
- final MutationBatch mb = mvccLogEntrySerializationStrategy.write( message.scope, entry );
+ /**
+ * Migrate the log entry to the new format
+ */
+ for (final MvccLogEntry entry : logEntries) {
+ final MutationBatch mb = mvccLogEntrySerializationStrategy.write(message.scope, entry);
- totalBatch.mergeShallow( mb );
+ totalBatch.mergeShallow(mb);
+ }
+ }catch (Exception e){
+ LOGGER.error("Failed to migrate entity "+ message.entity.getId().getUuid()+ " :: " + message.entity.getId().getType(),e);
}
@@ -232,7 +240,7 @@ public class MvccEntityDataMigrationImpl implements DataMigration<EntityIdScope>
}
- } ).subscribeOn( Schedulers.io() );
+ } ).subscribeOn(Schedulers.io());
}, 10) );
http://git-wip-us.apache.org/repos/asf/usergrid/blob/001a7e38/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/MapToEntityConverter.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/MapToEntityConverter.java b/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/MapToEntityConverter.java
index dbd1b2a..c0db81b 100644
--- a/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/MapToEntityConverter.java
+++ b/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/MapToEntityConverter.java
@@ -238,9 +238,9 @@ public class MapToEntityConverter{
} else {
//can't process non enties
logger.warn(
- "entity cannot process location values that don't have valid location{latitude,longitude} values"
+ "entity cannot process location values that don't have valid location{latitude,longitude} values, changing to generic object"
);
- // entity.setField(new EntityObjectField(fieldName,fromMap( value, false))); // recursion
+ entity.setField(new EntityObjectField(fieldName,fromMap( value, false))); // recursion
}
}
}
[3/3] usergrid git commit: Merge branch 'two-dot-o-dev' of
https://git-wip-us.apache.org/repos/asf/usergrid into two-dot-o-dev
Posted by sf...@apache.org.
Merge branch 'two-dot-o-dev' of https://git-wip-us.apache.org/repos/asf/usergrid into two-dot-o-dev
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/723ee3ab
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/723ee3ab
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/723ee3ab
Branch: refs/heads/two-dot-o-dev
Commit: 723ee3ab115fb4785b5a8556e564460034cb0a4f
Parents: 6f0bf9e 2faa805
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Sep 14 16:40:13 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Sep 14 16:40:13 2015 -0600
----------------------------------------------------------------------
.../creating-and-managing-notifications.md | 2 ++
portal/bower.json | 2 +-
portal/js/libs/usergrid.sdk.js | 8 +++++---
portal/package.json | 2 +-
.../apache/usergrid/persistence/entities/Notification.java | 7 +++----
.../usergrid/services/notifications/gcm/GCMAdapter.java | 2 +-
.../services/notifications/apns/NotificationsServiceIT.java | 2 +-
.../services/notifications/gcm/NotificationsServiceIT.java | 2 +-
8 files changed, 15 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
[2/3] usergrid git commit: change location to entity field
Posted by sf...@apache.org.
change location to entity field
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/6f0bf9ec
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/6f0bf9ec
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/6f0bf9ec
Branch: refs/heads/two-dot-o-dev
Commit: 6f0bf9eccbeb2052e1bce4992edb182a97fd3c2a
Parents: 001a7e3
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Sep 14 14:04:18 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Sep 14 14:04:18 2015 -0600
----------------------------------------------------------------------
.../corepersistence/CpEntityMapUtilsTest.java | 4 +-
.../org/apache/usergrid/persistence/GeoIT.java | 52 +++++++++++++++++++-
.../model/entity/MapToEntityConverter.java | 4 --
3 files changed, 53 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/6f0bf9ec/stack/core/src/test/java/org/apache/usergrid/corepersistence/CpEntityMapUtilsTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/CpEntityMapUtilsTest.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/CpEntityMapUtilsTest.java
index 325e51f..b53f7ae 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/CpEntityMapUtilsTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/CpEntityMapUtilsTest.java
@@ -133,14 +133,14 @@ public class CpEntityMapUtilsTest {
cpEntity = CpEntityMapUtils.fromMap(properties, "loc", true);
- assertNull(cpEntity.getFieldMap().get("location"));
+ assertTrue(cpEntity.getFieldMap().get("location") instanceof EntityObjectField);
properties = new LinkedHashMap<String, Object>();
properties.put("location", "denver");
cpEntity = CpEntityMapUtils.fromMap(properties, "loc", true);
- assertNull(cpEntity.getFieldMap().get("location") );
+ assertTrue(cpEntity.getFieldMap().get("location") instanceof StringField);
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/6f0bf9ec/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
index 8d71826..230f9be 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
@@ -33,7 +33,7 @@ import org.apache.usergrid.utils.MapUtils;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-
+import static org.junit.Assert.assertTrue;
public class GeoIT extends AbstractCoreIT {
@@ -252,6 +252,56 @@ public class GeoIT extends AbstractCoreIT {
}
@Test
+ public void testNonGeolocationEntities() throws Exception {
+ //1. load test entities
+ EntityManager em = app.getEntityManager();
+ assertNotNull(em);
+
+ List<Map<String, Object>> locations =
+ new ArrayList<Map<String, Object>>();
+
+
+ locations.add(new LinkedHashMap<String, Object>() {{
+ put("name", "norwest");
+ put("location", "texas");
+ }});
+ locations.add(new LinkedHashMap<String, Object>() {{
+ put("type", "store");
+ put("name", "ashfield");
+ put("location", "new jersey");
+ }});
+
+ //2. load test entities
+ for (Map<String, Object> location : locations) {
+ Entity entity = em.create("store", location);
+ assertNotNull(entity);
+ LOG.debug("Entity {} created", entity.getProperty("name"));
+ }
+ app.refreshIndex();
+ //2. validate the size of the result
+ Query query = new Query();
+ Results listResults = em.searchCollection(em.getApplicationRef(), "stores", query);
+ assertEquals("total number of 'stores'", locations.size(), listResults.size());
+ //3. verify each entity has geo data
+ for (Entity entity : listResults.entities) {
+ Object location = entity.getProperty("location");
+ assertNotNull(location);
+ assertTrue(location instanceof String);
+ }
+
+ query = Query.fromQL("select * where location='texas'");
+ listResults = em.searchCollection(em.getApplicationRef(), "stores", query);
+ assertEquals("total number of 'stores'", 1, listResults.size());
+ //3. verify each entity has geo data
+ for (Entity entity : listResults.entities) {
+ Object location = entity.getProperty("location");
+ assertNotNull(location);
+ assertTrue(location instanceof String);
+ }
+
+ }
+
+ @Test
/**
* Load entities with location data and query them from a far away location
* 1. create entities with geo
http://git-wip-us.apache.org/repos/asf/usergrid/blob/6f0bf9ec/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/MapToEntityConverter.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/MapToEntityConverter.java b/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/MapToEntityConverter.java
index c0db81b..2357a57 100644
--- a/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/MapToEntityConverter.java
+++ b/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/MapToEntityConverter.java
@@ -56,10 +56,6 @@ public class MapToEntityConverter{
Object value = map.get( fieldName );
boolean unique = schemaManager == null ? topLevel : topLevel && schemaManager.isPropertyUnique(entityType, fieldName);
//cannot store fields that aren't locations
- if(fieldName.toLowerCase().equals(locationKey) && !(value instanceof Map)) {
- logger.warn("can't map entity with location field");
- continue;
- }
if ( value instanceof String ) {
String stringValue =(String)value;