Example #1
0
        /// <summary>
        /// Adds the socket interface to the database
        /// </summary>
        /// <param name="socketSettings">the config data for the socket listener</param>
        public void AddSocketListener(SnapSocketListenerSettings socketSettings)
        {
            if ((object)socketSettings == null)
            {
                throw new ArgumentNullException("socketSettings");
            }

            using (Logger.AppendStackMessages(Log.InitialStackMessages))
            {
                SnapSocketListener listener = new SnapSocketListener(socketSettings, this);
                lock (m_syncRoot)
                {
                    m_sockets.Add(socketSettings.LocalEndPoint, listener);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Gets the status of the server.
        /// </summary>
        /// <param name="status">Target status output <see cref="StringBuilder"/>.</param>
        /// <param name="maxFileListing">Maximum file listing.</param>
        public void GetFullStatus(StringBuilder status, int maxFileListing = -1)
        {
            lock (m_syncRoot)
            {
                status.AppendLine($"Historian Instances:{Environment.NewLine}");
                int count = 0;

                foreach (DatabaseInfo dbInfo in GetDatabaseInfo())
                {
                    status.AppendLine($"Instance {++count:N0}: {dbInfo.DatabaseName}{Environment.NewLine}");

                    try
                    {
                        GetDatabase(dbInfo.DatabaseName).GetFullStatus(status, maxFileListing);
                    }
                    catch (Exception ex)
                    {
                        Log.Publish(MessageLevel.Warning, "Full Status", $"Failed to get full status for {dbInfo.DatabaseName}", exception: ex);
                    }
                }

                status.AppendLine($"{Environment.NewLine}Socket Connections:{Environment.NewLine}");
                count = 0;

                foreach (KeyValuePair <IPEndPoint, SnapSocketListener> socket in m_sockets)
                {
                    status.AppendLine($"Connection {++count:N0}: Port: {socket.Key}{Environment.NewLine}");

                    try
                    {
                        SnapSocketListener historian = socket.Value;
                        historian.GetFullStatus(status);
                    }
                    catch (Exception ex)
                    {
                        Log.Publish(MessageLevel.Warning, "Full Status", $"Failed to get full status for port {socket.Key}", exception: ex);
                    }
                }
            }
        }
Example #3
0
        /// <summary>
        /// Gets the status of the server.
        /// </summary>
        /// <param name="status"></param>
        public void GetFullStatus(StringBuilder status)
        {
            //ToDo: Consider a better way to get status data.
            lock (m_syncRoot)
            {
                status.AppendFormat("Historian Instances:");

                foreach (DatabaseInfo dbInfo in GetDatabaseInfo())
                {
                    status.AppendFormat("DB Name:{0}\r\n", dbInfo.DatabaseName);

                    try
                    {
                        GetDatabase(dbInfo.DatabaseName).GetFullStatus(status);
                    }
                    catch (Exception ex)
                    {
                        Log.Publish(MessageLevel.Warning, "Full Status", $"Failed to get full status for {dbInfo.DatabaseName}", exception: ex);
                    }
                }

                status.AppendFormat("Socket Connections");

                foreach (KeyValuePair <IPEndPoint, SnapSocketListener> socket in m_sockets)
                {
                    status.AppendFormat("Port:{0}\r\n", socket.Key);

                    try
                    {
                        SnapSocketListener historian = socket.Value;
                        historian.GetFullStatus(status);
                    }
                    catch (Exception ex)
                    {
                        Log.Publish(MessageLevel.Warning, "Full Status", $"Failed to get full status for port {socket.Key}", exception: ex);
                    }
                }
            }
        }