Exemple #1
0
        public static void StopAndDisposeTrainingPipeline(IDiagnosticsSession session, Pipeline pipeline)
        {
            Util.ThrowOnNullArgument(session, "session");
            Util.ThrowOnNullArgument(pipeline, "pipeline");
            session.TraceDebug("Calling Stop on the pipeline", new object[0]);
            IAsyncResult asyncResult = pipeline.BeginStop(null, null);

            asyncResult.AsyncWaitHandle.WaitOne();
            pipeline.EndStop(asyncResult);
            session.TraceDebug("Pipeline successfully stopped", new object[0]);
            pipeline.Dispose();
        }
Exemple #2
0
        public static Pipeline CreateAndStartTrainingPipeline(string dbGuid, IDiagnosticsSession session, string pipelineDefinitionFile, string pipelineInstanceName, Version pipelineVersion, out PipelineContext trainingPipelineContext)
        {
            Util.ThrowOnNullOrEmptyArgument(dbGuid, "dbGuid");
            Util.ThrowOnNullArgument(session, "session");
            Util.ThrowOnNullOrEmptyArgument(pipelineDefinitionFile, "pipelineDefinitionFile");
            Util.ThrowOnNullOrEmptyArgument(pipelineInstanceName, "pipelineInstanceName");
            Util.ThrowOnNullArgument(pipelineVersion, "pipelineVersion");
            string text = Path.Combine(InferencePipelineUtil.ExecutingAssemblyLocation, pipelineDefinitionFile);

            session.TraceDebug <string>("Loading pipeline definition from {0}", text);
            PipelineDefinition pipelineDefinition = PipelineDefinition.LoadFromFile(text);

            session.TraceDebug <string, int, int>("Loaded pipeline definition with Name = {0}, MaxConcurrency = {1}, Component Count = {2}", pipelineDefinition.Name, pipelineDefinition.MaxConcurrency, pipelineDefinition.Components.Length);
            session.TraceDebug <string>("Creating training pipeline context with version - {0}", pipelineVersion.ToString());
            trainingPipelineContext = new PipelineContext();
            string instance = string.Format("{0}-{1}", pipelineInstanceName, dbGuid);

            trainingPipelineContext.SetProperty <Version>(DocumentSchema.PipelineVersion, pipelineVersion);
            trainingPipelineContext.SetProperty <bool>(InferencePipelineUtil.AbortProcessing, false);
            trainingPipelineContext.SetProperty <string>(DocumentSchema.PipelineInstanceName, pipelineInstanceName);
            session.TraceDebug("Create the training pipeline", new object[0]);
            Pipeline pipeline = new Pipeline(pipelineDefinition, instance, trainingPipelineContext, null);

            session.TraceDebug("Calling prepareToStart", new object[0]);
            IAsyncResult asyncResult = pipeline.BeginPrepareToStart(null, null);

            asyncResult.AsyncWaitHandle.WaitOne();
            pipeline.EndPrepareToStart(asyncResult);
            session.TraceDebug("Calling Start", new object[0]);
            asyncResult = pipeline.BeginStart(null, null);
            asyncResult.AsyncWaitHandle.WaitOne();
            pipeline.EndStart(asyncResult);
            session.TraceDebug("Training pipeline successfully created and started", new object[0]);
            return(pipeline);
        }
Exemple #3
0
 private static void CallXsoAndMapExceptions(IDiagnosticsSession tracer, Guid mailboxGuid, MdbDocumentAdapter.CallXso xsoCall)
 {
     try
     {
         xsoCall();
     }
     catch (ConnectionFailedTransientException ex)
     {
         tracer.TraceError <Guid, ConnectionFailedTransientException>("Failed to connect to mailbox {0}, exception: {1}", mailboxGuid, ex);
         throw new ComponentFailedTransientException(Strings.ConnectionToMailboxFailed(mailboxGuid), ex);
     }
     catch (ConnectionFailedPermanentException ex2)
     {
         tracer.TraceError <Guid, ConnectionFailedPermanentException>("Failed to connect to mailbox {0}, exception: {1}", mailboxGuid, ex2);
         throw new ComponentFailedPermanentException(Strings.ConnectionToMailboxFailed(mailboxGuid), ex2);
     }
     catch (ObjectNotFoundException ex3)
     {
         tracer.TraceDebug <Guid, ObjectNotFoundException>("Got exception from XSO (MDB: {0}): {1}", mailboxGuid, ex3);
         throw new DocumentFailureException(ex3);
     }
     catch (CorruptDataException ex4)
     {
         tracer.TraceDebug <Guid, CorruptDataException>("Got exception from XSO (MDB: {0}): {1}", mailboxGuid, ex4);
         throw new DocumentFailureException(ex4);
     }
     catch (PropertyErrorException ex5)
     {
         tracer.TraceDebug <Guid, PropertyErrorException>("Got exception from XSO (MDB: {0}): {1}", mailboxGuid, ex5);
         throw new DocumentFailureException(ex5);
     }
     catch (MailboxUnavailableException ex6)
     {
         tracer.TraceDebug <Guid, MailboxUnavailableException>("Got exception from XSO (MDB: {0}): {1}", mailboxGuid, ex6);
         throw new DocumentFailureException(ex6);
     }
     catch (StoragePermanentException innerException)
     {
         throw new ComponentFailedPermanentException(innerException);
     }
     catch (StorageTransientException innerException2)
     {
         throw new ComponentFailedTransientException(innerException2);
     }
 }
 public static bool ConfigTryParseHelper <T>(IPipelineComponentConfig config, InferenceCommonUtility.TryParseFunction <T> tryParseFunction, string keyName, out T value, IDiagnosticsSession trace, T defaultValue)
 {
     if (!InferenceCommonUtility.ConfigTryParseHelper <T>(config, tryParseFunction, keyName, out value, trace))
     {
         value = defaultValue;
         if (trace != null)
         {
             trace.TraceDebug <string, T>("Defaulting config value referenced by keyName: {0} to: {1}", keyName, defaultValue);
         }
         return(false);
     }
     return(true);
 }
 public static bool ConfigTryParseHelper <T>(IPipelineComponentConfig config, InferenceCommonUtility.TryParseFunction <T> tryParseFunction, string keyName, out T value, IDiagnosticsSession trace)
 {
     value = default(T);
     if (config == null || !tryParseFunction(config[keyName], out value))
     {
         if (trace != null)
         {
             trace.TraceDebug <string>("Failed to parse config value referenced by keyName: {0}.", keyName);
         }
         return(false);
     }
     return(true);
 }
Exemple #6
0
 internal static void TranslateXsoExceptions(IDiagnosticsSession tracer, LocalizedString errorString, XsoUtil.XsoExceptionHandlingFlags flags, Action xsoCall)
 {
     try
     {
         xsoCall();
     }
     catch (ConnectionFailedTransientException ex)
     {
         XsoUtil.TraceAndThrowTransientException(tracer, errorString, ex);
     }
     catch (ConnectionFailedPermanentException ex2)
     {
         XsoUtil.TraceAndThrowPermanentException(tracer, errorString, ex2);
     }
     catch (MailboxUnavailableException ex3)
     {
         XsoUtil.TraceAndThrowPermanentException(tracer, errorString, ex3);
     }
     catch (ObjectNotFoundException ex4)
     {
         if ((flags & XsoUtil.XsoExceptionHandlingFlags.DoNotExpectObjectNotFound) == XsoUtil.XsoExceptionHandlingFlags.DoNotExpectObjectNotFound)
         {
             tracer.SendInformationalWatsonReport(ex4, null);
             if ((flags & XsoUtil.XsoExceptionHandlingFlags.RethrowUnexpectedExceptions) == XsoUtil.XsoExceptionHandlingFlags.RethrowUnexpectedExceptions)
             {
                 XsoUtil.TraceAndThrowPermanentException(tracer, errorString, ex4);
             }
         }
         else
         {
             tracer.TraceDebug <LocalizedString, ObjectNotFoundException>("Error: {0}, exception: {1}", errorString, ex4);
         }
     }
     catch (CorruptDataException ex5)
     {
         if ((flags & XsoUtil.XsoExceptionHandlingFlags.DoNotExpectCorruptData) == XsoUtil.XsoExceptionHandlingFlags.DoNotExpectCorruptData)
         {
             tracer.SendInformationalWatsonReport(ex5, null);
             if ((flags & XsoUtil.XsoExceptionHandlingFlags.RethrowUnexpectedExceptions) == XsoUtil.XsoExceptionHandlingFlags.RethrowUnexpectedExceptions)
             {
                 XsoUtil.TraceAndThrowPermanentException(tracer, errorString, ex5);
             }
         }
         else
         {
             tracer.TraceDebug <LocalizedString, CorruptDataException>("Error: {0}, exception: {1}", errorString, ex5);
         }
     }
     catch (AccessDeniedException ex6)
     {
         tracer.SendWatsonReport(ex6);
         XsoUtil.TraceAndThrowPermanentException(tracer, errorString, ex6);
     }
     catch (StoragePermanentException ex7)
     {
         if (ex7.GetType() != typeof(StoragePermanentException))
         {
             tracer.SendInformationalWatsonReport(ex7, null);
         }
         if ((flags & XsoUtil.XsoExceptionHandlingFlags.RethrowUnexpectedExceptions) == XsoUtil.XsoExceptionHandlingFlags.RethrowUnexpectedExceptions)
         {
             XsoUtil.TraceAndThrowPermanentException(tracer, errorString, ex7);
         }
     }
     catch (StorageTransientException ex8)
     {
         if (ex8.GetType() != typeof(StorageTransientException))
         {
             tracer.SendInformationalWatsonReport(ex8, null);
         }
         if ((flags & XsoUtil.XsoExceptionHandlingFlags.RethrowUnexpectedExceptions) == XsoUtil.XsoExceptionHandlingFlags.RethrowUnexpectedExceptions)
         {
             XsoUtil.TraceAndThrowPermanentException(tracer, errorString, ex8);
         }
     }
 }
Exemple #7
0
        internal static UserConfiguration ResetModel(string userConfigurationName, UserConfigurationTypes userConfigType, MailboxSession session, bool deleteOld, IDiagnosticsSession diagnosticSession)
        {
            StoreId         defaultFolderId = session.GetDefaultFolderId(DefaultFolderType.Inbox);
            OperationResult operationResult = OperationResult.Succeeded;
            Exception       ex = null;

            if (deleteOld)
            {
                try
                {
                    operationResult = session.UserConfigurationManager.DeleteFolderConfigurations(defaultFolderId, new string[]
                    {
                        userConfigurationName
                    });
                }
                catch (ObjectNotFoundException ex2)
                {
                    ex = ex2;
                    if (diagnosticSession != null)
                    {
                        diagnosticSession.TraceDebug <string, ObjectNotFoundException>("FAI message '{0}' is missing. Exception: {1}", userConfigurationName, ex2);
                    }
                }
                if (operationResult != OperationResult.Succeeded && ex == null)
                {
                    if (diagnosticSession != null)
                    {
                        diagnosticSession.TraceError(string.Format("Deletion of user configuration (userConfiguration Name = {0}) failed. OperationResult = {1}. ObjectNotFoundException = {2}", userConfigurationName, operationResult.ToString(), ex), new object[0]);
                    }
                    throw new DeleteItemsException(string.Format("Deletion of user configuration (userConfiguration Name = {0}) failed. OperationResult = {1}. ObjectNotFoundException = {2}", userConfigurationName, operationResult.ToString(), ex));
                }
            }
            UserConfiguration userConfiguration = null;

            try
            {
                userConfiguration = session.UserConfigurationManager.CreateFolderConfiguration(userConfigurationName, userConfigType, defaultFolderId);
                userConfiguration.Save();
            }
            catch (Exception ex3)
            {
                if (diagnosticSession != null && !(ex3 is QuotaExceededException))
                {
                    if (ex3 is StoragePermanentException)
                    {
                        diagnosticSession.SendInformationalWatsonReport(ex3, string.Format("Creation of user configuration failed (userConfiguration Name = {0}) deleteOld flag was {1}. Result of deletion of user configuration OperationResult = {2}. ObjectNotFoundException = {3}", new object[]
                        {
                            userConfigurationName,
                            deleteOld,
                            deleteOld ? operationResult.ToString() : "Not Applicable",
                            ex
                        }));
                    }
                    else
                    {
                        diagnosticSession.TraceError("Creation of user configuration failed (userConfiguration Name = {0}) deleteOld flag was {1}. Result of deletion of user configuration OperationResult = {2}. ObjectNotFoundException = {3}. Exception = {4}", new object[]
                        {
                            userConfigurationName,
                            deleteOld,
                            deleteOld ? operationResult.ToString() : "Not Applicable",
                            ex,
                            ex3.ToString()
                        });
                    }
                }
                if (userConfiguration != null)
                {
                    userConfiguration.Dispose();
                }
                throw;
            }
            return(userConfiguration);
        }