private void UpdateReplications(string syncURL) { if (_puller != null) { _puller.Stop(); } if(_pusher != null) { _pusher.Stop(); } if (String.IsNullOrEmpty(syncURL)) { return; } var uri = new Uri(syncURL); _puller = _db.CreatePullReplication(uri); _puller.Continuous = true; _puller.Start(); _pusher = _db.CreatePushReplication(uri); _pusher.Continuous = true; _pusher.Start(); }
public virtual void RunReplication(Replication replication) { CountDownLatch replicationDoneSignal = new CountDownLatch(1); LiteTestCase.ReplicationFinishedObserver replicationFinishedObserver = new LiteTestCase.ReplicationFinishedObserver (replicationDoneSignal); replication.AddChangeListener(replicationFinishedObserver); replication.Start(); CountDownLatch replicationDoneSignalPolling = ReplicationWatcherThread(replication ); Log.D(Tag, "Waiting for replicator to finish"); try { bool success = replicationDoneSignal.Await(300, TimeUnit.Seconds); NUnit.Framework.Assert.IsTrue(success); success = replicationDoneSignalPolling.Await(300, TimeUnit.Seconds); NUnit.Framework.Assert.IsTrue(success); Log.D(Tag, "replicator finished"); } catch (Exception e) { Sharpen.Runtime.PrintStackTrace(e); } replication.RemoveChangeListener(replicationFinishedObserver); }
private IEnumerator Start () { Debug.LogFormat ("Data path = {0}", Application.persistentDataPath); #if UNITY_EDITOR_WIN Log.SetLogger(new UnityLogger()); #endif _db = Manager.SharedInstance.GetDatabase ("spaceshooter"); _pull = _db.CreatePullReplication (GameController.SYNC_URL); _pull.Continuous = true; _pull.Start (); while (_pull != null && _pull.Status == ReplicationStatus.Active) { yield return new WaitForSeconds(0.5f); } var doc = _db.GetExistingDocument ("player_data"); if (doc != null) { //We have a record! Get the ship data, if possible. string assetName = String.Empty; if(doc.UserProperties.ContainsKey("ship_data")) { assetName = doc.UserProperties ["ship_data"] as String; } StartCoroutine(LoadAsset (assetName)); } else { //Create a new record doc = _db.GetDocument("player_data"); doc.PutProperties(new Dictionary<string, object> { { "ship_data", String.Empty } }); } doc.Change += DocumentChanged; _push = _db.CreatePushReplication (new Uri ("http://127.0.0.1:4984/spaceshooter")); _push.Start(); }
protected virtual void RunReplication(Replication replication) { var replicationDoneSignal = new CountdownEvent(1); var observer = new ReplicationObserver(replicationDoneSignal); replication.Changed += observer.Changed; replication.Start(); var success = replicationDoneSignal.Wait(TimeSpan.FromSeconds(60)); Assert.IsTrue(success); replication.Changed -= observer.Changed; }
protected override void RunReplication(Replication replication) { var replicationDoneSignal = new CountdownEvent(1); var observer = new ReplicationObserver(replicationDoneSignal); replication.Changed += observer.Changed; replication.Start(); var replicationDoneSignalPolling = ReplicationWatcherThread(replication); var success = replicationDoneSignal.Wait(TimeSpan.FromSeconds(15)); Assert.IsTrue(success); success = replicationDoneSignalPolling.Wait(TimeSpan.FromSeconds(15)); Assert.IsTrue(success); replication.Changed -= observer.Changed; }
/// <exception cref="System.Exception"></exception> public virtual void TestGetActiveReplications() { Uri remote = GetReplicationURL(); Replication replication = (Replication)database.CreatePullReplication(remote); NUnit.Framework.Assert.AreEqual(0, database.GetAllReplications().Count); NUnit.Framework.Assert.AreEqual(0, database.GetActiveReplications().Count); replication.Start(); NUnit.Framework.Assert.AreEqual(1, database.GetAllReplications().Count); NUnit.Framework.Assert.AreEqual(1, database.GetActiveReplications().Count); CountDownLatch replicationDoneSignal = new CountDownLatch(1); LiteTestCase.ReplicationFinishedObserver replicationFinishedObserver = new LiteTestCase.ReplicationFinishedObserver (replicationDoneSignal); replication.AddChangeListener(replicationFinishedObserver); bool success = replicationDoneSignal.Await(60, TimeUnit.Seconds); NUnit.Framework.Assert.IsTrue(success); NUnit.Framework.Assert.AreEqual(1, database.GetAllReplications().Count); NUnit.Framework.Assert.AreEqual(0, database.GetActiveReplications().Count); }
public void StartSync(string syncUrl) { Uri uri; try { uri = new Uri(syncUrl); } catch(UriFormatException) { Log.E("TaskManager", "Invalid URL {0}", syncUrl); return; } if(_pull == null) { _pull = _db.CreatePullReplication(uri); _pull.Continuous = true; _pull.Start(); } if(_push == null) { _push = _db.CreatePushReplication(uri); _push.Continuous = true; _push.Start(); } }
private void RunReplication(Replication replication) { var replicationDoneSignal = new CountDownLatch(1); var observer = new ReplicationObserver(replicationDoneSignal); replication.Changed += observer.Changed; replication.Start(); var replicationDoneSignalPolling = ReplicationWatcherThread(replication); Log.D(Tag, "Waiting for replicator to finish."); var success = replicationDoneSignal.Await(TimeSpan.FromSeconds(15)); Assert.IsTrue(success); success = replicationDoneSignalPolling.Wait(TimeSpan.FromSeconds(15)); Assert.IsTrue(success); Log.D(Tag, "replicator finished"); replication.Changed -= observer.Changed; }
protected virtual void RunReplication(Replication replication) { var replicationDoneSignal = new CountdownEvent(1); var observer = new ReplicationObserver(replicationDoneSignal); replication.Changed += observer.Changed; replication.Start(); var success = replicationDoneSignal.Wait(TimeSpan.FromSeconds(60)); Assert.IsTrue(success); replication.Changed -= observer.Changed; }
void StartPushChanges() { string uri = "http://" + hostName + ":" + portNumber.ToString() + "/" + databaseName; pushReplication = database.CreatePushReplication (new Uri (uri)); pushReplication.Start (); }
IEnumerator DoReplication(Replication replication) { replication.Start (); while (replication != null && replication.Status == ReplicationStatus.Active) { yield return new WaitForSeconds(0.5f); } }
void StartReplication () { if (StringEx.IsNullOrWhiteSpace (replicationUrl)) { Log.E (TAG, "Replication URL not set"); return; } _puller = _db.CreatePullReplication (new Uri(replicationUrl)); _puller.Continuous = true; _puller.Changed += (sender, e) => { Log.D (TAG, "Puller: " + _puller.LastError == null ? "Okay" : _puller.LastError.Message); }; _pusher = _db.CreatePushReplication (new Uri(replicationUrl)); _pusher.Continuous = true; _pusher.Changed += (sender, e) => { Log.D (TAG, "Pusher: " + _pusher.LastError == null ? "Okay" : _pusher.LastError.Message); }; _pusher.Start (); _puller.Start (); Log.D (TAG, "Started replication with " + replicationUrl); }
private void RunReplication(Replication replication) { // var replicationDoneSignal = new CountDownLatch(1); var replicationDoneSignalPolling = ReplicationWatcherThread(replication); replication.Changed += (sender, e) => replicationDoneSignalPolling.CountDown (); replication.Start(); Log.D(Tag, "Waiting for replicator to finish"); try { var success = replicationDoneSignalPolling.Await(TimeSpan.FromSeconds(15)); Assert.IsTrue(success); Sharpen.Thread.Sleep(5000); replication.Stop(); Log.D(Tag, "replicator finished"); } catch (Exception e) { Runtime.PrintStackTrace(e); } }
private void UpdateSync() { if (Database == null) return; var preferences = PreferenceManager.GetDefaultSharedPreferences(this); var syncUrl = preferences.GetString("sync-gateway-url", null); ForgetSync (); if (!String.IsNullOrEmpty(syncUrl)) { try { var uri = new System.Uri(syncUrl); Pull = Database.CreatePullReplication(uri); Pull.Continuous = true; Pull.Changed += ReplicationChanged; Push = Database.CreatePushReplication(uri); Push.Continuous = true; Push.Changed += ReplicationChanged; Pull.Start(); Push.Start(); } catch (Java.Lang.Throwable th) { Log.Debug(Tag, th, "UpdateSync Error"); } } }
public void StartSyncGateway(string url = "") { pull = _database.CreatePullReplication(CreateSyncUri()); push = _database.CreatePushReplication(CreateSyncUri()); var authenticator = AuthenticatorFactory.CreateBasicAuthenticator("david", "12345"); pull.Authenticator = authenticator; push.Authenticator = authenticator; pull.Continuous = true; push.Continuous = true; pull.Changed += Pull_Changed; push.Changed += Push_Changed; pull.Start(); push.Start(); }
void UpdateSyncUrl () { if (Database == null) return; Uri newRemoteUrl = null; var syncPoint = NSUserDefaults.StandardUserDefaults.StringForKey (ConfigViewController.SyncUrlKey); if (!String.IsNullOrWhiteSpace (syncPoint)) newRemoteUrl = new Uri (syncPoint); else return; ForgetSync (); pull = Database.CreatePullReplication (newRemoteUrl); push = Database.CreatePushReplication (newRemoteUrl); pull.Continuous = push.Continuous = true; pull.Changed += ReplicationProgress; push.Changed += ReplicationProgress; pull.Start(); push.Start(); }
public void TestIssue490() { var sg = new CouchDB("http", GetReplicationServer()); using (var remoteDb = sg.CreateDatabase("issue490")) { var push = database.CreatePushReplication(remoteDb.RemoteUri); CreateFilteredDocuments(database, 30); CreateNonFilteredDocuments (database, 10); RunReplication(push); Assert.IsTrue(push.ChangesCount==40); Assert.IsTrue(push.CompletedChangesCount==40); Assert.IsNull(push.LastError); Assert.AreEqual(40, database.DocumentCount); for (int i = 0; i <= 5; i++) { pull = database.CreatePullReplication(remoteDb.RemoteUri); pull.Continuous = true; pull.Start (); Task.Delay (1000).Wait(); CallToView (); Task.Delay (2000).Wait(); RecreateDatabase (); } } }
public void TestFacebookAuth() { var doneEvent = new ManualResetEvent(false); var accountStore = new ACAccountStore(); var accountType = accountStore.FindAccountType(ACAccountType.Facebook); var options = new AccountStoreOptions(); options.FacebookAppId = FacebookAppId; options.SetPermissions(ACFacebookAudience.Friends, new [] { "email" }); var success = true; ACAccount account = null; accountStore.RequestAccess(accountType, options, (result, error) => { success = result; if (success) { var accounts = accountStore.FindAccounts(accountType); account = accounts != null && accounts.Length > 0 ? accounts[0] : null; } else { Log.W(Tag, "Facebook Login needed. Go to Settings > Facebook and login."); Log.E(Tag, "Facebook Request Access Error : " + error); } doneEvent.Set(); }); doneEvent.WaitOne(TimeSpan.FromSeconds(30)); Assert.IsTrue(success); Assert.IsNotNull(account); var token = account.Credential.OAuthToken; Assert.IsNotNull(token); Assert.IsTrue(token.Length > 0); var url = GetReplicationURLWithoutCredentials(); var cookieStore = new CookieStore(); var httpClientFactory = new CouchbaseLiteHttpClientFactory(cookieStore); manager.DefaultHttpClientFactory = httpClientFactory; Replication replicator = database.CreatePushReplication(url); replicator.Authenticator = AuthenticatorFactory.CreateFacebookAuthenticator(token); Assert.IsNotNull(replicator); Assert.IsNotNull(replicator.Authenticator); Assert.IsTrue(replicator.Authenticator is TokenAuthenticator); replicator.Start(); doneEvent.Reset(); Task.Factory.StartNew(() => { var timeout = DateTime.UtcNow + TimeSpan.FromSeconds(30); while (DateTime.UtcNow < timeout) { if (!replicator.active) { break; } System.Threading.Thread.Sleep(TimeSpan.FromMilliseconds(10)); } doneEvent.Set(); }); doneEvent.WaitOne(TimeSpan.FromSeconds(35)); var urlStr = url.ToString(); urlStr = urlStr.EndsWith("/") ? urlStr : urlStr + "/"; var cookies = httpClientFactory.GetCookieContainer().GetCookies(new Uri(urlStr)); Assert.IsTrue(cookies.Count == 1); Assert.AreEqual("SyncGatewaySession", cookies[0].Name); }
protected override void RunReplication(Replication replication) { var replicationDoneSignal = new CountdownEvent(1); var observer = new ReplicationObserver(replicationDoneSignal); replication.Changed += observer.Changed; replication.Start(); var replicationDoneSignalPolling = ReplicationWatcherThread(replication); var success = replicationDoneSignal.Wait(TimeSpan.FromSeconds(15)); Assert.IsTrue(success); success = replicationDoneSignalPolling.Wait(TimeSpan.FromSeconds(15)); Assert.IsTrue(success); replication.Changed -= observer.Changed; }
private void RunReplication(Replication replication) { var replicationDoneSignal = new CountDownLatch(1); var observer = new ReplicationObserver(replicationDoneSignal); replication.Changed += observer.Changed; replication.Start(); var replicationDoneSignalPolling = ReplicationWatcherThread(replication); Log.D(Tag, "Waiting for replicator to finish."); var success = replicationDoneSignal.Await(TimeSpan.FromSeconds(15)); Assert.IsTrue(success); success = replicationDoneSignalPolling.Wait(TimeSpan.FromSeconds(15)); Assert.IsTrue(success); Log.D(Tag, "replicator finished"); replication.Changed -= observer.Changed; }
private void RunReplication(Replication replication) { CountDownLatch replicationDoneSignal = new CountDownLatch(1); ReplicationTest.ReplicationObserver replicationObserver = new ReplicationTest.ReplicationObserver (this, replicationDoneSignal); replication.AddChangeListener(replicationObserver); replication.Start(); CountDownLatch replicationDoneSignalPolling = ReplicationWatcherThread(replication ); Log.D(Tag, "Waiting for replicator to finish"); try { bool success = replicationDoneSignal.Await(300, TimeUnit.Seconds); NUnit.Framework.Assert.IsTrue(success); success = replicationDoneSignalPolling.Await(300, TimeUnit.Seconds); NUnit.Framework.Assert.IsTrue(success); Log.D(Tag, "replicator finished"); } catch (Exception e) { Sharpen.Runtime.PrintStackTrace(e); } }
private void RunReplication(Replication replication) { var replicationDoneSignal = new CountdownEvent(1); var observer = new ReplicationObserver(replicationDoneSignal); replication.Changed += observer.Changed; replication.Start(); var replicationDoneSignalPolling = ReplicationWatcherThread(replication, observer); Log.D(Tag, "Waiting for replicator to finish."); var success = WaitHandle.WaitAll(new[] { replicationDoneSignal.WaitHandle, replicationDoneSignalPolling.WaitHandle }, 60*1000); Assert.IsTrue(success); Log.D(Tag, "replicator finished"); replication.Changed -= observer.Changed; }
IEnumerator StartPullChanges() { string uri = "http://" + hostName + ":" + portNumber.ToString() + "/" + databaseName; /*****DO IT LATER*********************************************** try{ pullReplication.Authenticator = facebookAuthenticator; }catch (NullReferenceException e){ Debug.Log ("At StartPullChanges: " + e.Message); } ****************************************************************/ pullReplication = database.CreatePullReplication (new Uri (uri)); pullReplication.Continuous = true; pullReplication.Start (); while (pullReplication != null && pullReplication.Status == ReplicationStatus.Active) { yield return new WaitForSeconds(0.5f); } }