Exemple #1
0
        private static async Task StoreActiveDatabaseNames(ServerRecord server, AsyncServerClient client, IAsyncDocumentSession session)
        {
            AdminStatistics adminStatistics = await client.GlobalAdmin.GetStatisticsAsync();

            server.IsUnauthorized = false;

            server.ClusterName      = adminStatistics.ClusterName;
            server.ServerName       = adminStatistics.ServerName;
            server.MemoryStatistics = adminStatistics.Memory;

            foreach (var loadedDatabase in adminStatistics.LoadedDatabases)
            {
                var databaseRecord = await session.LoadAsync <DatabaseRecord>(server.Id + "/" + loadedDatabase.Name);

                if (databaseRecord == null)
                {
                    databaseRecord = new DatabaseRecord {
                        Name = loadedDatabase.Name, ServerId = server.Id, ServerUrl = server.Url
                    };
                    await session.StoreAsync(databaseRecord);
                }

                databaseRecord.LoadedDatabaseStatistics = loadedDatabase;
            }
            server.LoadedDatabases = adminStatistics.LoadedDatabases.Select(database => database.Name).ToArray();
        }
Exemple #2
0
        /// <summary>
        /// Initialize the document store access method to RavenDB
        /// </summary>
        protected virtual void InitializeInternal()
        {
#if !SILVERLIGHT
            var rootDatabaseUrl  = MultiDatabase.GetRootDatabaseUrl(Url);
            var rootServicePoint = ServicePointManager.FindServicePoint(new Uri(rootDatabaseUrl));
            rootServicePoint.UseNagleAlgorithm = false;
            rootServicePoint.Expect100Continue = false;
            rootServicePoint.ConnectionLimit   = 256;

            databaseCommandsGenerator = () =>
            {
                string databaseUrl = Url;
                if (string.IsNullOrEmpty(DefaultDatabase) == false)
                {
                    databaseUrl = rootDatabaseUrl;
                    databaseUrl = databaseUrl + "/databases/" + DefaultDatabase;
                }
                return(new ServerClient(databaseUrl, Conventions, credentials, GetReplicationInformerForDatabase, null, jsonRequestFactory, currentSessionId, listeners.ConflictListeners));
            };
#endif

            asyncDatabaseCommandsGenerator = () =>
            {
                var asyncServerClient = new AsyncServerClient(Url, Conventions, credentials, jsonRequestFactory, currentSessionId, GetReplicationInformerForDatabase, null, listeners.ConflictListeners);

                if (string.IsNullOrEmpty(DefaultDatabase))
                {
                    return(asyncServerClient);
                }
                return(asyncServerClient.ForDatabase(DefaultDatabase));
            };
        }
        protected virtual void InitializeInternal()
        {
            ReplicationInformer replicationInformer = new ReplicationInformer(this.Conventions);

            this.databaseCommandsGenerator = (Func <IDatabaseCommands>)(() =>
            {
                ServerClient local_0 = new ServerClient(this.Url, this.Conventions, this.credentials, replicationInformer, this.jsonRequestFactory, DocumentStore.currentSessionId);
                if (string.IsNullOrEmpty(this.DefaultDatabase))
                {
                    return((IDatabaseCommands)local_0);
                }
                else
                {
                    return(local_0.ForDatabase(this.DefaultDatabase));
                }
            });
            this.asyncDatabaseCommandsGenerator = (Func <IAsyncDatabaseCommands>)(() =>
            {
                AsyncServerClient local_0 = new AsyncServerClient(this.Url, this.Conventions, this.credentials, this.jsonRequestFactory, DocumentStore.currentSessionId);
                if (string.IsNullOrEmpty(this.DefaultDatabase))
                {
                    return((IAsyncDatabaseCommands)local_0);
                }
                else
                {
                    return(local_0.ForDatabase(this.DefaultDatabase));
                }
            });
        }
        /// <summary>
        /// Initialize the document store access method to RavenDB
        /// </summary>
        protected virtual void InitializeInternal()
        {
            var rootDatabaseUrl = MultiDatabase.GetRootDatabaseUrl(Url);

            databaseCommandsGenerator = () =>
            {
                string databaseUrl = Url;
                if (string.IsNullOrEmpty(DefaultDatabase) == false)
                {
                    databaseUrl = rootDatabaseUrl;
                    databaseUrl = databaseUrl + "/databases/" + DefaultDatabase;
                }
                return(new ServerClient(new AsyncServerClient(databaseUrl, Conventions, new OperationCredentials(ApiKey, Credentials), jsonRequestFactory,
                                                              currentSessionId, GetRequestExecuterForDatabase, GetRequestTimeMetricForDatabase, Changes, null,
                                                              Listeners.ConflictListeners, true, Conventions.ClusterBehavior)));
            };

            asyncDatabaseCommandsGenerator = () =>
            {
                var asyncServerClient = new AsyncServerClient(Url, Conventions, new OperationCredentials(ApiKey, Credentials), jsonRequestFactory, currentSessionId, GetRequestExecuterForDatabase, GetRequestTimeMetricForDatabase, Changes, null, Listeners.ConflictListeners, true, Conventions.ClusterBehavior);

                if (string.IsNullOrEmpty(DefaultDatabase))
                {
                    return(asyncServerClient);
                }
                return(asyncServerClient.ForDatabase(DefaultDatabase));
            };
        }
        public Task UpdateReplicationInformationIfNeededAsync(AsyncServerClient serverClient, bool force = false)
        {
            if (force)
            {
                throw new NotSupportedException("Force is not supported in ReplicationAwareRequestExecuter");
            }

            return(replicationInformer.UpdateReplicationInformationIfNeededAsync(serverClient));
        }
 public ChunkedRemoteBulkInsertOperation(BulkInsertOptions options, AsyncServerClient client, IDatabaseChanges changes, int chunkSize, long?documentSizeInChunkLimit = null)
 {
     this.options   = options;
     this.client    = client;
     this.changes   = changes;
     this.chunkSize = chunkSize;
     this.documentSizeInChunkLimit = documentSizeInChunkLimit;
     documentSizeInChunk           = 0;
 }
Exemple #7
0
        private async Task <Stream> ConnectToServer(AsyncServerClient asyncServerClient)
        {
            var connectionInfo = await asyncServerClient.GetTcpInfoAsync().ConfigureAwait(false);

            var uri = new Uri(connectionInfo.Url);
            await _tcpClient.ConnectAsync(uri.Host, uri.Port).ConfigureAwait(false);

            _tcpClient.NoDelay           = true;
            _tcpClient.SendBufferSize    = 32 * 1024;
            _tcpClient.ReceiveBufferSize = 4096;
            var networkStream = _tcpClient.GetStream();

            return(networkStream);
        }
Exemple #8
0
        /// <summary>
        /// Initialize the document store access method to RavenDB
        /// </summary>
        protected virtual void InitializeInternal()
        {
#if !SILVERLIGHT && !NETFX_CORE
            var rootDatabaseUrl  = MultiDatabase.GetRootDatabaseUrl(Url);
            var rootServicePoint = ServicePointManager.FindServicePoint(new Uri(rootDatabaseUrl));
            rootServicePoint.UseNagleAlgorithm = false;
            rootServicePoint.Expect100Continue = false;
            rootServicePoint.ConnectionLimit   = 256;

            databaseCommandsGenerator = () =>
            {
                string databaseUrl = Url;
                if (string.IsNullOrEmpty(DefaultDatabase) == false)
                {
                    databaseUrl = rootDatabaseUrl;
                    databaseUrl = databaseUrl + "/databases/" + DefaultDatabase;
                }
                return(new ServerClient(databaseUrl, Conventions, ApiKey, Credentials, GetReplicationInformerForDatabase, null, jsonRequestFactory, currentSessionId, listeners.ConflictListeners));
            };
#endif

            asyncDatabaseCommandsGenerator = () =>
            {
                var asyncServerClient = new AsyncServerClient(Url, Conventions, ApiKey, Credentials, jsonRequestFactory, currentSessionId, GetReplicationInformerForDatabase, null, listeners.ConflictListeners);

                if (string.IsNullOrEmpty(DefaultDatabase))
                {
                    return(asyncServerClient);
                }
                return(asyncServerClient.ForDatabase(DefaultDatabase));
            };


#if SILVERLIGHT
            // required to ensure just a single auth dialog
            var task = asyncDatabaseCommandsGenerator().GetDocumentsAsync(0, 0, metadataOnly: true)
                       .ContinueWith(t =>
            {
                // we don't actually _care_ if we succeed or not here, we just care that we
                // issued this command and now will only have a single auth dialog
                return(t.Exception != null);
            });
            jsonRequestFactory.ConfigureRequest += (sender, args) =>
            {
                args.JsonRequest.WaitForTask = task;
            };
#endif
        }
Exemple #9
0
        private static async Task StoreDatabaseNames(ServerRecord server, AsyncServerClient client, IAsyncDocumentSession session)
        {
            server.Databases = await client.GetDatabaseNamesAsync(1024);

            foreach (var databaseName in server.Databases.Concat(new[] { Constants.SystemDatabase }))
            {
                var databaseRecord = await session.LoadAsync <DatabaseRecord>(server.Id + "/" + databaseName);

                if (databaseRecord == null)
                {
                    databaseRecord = new DatabaseRecord {
                        Name = databaseName, ServerId = server.Id, ServerUrl = server.Url
                    };
                    await session.StoreAsync(databaseRecord);
                }
            }
        }
Exemple #10
0
		public static HttpJsonRequest ToJsonRequest(this string url, AsyncServerClient requestor, ICredentials credentials, DocumentConvention convention, IDictionary<string, string> operationsHeaders, string method)
		{
			var httpJsonRequest = requestor.JsonRequestFactory.CreateHttpJsonRequest(requestor, url, method, credentials, convention);
			httpJsonRequest.AddOperationHeaders(operationsHeaders);
			return httpJsonRequest;
		}
Exemple #11
0
		public static HttpJsonRequest ToJsonRequest(this string url, AsyncServerClient requestor, ICredentials credentials, Document.DocumentConvention convention)
		{
			return requestor.JsonRequestFactory.CreateHttpJsonRequest(requestor, url, "GET", credentials, convention);
		}
        public AsyncAttachmentSession(string databaseAddress)
        {
            Convention = new DocumentConvention();

            Client = new AsyncServerClient(databaseAddress, Convention, Credentials);
        }