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;
        }
Exemple #2
0
 public ManagerServerMessageProcessor(ManagerService service)
 {
     this.service = service;
 }
Exemple #3
0
        protected override void OnStop()
        {
            if (configTimer != null) {
                configTimer.Dispose();
                configTimer = null;
            }

            if (manager != null) {
                manager.Dispose();
                manager = null;
            }
            if (root != null) {
                root.Dispose();
                root = null;
            }
            if (block != null) {
                block.Dispose();
                block = null;
            }
        }
Exemple #4
0
        protected override void Dispose(bool disposing)
        {
            if (disposing) {
                if (manager != null) {
                    manager.Dispose();
                    manager = null;
                }
                if (root != null) {
                    root.Dispose();
                    root = null;
                }
                if (block != null) {
                    block.Dispose();
                    block = null;
                }
            }

            base.Dispose(disposing);
        }
Exemple #5
0
 public void StopService(ServiceType serviceType)
 {
     lock (serverManagerLock) {
         if (serviceType == ServiceType.Manager && manager != null) {
             manager.Stop();
             manager = null;
         } else if (serviceType == ServiceType.Root && root != null) {
             root.Stop();
             root = null;
         } else if (serviceType == ServiceType.Block && block != null) {
             block.Stop();
             block = null;
         }
     }
 }
Exemple #6
0
        public void StartService(ServiceType serviceType)
        {
            // Start the services,
            lock (serverManagerLock) {
                IService service = serviceFactory.CreateService(address, serviceType, connector);
                if (service == null)
                    throw new ApplicationException("Unable to create service of tyoe  " + serviceType);

                service.Start();

                if (serviceType == ServiceType.Manager)
                    manager = (ManagerService)service;
                else if (serviceType == ServiceType.Root)
                    root = (RootService)service;
                else if (serviceType == ServiceType.Block)
                    block = (BlockService) service;
            }
        }
 public BlockUpdateTask(ManagerService service)
 {
     this.service = service;
 }