public async Task <float[]> InferMainBBox(object image) { var res = await _mnssd.PlayMNSSD(image, Labels.Count, OUT_BB_COUNT); var startSelectBBTime = DateTimeOffset.UtcNow; _mainBB = SelectMainBB(res.Item1, res.Item2); if (_mainBB[0] < -99) { _mainBB = null; } var selectBBTime = DateTimeOffset.UtcNow - startSelectBBTime; var preTime = _mnssd.PreprocessTime.TotalMilliseconds.ToString("F0"); var inferTime = _mnssd.InferenceTime.TotalMilliseconds.ToString("F0"); var postTime = _mnssd.PostprocessTime.TotalMilliseconds.ToString("F0"); var logParams = new LogParams { ShowIdx = 2, Color = Color.LimeGreen, Text = $"MNSSD: {preTime}ms, {inferTime}ms, {postTime}ms{Environment.NewLine}" + $" - Select mainBB: {selectBBTime.TotalMilliseconds:F0}ms" }; LogChanged?.Invoke(this, logParams); return(_mainBB); }
public async Task Remove(long rowId, LogParams logParams)//TODO: transaction? { using (var db = new FinancialStatementContext()) { var model = await GetSingleModel(db, rowId); var existingMapping = await GetSingle(db, rowId); if (model != null && existingMapping != null) { var checkErrors = await CheckRestrictionsOnRemove(db, model); if (checkErrors.Any()) { throw new PublicException("Mapping remove failed due to locks: " + JoinErrors(checkErrors)); } try { RemoveMappingFunc(db, existingMapping); await db.SaveChangesAsync(); } catch (Exception ex) { throw new PublicException(RemovingErrorText, ex); } logParams.ActionType = RemovingActionType; logParams.Details = GetDetailsForLog(model); await SaveLog(db, logParams); } } }
/// <inheritdoc/> public override string ToString() { var sb = new StringBuilder(); sb.Append(Id); sb.Append(','); sb.Append(TimeStamp); sb.Append(','); if (LogType != null) { sb.Append(LogType); sb.Append('/'); sb.Append(LogAction); sb.Append(",{"); if (LogParams.Count > 0) { sb.Append(string.Join(",", LogParams.Select(p => p.Key + "=" + p.Value.ToString(Formatting.None)))); } sb.Append("},"); } sb.Append(Type); sb.Append(",["); sb.Append(Flags); sb.Append("],"); sb.Append(Title); sb.Append(','); sb.Append(UserName); sb.Append(','); sb.Append(Comment); return(sb.ToString()); }
public async Task Remove(long id, LogParams logParams)//TODO: transaction? { using (var db = new FinancialStatementContext()) { var model = await GetSingleModel(db, id); var existingItem = await GetSingle(db, id); if (existingItem != null) { try { RemoveFunc(db, existingItem); await db.SaveChangesAsync(); } catch (Exception ex) { throw new PublicException(RemovingErrorText, ex); } logParams.ActionType = RemovingActionType; logParams.Details = GetDetailsForLog(model); await SaveLog(db, logParams); } } }
public async Task <PagedList <Log> > GetLogs(LogParams logParams) { var logs = context.Logs.AsQueryable(); if (logParams.Level != 0) { logs = logs.Where((log) => log.Level == logParams.Level); } if (logParams.LastXDays != 0) { var dataFrom = DateTime.Now.AddDays(-logParams.LastXDays); logs = logs.Where((log) => log.Timestamp >= dataFrom); } if (!string.IsNullOrEmpty(logParams.Name)) { var user = await userManager.FindByNameAsync(logParams.Name); if (user != null) { logs = logs.Where(l => l.UserId == user.Id); } } var list = await PagedList <Log> .CreateAsync(logs, logParams.PageNumber, logParams.PageSize); return(list); }
public async Task <IActionResult> GetLogs([FromQuery] LogParams logParams) { var logs = await _logRepository.GetLogs(logParams); Response.AddPagination(logs.CurrentPage, logs.PageSize, logs.TotalCount, logs.TotalPages); return(Ok(logs)); }
public void PRE_MAPPING_CREATE_is_logged() { LogParams logMessage = log_that_contains_message("PRE_MAPPING_CREATE"); Assert.That(logMessage.messageParameters, Is.EqualTo(new List <object> { typeof(SupportContainer), null }).AsCollection); }
public void POST_CONSTRUCT_is_logged() { LogParams logMessage = log_that_contains_message("POST_CONSTRUCT"); Assert.That(logMessage.messageParameters, Is.EqualTo(new List <object> { supportContainer, typeof(SupportContainer) }).AsCollection); }
protected async Task SaveLog(FinancialStatementContext db, LogParams logParams) { try { logParams.CreatedOn = DateTime.Now; var sqlParams = new[] { new SqlParameter { ParameterName = "@createdOn", Value = logParams.CreatedOn, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.DateTime, Size = 8 }, new SqlParameter { ParameterName = "@actionType", Value = logParams.ActionType, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.NVarChar, Size = 100 }, new SqlParameter { ParameterName = "@adUsername", Value = logParams.AdUsername, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.NVarChar, Size = 100 }, new SqlParameter { ParameterName = "@remoteAddress", Value = logParams.RemoteAddress, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.NVarChar, Size = 50 }, new SqlParameter { ParameterName = "@oldData", Value = logParams.OldData, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.NVarChar, Size = 1000 }, new SqlParameter { ParameterName = "@newData", Value = logParams.NewData, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.NVarChar, Size = 1000 }, new SqlParameter { ParameterName = "@details", Value = logParams.Details, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.NVarChar, Size = -1 }, }; CheckParamValues(sqlParams); try { await db.Database.ExecuteSqlCommandAsync(ExecuteLogMappingProcedureQuery, sqlParams); } catch (Exception ex) { var nl = Environment.NewLine; var message = $"CreatedOn: {logParams.CreatedOn}; " + nl + $"ActionType: {logParams.ActionType}; " + nl + $"AdUsername: {logParams.AdUsername}; " + nl + $"RemoteAddress: {logParams.RemoteAddress}; " + nl + $"OldData: {logParams.OldData}; " + nl + $"NewData: {logParams.NewData}; " + nl + $"Details: {logParams.Details} "; throw new LogException($"Failed to write to log: {nl + message}", ex); } } catch (Exception ex) { throw new PublicException("An error occured while writing to log", ex); } }
public async Task CreateLog(LogParams logParams) { try { var log = new Log(logParams.UserId, logParams.ApiRoute, logParams.Message, (int)logParams.StatusCode, logParams.Ip); SetLogLevel(log, logParams.StatusCode); database.AdminRepository.Add(log); await database.Complete(); } catch (Exception) { } }
public HttpResponseMessage InsertLog(LogParams obj) { try { if (obj == null) { goto ThrowBadRequest; } var log = db.LogInsert(obj.Details, obj.Action, obj.RelatedID, obj.RelatedID, obj.Type); return(Request.CreateResponse(HttpStatusCode.OK, log)); } catch (Exception) { return(Request.CreateResponse(HttpStatusCode.InternalServerError)); } ThrowBadRequest: return(Request.CreateResponse(HttpStatusCode.BadRequest)); }
public HttpResponseMessage SelectLog(LogParams obj, int pageNumber = 1, int pageSize = 10) { try { if (obj == null) { goto ThrowBadRequest; } var logs = db.LogSelect(pageNumber, pageSize, obj.DateFrom, obj.DateTo, obj.Action, obj.RelatedID, obj.StaffID, obj.Type, obj.TicketNumber); return(Request.CreateResponse(HttpStatusCode.OK, logs)); } catch (Exception) { return(Request.CreateResponse(HttpStatusCode.InternalServerError)); } ThrowBadRequest: return(Request.CreateResponse(HttpStatusCode.BadRequest)); }
public async Task <SaveResult> Save(TReference item, LogParams logParams)//TODO: transaction? { using (var db = new FinancialStatementContext()) { var existingItem = item.IsNew.HasValue && item.IsNew.Value ? null : await GetSingle(db, item.Id); if (existingItem == null) { await Add(db, item, logParams); return(SaveResult.Added); } else { await Edit(db, existingItem, item, logParams); return(SaveResult.Edited); } } }
protected async Task Add(FinancialStatementContext db, TReference item, LogParams logParams) { try { AddFunc(db, item); await db.SaveChangesAsync(); } catch (Exception ex) { if (SqlExceptionHelper.IsUniqueConstraintError(ex)) { throw new PublicException(UniqueConstraintErrorText, ex); } throw new PublicException(CreatingErrorText, ex); } logParams.ActionType = CreatingActionType; logParams.Details = GetDetailsForLog(item); await SaveLog(db, logParams); }
public async Task <SaveResult> Save(TViewModel model, LogParams logParams)//TODO: transaction? { using (var db = new FinancialStatementContext()) { var existingMapping = model.IsNew.HasValue && model.IsNew.Value ? null : await GetSingle(db, model.RowId); if (existingMapping == null) { await AddMapping(db, model, logParams); return(SaveResult.Added); } else { await EditMapping(db, existingMapping, model, logParams); return(SaveResult.Edited); } } }
public async Task FeedFrame(FrameEntry frame, RectangleF carBB, bool isFirst) { Rectangle bb = ScaleCarBBoxAddingMargins(frame, carBB); var croppedCar = _accessor.Helpers.CropImage(frame, bb); var orientNumber = _accessor.Helpers.DeviceOrientationAsNumber(); croppedCar = _accessor.Helpers.RotateImage(croppedCar, orientNumber); LastCarImage = croppedCar; // _accessor.DumpService.SaveFrame(croppedCar); var carImage = _accessor.Helpers.ToNativeImage(croppedCar); await _accessor.CarModelClassifier.Classify(carImage); await _accessor.CarColorClassifier.Classify(carImage); if (carImage is IDisposable disposable) { disposable.Dispose(); } if (isFirst) { //Array.Fill(_carModelProbSum, 0.0f); //Array.Fill(_carColorProbSum, 0.0f); for (int i = 0; i < _carModelProbSum.Length; i++) _carModelProbSum[i] = 0; for (int i = 0; i < _carColorProbSum.Length; i++) _carColorProbSum[i] = 0; _feedCount = 0; } _feedCount++; for (int idx = 0; idx < _accessor.CarModelClassifier.OutputSize(); idx++) _carModelProbSum[idx] += _accessor.CarModelClassifier.Probabilities[idx]; for (int idx = 0; idx < _accessor.CarColorClassifier.OutputSize(); idx++) _carColorProbSum[idx] += _accessor.CarColorClassifier.Probabilities[idx]; // ----------------------------------------- // // Throw events for the screen log var top3 = TopKFeatures(3); var colorPreTime = _accessor.CarColorClassifier.PreprocessTime.TotalMilliseconds.ToString("F0"); var colorInferTime = _accessor.CarColorClassifier.InferenceTime.TotalMilliseconds.ToString("F0"); var colorPostTime = _accessor.CarColorClassifier.PostprocessTime.TotalMilliseconds.ToString("F0"); var logText = $"Color NN: {colorPreTime}ms, {colorInferTime}ms, {colorPostTime}ms{Environment.NewLine}" + $" - {top3[0].ColorName} - {100 * top3[0].ColorProbability:F1}%{Environment.NewLine}" + $" - {top3[1].ColorName} - {100 * top3[1].ColorProbability:F1}%{Environment.NewLine}" + $" - {top3[2].ColorName} - {100 * top3[2].ColorProbability:F1}%{Environment.NewLine}"; var mmPreTime = _accessor.CarModelClassifier.PreprocessTime.TotalMilliseconds.ToString("F0"); var mmInferTime = _accessor.CarModelClassifier.InferenceTime.TotalMilliseconds.ToString("F0"); var mmPostTime = _accessor.CarModelClassifier.PostprocessTime.TotalMilliseconds.ToString("F0"); logText += $"M/m NN: {mmPreTime}ms, {mmInferTime}ms, {mmPostTime}ms{Environment.NewLine}" + $" - {top3[0].ModelName} - {100 * top3[0].ModelProbability:F1}%{Environment.NewLine}" + $" - {top3[1].ModelName} - {100 * top3[1].ModelProbability:F1}%{Environment.NewLine}" + $" - {top3[2].ModelName} - {100 * top3[2].ModelProbability:F1}%{Environment.NewLine}"; var logParams = new LogParams() { ShowIdx = 3, Color = Color.Cyan, Text = logText }; LogChanged?.Invoke(this, logParams); // ----------------------------------------- // }
private async Task Edit(FinancialStatementContext db, TReference existingItem, TReference item, LogParams logParams) { var logEntries = new List <LogParams>(); try { logEntries.AddRange(EditFunc(db, existingItem, item)); await db.SaveChangesAsync(); } catch (Exception ex) { if (SqlExceptionHelper.IsUniqueConstraintError(ex)) { throw new PublicException(UniqueConstraintErrorText, ex); } throw new PublicException(EditingErrorText, ex); } foreach (var logEntry in logEntries) { logEntry.ActionType = EditingActionType; logEntry.AdUsername = logParams.AdUsername; logEntry.RemoteAddress = logParams.RemoteAddress; await SaveLog(db, logEntry); } }
private static void GatherConflicts(object param) { var jobData = (ConflictsScanJobData)param; var results = jobData.Reults; var logParams = new LogParams() { FetchAffectedPaths = true, FetchCommitMessages = false, StopOnCopy = true, Limit = 10, }; const string svnDateFormat = "yyyy-MM-dd"; switch (jobData.LimitType) { case ConflictsScanLimitType.Days: logParams.RangeStart = "{" + System.DateTime.Now.AddDays(-1 * jobData.LimitParam).ToString(svnDateFormat) + "}"; logParams.RangeEnd = "HEAD"; break; case ConflictsScanLimitType.Weeks: logParams.RangeStart = "{" + System.DateTime.Now.AddDays(-1 * 7 * jobData.LimitParam).ToString(svnDateFormat) + "}"; logParams.RangeEnd = "HEAD"; break; case ConflictsScanLimitType.Months: logParams.RangeStart = "{" + System.DateTime.Now.AddMonths(-1 * jobData.LimitParam).ToString(svnDateFormat) + "}"; logParams.RangeEnd = "HEAD"; break; case ConflictsScanLimitType.Revisions: // Revisions are calculated per branch. Do nothing here. break; case ConflictsScanLimitType.Unlimited: logParams.RangeStart = ""; break; default: Debug.LogError($"Unsupported ConflictsScanLimitType {jobData.LimitType} with param {jobData.LimitParam}"); break; } List <LogEntry> logEntries = new List <LogEntry>(); for (int i = 0; i < results.Length; ++i) { var result = results[i]; logEntries.Clear(); var targetURL = result.UnityURL + "/" + jobData.TargetAssetPath; var targetRelativeURL = WiseSVNIntegration.AssetPathToRelativeURL(targetURL); // Either it doesn't exist in this branch or it was moved / deleted. Can't know for sure without some deep digging. if (string.IsNullOrEmpty(targetRelativeURL)) { result.State = ConflictState.Missing; results[i] = result; continue; } if (jobData.LimitType == ConflictsScanLimitType.Revisions) { var lastChangedRevision = WiseSVNIntegration.LastChangedRevision(targetURL); if (lastChangedRevision < 0) { // Probably doesn't exist in this branch. logParams.RangeStart = ""; logParams.RangeEnd = ""; } else { logParams.RangeStart = (lastChangedRevision - jobData.LimitParam).ToString(); logParams.RangeEnd = lastChangedRevision.ToString(); } } var opResult = WiseSVNIntegration.Log(targetURL, logParams, logEntries, 60000 * 5); // Either it doesn't exist in this branch or it was moved / deleted. Can't know for sure without some deep digging. if (opResult == LogOperationResult.NotFound) { result.State = ConflictState.Missing; results[i] = result; continue; } if (opResult != LogOperationResult.Success) { result.State = ConflictState.Error; results[i] = result; continue; } result.State = ConflictState.Normal; foreach (var logEntry in logEntries) { var logPath = logEntry.AffectedPaths.FirstOrDefault(ap => ap.Path.StartsWith(targetRelativeURL)); // If not found in the affected paths -> this is the log entry of the branch copy. if (string.IsNullOrEmpty(logPath.Path)) { continue; } result.State = ConflictState.Conflicted; // Don't consider folder children for "Added" and "Deleted". Folders are just modified by their children. if (logPath.Path != targetRelativeURL) { continue; } if (logPath.Added || logPath.Replaced) { result.State = ConflictState.Added; break; } if (logPath.Deleted) { result.State = ConflictState.Missing; break; } } results[i] = result; } }
public override void OnActionExecuting(HttpActionContext actionContext) { _RequestStopWatch.Start(); _ModuleId = (int)Module; _RequestUri = actionContext.Request.RequestUri.AbsolutePath; _UserId = actionContext.ControllerContext.Request.Properties["UserID"].ToString().ToNumber <int>(); _UnId = actionContext.ControllerContext.Request.Properties["UnID"].ToString().ToNumber <int>(); _SubUserId = actionContext.ControllerContext.Request.Properties["SubUserID"].ToString().ToNumber <int>(); //_Ip = actionContext.ControllerContext.Request.Headers.Referrer.Host; _Ip = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; //_Ip = (actionContext.Request.Properties["MS_OwinContext"] as OwinContext).Request.RemoteIpAddress; //.Request.RemoteIpAddress; var actionArgs = actionContext.ActionArguments; /*Request ის პარამეტრების ლოგირება*/ if (actionArgs.Count != 0 && !string.IsNullOrWhiteSpace(LogParams)) { var paramsArray = new List <string>(); var searchKeys = LogParams.Split(','); foreach (var k in searchKeys) { /*request ის პარამეტრის object*/ var requestParamsObj = actionContext.ActionArguments.FirstOrDefault().Value; var requestParamsJObj = requestParamsObj as JObject; var searchSubKeys = k.Split('.'); if (requestParamsJObj != null) { var jObjValFromRequestParams = requestParamsJObj[searchSubKeys[0]] as JToken; for (int i = 1; i < searchSubKeys.Length; i++) { if (jObjValFromRequestParams == null || jObjValFromRequestParams is JArray) { break; } jObjValFromRequestParams = jObjValFromRequestParams.Value <JToken>(searchSubKeys[i]); } var jTokenFromRequestParams = jObjValFromRequestParams is JValue ? jObjValFromRequestParams : null; if (jTokenFromRequestParams != null) { var path = jTokenFromRequestParams.Path; var value = (jTokenFromRequestParams as JValue).Value.ToString(); paramsArray.Add($"{path}:{value}"); } } } if (paramsArray.Any()) { _RequestParams = paramsArray.Aggregate((current, next) => current + ", " + next); } else { _RequestParams = "ERROR"; } } }
private async Task EditMapping(FinancialStatementContext db, TMapping existingMapping, TViewModel model, LogParams logParams) { var logEntries = new List <LogParams>(); try { var existingModel = await GetSingleModel(db, model.RowId); var checkErrors = await CheckRestrictionsOnEdit(db, existingModel, model); if (checkErrors.Any()) { throw new PublicException("Mapping edit failed due to locks: " + JoinErrors(checkErrors)); } logEntries.AddRange(EditMappingFunc(db, existingMapping, existingModel, model)); existingMapping.ModifiedOn = DateTime.Now; existingMapping.ModifiedUser = logParams.AdUsername; await db.SaveChangesAsync(); } catch (Exception ex) { if (SqlExceptionHelper.IsUniqueConstraintError(ex)) { throw new PublicException(UniqueConstraintErrorText, ex); } throw new PublicException(EditingErrorText, ex); } foreach (var logEntry in logEntries) { logEntry.ActionType = EditingActionType; logEntry.AdUsername = logParams.AdUsername; logEntry.RemoteAddress = logParams.RemoteAddress; await SaveLog(db, logEntry); } }
/// <exception cref="System.Exception"/> public virtual int Run(string[] argv) { int exitCode = -1; if (argv.Length < 1) { DisplayUsage(string.Empty); return(exitCode); } // process arguments string cmd = argv[0]; string submitJobFile = null; string jobid = null; string taskid = null; string historyFile = null; string counterGroupName = null; string counterName = null; JobPriority jp = null; string taskType = null; string taskState = null; int fromEvent = 0; int nEvents = 0; bool getStatus = false; bool getCounter = false; bool killJob = false; bool listEvents = false; bool viewHistory = false; bool viewAllHistory = false; bool listJobs = false; bool listAllJobs = false; bool listActiveTrackers = false; bool listBlacklistedTrackers = false; bool displayTasks = false; bool killTask = false; bool failTask = false; bool setJobPriority = false; bool logs = false; if ("-submit".Equals(cmd)) { if (argv.Length != 2) { DisplayUsage(cmd); return(exitCode); } submitJobFile = argv[1]; } else { if ("-status".Equals(cmd)) { if (argv.Length != 2) { DisplayUsage(cmd); return(exitCode); } jobid = argv[1]; getStatus = true; } else { if ("-counter".Equals(cmd)) { if (argv.Length != 4) { DisplayUsage(cmd); return(exitCode); } getCounter = true; jobid = argv[1]; counterGroupName = argv[2]; counterName = argv[3]; } else { if ("-kill".Equals(cmd)) { if (argv.Length != 2) { DisplayUsage(cmd); return(exitCode); } jobid = argv[1]; killJob = true; } else { if ("-set-priority".Equals(cmd)) { if (argv.Length != 3) { DisplayUsage(cmd); return(exitCode); } jobid = argv[1]; try { jp = JobPriority.ValueOf(argv[2]); } catch (ArgumentException iae) { Log.Info(iae); DisplayUsage(cmd); return(exitCode); } setJobPriority = true; } else { if ("-events".Equals(cmd)) { if (argv.Length != 4) { DisplayUsage(cmd); return(exitCode); } jobid = argv[1]; fromEvent = System.Convert.ToInt32(argv[2]); nEvents = System.Convert.ToInt32(argv[3]); listEvents = true; } else { if ("-history".Equals(cmd)) { if (argv.Length != 2 && !(argv.Length == 3 && "all".Equals(argv[1]))) { DisplayUsage(cmd); return(exitCode); } viewHistory = true; if (argv.Length == 3 && "all".Equals(argv[1])) { viewAllHistory = true; historyFile = argv[2]; } else { historyFile = argv[1]; } } else { if ("-list".Equals(cmd)) { if (argv.Length != 1 && !(argv.Length == 2 && "all".Equals(argv[1]))) { DisplayUsage(cmd); return(exitCode); } if (argv.Length == 2 && "all".Equals(argv[1])) { listAllJobs = true; } else { listJobs = true; } } else { if ("-kill-task".Equals(cmd)) { if (argv.Length != 2) { DisplayUsage(cmd); return(exitCode); } killTask = true; taskid = argv[1]; } else { if ("-fail-task".Equals(cmd)) { if (argv.Length != 2) { DisplayUsage(cmd); return(exitCode); } failTask = true; taskid = argv[1]; } else { if ("-list-active-trackers".Equals(cmd)) { if (argv.Length != 1) { DisplayUsage(cmd); return(exitCode); } listActiveTrackers = true; } else { if ("-list-blacklisted-trackers".Equals(cmd)) { if (argv.Length != 1) { DisplayUsage(cmd); return(exitCode); } listBlacklistedTrackers = true; } else { if ("-list-attempt-ids".Equals(cmd)) { if (argv.Length != 4) { DisplayUsage(cmd); return(exitCode); } jobid = argv[1]; taskType = argv[2]; taskState = argv[3]; displayTasks = true; if (!taskTypes.Contains(StringUtils.ToUpperCase(taskType))) { System.Console.Out.WriteLine("Error: Invalid task-type: " + taskType); DisplayUsage(cmd); return(exitCode); } if (!taskStates.Contains(StringUtils.ToLowerCase(taskState))) { System.Console.Out.WriteLine("Error: Invalid task-state: " + taskState); DisplayUsage(cmd); return(exitCode); } } else { if ("-logs".Equals(cmd)) { if (argv.Length == 2 || argv.Length == 3) { logs = true; jobid = argv[1]; if (argv.Length == 3) { taskid = argv[2]; } else { taskid = null; } } else { DisplayUsage(cmd); return(exitCode); } } else { DisplayUsage(cmd); return(exitCode); } } } } } } } } } } } } } } // initialize cluster cluster = CreateCluster(); // Submit the request try { if (submitJobFile != null) { Job job = Job.GetInstance(new JobConf(submitJobFile)); job.Submit(); System.Console.Out.WriteLine("Created job " + job.GetJobID()); exitCode = 0; } else { if (getStatus) { Job job = cluster.GetJob(JobID.ForName(jobid)); if (job == null) { System.Console.Out.WriteLine("Could not find job " + jobid); } else { Counters counters = job.GetCounters(); System.Console.Out.WriteLine(); System.Console.Out.WriteLine(job); if (counters != null) { System.Console.Out.WriteLine(counters); } else { System.Console.Out.WriteLine("Counters not available. Job is retired."); } exitCode = 0; } } else { if (getCounter) { Job job = cluster.GetJob(JobID.ForName(jobid)); if (job == null) { System.Console.Out.WriteLine("Could not find job " + jobid); } else { Counters counters = job.GetCounters(); if (counters == null) { System.Console.Out.WriteLine("Counters not available for retired job " + jobid); exitCode = -1; } else { System.Console.Out.WriteLine(GetCounter(counters, counterGroupName, counterName)); exitCode = 0; } } } else { if (killJob) { Job job = cluster.GetJob(JobID.ForName(jobid)); if (job == null) { System.Console.Out.WriteLine("Could not find job " + jobid); } else { JobStatus jobStatus = job.GetStatus(); if (jobStatus.GetState() == JobStatus.State.Failed) { System.Console.Out.WriteLine("Could not mark the job " + jobid + " as killed, as it has already failed." ); exitCode = -1; } else { if (jobStatus.GetState() == JobStatus.State.Killed) { System.Console.Out.WriteLine("The job " + jobid + " has already been killed."); exitCode = -1; } else { if (jobStatus.GetState() == JobStatus.State.Succeeded) { System.Console.Out.WriteLine("Could not kill the job " + jobid + ", as it has already succeeded." ); exitCode = -1; } else { job.KillJob(); System.Console.Out.WriteLine("Killed job " + jobid); exitCode = 0; } } } } } else { if (setJobPriority) { Job job = cluster.GetJob(JobID.ForName(jobid)); if (job == null) { System.Console.Out.WriteLine("Could not find job " + jobid); } else { job.SetPriority(jp); System.Console.Out.WriteLine("Changed job priority."); exitCode = 0; } } else { if (viewHistory) { ViewHistory(historyFile, viewAllHistory); exitCode = 0; } else { if (listEvents) { ListEvents(cluster.GetJob(JobID.ForName(jobid)), fromEvent, nEvents); exitCode = 0; } else { if (listJobs) { ListJobs(cluster); exitCode = 0; } else { if (listAllJobs) { ListAllJobs(cluster); exitCode = 0; } else { if (listActiveTrackers) { ListActiveTrackers(cluster); exitCode = 0; } else { if (listBlacklistedTrackers) { ListBlacklistedTrackers(cluster); exitCode = 0; } else { if (displayTasks) { DisplayTasks(cluster.GetJob(JobID.ForName(jobid)), taskType, taskState); exitCode = 0; } else { if (killTask) { TaskAttemptID taskID = TaskAttemptID.ForName(taskid); Job job = cluster.GetJob(taskID.GetJobID()); if (job == null) { System.Console.Out.WriteLine("Could not find job " + jobid); } else { if (job.KillTask(taskID, false)) { System.Console.Out.WriteLine("Killed task " + taskid); exitCode = 0; } else { System.Console.Out.WriteLine("Could not kill task " + taskid); exitCode = -1; } } } else { if (failTask) { TaskAttemptID taskID = TaskAttemptID.ForName(taskid); Job job = cluster.GetJob(taskID.GetJobID()); if (job == null) { System.Console.Out.WriteLine("Could not find job " + jobid); } else { if (job.KillTask(taskID, true)) { System.Console.Out.WriteLine("Killed task " + taskID + " by failing it"); exitCode = 0; } else { System.Console.Out.WriteLine("Could not fail task " + taskid); exitCode = -1; } } } else { if (logs) { try { JobID jobID = JobID.ForName(jobid); TaskAttemptID taskAttemptID = TaskAttemptID.ForName(taskid); LogParams logParams = cluster.GetLogParams(jobID, taskAttemptID); LogCLIHelpers logDumper = new LogCLIHelpers(); logDumper.SetConf(GetConf()); exitCode = logDumper.DumpAContainersLogs(logParams.GetApplicationId(), logParams. GetContainerId(), logParams.GetNodeId(), logParams.GetOwner()); } catch (IOException e) { if (e is RemoteException) { throw; } System.Console.Out.WriteLine(e.Message); } } } } } } } } } } } } } } } } } catch (RemoteException re) { IOException unwrappedException = re.UnwrapRemoteException(); if (unwrappedException is AccessControlException) { System.Console.Out.WriteLine(unwrappedException.Message); } else { throw; } } finally { cluster.Close(); } return(exitCode); }
private async Task AddMapping(FinancialStatementContext db, TViewModel model, LogParams logParams) { try { model.ModifiedOn = DateTime.Now; model.ModifiedUser = logParams.AdUsername; AddMappingFunc(db, model); await db.SaveChangesAsync(); } catch (Exception ex) { if (SqlExceptionHelper.IsUniqueConstraintError(ex)) { throw new PublicException(UniqueConstraintErrorText, ex); } throw new PublicException(CreatingErrorText, ex); } logParams.ActionType = CreatingActionType; logParams.Details = GetDetailsForLog(model); await SaveLog(db, logParams); }