public BackupGrain( IBackupArchiveLocation backupArchiveLocation, IBackupArchiveStore backupArchiveStore, IClock clock, IEventDataFormatter eventDataFormatter, IEventStore eventStore, IGrainState <BackupState> state, IServiceProvider serviceProvider, IUserResolver userResolver, ISemanticLog log) { Guard.NotNull(backupArchiveLocation, nameof(backupArchiveLocation)); Guard.NotNull(backupArchiveStore, nameof(backupArchiveStore)); Guard.NotNull(clock, nameof(clock)); Guard.NotNull(eventDataFormatter, nameof(eventDataFormatter)); Guard.NotNull(eventStore, nameof(eventStore)); Guard.NotNull(serviceProvider, nameof(serviceProvider)); Guard.NotNull(state, nameof(state)); Guard.NotNull(userResolver, nameof(userResolver)); Guard.NotNull(log, nameof(log)); this.backupArchiveLocation = backupArchiveLocation; this.backupArchiveStore = backupArchiveStore; this.clock = clock; this.eventDataFormatter = eventDataFormatter; this.eventStore = eventStore; this.serviceProvider = serviceProvider; this.state = state; this.userResolver = userResolver; this.log = log; }
public BackupGrain( IAssetStore assetStore, IBackupArchiveLocation backupArchiveLocation, IClock clock, IEventStore eventStore, IEventDataFormatter eventDataFormatter, ISemanticLog log, IStore <Guid> store) { Guard.NotNull(assetStore, nameof(assetStore)); Guard.NotNull(backupArchiveLocation, nameof(backupArchiveLocation)); Guard.NotNull(clock, nameof(clock)); Guard.NotNull(eventStore, nameof(eventStore)); Guard.NotNull(eventDataFormatter, nameof(eventDataFormatter)); Guard.NotNull(store, nameof(store)); Guard.NotNull(log, nameof(log)); this.assetStore = assetStore; this.backupArchiveLocation = backupArchiveLocation; this.clock = clock; this.eventStore = eventStore; this.eventDataFormatter = eventDataFormatter; this.store = store; this.log = log; }
public RestoreGrain( IBackupArchiveLocation backupArchiveLocation, IClock clock, ICommandBus commandBus, IEventDataFormatter eventDataFormatter, IEventStore eventStore, IGrainState <RestoreState2> state, IServiceProvider serviceProvider, IStreamNameResolver streamNameResolver, IUserResolver userResolver, ISemanticLog log) { Guard.NotNull(backupArchiveLocation); Guard.NotNull(clock); Guard.NotNull(commandBus); Guard.NotNull(eventDataFormatter); Guard.NotNull(eventStore); Guard.NotNull(serviceProvider); Guard.NotNull(state); Guard.NotNull(streamNameResolver); Guard.NotNull(userResolver); Guard.NotNull(log); this.backupArchiveLocation = backupArchiveLocation; this.clock = clock; this.commandBus = commandBus; this.eventDataFormatter = eventDataFormatter; this.eventStore = eventStore; this.serviceProvider = serviceProvider; this.state = state; this.streamNameResolver = streamNameResolver; this.userResolver = userResolver; this.log = log; }
public BackupGrain( IAssetStore assetStore, IBackupArchiveLocation backupArchiveLocation, IClock clock, IEventStore eventStore, IEventDataFormatter eventDataFormatter, IEnumerable <BackupHandler> handlers, IJsonSerializer serializer, ISemanticLog log, IStore <Guid> store) { Guard.NotNull(assetStore, nameof(assetStore)); Guard.NotNull(backupArchiveLocation, nameof(backupArchiveLocation)); Guard.NotNull(clock, nameof(clock)); Guard.NotNull(eventStore, nameof(eventStore)); Guard.NotNull(eventDataFormatter, nameof(eventDataFormatter)); Guard.NotNull(handlers, nameof(handlers)); Guard.NotNull(serializer, nameof(serializer)); Guard.NotNull(store, nameof(store)); Guard.NotNull(log, nameof(log)); this.assetStore = assetStore; this.backupArchiveLocation = backupArchiveLocation; this.clock = clock; this.eventStore = eventStore; this.eventDataFormatter = eventDataFormatter; this.handlers = handlers; this.serializer = serializer; this.store = store; this.log = log; }
public RestoreGrain(IBackupArchiveLocation backupArchiveLocation, IClock clock, ICommandBus commandBus, IEventStore eventStore, IEventDataFormatter eventDataFormatter, IEnumerable <BackupHandler> handlers, ISemanticLog log, IStreamNameResolver streamNameResolver, IStore <string> store) { Guard.NotNull(backupArchiveLocation, nameof(backupArchiveLocation)); Guard.NotNull(clock, nameof(clock)); Guard.NotNull(commandBus, nameof(commandBus)); Guard.NotNull(eventStore, nameof(eventStore)); Guard.NotNull(eventDataFormatter, nameof(eventDataFormatter)); Guard.NotNull(handlers, nameof(handlers)); Guard.NotNull(store, nameof(store)); Guard.NotNull(streamNameResolver, nameof(streamNameResolver)); Guard.NotNull(log, nameof(log)); this.backupArchiveLocation = backupArchiveLocation; this.clock = clock; this.commandBus = commandBus; this.eventStore = eventStore; this.eventDataFormatter = eventDataFormatter; this.handlers = handlers; this.store = store; this.streamNameResolver = streamNameResolver; this.log = log; }
public BackupGrain( IAssetStore assetStore, IBackupArchiveLocation backupArchiveLocation, IClock clock, IEventStore eventStore, IEventDataFormatter eventDataFormatter, IJsonSerializer serializer, IServiceProvider serviceProvider, ISemanticLog log, IGrainState <BackupState> state) { Guard.NotNull(assetStore, nameof(assetStore)); Guard.NotNull(backupArchiveLocation, nameof(backupArchiveLocation)); Guard.NotNull(clock, nameof(clock)); Guard.NotNull(eventStore, nameof(eventStore)); Guard.NotNull(eventDataFormatter, nameof(eventDataFormatter)); Guard.NotNull(serviceProvider, nameof(serviceProvider)); Guard.NotNull(serializer, nameof(serializer)); Guard.NotNull(state, nameof(state)); Guard.NotNull(log, nameof(log)); this.assetStore = assetStore; this.backupArchiveLocation = backupArchiveLocation; this.clock = clock; this.eventStore = eventStore; this.eventDataFormatter = eventDataFormatter; this.serializer = serializer; this.serviceProvider = serviceProvider; this.state = state; this.log = log; }
public RestoreGrain(IBackupArchiveLocation backupArchiveLocation, IClock clock, ICommandBus commandBus, IEventStore eventStore, IEventDataFormatter eventDataFormatter, IJsonSerializer serializer, ISemanticLog log, IServiceProvider serviceProvider, IStreamNameResolver streamNameResolver, IGrainState <RestoreState> state) { Guard.NotNull(backupArchiveLocation, nameof(backupArchiveLocation)); Guard.NotNull(clock, nameof(clock)); Guard.NotNull(commandBus, nameof(commandBus)); Guard.NotNull(eventStore, nameof(eventStore)); Guard.NotNull(eventDataFormatter, nameof(eventDataFormatter)); Guard.NotNull(serializer, nameof(serializer)); Guard.NotNull(serviceProvider, nameof(serviceProvider)); Guard.NotNull(state, nameof(state)); Guard.NotNull(streamNameResolver, nameof(streamNameResolver)); Guard.NotNull(log, nameof(log)); this.backupArchiveLocation = backupArchiveLocation; this.clock = clock; this.commandBus = commandBus; this.eventStore = eventStore; this.eventDataFormatter = eventDataFormatter; this.serializer = serializer; this.serviceProvider = serviceProvider; this.streamNameResolver = streamNameResolver; this.state = state; this.log = log; }
public static async Task DownloadAsync(this IBackupArchiveLocation backupArchiveLocation, Uri url, Guid id) { HttpResponseMessage response = null; try { using (var client = new HttpClient()) { response = await client.GetAsync(url); response.EnsureSuccessStatusCode(); using (var sourceStream = await response.Content.ReadAsStreamAsync()) { using (var targetStream = await backupArchiveLocation.OpenStreamAsync(id)) { await sourceStream.CopyToAsync(targetStream); } } } } catch (HttpRequestException ex) { throw new BackupRestoreException($"Cannot download the archive. Got status code: {response?.StatusCode}.", ex); } }
public static async Task DeleteAsync(IBackupArchiveLocation backupArchiveLocation, string id, ISemanticLog log) { try { await backupArchiveLocation.DeleteArchiveAsync(id); } catch (Exception ex) { log.LogError(ex, id, (logOperationId, w) => w .WriteProperty("action", "deleteArchive") .WriteProperty("status", "failed") .WriteProperty("operationId", logOperationId)); } }
public static async Task DownloadAsync(this IBackupArchiveLocation backupArchiveLocation, Uri url, string id) { if (string.Equals(url.Scheme, "file")) { try { using (var targetStream = await backupArchiveLocation.OpenStreamAsync(id)) { using (var sourceStream = new FileStream(url.LocalPath, FileMode.Open, FileAccess.Read)) { await sourceStream.CopyToAsync(targetStream); } } } catch (IOException ex) { throw new BackupRestoreException($"Cannot download the archive: {ex.Message}.", ex); } } else { HttpResponseMessage?response = null; try { using (var client = new HttpClient()) { response = await client.GetAsync(url); response.EnsureSuccessStatusCode(); using (var sourceStream = await response.Content.ReadAsStreamAsync()) { using (var targetStream = await backupArchiveLocation.OpenStreamAsync(id)) { await sourceStream.CopyToAsync(targetStream); } } } } catch (HttpRequestException ex) { throw new BackupRestoreException($"Cannot download the archive. Got status code: {response?.StatusCode}.", ex); } } }
public BackupGrain( IBackupArchiveLocation backupArchiveLocation, IBackupArchiveStore backupArchiveStore, IClock clock, IEventDataFormatter eventDataFormatter, IEventStore eventStore, IGrainState <BackupState> state, IServiceProvider serviceProvider, IUserResolver userResolver, ILogger <BackupGrain> log) { this.backupArchiveLocation = backupArchiveLocation; this.backupArchiveStore = backupArchiveStore; this.clock = clock; this.eventDataFormatter = eventDataFormatter; this.eventStore = eventStore; this.serviceProvider = serviceProvider; this.state = state; this.userResolver = userResolver; this.log = log; }
public static async Task <BackupReader> OpenArchiveAsync(this IBackupArchiveLocation backupArchiveLocation, string id, IJsonSerializer serializer) { Stream?stream = null; try { stream = await backupArchiveLocation.OpenStreamAsync(id); return(new BackupReader(serializer, stream)); } catch (IOException) { stream?.Dispose(); throw new BackupRestoreException("The backup archive is correupt and cannot be opened."); } catch (Exception) { stream?.Dispose(); throw; } }