コード例 #1
0
        private ICluster CreateClusterAndWaitUntilConnectException(Action <Builder> b, out Exception ex)
        {
            Exception tempEx  = null;
            ICluster  cluster = null;

            TestHelper.RetryAssert(
                () =>
            {
                var builder = Cluster.Builder().AddContactPoints(TestCluster.ContactPoints);
                b(builder);
                cluster = builder.Build();
                try
                {
                    tempEx = Assert.Catch <Exception>(() => cluster.Connect());
                }
                catch (Exception)
                {
                    cluster.Dispose();
                    SetupNewTestCluster();
                    Interlocked.MemoryBarrier();
                    TestCluster.DisableConnectionListener(type: "reject_startup");
                    throw;
                }
            }, 500, 20);

            Interlocked.MemoryBarrier();
            ex = tempEx;
            return(cluster);
        }
コード例 #2
0
        protected override void CreateCommonSession()
        {
            Exception last = null;

            for (var i = 0; i < SharedCloudClusterTest.MaxRetries; i++)
            {
                try
                {
                    Cluster = CreateCluster();
                    SetBaseSession(Cluster.Connect());
                    return;
                }
                catch (Exception ex)
                {
                    last = ex;
                    Task.Delay(1000).GetAwaiter().GetResult();
                    if (Cluster != null)
                    {
                        Cluster.Dispose();
                        Cluster = null;
                    }
                }
            }
            throw last;
        }
コード例 #3
0
 public void TearDown()
 {
     if (_cluster != null)
     {
         _cluster.Dispose();
     }
 }
コード例 #4
0
        public void OneTimeTearDown()
        {
            _cluster.CloseBucket(_bucket);

            _clusterManager.RemoveBucket(BucketName);
            _cluster.Dispose();
        }
コード例 #5
0
        public void Dispose()
        {
            try
            {
                _logger.LogInformation("Disconnecting from SQL Server...");
                _sqlConnection.Close();
                _sqlConnection.Dispose();
                _logger.LogInformation("Done");
            }
            catch (Exception ex)
            {
                _logger.LogError($"something went wrong: {ex.Message}");
            }

            try
            {
                _logger.LogInformation("Disconnecting from Couchbase...");
                _cluster.Dispose();
                _logger.LogInformation("Done");
            }
            catch (Exception ex)
            {
                _logger.LogError($"something went wrong: {ex.Message}");
            }
        }
コード例 #6
0
        public void TestFixtureTearDown()
        {
            _cluster.CloseBucket(_bucket);

            _clusterManager.RemoveBucket(BucketName);
            _cluster.Dispose();
        }
コード例 #7
0
        protected async Task <ISession> CreateSessionAsync(
            string creds = "creds-v1.zip", int retries = SharedCloudClusterTest.MaxRetries, Action <Builder> act = null)
        {
            Exception last    = null;
            ICluster  cluster = null;

            for (var i = 0; i < SharedCloudClusterTest.MaxRetries; i++)
            {
                try
                {
                    cluster = CreateTemporaryCluster(creds, act);
                    return(await cluster.ConnectAsync().ConfigureAwait(false));
                }
                catch (Exception ex)
                {
                    last = ex;
                    Task.Delay(1000).GetAwaiter().GetResult();
                    if (cluster != null)
                    {
                        cluster.Dispose();
                        cluster = null;
                    }
                }
            }
            throw last;
        }
コード例 #8
0
 private void Disconnect()
 {
     _cluster.CloseBucket(_bucket);
     _bucket.Dispose();
     _bucket = null;
     _cluster.Dispose();
     _cluster = null;
 }
コード例 #9
0
 public void OneTimeTearDown()
 {
     if (_cluster != null)
     {
         _cluster.Dispose();
         _cluster = null;
     }
 }
コード例 #10
0
 public void Dispose()
 {
     if (!_disposed && _cluster != null)
     {
         _disposed = true;
         _cluster.Dispose();
     }
 }
コード例 #11
0
 public void TestFixtureTearDown()
 {
     if (_cluster != null)
     {
         _cluster.Dispose();
         _cluster = null;
     }
 }
コード例 #12
0
 public void Disconnect()
 {
     _cluster.CloseBucket(Bucket);
     Bucket.Dispose();
     Bucket = null;
     _cluster.Dispose();
     _cluster = null;
 }
        private void Shutdown()
        {
            _trace.TraceInformation("Shutdown()");

            if (_cluster != null)
            {
                _cluster.Dispose();
            }
        }
コード例 #14
0
 private void CloseClusterConnection()
 {
     if (_cluster != null)
     {
         _cluster?.Dispose();
         _cluster = null;
         _userNotifier.ClusterConnectionChanged(_clusterFactoryPlugin.ClusterName, false);
     }
 }
コード例 #15
0
        public override void Dispose()
        {
            if (null != _prepared)
            {
                _prepared.Dispose();
            }

            _cluster.Dispose();
            ClusterManager.Shutdown();
        }
コード例 #16
0
        public void Dispose()
        {
            if (!_disposed)
            {
                _disposed = true;

                _cluster?.Dispose();
                _cluster = null;
            }
        }
コード例 #17
0
 /// <summary>
 /// Handle disposing of the session-state store object
 /// </summary>
 public override void Dispose()
 {
     lock (_syncObj)
     {
         if (_cluster != null)
         {
             _cluster.Dispose();
             _cluster = null;
         }
     }
 }
コード例 #18
0
        protected static void DisposeSourceSessionAndCluster()
        {
            if (_sourceSession == null || _sourceSession.IsDisposed)
            {
                return;
            }

            _logger.LogInformation("Disposing source's cluster and session...");

            _sourceSession.Dispose();
            _sourceCluster.Dispose();
        }
コード例 #19
0
        /// <summary>
        /// Disconnects from the database. Upon failure, errors are silently ignored, since we can't do
        /// much about them anyway.
        /// </summary>
        private void Disconnect()
        {
            try
            {
                if (_session != null && !_session.IsDisposed)
                {
                    _session.Dispose();
                }

                _cluster.Dispose();
            }
            catch (Exception) { }
        }
コード例 #20
0
        public void Dispose()
        {
            if (!_disposed)
            {
                _disposed = true;

                if (_cluster != null)
                {
                    _cluster.Dispose();
                    _cluster = null;
                }
            }
        }
コード例 #21
0
        public static void Main(string[] args)
        {
            var names = SerialPort.GetPortNames();

            var logger                = new DefaultLogger();
            var gamePluginsManager    = new PluginsManager <IGamePlugin>(logger);
            var clusterPluginsManager = new PluginsManager <ICluster>(logger);

            var gamePlugins    = gamePluginsManager.ReloadPlugins("Plugins");
            var clusterPlugins = clusterPluginsManager.ReloadPlugins("Plugins");
            var gamePlugin     = gamePlugins[1];

            cluster = clusterPlugins[0];
            //gamePlugin.GameStateChanged += PluginGameStateChanged;
            //gamePlugin.GameDataChanged += PluginGameDataChanged;

            // var connected = cluster.Connect(new ClusterConfiguration { PortName = "COM3" });

            Console.ReadKey();
            cluster.Dispose();
            //gamePlugin.Dispose();
        }
コード例 #22
0
        /// <summary>
        /// Unregisters and disposes the cluster.
        /// </summary>
        /// <param name="cluster">The cluster.</param>
        public void UnregisterAndDisposeCluster(ICluster cluster)
        {
            Ensure.IsNotNull(cluster, nameof(cluster));

            lock (_lock)
            {
                ClusterKey clusterKey = null;
                foreach (var keyValuePair in _registry)
                {
                    if (object.ReferenceEquals(keyValuePair.Value, cluster))
                    {
                        clusterKey = keyValuePair.Key;
                        break;
                    }
                }

                if (clusterKey != null)
                {
                    _registry.Remove(clusterKey);
                }
            }

            cluster.Dispose();
        }
コード例 #23
0
 public void TearDown()
 {
     _cluster?.Dispose();
     _cluster = null;
 }
コード例 #24
0
 public void TestFixtureTearDown()
 {
     _cluster.Dispose();
 }
コード例 #25
0
 public void TestFixtureTearDown()
 {
     _cluster.CloseBucket(_bucket);
     _cluster.Dispose();
 }
コード例 #26
0
        /// <summary>
        /// Unregisters and disposes the cluster.
        /// </summary>
        /// <param name="cluster">The cluster.</param>
        public void UnregisterAndDisposeCluster(ICluster cluster)
        {
            Ensure.IsNotNull(cluster, nameof(cluster));

            lock (_lock)
            {
                ClusterKey clusterKey = null;
                foreach (var keyValuePair in _registry)
                {
                    if (object.ReferenceEquals(keyValuePair.Value, cluster))
                    {
                        clusterKey = keyValuePair.Key;
                        break;
                    }
                }

                if (clusterKey != null)
                {
                    _registry.Remove(clusterKey);
                }
            }

            cluster.Dispose();
        }
コード例 #27
0
 public void TearDown()
 {
     _cluster.Dispose();
 }
コード例 #28
0
 public void OneTimeTearDown()
 {
     _cluster.Dispose();
 }
コード例 #29
0
 public void Dispose()
 {
     _cluster.Dispose();
     _transactions.Dispose();
 }
コード例 #30
0
 public void OneTimeTearDown()
 {
     _cluster.CloseBucket(_bucket);
     _cluster.Dispose();
 }
コード例 #31
0
 public void SuiteConfigurationTearDown()
 {
     DropDatabase();
     __cluster.Dispose();
 }