Search in sources :

Example 1 with PeriodicNotificationProvider

use of org.apache.rya.periodic.notification.recovery.PeriodicNotificationProvider in project incubator-rya by apache.

the class PeriodicNotificationApplicationFactory method addRegisteredNotices.

private static void addRegisteredNotices(final NotificationCoordinatorExecutor coord, final Snapshot sx) {
    coord.start();
    final PeriodicNotificationProvider provider = new PeriodicNotificationProvider();
    provider.processRegisteredNotifications(coord, sx);
}
Also used : PeriodicNotificationProvider(org.apache.rya.periodic.notification.recovery.PeriodicNotificationProvider)

Example 2 with PeriodicNotificationProvider

use of org.apache.rya.periodic.notification.recovery.PeriodicNotificationProvider in project incubator-rya by apache.

the class PeriodicNotificationProviderIT method testProvider.

@Test
public void testProvider() throws MalformedQueryException, InterruptedException, UnsupportedQueryException {
    String sparql = // n
    "prefix function: <http://org.apache.rya/function#> " + // n
    "prefix time: <http://www.w3.org/2006/time#> " + // n
    "select ?id (count(?obs) as ?total) where {" + // n
    "Filter(function:periodic(?time, 1, .25, time:minutes)) " + // n
    "?obs <uri:hasTime> ?time. " + // n
    "?obs <uri:hasId> ?id } group by ?id";
    BlockingQueue<TimestampedNotification> notifications = new LinkedBlockingQueue<>();
    PeriodicNotificationCoordinatorExecutor coord = new PeriodicNotificationCoordinatorExecutor(2, notifications);
    PeriodicNotificationProvider provider = new PeriodicNotificationProvider();
    CreateFluoPcj pcj = new CreateFluoPcj();
    String id = null;
    try (FluoClient fluo = new FluoClientImpl(getFluoConfiguration())) {
        id = pcj.createPcj(FluoQueryUtils.createNewPcjId(), sparql, Sets.newHashSet(), fluo).getQueryId();
        provider.processRegisteredNotifications(coord, fluo.newSnapshot());
    }
    TimestampedNotification notification = notifications.take();
    Assert.assertEquals(5000, notification.getInitialDelay());
    Assert.assertEquals(15000, notification.getPeriod());
    Assert.assertEquals(TimeUnit.MILLISECONDS, notification.getTimeUnit());
    Assert.assertEquals(FluoQueryUtils.convertFluoQueryIdToPcjId(id), notification.getId());
}
Also used : FluoClient(org.apache.fluo.api.client.FluoClient) FluoClientImpl(org.apache.fluo.core.client.FluoClientImpl) PeriodicNotificationCoordinatorExecutor(org.apache.rya.periodic.notification.coordinator.PeriodicNotificationCoordinatorExecutor) TimestampedNotification(org.apache.rya.periodic.notification.notification.TimestampedNotification) CreateFluoPcj(org.apache.rya.indexing.pcj.fluo.api.CreateFluoPcj) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) PeriodicNotificationProvider(org.apache.rya.periodic.notification.recovery.PeriodicNotificationProvider) Test(org.junit.Test)

Aggregations

PeriodicNotificationProvider (org.apache.rya.periodic.notification.recovery.PeriodicNotificationProvider)2 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)1 FluoClient (org.apache.fluo.api.client.FluoClient)1 FluoClientImpl (org.apache.fluo.core.client.FluoClientImpl)1 CreateFluoPcj (org.apache.rya.indexing.pcj.fluo.api.CreateFluoPcj)1 PeriodicNotificationCoordinatorExecutor (org.apache.rya.periodic.notification.coordinator.PeriodicNotificationCoordinatorExecutor)1 TimestampedNotification (org.apache.rya.periodic.notification.notification.TimestampedNotification)1 Test (org.junit.Test)1