public bool TryAddNewExceptionInfo([NotNull] TaskMetaInformation taskMeta, [NotNull] Exception exception, out List <TimeGuid> newExceptionInfoIds)
        {
            if (!taskMeta.IsTimeBased())
            {
                throw new InvalidOperationException(string.Format("TaskMeta is not time-based: {0}", taskMeta));
            }
            newExceptionInfoIds = null;
            var newExceptionInfo  = new TaskExceptionInfo(exception);
            var lastExceptionInfo = TryGetLastExceptionInfo(taskMeta);

            if (lastExceptionInfo != null && lastExceptionInfo.ExceptionMessageInfo == newExceptionInfo.ExceptionMessageInfo)
            {
                return(false);
            }
            var      newExceptionInfoId = TimeGuid.NowGuid();
            var      timestamp          = newExceptionInfoId.GetTimestamp().Ticks;
            TimeGuid oldExceptionInfoId;

            newExceptionInfoIds = taskMeta.AddExceptionInfoId(newExceptionInfoId, out oldExceptionInfoId);
            var newExceptionInfoBytes = serializer.Serialize(newExceptionInfo);

            timeBasedBlobStorage.Write(taskMeta.Id, newExceptionInfoId, newExceptionInfoBytes, timestamp, taskMeta.GetTtl());
            if (oldExceptionInfoId != null)
            {
                timeBasedBlobStorage.Delete(taskMeta.Id, oldExceptionInfoId, timestamp);
            }
            return(true);
        }
コード例 #2
0
 public byte[] Read([NotNull] TaskMetaInformation taskMeta)
 {
     if (!taskMeta.IsTimeBased())
     {
         throw new InvalidOperationException(string.Format("TaskMeta is not time-based: {0}", taskMeta));
     }
     return(timeBasedBlobStorage.Read(taskMeta.GetTaskDataId()));
 }
コード例 #3
0
 public void Overwrite([NotNull] TaskMetaInformation taskMeta, [NotNull] byte[] taskData)
 {
     if (!taskMeta.IsTimeBased())
     {
         throw new InvalidOperationException(string.Format("TaskMeta is not time-based: {0}", taskMeta));
     }
     timeBasedBlobStorage.Write(taskMeta.GetTaskDataId(), taskData, timestamp: Timestamp.Now.Ticks, ttl: taskMeta.GetTtl());
 }
コード例 #4
0
        public BlobId Write([NotNull] TaskMetaInformation taskMeta, [NotNull] byte[] taskData)
        {
            if (!taskMeta.IsTimeBased())
            {
                throw new InvalidOperationException(string.Format("TaskId is not time-based: {0}", taskMeta.Id));
            }
            var blobId    = TimeBasedBlobStorage.GenerateNewBlobId(taskData.Length);
            var timestamp = blobId.Id.GetTimestamp().Ticks;

            timeBasedBlobStorage.Write(blobId, taskData, timestamp, taskMeta.GetTtl());
            return(blobId);
        }
        public void Delete([NotNull] TaskMetaInformation taskMeta)
        {
            if (!taskMeta.IsTimeBased())
            {
                throw new InvalidOperationException(string.Format("TaskMeta is not time-based: {0}", taskMeta));
            }
            var timestamp = Timestamp.Now.Ticks;

            foreach (var blobId in taskMeta.GetTaskExceptionInfoIds())
            {
                timeBasedBlobStorage.Delete(taskMeta.Id, blobId, timestamp);
            }
        }
        public void ProlongExceptionInfosTtl([NotNull] TaskMetaInformation taskMeta)
        {
            if (!taskMeta.IsTimeBased())
            {
                throw new InvalidOperationException(string.Format("TaskMeta is not time-based: {0}", taskMeta));
            }
            var oldExceptionInfos = timeBasedBlobStorage.Read(taskMeta.Id, taskMeta.GetTaskExceptionInfoIds().ToArray());
            var timestamp         = Timestamp.Now.Ticks;

            foreach (var exceptionInfo in oldExceptionInfos)
            {
                timeBasedBlobStorage.Write(taskMeta.Id, exceptionInfo.Key, exceptionInfo.Value, timestamp, taskMeta.GetTtl());
            }
        }
        private TaskExceptionInfo TryGetLastExceptionInfo([NotNull] TaskMetaInformation taskMeta)
        {
            if (!taskMeta.IsTimeBased())
            {
                throw new InvalidOperationException(string.Format("TaskMeta is not time-based: {0}", taskMeta));
            }
            var lastExceptionInfoId = taskMeta.GetTaskExceptionInfoIds().LastOrDefault();

            if (lastExceptionInfoId == null)
            {
                return(null);
            }
            var lastExceptionInfoBytes = timeBasedBlobStorage.Read(taskMeta.Id, lastExceptionInfoId);

            if (lastExceptionInfoBytes == null)
            {
                return(null);
            }
            return(serializer.Deserialize <TaskExceptionInfo>(lastExceptionInfoBytes));
        }