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/04/14 04:20:05 UTC
[2/3] incubator-usergrid git commit: refactor index to use
observables for refresh
refactor index to use observables for refresh
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/f74139e7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/f74139e7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/f74139e7
Branch: refs/heads/two-dot-o-dev
Commit: f74139e76b1f09fbac9a0cf516e285326c29eda3
Parents: a971de1
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Apr 13 20:18:23 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Apr 13 20:18:23 2015 -0600
----------------------------------------------------------------------
.../batch/service/SchedulerServiceImpl.java | 2 +-
.../corepersistence/CpEntityManagerFactory.java | 9 +++++----
.../org/apache/usergrid/CoreApplication.java | 20 +-------------------
.../org/apache/usergrid/rest/IndexResource.java | 2 +-
.../rest/test/RefreshIndexResource.java | 2 +-
5 files changed, 9 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f74139e7/stack/core/src/main/java/org/apache/usergrid/batch/service/SchedulerServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/batch/service/SchedulerServiceImpl.java b/stack/core/src/main/java/org/apache/usergrid/batch/service/SchedulerServiceImpl.java
index 87c1d50..646fa23 100644
--- a/stack/core/src/main/java/org/apache/usergrid/batch/service/SchedulerServiceImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/batch/service/SchedulerServiceImpl.java
@@ -435,6 +435,6 @@ public class SchedulerServiceImpl implements SchedulerService, JobAccessor, JobR
@Override
public void refreshIndex() {
this.entityIndex = entityIndex == null ? injector.getInstance(EntityIndex.class) : entityIndex;
- entityIndex.refresh();
+ entityIndex.refreshAsync().toBlocking().last();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f74139e7/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 d38f473..9907f91 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
@@ -148,7 +148,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
em.getApplication();
}
- entityIndex.refresh();
+ entityIndex.refreshAsync().toBlocking().last();
} catch (Exception ex) {
throw new RuntimeException("Fatal error creating management application", ex);
@@ -257,7 +257,8 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
EntityManager appEm = getEntityManager( applicationId);
appEm.create(applicationId, TYPE_APPLICATION, properties);
appEm.resetRoles();
- entityIndex.refresh();
+ entityIndex.refreshAsync().toBlocking().last();
+
// create application info entity in the management app
@@ -376,7 +377,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
if (oldAppEntity != null) {
managementEm.delete(oldAppEntity);
applicationIdCache.evictAppId(oldAppEntity.getName());
- entityIndex.refresh();
+ entityIndex.refreshAsync().toBlocking().last();
}
} catch (Exception e) {
throw new RuntimeException(e);
@@ -647,7 +648,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
// refresh special indexes without calling EntityManager refresh because stack overflow
maybeCreateIndexes();
- entityIndex.refresh();
+ entityIndex.refreshAsync().toBlocking().last();
}
private void maybeCreateIndexes() {
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f74139e7/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java b/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
index a5b8da2..19f58b3 100644
--- a/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
+++ b/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
@@ -227,25 +227,7 @@ public class CoreApplication implements Application, TestRule {
@Override
public synchronized void refreshIndex() {
//Insert test entity and find it
- String type = "unittests";
- Id id = new SimpleId(UUID.randomUUID(), type);
- Map<String, Object> fields = new HashMap<>();
- fields.put("name", "unit" + id.getUuid());
- try {
- Entity find = em.create(id, fields);
- Query query = new Query().fromQL("name='" + find.getName() + "'");
- for (int i = 0; i < 20; i++) {
- Results results = em.searchCollection(em.getApplicationRef(), type, query);
- if (results.size() > 0) {
- break;
- }
- entityIndex.refresh();
- Thread.sleep(200);
- }
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
-
+ entityIndex.refreshAsync().toBlocking().last();
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f74139e7/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
index d68b894..0c477b8 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
@@ -300,7 +300,7 @@ public class IndexResource extends AbstractContextResource {
logger.info( "Reindexing for app id: {} and collection {}", applicationId, collectionName );
emf.rebuildCollectionIndex(applicationId, collectionName, reverse, po);
- getEntityIndex().refresh();
+ getEntityIndex().refreshAsync().toBlocking().last();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f74139e7/stack/rest/src/main/java/org/apache/usergrid/rest/test/RefreshIndexResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/test/RefreshIndexResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/test/RefreshIndexResource.java
index 19708e6..41d5ef5 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/test/RefreshIndexResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/test/RefreshIndexResource.java
@@ -66,7 +66,7 @@ public class RefreshIndexResource extends AbstractContextResource {
}
// refresh the system apps or app lookup below may fail
- getEntityIndex().refresh();
+ getEntityIndex().refreshAsync().toBlocking().last();
} catch (Exception e) {
logger.error("Error in refresh", e);