Search in sources :

Example 11 with IThrowableProxy

use of ch.qos.logback.classic.spi.IThrowableProxy in project cdap by caskdata.

the class ThrowableProxyArraySerializer method decode.

static IThrowableProxy[] decode(GenericArray<GenericRecord> datum) {
    if (datum != null) {
        IThrowableProxy[] throwableProxies = new IThrowableProxy[datum.size()];
        int i = 0;
        for (GenericRecord aDatum : datum) {
            throwableProxies[i++] = ThrowableProxySerializer.decode(aDatum);
        }
        return throwableProxies;
    }
    return null;
}
Also used : IThrowableProxy(ch.qos.logback.classic.spi.IThrowableProxy) GenericRecord(org.apache.avro.generic.GenericRecord)

Example 12 with IThrowableProxy

use of ch.qos.logback.classic.spi.IThrowableProxy in project cdap by caskdata.

the class ThrowableProxyArraySerializer method encode.

static GenericArray<GenericRecord> encode(Schema schema, IThrowableProxy[] throwableProxies) {
    if (throwableProxies != null) {
        Schema tpArraySchema = schema.getTypes().get(1);
        GenericArray<GenericRecord> steArray = new GenericData.Array<>(throwableProxies.length, tpArraySchema);
        for (IThrowableProxy tp : throwableProxies) {
            steArray.add(ThrowableProxySerializer.encode(tpArraySchema.getElementType(), tp));
        }
        return steArray;
    }
    return null;
}
Also used : GenericArray(org.apache.avro.generic.GenericArray) IThrowableProxy(ch.qos.logback.classic.spi.IThrowableProxy) Schema(org.apache.avro.Schema) GenericRecord(org.apache.avro.generic.GenericRecord)

Example 13 with IThrowableProxy

use of ch.qos.logback.classic.spi.IThrowableProxy in project Saturn by vipshop.

the class LocalModeIT method test_D_fixIssue441.

@Test
public void test_D_fixIssue441() throws Exception {
    LogbackListAppender logbackListAppender = new LogbackListAppender();
    logbackListAppender.addToLogger(AbstractAsyncShardingTask.class);
    logbackListAppender.start();
    final int items = 4;
    final String jobName = "test_D_fixIssue441";
    JobConfig jobConfig = new JobConfig();
    jobConfig.setJobName(jobName);
    jobConfig.setCron("*/1 * * * * ?");
    jobConfig.setJobType(JobType.JAVA_JOB.toString());
    jobConfig.setProcessCountIntervalSeconds(1);
    jobConfig.setJobClass(SimpleJavaJob.class.getCanonicalName());
    jobConfig.setShardingItemParameters("*=0");
    jobConfig.setLocalMode(true);
    addJob(jobConfig);
    Thread.sleep(1000);
    enableJob(jobName);
    Thread.sleep(1000);
    startExecutorList(items);
    waitForFinish(new FinishCheck() {

        @Override
        public boolean isOk() {
            for (int i = 0; i < items; i++) {
                if (SimpleJavaJob.statusMap.get(jobName + "_" + i) <= 0) {
                    return false;
                }
            }
            return true;
        }
    }, 30);
    // 下线0,1,2
    stopExecutorGracefully(0);
    stopExecutorGracefully(1);
    stopExecutorGracefully(2);
    // 上线一个executor
    startOneNewExecutorList();
    List<ILoggingEvent> allLogs = logbackListAppender.getAllLogs();
    Iterator<ILoggingEvent> iterator = allLogs.iterator();
    while (iterator.hasNext()) {
        ILoggingEvent event = iterator.next();
        if (event != null) {
            IThrowableProxy throwableProxy = event.getThrowableProxy();
            if (throwableProxy != null) {
                assertThat(throwableProxy.getClassName()).isNotEqualTo("java.lang.ArrayIndexOutOfBoundsException");
            }
        }
    }
    disableJob(jobName);
    Thread.sleep(1000);
    removeJob(jobName);
}
Also used : LogbackListAppender(com.vip.saturn.it.utils.LogbackListAppender) IThrowableProxy(ch.qos.logback.classic.spi.IThrowableProxy) FinishCheck(com.vip.saturn.it.base.FinishCheck) SimpleJavaJob(com.vip.saturn.it.job.SimpleJavaJob) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent) JobConfig(com.vip.saturn.job.console.domain.JobConfig)

Example 14 with IThrowableProxy

use of ch.qos.logback.classic.spi.IThrowableProxy in project webpieces by deanhiller.

the class ThrowableUtil method recursiveAppend.

private void recursiveAppend(StringBuilder sb, String prefix, int indent, IThrowableProxy tp) {
    if (tp == null)
        return;
    subjoinFirstLine(sb, prefix, indent, tp);
    sb.append(CoreConstants.LINE_SEPARATOR);
    subjoinSTEPArray(sb, indent, tp);
    IThrowableProxy[] suppressed = tp.getSuppressed();
    if (suppressed != null) {
        for (IThrowableProxy current : suppressed) {
            recursiveAppend(sb, CoreConstants.SUPPRESSED, indent + ThrowableProxyUtil.SUPPRESSED_EXCEPTION_INDENT, current);
        }
    }
    recursiveAppend(sb, CoreConstants.CAUSED_BY, indent, tp.getCause());
}
Also used : IThrowableProxy(ch.qos.logback.classic.spi.IThrowableProxy)

Example 15 with IThrowableProxy

use of ch.qos.logback.classic.spi.IThrowableProxy in project platformlayer by platformlayer.

the class LogbackHook method append.

@Override
protected void append(E e) {
    OpsContext opsContext = OpsContext.get();
    if (opsContext != null) {
        ILoggingEvent event = (ILoggingEvent) e;
        // Note that we can get the unformatted message in getMessage(), presumably along with the parameters...
        String message = event.getFormattedMessage();
        Level level = event.getLevel();
        int levelInt = level.toInt();
        List<String[]> exceptionStacks = null;
        IThrowableProxy throwableInformation = event.getThrowableProxy();
        while (throwableInformation != null) {
            String[] exceptionStackTrace = null;
            StackTraceElementProxy[] trace = throwableInformation.getStackTraceElementProxyArray();
            String exceptionMessage = throwableInformation.getMessage();
            String exceptionClass = throwableInformation.getClassName();
            if (trace != null) {
                exceptionStackTrace = new String[1 + trace.length];
                exceptionStackTrace[0] = exceptionClass + ": " + exceptionMessage;
                for (int i = 0; i < trace.length; i++) {
                    exceptionStackTrace[1 + i] = trace[i].getSTEAsString();
                }
            } else {
                exceptionStackTrace = new String[1];
                exceptionStackTrace[0] = exceptionClass + ": " + exceptionMessage;
            }
            if (exceptionStacks == null) {
                exceptionStacks = Lists.newArrayList();
            }
            exceptionStacks.add(exceptionStackTrace);
            throwableInformation = throwableInformation.getCause();
        }
        if (message != null || exceptionStacks != null) {
            opsContext.getJobLogger().logMessage(message, exceptionStacks, levelInt);
            if (levelInt >= Level.ERROR_INT) {
                // String key = "warn-" + OpsSystem.buildSimpleTimeString() + "-" + (System.nanoTime() % 1000);
                if (opsContext != null) {
                    // && opsContext.getOperation() != null) {
                    if (exceptionStacks != null && !exceptionStacks.isEmpty()) {
                        String[] exceptionStack = exceptionStacks.get(0);
                        if (exceptionStack != null && exceptionStack.length > 0) {
                            message += "; " + exceptionStack[0];
                        }
                    }
                    opsContext.addWarning(null, message);
                }
            }
        }
    }
}
Also used : IThrowableProxy(ch.qos.logback.classic.spi.IThrowableProxy) Level(ch.qos.logback.classic.Level) OpsContext(org.platformlayer.ops.OpsContext) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent) StackTraceElementProxy(ch.qos.logback.classic.spi.StackTraceElementProxy)

Aggregations

IThrowableProxy (ch.qos.logback.classic.spi.IThrowableProxy)16 StackTraceElementProxy (ch.qos.logback.classic.spi.StackTraceElementProxy)4 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)3 GenericRecord (org.apache.avro.generic.GenericRecord)3 ThrowableProxy (ch.qos.logback.classic.spi.ThrowableProxy)2 IOException (java.io.IOException)2 Map (java.util.Map)2 Level (ch.qos.logback.classic.Level)1 LoggingEvent (ch.qos.logback.classic.spi.LoggingEvent)1 Gson (com.google.gson.Gson)1 JsonWriter (com.google.gson.stream.JsonWriter)1 FinishCheck (com.vip.saturn.it.base.FinishCheck)1 SimpleJavaJob (com.vip.saturn.it.job.SimpleJavaJob)1 LogbackListAppender (com.vip.saturn.it.utils.LogbackListAppender)1 JobConfig (com.vip.saturn.job.console.domain.JobConfig)1 StringWriter (java.io.StringWriter)1 LinkedHashMap (java.util.LinkedHashMap)1 Exception (org.apache.airavata.common.logging.Exception)1 LogEntry (org.apache.airavata.common.logging.LogEntry)1 Schema (org.apache.avro.Schema)1