You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by mr...@apache.org on 2017/04/06 02:01:38 UTC
usergrid git commit: Add new push notification test and remove
duplicate index processing on entity create/update.
Repository: usergrid
Updated Branches:
refs/heads/master d3e988bcb -> 949b46506
Add new push notification test and remove duplicate index processing on entity create/update.
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/949b4650
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/949b4650
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/949b4650
Branch: refs/heads/master
Commit: 949b4650608ce9ecd3d3bea10ff81d7fe7f8be2f
Parents: d3e988b
Author: Michael Russo <ru...@google.com>
Authored: Wed Apr 5 19:01:11 2017 -0700
Committer: Michael Russo <ru...@google.com>
Committed: Wed Apr 5 19:01:11 2017 -0700
----------------------------------------------------------------------
.../batch/service/JobSchedulerService.java | 8 ++--
.../batch/service/SchedulerServiceImpl.java | 2 +-
.../asyncevents/AsyncEventServiceImpl.java | 14 ++----
.../org/apache/usergrid/ServiceITSetup.java | 3 ++
.../org/apache/usergrid/ServiceITSetupImpl.java | 17 ++++---
.../apns/NotificationsServiceIT.java | 47 +++++++++++++++++---
6 files changed, 62 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/949b4650/stack/core/src/main/java/org/apache/usergrid/batch/service/JobSchedulerService.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/batch/service/JobSchedulerService.java b/stack/core/src/main/java/org/apache/usergrid/batch/service/JobSchedulerService.java
index 807daa3..23a86af 100644
--- a/stack/core/src/main/java/org/apache/usergrid/batch/service/JobSchedulerService.java
+++ b/stack/core/src/main/java/org/apache/usergrid/batch/service/JobSchedulerService.java
@@ -129,9 +129,9 @@ public class JobSchedulerService extends AbstractScheduledService {
}
for ( JobDescriptor jd : activeJobs ) {
- logger.info( "Submitting work for {}", jd );
+ logger.debug( "Submitting work for {}", jd );
submitWork( jd );
- logger.info( "Work submitted for {}", jd );
+ logger.debug( "Work submitted for {}", jd );
}
}
}
@@ -228,7 +228,7 @@ public class JobSchedulerService extends AbstractScheduledService {
// TODO wrap and throw specifically typed exception for onFailure,
// needs jobId
- logger.info( "Starting job {} with execution data {}", job, execution );
+ logger.debug( "Starting job {} with execution data {}", job, execution );
job.execute( execution );
@@ -259,7 +259,7 @@ public class JobSchedulerService extends AbstractScheduledService {
//TODO, refactor into the execution itself for checking if done
if ( execution.getStatus() == Status.IN_PROGRESS ) {
- logger.info( "Successful completion of bulkJob {}", execution );
+ logger.debug( "Successful completion of bulkJob {}", execution );
execution.completed();
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/949b4650/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 af933f6..9b3714c 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
@@ -305,7 +305,7 @@ public class SchedulerServiceImpl implements SchedulerService, JobAccessor, JobR
getEm().update( data );
}
- logger.info( "Updating stats for job {}", data.getJobName() );
+ logger.debug( "Updating stats for job {}", data.getJobName() );
getEm().update( stat );
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/949b4650/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/AsyncEventServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/AsyncEventServiceImpl.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/AsyncEventServiceImpl.java
index e565754..75d2ce0 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/AsyncEventServiceImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/AsyncEventServiceImpl.java
@@ -420,8 +420,8 @@ public class AsyncEventServiceImpl implements AsyncEventService {
if( !(event instanceof ElasticsearchIndexEvent)
&& !(event instanceof InitializeApplicationIndexEvent)
&& single.isEmpty() ){
- logger.warn("No index operation messages came back from event processing for msg: {} ",
- message.getStringBody().trim());
+ logger.warn("No index operation messages came back from event processing for eventType: {}, msgId: {}, msgBody: {}",
+ event.getClass().getSimpleName(), message.getMessageId(), message.getStringBody());
}
@@ -481,15 +481,7 @@ public class AsyncEventServiceImpl implements AsyncEventService {
entity.getId().getUuid(), entity.getId().getType());
offer(new EntityIndexEvent(queueFig.getPrimaryRegion(),
- new EntityIdScope(applicationScope, entity.getId()), 0));
-
- final EntityIndexOperation entityIndexOperation =
- new EntityIndexOperation( applicationScope, entity.getId(), updatedAfter);
-
- final IndexOperationMessage indexMessage =
- eventBuilder.buildEntityIndex( entityIndexOperation ).toBlocking().lastOrDefault(null);
-
- queueIndexOperationMessage( indexMessage, false);
+ new EntityIdScope(applicationScope, entity.getId()), updatedAfter));
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/949b4650/stack/services/src/test/java/org/apache/usergrid/ServiceITSetup.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/ServiceITSetup.java b/stack/services/src/test/java/org/apache/usergrid/ServiceITSetup.java
index 6cdb0ea..ee5313e 100644
--- a/stack/services/src/test/java/org/apache/usergrid/ServiceITSetup.java
+++ b/stack/services/src/test/java/org/apache/usergrid/ServiceITSetup.java
@@ -17,6 +17,7 @@
package org.apache.usergrid;
+import org.apache.usergrid.batch.service.JobSchedulerService;
import org.apache.usergrid.management.ApplicationCreator;
import org.apache.usergrid.management.ManagementService;
import org.apache.usergrid.management.export.ExportService;
@@ -44,6 +45,8 @@ public interface ServiceITSetup extends CoreITSetup {
ImportService getImportService();
+ JobSchedulerService getJobSchedulerService();
+
void refreshIndex(UUID appid);
/**
http://git-wip-us.apache.org/repos/asf/usergrid/blob/949b4650/stack/services/src/test/java/org/apache/usergrid/ServiceITSetupImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/ServiceITSetupImpl.java b/stack/services/src/test/java/org/apache/usergrid/ServiceITSetupImpl.java
index ac40ae3..0308e15 100644
--- a/stack/services/src/test/java/org/apache/usergrid/ServiceITSetupImpl.java
+++ b/stack/services/src/test/java/org/apache/usergrid/ServiceITSetupImpl.java
@@ -19,6 +19,7 @@ package org.apache.usergrid;
import java.util.Properties;
+import org.apache.usergrid.batch.service.JobSchedulerService;
import org.apache.usergrid.corepersistence.GuiceFactory;
import org.apache.usergrid.management.AppInfoMigrationPlugin;
import org.junit.runner.Description;
@@ -36,13 +37,7 @@ import org.apache.usergrid.persistence.cassandra.CassandraService;
import org.apache.usergrid.security.providers.SignInProviderFactory;
import org.apache.usergrid.security.tokens.TokenService;
import org.apache.usergrid.services.ServiceManagerFactory;
-import org.junit.runner.Description;
-import org.junit.runners.model.Statement;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.config.PropertiesFactoryBean;
-import java.util.Properties;
import java.util.UUID;
@@ -59,6 +54,7 @@ public class ServiceITSetupImpl extends CoreITSetupImpl implements ServiceITSetu
private ExportService exportService;
private ImportService importService;
private AppInfoMigrationPlugin appInfoMigrationPlugin;
+ private JobSchedulerService jobSchedulerService;
public ServiceITSetupImpl() {
@@ -72,6 +68,8 @@ public class ServiceITSetupImpl extends CoreITSetupImpl implements ServiceITSetu
smf = springResource.getBean( ServiceManagerFactory.class );
exportService = springResource.getBean( ExportService.class );
importService = springResource.getBean( ImportService.class );
+ jobSchedulerService = springResource.getBean(JobSchedulerService.class);
+
try {
appInfoMigrationPlugin = springResource.getBean(GuiceFactory.class)
@@ -125,12 +123,19 @@ public class ServiceITSetupImpl extends CoreITSetupImpl implements ServiceITSetu
return managementService;
}
+
+
@Override
public ExportService getExportService() { return exportService; }
@Override
public ImportService getImportService() { return importService; }
+ @Override
+ public JobSchedulerService getJobSchedulerService() {
+ return jobSchedulerService;
+ }
+
public ServiceManagerFactory getSmf() {
if ( smf == null ) {
http://git-wip-us.apache.org/repos/asf/usergrid/blob/949b4650/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
index 1c3bbcd..4fb9add 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
@@ -16,6 +16,7 @@
*/
package org.apache.usergrid.services.notifications.apns;
+import com.google.common.util.concurrent.Service;
import com.relayrides.pushy.apns.util.*;
import net.jcip.annotations.NotThreadSafe;
import org.apache.commons.io.IOUtils;
@@ -118,6 +119,11 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
listener = new QueueListener(ns.getServiceManagerFactory(),ns.getEntityManagerFactory(), new Properties());
listener.start();
+
+ if ( !setup.getJobSchedulerService().isRunning()) {
+ setup.getJobSchedulerService().startAsync();
+ setup.getJobSchedulerService().awaitRunning();
+ }
}
@After
@@ -290,14 +296,41 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
notification = app.getEntityManager().get(e.getUuid(), Notification.class);
assertEquals(Notification.State.SCHEDULED, notification.getState());
+ }
+
+ @Test
+ public void scheduledNotificationAndEnsureSend() throws Exception {
+
+ // create push notification //
+ app.clear();
+ String payload = getPayload();
+ Map<String, String> payloads = new HashMap<String, String>(1);
+ payloads.put(notifier.getUuid().toString(), payload);
+ app.put("payloads", payloads);
+ app.put("deliver", System.currentTimeMillis() + 2000);
+ app.put("debug",true);
+
+ Entity e = app.testRequest(ServiceAction.POST, 1,"devices",device1.getUuid(), "notifications")
+ .getEntity();
+ app.testRequest(ServiceAction.GET, 1, "notifications", e.getUuid());
+
+
+ Notification notification = app.getEntityManager().get(e.getUuid(),
+ Notification.class);
+ assertEquals(
+ notification.getPayloads().get(notifier.getUuid().toString()),
+ payload);
+
+
+ // delay until the scheduler has time to run
+ logger.info("Sleeping while the scheduler does its work");
+ Thread.sleep(5000);
+
+
+ notification = app.getEntityManager().get(e.getUuid(), Notification.class);
+
+ assertEquals(Notification.State.FINISHED, notification.getState());
-// try {
-// e = app.testRequest(ServiceAction.DELETE, 1, "notifications",
-// e.getUuid()).getEntity();
-// }catch (Exception deleteException){
-// LOG.error("Couldn't delete",deleteException);
-// }
-// app.getEntityManager().get(e.getUuid(), Notification.class);
}
@Test