Ejemplo n.º 1
0
 public AsyncAdminServerClient(AsyncServerClient asyncServerClient)
 {
     innerAsyncServerClient = asyncServerClient;
     adminRequest           =
         new AdminRequestCreator((url, method) => innerAsyncServerClient.ForSystemDatabase().CreateRequest(url, method),
                                 (currentServerUrl, requestUrl, method) => innerAsyncServerClient.CreateReplicationAwareRequest(currentServerUrl, requestUrl, method));
 }
		public ChunkedRemoteBulkInsertOperation(BulkInsertOptions options, AsyncServerClient client, IDatabaseChanges changes, int chunkSize)
		{
			this.options = options;
			this.client = client;
			this.changes = changes;
			this.chunkSize = chunkSize;
		}
Ejemplo n.º 3
0
 public AsyncAdminServerClient(AsyncServerClient asyncServerClient)
 {
     innerAsyncServerClient = asyncServerClient;
     adminRequest =
         new AdminRequestCreator((url, method) => innerAsyncServerClient.ForSystemDatabase().CreateRequest(url, method),
                                 (url, method) => innerAsyncServerClient.CreateRequest(url, method),
                                 (currentServerUrl, requestUrl, method) => innerAsyncServerClient.CreateReplicationAwareRequest(currentServerUrl, requestUrl, method));
 }
 public ChunkedRemoteBulkInsertOperation(BulkInsertOptions options, AsyncServerClient client, IDatabaseChanges changes)
 {
     this.options = options;
     this.client = client;
     this.changes = changes;			
     currentChunkSize = 0;
     current = GetBulkInsertOperation();
 }
		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;
		}
		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;
			if(documentSizeInChunkLimit.HasValue)
				Console.WriteLine("Limit of document size in chunk = " + documentSizeInChunkLimit.Value);
		}
Ejemplo n.º 7
0
		public AdminServerClient(AsyncServerClient asyncServerClient, AsyncAdminServerClient asyncAdminServerClient)
		{
			this.asyncServerClient = asyncServerClient;
			this.asyncAdminServerClient = asyncAdminServerClient;
		}
Ejemplo n.º 8
0
        /// <summary>
        /// Initialize the document store access method to RavenDB
        /// </summary>
        protected virtual void InitializeInternal()
        {
            var rootDatabaseUrl = MultiDatabase.GetRootDatabaseUrl(Url);

            rootServicePoint = ServicePointManager.FindServicePoint(new Uri(rootDatabaseUrl));
            rootServicePoint.UseNagleAlgorithm = false;
            rootServicePoint.Expect100Continue = false;
            rootServicePoint.ConnectionLimit = 256;
            rootServicePoint.MaxIdleTime = Timeout.Infinite;

            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, GetReplicationInformerForDatabase, null,
                    Listeners.ConflictListeners, true));
            };

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

                if (string.IsNullOrEmpty(DefaultDatabase))
                    return asyncServerClient;
                return asyncServerClient.ForDatabase(DefaultDatabase);
            };
        }
Ejemplo n.º 9
0
		public static HttpJsonRequest ToJsonRequest(this string url, AsyncServerClient requestor, OperationCredentials credentials, DocumentConvention convention, IDictionary<string, string> operationsHeaders, string method)
		{
			var httpJsonRequest = requestor.jsonRequestFactory.CreateHttpJsonRequest(
				new CreateHttpJsonRequestParams(requestor, url, method, credentials, convention)
					.AddOperationHeaders(operationsHeaders));
			
			return httpJsonRequest;
		}
Ejemplo n.º 10
0
		public static HttpJsonRequest ToJsonRequest(this string url, AsyncServerClient requestor, OperationCredentials credentials, Document.DocumentConvention convention)
		{
			return requestor.jsonRequestFactory.CreateHttpJsonRequest(new CreateHttpJsonRequestParams(requestor, url, "GET", credentials, convention));
		}
Ejemplo n.º 11
0
		public Operation(AsyncServerClient asyncServerClient, long id)
		{
			this.asyncServerClient = asyncServerClient;
			this.id = id;
		}
Ejemplo n.º 12
0
		public Operation(AsyncServerClient asyncServerClient, long id)
		    : this(asyncServerClient.GetOperationStatusAsync, id)
		{
		}
Ejemplo n.º 13
0
 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);
       });
 }
Ejemplo n.º 14
0
		private static async Task CheckReplicationStatusOfEachActiveDatabase(ServerRecord server, AsyncServerClient client, IAsyncDocumentSession session)
		{
			await HandleDatabaseInServerAsync(server, Constants.SystemDatabase, client, session);
			foreach (var databaseName in server.LoadedDatabases)
			{
				await HandleDatabaseInServerAsync(server, databaseName, client.ForDatabase(databaseName), session);
			}
		}
Ejemplo n.º 15
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();
		}
Ejemplo n.º 16
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);
				}
			}
		}