MessageWriteScheduler(ICloudFactory factory, int parallelism, CancellationTokenSource source) { _factory = factory; _source = source; _writers = new ConcurrentDictionary <string, MessageWriter>(); _scheduler = new TaskSchedulerWithAffinity(parallelism); }
static CloudPageBlob GetBlob(ICloudFactory cloudBlobClient) { var container = cloudBlobClient.GetSysContainerReference(); var blob = container.GetPageBlobReference(Constants.MasterDataFileName); return(blob); }
public LeaderLock(ICloudFactory account, LeaderInfo info, ApiImplementation api) { Require.NotNull("account", account); Require.NotNull("info", info); _account = account; _info = info; _api = api; _lease = RenewableBlobLease.Create(account, LeaderMethod); }
public static RenewableBlobLease Create(ICloudFactory account, LeaderTask task) { Require.NotNull("account", account); Require.NotNull("task", task); var container = account.GetSysContainerReference(); var blob = container.GetPageBlobReference(Constants.MasterLockFileName); return new RenewableBlobLease(blob, task); }
public static async Task<LeaderInfo> Get(ICloudFactory client) { var blob = GetBlob(client); var exists = await blob.ExistsAsync(); if (!exists) { return null; } var endpoint = blob.Metadata["endpoint"]; return new LeaderInfo(endpoint); }
public static RenewableBlobLease Create(ICloudFactory account, LeaderTask task) { Require.NotNull("account", account); Require.NotNull("task", task); var container = account.GetSysContainerReference(); var blob = container.GetPageBlobReference(Constants.MasterLockFileName); return(new RenewableBlobLease(blob, task)); }
public static AuthData LoadFromStorageAccount(ICloudFactory account) { var container = account.GetSysContainerReference(); var blob = container.GetBlockBlobReference(Constants.AuthFileName); if (!blob.Exists()) { return GetEmptyConfig(); } var source = blob.DownloadText(); return AuthData.Deserialize(source); }
public async Task WriteToBlob(ICloudFactory storage) { var blob = GetBlob(storage); var exists = await blob.ExistsAsync(); if (!exists) { blob.Create(0, AccessCondition.GenerateIfNoneMatchCondition("*")); } blob.Metadata["endpoint"] = this._endpoint; await blob.SetMetadataAsync(); }
public static async Task <LeaderInfo> Get(ICloudFactory client) { var blob = GetBlob(client); var exists = await blob.ExistsAsync(); if (!exists) { return(null); } var endpoint = blob.Metadata["endpoint"]; return(new LeaderInfo(endpoint)); }
public static AuthData LoadFromStorageAccount(ICloudFactory account) { var container = account.GetSysContainerReference(); var blob = container.GetBlockBlobReference(Constants.AuthFileName); if (!blob.Exists()) { return(GetEmptyConfig()); } var source = blob.DownloadText(); return(AuthData.Deserialize(source)); }
public MainViewModel(MainState state, ICloudFactory factory, CloudViewModelFactory createViewModel) { _factory = factory; Refresh = ReactiveCommand.Create(state.Clouds.Refresh); _isLoading = Refresh .IsExecuting .ToProperty(this, x => x.IsLoading); _isReady = Refresh .IsExecuting .Select(executing => !executing) .ToProperty(this, x => x.IsReady); state .Clouds .Connect() .Transform(ps => createViewModel(ps, factory.CreateCloud(ps.Parameters))) .Sort(SortExpressionComparer <ICloudViewModel> .Descending(x => x.Created)) .ObserveOn(RxApp.MainThreadScheduler) .Bind(out _providers) .Subscribe(); var canRemove = this .WhenAnyValue(x => x.SelectedProvider) .Select(provider => provider != null); Remove = ReactiveCommand.Create( () => state.Clouds.RemoveKey(SelectedProvider.Id), canRemove); var canAddProvider = this .WhenAnyValue(x => x.SelectedSupportedType) .Select(type => Enum.IsDefined(typeof(CloudType), type)); Add = ReactiveCommand.Create( () => state.Clouds.AddOrUpdate(new CloudState { Type = SelectedSupportedType }), canAddProvider); _welcomeScreenVisible = this .WhenAnyValue(x => x.SelectedProvider) .Select(provider => provider == null) .ToProperty(this, x => x.WelcomeScreenVisible); _welcomeScreenCollapsed = this .WhenAnyValue(x => x.WelcomeScreenVisible) .Select(visible => !visible) .ToProperty(this, x => x.WelcomeScreenCollapsed); var canUnselect = this .WhenAnyValue(x => x.SelectedProvider) .Select(provider => provider != null); Unselect = ReactiveCommand.Create(() => Unit.Default, canUnselect); Unselect.Subscribe(unit => SelectedProvider = null); var outputCollectionChanges = Clouds .ToObservableChangeSet(x => x.Id) .Publish() .RefCount(); outputCollectionChanges .Filter(provider => provider.Id == state.SelectedProviderId) .ObserveOn(RxApp.MainThreadScheduler) .OnItemAdded(provider => SelectedProvider = provider) .Subscribe(); outputCollectionChanges .OnItemRemoved(provider => SelectedProvider = null) .Subscribe(); this.WhenAnyValue(x => x.SelectedProvider) .Skip(1) .Select(provider => provider?.Id ?? Guid.Empty) .Subscribe(id => state.SelectedProviderId = id); SelectedSupportedType = state.SelectedSupportedType ?? SupportedTypes.First(); this.WhenAnyValue(x => x.SelectedSupportedType) .Subscribe(type => state.SelectedSupportedType = type); }
public static MessageWriteScheduler Create(ICloudFactory factory, int parallelism) { return new MessageWriteScheduler(factory, parallelism); }
MessageWriteScheduler(ICloudFactory factory, int parallelism) { _factory = factory; _writers = new ConcurrentDictionary<string, MessageWriter>(); _scheduler = new TaskSchedulerWithAffinity(parallelism); }
static CloudPageBlob GetBlob(ICloudFactory cloudBlobClient) { var container = cloudBlobClient.GetSysContainerReference(); var blob = container.GetPageBlobReference(Constants.MasterDataFileName); return blob; }
ApiImplementation(ICloudFactory client, LeaderInfoPoller poller) { _client = client; _poller = poller; }
public static ApiImplementation Create(ICloudFactory account, LeaderInfoPoller poller, AuthData auth) { return new ApiImplementation(account, poller); }
public LeaderInfoPoller(ICloudFactory storage) { _storage = storage; }
public static MessageWriteScheduler Create(ICloudFactory factory, int parallelism, CancellationTokenSource source) { return(new MessageWriteScheduler(factory, parallelism, source)); }
public static ApiImplementation Create(ICloudFactory account, LeaderInfoPoller poller, AuthData auth) { return(new ApiImplementation(account, poller)); }