Beispiel #1
0
        public override void Shutdown()
        {
            log.Info("()");

            ShutdownSignaling.SignalShutdown();

            List <IncomingClient> clients = clientList.GetNetworkClientList();

            try
            {
                log.Info("Closing {0} existing client connections of role servers.", clients.Count);
                foreach (IncomingClient client in clients)
                {
                    client.CloseConnection();
                }
            }
            catch
            {
            }

            foreach (TcpRoleServer server in tcpServers.Values)
            {
                if (server.IsRunning)
                {
                    server.Stop();
                }
            }
            tcpServers.Clear();

            log.Info("(-)");
        }
        public override bool Init()
        {
            log.Info("()");

            bool res = false;

            try
            {
                imageManager = this;

                Configuration.Default.AddImageFormat(new JpegFormat());
                Configuration.Default.AddImageFormat(new PngFormat());

                if (InitializeReferenceCounter() &&
                    DeleteUnusedImages())
                {
                    RegisterCronJobs();

                    res         = true;
                    Initialized = true;
                }
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }

            if (!res)
            {
                ShutdownSignaling.SignalShutdown();
            }

            log.Info("(-):{0}", res);
            return(res);
        }
Beispiel #3
0
        public override bool Init()
        {
            log.Info("()");

            bool res = false;

            try
            {
                if (base.Init())
                {
                    relayList = new RelayList();

                    RegisterCronJobs();

                    res         = true;
                    Initialized = true;
                }
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }

            if (!res)
            {
                ShutdownSignaling.SignalShutdown();
            }

            log.Info("(-):{0}", res);
            return(res);
        }
        public override bool Init()
        {
            log.Info("()");

            bool res = false;

            try
            {
                if (DeleteUninitializedNeighbors() &&
                    DeleteUninitializedFollowers() &&
                    DeleteInvalidNeighborIdentities() &&
                    DeleteInvalidNeighborhoodActions())
                {
                    res         = true;
                    Initialized = true;
                }
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }

            if (!res)
            {
                ShutdownSignaling.SignalShutdown();
            }

            log.Info("(-):{0}", res);
            return(res);
        }
Beispiel #5
0
        public override bool Init()
        {
            log.Info("()");

            bool res = false;

            try
            {
                apiUrl = string.Format("http://{0}:{1}/api/v0/", Base.Configuration.CanEndPoint.Address, Base.Configuration.CanEndPoint.Port);

                res         = true;
                Initialized = true;
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }

            if (!res)
            {
                ShutdownSignaling.SignalShutdown();
            }

            log.Info("(-):{0}", res);
            return(res);
        }
        public override bool Init()
        {
            log.Info("()");

            bool res = false;

            try
            {
                delayedStartupThread = new Thread(new ThreadStart(DelayedStartupThread));
                delayedStartupThread.Start();

                res         = true;
                Initialized = true;
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }

            if (!res)
            {
                ShutdownSignaling.SignalShutdown();

                if ((delayedStartupThread != null) && !delayedStartupThreadFinished.WaitOne(10000))
                {
                    log.Error("Delayed startup thread did not terminated in 10 seconds.");
                }
            }

            log.Info("(-):{0}", res);
            return(res);
        }
Beispiel #7
0
        public override void Shutdown()
        {
            log.Info("()");

            ShutdownSignaling.SignalShutdown();

            log.Info("(-)");
        }
        public override void Shutdown()
        {
            log.Info("()");

            ShutdownSignaling.SignalShutdown();

            if ((initThread != null) && !initThreadFinished.WaitOne(25000))
            {
                log.Error("Init thread did not terminate in 25 seconds.");
            }

            log.Info("(-)");
        }
Beispiel #9
0
        public override bool Init()
        {
            log.Info("()");

            bool res = false;

            try
            {
                foreach (CronJob job in jobDefinitions)
                {
                    job.Timer = new Timer(SignalTimerCallback, job.Event, job.StartDelay, job.Interval);
                    jobs.Add(job.Name, job);
                }

                executiveThread = new Thread(new ThreadStart(ExecutiveThread));
                executiveThread.Start();

                res         = true;
                Initialized = true;
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }

            if (!res)
            {
                ShutdownSignaling.SignalShutdown();

                foreach (CronJob job in jobs.Values)
                {
                    if (job.Timer != null)
                    {
                        job.Timer.Dispose();
                    }
                    job.Timer = null;
                }

                if ((executiveThread != null) && !executiveThreadFinished.WaitOne(10000))
                {
                    log.Error("Executive thread did not terminated in 10 seconds.");
                }
            }

            log.Info("(-):{0}", res);
            return(res);
        }
        public override bool Init()
        {
            log.Info("()");

            bool res = false;

            try
            {
                canIpnsLastSequenceNumber = Config.Configuration.CanIpnsLastSequenceNumber;
                api = new CanApi(Config.Configuration.CanEndPoint, ShutdownSignaling);

                // Construct profile server's contact information CAN object.
                canContactInformation = new CanProfileServerContact()
                {
                    PublicKey   = ProtocolHelper.ByteArrayToByteString(Config.Configuration.Keys.PublicKey),
                    IpAddress   = ProtocolHelper.ByteArrayToByteString(Config.Configuration.ExternalServerAddress.GetAddressBytes()),
                    PrimaryPort = (uint)Config.Configuration.ServerRoles.GetRolePort((uint)ServerRole.Primary)
                };


                initThread = new Thread(new ThreadStart(InitThread));
                initThread.Start();

                RegisterCronJobs();

                res         = true;
                Initialized = true;
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }

            if (!res)
            {
                ShutdownSignaling.SignalShutdown();

                if ((initThread != null) && !initThreadFinished.WaitOne(25000))
                {
                    log.Error("Init thread did not terminated in 25 seconds.");
                }
            }

            log.Info("(-):{0}", res);
            return(res);
        }
        public override void Shutdown()
        {
            log.Info("()");

            ShutdownSignaling.SignalShutdown();

            if (client != null)
            {
                client.Dispose();
            }

            if ((locConnectionThread != null) && !locConnectionThreadFinished.WaitOne(10000))
            {
                log.Error("LOC connection thread did not terminated in 10 seconds.");
            }

            log.Info("(-)");
        }
Beispiel #12
0
        public override bool Init()
        {
            log.Info("()");

            bool res = false;

            try
            {
                canApi = (CanApi)Base.ComponentDictionary["Network.ContentAddressNetwork.CanApi"];

                // Construct profile server's contact information CAN object.
                canContactInformation = new CanProfileServerContact()
                {
                    PublicKey   = ProtocolHelper.ByteArrayToByteString(Base.Configuration.Keys.PublicKey),
                    IpAddress   = ProtocolHelper.ByteArrayToByteString(Base.Configuration.ServerInterface.GetAddressBytes()),
                    PrimaryPort = (uint)Base.Configuration.ServerRoles.GetRolePort(ServerRole.Primary)
                };


                initThread = new Thread(new ThreadStart(InitThread));
                initThread.Start();

                res         = true;
                Initialized = true;
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }

            if (!res)
            {
                ShutdownSignaling.SignalShutdown();

                if ((initThread != null) && !initThreadFinished.WaitOne(25000))
                {
                    log.Error("Init thread did not terminated in 25 seconds.");
                }
            }

            log.Info("(-):{0}", res);
            return(res);
        }
Beispiel #13
0
        public override void Shutdown()
        {
            log.Info("()");

            ShutdownSignaling.SignalShutdown();

            if (checkInactiveClientConnectionsTimer != null)
            {
                checkInactiveClientConnectionsTimer.Dispose();
            }
            checkInactiveClientConnectionsTimer = null;

            if ((serversMaintenanceThread != null) && !serversMaintenanceThreadFinished.WaitOne(10000))
            {
                log.Error("Servers maintenance thread did not terminated in 10 seconds.");
            }

            List <Client> clients = clientList.GetNetworkClientList();

            try
            {
                log.Info("Closing {0} existing client connections of role servers.", clients.Count);
                foreach (Client client in clients)
                {
                    client.CloseConnection().Wait();
                }
            }
            catch
            {
            }

            foreach (TcpRoleServer server in tcpServers.Values)
            {
                if (server.IsRunning)
                {
                    server.Stop();
                }
            }
            tcpServers.Clear();

            log.Info("(-)");
        }
Beispiel #14
0
        public override void Shutdown()
        {
            log.Info("()");

            ShutdownSignaling.SignalShutdown();

            lock (jobsLock)
            {
                foreach (CronJob job in jobs.Values)
                {
                    job.Dispose();
                }
            }

            if ((executiveThread != null) && !executiveThreadFinished.WaitOne(10000))
            {
                log.Error("Executive thread did not terminated in 10 seconds.");
            }

            log.Info("(-)");
        }
Beispiel #15
0
        public override bool Init()
        {
            log.Info("()");

            bool res = false;

            try
            {
                client = new LocClient(Config.Configuration.LocEndPoint, new LocMessageProcessor(), ShutdownSignaling);

                this.Location = Config.Configuration.LocLocation;

                locConnectionThread = new Thread(new ThreadStart(LocConnectionThread));
                locConnectionThread.Start();

                RegisterCronJobs();

                res         = true;
                Initialized = true;
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }

            if (!res)
            {
                ShutdownSignaling.SignalShutdown();

                if ((locConnectionThread != null) && !locConnectionThreadFinished.WaitOne(10000))
                {
                    log.Error("LOC connection thread did not terminated in 10 seconds.");
                }
            }

            log.Info("(-):{0}", res);
            return(res);
        }
Beispiel #16
0
        public override bool Init()
        {
            log.Info("()");

            bool res   = false;
            bool error = false;

            try
            {
                clientList = new ClientList();

                checkInactiveClientConnectionsTimer = new Timer(CheckInactiveClientConnectionsTimerCallback, null, CheckInactiveClientConnectionsTimerInterval, CheckInactiveClientConnectionsTimerInterval);

                serversMaintenanceThread = new Thread(new ThreadStart(ServersMaintenanceThread));
                serversMaintenanceThread.Start();

                foreach (RoleServerConfiguration roleServer in Base.Configuration.ServerRoles.RoleServers.Values)
                {
                    if (roleServer.IsTcpServer)
                    {
                        IPEndPoint    endPoint = new IPEndPoint(Base.Configuration.ServerInterface, roleServer.Port);
                        TcpRoleServer server   = new TcpRoleServer(endPoint, roleServer.Encrypted, roleServer.Roles);
                        tcpServers.Add(server.EndPoint.Port, server);
                    }
                    else
                    {
                        log.Fatal("UDP servers are not implemented.");
                        error = true;
                        break;
                    }
                }


                foreach (TcpRoleServer server in tcpServers.Values)
                {
                    if (!server.Start())
                    {
                        log.Error("Unable to start TCP server {0}.", server.EndPoint);
                        error = true;
                        break;
                    }
                }

                if (!error)
                {
                    res         = true;
                    Initialized = true;
                }
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }

            if (!res)
            {
                ShutdownSignaling.SignalShutdown();

                if (checkInactiveClientConnectionsTimer != null)
                {
                    checkInactiveClientConnectionsTimer.Dispose();
                }
                checkInactiveClientConnectionsTimer = null;

                foreach (TcpRoleServer server in tcpServers.Values)
                {
                    if (server.IsRunning)
                    {
                        server.Stop();
                    }
                }
                tcpServers.Clear();
            }

            log.Info("(-):{0}", res);
            return(res);
        }
        public override bool Init()
        {
            log.Info("()");

            bool res   = false;
            bool error = false;

            try
            {
                ConfigBase config = (ConfigBase)Base.ComponentDictionary[ConfigBase.ComponentName];
                serverId   = Crypto.Sha256(((KeysEd25519)config.Settings["Keys"]).PublicKey);
                clientList = new IncomingClientList();

                foreach (RoleServerConfiguration roleServer in ((ConfigServerRoles)config.Settings["ServerRoles"]).RoleServers.Values)
                {
                    if (roleServer.IsTcpServer)
                    {
                        IPEndPoint endPoint = new IPEndPoint((IPAddress)config.Settings["BindToInterface"], roleServer.Port);
                        TcpRoleServer <TIncomingClient> server = new TcpRoleServer <TIncomingClient>(endPoint, roleServer.Encrypted, roleServer.Roles, roleServer.ClientKeepAliveTimeoutMs);
                        tcpServers.Add(server.EndPoint.Port, server);
                    }
                    else
                    {
                        log.Fatal("UDP servers are not supported.");
                        error = true;
                        break;
                    }
                }


                foreach (TcpRoleServer <TIncomingClient> server in tcpServers.Values)
                {
                    if (!server.Start())
                    {
                        log.Error("Unable to start TCP server {0}.", server.EndPoint);
                        error = true;
                        break;
                    }
                }

                if (!error)
                {
                    res         = true;
                    Initialized = true;
                }
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }

            if (!res)
            {
                ShutdownSignaling.SignalShutdown();

                foreach (TcpRoleServer <TIncomingClient> server in tcpServers.Values)
                {
                    if (server.IsRunning)
                    {
                        server.Stop();
                    }
                }
                tcpServers.Clear();
            }

            log.Info("(-):{0}", res);
            return(res);
        }
Beispiel #18
0
        public override bool Init()
        {
            log.Info("()");

            bool res   = false;
            bool error = false;

            try
            {
                serverId   = ProfileServerCrypto.Crypto.Sha256(Base.Configuration.Keys.PublicKey);
                clientList = new IncomingClientList();

                foreach (RoleServerConfiguration roleServer in Base.Configuration.ServerRoles.RoleServers.Values)
                {
                    if (roleServer.IsTcpServer)
                    {
                        IPEndPoint    endPoint = new IPEndPoint(Base.Configuration.ServerInterface, roleServer.Port);
                        TcpRoleServer server   = new TcpRoleServer(endPoint, roleServer.Encrypted, roleServer.Roles);
                        tcpServers.Add(server.EndPoint.Port, server);
                    }
                    else
                    {
                        log.Fatal("UDP servers are not supported.");
                        error = true;
                        break;
                    }
                }


                foreach (TcpRoleServer server in tcpServers.Values)
                {
                    if (!server.Start())
                    {
                        log.Error("Unable to start TCP server {0}.", server.EndPoint);
                        error = true;
                        break;
                    }
                }

                if (!error)
                {
                    res         = true;
                    Initialized = true;
                }
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }

            if (!res)
            {
                ShutdownSignaling.SignalShutdown();

                foreach (TcpRoleServer server in tcpServers.Values)
                {
                    if (server.IsRunning)
                    {
                        server.Stop();
                    }
                }
                tcpServers.Clear();
            }

            log.Info("(-):{0}", res);
            return(res);
        }