public async Task PingBucket(BucketType bucketType) { var cluster = await _fixture.GetCluster().ConfigureAwait(false); await cluster.Buckets.CreateBucketAsync(new BucketSettings { BucketType = bucketType, Name = "bucketmgr_test", RamQuotaMB = 100, FlushEnabled = true }).ConfigureAwait(false); await Task.Delay(5000).ConfigureAwait(false); try { var bucket = await cluster.BucketAsync("bucketmgr_test").ConfigureAwait(false); var pingReport = await bucket.PingAsync().ConfigureAwait(false); Assert.Contains(pingReport.Services.Keys, x => x == "kv"); Assert.True(pingReport.Services["kv"].All(x => x.State == Couchbase.Diagnostics.ServiceState.Ok)); } finally { await _fixture.InitializeAsync().ConfigureAwait(false); cluster = await _fixture.GetCluster().ConfigureAwait(false); await cluster.Buckets.DropBucketAsync("bucketmgr_test").ConfigureAwait(false); } }
public static Bucket Create(BucketType bucketType, Cell cell, Color32 paintColor, string bucketName = null) { switch (bucketType) { case BucketType.Horizontal: bucket = new BucketHorizontal(cell, paintColor); bucket.bucketName = bucketName; bucket.cell = cell; bucket.paintColor = paintColor; break; case BucketType.Vertical: break; case BucketType.Random: break; default: break; } return(bucket); }
public void Create_GivenType_ExpectedType(BucketType bucketType, Type expectedType) { // Arrange var bucketFactory = new BucketFactory( new ClusterContext(), new Mock <IScopeFactory>().Object, new Mock <IRetryOrchestrator>().Object, new Mock <IVBucketKeyMapperFactory>().Object, new Mock <IKetamaKeyMapperFactory>().Object, new Mock <ILogger <CouchbaseBucket> >().Object, new Mock <ILogger <MemcachedBucket> >().Object, new TypedRedactor(RedactionLevel.None), new Mock <IBootstrapperFactory>().Object, NoopRequestTracer.Instance, new Mock <IOperationConfigurator>().Object, new BestEffortRetryStrategy(), new Mock <IHttpClusterMapFactory>().Object); // Act var result = bucketFactory.Create("bucket_name", bucketType, new BucketConfig()); // Assert Assert.IsAssignableFrom(expectedType, result); Assert.Equal("bucket_name", result.Name); }
public ClusterNode(ClusterContext context, IConnectionPoolFactory connectionPoolFactory, ILogger <ClusterNode> logger, ObjectPool <OperationBuilder> operationBuilderPool, ICircuitBreaker circuitBreaker, ISaslMechanismFactory saslMechanismFactory, IRedactor redactor, IPEndPoint endPoint, BucketType bucketType, NodeAdapter nodeAdapter, IRequestTracer tracer) { _context = context ?? throw new ArgumentNullException(nameof(context)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _circuitBreaker = circuitBreaker ?? throw new ArgumentException(nameof(circuitBreaker)); _operationBuilderPool = operationBuilderPool ?? throw new ArgumentNullException(nameof(operationBuilderPool)); _saslMechanismFactory = saslMechanismFactory ?? throw new ArgumentException(nameof(saslMechanismFactory)); _redactor = redactor ?? throw new ArgumentNullException(nameof(redactor)); _tracer = tracer; BucketType = bucketType; EndPoint = endPoint ?? throw new ArgumentNullException(nameof(endPoint)); _cachedToString = $"{EndPoint}-{_id}"; KeyEndPoints = new ReadOnlyObservableCollection <IPEndPoint>(_keyEndPoints); UpdateKeyEndPoints(); ((INotifyCollectionChanged)_keyEndPoints).CollectionChanged += (_, e) => OnKeyEndPointsChanged(e); if (connectionPoolFactory == null) { throw new ArgumentNullException(nameof(connectionPoolFactory)); } ConnectionPool = connectionPoolFactory.Create(this); if (nodeAdapter != null) { NodesAdapter = nodeAdapter; } }
public Bucket(Cell _cell, Color32 _paintColor, string _bucketName = null, BucketType _bucketType = BucketType.Random) { bucketType = _bucketType; cell = _cell; paintColor = _paintColor; bucketName = _bucketName; }
public void Create_GivenType_ExpectedType(BucketType bucketType, Type expectedType) { // Arrange var bucketFactory = new BucketFactory( new ClusterContext(), new Mock <IScopeFactory>().Object, new Mock <IRetryOrchestrator>().Object, new Mock <IVBucketKeyMapperFactory>().Object, new Mock <IKetamaKeyMapperFactory>().Object, new Mock <ILogger <CouchbaseBucket> >().Object, new Mock <ILogger <MemcachedBucket> >().Object, new Mock <IRedactor>().Object, new Mock <IBootstrapperFactory>().Object, NullRequestTracer.Instance); // Act var result = bucketFactory.Create("bucket_name", bucketType); // Assert Assert.IsAssignableFrom(expectedType, result); Assert.Equal("bucket_name", result.Name); }
public static void B2BucketTypeError(this IGuardClause guardClause, BucketType type) { if (type != BucketType.Public || type != BucketType.Private) { throw new B2BucketTypeError("A bucket can only be private or public in this context."); } }
/// <summary> /// 上传文件到OSS /// </summary> /// <param name="file">文件内存流</param> /// <param name="key">Key</param> /// <param name="bucketName">存储空间(Bucket)名称</param> /// <param name="bucketType">存储空间(Bucket)类型</param> /// <returns></returns> /// <Author>旷丽文</Author> public PutObjectResult PutFile(Stream file, string key, string bucketName, BucketType bucketType) { if (file == null) { throw new Exception("文件为空"); } if (key.IsNullOrWhiteSpace()) { throw new Exception("Key不能为空"); } if (bucketName.IsNullOrWhiteSpace()) { throw new Exception("bucket不能为空"); } try { key = key.Trim(); bucketName = $"{AppSettings["OSSBucketName"]}{bucketType.ToString()}{bucketName}".ToLower(); var result = this.Client.PutObject(bucketName, key, file); return(result); } catch (Exception ex) { LogerManager.Error(ex); return(null); } finally { file.Close(); file.Dispose(); } }
public string S3Bucket; /// Name of the Amazon S3 bucket. public JungleDiskBucket(BucketType type, string s3Bucket, string path, string displayName) { TypeOfBucket = type; S3Bucket = s3Bucket; BucketPath = path; DisplayName = displayName; }
/// <summary> /// 创建一个新的存储空间(Bucket) /// 不要平凡的创建存储空间 /// </summary> /// <param name="bucketName">存储控件的名称,该名称一定要唯一</param> /// <param name="bucketType">存储空间类型</param> /// <returns>创建成功的话, 返回Bucket对象, 否则返回null</returns> public Bucket CreateBucket(string bucketName, BucketType bucketType) { if (bucketName.IsNullOrWhiteSpace()) { throw new Exception("bucket不能为空"); } try { var exist = this.BucketExist(bucketName, bucketType); if (exist == null) { throw new Exception("创建失败"); } if ((bool)exist) { throw new Exception("该Bucket已经存在, 请更换名称"); } bucketName = $"{AppSettings["OSSBucketName"]}{bucketType.ToString()}{bucketName}".ToLower(); return(this.Client.CreateBucket(bucketName)); } catch (Exception ex) { LogerManager.Error(ex); return(null); } }
public Bucket(BucketType bucketType, string propertyName, int bucketNumber, bool sepsis) { BucketType = bucketType; PropertyName = propertyName; BucketNumber = bucketNumber; IsSepsis = sepsis; }
/// <summary> /// Initializes a new instance of the <see cref="CreateBucketRequest"/> class. /// </summary> /// <param name="accountId">The account id.</param> /// <param name="bucketName">The name to give the new bucket. Bucket names must be a minimum of <see cref="MinimumBucketNameLength"/> and a maximum of <see cref="MaximumBucketNameLength"/> characters long, and must be globally unique.</param> /// <param name="bucketType">The bucket secuirty authorization type.</param> public CreateBucketRequest(string accountId, string bucketName, BucketType bucketType) { // Validate required arguments if (string.IsNullOrWhiteSpace(accountId)) { throw new ArgumentException("Argument can not be null, empty, or consist only of white-space characters.", nameof(accountId)); } if (string.IsNullOrWhiteSpace(bucketName)) { throw new ArgumentException("Argument can not be null, empty, or consist only of white-space characters.", nameof(bucketName)); } if (bucketName.Length < MinimumBucketNameLength || bucketName.Length > MaximumBucketNameLength) { throw new ArgumentOutOfRangeException($"Argument must be a minimum of {MinimumBucketNameLength} and a maximum of {MaximumBucketNameLength} characters long.", nameof(bucketName)); } if (!Regex.IsMatch(bucketName, @"^([A-Za-z0-9\-]+)$")) { throw new ArgumentOutOfRangeException("Argument can consist of only letters, digits, and dashs.", nameof(bucketName)); } if (bucketName.StartsWith("b2-")) { throw new ArgumentException("Argument cannot start with 'b2-'. Reserved for internal Backblaze use.", nameof(bucketName)); } // Initialize and set required properties AccountId = accountId; BucketName = bucketName; BucketType = bucketType; }
/// <summary> /// Update an existing bucket. /// </summary> /// <param name="bucketId">The buckete id to update.</param> /// <param name="bucketType">The bucket secuirty authorization type.</param> /// <exception cref="AuthenticationException">Thrown when authentication fails.</exception> /// <exception cref="ApiException">Thrown when an error occurs during client operation.</exception> async Task <IApiResults <UpdateBucketResponse> > IStorageBuckets.UpdateAsync (string bucketId, BucketType bucketType) { var request = new UpdateBucketRequest(AccountId, bucketId, bucketType); return(await _client.UpdateBucketAsync(request, _cancellationToken)); }
public async Task FlushBuckets(BucketType bucketType) { var cluster = await _fixture.GetCluster().ConfigureAwait(false); var bucketName = nameof(BucketManagerTests) + "_" + nameof(FlushBuckets); await cluster.Buckets.CreateBucketAsync(new BucketSettings { BucketType = bucketType, Name = bucketName, RamQuotaMB = 100, FlushEnabled = true }).ConfigureAwait(false); await Task.Delay(5000).ConfigureAwait(false); try { await cluster.Buckets.FlushBucketAsync(bucketName).ConfigureAwait(false); } finally { await cluster.Buckets.DropBucketAsync(bucketName).ConfigureAwait(false); } }
public Bucket(BucketType bucketType, long epoch, string rootNamespace = "") { BucketType = bucketType; Epoch = epoch; RootNamespace = rootNamespace; }
public override int GetHashCode() { return(AccountID?.GetHashCode() ?? 0 ^ BucketID?.GetHashCode() ?? 0 ^ BucketName?.GetHashCode() ?? 0 ^ BucketType?.GetHashCode() ?? 0 ^ Revision.GetHashCode()); }
public B2Bucket(string AccountId, string BucketId, string BucketName, BucketType BucketType, List <B2LifecycleRule> LifecycleRules, ulong Revision) { this.AccountId = AccountId; this.BucketId = BucketId; this.BucketName = BucketName; this.BucketType = BucketType; this.LifecycleRules = LifecycleRules; this.Revision = Revision; }
protected S3BaseKey(string folderPath, BucketType bucketType) { if (bucketType == BucketType.None) { throw new ArgumentException($"Value must not equal '{bucketType}'", nameof(bucketType)); } BucketType = bucketType; FolderPath = folderPath ?? throw new ArgumentNullException(nameof(folderPath)); }
/// <summary> /// 获得OSS里面文件的网络地址 /// </summary> /// <param name="key">Key</param> /// <param name="bucketName">存储空间(Bucket)名称</param> /// <param name="bucketType">存储空间(Bucket)类型</param> /// <returns>返回网络地址</returns> /// <Author>旷丽文</Author> public string GetOssFileUrl(string key, string bucketName, BucketType bucketType) { if (key.IsNullOrWhiteSpace()) { throw new Exception("Key不能为空"); } key = key.Trim(); bucketName = $"{AppSettings["OSSBucketName"]}{bucketType.ToString()}{bucketName}".ToLower(); return($"http://{bucketName}.{this.OSSAddress}/{key}"); }
/// <summary> /// Creawte a new request object. /// </summary> /// <param name="accountId">The account ID.</param> /// <param name="bucketName">The bucket name.</param> /// <param name="bucketType">The bucket type.</param> public CreateBucketV1Request(string accountId, string bucketName, BucketType bucketType) : base(UrlParams.Empty, HeaderParams.Empty, new BodyParams( RequiredParam.Of("accountId", accountId), RequiredParam.Of("bucketName", bucketName), RequiredParam.Of("bucketType", bucketType) ) ) { }
private void BucketActivated(BucketType type) { if (type == BucketType.LevelPart) { IsLevelPartBucketActive = true; } else if (type == BucketType.LevelEnd) { IsLevelEndBucketActive = true; } }
//one of the many ways to describe a sale public void PrintSale() { if (BucketType != BucketTypes.Single) { Console.WriteLine(date.ToString() + " : Bucket : " + BucketType.ToString() + " cost : " + cost.ToString()); } else { Console.WriteLine(date.ToString() + " : Flower : " + FlowerType.ToString() + " cost : " + cost.ToString()); } }
/// <summary> /// 设置存储空间的访问权限 /// </summary> /// <param name="buckteName">存储空间的名称</param> /// <param name="bucketType">存储空间(Bucket)类型</param> public void SetBucketAcl(string buckteName, BucketType bucketType) { try { buckteName = $"{AppSettings["OSSBucketName"]}{bucketType.ToString()}{buckteName}".ToLower(); // 指定Bucket ACL为公共读 this.Client.SetBucketAcl(buckteName, CannedAccessControlList.PublicRead); } catch (Exception ex) { LogerManager.Error(ex); } }
public bool DeepEquals(DestinyEquipmentSlotDefinition other) { return(other != null && ApplyCustomArtDyes == other.ApplyCustomArtDyes && DisplayProperties.DeepEquals(other.DisplayProperties) && ArtDyeChannels.DeepEqualsReadOnlyCollections(other.ArtDyeChannels) && BucketType.DeepEquals(other.BucketType) && EquipmentCategoryHash == other.EquipmentCategoryHash && Blacklisted == other.Blacklisted && Hash == other.Hash && Index == other.Index && Redacted == other.Redacted); }
public Bucket(string BucketName, string BucketId, BucketType BucketType, string AccountId, Dictionary <string, string> BucketInfo, List <Dictionary <string, string> > LifecycleRules, long Revision) { this.BucketName = BucketName; this.BucketId = BucketId; this.BucketType = BucketType; this.AccountId = AccountId; this.BucketInfo = BucketInfo; this.LifecycleRules = LifecycleRules; this.Revision = Revision; }
public override int GetHashCode() { unchecked { var hash = 17; hash = hash * 23 + VBucketServerMap.GetHashCode(); hash = hash * 23 + BucketType.GetHashCode(); hash = hash * 23 + Name.GetHashCode(); hash = hash * 23 + AuthType.GetHashCode(); hash = hash * 23 + NodeLocator.GetHashCode(); hash = hash * 23 + SaslPassword.GetHashCode(); hash = hash * 23 + Uuid.GetHashCode(); hash = hash * 23 + Nodes.GetCombinedHashcode(); return(hash); } }
public bool DeepEquals(InventoryItemInventoryBlock other) { return(other != null && StackUniqueLabel == other.StackUniqueLabel && BucketType.DeepEquals(other.BucketType) && ExpirationTooltip == other.ExpirationTooltip && ExpiredInActivityMessage == other.ExpiredInActivityMessage && ExpiredInOrbitMessage == other.ExpiredInOrbitMessage && IsInstanceItem == other.IsInstanceItem && MaxStackSize == other.MaxStackSize && NonTransferrableOriginal == other.NonTransferrableOriginal && RecoveryBucketType.DeepEquals(other.RecoveryBucketType) && SuppressExpirationWhenObjectivesComplete == other.SuppressExpirationWhenObjectivesComplete && TierTypeEnumValue == other.TierTypeEnumValue && TierType.DeepEquals(other.TierType) && TierTypeName == other.TierTypeName); }
/// <summary> /// 判断存储空间(Bucket)是否存在 /// </summary> /// <param name="bucketName"></param> /// <param name="bucketType"></param> /// <returns>是否存在的bool, 调用失败返回null</returns> /// <Author>旷丽文</Author> public bool?BucketExist(string bucketName, BucketType bucketType) { if (bucketName.IsNullOrWhiteSpace()) { throw new Exception("bucket不能为空"); } try { bucketName = $"{AppSettings["OSSBucketName"]}{bucketType.ToString()}{bucketName}".ToLower(); return(this.Client.DoesBucketExist(bucketName)); } catch (Exception ex) { LogerManager.Error(ex); return(null); } }
/// <summary> /// Initializes a new instance of the <see cref="UpdateBucketRequest"/> class. /// </summary> /// <param name="accountId">The account id that the bucket is in.</param> /// <param name="bucketId">The buckete id to update.</param> /// <param name="bucketType">The bucket secuirty authorization type.</param> public UpdateBucketRequest(string accountId, string bucketId, BucketType bucketType) { // Validate required arguments if (string.IsNullOrWhiteSpace(accountId)) { throw new ArgumentException("Argument can not be null, empty, or consist only of white-space characters.", nameof(accountId)); } if (string.IsNullOrWhiteSpace(bucketId)) { throw new ArgumentException("Argument can not be null, empty, or consist only of white-space characters.", nameof(bucketId)); } // Initialize and set required properties AccountId = accountId; BucketId = bucketId; BucketType = bucketType; }
public S3FileKey( string folderPath, string fileName, BucketType bucketType, string versionId = null) : base(folderPath, bucketType) { if (string.IsNullOrWhiteSpace(fileName)) { throw new ArgumentException("Value cannot be null or whitespace.", nameof(fileName)); } if (versionId != null && versionId.Trim() == string.Empty) { throw new ArgumentException("Value cannot be empty or whitespace.", nameof(versionId)); } FileName = fileName; VersionId = versionId; }