2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowplugin.openflow.md.core;
11 import java.util.Arrays;
12 import java.util.concurrent.LinkedBlockingQueue;
14 import org.opendaylight.openflowplugin.openflow.md.core.session.SessionContext;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
19 * dumping all exceptions to log
22 public class ErrorHandlerQueueImpl implements ErrorHandler {
24 private static final Logger LOG = LoggerFactory
25 .getLogger(ErrorHandlerQueueImpl.class);
27 private LinkedBlockingQueue<Exception> errorQueue;
32 public ErrorHandlerQueueImpl() {
33 this.errorQueue = new LinkedBlockingQueue<>();
41 error = errorQueue.take();
42 Throwable cause = error.getCause();
43 LOG.error(error.getMessage()+" -> "+cause.getMessage(), cause);
44 } catch (InterruptedException e) {
45 LOG.warn(e.getMessage());
51 public void handleException(Throwable e, SessionContext sessionContext) {
52 String sessionKeyId = null;
53 if (sessionContext != null) {
54 sessionKeyId = Arrays.toString(sessionContext.getSessionKey().getId());
57 Exception causeAndThread = new Exception(
58 "IN THREAD: "+Thread.currentThread().getName() +
59 "; session:"+sessionKeyId, e);
61 errorQueue.put(causeAndThread);
62 } catch (InterruptedException e1) {
63 LOG.error(e1.getMessage(), e1);