/// <summary> /// Builds a new instance of the <see cref="IChangeFeedProcessor"/> with the specified configuration. /// </summary> /// <returns>An instance of <see cref="IChangeFeedProcessor"/>.</returns> public async Task <IChangeFeedProcessor> BuildAsync() { if (this.hostName == null) { throw new InvalidOperationException("Host name was not specified"); } if (this.feedCollectionLocation == null) { throw new InvalidOperationException(nameof(this.feedCollectionLocation) + " was not specified"); } if (this.leaseCollectionLocation == null) { throw new InvalidOperationException(nameof(this.leaseCollectionLocation) + " was not specified"); } if (this.observerFactory == null) { throw new InvalidOperationException("Observer was not specified"); } await this.InitializeCollectionPropertiesForBuildAsync().ConfigureAwait(false); ILeaseManager leaseManager = await this.GetLeaseManagerAsync().ConfigureAwait(false); IPartitionManager partitionManager = await this.BuildPartitionManagerAsync(leaseManager).ConfigureAwait(false); return(new ChangeFeedProcessor(partitionManager)); }
public AppLeaseManager( AzureStorageClient azureStorageClient, IPartitionManager partitionManager, string appLeaseContainerName, string appLeaseInfoBlobName, AppLeaseOptions options) { this.azureStorageClient = azureStorageClient; this.partitionManager = partitionManager; this.appLeaseContainerName = appLeaseContainerName; this.appLeaseInfoBlobName = appLeaseInfoBlobName; this.options = options; this.storageAccountName = this.azureStorageClient.BlobAccountName; this.settings = this.azureStorageClient.Settings; this.taskHub = settings.TaskHubName; this.workerName = settings.WorkerId; this.appName = settings.AppName; this.appLeaseIsEnabled = this.settings.UseAppLease; this.appLeaseContainer = this.azureStorageClient.GetBlobContainerReference(this.appLeaseContainerName); this.appLeaseInfoBlob = this.appLeaseContainer.GetBlobReference(this.appLeaseInfoBlobName); var appNameHashInBytes = BitConverter.GetBytes(Fnv1aHashHelper.ComputeHash(this.appName)); Array.Resize(ref appNameHashInBytes, 16); this.appLeaseId = new Guid(appNameHashInBytes).ToString(); this.isLeaseOwner = false; this.shutdownCompletedEvent = new AsyncManualResetEvent(); }
public ShowController(IServiceFactory <IShowService> showServiceFactory, IPartitionManager partitionManager, IServiceFactory <IReservationService> reservationServiceFactory) { _showServiceFactory = showServiceFactory; _partitionManager = partitionManager; _reservationServiceFactory = reservationServiceFactory; }
public AppLeaseManager( AzureStorageClient azureStorageClient, IPartitionManager partitionManager, string appLeaseContainerName, string appLeaseInfoBlobName, AppLeaseOptions options) { this.azureStorageClient = azureStorageClient; this.partitionManager = partitionManager; this.appLeaseContainerName = appLeaseContainerName; this.appLeaseInfoBlobName = appLeaseInfoBlobName; this.options = options; this.storageAccountName = this.azureStorageClient.StorageAccountName; this.settings = this.azureStorageClient.Settings; this.taskHub = settings.TaskHubName; this.workerName = settings.WorkerId; this.appName = settings.AppName; this.appLeaseIsEnabled = this.settings.UseAppLease; this.appLeaseContainer = this.azureStorageClient.GetBlobContainerReference(this.appLeaseContainerName); this.appLeaseInfoBlob = this.appLeaseContainer.GetBlobReference(this.appLeaseInfoBlobName); using (MD5 md5 = MD5.Create()) { byte[] hash = md5.ComputeHash(Encoding.Default.GetBytes(this.appName)); this.appLeaseId = new Guid(hash).ToString(); } this.isLeaseOwner = false; this.shutdownCompletedEvent = new AsyncManualResetEvent(); }
public ChangeFeedProcessor(IPartitionManager partitionManager) { if (partitionManager == null) { throw new ArgumentNullException(nameof(partitionManager)); } this.partitionManager = partitionManager; }
internal Journal(IJournalMetadata metadata, IPartitionManager partitionManager, IJournalServer server) : base(metadata, partitionManager) { _metadata = metadata; _partitionManager = partitionManager; _server = server; _partitionManager.OnCommited += OnCommited; _writerState = new WriterState <T>(metadata.GetTimestampReader <T>()); }
internal Writer(IWriterState writerState, IPartitionManager partitionManager, object writeLock, int partitionTtl = MetadataConstants.DEFAULT_OPEN_PARTITION_TTL) { _writerState = writerState; _partitionManager = partitionManager; _transaction = _partitionManager.ReadTxLog(partitionTtl); _writeLock = writeLock; _partitionTtl = partitionTtl; }
internal JournalCore(IJournalMetadata metadata, IPartitionManager partitionManager) { _settings = metadata.Settings; _partitionManager = partitionManager; Metadata = metadata; var unsafePartitionManager = (IUnsafePartitionManager)partitionManager; QueryStatistics = new JournalStatistics(Metadata, unsafePartitionManager); Diagnostics = new JournalDiagnostics(unsafePartitionManager); Initialize(partitionManager.Access); }
/// <summary> /// Queries all Partition of given Service <typeparam name="TService"></typeparam> with given Items <typeparam name="TItem"></typeparam> /// </summary> /// <typeparam name="TService">Type of all Service instances which will be queried on all partitions</typeparam> /// <typeparam name="TItem">Type for what will be queried for</typeparam> /// <param name="serviceFactory">Factory of Type <typeparam name="IServiceFactory{TService}"> which creates the service</typeparam></param> /// <param name="partitionManager">Partition Manager, which wrapps the partition call to service fabric</param> /// <param name="action">actual query on the data item</param> /// <returns>All Items which had been queried for</returns> public static async Task ForEachService <TService>( IServiceFactory <TService> serviceFactory, IPartitionManager partitionManager, Action <TService> action) where TService : IService { var partitions = await GetServicePartitionList(serviceFactory, partitionManager); Parallel.ForEach(partitions, (partition, state) => { var service = serviceFactory.Get(partition.GetPartitionKey()); action(service); }); }
/// <summary> /// Queries all Partition of given Service <typeparam name="TService"></typeparam> with given Items <typeparam name="TItem"></typeparam> /// </summary> /// <typeparam name="TService">Type of all Service instances which will be queried on all partitions</typeparam> /// <typeparam name="TItem">Type for what will be queried for</typeparam> /// <param name="serviceFactory">Factory of Type <typeparam name="IServiceFactory{TService}"> which creates the service</typeparam></param> /// <param name="partitionManager">Partition Manager, which wrapps the partition call to service fabric</param> /// <param name="predicate">actual query on the data item</param> /// <returns>All Items which had been queried for</returns> public static async Task <IEnumerable <TItem> > SelectManyService <TService, TItem>( IServiceFactory <TService> serviceFactory, IPartitionManager partitionManager, Func <TService, TItem> predicate) where TService : IService { var partitions = await GetServicePartitionList(serviceFactory, partitionManager); var items = new BlockingCollection <TItem>(); Parallel.ForEach(partitions, (partition, state) => { var service = serviceFactory.Get(partition.GetPartitionKey()); var resItem = predicate(service); if (resItem != null) { items.Add(resItem); state.Break(); } }); return(items); }
public EpochManager(IPublisher bus, int cachedEpochCount, ICheckpoint checkpoint, ITransactionFileWriter writer, int initialReaderCount, int maxReaderCount, Func <ITransactionFileReader> readerFactory, IRecordFactory <TStreamId> recordFactory, INameIndex <TStreamId> streamNameIndex, INameIndex <TStreamId> eventTypeIndex, IPartitionManager partitionManager, Guid instanceId) { Ensure.NotNull(bus, "bus"); Ensure.Nonnegative(cachedEpochCount, "cachedEpochCount"); Ensure.NotNull(checkpoint, "checkpoint"); Ensure.NotNull(writer, "chunkWriter"); Ensure.Nonnegative(initialReaderCount, "initialReaderCount"); Ensure.Positive(maxReaderCount, "maxReaderCount"); if (initialReaderCount > maxReaderCount) { throw new ArgumentOutOfRangeException(nameof(initialReaderCount), "initialReaderCount is greater than maxReaderCount."); } Ensure.NotNull(readerFactory, "readerFactory"); _bus = bus; _cacheSize = cachedEpochCount; _checkpoint = checkpoint; _readers = new ObjectPool <ITransactionFileReader>("EpochManager readers pool", initialReaderCount, maxReaderCount, readerFactory); _writer = writer; _recordFactory = recordFactory; _streamNameIndex = streamNameIndex; _eventTypeIndex = eventTypeIndex; _partitionManager = partitionManager; _instanceId = instanceId; }
private void ConfigurePartitioner(IPartitionManager pm) { // TODO: fine tuning of partitioner // currently it does nothing }
public ReservationController(IServiceFactory <IReservationService> serviceFactory, IPartitionManager partitionManager) { _serviceFactory = serviceFactory; _partitionManager = partitionManager; }
private static async Task <ServicePartitionList> GetServicePartitionList <TService>(IServiceFactory <TService> serviceFactory, IPartitionManager partitionManager) where TService : IService { var uri = serviceFactory.GetServiceUri(); var partitions = await partitionManager.GetPartitionListAsync(uri); return(partitions); }