Exemplo n.º 1
0
		public void RefreshReplicationInformation(ServerClient commands)
		{
			lock (replicationLock)
			{

				lastReplicationUpdate = DateTime.UtcNow;
				var document = commands.DirectGet(commands.Url, RavenReplicationDestinations);
				failureCounts[commands.Url] = new IntHolder();// we just hit the master, so we can reset its failure count
				if (document == null)
					return;
				var replicationDocument = document.DataAsJson.JsonDeserialization<ReplicationDocument>();
				replicationDestinations = replicationDocument.Destinations.Select(x => x.Url).ToList();
				foreach (var replicationDestination in replicationDestinations)
				{
					IntHolder value;
					if (failureCounts.TryGetValue(replicationDestination, out value))
						continue;
					failureCounts[replicationDestination] = new IntHolder();
				}
			}
		}
Exemplo n.º 2
0
 /// <summary>
 /// Refreshes the replication information.
 /// </summary>
 /// <param name="commands">The commands.</param>
 public void RefreshReplicationInformation(ServerClient commands)
 {
     lock (replicationLock)
     {
         lastReplicationUpdate = DateTime.UtcNow;
         var document = commands.DirectGet(commands.Url, RavenReplicationDestinations);
         failureCounts[commands.Url] = new IntHolder();                // we just hit the master, so we can reset its failure count
         if (document == null)
         {
             return;
         }
         var replicationDocument = document.DataAsJson.JsonDeserialization <ReplicationDocument>();
         replicationDestinations = replicationDocument.Destinations.Select(x => x.Url).ToList();
         foreach (var replicationDestination in replicationDestinations)
         {
             IntHolder value;
             if (failureCounts.TryGetValue(replicationDestination, out value))
             {
                 continue;
             }
             failureCounts[replicationDestination] = new IntHolder();
         }
     }
 }
Exemplo n.º 3
0
		/// <summary>
		/// Updates the replication information if needed.
		/// </summary>
		/// <param name="serverClient">The server client.</param>
		public void UpdateReplicationInformationIfNeeded(ServerClient serverClient)
		{
			if (lastReplicationUpdate.AddMinutes(5) > DateTime.UtcNow)
				return;
			RefreshReplicationInformation(serverClient);
		}
Exemplo n.º 4
0
        public IDocumentStore Initialise()
        {
            try
            {
            #if !CLIENT
                if (configuration != null)
                {
                    var embeddedDatabase = new Raven.Database.DocumentDatabase(configuration);
                    embeddedDatabase.SpinBackgroundWorkers();
                    DatabaseCommands = new EmbededDatabaseCommands(embeddedDatabase, Conventions);
                }
                else
            #endif
                {
                    DatabaseCommands = new ServerClient(Url, Conventions, credentials);
                }
                if(Conventions.DocumentKeyGenerator == null)// don't overwrite what the user is doing
                {
                    var generator = new MultiTypeHiLoKeyGenerator(DatabaseCommands, 1024);
                    Conventions.DocumentKeyGenerator = entity => generator.GenerateDocumentKey(Conventions, entity);
                }
            }
            catch (Exception)
            {
                Dispose();
                throw;
            }

            return this;
        }
Exemplo n.º 5
0
        public IDocumentStore Initialise()
        {
            try
            {
                if (String.IsNullOrEmpty(server))
                {
                    var embeddedDatabase = new DocumentDatabase(new RavenConfiguration {DataDirectory = DataDirectory});
                    embeddedDatabase.SpinBackgroundWorkers();
                    DatabaseCommands = new EmbededDatabaseCommands(embeddedDatabase);
                }
                else
                {
                    DatabaseCommands = new ServerClient(server, port);
                }
            }
            catch (Exception)
            {
                Dispose();
                throw;
            }

            return this;
        }