Exemple #1
0
        public void Insert(string family, string key, string superColumnName, string columnName, string value)
        {
            ICluster cluster = AquilesHelper.RetrieveCluster(Cluster);

            byte[] keyAsByteArray   = Encoding.ASCII.GetBytes(key);
            byte[] valueAsByteArray = Encoding.ASCII.GetBytes(value);
            var    columnParent     = new ColumnParent
            {
                Column_family = family,
            };
            var column = new Column
            {
                Name      = ByteEncoderHelper.UTF8Encoder.ToByteArray(columnName),
                Timestamp = UnixHelper.UnixTimestamp,
                Value     = valueAsByteArray
            };


            cluster.Execute(new ExecutionBlock(client =>
            {
                // http://www.dotnetperls.com/convert-string-byte-array

                client.insert(keyAsByteArray, columnParent, column,
                              ConsistencyLevel.ONE);
                return(null);
            }), keyspaceName);
        }
Exemple #2
0
        /// <summary>
        /// Creates new instance of AquilesStorage type
        /// </summary>
        /// <param name="clusterName">Cluster name</param>
        /// <param name="keySpace">Key space name used to store IOG data</param>
        /// <param name="columnFamily">Column family name used to store IOG data</param>
        public AquilesStorage(string clusterName, string keySpace, string columnFamily)
        {
            AquilesHelper.Initialize();
            cluster = AquilesHelper.RetrieveCluster(clusterName);

            this.keySpace     = keySpace;
            this.columnFamily = columnFamily;
        }
Exemple #3
0
        protected void Application_Start()
        {
            ViewEngines.Engines.Clear();
            // ViewEngines.Engines.Add(new WebFormViewEngine());
            ViewEngines.Engines.Add(new RazorViewEngine());

            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            AquilesHelper.Initialize();
        }
Exemple #4
0
        public List <ColumnOrSuperColumn> GetSlice(string family, string key, string superColumnName, int count)
        {
            //var getSliceCommand = new GetSliceCommand
            //                          {
            //                              KeySpace = Name,
            //                              Key = key,
            //                              ColumnFamily = family,
            //                              SuperColumn = superColumnName,
            //                              Predicate =
            //                                  new SlicePredicate
            //                                      {
            //                                          Slice_range = new SliceRange {Count = count}
            //                                      }
            //
            //using (var connection = AquilesHelper.RetrieveConnection(Cluster))
            //{
            //    connection.Execute(getSliceCommand);
            //    return getSliceCommand.Output == null
            //               ? new List<AquilesColumn>()
            //               : getSliceCommand.Output.Results.Select(o => o.Column).ToList();
            //}

            byte[] keyAsByteArray = Encoding.ASCII.GetBytes(key);
            var    columnParent   = new ColumnParent
            {
                Column_family = family,
            };
            var predicate = new SlicePredicate
            {
                Slice_range = new SliceRange
                {
                    Count    = 1000,
                    Reversed = false,
                    Start    = new byte[0],
                    Finish   = new byte[0],
                },
            };

            ICluster cluster  = AquilesHelper.RetrieveCluster(Cluster);
            object   rtnValue = cluster.Execute(new ExecutionBlock(
                                                    client =>
                                                    client.get_slice(keyAsByteArray, columnParent, predicate,
                                                                     ConsistencyLevel.ONE)), keyspaceName);

            return(rtnValue as List <ColumnOrSuperColumn>);
        }
Exemple #5
0
        public void Initialize(ConfigSettings settings)
        {
            AquilesHelper.Initialize();
            _storage = new InventoryStorage(settings.InventoryCluster);

            _delayedMutationMgr = new DelayedMutationManager();
            _delayedMutationMgr.Start();
            _storage.DelayedMutationMgr = _delayedMutationMgr;

            if (settings.InventoryMigrationActive)
            {
                _legacyStorage = new LegacyMysqlInventoryStorage(settings.LegacyInventorySource);
            }

            _storageSelector = new CassandraMigrationProviderSelector(settings.InventoryMigrationActive, settings.CoreConnectionString,
                                                                      _storage, _legacyStorage);

            ProviderRegistry.Instance.RegisterInterface <IInventoryProviderSelector>(_storageSelector);
        }
Exemple #6
0
        public ColumnOrSuperColumn GetColumn(string family, string key, string superColumnName, string columnName)
        {
            //var getCommand = new GetCommand
            //                     {
            //                         KeySpace = Name,
            //                         Key = key,
            //                         ColumnFamily = family,
            //                         ColumnName = columnName,
            //                         SuperColumnName = superColumnName
            //                     };
            //using (var connection = AquilesHelper.RetrieveConnection(Cluster))
            //{
            //    connection.Execute(getCommand);
            //    return getCommand.Output == null ? null : getCommand.Output.Column;
            //}


            byte[] keyAsByteArray        = Encoding.ASCII.GetBytes(key);
            byte[] columnNameAsByteArray = Encoding.ASCII.GetBytes(columnName);
            var    columnPath            = new ColumnPath
            {
                Column        = columnNameAsByteArray,
                Column_family = family,
            };

            ICluster cluster = AquilesHelper.RetrieveCluster(Cluster);

            return((ColumnOrSuperColumn)cluster.Execute(new ExecutionBlock(client =>
            {
                try
                {
                    return client.get(keyAsByteArray, columnPath,
                                      ConsistencyLevel.ONE);
                }
                catch (Exception e)
                {
                    return null;
                }
            }), keyspaceName));
        }
Exemple #7
0
        /// <summary>
        /// Default cluster
        /// </summary>
        /// <returns>
        /// The Lesula.Cassandra.Cluster.ICluster.
        /// </returns>
        internal static ICluster GetCluster()
        {
            var defaultCluster = Context.Config.Get("DefaultCluster");

            return(AquilesHelper.RetrieveCluster(defaultCluster));
        }