Esempio n. 1
0
        private void Initialize(ClientConfiguration configuration, string defaultBucket, CouchbaseStorageOptions options)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }
            if (string.IsNullOrEmpty(defaultBucket))
            {
                throw new ArgumentNullException(nameof(defaultBucket));
            }

            Options = options ?? new CouchbaseStorageOptions();
            Options.DefaultBucket = defaultBucket;

            configuration.Serializer = () => new DocumentDefaultSerializer();
            Client = new Cluster(configuration);

            string  indexPrefix = $"IDX_{defaultBucket}";
            IBucket bucket      = Client.OpenBucket(Options.DefaultBucket);
            {
                IBucketManager manager = bucket.CreateManager(bucket.Configuration.Username, bucket.Configuration.Password);
                manager.CreateN1qlPrimaryIndex($"{indexPrefix}_Primary", false);
                manager.CreateN1qlIndex($"{indexPrefix}_Type", false, "type");
                manager.CreateN1qlIndex($"{indexPrefix}_Id", false, "id");
                manager.CreateN1qlIndex($"{indexPrefix}_Expire", false, "expire_on");
                manager.CreateN1qlIndex($"{indexPrefix}_Name", false, "name");
            }

            JobQueueProvider provider = new JobQueueProvider(this);

            QueueProviders = new PersistentJobQueueProviderCollection(provider);
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel()
        {
            if (ViewModelBase.IsInDesignModeStatic)
            {
                return;
            }

            IsBusy               = false;
            IsIndeterminate      = true;
            EntityModels         = new ObservableCollection <EntityModel>();
            EntityRelationModels = new ObservableCollection <EntityRelationModel>();

            _cluster = new Cluster("couchbaseClients/couchbase");
            _bucket  = _cluster.OpenBucket();
            _manager = _bucket.CreateManager(ConfigurationManager.AppSettings["Username"], ConfigurationManager.AppSettings["Password"]);

            // model is a GraphLinksModel using instances of NodeData as the node data
            // and LinkData as the link data
            _graphModel            = new GraphLinksModel <NodeData, String, String, LinkData>();
            _graphModel.Modifiable = true;

            _nodes = new ObservableCollection <NodeData>();
            _links = new ObservableCollection <LinkData>();

            _graphModel.NodesSource = _nodes;
            _graphModel.LinksSource = _links;

            SearchText = ConfigurationManager.AppSettings["DefaultEntity"];
            int.TryParse(ConfigurationManager.AppSettings["PageSize"], out PageSize);
            PageSize = PageSize > 0 ? PageSize : 1000;

            LoadSchema();
            LoadState();
        }
Esempio n. 3
0
        public void OneTimeSetUp()
        {
            TestConfiguration.IgnoreIfMock();

            _cluster = new Cluster(Utils.TestConfiguration.GetConfiguration("basic"));
            _cluster.SetupEnhancedAuth();
            _clusterManager = _cluster.CreateManager(TestConfiguration.Settings.AdminUsername, TestConfiguration.Settings.AdminPassword);

            var listbucketsResult = _clusterManager.ListBuckets();

            if (listbucketsResult.Value.Any(bucket => bucket.Name == BucketName))
            {
                var removeResult = _clusterManager.RemoveBucket(BucketName);
                Assert.IsTrue(removeResult.Success);
            }

            var createResult = _clusterManager.CreateBucket(BucketName, replicaNumber: ReplicaNumber.Zero, flushEnabled: true);

            Assert.True(createResult.Success);

            // Allow time for bucket to be created and configuration to propagate before beginning operations
            Thread.Sleep(500);

            _bucket        = _cluster.OpenBucket(BucketName);
            _bucketManager = _bucket.CreateManager(TestConfiguration.Settings.AdminUsername, TestConfiguration.Settings.AdminPassword);
        }
Esempio n. 4
0
        public static Task CreateAsync(this IBucketManager bucketManager, BucketSettings settings, Action <CreateBucketOptions> configureOptions)
        {
            var options = new CreateBucketOptions();

            configureOptions(options);

            return(bucketManager.CreateAsync(settings, options));
        }
 public BucketController(
     IStringLocalizer <SharedResources> sharedLocalizer,
     ILogger <BucketController> logger,
     IBucketManager manager) : base(sharedLocalizer)
 {
     this.logger  = logger;
     this.manager = manager;
 }
Esempio n. 6
0
        public static Task <BucketSettings> GetAsync(this IBucketManager bucketManager, string bucketName, Action <GetBucketOptions> configureOptions)
        {
            var options = new GetBucketOptions();

            configureOptions(options);

            return(bucketManager.GetAsync(bucketName, options));
        }
Esempio n. 7
0
        public static Task DropAsync(this IBucketManager bucketManager, string bucketName, Action <DropBucketOptions> configureOptions)
        {
            var options = new DropBucketOptions();

            configureOptions(options);

            return(bucketManager.DropAsync(bucketName, options));
        }
Esempio n. 8
0
        public static Task <Dictionary <string, BucketSettings> > GetAllAsync(this IBucketManager bucketManager, Action <GetAllBucketOptions> configureOptions)
        {
            var options = new GetAllBucketOptions();

            configureOptions(options);

            return(bucketManager.GetAllAsync(options));
        }
Esempio n. 9
0
        public static Task FlushAsync(this IBucketManager bucketManager, string bucketName, Action <FlushBucketOptions> configureOptions)
        {
            var options = new FlushBucketOptions();

            configureOptions(options);

            return(bucketManager.Flush(bucketName, options));
        }
        public CouchbaseEventStore(IBucket bucket, string couchbaseUser, string couchbasePwd)
        {
            if (_bucket == null)
                _bucket = bucket;
            if (bucketManager == null)
                bucketManager = _bucket.CreateManager(couchbaseUser, couchbasePwd);

        }
Esempio n. 11
0
        public static Task UpsertAsync(this IBucketManager bucketManager, BucketSettings settings, Action <UpsertBucketOptions> configureOptions)
        {
            var options = new UpsertBucketOptions();

            configureOptions(options);

            return(bucketManager.UpsertAsync(settings, options));
        }
 public CouchbaseEventStore(IBucket bucket, string couchbaseUser, string couchbasePwd)
 {
     if (_bucket == null)
     {
         _bucket = bucket;
     }
     if (bucketManager == null)
     {
         bucketManager = _bucket.CreateManager(couchbaseUser, couchbasePwd);
     }
 }
        public BucketTests()
        {
            var EsConfig            = GetAppsettingsConfigs.GetConfiguration <ElasticSearchRepository>();
            var BucketManagerConfig = GetAppsettingsConfigs.GetConfiguration <BucketManager>();

            IElasticsearchRepository EsRepository = new ElasticSearchRepository(EsConfig.Logger, EsConfig.Configurations, EsConfig.Configurations.Value.Elasticsearch.GetElasticSearchClient());

            var minioClient = BucketManagerConfig.Configurations.Value.Minio.GetMinioClient();

            this.BucketManager = new BucketManager(BucketManagerConfig.Logger, BucketManagerConfig.Configurations, EsRepository, minioClient);

            this.BucketManager.SetBucket(this.BucketName);
        }
        public static void CreateBucketConnection()
        {
            var cluster = ClusterFactory.GetCluster();
            var cbConfig = new CouchbaseConfiguration();

            var password = cbConfig.GetPassword();
            if (!string.IsNullOrWhiteSpace(password))
                bucket = cluster.OpenBucket(cbConfig.GetBucket(), password);
            else
                bucket = cluster.OpenBucket(cbConfig.GetBucket());

            bucketManager = bucket.CreateManager("Administrator", "123456");
        }
Esempio n. 15
0
 public static void VegsRepopulate(IRobotManager robotManager, IBucketManager bucketManager)
 {
     CoolDown++;
     if (CoolDown >= SimOpt.SimOpts.RepopCooldown)
     {
         for (var t = 1; t < SimOpt.SimOpts.RepopAmount; t++)
         {
             aggiungirob(robotManager, bucketManager);
             TotalVegs++;
         }
         CoolDown -= SimOpt.SimOpts.RepopCooldown;
     }
 }
        public void OneTimeSetUp()
        {
            _cluster = new Cluster(Utils.TestConfiguration.GetConfiguration("basic"));
            _clusterManager = _cluster.CreateManager(TestConfiguration.Settings.AdminUsername, TestConfiguration.Settings.AdminPassword);

            var createResult = _clusterManager.CreateBucket(BucketName, flushEnabled: true, bucketType:BucketTypeEnum.Memcached);
            Console.WriteLine(createResult.Success);

            // Allow time for bucket to be created and configuration to propagate before beginning operations
            Thread.Sleep(500);

            _bucket = _cluster.OpenBucket(BucketName);
            _bucketManager = _bucket.CreateManager(TestConfiguration.Settings.AdminUsername, TestConfiguration.Settings.AdminPassword);
        }
        public void OneTimeSetUp()
        {
            _cluster = new Cluster(Utils.TestConfiguration.GetConfiguration("basic"));
            _clusterManager = _cluster.CreateManager(TestConfiguration.Settings.AdminUsername, TestConfiguration.Settings.AdminPassword);

            var createResult = _clusterManager.CreateBucket(BucketName, replicaNumber:ReplicaNumber.Zero, flushEnabled: true);
            Assert.True(createResult.Success);

            // Allow time for bucket to be created and configuration to propagate before beginning operations
            Thread.Sleep(500);

            _bucket = _cluster.OpenBucket(BucketName);
            _bucketManager = _bucket.CreateManager(TestConfiguration.Settings.AdminUsername, TestConfiguration.Settings.AdminPassword);
        }
Esempio n. 18
0
        public void OneTimeSetUp()
        {
            _cluster        = new Cluster(Utils.TestConfiguration.GetConfiguration("basic"));
            _clusterManager = _cluster.CreateManager(TestConfiguration.Settings.AdminUsername, TestConfiguration.Settings.AdminPassword);

            var createResult = _clusterManager.CreateBucket(BucketName, flushEnabled: true, bucketType: BucketTypeEnum.Memcached);

            Console.WriteLine(createResult.Success);

            // Allow time for bucket to be created and configuration to propagate before beginning operations
            Thread.Sleep(500);

            _bucket        = _cluster.OpenBucket(BucketName);
            _bucketManager = _bucket.CreateManager(TestConfiguration.Settings.AdminUsername, TestConfiguration.Settings.AdminPassword);
        }
Esempio n. 19
0
        public void OneTimeSetUp()
        {
            _cluster        = new Cluster(Utils.TestConfiguration.GetConfiguration("basic"));
            _clusterManager = _cluster.CreateManager(TestConfiguration.Settings.AdminUsername, TestConfiguration.Settings.AdminPassword);

            var createResult = _clusterManager.CreateBucket(BucketName, replicaNumber: ReplicaNumber.Zero, flushEnabled: true);

            Assert.True(createResult.Success);

            // Allow time for bucket to be created and configuration to propagate before beginning operations
            Thread.Sleep(500);

            _bucket        = _cluster.OpenBucket(BucketName);
            _bucketManager = _bucket.CreateManager(TestConfiguration.Settings.AdminUsername, TestConfiguration.Settings.AdminPassword);
        }
Esempio n. 20
0
        public static void CreateBucketConnection()
        {
            var cluster  = ClusterFactory.GetCluster();
            var cbConfig = new CouchbaseConfiguration();

            var password = cbConfig.GetPassword();

            if (!string.IsNullOrWhiteSpace(password))
            {
                bucket = cluster.OpenBucket(cbConfig.GetBucket(), password);
            }
            else
            {
                bucket = cluster.OpenBucket(cbConfig.GetBucket());
            }

            bucketManager = bucket.CreateManager("Administrator", "123456");
        }
Esempio n. 21
0
        private static void aggiungirob(IRobotManager robotManager, IBucketManager bucketManager)
        {
            if (!SimOpt.SimOpts.Specie.Any(s => CheckVegStatus(robotManager, s)))
            {
                return;
            }

            int r;

            do
            {
                r = ThreadSafeRandom.Local.Next(0, SimOpt.SimOpts.Specie.Count); // start randomly in the list of species
            } while (!CheckVegStatus(robotManager, SimOpt.SimOpts.Specie[r]));

            var x = ThreadSafeRandom.Local.Next(Robot.RobSize / 2, SimOpt.SimOpts.FieldWidth - Robot.RobSize / 2);
            var y = ThreadSafeRandom.Local.Next(Robot.RobSize / 2, SimOpt.SimOpts.FieldHeight - Robot.RobSize / 2);

            if (SimOpt.SimOpts.Specie[r].Name == "" || SimOpt.SimOpts.Specie[r].Path == "Invalid Path")
            {
                return;
            }

            var a = DnaManipulations.RobScriptLoad(robotManager, bucketManager, System.IO.Path.Join(SimOpt.SimOpts.Specie[r].Path,
                                                                                                    SimOpt.SimOpts.Specie[r].Name));

            if (a == null)
            {
                SimOpt.SimOpts.Specie[r].Native = false;
                return;
            }

            //Check to see if we were able to load the bot.  If we can't, the path may be wrong, the sim may have
            //come from another machine with a different install path.  Set the species path to an empty string to
            //prevent endless looping of error dialogs.
            if (!a.Exists)
            {
                SimOpt.SimOpts.Specie[r].Path = "Invalid Path";
                return;
            }

            a.IsVegetable = SimOpt.SimOpts.Specie[r].Veg;
            if (a.IsVegetable)
            {
                a.Chloroplasts = SimOptions.StartChlr;
            }

            a.IsFixed                 = SimOpt.SimOpts.Specie[r].Fixed;
            a.CantSee                 = SimOpt.SimOpts.Specie[r].CantSee;
            a.DnaDisabled             = SimOpt.SimOpts.Specie[r].DisableDna;
            a.MovementSysvarsDisabled = SimOpt.SimOpts.Specie[r].DisableMovementSysvars;
            a.CantReproduce           = SimOpt.SimOpts.Specie[r].CantReproduce;
            a.IsVirusImmune           = SimOpt.SimOpts.Specie[r].VirusImmune;
            a.IsCorpse                = false;
            a.IsDead       = false;
            a.Body         = 1000;
            a.Mutations    = 0;
            a.OldMutations = 0;
            a.LastMutation = 0;
            a.SonNumber    = 0;
            a.Parent       = null;
            Array.Clear(a.Memory, 0, a.Memory.Length);

            if (a.IsFixed)
            {
                a.Memory[216] = 1;
            }

            a.Position = new DoubleVector(x, y);

            a.Aim = ThreadSafeRandom.Local.NextDouble() * Math.PI * 2;
            a.Memory[MemoryAddresses.SetAim] = (int)a.Aim * 200;

            //Bot is already in a bucket due to the prepare routine
            bucketManager.UpdateBotBucket(a);
            a.Energy = SimOpt.SimOpts.Specie[r].Stnrg;
            a.MutationProbabilities = SimOpt.SimOpts.Specie[r].Mutables;

            a.VirusTimer    = 0;
            a.VirusShot     = null;
            a.NumberOfGenes = DnaManipulations.CountGenes(a.Dna);

            a.GenMut = (double)a.Dna.Count / RobotsManager.GeneticSensitivity;

            a.Memory[MemoryAddresses.DnaLenSys] = a.Dna.Count;
            a.Memory[MemoryAddresses.GenesSys]  = a.NumberOfGenes;

            a.ChloroplastsDisabled = SimOpt.SimOpts.Specie[r].NoChlr;

            for (var i = 0; i < 7; i++)
            {
                a.Skin[i] = SimOpt.SimOpts.Specie[r].Skin[i];
            }

            a.Color = SimOpt.SimOpts.Specie[r].Color;
            Senses.MakeOccurrList(a);
        }
Esempio n. 22
0
 public void Init()
 {
     bucketManager = new BucketManager();
 }
Esempio n. 23
0
 public static Task CreateAsync(this IBucketManager bucketManager, BucketSettings settings)
 {
     return(bucketManager.CreateAsync(settings, CreateBucketOptions.Default));
 }
Esempio n. 24
0
 public static Task FlushAsync(this IBucketManager bucketManager, string bucketName)
 {
     return(bucketManager.Flush(bucketName, FlushBucketOptions.Default));
 }
Esempio n. 25
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory, IBucketManager bucketManager, ICouchbaseClientStore clientStore, ICouchbaseScopeStore scopeStore)
        {
            loggerFactory.AddConsole(_configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            bucketManager.CreateN1qlPrimaryIndex("primary", false);

            // Our client for the Mvc sample site
            var client = new Client
            {
                ClientId   = "mvc_implicit",
                ClientName = "MVC Implicit",
                ClientUri  = "http://identityserver.io",

                RedirectUris = new List <string>
                {
                    "http://*****:*****@email.com",
                SubjectId = Guid.NewGuid().ToString(),
                Claims    = new List <Claim>()
                {
                    new Claim(JwtClaimTypes.Name, "*****@*****.**"),
                }
            }, "Alice1#").Result;

            loggerFactory.AddDebug();

            app.UseMiddleware <ErrorCodeMiddleware>();

            app.UseIdentityServer();

            app.UseStaticFiles();
            app.UseMvcWithDefaultRoute();
        }
Esempio n. 26
0
 public static Task <BucketSettings> GetAsync(this IBucketManager bucketManager, string bucketName)
 {
     return(bucketManager.GetAsync(bucketName, GetBucketOptions.Default));
 }
Esempio n. 27
0
 public BucketsController(ILogger <BucketsController> logger)
 {
     _logger        = logger;
     _bucketManager = new BucketManager();
 }
Esempio n. 28
0
 public Robot(IBucketManager bucketManager)
 {
     _bucketManager = bucketManager;
 }
Esempio n. 29
0
 public static Task UpsertAsync(this IBucketManager bucketManager, BucketSettings settings)
 {
     return(bucketManager.UpsertAsync(settings, UpsertBucketOptions.Default));
 }
Esempio n. 30
0
 public static Task DropAsync(this IBucketManager bucketManager, string bucketName)
 {
     return(bucketManager.DropAsync(bucketName, DropBucketOptions.Default));
 }
Esempio n. 31
0
 public static Task <Dictionary <string, BucketSettings> > GetAllAsync(this IBucketManager bucketManager)
 {
     return(bucketManager.GetAllAsync(GetAllBucketOptions.Default));
 }