示例#1
0
        protected override void ProcessItem(Model.WorkQueue item)
        {
            Platform.CheckForNullReference(item, "item");

            Platform.Log(LogLevel.Info,
                         "Starting Tier Migration of study {0} for Patient {1} (PatientId:{2} A#:{3}) on Partition {4}",
                         Study.StudyInstanceUid, Study.PatientsName, Study.PatientId,
                         Study.AccessionNumber, ServerPartition.Description);

            // The WorkQueue Data column contains the state of the processing. It is set to "Migrated" if the entry has been
            // successfully executed once.
            TierMigrationProcessingState state = GetCurrentState(item);

            switch (state)
            {
            case TierMigrationProcessingState.Migrated:
                Platform.Log(LogLevel.Info, "Study has been migrated to {0} on {1}", StorageLocation.FilesystemPath, StorageLocation.FilesystemTierEnum.Description);
                PostProcessing(item, WorkQueueProcessorStatus.Complete, WorkQueueProcessorDatabaseUpdate.ResetQueueState);
                break;

            case TierMigrationProcessingState.NotStated:
                ServerFilesystemInfo currFilesystem = FilesystemMonitor.Instance.GetFilesystemInfo(StorageLocation.FilesystemKey);
                ServerFilesystemInfo newFilesystem  = FilesystemMonitor.Instance.GetLowerTierFilesystemForStorage(currFilesystem);

                if (newFilesystem == null)
                {
                    // This entry shouldn't have been scheduled in the first place.
                    // It's possible that the folder wasn't full when the entry was scheduled.
                    // Another possiblity is the study was migrated but an error was encountered when updating the entry.//
                    // We should re-insert the filesystem queue so that if the study will be migrated if the space is freed up
                    // in the future.
                    String msg = String.Format(
                        "Study '{0}' cannot be migrated: no writable filesystem can be found in lower tiers for filesystem '{1}'. Reschedule migration for future.",
                        StorageLocation.StudyInstanceUid, currFilesystem.Filesystem.Description);

                    Platform.Log(LogLevel.Warn, msg);
                    ReinsertFilesystemQueue();
                    PostProcessing(item, WorkQueueProcessorStatus.Complete, WorkQueueProcessorDatabaseUpdate.ResetQueueState);
                }
                else
                {
                    DoMigrateStudy(StorageLocation, newFilesystem);

                    // Update the state separately so that if the validation (done in the PostProcessing method) fails,
                    // we know the study has been migrated when we resume after auto-recovery has been completed.
                    UpdateState(item.Key, TierMigrationProcessingState.Migrated);
                    PostProcessing(item, WorkQueueProcessorStatus.Complete, WorkQueueProcessorDatabaseUpdate.ResetQueueState);
                }
                break;

            default:
                throw new NotImplementedException("Not implemented");
            }
        }
示例#2
0
        private static void UpdateState(ServerEntityKey key, TierMigrationProcessingState state)
        {
            TierMigrationWorkQueueData data = new TierMigrationWorkQueueData {
                State = state
            };

            using (IUpdateContext context = PersistentStoreRegistry.GetDefaultStore().OpenUpdateContext(UpdateContextSyncMode.Flush))
            {
                IWorkQueueEntityBroker broker = context.GetBroker <IWorkQueueEntityBroker>();
                WorkQueueUpdateColumns parms  = new WorkQueueUpdateColumns {
                    Data = XmlUtils.SerializeAsXmlDoc(data)
                };
                if (!broker.Update(key, parms))
                {
                    throw new ApplicationException("Unable to update work queue state");
                }
                context.Commit();
            }
        }
示例#3
0
        private static void UpdateState(ServerEntityKey key, TierMigrationProcessingState state)
        {
            TierMigrationWorkQueueData data = new TierMigrationWorkQueueData {State = state};

        	using(IUpdateContext context = PersistentStoreRegistry.GetDefaultStore().OpenUpdateContext(UpdateContextSyncMode.Flush))
            {
                IWorkQueueEntityBroker broker = context.GetBroker<IWorkQueueEntityBroker>();
                WorkQueueUpdateColumns parms = new WorkQueueUpdateColumns {Data = XmlUtils.SerializeAsXmlDoc(data)};
            	if (!broker.Update(key, parms))
                    throw new ApplicationException("Unable to update work queue state");
            	context.Commit();
            }
        }