Пример #1
0
        /// <summary>
        /// constructor
        /// </summary>
        /// <param name="servers"></param>
        public ConnectionForm(Servers servers)
        {
            InitializeComponent();

            _servers = servers;
            _default = _servers.Clone();
        }
Пример #2
0
        public object Clone()
        {
            ShardConfiguration sConfiguration = new ShardConfiguration();

            sConfiguration.Name    = Name;
            sConfiguration.Port    = Port;
            sConfiguration.Servers = Servers != null ? (ServerNodes)Servers.Clone() : null;
            sConfiguration.Status  = Status;
            sConfiguration.NodeHeartbeatInterval = NodeHeartbeatInterval;
            sConfiguration.UID = UID;



            return(sConfiguration);
        }
Пример #3
0
        public object Clone()
        {
            CacheConfiguration configuration = new CacheConfiguration();

            configuration.BindIp       = _bindIp;
            configuration._cacheId     = _cacheId;
            configuration._loadBalance = _loadBalance;
            configuration.Servers      = Servers != null?Servers.Clone() as CacheServer[] : null;

            configuration._serverRuntimeContext = _serverRuntimeContext;
            configuration._serverMapping        = _serverMapping != null?_serverMapping.Clone() as ServerMapping : null;

            configuration._enableClientLogs       = _enableClientLogs;
            configuration._logLevel               = _logLevel;
            configuration._enableServerPriorities = _enableServerPriorities;
            return(configuration);
        }
Пример #4
0
        public object Clone()
        {
            CacheConfiguration configuration = new CacheConfiguration();

            configuration.BindIp                    = _bindIp;
            configuration._cacheId                  = _cacheId;
            configuration._clientCacheId            = _clientCacheId;
            configuration._clientCacheSyncMode      = _clientCacheSyncMode;
            configuration._defaultReadThruProvider  = _defaultReadThruProvider;
            configuration._defaultWriteThruProvider = _defaultWriteThruProvider;
            configuration._loadBalance              = _loadBalance;

            configuration.Servers = Servers != null?Servers.Clone() as CacheServer[] : null;

            configuration._serverRuntimeContext = _serverRuntimeContext;
            configuration._serverMapping        = _serverMapping != null?_serverMapping.Clone() as ServerMapping : null;

            configuration._enableClientLogs = _enableClientLogs;
            configuration._logLevel         = _logLevel;
            return(configuration);
        }
Пример #5
0
        private Servers GetServerMonitorData_V2(Servers server, DelegateServers account)
        {
            string name  = server.serverName;
            string error = "";

            server.tailLog = string.Empty;
            server.error   = string.Empty;

            var client = bll.GetConection(server);//new SshClient(server.serverIP, server.userName, server.userPassword);

            try
            {
                bool isLiskRunning = bll.VerifyIfLiskIsRunning_V2(server, out error, client);

                decimal missedBlockPrevous = account.account.missedblocks;
                Servers serverPreviousData = (Servers)server.Clone();

                string url = "http://" + server.serverIP + ":" + server.serverPort;

                BlockChainStatus status = bll.GetBlockChainStatusSSH_V2(server, out error, client);
                server.error += error;
                if (status.success && isLiskRunning)
                {
                    server.blockChainHeight = status.height;
                    server.blockDiff        = status.blocks;
                    server.isChainSyncing   = status.syncing;
                    server.broadhash        = status.broadhash;
                    server.consensus        = string.IsNullOrEmpty(status.consensus) ? 0 : Convert.ToInt16(status.consensus);
                    // server.BroadhashConsensus100=status
                    if (server.isChainSyncing)
                    {
                        server.isChainSynced = false;
                        server.isRebuilding  = true;
                        //server.lastRebuild = DateTime.Now;

                        if (serverPreviousData.isForging)
                        {
                            server.isForging = false;
                        }
                    }
                    else
                    {
                        server.isChainSynced = true;
                        server.isRebuilding  = false;
                    }
                }


                //GetMaxPeerBlock
                string erro2 = "";
                //server.maxPeerBlock= bll.GetMaxPeerBlock(out erro2,server.serverPort);
                server.maxPeerBlock = bll.GetMaxPeerBlock_V2(out erro2, server, client);
                server.error       += erro2;

                //blockdiff
                server.blockDiff = server.maxPeerBlock - server.blockChainHeight;
                if (server.blockDiff < 0)
                {
                    server.blockDiff = server.blockDiff * -1;
                }


                if (server.blockDiff > blockDiffToRebuild)
                {
                    server.isChainSynced = false;
                    if (serverPreviousData.isRebuilding == true && server.isRebuilding == false /*changed  because GetBlockChainStatusSSH above has issue*/)
                    {
                        server.isChainSynced = false;
                        server.isRebuilding  = true;
                    }
                }
                else
                {
                    server.isChainSynced = true;
                    server.isRebuilding  = false;
                }


                //latestBlockForged
                string error3 = "";
                if (server.isChainSynced == true && server.isRebuilding == false)
                {
                    Block block = bll.GetLatestBlockSSH_V2(server, account.account.generatorPublicKey, out error3, client);
                    server.LastBlockMinutsPassedSince = block.minutsPassedSinceLastBlock;
                    server.LastBlockForgedHeight      = block.height;

                    // getnextforgers
                    int position = bll.GetForgingPosition(server, account.account.generatorPublicKey, client);

                    server.forgingPositionCurrenSlot = position == -1?-1:position + 1;
                }
                else
                {
                    Block block = new Block();
                    server.LastBlockMinutsPassedSince = 9999;
                    server.LastBlockForgedHeight      = 0;
                    server.forgingPositionCurrenSlot  = -1;
                }


                server.error += error3;

                server.tailLog = bll.ReadTailLog_V2(server, client);


                ////notify END rebuild
                if (serverPreviousData.isChainSynced == false && serverPreviousData.isRebuilding && server.isRebuilding == false)
                {
                    string serverResult = bll.GetAccountString(account);//GetServerJsonToNotify(server);

                    if (serverPreviousData.isRebuilding == true && server.isRebuilding == false)
                    {
                        //server.lastRebuild = DateTime.Now.AddMinutes(10);
                        File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + "\\logs\\" + "REBUILD_END_" + server.serverName + "_" + DateTime.Now.Ticks.ToString() + ".txt", "Rebuild End at " + DateTime.Now.ToString() + " \r\n Server Data:" + serverResult);

                        bll.SendEmail("SERVER END REBUILD " + server.serverName + " " + DateTime.Now.ToString(), account.account.email, "SERVER END REBUILD " + server.serverName + " " + DateTime.Now.ToString() + " server data: " + serverResult);
                    }
                }

                //notify LastBlockForgedHeight
                if (server.isForging && server.isChainSynced && numberTickesMade > 1)
                {
                    if (server.LastBlockLastNofication < DateTime.Now)
                    {
                        if (account.account.rate <= 101 && serverPreviousData.LastBlockForgedHeight < server.LastBlockForgedHeight && server.LastBlockForgedHeight > 0)
                        {
                            //string accountString = JsonConvert.SerializeObject(account);
                            string accountString = bll.GetAccountString(account);

                            string sms = account.account.username + " Rank: " + account.account.rate.ToString() + " Last Block: " + DateTime.Now.ToString() + " - " + server.serverName + " LastBlockForgedHeight:" + server.LastBlockForgedHeight.ToString() + " LastBlockMinutsPassed: " + server.LastBlockMinutsPassedSince + " this notification is sent every 5 hours, see inside account data.!!!";
                            bll.SendEmail(sms, account.account.email, sms + " Account: " + accountString);
                        }
                        else
                        {
                            if (account.account.rate > 101)
                            {
                                //string accountString = JsonConvert.SerializeObject(account);
                                string accountString = bll.GetAccountString(account);

                                string sms = account.account.username + " Rank: " + account.account.rate.ToString() + " this notification is sent every 5 hours, see inside account data.!!!";
                                bll.SendEmail(sms, account.account.email, sms + " Account:" + accountString);
                            }
                        }
                        server.LastBlockLastNofication = DateTime.Now.AddHours(5);
                    }
                }

                //notify missed block
                if (missedBlockPrevous < account.account.missedblocks)
                {
                    string accountString = bll.GetAccountString(account); //JsonConvert.SerializeObject(account);

                    string sms = "Missed Block Notification  " + account.account.username + " Rank:" + account.account.rate.ToString() + " " + DateTime.Now.ToString() + " - Server: " + server.serverName + " Missed Blocks:" + account.account.missedblocks;
                    bll.SendEmail(sms, account.account.email, sms + " Account:" + accountString);
                }
            }
            catch
            {
            }
            finally
            {
                //client.Disconnect();
                //client.Dispose();
            }



            return(server);
        }
Пример #6
0
 public Profile CloneProfile()
 {
     return(new Profile {
         FilePath = FilePath, Name = Name, Password = Password, PasswordHash = PasswordHash, Servers = Servers.Clone()
     });
 }