Exemplo n.º 1
0
        private static async Task <ModifyOngoingTaskResult> SetupReplication(IDocumentStore store, ExternalReplicationBase watcher)
        {
            var result = await store.Maintenance.SendAsync(new PutConnectionStringOperation <RavenConnectionString>(new RavenConnectionString
            {
                Name = watcher.ConnectionStringName,
                Database = watcher.Database,
                TopologyDiscoveryUrls = new[]
                {
                    watcher.Url
                }
            }));

            Assert.NotNull(result.RaftCommandIndex);

            IMaintenanceOperation <ModifyOngoingTaskResult> op;

            switch (watcher)
            {
            case PullReplicationAsSink pull:
                op = new UpdatePullReplicationAsSinkOperation(pull);
                break;

            case ExternalReplication ex:
                op = new UpdateExternalReplicationOperation(ex);
                break;

            default:
                throw new ArgumentException($"Unrecognized type: {watcher.GetType().FullName}");
            }

            return(await store.Maintenance.SendAsync(op));
        }
Exemplo n.º 2
0
        protected static async Task <ModifyOngoingTaskResult> AddWatcherToReplicationTopology <T>(
            IDocumentStore store,
            T watcher,
            string[] urls = null) where T : ExternalReplicationBase
        {
            var result = await store.Maintenance.SendAsync(new PutConnectionStringOperation <RavenConnectionString>(new RavenConnectionString
            {
                Name = watcher.ConnectionStringName,
                Database = watcher.Database,
                TopologyDiscoveryUrls = urls ?? store.Urls
            }));

            Assert.NotNull(result.RaftCommandIndex);

            IMaintenanceOperation <ModifyOngoingTaskResult> op;

            if (watcher is PullReplicationAsSink pull)
            {
                op = new UpdatePullReplicationAsSinkOperation(pull);
            }
            else if (watcher is ExternalReplication ex)
            {
                op = new UpdateExternalReplicationOperation(ex);
            }
            else
            {
                throw new ArgumentException($"Unrecognized type: {watcher.GetType().FullName}");
            }

            return(await store.Maintenance.SendAsync(op));
        }
Exemplo n.º 3
0
        public async Task EnsureConnectionStringNameCantBeNull()
        {
            using (var store = GetDocumentStore())
            {
                var pull = new PullReplicationAsSink(store.Database, "test", "dummy");
                pull.ConnectionStringName = null;
                var op = new UpdatePullReplicationAsSinkOperation(pull);
                var ex = await Assert.ThrowsAsync <RavenException>(async() => await store.Maintenance.SendAsync(op));

                RavenTestHelper.AssertStartsWithRespectingNewLines("Raven.Server.Rachis.RachisApplyException: Failed to update database record.\r\n ---> System.ArgumentNullException: Value cannot be null.", ex.Message);
            }
        }