Repository: incubator-usergrid Updated Branches: refs/heads/two-dot-o-dev 34fd9cf33 -> 014162335
adding background tasks Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/381d8c57 Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/381d8c57 Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/381d8c57 Branch: refs/heads/two-dot-o-dev Commit: 381d8c57f2156ed3783a5d570cfdd92c7bfd5be1 Parents: 5594d74 Author: Shawn Feldman <sfeld...@apache.org> Authored: Wed Apr 22 18:09:49 2015 -0600 Committer: Shawn Feldman <sfeld...@apache.org> Committed: Wed Apr 22 18:09:49 2015 -0600 ---------------------------------------------------------------------- .../Usergrid.Notifications/BackgroundTask.cs | 57 ++++++++++++++++++++ .../Client/IUsergridClient.cs | 2 +- .../Usergrid.Notifications/Client/PushClient.cs | 12 +++-- .../Usergrid.Notifications/MainPage.xaml.cs | 14 +++-- .../Usergrid.Notifications/MyBackgroundTask.cs | 18 +++++++ .../Usergrid.Notifications/Package.appxmanifest | 8 +++ .../Usergrid.Notifications.csproj | 1 + .../Usergrid.Notifications.sln | 40 ++++++++++++++ .../persistence/query/IteratingQueryIT.java | 54 +++++++++---------- 9 files changed, 170 insertions(+), 36 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/381d8c57/sdks/dotnet/samples/notifications/Usergrid.Notifications/BackgroundTask.cs ---------------------------------------------------------------------- diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/BackgroundTask.cs b/sdks/dotnet/samples/notifications/Usergrid.Notifications/BackgroundTask.cs new file mode 100644 index 0000000..1096ca8 --- /dev/null +++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/BackgroundTask.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Windows.ApplicationModel.Background; + +namespace Usergrid.Notifications +{ + public sealed class ExampleBackgroundTask : IBackgroundTask + { + private static BackgroundTaskRegistration task; + public void Run(IBackgroundTaskInstance taskInstance) + { + var test = ""; + + } + public static void Register() + { + + foreach (var iter in BackgroundTaskRegistration.AllTasks) + { + IBackgroundTaskRegistration mytask = iter.Value; + if (mytask.Name == "ExampleBackgroundTask") + { + + mytask.Unregister(true); + break; + } + } + + + var builder = new BackgroundTaskBuilder(); + PushNotificationTrigger trigger = new PushNotificationTrigger(); + builder.SetTrigger(trigger); + builder.Name = "ExampleBackgroundTask"; + builder.TaskEntryPoint = "Usergrid.Notifications.ExampleBackgroundTask"; + + ExampleBackgroundTask.task = builder.Register(); + task.Progress += task_Progress; + + task.Completed += task_Completed; + + } + + static void task_Progress(BackgroundTaskRegistration sender, BackgroundTaskProgressEventArgs args) + { + + var test = "done"; + } + + static void task_Completed(BackgroundTaskRegistration sender, BackgroundTaskCompletedEventArgs args) + { + var test = "done"; + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/381d8c57/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/IUsergridClient.cs ---------------------------------------------------------------------- diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/IUsergridClient.cs b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/IUsergridClient.cs index 5efbb9b..5279e32 100644 --- a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/IUsergridClient.cs +++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/IUsergridClient.cs @@ -108,7 +108,7 @@ namespace Usergrid.Notifications.Client /// <param name="message"></param> /// <returns></returns> Task<bool> SendToast(string message); - Task<bool> SendRaw(string message); + Task<bool> SendRaw(JObject message); /// <summary> /// Send a badge update /// </summary> http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/381d8c57/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/PushClient.cs ---------------------------------------------------------------------- diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/PushClient.cs b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/PushClient.cs index 343e28b..54d7b00 100644 --- a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/PushClient.cs +++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/PushClient.cs @@ -86,7 +86,7 @@ namespace Usergrid.Notifications.Client } - public async Task<bool> SendRaw(String message) + public async Task<bool> SendRaw(JObject message) { if (DeviceId == null) { @@ -95,7 +95,7 @@ namespace Usergrid.Notifications.Client var jsonObject = new JObject(); var payloads = new JObject(); var payload = new JObject(); - payload.Add("raw", new JValue(message)); + payload.Add("raw", message); payloads.Add(Notifier, payload); jsonObject.Add("payloads", payloads); jsonObject.Add("debug", true); @@ -107,6 +107,8 @@ namespace Usergrid.Notifications.Client { channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync().AsTask<PushNotificationChannel>(); channel.PushNotificationReceived += channel_PushNotificationReceived; + ExampleBackgroundTask.Register(); + if (settings.Values[DEVICE_KEY] == null) { Guid uuid = await registerDevice(true); @@ -134,7 +136,11 @@ namespace Usergrid.Notifications.Client void channel_PushNotificationReceived(PushNotificationChannel sender, PushNotificationReceivedEventArgs args) { - throw new NotImplementedException(); + var test = "test"; + if (args.NotificationType == PushNotificationType.Raw) + { + + } } http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/381d8c57/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml.cs ---------------------------------------------------------------------- diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml.cs b/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml.cs index 2120eeb..80b6dd8 100644 --- a/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml.cs +++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/MainPage.xaml.cs @@ -1,4 +1,5 @@ -/* +using Newtonsoft.Json.Linq; +/* * * * Licensed to the Apache Software Foundation (ASF) under one or more * * contributor license agreements. The ASF licenses this file to You @@ -44,7 +45,7 @@ namespace Usergrid.Notifications { this.InitializeComponent(); //TODO: change me to your server - serverUrl = "http://server/"; + serverUrl = "http://yoururl/"; //TODO: change me to your org org = "test-organization"; //TODO: change me to your app @@ -52,9 +53,9 @@ namespace Usergrid.Notifications //TODO: change me to your notifier name notifier = "windows"; //TODO: change me to your user - user = "test"; + user = "mobileuser"; //TODO: change me to your password - password = "test"; + password = "password"; this.NavigationCacheMode = NavigationCacheMode.Required; usergrid = new Client.Usergrid(serverUrl, org, app, user, password, notifier); @@ -126,7 +127,10 @@ namespace Usergrid.Notifications Result.Text = "Sending...."; var message = this.pushText.Text; - if (await usergrid.Push.SendRaw(message)) + + JObject obj = new JObject(); + obj.Add("message", message); + if (await usergrid.Push.SendRaw(obj)) { Result.Text = "It did! :)"; } http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/381d8c57/sdks/dotnet/samples/notifications/Usergrid.Notifications/MyBackgroundTask.cs ---------------------------------------------------------------------- diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/MyBackgroundTask.cs b/sdks/dotnet/samples/notifications/Usergrid.Notifications/MyBackgroundTask.cs new file mode 100644 index 0000000..9d8a446 --- /dev/null +++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/MyBackgroundTask.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Windows.ApplicationModel.Background; + +namespace Usergrid.Notifications +{ + + public sealed class ExampleBackgroundTask : IBackgroundTask + { + public void Run(IBackgroundTaskInstance taskInstance) + { + + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/381d8c57/sdks/dotnet/samples/notifications/Usergrid.Notifications/Package.appxmanifest ---------------------------------------------------------------------- diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Package.appxmanifest b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Package.appxmanifest index 03165e6..2eec1a9 100644 --- a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Package.appxmanifest +++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Package.appxmanifest @@ -45,6 +45,14 @@ <m3:Rotation Preference="portrait" /> </m3:InitialRotationPreference> </m3:VisualElements> + <Extensions> + <Extension Category="windows.backgroundTasks" EntryPoint="Usergrid.Notifications.ExampleBackgroundTask"> + <BackgroundTasks> + <Task Type="pushNotification" /> + </BackgroundTasks> + </Extension> + + </Extensions> </Application> </Applications> <Capabilities> http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/381d8c57/sdks/dotnet/samples/notifications/Usergrid.Notifications/Usergrid.Notifications.csproj ---------------------------------------------------------------------- diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Usergrid.Notifications.csproj b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Usergrid.Notifications.csproj index f5ec3fa..b2361e8 100644 --- a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Usergrid.Notifications.csproj +++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Usergrid.Notifications.csproj @@ -84,6 +84,7 @@ <Compile Include="App.xaml.cs"> <DependentUpon>App.xaml</DependentUpon> </Compile> + <Compile Include="BackgroundTask.cs" /> <Compile Include="Client\EntityResponse.cs" /> <Compile Include="Client\IUsergridClient.cs" /> <Compile Include="Client\PushClient.cs" /> http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/381d8c57/sdks/dotnet/samples/notifications/Usergrid.Notifications/Usergrid.Notifications.sln ---------------------------------------------------------------------- diff --git a/sdks/dotnet/samples/notifications/Usergrid.Notifications/Usergrid.Notifications.sln b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Usergrid.Notifications.sln new file mode 100644 index 0000000..79e96ec --- /dev/null +++ b/sdks/dotnet/samples/notifications/Usergrid.Notifications/Usergrid.Notifications.sln @@ -0,0 +1,40 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Usergrid.Notifications", "Usergrid.Notifications.csproj", "{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|ARM = Debug|ARM + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|ARM = Release|ARM + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|ARM.ActiveCfg = Debug|ARM + {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|ARM.Build.0 = Debug|ARM + {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|ARM.Deploy.0 = Debug|ARM + {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|x86.ActiveCfg = Debug|x86 + {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|x86.Build.0 = Debug|x86 + {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|x86.Deploy.0 = Debug|x86 + {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|Any CPU.Build.0 = Release|Any CPU + {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|Any CPU.Deploy.0 = Release|Any CPU + {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|ARM.ActiveCfg = Release|ARM + {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|ARM.Build.0 = Release|ARM + {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|ARM.Deploy.0 = Release|ARM + {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|x86.ActiveCfg = Release|x86 + {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|x86.Build.0 = Release|x86 + {EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|x86.Deploy.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/381d8c57/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java ---------------------------------------------------------------------- diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java index 3a9c5f2..3afc279 100644 --- a/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java +++ b/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java @@ -661,7 +661,7 @@ public class IteratingQueryIT { io.doSetup(); - int size = 200; + int size = 10; int queryLimit = Query.MAX_LIMIT; int matchMax = queryLimit - 1; @@ -719,9 +719,9 @@ public class IteratingQueryIT { io.doSetup(); - int size = 200; - int queryLimit = 100; - int startValue = 100; + int size = 10; + int queryLimit = 5; + int startValue = 5; long start = System.currentTimeMillis(); @@ -779,9 +779,9 @@ public class IteratingQueryIT { io.doSetup(); - int size = 200; - int queryLimit = 50; - int startValue = 100; + int size = 20; + int queryLimit = 5; + int startValue = 10; long start = System.currentTimeMillis(); @@ -839,9 +839,9 @@ public class IteratingQueryIT { io.doSetup(); - int size = 200; - int queryLimit = 100; - int startValue = 100; + int size = 20; + int queryLimit = 10; + int startValue = 10; long start = System.currentTimeMillis(); @@ -898,9 +898,9 @@ public class IteratingQueryIT { io.doSetup(); - int size = 200; - int queryLimit = 100; - int startValue = 99; + int size = 20; + int queryLimit = 10; + int startValue = 9; long start = System.currentTimeMillis(); @@ -957,10 +957,10 @@ public class IteratingQueryIT { io.doSetup(); - int size = 200; - int queryLimit = 100; - int startValue = 50; - int endValue = 150; + int size = 20; + int queryLimit = 10; + int startValue = 5; + int endValue = 15; long start = System.currentTimeMillis(); @@ -1020,10 +1020,10 @@ public class IteratingQueryIT { io.doSetup(); - int size = 200; - int queryLimit = 100; - int startValue = 50; - int endValue = 150; + int size = 20; + int queryLimit = 10; + int startValue = 5; + int endValue = 15; long start = System.currentTimeMillis(); @@ -1088,7 +1088,7 @@ public class IteratingQueryIT { io.doSetup(); - int size = 300; + int size = 30; long start = System.currentTimeMillis(); @@ -1109,7 +1109,7 @@ public class IteratingQueryIT { Thread.sleep(500); Query query = new Query(); - query.setLimit( 100 ); + query.setLimit( 10 ); int count = 0; @@ -1142,7 +1142,7 @@ public class IteratingQueryIT { io.doSetup(); - int size = 200; + int size = 20; int queryLimit = Query.MAX_LIMIT; // the number of entities that should be written including an intersection @@ -1249,7 +1249,7 @@ public class IteratingQueryIT { io.doSetup(); - int size = 200; + int size = 20; int queryLimit = Query.MAX_LIMIT; // the number of entities that should be written including an intersection @@ -1361,7 +1361,7 @@ public class IteratingQueryIT { /** * Leave this as a large size. We have to write over 1k to reproduce this issue */ - int size = 200; + int size = 20; long start = System.currentTimeMillis(); @@ -1381,7 +1381,7 @@ public class IteratingQueryIT { LOG.info( "Writes took {} ms", stop - start ); Query query = Query.fromQL("select * where NOT boolean = false order by index asc"); - query.setLimit( 20 ); + query.setLimit( 2 ); int index = 0; int count = 0;