private async Task WithContentLocationEventStore(Func <Context, IClock, IAbsFileSystem, ContentLocationEventStore, Task> action, ContentLocationEventStoreConfiguration configuration, IContentLocationEventHandler eventHandler, string localMachineName = "Worker") { string centralStateKeyBase = "ThisIsUnused"; var clock = new MemoryClock(); using var fileSystem = new PassThroughFileSystem(TestGlobal.Logger); var tracingContext = new Context(TestGlobal.Logger); { using var localDiskCentralStoreWorkingDirectory = new DisposableDirectory(fileSystem); var localDiskCentralStoreConfiguration = new LocalDiskCentralStoreConfiguration(localDiskCentralStoreWorkingDirectory.Path, centralStateKeyBase); var centralStorage = new LocalDiskCentralStorage(localDiskCentralStoreConfiguration); { using var eventHubWorkingDirectory = new DisposableDirectory(fileSystem); var eventStore = CreateEventStore(configuration, eventHandler, localMachineName, centralStorage, eventHubWorkingDirectory, clock); (await eventStore.StartupAsync(tracingContext)).ShouldBeSuccess(); await action(tracingContext, clock, fileSystem, eventStore); if (!eventStore.ShutdownStarted) { (await eventStore.ShutdownAsync(tracingContext)).ShouldBeSuccess(); } } } }
/// <inheritdoc /> public LocalDiskCentralStorage(LocalDiskCentralStoreConfiguration configuration) { Contract.Requires(configuration != null); _workingDirectory = configuration.WorkingDirectory; if (!string.IsNullOrEmpty(configuration.ContainerName)) { _workingDirectory /= configuration.ContainerName; } }
public Task ReconciliationOverRealStorage() { var checkpointsKey = Guid.NewGuid().ToString(); // Copy and paste a real connection string here. var storageConnectionString = string.Empty; // Consider updating this directory if you want to keep data between invocations. var workingDirectory = TestRootDirectoryPath; var configuration = new LocalDiskCentralStoreConfiguration( workingDirectory, checkpointsKey); var blobStoreConfiguration = new BlobCentralStoreConfiguration( credentials: new AzureBlobStorageCredentials(storageConnectionString), containerName: "checkpoints", checkpointsKey: checkpointsKey); var producerMachineLocation = new MachineLocation(); ConfigureWithOneMaster(s => { s.ReconcileMode = ReconciliationMode.Once.ToString(); s.AzureStorageSecretName = Host.StoreSecret("StorageName", storageConnectionString); }); return(RunTestAsync( new Context(Logger), 2, async context => { var master = context.GetMaster(); var worker = context.GetFirstWorker(); var workerId = worker.LocalLocationStore.ClusterState.PrimaryMachineId; var workerSession = context.Sessions[context.GetFirstWorkerIndex()]; var checkpointState = new CheckpointState( Role.Worker, EventSequencePoint.Parse("24382354"), "MD5:8C4856EA13F6AD59B65D8F6781D2A2F9||DCS||incrementalCheckpoints/24382354.10a0ca0f-d63f-4992-a088-f67bd00abd8a.checkpointInfo.txt|Incremental", DateTime.Now, producerMachineLocation, producerMachineLocation); // Next heartbeat workers to restore checkpoint await worker.LocalLocationStore.ProcessStateAsync(new OperationContext(context), checkpointState, inline: true, forceRestore: true).ShouldBeSuccess(); var reconcileResult = await worker.ReconcileAsync(context).ShouldBeSuccess(); Output.WriteLine($"Reconcile result: {reconcileResult}"); })); }
/// <inheritdoc /> public LocalDiskCentralStorage(LocalDiskCentralStoreConfiguration configuration) { Contract.Requires(configuration != null); _workingDirectory = configuration.WorkingDirectory; }