private static RetriableOperationExceptionHandler.Response AzureStorageExceptionHandler(Exception e) { if (e is StorageException) { // If this was a network error, we'll retry later. Else, we'll // just give up. StorageException storageException = (StorageException)e; if (IsNetworkError(storageException.RequestInformation.HttpStatusCode)) { return(RetriableOperationExceptionHandler.Response.Retry); } TraceSource.WriteExceptionAsWarning( TraceType, e, "Encountered an unhandled storage exception with http code {0}", storageException.RequestInformation.HttpStatusCode); } else if ((e is IOException) || (e is FabricException)) { // If there was an error accessing the file, but it was not because // the file was not found, we'll retry later. Else, we'll just give up. if (false == ((e is FileNotFoundException) || (e is DirectoryNotFoundException))) { return(RetriableOperationExceptionHandler.Response.Retry); } } return(RetriableOperationExceptionHandler.Response.Abort); }
public static COMException CreateException(TraceType traceType, NativeTypes.FABRIC_ERROR_CODE error, string format, params object[] args) { string message = string.Format(CultureInfo.InvariantCulture, format, args); var exception = new COMException(message, (int)error); traceSource.WriteExceptionAsWarning(traceType.Name, exception); return(exception); }
public void WriteExceptionAsWarning(TraceType traceType, Exception ex, string format, params object[] args) { if (!string.IsNullOrEmpty(this.TraceId)) { TraceSource.WriteExceptionAsWarningWithId(traceType.Name, this.TraceId, ex, format, args); } else { TraceSource.WriteExceptionAsWarning(traceType.Name, ex, format, args); } }
internal static string GetKernelCrashFolder(FabricEvents.ExtensionsEvents traceSource, string logSourceId) { string string_to_check = "Not ready to kdump"; string kdump_config_output = string.Empty; string kernelCrashFolderPath = string.Empty; try { using (var p = new Process()) { var startInfo = new ProcessStartInfo { FileName = "kdump-config", Arguments = "status" }; startInfo.RedirectStandardOutput = true; p.StartInfo = startInfo; p.Start(); p.WaitForExit(3000); using (var reader = p.StandardOutput) kdump_config_output = reader.ReadToEnd(); } if (kdump_config_output == null) { traceSource.WriteWarning( logSourceId, "kdump status output empty"); return(string.Empty); } } catch (Exception e) { traceSource.WriteExceptionAsWarning( logSourceId, e); return(string.Empty); } if (kdump_config_output.Contains(string_to_check)) { traceSource.WriteWarning( logSourceId, "kdump is not configured"); return(string.Empty); } try { using (var p = new Process()) { var startInfo = new ProcessStartInfo { FileName = "/bin/bash", Arguments = "-c \" kdump-config show | grep \"KDUMP_COREDIR:\" | cut -f 5 -d' ' \" " }; startInfo.RedirectStandardOutput = true; p.StartInfo = startInfo; p.Start(); p.WaitForExit(3000); using (var reader = p.StandardOutput) { kdump_config_output = reader.ReadToEnd(); } } if (kdump_config_output == null) { traceSource.WriteWarning( logSourceId, "kdump config output empty"); return(string.Empty); } kernelCrashFolderPath = Path.GetFullPath(kdump_config_output); } catch (Exception e) { traceSource.WriteExceptionAsWarning( logSourceId, e); return(string.Empty); } return(kernelCrashFolderPath.Trim()); }