Esempio n. 1
0
        public int DoWork()
        {
            long nowMs = epochClock.Time();

            if (cachedEpochClock.Time() != nowMs)
            {
                markFile.UpdateActivityTimestamp(nowMs);
                cachedEpochClock.Update(nowMs);
            }

            int workCount = logAdapter.Poll();

            if (0 == workCount)
            {
                if (logAdapter.Image().Closed)
                {
                    throw new AgentTerminationException("Image closed unexpectedly");
                }

                if (!CommitPos.IsActive(aeron.CountersReader(), logAdapter.UpperBoundCounterId()))
                {
                    throw new AgentTerminationException("Commit position is not active");
                }
            }

            workCount += serviceControlAdapter.Poll();
            if (activeLog != null)
            {
                // TODO: handle new log case
                activeLog = null;
            }

            return(workCount);
        }
        private void JoinActiveLog(CountersReader counters)
        {
            AwaitActiveLog();

            int commitPositionId = activeLog.commitPositionId;

            if (!CommitPos.IsActive(counters, commitPositionId))
            {
                throw new InvalidOperationException("CommitPos counter not active: " + commitPositionId);
            }

            int logSessionId = activeLog.sessionId;

            leadershipTermId    = activeLog.leadershipTermId;
            termBaseLogPosition = CommitPos.GetTermBaseLogPosition(counters, commitPositionId);

            Subscription logSubscription = aeron.AddSubscription(activeLog.channel, activeLog.streamId);

            if (activeLog.ackBeforeImage)
            {
                serviceControlPublisher.AckAction(termBaseLogPosition, leadershipTermId, serviceId, ClusterAction.READY);
            }

            Image image = AwaitImage(logSessionId, logSubscription);

            heartbeatCounter.SetOrdered(epochClock.Time());

            if (!activeLog.ackBeforeImage)
            {
                serviceControlPublisher.AckAction(termBaseLogPosition, leadershipTermId, serviceId, ClusterAction.READY);
            }

            logAdapter = new BoundedLogAdapter(image, new ReadableCounter(counters, commitPositionId), this);
            activeLog  = null;
        }
Esempio n. 3
0
 private ActiveLog CopyActiveLog(ActiveLog alog, string format)
 {
     return(new ActiveLog()
     {
         LogID = alog.LogID,
         TableName = string.Format(format, alog.TableName),
         Record = alog.Record,
         EnableDate = alog.EnableDate,
         DisableDate = alog.DisableDate
     });
 }
 public void OnJoinLog(
     long leadershipTermId,
     int commitPositionId,
     int logSessionId,
     int logStreamId,
     bool ackBeforeImage,
     string logChannel)
 {
     activeLog = new ActiveLog(
         leadershipTermId, commitPositionId, logSessionId, logStreamId, ackBeforeImage, logChannel);
 }
Esempio n. 5
0
 protected override bool InitCache()
 {
     try
     {
         ActiveLog oActiveLog = new ActiveLog();
         this.addCache(oActiveLog);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Esempio n. 6
0
        private void AwaitActiveLog()
        {
            activeLog = null;
            idleStrategy.Reset();
            while (true)
            {
                int fragments = serviceControlAdapter.Poll();
                if (activeLog != null)
                {
                    break;
                }

                CheckInterruptedStatus();
                idleStrategy.Idle(fragments);
            }
        }
Esempio n. 7
0
        public ActiveLogModel Post([FromBody] ActiveLogModel model)
        {
            ActiveLog alog = DataSession.Single <ActiveLog>(model.LogID);

            if (alog == null)
            {
                return(null);
            }

            alog.EnableDate = model.EnableDate;
            DataSession.SaveOrUpdate(alog);

            return(new ActiveLogModel()
            {
                LogID = alog.LogID, EnableDate = alog.EnableDate
            });
        }
Esempio n. 8
0
        public IEnumerable <IOrg> GetActiveOrgs(int clientId, DateTime sd, DateTime ed)
        {
            ActiveLog alog = null;
            ClientOrg co   = null;
            Org       org  = null;

            var query = Session.QueryOver(() => org)
                        .JoinAlias(() => org, () => co.Org)
                        .JoinAlias(() => alog.Record, () => org.OrgID)
                        .Where(() => alog.TableName == "ClientOrg" && alog.EnableDate < ed && (alog.DisableDate == null || alog.DisableDate > sd))
                        .And(() => co.Client.ClientID == clientId);

            var list = query.List();

            var result = list.CreateModels <IOrg>();

            return(result);
        }
        private void SwitchActiveLog()
        {
            if (logAdapter.IsCaughtUp())
            {
                logAdapter.Dispose();

                var counters  = aeron.CountersReader();
                var counterId = activeLog.commitPositionId;

                leadershipTermId    = activeLog.leadershipTermId;
                termBaseLogPosition = CommitPos.GetTermBaseLogPosition(counters, counterId);

                Subscription subscription = aeron.AddSubscription(activeLog.channel, activeLog.streamId);
                Image        image        = AwaitImage(activeLog.sessionId, subscription);
                serviceControlPublisher.AckAction(termBaseLogPosition, leadershipTermId, serviceId, ClusterAction.READY);

                logAdapter = new BoundedLogAdapter(image, new ReadableCounter(counters, counterId), this);
                activeLog  = null;
                Role((ClusterRole)roleCounter.Get());
            }
        }
Esempio n. 10
0
        public static ActiveLog AddLog(string option, string remaeks, string openid)
        {
            var db = new ModelContext();

            var usr = WechatHelper.CheckOpenid(openid);

            usr = WechatHelper.CheckUser(usr);
            //usr = WechatHelper.CheckUser(usr);
            if (usr.UserInfoId == null || usr.UserInfoId == 0 || usr.UserInfo == null)
            {
                return(null);
            }

            var tname = System.Configuration.ConfigurationManager.AppSettings["termailname"];
            var tmn   = db.TerminalSet.FirstOrDefault(item => item.Name == tname);

            usr.UserInfo.LastLoginTerminalId = tmn.TerminalId;
            usr.UserInfo.LastLoginTime       = DateTime.Now;

            var log = new ActiveLog
            {
                CreateDate    = DateTime.Now,
                TerminalId    = tmn.TerminalId,
                UserId        = usr.UserInfoId,
                OptionContent = option,
                Remarks       = remaeks,
            };

            db.ActiveLogSet.Add(log);

            usr.UserInfo.LastLoginTime       = DateTime.Now;
            usr.UserInfo.LastLoginTerminalId = tmn.TerminalId;
            db.SaveChanges();

            return(log);
        }
Esempio n. 11
0
        private void JoinActiveLog(CountersReader counters)
        {
            AwaitActiveLog();

            int commitPositionId = activeLog.commitPositionId;

            if (!CommitPos.IsActive(counters, commitPositionId))
            {
                throw new System.InvalidOperationException("CommitPos counter not active: " + commitPositionId);
            }

            int logSessionId = activeLog.sessionId;

            leadershipTermId = activeLog.leadershipTermId;
            baseLogPosition  = CommitPos.GetBaseLogPosition(counters, commitPositionId);

            Subscription logSubscription = aeron.AddSubscription(activeLog.channel, activeLog.streamId);
            Image        image           = AwaitImage(logSessionId, logSubscription);

            serviceControlPublisher.AckAction(baseLogPosition, leadershipTermId, serviceId, ClusterAction.READY);

            logAdapter = new BoundedLogAdapter(image, new ReadableCounter(counters, commitPositionId), this);
            activeLog  = null;
        }
Esempio n. 12
0
 protected override bool InitCache()
 {
     try
     {
         ActiveLog oActiveLog = new ActiveLog();
         this.addCache(oActiveLog);
         return true;
     }
     catch
     {
         return false;
     }
 }
Esempio n. 13
0
    public void addLogList(LogSql ologSql)
    {
        ActiveLog oActiveLog = (ActiveLog)this.getCache();

        oActiveLog.addLogList(ologSql);
    }