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; }
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); }
protected override bool InitCache() { try { ActiveLog oActiveLog = new ActiveLog(); this.addCache(oActiveLog); return(true); } catch { return(false); } }
private void AwaitActiveLog() { activeLog = null; idleStrategy.Reset(); while (true) { int fragments = serviceControlAdapter.Poll(); if (activeLog != null) { break; } CheckInterruptedStatus(); idleStrategy.Idle(fragments); } }
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 }); }
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()); } }
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); }
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; }
protected override bool InitCache() { try { ActiveLog oActiveLog = new ActiveLog(); this.addCache(oActiveLog); return true; } catch { return false; } }
public void addLogList(LogSql ologSql) { ActiveLog oActiveLog = (ActiveLog)this.getCache(); oActiveLog.addLogList(ologSql); }