Package org.apache.oozie.util

Examples of org.apache.oozie.util.XLog


                    if (runningJob.isSuccessful() && LauncherMapper.isMainSuccessful(runningJob)) {
                        getActionData(actionFs, runningJob, action, context);
                        XLog.getLog(getClass()).info(XLog.STD, "action produced output");
                    }
                    else {
                        XLog log = XLog.getLog(getClass());
                        String errorReason;
                        Path actionError = LauncherMapper.getErrorPath(context.getActionDir());
                        if (actionFs.exists(actionError)) {
                            InputStream is = actionFs.open(actionError);
                            BufferedReader reader = new BufferedReader(new InputStreamReader(is));
                            Properties props = PropertiesUtils.readProperties(reader, -1);
                            reader.close();
                            String errorCode = props.getProperty("error.code");
                            if (errorCode.equals("0")) {
                                errorCode = "JA018";
                            }
                            if (errorCode.equals("-1")) {
                                errorCode = "JA019";
                            }
                            errorReason = props.getProperty("error.reason");
                            log.warn("Launcher ERROR, reason: {0}", errorReason);
                            String exMsg = props.getProperty("exception.message");
                            String errorInfo = (exMsg != null) ? exMsg : errorReason;
                            context.setErrorInfo(errorCode, errorInfo);
                            String exStackTrace = props.getProperty("exception.stacktrace");
                            if (exMsg != null) {
                                log.warn("Launcher exception: {0}{E}{1}", exMsg, exStackTrace);
                            }
                        }
                        else {
                            errorReason = XLog.format("LauncherMapper died, check Hadoop log for job [{0}:{1}]", action
                                    .getTrackerUri(), action.getExternalId());
                            log.warn(errorReason);
                        }
                        context.setExecutionData(FAILED_KILLED, null);
                    }
                }
                else {
                    context.setExternalStatus(RUNNING);
                    XLog.getLog(getClass()).info(XLog.STD, "checking action, external ID [{0}] status [{1}]",
                            action.getExternalId(), action.getExternalStatus());
                }
            }
            else {
                context.setExternalStatus(RUNNING);
                XLog.getLog(getClass()).info(XLog.STD, "checking action, external ID [{0}] status [{1}]",
                        action.getExternalId(), action.getExternalStatus());
            }
        }
        catch (Exception ex) {
            XLog.getLog(getClass()).warn("Exception in check(). Message[{0}]", ex.getMessage(), ex);
            exception = true;
            throw convertException(ex);
        }
        finally {
            if (jobClient != null) {
                try {
                    jobClient.close();
                }
                catch (Exception e) {
                    if (exception) {
                        log.error("JobClient error: ", e);
                    }
                    else {
                        throw convertException(e);
                    }
                }
View Full Code Here


            this.nameIndex = id + ":" + nameIndex;
            this.sb = buffer;
        }

        public void run() {
            XLog log = XLog.getLog(getClass());
            try {
                WorkflowStore store = Services.get().get(WorkflowStoreService.class).create();
                log.info("Get [{0}]", nameIndex);
                store.beginTrx();
                store.getWorkflow(id, false);
                log.info("Got [{0}]", nameIndex);
                sb.append(nameIndex + "-L ");
                synchronized (this) {
                    wait();
                }
                sb.append(nameIndex + "-U ");
                store.commitTrx();
                store.closeTrx();
                log.info("Release [{0}]", nameIndex);
            }
            catch (Exception ex) {
                throw new RuntimeException(ex);
            }
        }
View Full Code Here

            this.bundleOlderThan = bundleOlderThan;
        }

        public void run() {
            XLog.Info.get().clear();
            XLog log = XLog.getLog(getClass());
            msg = new StringBuilder();
            jpaService = Services.get().get(JPAService.class);
            runWFRecovery();
            runCoordActionRecovery();
            runCoordActionRecoveryForReady();
            runBundleRecovery();
            log.debug("QUEUING [{0}] for potential recovery", msg.toString());
            boolean ret = false;
            if (null != callables) {
                ret = Services.get().get(CallableQueueService.class).queueSerial(callables);
                if (ret == false) {
                    log.warn("Unable to queue the callables commands for RecoveryService. "
                            + "Most possibly command queue is full. Queue size is :"
                            + Services.get().get(CallableQueueService.class).queueSize());
                }
                callables = null;
            }
            if (null != delayedCallables) {
                ret = Services.get().get(CallableQueueService.class).queueSerial(delayedCallables, this.delay);
                if (ret == false) {
                    log.warn("Unable to queue the delayedCallables commands for RecoveryService. "
                            + "Most possibly Callable queue is full. Queue size is :"
                            + Services.get().get(CallableQueueService.class).queueSize());
                }
                delayedCallables = null;
                this.delay = 0;
View Full Code Here

            }
        }

        private void runBundleRecovery(){
            XLog.Info.get().clear();
            XLog log = XLog.getLog(getClass());

            try {
                List<BundleActionBean> bactions = jpaService.execute(new BundleActionsGetWaitingOlderJPAExecutor(bundleOlderThan));
                msg.append(", BUNDLE_ACTIONS : " + bactions.size());
                for (BundleActionBean baction : bactions) {
                    Services.get().get(InstrumentationService.class).get().incr(INSTRUMENTATION_GROUP,
                            INSTR_RECOVERED_BUNDLE_ACTIONS_COUNTER, 1);
                    if(baction.getStatus() == Job.Status.PREP){
                        BundleJobBean bundleJob = null;
                        try {
                            if (jpaService != null) {
                                bundleJob = jpaService.execute(new BundleJobGetJPAExecutor(baction.getBundleId()));
                            }
                            if(bundleJob != null){
                                Element bAppXml = XmlUtils.parseXml(bundleJob.getJobXml());
                                List<Element> coordElems = bAppXml.getChildren("coordinator", bAppXml.getNamespace());
                                for (Element coordElem : coordElems) {
                                    Attribute name = coordElem.getAttribute("name");
                                    if (name.getValue().equals(baction.getCoordName())) {
                                        Configuration coordConf = mergeConfig(coordElem,bundleJob);
                                        coordConf.set(OozieClient.BUNDLE_ID, baction.getBundleId());
                                        queueCallable(new CoordSubmitXCommand(coordConf, bundleJob.getAuthToken(), bundleJob.getId(), name.getValue()));
                                    }
                                }
                            }
                        }
                        catch (JDOMException jex) {
                            throw new CommandException(ErrorCode.E1301, jex);
                        }
                        catch (JPAExecutorException je) {
                            throw new CommandException(je);
                        }
                    }
                    else if(baction.getStatus() == Job.Status.KILLED){
                        queueCallable(new CoordKillXCommand(baction.getCoordId()));
                    }
                    else if(baction.getStatus() == Job.Status.SUSPENDED){
                        queueCallable(new CoordSuspendXCommand(baction.getCoordId()));
                    }
                    else if(baction.getStatus() == Job.Status.RUNNING){
                        queueCallable(new CoordResumeXCommand(baction.getCoordId()));
                    }
                }
            }
            catch (Exception ex) {
                log.error("Exception, {0}", ex.getMessage(), ex);
            }
        }
View Full Code Here

        /**
         * Recover coordinator actions that are staying in WAITING or SUBMITTED too long
         */
        private void runCoordActionRecovery() {
            XLog.Info.get().clear();
            XLog log = XLog.getLog(getClass());

            try {
                List<CoordinatorActionBean> cactions = jpaService.execute(new CoordActionsGetForRecoveryJPAExecutor(coordOlderThan));
                msg.append(", COORD_ACTIONS : " + cactions.size());
                for (CoordinatorActionBean caction : cactions) {
                    Services.get().get(InstrumentationService.class).get().incr(INSTRUMENTATION_GROUP,
                                                                                INSTR_RECOVERED_COORD_ACTIONS_COUNTER, 1);
                    if (caction.getStatus() == CoordinatorActionBean.Status.WAITING) {
            queueCallable(new CoordActionInputCheckXCommand(
                caction.getId(), caction.getJobId()));

            log.info("Recover a WAITTING coord action and resubmit CoordActionInputCheckXCommand :"
                + caction.getId());
                    }
                    else if (caction.getStatus() == CoordinatorActionBean.Status.SUBMITTED) {
                        CoordinatorJobBean coordJob = jpaService.execute(new CoordJobGetJPAExecutor(caction.getJobId()));
            queueCallable(new CoordActionStartXCommand(
                caction.getId(), coordJob.getUser(),
                coordJob.getAuthToken(), caction.getJobId()));

                        log.info("Recover a SUBMITTED coord action and resubmit CoordActionStartCommand :" + caction.getId());
                    }
                    else if (caction.getStatus() == CoordinatorActionBean.Status.SUSPENDED) {
                        if (caction.getExternalId() != null) {
                            queueCallable(new SuspendXCommand(caction.getExternalId()));
                            log.debug("Recover a SUSPENDED coord action and resubmit SuspendXCommand :" + caction.getId());
                        }
                    }
                    else if (caction.getStatus() == CoordinatorActionBean.Status.KILLED) {
                        if (caction.getExternalId() != null) {
                            queueCallable(new KillXCommand(caction.getExternalId()));
                            log.debug("Recover a KILLED coord action and resubmit KillXCommand :" + caction.getId());
                        }
                    }
                    else if (caction.getStatus() == CoordinatorActionBean.Status.RUNNING) {
                        if (caction.getExternalId() != null) {
                            queueCallable(new ResumeXCommand(caction.getExternalId()));
                            log.debug("Recover a RUNNING coord action and resubmit ResumeXCommand :" + caction.getId());
                        }
                    }
                }
            }
            catch (Exception ex) {
                log.error("Exception, {0}", ex.getMessage(), ex);
            }
        }
View Full Code Here

        /**
         * Recover coordinator actions that are staying in READY too long
         */
        private void runCoordActionRecoveryForReady() {
            XLog.Info.get().clear();
            XLog log = XLog.getLog(getClass());

            try {
                List<String> jobids = jpaService.execute(new CoordActionsGetReadyGroupbyJobIDJPAExecutor(coordOlderThan));
                msg.append(", COORD_READY_JOBS : " + jobids.size());
                for (String jobid : jobids) {
                        queueCallable(new CoordActionReadyXCommand(jobid));

                    log.info("Recover READY coord actions for jobid :" + jobid);
                }
            }
            catch (Exception ex) {
                log.error("Exception, {0}", ex.getMessage(), ex);
            }
        }
View Full Code Here

        /**
         * Recover wf actions
         */
        private void runWFRecovery() {
            XLog.Info.get().clear();
            XLog log = XLog.getLog(getClass());
            // queue command for action recovery
            try {
                List<WorkflowActionBean> actions = null;
                try {
                    actions = jpaService.execute(new WorkflowActionsGetPendingJPAExecutor(olderThan));
                }
                catch (JPAExecutorException ex) {
                    log.warn("Exception while reading pending actions from storage", ex);
                }
                //log.debug("QUEUING[{0}] pending wf actions for potential recovery", actions.size());
                msg.append(" WF_ACTIONS " + actions.size());

                for (WorkflowActionBean action : actions) {
                    Services.get().get(InstrumentationService.class).get().incr(INSTRUMENTATION_GROUP,
                            INSTR_RECOVERED_ACTIONS_COUNTER, 1);
                    if (action.getStatus() == WorkflowActionBean.Status.PREP
                            || action.getStatus() == WorkflowActionBean.Status.START_MANUAL) {
            queueCallable(new ActionStartXCommand(action.getId(),
                action.getType()));
                    }
                    else if (action.getStatus() == WorkflowActionBean.Status.START_RETRY) {
                        Date nextRunTime = action.getPendingAge();
                            queueCallable(new ActionStartXCommand(action.getId(), action.getType()), nextRunTime.getTime()
                                    - System.currentTimeMillis());
                    }
                    else if (action.getStatus() == WorkflowActionBean.Status.DONE
                            || action.getStatus() == WorkflowActionBean.Status.END_MANUAL) {
                            queueCallable(new ActionEndXCommand(action.getId(), action.getType()));
                    }
                    else if (action.getStatus() == WorkflowActionBean.Status.END_RETRY) {
                        Date nextRunTime = action.getPendingAge();
            queueCallable(new ActionEndXCommand(action.getId(),
                action.getType()), nextRunTime.getTime()
                - System.currentTimeMillis());

                    }
                    else if (action.getStatus() == WorkflowActionBean.Status.OK
                            || action.getStatus() == WorkflowActionBean.Status.ERROR) {
            queueCallable(new SignalXCommand(action.getJobId(),
                action.getId()));
                    }
                    else if (action.getStatus() == WorkflowActionBean.Status.USER_RETRY) {
            queueCallable(new ActionStartXCommand(action.getId(),
                action.getType()));
                    }
                }
            }
            catch (Exception ex) {
                log.error("Exception, {0}", ex.getMessage(), ex);
            }
        }
View Full Code Here

            this.actionCheckDelay = actionCheckDelay;
        }

        public void run() {
            XLog.Info.get().clear();
            XLog LOG = XLog.getLog(getClass());
            msg = new StringBuilder();
            try {
                runWFActionCheck();
                runCoordActionCheck();
            }
            catch (CommandException ce) {
                LOG.error("Unable to run action checks, ", ce);
            }

            LOG.debug("QUEUING [{0}] for potential checking", msg.toString());
            if (null != callables) {
                boolean ret = Services.get().get(CallableQueueService.class).queueSerial(callables);
                if (ret == false) {
                    LOG.warn("Unable to queue the callables commands for CheckerService. "
                            + "Most possibly command queue is full. Queue size is :"
                            + Services.get().get(CallableQueueService.class).queueSize());
                }
                callables = null;
            }
View Full Code Here

            TOTAL_REQUESTS_SAMPLER_COUNTER.incrementAndGet();
            samplerCounter.incrementAndGet();
            super.service(request, response);
        }
        catch (XServletException ex) {
            XLog log = XLog.getLog(getClass());
            log.warn("URL[{0} {1}] error[{2}], {3}", request.getMethod(), getRequestUrl(request), ex.getErrorCode(), ex
                    .getMessage(), ex);
            request.setAttribute(AUDIT_ERROR_MESSAGE, ex.getMessage());
            request.setAttribute(AUDIT_ERROR_CODE, ex.getErrorCode().toString());
            request.setAttribute(AUDIT_HTTP_STATUS_CODE, ex.getHttpStatusCode());
            incrCounter(INSTR_TOTAL_FAILED_REQUESTS_COUNTER, 1);
            sendErrorResponse(response, ex.getHttpStatusCode(), ex.getErrorCode().toString(), ex.getMessage());
        }
        catch (AccessControlException ex) {
            XLog log = XLog.getLog(getClass());
            log.error("URL[{0} {1}] error, {2}", request.getMethod(), getRequestUrl(request), ex.getMessage(), ex);
            incrCounter(INSTR_TOTAL_FAILED_REQUESTS_COUNTER, 1);
            sendErrorResponse(response, HttpServletResponse.SC_UNAUTHORIZED, ErrorCode.E1400.toString(),
                              ex.getMessage());
        }
        catch (RuntimeException ex) {
            XLog log = XLog.getLog(getClass());
            log.error("URL[{0} {1}] error, {2}", request.getMethod(), getRequestUrl(request), ex.getMessage(), ex);
            incrCounter(INSTR_TOTAL_FAILED_REQUESTS_COUNTER, 1);
            throw ex;
        }
        finally {
            logAuditInfo(request);
View Full Code Here

            else {
                interval = Long.parseLong(System.getProperty(LOG4J_RELOAD, DEFAULT_RELOAD_INTERVAL));
                PropertyConfigurator.configureAndWatch(log4jFile.toString(), interval * 1000);
            }

            log = new XLog(LogFactory.getLog(getClass()));

            log.info(XLog.OPS, STARTUP_MESSAGE, BuildInfo.getBuildInfo().getProperty(BuildInfo.BUILD_VERSION),
                    BuildInfo.getBuildInfo().getProperty(BuildInfo.BUILD_USER_NAME), BuildInfo.getBuildInfo()
                            .getProperty(BuildInfo.BUILD_TIME), BuildInfo.getBuildInfo().getProperty(
                            BuildInfo.BUILD_VC_REVISION), BuildInfo.getBuildInfo().getProperty(BuildInfo.BUILD_VC_URL));
View Full Code Here

TOP

Related Classes of org.apache.oozie.util.XLog

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.