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;
}
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;
}
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);
}
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());
}
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);
}
}
}
}
}
Aggregations