示例#1
0
        public virtual void Handle(LogHandlerEvent @event)
        {
            switch (@event.GetType())
            {
            case LogHandlerEventType.ApplicationStarted:
            {
                LogHandlerAppStartedEvent appStartEvent = (LogHandlerAppStartedEvent)@event;
                InitApp(appStartEvent.GetApplicationId(), appStartEvent.GetUser(), appStartEvent.
                        GetCredentials(), appStartEvent.GetLogRetentionPolicy(), appStartEvent.GetApplicationAcls
                            (), appStartEvent.GetLogAggregationContext());
                break;
            }

            case LogHandlerEventType.ContainerFinished:
            {
                LogHandlerContainerFinishedEvent containerFinishEvent = (LogHandlerContainerFinishedEvent
                                                                         )@event;
                StopContainer(containerFinishEvent.GetContainerId(), containerFinishEvent.GetExitCode
                                  ());
                break;
            }

            case LogHandlerEventType.ApplicationFinished:
            {
                LogHandlerAppFinishedEvent appFinishedEvent = (LogHandlerAppFinishedEvent)@event;
                StopApp(appFinishedEvent.GetApplicationId());
                break;
            }

            default:
            {
                break;
            }
            }
        }
示例#2
0
            public void Handle(LogHandlerEvent @event)
            {
                switch (@event.GetType())
                {
                case LogHandlerEventType.ApplicationStarted:
                {
                    break;
                }

                case LogHandlerEventType.ContainerFinished:
                {
                    break;
                }

                case LogHandlerEventType.ApplicationFinished:
                {
                    break;
                }

                default:
                {
                    break;
                }
                }
            }
示例#3
0
        public virtual void Handle(LogHandlerEvent @event)
        {
            switch (@event.GetType())
            {
            case LogHandlerEventType.ApplicationStarted:
            {
                LogHandlerAppStartedEvent appStartedEvent = (LogHandlerAppStartedEvent)@event;
                this.appOwners[appStartedEvent.GetApplicationId()] = appStartedEvent.GetUser();
                this.dispatcher.GetEventHandler().Handle(new ApplicationEvent(appStartedEvent.GetApplicationId
                                                                                  (), ApplicationEventType.ApplicationLogHandlingInited));
                break;
            }

            case LogHandlerEventType.ContainerFinished:
            {
                // Ignore
                break;
            }

            case LogHandlerEventType.ApplicationFinished:
            {
                LogHandlerAppFinishedEvent appFinishedEvent = (LogHandlerAppFinishedEvent)@event;
                ApplicationId appId = appFinishedEvent.GetApplicationId();
                // Schedule - so that logs are available on the UI till they're deleted.
                Log.Info("Scheduling Log Deletion for application: " + appId + ", with delay of "
                         + this.deleteDelaySeconds + " seconds");
                string user = Sharpen.Collections.Remove(appOwners, appId);
                if (user == null)
                {
                    Log.Error("Unable to locate user for " + appId);
                    break;
                }
                NonAggregatingLogHandler.LogDeleterRunnable logDeleter = new NonAggregatingLogHandler.LogDeleterRunnable
                                                                             (this, user, appId);
                long deletionTimestamp = Runtime.CurrentTimeMillis() + this.deleteDelaySeconds *
                                         1000;
                YarnServerNodemanagerRecoveryProtos.LogDeleterProto deleterProto = ((YarnServerNodemanagerRecoveryProtos.LogDeleterProto
                                                                                     )YarnServerNodemanagerRecoveryProtos.LogDeleterProto.NewBuilder().SetUser(user).
                                                                                    SetDeletionTime(deletionTimestamp).Build());
                try
                {
                    stateStore.StoreLogDeleter(appId, deleterProto);
                }
                catch (IOException e)
                {
                    Log.Error("Unable to record log deleter state", e);
                }
                try
                {
                    sched.Schedule(logDeleter, this.deleteDelaySeconds, TimeUnit.Seconds);
                }
                catch (RejectedExecutionException)
                {
                    // Handling this event in local thread before starting threads
                    // or after calling sched.shutdownNow().
                    logDeleter.Run();
                }
                break;
            }

            default:
            {
                break;
            }
            }
        }