2013-03-07 23:23:20 +06:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
2013-02-13 06:12:43 +06:00
|
|
|
|
using Umbraco.Core.Services;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Core.Sync
|
|
|
|
|
|
{
|
2013-03-07 22:57:42 +06:00
|
|
|
|
/// <summary>
|
2015-03-04 12:16:28 +01:00
|
|
|
|
/// A registrar that stores registered server nodes in the database.
|
2013-03-07 22:57:42 +06:00
|
|
|
|
/// </summary>
|
2016-06-20 17:30:49 +02:00
|
|
|
|
public sealed class DatabaseServerRegistrar : IServerRegistrar
|
2013-03-07 22:57:42 +06:00
|
|
|
|
{
|
2015-06-22 16:22:47 +02:00
|
|
|
|
private readonly Lazy<IServerRegistrationService> _registrationService;
|
2013-02-13 06:12:43 +06:00
|
|
|
|
|
2015-03-04 12:16:28 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets or sets the registrar options.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public DatabaseServerRegistrarOptions Options { get; private set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Initializes a new instance of the <see cref="DatabaseServerRegistrar"/> class.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="registrationService">The registration service.</param>
|
|
|
|
|
|
/// <param name="options">Some options.</param>
|
2015-06-22 16:22:47 +02:00
|
|
|
|
public DatabaseServerRegistrar(Lazy<IServerRegistrationService> registrationService, DatabaseServerRegistrarOptions options)
|
2013-03-07 22:57:42 +06:00
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
|
if (registrationService == null) throw new ArgumentNullException("registrationService");
|
|
|
|
|
|
if (options == null) throw new ArgumentNullException("options");
|
|
|
|
|
|
|
|
|
|
|
|
Options = options;
|
2013-03-07 22:57:42 +06:00
|
|
|
|
_registrationService = registrationService;
|
|
|
|
|
|
}
|
2013-02-13 06:12:43 +06:00
|
|
|
|
|
2015-03-04 12:16:28 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets the registered servers.
|
|
|
|
|
|
/// </summary>
|
2013-03-07 22:57:42 +06:00
|
|
|
|
public IEnumerable<IServerAddress> Registrations
|
|
|
|
|
|
{
|
2013-03-07 23:23:20 +06:00
|
|
|
|
get { return _registrationService.Value.GetActiveServers(); }
|
2013-03-07 22:57:42 +06:00
|
|
|
|
}
|
2015-08-25 15:48:12 +02:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets the role of the current server in the application environment.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public ServerRole GetCurrentServerRole()
|
|
|
|
|
|
{
|
2015-08-27 13:22:01 +02:00
|
|
|
|
var service = _registrationService.Value;
|
2015-08-25 15:48:12 +02:00
|
|
|
|
return service.GetCurrentServerRole();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets the current umbraco application url.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public string GetCurrentServerUmbracoApplicationUrl()
|
|
|
|
|
|
{
|
|
|
|
|
|
// this registrar does not provide the umbraco application url
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2013-03-07 22:57:42 +06:00
|
|
|
|
}
|
2013-02-13 06:12:43 +06:00
|
|
|
|
}
|