public FileSystemRootService(IServiceConnector connector, IServiceAddress address, string path) : base(connector, address) { this.path = path; pathInitializationQueue = new List<string>(64); }
/// <inheritdoc cref="IMessageToServiceMapper.AddService(Guid, string, INetworkConnector)"/> public void AddService(Guid id, string name, INetworkConnector networkConnector) { if (!ServiceTypeCache.ContainsKey(name)) { _logger.LogError("Service is not added because it has no message types associated with it. "); return; } Type type = ServiceTypeCache[name][0]; if (_messageToServiceMap.ContainsKey(type)) { IServiceConnector serviceConnector = _messageToServiceMap[type]; _serviceMap.TryAdd(id, serviceConnector); serviceConnector.AddService(networkConnector, id); } else { IServiceConnector serviceConnector = new ServiceConnector(networkConnector, name, id); _serviceMap.TryAdd(id, serviceConnector); foreach (Type messageType in ServiceTypeCache[name]) { _messageToServiceMap.TryAdd(messageType, serviceConnector); } _ = Task.Run(() => serviceConnector.StartPublishingAsync(_cancellationTokenSource.Token), _cancellationTokenSource.Token); } }
/// <summary> /// Initializes a new instance of the <see cref="ArtifactDeployState{TArtifact,TEntity}"/> class. /// </summary> /// <param name="art">The artifact.</param> /// <param name="entity">The entity.</param> /// <param name="connector">The service connector deploying the artifact.</param> /// <param name="nextPass">The next pass number.</param> public ArtifactDeployState(TArtifact art, TEntity entity, IServiceConnector connector, int nextPass) { Artifact = art; Entity = entity; Connector = connector; NextPass = nextPass; }
public FileSystemBlockService(IServiceConnector connector, string path) : base(connector) { this.path = path; compressionThread = new Thread(Compress); compressionThread.IsBackground = true; }
public void SetUp() { SetupEvent.WaitOne(); adminService = CreateAdminService(storeType); IServiceConnector connector = CreateConnector(); NetworkConfigSource config = new NetworkConfigSource(); Config(config); adminService.Config = config; adminService.Connector = connector; adminService.Start(); networkProfile = new NetworkProfile(connector); NetworkConfigSource netConfig = new NetworkConfigSource(); netConfig.AddNetworkNode(LocalAddress); networkProfile.Configuration = netConfig; OnSetUp(); SetupEvent.Set(); }
public FileSystemManagerService(IServiceConnector connector, string basePath, string dbPath, IServiceAddress address) : base(connector, address) { this.basePath = basePath; this.dbPath = dbPath; }
internal MessageCommunicator(IServiceConnector network, ServiceStatusTracker tracker) { this.network = network; this.tracker = tracker; queueMap = new Dictionary<IServiceAddress, RetryMessageQueue>(); }
internal MessageCommunicator(IServiceConnector network, ServiceStatusTracker tracker) { this.network = network; this.tracker = tracker; queueMap = new Dictionary <IServiceAddress, RetryMessageQueue>(); }
public FileSystemRootService(IServiceConnector connector, IServiceAddress address, string path) : base(connector, address) { this.path = path; pathInitializationQueue = new List <string>(64); }
public static ServiceStatusTracker GetServiceTracker(IServiceAddress[] managers, IServiceConnector connector) { lock (TrackerCacheMap) { ServiceStatusTracker picked = null; int pickedCount = 0; for (int i = 0; i < managers.Length; ++i) { ServiceStatusTracker g; if (TrackerCacheMap.TryGetValue(managers[i], out g)) { picked = g; ++pickedCount; } } if (picked == null) { picked = new ServiceStatusTracker(connector); for (int i = 0; i < managers.Length; ++i) { TrackerCacheMap[managers[i]] = picked; } } else if (pickedCount != managers.Length) { for (int i = 0; i < managers.Length; ++i) { TrackerCacheMap[managers[i]] = picked; } } return picked; } }
public NetworkClient(IServiceAddress[] managerAddresses, IServiceConnector connector, INetworkCache lnc) { this.connector = connector; this.managerAddresses = managerAddresses; this.localNetworkCache = lnc; // Default values, MaxTransactionNodeCacheHeapSize = 14 * 1024 * 1024; }
public NetworkClient(IServiceAddress[] managerAddresses, IServiceConnector connector, INetworkCache lnc) { this.connector = connector; this.managerAddresses = managerAddresses; this.localNetworkCache = lnc; // Default values, MaxTransactionNodeCacheHeapSize = 14*1024*1024; }
/// <summary> /// Adds the service connector. /// </summary> /// <param name="serviceID">The service identifier.</param> /// <param name="connector">The connector.</param> public void AddServiceConnector(Guid serviceID, IServiceConnector connector) { if (lstConnectors.ContainsKey(serviceID)) { throw new InvalidOperationException("This service ID is already in use."); } lstConnectors.Add(serviceID, connector); }
public static IServiceConnector GetConnector() { if (_serviceConnector == null) { _serviceConnector = new QuoridorService(); } return(_serviceConnector); }
public NetworkClient(IServiceAddress managerAddress, IServiceConnector connector, INetworkCache cache) { if (!(connector.MessageSerializer is IRpcMessageSerializer) || !((IRpcMessageSerializer)connector.MessageSerializer).SupportsMessageStream) throw new ArgumentException("The connector given has an invalid message serializer for this context (must be a IRPC serializer)."); this.connector = connector; this.managerAddress = managerAddress; this.cache = cache; }
public AdminService(IServiceAddress address, IServiceConnector connector, IServiceFactory serviceFactory) { if (serviceFactory == null) throw new ArgumentNullException("serviceFactory"); this.serviceFactory = serviceFactory; this.address = address; this.connector = connector; analytics = new Analytics(); }
public NetworkTreeSystem(IServiceConnector connector, IServiceAddress[] managerAddresses, INetworkCache networkCache, ServiceStatusTracker serviceTracker) { this.connector = connector; this.managerAddresses = managerAddresses; this.networkCache = networkCache; this.serviceTracker = serviceTracker; failureFloodControl = new Dictionary<IServiceAddress, DateTime>(); failureFloodControlBidc = new Dictionary<IServiceAddress, DateTime>(); }
protected BlockService(IServiceConnector connector) { this.connector = connector; blockContainerMap = new Dictionary <BlockId, BlockContainer>(); blockContainerAccessList = new LinkedList <BlockContainer>(); maxKnownBlockId = new Dictionary <int, BlockId>(); blocksPendingSync = new LinkedList <BlockContainer>(); }
public IService CreateService(IServiceAddress serviceAddress, ServiceType serviceType, IServiceConnector connector) { if (serviceType == ServiceType.Manager) return new MemoryManagerService(connector, serviceAddress); if (serviceType == ServiceType.Root) return new MemoryRootService(connector); if (serviceType == ServiceType.Block) return new MemoryBlockService(connector); throw new ArgumentException("An invalid service type was specified."); }
public AdminService(IServiceAddress address, IServiceConnector connector, IServiceFactory serviceFactory) { if (serviceFactory == null) { throw new ArgumentNullException("serviceFactory"); } this.serviceFactory = serviceFactory; this.address = address; this.connector = connector; analytics = new Analytics(); }
protected RootService(IServiceConnector connector, IServiceAddress address) { this.connector = connector; this.address = address; lockDb = new Dictionary<string, PathAccess>(128); pathInfoMap = new Dictionary<string, PathInfo>(128); loadPathInfoQueue = new List<PathInfo>(64); serviceTracker = new ServiceStatusTracker(connector); serviceTracker.StatusChange += ServiceTracker_OnStatusChange; }
public HeartbeatThread(ServiceStatusTracker tracker, IServiceConnector connector, List <TrackedService> monitoredServers) { this.tracker = tracker; this.connector = connector; this.monitoredServers = monitoredServers; thread = new Thread(Execute); thread.IsBackground = true; thread.Name = "StatusTracker::Heatbeat"; thread.Start(); }
internal NetworkTreeSystem(IServiceConnector connector, IServiceAddress managerAddress, INetworkCache networkCache) { if (!(connector.MessageSerializer is IRpcMessageSerializer) || !((IRpcMessageSerializer)connector.MessageSerializer).SupportsMessageStream) throw new ArgumentException("The message serializer specified by the connector is not valid (must be IRPC)."); this.connector = connector; this.managerAddress = managerAddress; this.networkCache = networkCache; failures = new Dictionary<IServiceAddress, DateTime>(); pathToRoot = new Dictionary<string, IServiceAddress>(); logger = Logger.Network; }
public void ServiceConnectorSendMessageTest() { // arrange IServiceConnector serviceConnector = ServiceConnector.GetInstance(); serviceConnector.SetAddress("http://localhost:5000/"); serviceConnector.TrySetUsername("testUser", out var testUser); // act var result = serviceConnector.SendMessage(_adminUserId, "Hallo test"); // assert Assert.IsNotNull(result); }
public void ServiceConnectorDeviceGetValueTest() { // arrange IServiceConnector serviceConnector = ServiceConnector.GetInstance(); serviceConnector.SetAddress("http://localhost:5000/"); // it must a non exist device const long id = 12345678L; // act var result = serviceConnector.DeviceGetValue(id); // assert Assert.AreEqual(0, result); }
public void ServiceConnectorGetAllUsersTest() { // arrange IServiceConnector serviceConnector = ServiceConnector.GetInstance(); serviceConnector.SetAddress("http://localhost:5000/"); // act var result = serviceConnector.GetAllUsers(); // assert Assert.IsNotNull(result); Assert.IsTrue(result.Any()); }
protected PathClientService(IServiceAddress address, IServiceAddress managerAddress, IServiceConnector connector) { this.address = address; this.managerAddress = managerAddress; this.connector = connector; NetworkConfigSource netConfig = new NetworkConfigSource(); netConfig.AddNetworkNode(managerAddress); network = new NetworkProfile(connector); network.Configuration = netConfig; log = Logger.Network; }
protected ManagerService(IServiceConnector connector, IServiceAddress address) { this.connector = connector; this.address = address; blockServersMap = new Dictionary<long, BlockServiceInfo>(); blockServersList = new List<BlockServiceInfo>(); rootServersList = new List<RootServiceInfo>(); managerServersList = new List<ManagerServiceInfo>(); rng = new Random(); serviceTracker = new ServiceStatusTracker(connector); blockUpdateTask = new BlockUpdateTask(this); }
public void ServiceConnectorGetMessagesTest() { // arrange IServiceConnector serviceConnector = ServiceConnector.GetInstance(); serviceConnector.SetAddress("http://localhost:5000/"); serviceConnector.TrySetUsername("testUser", out var testUser); // act var result = serviceConnector.GetMessages(_adminUserId); // assert Assert.IsNotNull(result); Assert.IsTrue(result.Any()); Assert.AreEqual("Hallo ich bin der Admin Benutzer", result.First().Text); }
public void ServiceConnectorSetUserAndGetAllUsersTest() { // arrange IServiceConnector serviceConnector = ServiceConnector.GetInstance(); serviceConnector.SetAddress("http://localhost:5000/"); serviceConnector.TrySetUsername("testUser", out var testUser); // act var result = serviceConnector.GetAllUsers(); // assert Assert.IsNotNull(result); // only admin, well it show only other not self user Assert.AreEqual(1, result.Length); }
protected ManagerService(IServiceConnector connector, IServiceAddress address) { this.connector = connector; this.address = address; blockServersMap = new Dictionary<long, BlockServerInfo>(256); blockServers = new List<BlockServerInfo>(256); rootServers = new List<RootServerInfo>(256); random = new Random(); failureFloodControl = new Dictionary<IServiceAddress, DateTime>(); heartbeatThread = new Thread(Heartbeat); heartbeatThread.IsBackground = true; heartbeatThread.Start(); }
public GamePage(string launchArguments) { this.InitializeComponent(); _messages = new ObservableCollection <PlayerMessage>(); //_messages.Add(new PlayerMessage() { Message = "Testowa wiadomosc"}); _players = new ObservableCollection <Player>(); //_players.Add(new Player() {Id = 1, Name = "Uzytkownik"}); PlayersListView.ItemsSource = _players; MessagesListView.ItemsSource = _messages; // Create the game. _game = XamlGame <Game1> .Create(launchArguments, Window.Current.CoreWindow, this); _game.GamePage = this; _serviceConnector = SharedModel.GetConnector(); }
public void ServiceConnectorTrySetUsernameTest() { // arrange IServiceConnector serviceConnector = ServiceConnector.GetInstance(); serviceConnector.SetAddress("http://localhost:5000/"); const string username = "******"; // act var success = serviceConnector.TrySetUsername(username, out var result); // assert Assert.IsTrue(success); Assert.IsNotNull(result); Assert.AreEqual(username, result.Username); Assert.AreNotEqual(0, result.ID); }
public void ServiceConnectorSendMessageAndGetMessageTest() { // arrange IServiceConnector serviceConnector = ServiceConnector.GetInstance(); serviceConnector.SetAddress("http://localhost:5000/"); serviceConnector.TrySetUsername("testUser", out _); // act serviceConnector.SendMessage(_adminUserId, "Hallo test"); var result = serviceConnector.GetMessages(_adminUserId); // assert Assert.IsNotNull(result); Assert.IsTrue(result.Any()); Assert.AreEqual("Hallo test", result.Last().Text); }
public void ServiceConnectorDeviceSendComandValueTest() { // arrange IServiceConnector serviceConnector = ServiceConnector.GetInstance(); serviceConnector.SetAddress("http://localhost:5000/"); serviceConnector.DeviceGetValue(1L); const long value = 234L; // act var result = serviceConnector.DeviceSendCommand(1L, 234); var resultValue = serviceConnector.DeviceGetValue(1L); // assert Assert.IsTrue(result); Assert.AreEqual(value, resultValue); }
public void ServiceConnectorDeviceSendComandTextTest() { // arrange IServiceConnector serviceConnector = ServiceConnector.GetInstance(); serviceConnector.SetAddress("http://localhost:5000/"); serviceConnector.DeviceGetText(1L); string sendText = "Hello"; // act var result = serviceConnector.DeviceSendCommand(1L, sendText); var resultText = serviceConnector.DeviceGetText(1L); // assert Assert.IsTrue(result); Assert.AreEqual(sendText, resultText); }
internal ReplicatedValueStore(IServiceAddress address, IServiceConnector connector, IDatabase localDb, Object dbWriteLock, ServiceStatusTracker tracker) { this.address = address; this.connector = connector; blockDatabase = localDb; blockDbWriteLock = dbWriteLock; this.tracker = tracker; comm = new MessageCommunicator(connector, tracker); cluster = new List<IServiceAddress>(9); ClearAllMachines(); // Add listener for service status updates, tracker.StatusChange += TrackerOnStatusChange; }
public void Disconnect() { if (connector != null) { try { connector.Close(); } finally { try { serviceTracker.Stop(); } finally { connector = null; serviceTracker = null; treeSystem = null; } connected = false; } } }
private Service DoCreateService(IServiceAddress serviceAddress, ServiceType serviceType, IServiceConnector connector) { Service service = null; if (serviceType == ServiceType.Manager) { if (manager == null) { string npath = Path.Combine(basePath, "manager"); if (!Directory.Exists(npath)) Directory.CreateDirectory(npath); manager = new FileSystemManagerService(connector, basePath, npath, serviceAddress); } service = manager; } else if (serviceType == ServiceType.Root) { if (root == null) { string npath = Path.Combine(basePath, "root"); if (!Directory.Exists(npath)) Directory.CreateDirectory(npath); root = new FileSystemRootService(connector, serviceAddress, npath); } service = root; } else if (serviceType == ServiceType.Block) { if (block == null) { string npath = Path.Combine(basePath, "block"); if (!Directory.Exists(npath)) Directory.CreateDirectory(npath); block = new FileSystemBlockService(connector, npath); } service = block; } if (service != null) { service.Started += ServiceStarted; service.Stopped += ServiceStopped; } return service; }
public void ServiceConnectorDeviceSendComandGetResponseTest() { // arrange IServiceConnector serviceConnector = ServiceConnector.GetInstance(); serviceConnector.SetAddress("http://localhost:5000/"); serviceConnector.DeviceGet(1L); const long id = 1L; const long value = 456L; string sendText = "Hello"; // act var result = serviceConnector.DeviceSendCommand(id, value, sendText); var resultResponse = serviceConnector.DeviceGet(id); // assert Assert.IsTrue(result); Assert.AreEqual(sendText, resultResponse.Text); Assert.AreEqual(value, resultResponse.Value); }
public MemoryBlockService(IServiceConnector connector) : base(connector) { blockData = new Dictionary<BlockId, Stream>(); }
protected RootService(IServiceConnector connector) { this.connector = connector; pathCache = new Dictionary<string, PathAccess>(128); }
public PathConnection(RootService service, string pathName, IServiceConnector connector, IServiceAddress manager, INetworkCache networkCache) { this.service = service; this.pathName = pathName; treeSystem = new NetworkTreeSystem(connector, manager, networkCache); }
public RestPathClientService(HttpServiceAddress address, IServiceAddress managerAddress, IServiceConnector connector) : base(address, managerAddress, connector) { }
public MemoryRootService(IServiceConnector connector, IServiceAddress address) : base(connector, address) { pathStreams = new Dictionary<string, Stream>(); }
public FileSystemBlockService(IServiceConnector connector, string path) : base(connector) { this.path = path; }
public static int Main(string[] args) { m_Server = new HttpServerBase("R.O.B.U.S.T.", args); IConfig serverConfig = m_Server.Config.Configs["Startup"]; if (serverConfig == null) { System.Console.WriteLine("Startup config section missing in .ini file"); throw new Exception("Configuration error"); } string connList = serverConfig.GetString("ServiceConnectors", String.Empty); string[] conns = connList.Split(new char[] { ',', ' ' }); // int i = 0; foreach (string c in conns) { if (c == String.Empty) { continue; } string configName = String.Empty; string conn = c; uint port = 0; string[] split1 = conn.Split(new char[] { '/' }); if (split1.Length > 1) { conn = split1[1]; string[] split2 = split1[0].Split(new char[] { '@' }); if (split2.Length > 1) { configName = split2[0]; port = Convert.ToUInt32(split2[1]); } else { port = Convert.ToUInt32(split1[0]); } } string[] parts = conn.Split(new char[] { ':' }); string friendlyName = parts[0]; if (parts.Length > 1) { friendlyName = parts[1]; } IHttpServer server = m_Server.HttpServer; if (port != 0) { server = m_Server.GetHttpServer(port); } if (port != m_Server.DefaultPort && port != 0) { m_log.InfoFormat("[SERVER]: Loading {0} on port {1}", friendlyName, port); } else { m_log.InfoFormat("[SERVER]: Loading {0}", friendlyName); } IServiceConnector connector = null; Object[] modargs = new Object[] { m_Server.Config, server, configName }; connector = ServerUtils.LoadPlugin <IServiceConnector>(conn, modargs); if (connector == null) { modargs = new Object[] { m_Server.Config, server }; connector = ServerUtils.LoadPlugin <IServiceConnector>(conn, modargs); } if (connector != null) { m_ServiceConnectors.Add(connector); m_log.InfoFormat("[SERVER]: {0} loaded successfully", friendlyName); } else { m_log.InfoFormat("[SERVER]: Failed to load {0}", conn); } } int res = m_Server.Run(); Environment.Exit(res); return(0); }
public MemoryBlockService(IServiceConnector connector) : base(connector) { blockData = new Dictionary <BlockId, Stream>(); }
public HeartbeatThread(ServiceStatusTracker tracker, IServiceConnector connector, List<TrackedService> monitoredServers) { this.tracker = tracker; this.connector = connector; this.monitoredServers = monitoredServers; thread = new Thread(Execute); thread.IsBackground = true; thread.Name = "StatusTracker::Heatbeat"; thread.Start(); }
public PathConnection(RootService service, PathInfo pathInfo, IServiceConnector connector, IServiceAddress[] managerServers, INetworkCache cache, ServiceStatusTracker statusTracker) { this.service = service; this.pathInfo = pathInfo; treeSystem = new NetworkTreeSystem(connector, managerServers, cache, statusTracker); }
public IService CreateService(IServiceAddress serviceAddress, ServiceType serviceType, IServiceConnector connector) { return factory.CreateService(serviceAddress, serviceType, connector); }
public NetworkClient(IServiceAddress managerAddress, IServiceConnector connector) : this(new IServiceAddress[] { managerAddress}, connector) { }
public NetworkClient(IServiceAddress[] managerAddresses, IServiceConnector connector) : this(managerAddresses, connector, MachineState.GetCacheForManager(managerAddresses)) { }
public static int Main(string[] args) { Culture.SetCurrentCulture(); Culture.SetDefaultCurrentCulture(); ServicePointManager.DefaultConnectionLimit = 64; ServicePointManager.Expect100Continue = false; ServicePointManager.UseNagleAlgorithm = false; ServicePointManager.ServerCertificateValidationCallback = ValidateServerCertificate; m_Server = new HttpServerBase("R.O.B.U.S.T.", args); string registryLocation; IConfig serverConfig = m_Server.Config.Configs["Startup"]; if (serverConfig == null) { System.Console.WriteLine("Startup config section missing in .ini file"); throw new Exception("Configuration error"); } int dnsTimeout = serverConfig.GetInt("DnsTimeout", 30000); try { ServicePointManager.DnsRefreshTimeout = dnsTimeout; } catch { } m_NoVerifyCertChain = serverConfig.GetBoolean("NoVerifyCertChain", m_NoVerifyCertChain); m_NoVerifyCertHostname = serverConfig.GetBoolean("NoVerifyCertHostname", m_NoVerifyCertHostname); string connList = serverConfig.GetString("ServiceConnectors", String.Empty); registryLocation = serverConfig.GetString("RegistryLocation", "."); IConfig servicesConfig = m_Server.Config.Configs["ServiceList"]; if (servicesConfig != null) { List <string> servicesList = new List <string>(); if (connList != String.Empty) { servicesList.Add(connList); } foreach (string k in servicesConfig.GetKeys()) { string v = servicesConfig.GetString(k); if (v != String.Empty) { servicesList.Add(v); } } connList = String.Join(",", servicesList.ToArray()); } string[] conns = connList.Split(new char[] { ',', ' ', '\n', '\r', '\t' }); // int i = 0; foreach (string c in conns) { if (c == String.Empty) { continue; } string configName = String.Empty; string conn = c; uint port = 0; string[] split1 = conn.Split(new char[] { '/' }); if (split1.Length > 1) { conn = split1[1]; string[] split2 = split1[0].Split(new char[] { '@' }); if (split2.Length > 1) { configName = split2[0]; port = Convert.ToUInt32(split2[1]); } else { port = Convert.ToUInt32(split1[0]); } } string[] parts = conn.Split(new char[] { ':' }); string friendlyName = parts[0]; if (parts.Length > 1) { friendlyName = parts[1]; } IHttpServer server; if (port != 0) { server = MainServer.GetHttpServer(port); } else { server = MainServer.Instance; } m_log.InfoFormat("[SERVER]: Loading {0} on port {1}", friendlyName, server.Port); IServiceConnector connector = null; Object[] modargs = new Object[] { m_Server.Config, server, configName }; connector = ServerUtils.LoadPlugin <IServiceConnector>(conn, modargs); if (connector == null) { modargs = new Object[] { m_Server.Config, server }; connector = ServerUtils.LoadPlugin <IServiceConnector>(conn, modargs); } if (connector != null) { m_ServiceConnectors.Add(connector); m_log.InfoFormat("[SERVER]: {0} loaded successfully", friendlyName); } else { m_log.ErrorFormat("[SERVER]: Failed to load {0}", conn); } } loader = new PluginLoader(m_Server.Config, registryLocation); int res = m_Server.Run(); if (m_Server != null) { m_Server.Shutdown(); } Util.StopThreadPool(); Environment.Exit(res); return(0); }
public ServiceStatusTracker(IServiceConnector connector) { monitoredServers = new List<TrackedService>(128); heartbeatThread = new HeartbeatThread(this, connector, monitoredServers); }
public IService CreateService(IServiceAddress serviceAddress, ServiceType serviceType, IServiceConnector connector) { return(DoCreateService(serviceAddress, serviceType, connector)); }
public static int Main(string[] args) { // Make sure we don't get outbound connections queueing ServicePointManager.DefaultConnectionLimit = 50; ServicePointManager.UseNagleAlgorithm = false; m_Server = new HttpServerBase("R.O.B.U.S.T.", args); string registryLocation; IConfig serverConfig = m_Server.Config.Configs["Startup"]; if (serverConfig == null) { System.Console.WriteLine("Startup config section missing in .ini file"); throw new Exception("Configuration error"); } string connList = serverConfig.GetString("ServiceConnectors", String.Empty); registryLocation = serverConfig.GetString("RegistryLocation", "."); IConfig servicesConfig = m_Server.Config.Configs["ServiceList"]; if (servicesConfig != null) { List <string> servicesList = new List <string>(); if (connList != String.Empty) { servicesList.Add(connList); } foreach (string k in servicesConfig.GetKeys()) { string v = servicesConfig.GetString(k); if (v != String.Empty) { servicesList.Add(v); } } connList = String.Join(",", servicesList.ToArray()); } string[] conns = connList.Split(new char[] { ',', ' ', '\n', '\r', '\t' }); // int i = 0; foreach (string c in conns) { if (c == String.Empty) { continue; } string configName = String.Empty; string conn = c; uint port = 0; string[] split1 = conn.Split(new char[] { '/' }); if (split1.Length > 1) { conn = split1[1]; string[] split2 = split1[0].Split(new char[] { '@' }); if (split2.Length > 1) { configName = split2[0]; port = Convert.ToUInt32(split2[1]); } else { port = Convert.ToUInt32(split1[0]); } } string[] parts = conn.Split(new char[] { ':' }); string friendlyName = parts[0]; if (parts.Length > 1) { friendlyName = parts[1]; } IHttpServer server; if (port != 0) { server = MainServer.GetHttpServer(port); } else { server = MainServer.Instance; } m_log.InfoFormat("[SERVER]: Loading {0} on port {1}", friendlyName, server.Port); IServiceConnector connector = null; Object[] modargs = new Object[] { m_Server.Config, server, configName }; connector = ServerUtils.LoadPlugin <IServiceConnector>(conn, modargs); if (connector == null) { modargs = new Object[] { m_Server.Config, server }; connector = ServerUtils.LoadPlugin <IServiceConnector>(conn, modargs); } if (connector != null) { m_ServiceConnectors.Add(connector); m_log.InfoFormat("[SERVER]: {0} loaded successfully", friendlyName); } else { m_log.ErrorFormat("[SERVER]: Failed to load {0}", conn); } } loader = new PluginLoader(m_Server.Config, registryLocation); int res = m_Server.Run(); Environment.Exit(res); return(0); }
private Service DoCreateService(IServiceAddress serviceAddress, ServiceType serviceType, IServiceConnector connector) { Service service = null; if (serviceType == ServiceType.Manager) { if (manager == null) { string npath = Path.Combine(basePath, "manager"); if (!Directory.Exists(npath)) { Directory.CreateDirectory(npath); } manager = new FileSystemManagerService(connector, basePath, npath, serviceAddress); } service = manager; } else if (serviceType == ServiceType.Root) { if (root == null) { string npath = Path.Combine(basePath, "root"); if (!Directory.Exists(npath)) { Directory.CreateDirectory(npath); } root = new FileSystemRootService(connector, serviceAddress, npath); } service = root; } else if (serviceType == ServiceType.Block) { if (block == null) { string npath = Path.Combine(basePath, "block"); if (!Directory.Exists(npath)) { Directory.CreateDirectory(npath); } block = new FileSystemBlockService(connector, npath); } service = block; } if (service != null) { service.Started += ServiceStarted; service.Stopped += ServiceStopped; } return(service); }