public void AddSnapshotConfig <T>(SnapshotConfig config) { var entityType = typeof(T); if (!entitySnapshotsConfigs.TryAdd(entityType, config)) { throw new DungeonException($"Snapshot configration for given entity type already exists: {entityType.FullName}"); } }
public ByteArraySnapshotDao( AkkaPersistenceDataConnectionFactory connectionFactory, SnapshotConfig snapshotConfig, Akka.Serialization.Serialization serialization, IMaterializer mat, ILoggingAdapter logger) { _logger = logger; _mat = mat; _snapshotConfig = snapshotConfig; _serialization = serialization; _connectionFactory = connectionFactory; _serializer = new ByteArraySnapshotSerializer(serialization, _snapshotConfig); }
public DriverTaskInstance( RemoteInstallConfig config, string logpath, bool simulationOnly, VirtualMachineConfig vmConfig, InstallersConfig installersConfig, SnapshotConfig snapshotConfig) { _config = config; _vmConfig = vmConfig; _simulationOnly = simulationOnly; _logpath = logpath; _vmPowerDriver = new VirtualMachinePowerDriver(vmConfig, snapshotConfig, simulationOnly); _installersConfig = installersConfig; }
public Linq2DbSnapshotStore(Configuration.Config config) { _snapshotConfig = new SnapshotConfig(config); _dao = new ByteArraySnapshotDao( new AkkaPersistenceDataConnectionFactory(_snapshotConfig), _snapshotConfig, Context.System.Serialization, Materializer.CreateSystemMaterializer((ExtendedActorSystem)Context.System), Context.GetLogger()); if (_snapshotConfig.TableConfig.AutoInitialize) { try { _dao.InitializeTables(); } catch (Exception e) { Context.GetLogger().Warning(e, "Unable to Initialize Persistence Snapshot Table!"); } } }
public void OneChildNoOverlapTest() { VirtualMachineConfig config1 = new VirtualMachineConfig(); config1.File = Guid.NewGuid().ToString(); config1.Host = Guid.NewGuid().ToString(); VirtualMachineConfig config2 = new VirtualMachineConfig(); config2.File = Guid.NewGuid().ToString(); config2.Host = Guid.NewGuid().ToString(); SnapshotConfig snapshot1 = new SnapshotConfig(); config2.Snapshots.Add(snapshot1); SnapshotsConfig snapshots1 = new SnapshotsConfig(); snapshots1.Add(snapshot1); Assert.IsFalse(config1.Overlaps(config2)); Assert.IsFalse(config2.Overlaps(config1)); }
public void TwoChildrenOverlapTest() { VirtualMachineConfig config1 = new VirtualMachineConfig(); config1.File = Guid.NewGuid().ToString(); config1.Host = Guid.NewGuid().ToString(); VirtualMachineConfig config2 = new VirtualMachineConfig(); config2.File = Guid.NewGuid().ToString(); config2.Host = Guid.NewGuid().ToString(); // a snapshot child with a virtual machine SnapshotConfig snapshot0 = new SnapshotConfig(); SnapshotsConfig snapshots0 = new SnapshotsConfig(); snapshots0.Add(snapshot0); VirtualMachineConfig config3 = new VirtualMachineConfig(); config3.File = Guid.NewGuid().ToString(); config3.Host = Guid.NewGuid().ToString(); snapshot0.VirtualMachines.Add(config3); config2.Snapshots.Add(snapshot0); SnapshotConfig snapshot1 = new SnapshotConfig(); SnapshotsConfig snapshots1 = new SnapshotsConfig(); snapshots1.Add(snapshot1); config3.Snapshots.Add(snapshot1); Assert.IsFalse(config1.Overlaps(config2)); Assert.IsFalse(config2.Overlaps(config1)); snapshot1.VirtualMachines.Add(config1); Assert.IsTrue(config1.Overlaps(config2)); Assert.IsTrue(config2.Overlaps(config1)); }
static void Main(string[] args) { var serviceCollection = new ServiceCollection(); DungeonMongoRegistrationTool.RegisterInternals(); var serviceProvider = serviceCollection .AddCqrs <ConsoleLogger>() .AddMongoEventSourcing("mongodb://172.17.0.2:27017", "test_cqrs") // .WithoutSnapshots() .WithMongoSnapshots( "mongodb://172.17.0.2:27017", "test_cqrs", c => c.SetDefaultSnapshotConfig(SnapshotConfig.VersionDiff(10))) .RegisterCommandHandler <UserCommandHandler>() .RegisterEventHandler <UserEventHandler>() .Build() .BuildServiceProvider(); DungeonMongoRegistrationTool.RegisterAll(typeof(Program).Assembly); var cmdDispatch = serviceProvider.GetService <ICommandDispatcher>(); for (int i = 0; i < 10; i++) { Task.Factory.StartNew(() => { var sw = new Stopwatch(); sw.Start(); while (true) { System.Console.WriteLine("E"); sw.Restart(); try { //cmdDispatch.Dispatch<Guid, RegisterUserCommand> (new RegisterUserCommand { Login = "******", }, 5).Wait (); cmdDispatch.DispatchAbstract <Guid>(new RegisterUserCommand { Login = "******", }, 5).Wait(); } catch (Exception e) { System.Console.WriteLine(e); } try { cmdDispatch.DispatchAbstract <Guid>(new RegisterUserCommand { Login = "******" }, 5).Wait(); //cmdDispatch.Dispatch<Guid, RegisterUserCommand> (new RegisterUserCommand { Login = "******" }, 5).Wait (); } catch (Exception e) { System.Console.WriteLine(e); } try { cmdDispatch.DispatchAbstract(new RemoveUserCommand { Login = "******" }, 5).Wait(); //cmdDispatch.Dispatch (new RemoveUserCommand { Login = "******" }, 5).Wait (); } catch (Exception e) { System.Console.WriteLine(e); } try { cmdDispatch.DispatchAbstract(new RemoveUserCommand { Login = "******" }, 5).Wait(); //cmdDispatch.Dispatch (new RemoveUserCommand { Login = "******" }, 5).Wait (); } catch (Exception e) { System.Console.WriteLine(e); } System.Console.WriteLine("E: " + sw.ElapsedMilliseconds); } }, TaskCreationOptions.LongRunning); } while (true) { Thread.Sleep(10000); } }
public HttpResponseMessage Post(SnapshotConfig config) { // Validate credentials if (!ValidateCredentials(config.ApiId, config.Application)) { return(new HttpResponseMessage(HttpStatusCode.Forbidden)); } // If Url is null the can´t crawl if (config.Url == null) { return(new HttpResponseMessage { StatusCode = HttpStatusCode.BadRequest, Content = new StringContent("Url is required for crawl") }); } // If storing snapshot then a expiration date is required if (config.Store && config.ExpirationDate == null) { return(new HttpResponseMessage { StatusCode = HttpStatusCode.BadRequest, Content = new StringContent("Can´t store the crawl result without an expiration date") }); } //Create container for the app AzureHelper.CreateAppContainerIfNotExists(config.Application); if (AzureHelper.SnapshotExist(config.Application, config.Url)) { // If the snapshot is expired then crawl again if (AzureHelper.SnapshotExpired(config.Application, config.Url)) { var result = Crawl(config.Url); if (!result.Contains("Error : Unable to load url") && config.Store) { AzureHelper.SaveSnapshot(config.Application, config.Url, SkipMetaFragment(result)); AzureHelper.SetBlobAttributes(config.Application, config.Url, config.UserAgent, config.ExpirationDate); } return(new HttpResponseMessage() { Content = new StringContent(result) }); } // If not expired then read the stored snapshot return(new HttpResponseMessage() { Content = new StringContent(AzureHelper.ReadSnapshot(config.Application, config.Url)) }); } else { // Crawl and store the snapshot var result = Crawl(config.Url); if (!result.Contains("Error : Unable to load url") && config.Store) { AzureHelper.SaveSnapshot(config.Application, config.Url, SkipMetaFragment(result)); AzureHelper.SetBlobAttributes(config.Application, config.Url, config.UserAgent, config.ExpirationDate); } return(new HttpResponseMessage() { Content = new StringContent(result) }); } }
public ByteArraySnapshotSerializer(Akka.Serialization.Serialization serialization, SnapshotConfig config) { _serialization = serialization; _config = config; }
public void SetDefaultSnapshotConfig(SnapshotConfig config) { defaultSnapshotConfig = config; }