Create() public method

public Create ( string url, string method, RavenConnectionStringOptions connectionStringOptions ) : HttpRavenRequest
url string
method string
connectionStringOptions RavenConnectionStringOptions
return HttpRavenRequest
Esempio n. 1
0
 public void CompactUpdateMessagesShouldNotAppearInMessages(string requestedStorage)
 {
     using (var documentStore = NewRemoteDocumentStore(requestedStorage: requestedStorage, databaseName:"Test",runInMemory:false))
     {
         using (var session = documentStore.OpenSession())
         {
             session.Store(new RavenJObject());
             session.SaveChanges();
         }
         var ravenHtttpFactory = new HttpRavenRequestFactory();
         var request = ravenHtttpFactory.Create("http://localhost:8079/admin/compact?database=Test","POST",new RavenConnectionStringOptions());
         var response = request.ExecuteRequest<RavenJObject>();
         using (var systemDocumentStore = new DocumentStore() { Url = "http://localhost:8079" }.Initialize())
         {
             using (var session = systemDocumentStore.OpenSession())
             {
                 var stopeWatch = new Stopwatch();
                 stopeWatch.Start();
                 do
                 {
                     if (stopeWatch.Elapsed >= timeout) throw new TimeoutException("Waited to long for test to complete compaction.");
                     var statusRequest = ravenHtttpFactory.Create("http://localhost:8079/operation/status?id=" + response.Value<string>("OperationId"), "GET", new RavenConnectionStringOptions());
                     var status = statusRequest.ExecuteRequest<RavenJObject>();
                     if (status.Value<bool>("Completed"))
                     {
                         var compactStatus = session.Load<CompactStatus>(CompactStatus.RavenDatabaseCompactStatusDocumentKey("Test"));
                         Assert.Equal(compactStatus.Messages.Count, storageToExpectedLength[requestedStorage]);
                         return;
                     } else if (status.Value<bool>("Faulted"))
                     {
                         throw new Exception("Something went wrong, compaction was not successful");
                     }
                     Thread.Sleep(1000);
                     
                 } while (true);
             }
         }
     }
     
 }
Esempio n. 2
0
		private void ReplicateIndex(string indexName, ReplicationDestination destination, RavenJObject indexDefinition, HttpRavenRequestFactory httpRavenRequestFactory)
		{
			var connectionOptions = new RavenConnectionStringOptions
			{
				ApiKey = destination.ApiKey,
				Url = destination.Url,
				DefaultDatabase = destination.Database
			};

			if (!String.IsNullOrWhiteSpace(destination.Username) &&
				!String.IsNullOrWhiteSpace(destination.Password))
			{
				connectionOptions.Credentials = new NetworkCredential(destination.Username, destination.Password, destination.Domain ?? string.Empty);
			}

			const string urlTemplate = "{0}/databases/{1}/indexes/{2}";

			var operationUrl = string.Format(urlTemplate, destination.Url, destination.Database, Uri.EscapeUriString(indexName));
			var replicationRequest = httpRavenRequestFactory.Create(operationUrl, "PUT", connectionOptions);
			replicationRequest.Write(indexDefinition);

			replicationRequest.ExecuteRequest();
		}
Esempio n. 3
0
		private void ReplicateTransformer(string transformerName, ReplicationDestination destination, RavenJObject transformerDefinition, ConcurrentBag<string> failedDestinations, HttpRavenRequestFactory httpRavenRequestFactory)
		{
			var connectionOptions = new RavenConnectionStringOptions
			{
				ApiKey = destination.ApiKey,
				Url = destination.Url,
				DefaultDatabase = destination.Database
			};

			if (!String.IsNullOrWhiteSpace(destination.Username) &&
				!String.IsNullOrWhiteSpace(destination.Password))
			{
				connectionOptions.Credentials = new NetworkCredential(destination.Username, destination.Password, destination.Domain ?? string.Empty);
			}

			//databases/{databaseName}/transformers/{*id}
			const string urlTemplate = "{0}/databases/{1}/transformers/{2}";
			if (Uri.IsWellFormedUriString(destination.Url, UriKind.RelativeOrAbsolute) == false)
			{
				const string error = "Invalid destination URL";
				failedDestinations.Add(destination.Url);
				Log.Error(error);
				return;
			}

			var operationUrl = string.Format(urlTemplate, destination.Url, destination.Database, Uri.EscapeUriString(transformerName));
			var replicationRequest = httpRavenRequestFactory.Create(operationUrl, "PUT", connectionOptions);
			replicationRequest.Write(transformerDefinition);

			try
			{
				replicationRequest.ExecuteRequest();
			}
			catch (Exception e)
			{
				Log.ErrorException("failed to replicate index to: " + destination.Url, e);
				failedDestinations.Add(destination.Url);
			}
		}