示例#1
0
        protected virtual IFilesChanges CreateFileSystemChanges(string filesystem)
        {
            if (string.IsNullOrEmpty(Url))
            {
                throw new InvalidOperationException("Changes API requires usage of server/client");
            }

            var tenantUrl = Url + "/fs/" + filesystem;

            var commands = fileSystemCommands.GetOrAdd(filesystem, x => (IAsyncFilesCommandsImpl)this.AsyncFilesCommands.ForFileSystem(x));

            using (NoSynchronizationContext.Scope())
            {
                var client = new FilesChangesClient(tenantUrl,
                                                    ApiKey,
                                                    Credentials,
                                                    jsonRequestFactory,
                                                    Conventions,
                                                    commands.ReplicationInformer,
                                                    ((AsyncFilesServerClient)this.AsyncFilesCommands).TryResolveConflictByUsingRegisteredListenersAsync,
                                                    () =>
                {
                    fileSystemChanges.Remove(filesystem);
                    fileSystemCommands.Remove(filesystem);
                });

                return(client);
            }
        }
示例#2
0
        protected virtual IDatabaseChanges CreateDatabaseChanges(string database)
        {
            if (string.IsNullOrEmpty(Url))
            {
                throw new InvalidOperationException("Changes API requires usage of server/client");
            }

            database = database ?? DefaultDatabase;

            var dbUrl = MultiDatabase.GetRootDatabaseUrl(Url);

            if (string.IsNullOrEmpty(database) == false)
            {
                dbUrl = dbUrl + "/databases/" + database;
            }

            using (NoSynchronizationContext.Scope())
            {
                return(new RemoteDatabaseChanges(dbUrl,
                                                 ApiKey,
                                                 Credentials,
                                                 jsonRequestFactory,
                                                 Conventions,
                                                 GetReplicationInformerForDatabase(database),
                                                 () => databaseChanges.Remove(database),
                                                 ((AsyncServerClient)AsyncDatabaseCommands).TryResolveConflictByUsingRegisteredListenersAsync));
            }
        }
示例#3
0
        protected virtual IDatabaseChanges CreateDatabaseChanges(string database)
        {
            if (string.IsNullOrEmpty(Url))
            {
                throw new InvalidOperationException("Changes API requires usage of server/client");
            }

            database = database ?? DefaultDatabase ?? MultiDatabase.GetDatabaseName(Url);

            var dbUrl = MultiDatabase.GetRootDatabaseUrl(Url);

            if (string.IsNullOrEmpty(database) == false &&
                string.Equals(database, Constants.SystemDatabase, StringComparison.OrdinalIgnoreCase) == false)
            {
                dbUrl = dbUrl + "/databases/" + database;
            }

            using (NoSynchronizationContext.Scope())
            {
                return(new RemoteDatabaseChanges(dbUrl,
                                                 ApiKey,
                                                 Credentials,
                                                 jsonRequestFactory,
                                                 Conventions,
                                                 () => databaseChanges.Remove(database),
                                                 (key, etag, conflictIds, metadata) => ((AsyncServerClient)AsyncDatabaseCommands).TryResolveConflictByUsingRegisteredListenersAsync(key, etag, conflictIds, metadata)));
            }
        }
        public void Dispose()
        {
            if (disposed)
            {
                return;
            }

            using (NoSynchronizationContext.Scope())
            {
                var disposeAsync = DisposeAsync().ConfigureAwait(false);
                disposeAsync.GetAwaiter().GetResult();
            }
        }
        public RemoteBulkInsertOperation(BulkInsertOptions options, AsyncServerClient client, IDatabaseChanges changes)
        {
            using (NoSynchronizationContext.Scope())
            {
                OperationId     = Guid.NewGuid();
                operationClient = client;
                queue           = new BlockingCollection <RavenJObject>(Math.Max(128, (options.BatchSize * 3) / 2));

                operationTask = StartBulkInsertAsync(options);
#if !MONO
                SubscribeToBulkInsertNotifications(changes);
#endif
            }
        }
示例#6
0
        public RemoteBulkInsertOperation(BulkInsertOptions options, AsyncServerClient client, IDatabaseChanges changes,
                                         Task <int> previousTask = null, Guid?existingOperationId = null)
        {
            this.options      = options;
            this.previousTask = previousTask;
            using (NoSynchronizationContext.Scope())
            {
                OperationId     = existingOperationId.HasValue?existingOperationId.Value:Guid.NewGuid();
                operationClient = client;
                queue           = new BlockingCollection <RavenJObject>(Math.Max(128, (options.BatchSize * 3) / 2));

                operationTask = StartBulkInsertAsync(options);

#if !MONO
                SubscribeToBulkInsertNotifications(changes);
#endif
            }
        }
示例#7
0
        private ICountersChanges CreateCounterStorageChanges(string counterStorage)
        {
            if (string.IsNullOrEmpty(Url))
            {
                throw new InvalidOperationException("Changes API requires usage of server/client");
            }

            AssertInitialized();

            var tenantUrl = $"{Url}/cs/{counterStorage}";

            using (NoSynchronizationContext.Scope())
            {
                var client = new CountersChangesClient(tenantUrl,
                                                       Credentials.ApiKey,
                                                       Credentials.Credentials,
                                                       CountersConvention,
                                                       () => counterStorageChanges.Remove(counterStorage));

                return(client);
            }
        }
示例#8
0
        private ITimeSeriesChanges CreateTimeSeriesChanges(string timeSeries)
        {
            if (string.IsNullOrEmpty(Url))
            {
                throw new InvalidOperationException("Changes API requires usage of server/client");
            }

            AssertInitialized();

            var tenantUrl = Url + "/ts/" + timeSeries;

            using (NoSynchronizationContext.Scope())
            {
                var client = new TimeSeriesChangesClient(tenantUrl,
                                                         Credentials.ApiKey,
                                                         Credentials.Credentials,
                                                         TimeSeriesConvention,
                                                         () => timeSeriesChanges.Remove(timeSeries));

                return(client);
            }
        }