Inheritance: TBase
        public KsDef Describe(Server server)
        {
            if (_cachedKeyspaceDescription == null)
                _cachedKeyspaceDescription = CassandraSession.GetKeyspace(server, KeyspaceName);

            return _cachedKeyspaceDescription;
        }
        public string AddColumnFamily(Server server, CfDef definition)
        {
            _cachedKeyspaceDescription = null;

            using (var session = new CassandraSession(new ConnectionBuilder(KeyspaceName, server.Host, server.Port)))
                return session.GetClient().system_add_column_family(definition);
        }
 public CassandraKeyspaceSchema(KsDef def)
 {
     Name = def.Name;
     Strategy = def.Strategy_class;
     ReplicationFactor = def.Replication_factor;
     ColumnFamilies = def.Cf_defs.Select(family => new CassandraColumnFamilySchema(family)).ToList();
 }
 public CassandraKeyspaceSchema(KsDef def)
 {
     Name = def.Name;
     Strategy = def.Strategy_class;
     StrategyOptions = def.Strategy_options ?? new Dictionary<string, string>();
     ColumnFamilies = def.Cf_defs.Select(family => new CassandraColumnFamilySchema(family)).ToList();
     DurableWrites = def.Durable_writes;
 }
        public CassandraKeyspace(KsDef definition)
        {
            if (definition == null)
                throw new ArgumentNullException("definition");

            _keyspaceName = definition.Name;
            _cachedKeyspaceDescription = definition;
        }
Beispiel #6
0
        private void KeySpaceTree_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
        {
            List<CfDef> cfDefs = new List<CfDef>();
            CfDef cfDef = new CfDef();
            cfDef.Name = "Test";
            cfDef.Keyspace = e.Node.Text;
            cfDef.Column_type = "Standard";
            cfDefs.Add(cfDef);

            KsDef keySpaceDef = new KsDef();
            keySpaceDef.Name = e.Node.Text;
            keySpaceDef.Replication_factor = 1;
            keySpaceDef.Strategy_class = "org.apache.cassandra.locator.RackUnawareStrategy";
            keySpaceDef.Cf_defs = cfDefs;

            client.system_add_keyspace(keySpaceDef);

            // Data bind in future
            populateTreeView();
        }
 public void Read(TProtocol iprot)
 {
     TField field;
     iprot.ReadStructBegin();
     while (true)
     {
       field = iprot.ReadFieldBegin();
       if (field.Type == TType.Stop) {
     break;
       }
       switch (field.ID)
       {
     case 1:
       if (field.Type == TType.Struct) {
     Ks_def = new KsDef();
     Ks_def.Read(iprot);
       } else {
     TProtocolUtil.Skip(iprot, field.Type);
       }
       break;
     default:
       TProtocolUtil.Skip(iprot, field.Type);
       break;
       }
       iprot.ReadFieldEnd();
     }
     iprot.ReadStructEnd();
 }
 public static string UpdateKeyspace(Server server, KsDef definition)
 {
     using (var session = new CassandraSession(new ConnectionBuilder(null, server.Host, server.Port)))
         return session.GetClient(setKeyspace: false).system_update_keyspace(definition);
 }
 private void CreateKeyspaceAndColumnFamily()
 {
     List<CfDef> cfDefList = new List<CfDef>();
     cfDefList.Add(CreateCfDef());
     try
     {
         KsDef ksDef = new KsDef();
         ksDef.Name = LevelMapping.KeyspaceName;
         ksDef.Strategy_class = LevelMapping.PlacementStrategy;
         ksDef.Cf_defs = cfDefList;
         var strategyOptions = LevelMapping.GetStrategyOptions();
         if (LevelMapping.PlacementStrategy.Equals("org.apache.cassandra.locator.SimpleStrategy") && !strategyOptions.ContainsKey("replication_factor"))
             strategyOptions.Add("replication_factor", LevelMapping.ReplicationFactor.ToString());
         ksDef.Strategy_options = strategyOptions;
         this.client.system_add_keyspace(ksDef);
         int magnitude = this.client.describe_ring(LevelMapping.KeyspaceName).Count;
         Thread.Sleep(1000 * magnitude);
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
        private Boolean CheckForColumnFamily(KsDef ksDef)
        {
            Boolean exists = false;
            foreach (CfDef cfDef in ksDef.Cf_defs)
            {
                if (cfDef.Name.Equals(LevelMapping.ColumnFamily))
                {
                    exists = true;
                    break;
                }
            }

            return exists;
        }
Beispiel #11
0
 public void send_system_update_keyspace(KsDef ks_def)
 #endif
 {
   oprot_.WriteMessageBegin(new TMessage("system_update_keyspace", TMessageType.Call, seqid_));
   system_update_keyspace_args args = new system_update_keyspace_args();
   args.Ks_def = ks_def;
   args.Write(oprot_);
   oprot_.WriteMessageEnd();
   #if SILVERLIGHT
   return oprot_.Transport.BeginFlush(callback, state);
   #else
   oprot_.Transport.Flush();
   #endif
 }
 public void Read(TProtocol iprot)
 {
     TField field;
     iprot.ReadStructBegin();
     while (true)
     {
       field = iprot.ReadFieldBegin();
       if (field.Type == TType.Stop) {
     break;
       }
       switch (field.ID)
       {
     case 0:
       if (field.Type == TType.List) {
     {
       Success = new List<KsDef>();
       TList _list140 = iprot.ReadListBegin();
       for( int _i141 = 0; _i141 < _list140.Count; ++_i141)
       {
         KsDef _elem142 = new KsDef();
         _elem142 = new KsDef();
         _elem142.Read(iprot);
         Success.Add(_elem142);
       }
       iprot.ReadListEnd();
     }
       } else {
     TProtocolUtil.Skip(iprot, field.Type);
       }
       break;
     case 1:
       if (field.Type == TType.Struct) {
     Ire = new InvalidRequestException();
     Ire.Read(iprot);
       } else {
     TProtocolUtil.Skip(iprot, field.Type);
       }
       break;
     default:
       TProtocolUtil.Skip(iprot, field.Type);
       break;
       }
       iprot.ReadFieldEnd();
     }
     iprot.ReadStructEnd();
 }
Beispiel #13
0
 public IAsyncResult Begin_system_update_keyspace(AsyncCallback callback, object state, KsDef ks_def)
 {
   return send_system_update_keyspace(callback, state, ks_def);
 }
        public string DropColumnFamily(Server server, string columnFamily)
        {
            _cachedKeyspaceDescription = null;

            using (var session = new CassandraSession(new ConnectionBuilder(KeyspaceName, server.Host, server.Port)))
                return session.GetClient().system_drop_column_family(columnFamily);
        }
        private KsDef CreateTmpKs()
        {
            KsDef tmpKs = new KsDef();
            tmpKs.Name = "proxy_client_ks";
            tmpKs.Strategy_class = "org.apache.cassandra.locator.SimpleStrategy";
            tmpKs.Strategy_options = new Dictionary<String, String>();
            tmpKs.Strategy_options.Add("replication_factor", "1");

            this.client.system_add_keyspace(tmpKs);

            return tmpKs;
        }
 public void send_system_update_keyspace(KsDef ks_def)
 {
     oprot_.WriteMessageBegin(new TMessage("system_update_keyspace", TMessageType.Call, seqid_));
     system_update_keyspace_args args = new system_update_keyspace_args();
     args.Ks_def = ks_def;
     args.Write(oprot_);
     oprot_.WriteMessageEnd();
     oprot_.Transport.Flush();
 }
 public string system_update_keyspace(KsDef ks_def)
 {
     send_system_update_keyspace(ks_def);
     return recv_system_update_keyspace();
 }
Beispiel #18
0
      /// <summary>
      /// updates properties of a keyspace. returns the new schema id.
      /// </summary>
      /// <param name="ks_def"></param>
      public string system_update_keyspace(KsDef ks_def)
      {
        #if !SILVERLIGHT
        send_system_update_keyspace(ks_def);
        return recv_system_update_keyspace();

        #else
        var asyncResult = Begin_system_update_keyspace(null, null, ks_def);
        return End_system_update_keyspace(asyncResult);

        #endif
      }
 public void Read(TProtocol iprot)
 {
     TField field;
     iprot.ReadStructBegin();
     while (true)
     {
       field = iprot.ReadFieldBegin();
       if (field.Type == TType.Stop) {
     break;
       }
       switch (field.ID)
       {
     case 0:
       if (field.Type == TType.Struct) {
     Success = new KsDef();
     Success.Read(iprot);
       } else {
     TProtocolUtil.Skip(iprot, field.Type);
       }
       break;
     case 1:
       if (field.Type == TType.Struct) {
     Nfe = new NotFoundException();
     Nfe.Read(iprot);
       } else {
     TProtocolUtil.Skip(iprot, field.Type);
       }
       break;
     case 2:
       if (field.Type == TType.Struct) {
     Ire = new InvalidRequestException();
     Ire.Read(iprot);
       } else {
     TProtocolUtil.Skip(iprot, field.Type);
       }
       break;
     default:
       TProtocolUtil.Skip(iprot, field.Type);
       break;
       }
       iprot.ReadFieldEnd();
     }
     iprot.ReadStructEnd();
 }
Beispiel #20
0
 public IAsyncResult send_system_update_keyspace(AsyncCallback callback, object state, KsDef ks_def)