public RestoreQueueSelectCriteria(RestoreQueueSelectCriteria other)
 : base(other)
 {}
예제 #2
0
		public override RestoreQueue GetRestoreCandidate()
		{
			RestoreQueue queueItem;

			using (IUpdateContext updateContext = PersistentStore.OpenUpdateContext(UpdateContextSyncMode.Flush))
			{
				QueryRestoreQueueParameters parms = new QueryRestoreQueueParameters();

				parms.PartitionArchiveKey = _partitionArchive.GetKey();
				parms.ProcessorId = ServerPlatform.ProcessorId;
				parms.RestoreQueueStatusEnum = RestoreQueueStatusEnum.Restoring;
				IQueryRestoreQueue broker = updateContext.GetBroker<IQueryRestoreQueue>();

				// Stored procedure only returns 1 result.
				queueItem = broker.FindOne(parms);

	

				if (queueItem != null)
					updateContext.Commit();
			}
			if (queueItem == null)
			{
				using (IUpdateContext updateContext = PersistentStore.OpenUpdateContext(UpdateContextSyncMode.Flush))
				{
					RestoreQueueSelectCriteria criteria = new RestoreQueueSelectCriteria();
					criteria.RestoreQueueStatusEnum.EqualTo(RestoreQueueStatusEnum.Restoring);
					IRestoreQueueEntityBroker restoreQueueBroker = updateContext.GetBroker<IRestoreQueueEntityBroker>();

					if (restoreQueueBroker.Count(criteria) > HsmSettings.Default.MaxSimultaneousRestores)
						return null;

					QueryRestoreQueueParameters parms = new QueryRestoreQueueParameters();

					parms.PartitionArchiveKey = _partitionArchive.GetKey();
					parms.ProcessorId = ServerPlatform.ProcessorId;
					parms.RestoreQueueStatusEnum = RestoreQueueStatusEnum.Pending;
					IQueryRestoreQueue broker = updateContext.GetBroker<IQueryRestoreQueue>();

					parms.RestoreQueueStatusEnum = RestoreQueueStatusEnum.Pending;
					queueItem = broker.FindOne(parms);

					if (queueItem != null)
						updateContext.Commit();
				}
			}
			return queueItem;
		}
예제 #3
0
		/// <summary>
		/// Reset any failed restore requests that may have been left In Progress when the service last shut down.
		/// </summary>
		public void ResetFailedRestoreQueueItems()
		{
			using (IUpdateContext updateContext = PersistentStore.OpenUpdateContext(UpdateContextSyncMode.Flush))
			{
				IRestoreQueueEntityBroker broker = updateContext.GetBroker<IRestoreQueueEntityBroker>();

				ArchiveStudyStorageSelectCriteria selectStudyStorage = new ArchiveStudyStorageSelectCriteria();
				selectStudyStorage.PartitionArchiveKey.EqualTo(_partitionArchive.Key);

				RestoreQueueSelectCriteria criteria = new RestoreQueueSelectCriteria();
				criteria.ProcessorId.EqualTo(ServerPlatform.ProcessorId);
				criteria.RestoreQueueStatusEnum.EqualTo(RestoreQueueStatusEnum.InProgress);
				criteria.ArchiveStudyStorageRelatedEntityCondition.Exists(selectStudyStorage);

				IList<RestoreQueue> failedList = broker.Find(criteria);
				foreach (RestoreQueue failedItem in failedList)
				{
					UpdateRestoreQueue(updateContext, failedItem, RestoreQueueStatusEnum.Pending, Platform.Time.AddMinutes(2));

					Platform.Log(LogLevel.Warn,
								 "Reseting RestoreQueue entry {0} to Pending that was In Progress at startup for PartitionArchive '{1}' on ",
								 failedItem.Key, _partitionArchive.Description);
				}

				if (failedList.Count > 0)
					updateContext.Commit();
				else
					Platform.Log(LogLevel.Info, "No RestoreQueue entries to reset on startup for archive {0}", _partitionArchive.Description);
			}
		}
 public RestoreQueueSelectCriteria(RestoreQueueSelectCriteria other)
     : base(other)
 {
 }