Esempio n. 1
0
        public bool Execute(CommandProcessorContext context, CancellationToken token, string[] args)
        {
            // [abdullin]: we don't need checkpoint write flood (multi-threads)
            // since there is only one writer by default
            int repeat = 10000;

            if (args.Length > 0)
            {
                int.TryParse(args[0], out repeat);
            }

            const string            checkpointName = "epfl.chk";
            AzureStoreConfiguration configuration;
            var location = context.Client.Options.StoreLocation;

            if (AzureStoreConfiguration.TryParse(location, out configuration))
            {
                var container = CloudStorageAccount.Parse(configuration.ConnectionString)
                                .CreateCloudBlobClient()
                                .GetContainerReference(configuration.RootBlobContainerName);

                container.CreateIfNotExist();
                var blob = container.GetPageBlobReference(checkpointName);
                blob.Create(512);
                try
                {
                    using (var pointer = new TestAzurePointer(blob))
                    {
                        TestPointer(context, pointer, repeat, "page");
                    }
                    using (var pointer = AzureEventPointer.OpenWriteable(blob))
                    {
                        TestPointer(context, pointer, repeat, "meta");
                    }
                }
                finally
                {
                    blob.DeleteIfExists();
                }
            }
            else
            {
                var fullName = Path.Combine(location, checkpointName);

                try
                {
                    using (var openOrCreateForWriting = FileEventPointer.OpenOrCreateForWriting(fullName))
                    {
                        TestPointer(context, openOrCreateForWriting, repeat, "file");
                    }
                }
                finally
                {
                    File.Delete(fullName);
                }
            }
            return(true);
        }
        public bool Execute(CommandProcessorContext context, CancellationToken token, string[] args)
        {
            // [abdullin]: we don't need checkpoint write flood (multi-threads)
            // since there is only one writer by default
            int repeat = 10000;
            if (args.Length > 0)
                int.TryParse(args[0], out repeat);

            const string checkpointName = "epfl.chk";
            AzureStoreConfiguration configuration;
            var location = context.Client.Options.StoreLocation;
            if (AzureStoreConfiguration.TryParse(location, out configuration))
            {

                var container = CloudStorageAccount.Parse(configuration.ConnectionString)
                                                   .CreateCloudBlobClient()
                                                   .GetContainerReference(configuration.RootBlobContainerName);

                container.CreateIfNotExist();
                var blob = container.GetPageBlobReference(checkpointName);
                blob.Create(512);
                try
                {
                    using (var pointer = new TestAzurePointer(blob))
                    {
                        TestPointer(context, pointer, repeat, "page");
                    }
                    using (var pointer = AzureEventPointer.OpenWriteable(blob))
                    {
                        TestPointer(context, pointer, repeat, "meta");
                    }
                }
                finally
                {
                    blob.DeleteIfExists();
                }

            }
            else
            {
                var fullName = Path.Combine(location, checkpointName);

                try
                {
                    using (var openOrCreateForWriting = FileEventPointer.OpenOrCreateForWriting(fullName))
                    {
                        TestPointer(context, openOrCreateForWriting, repeat, "file");
                    }
                }
                finally
                {
                    File.Delete(fullName);
                }

            }
            return true;
        }