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
8 package org.opendaylight.controller.netconf.ssh.threads;
10 import ch.ethz.ssh2.ServerConnection;
11 import ch.ethz.ssh2.ServerSession;
12 import java.io.InputStream;
13 import java.io.OutputStream;
14 import javax.annotation.concurrent.ThreadSafe;
15 import org.apache.commons.io.IOUtils;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
20 public class IOThread extends Thread {
22 private static final Logger logger = LoggerFactory.getLogger(IOThread.class);
24 private InputStream inputStream;
25 private OutputStream outputStream;
27 private ServerSession servSession;
28 private ServerConnection servconnection;
31 public IOThread (InputStream is, OutputStream os, String id,ServerSession ss, ServerConnection conn){
32 this.inputStream = is;
33 this.outputStream = os;
34 this.servSession = ss;
35 this.servconnection = conn;
37 logger.trace("IOThread {} created", super.getName());
42 logger.trace("thread {} started", super.getName());
44 IOUtils.copy(this.inputStream, this.outputStream);
45 } catch (Exception e) {
46 logger.error("inputstream -> outputstream copy error ",e);
48 logger.trace("closing server session");
50 servconnection.close();
51 logger.trace("thread {} is closing",super.getName());