public CompatibilityCassandraDatabaseSetup(bool reset = false, bool toLower = false, bool toLower2 = false)
        {
            this.toLower = toLower;
            this.toLower2 = toLower2;

            ConnectionBuilder = new ConnectionBuilder(keyspace: Keyspace, server: Server, cqlVersion: CqlVersion.Cql3);
            DB = new CassandraContext(ConnectionBuilder);

            if (DB.KeyspaceExists(Keyspace))
                DB.DropKeyspace(Keyspace);

            var keyspace = new CassandraKeyspace(new CassandraKeyspaceSchema
            {
                Name = Keyspace,
            }, DB);

            var exists = DB.KeyspaceExists(Keyspace);
            if(!exists)
                keyspace.TryCreateSelf();

            Family = DB.GetColumnFamily<AsciiType>("Standard");
            SuperFamily = DB.GetColumnFamily<AsciiType, AsciiType>("Super");
            UserFamily = DB.GetColumnFamily(toLowerIf(toLower,"Users"));

            if (exists && !reset)
                return;

            ResetDatabase();
        }
		private static IConnectionProvider CreateProvider(ConnectionBuilder builder)
		{
			if (builder.Pooled)
				return new PooledConnectionProvider(builder);
			else
				return new NormalConnectionProvider(builder);
		}
Ejemplo n.º 3
0
 public RemoteTunnel(ConnectionBuilder cbuilder, ProtocolBuilder pfactory, int maxConnections = 2, int throttle = 0)
     : this(maxConnections)
 {
     CreateConnection = cbuilder;
     CreateProtocol = pfactory;
     Throttle = throttle;
 }
		/// <summary>
		/// 
		/// </summary>
		/// <param name="builder"></param>
		public PooledConnectionProvider(ConnectionBuilder builder)
			: base(builder)
		{
			PoolSize = builder.PoolSize;
			Lifetime = builder.Lifetime;

			_maintenanceTimer = new Timer(o => Cleanup(), null, 30000L, 30000L);
		}
        public void Configure(ConnectionBuilder builder)
        {
            Fiber fiber = GetConfiguredFiber(builder);

            var proxy = new WcfChannelProxy(fiber, _endpointUri, _pipeName);

            builder.AddChannel(proxy);
            builder.AddDisposable(proxy);
        }
        public async Task ClientConnectionLastWillCanSendOut()
        {
            using (StartVerifiableLog(out var loggerFactory, LogLevel.Warning, expectedErrors: c => true,
                                      logChecker: logs =>
            {
                Assert.Single(logs);
                Assert.Equal("ApplicationTaskFailed", logs[0].Write.EventId.Name);
                return(true);
            }))
            {
                var            ccm                 = new TestClientConnectionManager();
                var            ccf                 = new ClientConnectionFactory();
                var            protocol            = new ServiceProtocol();
                TestConnection transportConnection = null;
                var            connectionFactory   = new TestConnectionFactory(conn =>
                {
                    transportConnection = conn;
                    return(Task.CompletedTask);
                });
                var services          = new ServiceCollection();
                var connectionHandler = new EndlessConnectionHandler();
                services.AddSingleton(connectionHandler);
                var builder = new ConnectionBuilder(services.BuildServiceProvider());
                builder.UseConnectionHandler <EndlessConnectionHandler>();
                ConnectionDelegate handler = builder.Build();
                var connection             = new ServiceConnection(protocol, ccm, connectionFactory, loggerFactory, handler, ccf,
                                                                   "serverId", Guid.NewGuid().ToString("N"), null, null, null, closeTimeOutMilliseconds: 500);

                var connectionTask = connection.StartAsync();

                // completed handshake
                await connection.ConnectionInitializedTask.OrTimeout();

                Assert.Equal(ServiceConnectionStatus.Connected, connection.Status);
                var clientConnectionId = Guid.NewGuid().ToString();

                await transportConnection.Application.Output.WriteAsync(
                    protocol.GetMessageBytes(new OpenConnectionMessage(clientConnectionId, new Claim[] { })));

                var clientConnection = await ccm.WaitForClientConnectionAsync(clientConnectionId).OrTimeout();

                clientConnection.CancelApplication();

                // complete reading to end the connection
                transportConnection.Application.Output.Complete();

                await clientConnection.LifetimeTask.OrTimeout();

                // 1s for application task to timeout
                await connectionTask.OrTimeout(1000);

                Assert.Equal(ServiceConnectionStatus.Disconnected, connection.Status);
                Assert.Empty(ccm.ClientConnections);

                connectionHandler.CancellationToken.Cancel();
            }
        }
        private IDbConnection BuildConnection()
        {
            string            connectionString  = MySqlServer.Instance.GetConnectionString().Replace("Protocol=pipe;", "");
            ConnectionBuilder connectionBuilder = new ConnectionBuilder(MySqlClientFactory.Instance);
            IDbConnection     connection        = connectionBuilder.BuildConnection(connectionString);

            connection.Open();
            return(connection);
        }
        public void Configure(ConnectionBuilder builder, T instance)
        {
            Channel <TChannel> channel = _accessor(instance);

            if (channel != null)
            {
                builder.AddChannel(channel);
            }
        }
Ejemplo n.º 9
0
        public void SqlOrder_WithOrder_SetsOrderOnFieldType()
        {
            void Order(OrderByBuilder order, IReadOnlyDictionary <string, object> arguments,
                       IResolveFieldContext context, SqlTable sqlTable) => order.By("id");

            var builder = ConnectionBuilder.Create <ObjectGraphType, object>().SqlOrder(Order);

            builder.FieldType.GetSqlOrder().Should().Be((OrderByDelegate)Order);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 静态配置
        /// </summary>
        public static IApplicationBuilder UseConfigRegist(this IApplicationBuilder app, IConfiguration Configuration)
        {
            var reg = Configuration.Get <AppConfig>();

            //注册数据库
            ConnectionBuilder.ConfigRegist(reg.dBSetting.ConnectionString, reg.dBSetting.DBType);

            return(app);
        }
Ejemplo n.º 11
0
        private void cetak_2()
        {
            try
            {
                string text           = System.IO.File.ReadAllText("./settings2.txt");
                var    thePrinterConn = ConnectionBuilder.Build(text);
                try
                {
                    // Open the connection - physical connection is established here.
                    thePrinterConn.Open();

                    // This example prints "This is a ZPL test." near the top of the label.
                    string zplData = "^XA" +
                                     //item id
                                     "^FO015,21^A0,34,24^FD" + txt2AsalBarang.Text + "^FS" +
                                     "^FO440,21^A0,34,24^FD" + txt2AsalBarang.Text + "^FS" +
                                     //item name 1
                                     "^FO015,55^A0,34,24^FD" + txt2NamaBarang.Text + "^FS" +
                                     "^FO440,55^A0,34,24^FD" + txt2NamaBarang.Text + "^FS" +
                                     //item name 2
                                     "^FO015,89^A0,34,24^FD" + txt2TipeMobil.Text + "^FS" +
                                     "^FO440,89^A0,34,24^FD" + txt2TipeMobil.Text + "^FS" +
                                     //item name 3
                                     "^FO015,123^A0,34,24^FD" + txt2KodeJual.Text + "^FS" +
                                     "^FO440,123^A0,34,24^FD" + txt2KodeJual.Text + "^FS" +
                                     //item chinese
                                     "^FO015,156^CI28^A@N,36,30,E:SIMSUN.FNT^FD" + txt2HurufMandarin.Text + "^FS" +
                                     "^FO440,156^CI28^A@N,36,30,E:SIMSUN.FNT^FD" + txt2HurufMandarin.Text + "^FS" +
                                     "^XZ";

                    // Send the data to printer as a byte array.
                    thePrinterConn.Write(Encoding.UTF8.GetBytes(zplData));
                }
                catch (ConnectionException ex)
                {
                    // Handle communications error here.
                    Console.WriteLine(ex.ToString());
                }
                finally
                {
                    // Close the connection to release resources.
                    thePrinterConn.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Peringatan", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            txt2NamaBarang.Text    = "";
            txt2TipeMobil.Text     = "";
            txt2KodeJual.Text      = "";
            txt2KodeMandarin.Text  = "";
            txt2HurufMandarin.Text = "";
            num2Cetak.Value        = 0;
            txt2NamaBarang.Focus();
        }
        public void Configure(ConnectionBuilder builder)
        {
            Fiber fiber = this.GetFiberUsingConfiguredFactory(builder);

            foreach (var result in _results)
            {
                result.Connect(builder, fiber, _instance);
            }
        }
Ejemplo n.º 13
0
        public void SqlJoin_WhenJoinIsNull_ThrowsException()
        {
            Action action = () => ConnectionBuilder.Create <ObjectGraphType, object>().SqlJoin(null);

            action.Should()
            .Throw <ArgumentNullException>()
            .Which.ParamName.Should()
            .Be("join");
        }
Ejemplo n.º 14
0
        public ConnectionBuilder <TParentType, TGraphType, object> Connection <TParentType, TGraphType>()
            where TParentType : GraphType
            where TGraphType : ObjectGraphType, new()
        {
            var builder = ConnectionBuilder.Create <TParentType, TGraphType>();

            _fields.Add(builder.FieldType);
            return(builder);
        }
Ejemplo n.º 15
0
        /// <inheritdoc cref="ConnectionBuilder{TSourceType}.Create{TNodeType, TEdgeType}(string)"/>
        public ConnectionBuilder <TSourceType> Connection <TNodeType, TEdgeType>()
            where TNodeType : IGraphType
            where TEdgeType : EdgeType <TNodeType>
        {
            var builder = ConnectionBuilder.Create <TNodeType, TEdgeType, TSourceType>();

            AddField(builder.FieldType);
            return(builder);
        }
Ejemplo n.º 16
0
        public async Task TestServiceConnectionWithNormalApplicationTask()
        {
            using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
            {
                var            ccm                 = new TestClientConnectionManager();
                var            ccf                 = new ClientConnectionFactory();
                var            protocol            = new ServiceProtocol();
                TestConnection transportConnection = null;
                var            connectionFactory   = new TestConnectionFactory(conn =>
                {
                    transportConnection = conn;
                    return(Task.CompletedTask);
                });
                var services = new ServiceCollection();
                var builder  = new ConnectionBuilder(services.BuildServiceProvider());
                builder.UseConnectionHandler <TestConnectionHandler>();
                ConnectionDelegate handler = builder.Build();
                var connection             = new ServiceConnection(protocol, ccm, connectionFactory, loggerFactory, handler, ccf,
                                                                   "serverId", Guid.NewGuid().ToString("N"), null, null);

                var connectionTask = connection.StartAsync();

                // completed handshake
                await connection.ConnectionInitializedTask.OrTimeout();

                Assert.Equal(ServiceConnectionStatus.Connected, connection.Status);
                var clientConnectionId = Guid.NewGuid().ToString();

                await transportConnection.Application.Output.WriteAsync(
                    protocol.GetMessageBytes(new OpenConnectionMessage(clientConnectionId, new Claim[] { })));

                var clientConnection = await ccm.WaitForClientConnectionAsync(clientConnectionId).OrTimeout();

                await transportConnection.Application.Output.WriteAsync(
                    protocol.GetMessageBytes(new CloseConnectionMessage(clientConnectionId)));

                // Normal end with close message
                await ccm.WaitForClientConnectionRemovalAsync(clientConnectionId).OrTimeout();

                // another connection comes in
                clientConnectionId = Guid.NewGuid().ToString();

                await transportConnection.Application.Output.WriteAsync(
                    protocol.GetMessageBytes(new OpenConnectionMessage(clientConnectionId, new Claim[] { })));

                clientConnection = await ccm.WaitForClientConnectionAsync(clientConnectionId).OrTimeout();

                // complete reading to end the connection
                transportConnection.Application.Output.Complete();

                await connectionTask.OrTimeout();

                Assert.Equal(ServiceConnectionStatus.Disconnected, connection.Status);
                Assert.Empty(ccm.ClientConnections);
            }
        }
        public void AddNavigationConnectionField <TSource, TReturn>(
            ComplexGraphType <TSource> graph,
            string name,
            Func <ResolveEfFieldContext <TDbContext, TSource>, IEnumerable <TReturn> >?resolve = null,
            Type?itemGraphType = null,
            IEnumerable <QueryArgument>?arguments = null,
            IEnumerable <string>?includeNames     = null,
            int pageSize       = 10,
            string?description = null)
            where TReturn : class
        {
            Guard.AgainstNull(nameof(graph), graph);

            Guard.AgainstNullWhiteSpace(nameof(name), name);
            Guard.AgainstNegative(nameof(pageSize), pageSize);

            itemGraphType ??= GraphTypeFinder.FindGraphType <TReturn>();
            var fieldType = GetFieldType <TSource>(name, itemGraphType);

            var builder = ConnectionBuilder <TSource> .Create <FakeGraph>(name);

            if (description != null)
            {
                builder.Description(description);
            }
            builder.PageSize(pageSize).Bidirectional();
            SetField(builder, fieldType);
            IncludeAppender.SetIncludeMetadata(builder.FieldType, name, includeNames);

            if (resolve != null)
            {
                builder.ResolveAsync(async context =>
                {
                    var efFieldContext = BuildContext(context);

                    var enumerable = resolve(efFieldContext);

                    enumerable = enumerable.ApplyGraphQlArguments(context);
                    enumerable = await efFieldContext.Filters.ApplyFilter(enumerable, context.UserContext);
                    var page   = enumerable.ToList();

                    return(ConnectionConverter.ApplyConnectionContext(
                               page,
                               context.First,
                               context.After,
                               context.Last,
                               context.Before));
                });
            }

            var connection = builder;

            var field = graph.AddField(connection.FieldType);

            field.AddWhereArgument(arguments);
        }
        static void Main(string[] args)
        {
            var connection = new ConnectionBuilder()
                             .WithLogging()
                             .Build();

            // <string, string> = <T, T> = <InputDataType, OutputDataType>
            connection.On <string, string>("greeting", x => x + " World ! (from Core)");
            connection.Listen();
        }
        public void TestMultipleServersWithHostAndMixedPorts()
        {
            var servers = new ConnectionBuilder("Server=host:123,host2,host3:789;Connection Timeout=5").Servers;

            Assert.Equal(3, servers.Count);
            foreach (var server in servers)
            {
                Assert.Equal(5, server.Timeout);
            }
        }
		/// <summary>
		/// 
		/// </summary>
		/// <param name="builder"></param>
		public NormalConnectionProvider(ConnectionBuilder builder)
			: base(builder)
		{
			if (builder.Servers.Count > 1 && builder.Timeout == 0)
				throw new ElasticSearchException("You must specify a timeout when using multiple servers.");

			Timeout = builder.Timeout;
			ActiveServers = builder.Servers;
			TSocketSetting = builder.TSocketSetting;
		}
Ejemplo n.º 21
0
        private void Start <THub>() where THub : Hub
        {
            var app = new ConnectionBuilder(_serviceProvider)
                      .UseHub <THub>()
                      .Build();

            var dispatcher = _serviceProvider.GetRequiredService <ServiceHubDispatcher <THub> >();

            dispatcher.Start(app);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Maps incoming requests with the specified path to the provided connection pipeline.
        /// </summary>
        /// <param name="path">The request path.</param>
        /// <param name="options">Options used to configure the connection.</param>
        /// <param name="configure">A callback to configure the connection.</param>
        public void MapConnections(PathString path, HttpConnectionDispatcherOptions options, Action <IConnectionBuilder> configure)
        {
            var connectionBuilder = new ConnectionBuilder(_routes.ServiceProvider);

            configure(connectionBuilder);
            var socket = connectionBuilder.Build();

            _routes.MapRoute(path, c => _dispatcher.ExecuteAsync(c, options, socket));
            _routes.MapRoute(path + "/negotiate", c => _dispatcher.ExecuteNegotiateAsync(c, options));
        }
Ejemplo n.º 23
0
        static void Main(string[] args)
        {
            var connection = new ConnectionBuilder()
                             .WithLogging()
                             .Build();

            connection.On <string, string>("greeting", name => "Hello " + name);

            connection.Listen();
        }
Ejemplo n.º 24
0
        static void Main(string[] args)
        {
            var connection = new ConnectionBuilder()
                             .WithLogging()
                             .Build();

            connection.On <string, string>("greeting", (val) => $"Hello {val}");

            connection.Listen();
        }
Ejemplo n.º 25
0
        public static void ConfigureServices(string remoteHost, int remotePort, int localPort)
        {
            ConnectionBuilder connBuilder = new ConnectionBuilder();

            ConnServ = connBuilder.
                       ConfigureLocal(localPort)
                       .ConfigureRemote(remoteHost, remotePort)
                       .Build();
            MessageStorage = new FileStorage($@"{remoteHost}{remotePort}.txt");
            MessageServ    = new MessageService.MessageService(MessageStorage);
        }
Ejemplo n.º 26
0
 private Task<IConnection> CreateConnection(CancellationToken cancellationToken)
 {
     var ctx = new Context();
     ctx.SetRetryCount(0);
     return _connectionRetryPolicy.ExecuteAsync((context, ct) =>
     {
         var endpoint = GetCurrentEndpoint(context);
         var connectionBuilder = new ConnectionBuilder(_loggerFactory, _messageIdPolicyFactory);
         return connectionBuilder.CreateAsync(endpoint, ct);
     }, ctx, cancellationToken);
 }
Ejemplo n.º 27
0
        private ConnectionBuilder Initialize()
        {
            var connections = new ConnectionBuilder()
            {
                options_ = Options
            };

            OnConfiguring(connections);
            OnModelCreating(connections);
            return(connections);
        }
 public static void ResolveApiConnection <TEntity>(
     this ConnectionBuilder <object> builder,
     Swapi api
     ) where TEntity : Entity
 {
     builder
     .ResolveAsync(async ctx => await api
                   .GetConnectionAsync <TEntity>(ctx.GetConnectionArguments())
                   .ContinueWith(t => ctx.ToConnection(t.Result.Entities, t.Result.TotalCount))
                   );
 }
        public static Fiber GetFiberUsingConfiguredFactory <T, TChannel>(this FiberFactoryConfiguratorImpl <T> configurator,
                                                                         ConnectionBuilder <TChannel> builder)
            where T : class
        {
            FiberFactory fiberFactory = configurator.GetConfiguredFiberFactory();
            Fiber        fiber        = fiberFactory();

            builder.AddDisposable(fiber.ShutdownOnDispose(configurator.ShutdownTimeout));

            return(fiber);
        }
Ejemplo n.º 30
0
        static void Main(string[] args)
        {
            Assembly myassembly = Assembly.LoadFrom("HelloWorld.dll");
            var      connection = new ConnectionBuilder()
                                  .WithLogging()
                                  .Build();

            connection.On <string, string>("greeting", name => "The c# part sais hello: " + name);

            connection.Listen();
        }
Ejemplo n.º 31
0
        /// <summary>
        /// Sets whether the result set should be paginated.
        /// </summary>
        /// <param name="builder">The connection builder.</param>
        /// <param name="paginate">Should the result be paginated?</param>
        /// <returns>The <see cref="ConnectionBuilder{T}"/>.</returns>
        /// <exception cref="ArgumentNullException">If <paramref name="builder"/> is <c>null</c>.</exception>
        public static ConnectionBuilder <T> SqlPaginate <T>(this ConnectionBuilder <T> builder, bool paginate = true)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            builder.FieldType.SqlPaginate(paginate);

            return(builder);
        }
Ejemplo n.º 32
0
 private static IConnectionProvider CreateProvider(ConnectionBuilder builder)
 {
     if (builder.Pooled)
     {
         return(new PooledConnectionProvider(builder));
     }
     else
     {
         return(new NormalConnectionProvider(builder));
     }
 }
Ejemplo n.º 33
0
        public void SqlJoin_WithJoin_SetsJoinOnFieldType()
        {
            void Join(JoinBuilder join, IReadOnlyDictionary <string, object> arguments,
                      IResolveFieldContext context, Node sqlAstNode)
            {
            }

            var builder = ConnectionBuilder.Create <ObjectGraphType, object>().SqlJoin(Join);

            builder.FieldType.GetSqlJoin().Should().Be((JoinDelegate)Join);
        }
Ejemplo n.º 34
0
        public void SqlWhere_WithQuery_SetsQueryOnFieldType()
        {
            void Where(WhereBuilder where, IReadOnlyDictionary <string, object> arguments,
                       IResolveFieldContext context, SqlTable sqlAStNode)
            {
            }

            var builder = ConnectionBuilder.Create <ObjectGraphType, object>().SqlWhere(Where);

            builder.FieldType.GetSqlWhere().Should().Be((WhereDelegate)Where);
        }
Ejemplo n.º 35
0
        private void print_label()
        {
            String itemId      = txtItemId.Text;
            String itemName1   = txtItemName1.Text;
            String itemName2   = txtItemName2.Text;
            String itemName3   = txtItemName3.Text;
            String itemChinese = txtItemChinese.Text;
            //Connection thePrinterConn = new TcpConnection("127.0.0.1", TcpConnection.DEFAULT_ZPL_TCP_PORT);
            ///Connection thePrinterConn = new UsbConnection("Port_#0001.Hub_#0004");
            var thePrinterConn = ConnectionBuilder.Build("USB:ZDesigner GT800 (ZPL)");

            try
            {
                // Open the connection - physical connection is established here.
                thePrinterConn.Open();

                // This example prints "This is a ZPL test." near the top of the label.
                string zplData = "^XA" +
                                 //item id
                                 "^FO00,22^A0,38,26^FD" + itemId + "^FS" +
                                 "^FO290,22^A0,38,26^FD" + itemId + "^FS" +
                                 "^FO580,22^A0,38,26^FD" + itemId + "^FS" +
                                 //item name 1
                                 "^FO00,55^A0,30,22^FD" + itemName1 + "^FS" +
                                 "^FO290,55^A0,30,22^FD" + itemName1 + "^FS" +
                                 "^FO580,55^A0,30,22^FD" + itemName1 + "^FS" +
                                 //item name 2
                                 "^FO00,82^A0,30,22^FD" + itemName2 + "^FS" +
                                 "^FO290,82^A0,30,22^FD" + itemName2 + "^FS" +
                                 "^FO580,82^A0,30,22^FD" + itemName2 + "^FS" +
                                 //item name 3
                                 "^FO00,108^A0,30,22^FD" + itemName3 + "^FS" +
                                 "^FO290,108^A0,30,22^FD" + itemName3 + "^FS" +
                                 "^FO580,108^A0,30,22^FD" + itemName3 + "^FS" +
                                 //item chinese
                                 "^FO00,138^CI28^A@N,40,40,E:SIMSUN.FNT^FD" + itemChinese + "^FS" +
                                 "^FO290,138^CI28^A@N,40,40,E:SIMSUN.FNT^FD" + itemChinese + "^FS" +
                                 "^FO580,138^CI28^A@N,40,40,E:SIMSUN.FNT^FD" + itemChinese + "^FS" +
                                 "^XZ";

                // Send the data to printer as a byte array.
                thePrinterConn.Write(Encoding.UTF8.GetBytes(zplData));
            }
            catch (ConnectionException e)
            {
                // Handle communications error here.
                Console.WriteLine(e.ToString());
            }
            finally
            {
                // Close the connection to release resources.
                thePrinterConn.Close();
            }
        }
Ejemplo n.º 36
0
 public void DeleteProfile(ConnectionBuilder connection)
 {
     string statment = string.Format("delete from users where login = '******';", Login);
     try
     {
         connection.ExecuteDeleteSQL(statment);
     }
     catch(Exception e)
     {
         throw e;
     }
 }
        public void PooledConnectionProvider()
        {
            // arrange
            var expected = typeof(PooledConnectionProvider);
            var connectionString = "Keyspace=Testing;Pooled=True";

            // act
            var result = new ConnectionBuilder(connectionString);
            var actual = ConnectionProviderFactory.Get(result).GetType();

            // assert
            Assert.AreEqual(expected, actual);
        }
		public static IConnectionProvider Get(ConnectionBuilder connectionBuilder)
		{
			IConnectionProvider provider;

			if (!_providers.TryGetValue(connectionBuilder.ConnectionString, out provider))
				using (TimedLock.Lock(_lock))
				{
					provider = CreateProvider(connectionBuilder);
					_providers.Add(connectionBuilder.ConnectionString, provider);
				}

			return provider;
		}
Ejemplo n.º 39
0
 public RemoteTunnel(string url, DataEncoding encoding = DataEncoding.Proto, int maxConnections = 2) : this(maxConnections)
 {
     if (url == null)
         throw new ArgumentNullException();
     EndPoint = new Uri(url);
     var throttle = 0;
     CreateConnection = ConnectionBuilderFromUri(EndPoint, out throttle);
     Throttle = throttle;
     switch (encoding)
     {
         case DataEncoding.Memcached:
             CreateProtocol = (dtc) => { return new Memcached.ClientProtocol(dtc); }; break;
         default:
             throw new NotImplementedException(encoding.ToString());
     }
 }
		public CassandraDatabaseSetup(bool reset = false)
		{
			ConnectionBuilder = new ConnectionBuilder(keyspace: Keyspace, server: Server);
			DB = new CassandraContext(ConnectionBuilder);
			
			var exists = DB.KeyspaceExists(Keyspace);

			Family = DB.GetColumnFamily<AsciiType>("Standard");
			SuperFamily = DB.GetColumnFamily<AsciiType, AsciiType>("Super");
			UserFamily = DB.GetColumnFamily("Users");

			if (exists && !reset)
				return;

			ResetDatabase();
		}
        public void Fails_Over()
        {
            // arrange
            var expectedHost = "127.0.0.1";
            var expectedPort = Server.DefaultPort;

            // act
            var result = new ConnectionBuilder(FailoverConnectionString);
            var provider = ConnectionProviderFactory.Get(result);
            var conn = provider.Open();
            var actualHost = conn.Server.Host;
            var actualPort = conn.Server.Port;

            // assert
            Assert.AreEqual(expectedHost, actualHost);
            Assert.AreEqual(expectedPort, actualPort);
        }
        public GenericDatabaseSetup(bool reset = false)
        {
            ConnectionBuilder = new ConnectionBuilder(keyspace: Keyspace, server: Server, cqlVersion: CqlVersion.Cql3);
            DB = new CassandraContext(ConnectionBuilder);

            if (DB.KeyspaceExists(Keyspace))
                DB.DropKeyspace(Keyspace);

            var keyspace = new CassandraKeyspace(new CassandraKeyspaceSchema
            {
                Name = Keyspace,
            }, DB);

            var exists = DB.KeyspaceExists(Keyspace);
            if (!exists)
                keyspace.TryCreateSelf();

            if (exists && !reset)
                return;

            ResetDatabase();
        }
 public LoginDelegate(ConnectionBuilder connectionBuilder)
 {
     _conn = connectionBuilder;
 }
Ejemplo n.º 44
0
 public CassandraSession(ConnectionBuilder connectionBuilder)
     : this(ConnectionProviderFactory.Get(connectionBuilder), connectionBuilder.ReadConsistency, connectionBuilder.WriteConsistency)
 {
 }
Ejemplo n.º 45
0
		public void Configure(ConnectionBuilder builder)
		{
			builder.AddChannel(_channel);
		}
		/// <summary>
		/// 
		/// </summary>
		/// <param name="builder"></param>
		protected ConnectionProvider(ConnectionBuilder builder)
		{
			Builder = builder;
		}
Ejemplo n.º 47
0
 public Connection(ConnectionBuilder builder)
 {
     this.from = builder.A;
     this.to = builder.B;
     this.distance = builder.Distance;
 }