当前位置: 首页>>代码示例>>C#>>正文


C# CassandraContext.DropKeyspace方法代码示例

本文整理汇总了C#中CassandraContext.DropKeyspace方法的典型用法代码示例。如果您正苦于以下问题:C# CassandraContext.DropKeyspace方法的具体用法?C# CassandraContext.DropKeyspace怎么用?C# CassandraContext.DropKeyspace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CassandraContext的用法示例。


在下文中一共展示了CassandraContext.DropKeyspace方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CompatibilityCassandraDatabaseSetup

        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();
        }
开发者ID:smerchek,项目名称:fluentcassandra,代码行数:29,代码来源:CompatibilityCassandraDatabaseSetup.cs

示例2: ResetDatabase

        public void ResetDatabase()
        {
            using (var session = new CassandraSession(ConnectionBuilder))
            using (var db = new CassandraContext(session))
            {
                db.ThrowErrors = true;

                try { db.DropKeyspace(Keyspace); }
                catch (Exception exc) { Console.WriteLine(exc); }

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

                keyspace.TryCreateSelf();
                keyspace.TryCreateColumnFamily<AsciiType>("Standard");
                keyspace.TryCreateColumnFamily<AsciiType, AsciiType>("Super");
                keyspace.TryCreateColumnFamily<AsciiType>("StandardAsciiType");
                keyspace.TryCreateColumnFamily<BytesType>("StandardBytesType");
                keyspace.TryCreateColumnFamily<IntegerType>("StandardIntegerType");
                keyspace.TryCreateColumnFamily<LexicalUUIDType>("StandardLexicalUUIDType");
                keyspace.TryCreateColumnFamily<LongType>("StandardLongType");
                keyspace.TryCreateColumnFamily<TimeUUIDType>("StandardTimeUUIDType");
                keyspace.TryCreateColumnFamily<UTF8Type>("StandardUTF8Type");
                keyspace.TryCreateColumnFamily<UUIDType>("StandardUUIDType");
                keyspace.TryCreateColumnFamily(new CassandraColumnFamilySchema {
                    FamilyName = "StandardCompositeType",
                    ColumnNameType = CassandraType.CompositeType(new[] { CassandraType.AsciiType, CassandraType.DoubleType })
                });
                keyspace.TryCreateColumnFamily(new CassandraColumnFamilySchema {
                    FamilyName = "StandardDynamicCompositeType",
                    ColumnNameType = CassandraType.DynamicCompositeType(new Dictionary<char, CassandraType> { { 'a', CassandraType.AsciiType }, { 'd', CassandraType.DoubleType } })
                });

                db.ExecuteNonQuery(@"
            CREATE COLUMNFAMILY Users (
            KEY int PRIMARY KEY,
            Name ascii,
            Email ascii,
            Age int
            );");
                db.ExecuteNonQuery(@"CREATE INDEX User_Age ON Users (Age);");
                db.Keyspace.ClearCachedKeyspaceSchema();

                var family = db.GetColumnFamily<AsciiType>("Standard");
                var superFamily = db.GetColumnFamily<AsciiType, AsciiType>("Super");
                var userFamily = db.GetColumnFamily("Users");

                ResetFamily(family);
                ResetSuperFamily(superFamily);
                ResetUsersFamily(userFamily);
            }
        }
开发者ID:shawnbissell,项目名称:fluentcassandra,代码行数:54,代码来源:CassandraDatabaseSetup.cs

示例3: SetupKeyspace

		private static void SetupKeyspace()
		{
			using (var db = new CassandraContext(keyspace: KeyspaceName, server: Server))
			{
				if (db.KeyspaceExists(KeyspaceName))
					db.DropKeyspace(KeyspaceName);

				var keyspace = new CassandraKeyspace(new CassandraKeyspaceSchema
				{
					Name = KeyspaceName,
				}, db);

				keyspace.TryCreateSelf();

				// create column family using CQL
				db.ExecuteNonQuery(@"
				CREATE COLUMNFAMILY Posts (
				KEY ascii PRIMARY KEY,
				Title text,
				Body text,
				Author text,
				PostedOn timestamp
				);");

				// create column family using API
				keyspace.TryCreateColumnFamily(new CassandraColumnFamilySchema
				{
					FamilyName = "Tags",
					KeyValueType = CassandraType.AsciiType,
					ColumnNameType = CassandraType.Int32Type,
					DefaultColumnValueType = CassandraType.UTF8Type
				});

				// create super column family using API
				keyspace.TryCreateColumnFamily(new CassandraColumnFamilySchema
				{
					FamilyName = "Comments",
					FamilyType = ColumnType.Super,
					KeyValueType = CassandraType.AsciiType,
					SuperColumnNameType = CassandraType.DateType,
					ColumnNameType = CassandraType.UTF8Type,
					DefaultColumnValueType = CassandraType.UTF8Type
				});
			}
		}
开发者ID:achinn,项目名称:fluentcassandra,代码行数:45,代码来源:Program.cs

示例4: GenericDatabaseSetup

        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();
        }
开发者ID:smerchek,项目名称:fluentcassandra,代码行数:22,代码来源:GenericDatabaseSetup.cs

示例5: CassandraDatabaseSetup

        public CassandraDatabaseSetup(bool volitile = false)
        {
            var keyspaceName = "Testing";
            var server = new Server("localhost");

            DB = new CassandraContext(keyspaceName, server);
            DB.ThrowErrors = true;

            var exists = DB.KeyspaceExists(keyspaceName);
            Users = new[] {
                new User { Id = 1, Name = "Darren Gemmell", Email = "[email protected]", Age = 32 },
                new User { Id = 2, Name = "Fernando Laubscher", Email = "[email protected]", Age = 23 },
                new User { Id = 3, Name = "Cody Millhouse", Email = "[email protected]", Age = 56 },
                new User { Id = 4, Name = "Emilia Thibert", Email = "[email protected]", Age = 67 },
                new User { Id = 5, Name = "Allyson Schurr", Email = "[email protected]", Age = 21 }
            };

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

            if (exists && !volitile)
                return;

            using (var session = DB.OpenSession())
            {
                if (exists)
                    DB.DropKeyspace(keyspaceName);

                var keyspace = new CassandraKeyspace(new CassandraKeyspaceSchema { Name = keyspaceName, Strategy = CassandraKeyspaceSchema.ReplicaPlacementStrategySimple, ReplicationFactor = 1 }, DB);
                DB.Keyspace = keyspace;

                keyspace.TryCreateSelf();
                keyspace.TryCreateColumnFamily<AsciiType>("Standard");
                keyspace.TryCreateColumnFamily<AsciiType, AsciiType>("Super");
                keyspace.TryCreateColumnFamily<AsciiType>("StandardAsciiType");
                keyspace.TryCreateColumnFamily<BytesType>("StandardBytesType");
                keyspace.TryCreateColumnFamily<IntegerType>("StandardIntegerType");
                keyspace.TryCreateColumnFamily<LexicalUUIDType>("StandardLexicalUUIDType");
                keyspace.TryCreateColumnFamily<LongType>("StandardLongType");
                keyspace.TryCreateColumnFamily<TimeUUIDType>("StandardTimeUUIDType");
                keyspace.TryCreateColumnFamily<UTF8Type>("StandardUTF8Type");
                keyspace.TryCreateColumnFamily<UUIDType>("StandardUUIDType");
                keyspace.TryCreateColumnFamily<CompositeType<LongType, UTF8Type>>("StandardCompositeType");
                keyspace.TryCreateColumnFamily<DynamicCompositeType>("StandardDynamicCompositeType");

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

                Family.InsertColumn(TestKey1, "Test1", Math.PI);
                Family.InsertColumn(TestKey1, "Test2", Math.PI);
                Family.InsertColumn(TestKey1, "Test3", Math.PI);

                SuperFamily.InsertColumn(TestKey1, TestSuperName, "Test1", Math.PI);
                SuperFamily.InsertColumn(TestKey1, TestSuperName, "Test2", Math.PI);
                SuperFamily.InsertColumn(TestKey1, TestSuperName, "Test3", Math.PI);

                Family.InsertColumn(TestKey2, "Test1", Math.PI);
                Family.InsertColumn(TestKey2, "Test2", Math.PI);
                Family.InsertColumn(TestKey2, "Test3", Math.PI);

                SuperFamily.InsertColumn(TestKey2, TestSuperName, "Test1", Math.PI);
                SuperFamily.InsertColumn(TestKey2, TestSuperName, "Test2", Math.PI);
                SuperFamily.InsertColumn(TestKey2, TestSuperName, "Test3", Math.PI);

                DB.ExecuteNonQuery(@"
            CREATE COLUMNFAMILY Users (
            KEY int PRIMARY KEY,
            Name ascii,
            Email ascii,
            Age int
            );");
                DB.ExecuteNonQuery(@"CREATE INDEX User_Age ON Users (Age);");
                DB.Keyspace.ClearCachedKeyspaceSchema();
                UserFamily = DB.GetColumnFamily("Users");

                foreach (var user in Users)
                {
                    dynamic record = UserFamily.CreateRecord(user.Id);
                    record.Name = user.Name;
                    record.Email = user.Email;
                    record.Age = user.Age;

                    DB.Attach(record);
                }
                DB.SaveChanges();
            }
        }
开发者ID:bjuris,项目名称:fluentcassandra,代码行数:88,代码来源:CassandraDatabaseSetup.cs

示例6: Test

        public static void Test()
        {
            int TestTimeInMinutes = 10;

            int ThreadCount = 50;
            int ThreadCount2 = 10;
            int TimeOut_Sec = 5;
            bool usePooling = true;

            object alive_monitor = new object();
            bool alive_condition = true;
            List<Thread> threads = new List<Thread>();

            int thrStarted_cnt = 0;
            object thrStarted_monitor = new object();

            //initialize
            CassandraContext main_db = new CassandraContext(new ConnectionBuilder(keyspace: KeyspaceName, server: Server, cqlVersion: CqlVersion.Cql3, pooling: usePooling));
            {
                if (main_db.KeyspaceExists(KeyspaceName))
                    main_db.DropKeyspace(KeyspaceName);

                var keyspace = new CassandraKeyspace(new CassandraKeyspaceSchema
                {
                    Name = KeyspaceName,
                }, main_db);

                keyspace.TryCreateSelf();

                CreateTablesIfNotExists(main_db);
            }

            for (int tI = 0; tI < ThreadCount; tI++)
            {
                int thrNo = tI;
                var thr = new Thread(() =>
                {

                    Console.Write("(*" + thrNo + ")");
                    try
                    {
                        CassandraContext db = new CassandraContext(new ConnectionBuilder(keyspace: KeyspaceName, server: Server, cqlVersion: CqlVersion.Cql3, pooling: usePooling));
                        lock (thrStarted_monitor)
                        {
                            thrStarted_cnt++;
                            Monitor.PulseAll(thrStarted_monitor);
                        }

                        while (true)
                        {
                            var job = GetJob(db, 10);
                            if (job != null)
                            {
                                Console.Write("-");
                                if (job.GetLogic() == null || job.GetCommand() == null)
                                    Console.WriteLine("Error");
                                DeleteJob(db, job);
                            }
                            else
                            {
                                lock (alive_monitor)
                                {
                                    if (!alive_condition)
                                        return;
                                    else
                                        Monitor.Wait(alive_monitor, TimeOut_Sec * 1000);
                                }
                            }
                        }
                    }
                    finally
                    {
                        Console.Write("(~" + thrNo + ")");
                    }
                });
                threads.Add(thr);
                thr.Start();
            }

            for (int tI = 0; tI < ThreadCount2; tI++)
            {
                int thrNo = tI;
                var thr = new Thread(() =>
                {
                    Console.Write("<*" + thrNo + ">");
                    try
                    {
                        CassandraContext db = new CassandraContext(new ConnectionBuilder(keyspace: KeyspaceName, server: Server, cqlVersion: CqlVersion.Cql3, pooling: usePooling));
                        lock (thrStarted_monitor)
                        {
                            thrStarted_cnt++;
                            Monitor.PulseAll(thrStarted_monitor);
                        }

                        while (true)
                        {
                            StringBuilder sb = new StringBuilder();
                            for (int i = 0; i < 100; i++)
                                sb.AppendLine(Guid.NewGuid().ToString());
                            AddJob(db, sb.ToString(), Guid.NewGuid().ToString());
//.........这里部分代码省略.........
开发者ID:nativex,项目名称:fluentcassandra,代码行数:101,代码来源:StressTest2.cs


注:本文中的CassandraContext.DropKeyspace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。