// Path: common/src/main/java/com/turn/ttorrent/common/TorrentLoggerFactory.java
// public final class TorrentLoggerFactory {
// 
//   @Nullable
//   private static volatile String staticLoggersName = null;
// 
//   public static Logger getLogger(Class<?> clazz) {
//     String name = staticLoggersName;
//     if (name == null) {
//       name = clazz.getName();
//     }
//     return LoggerFactory.getLogger(name);
//   }
// 
//   public static void setStaticLoggersName(@Nullable String staticLoggersName) {
//     TorrentLoggerFactory.staticLoggersName = staticLoggersName;
//   }
// }
// 
// Path: network/src/main/java/com/turn/ttorrent/network/ConnectionClosedException.java
// public class ConnectionClosedException extends IOException {
// 
//   public ConnectionClosedException() {
//   }
// 
//   public ConnectionClosedException(Throwable cause) {
//     super(cause);
//   }
// }
// 
// Path: network/src/main/java/com/turn/ttorrent/network/WriteAttachment.java
// public interface WriteAttachment {
// 
//   /**
//    * @return queue for offer/peek write tasks
//    */
//   BlockingQueue<WriteTask> getWriteTasks();
// 
// }


import com.turn.ttorrent.common.TorrentLoggerFactory;
import com.turn.ttorrent.network.ConnectionClosedException;
import com.turn.ttorrent.network.WriteAttachment;
import com.turn.ttorrent.network.WriteTask;
import org.slf4j.Logger;
import java.io.EOFException;
import java.io.IOException;
import java.nio.channels.SelectableChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.SocketChannel;
package com.turn.ttorrent.network.keyProcessors;



public class WritableKeyProcessor implements KeyProcessor {

  private static final Logger logger = TorrentLoggerFactory.getLogger(WritableKeyProcessor.class);

  @Override
  public void process(SelectionKey key) throws IOException {
    SelectableChannel channel = key.channel();
    if (!(channel instanceof SocketChannel)) {
      logger.warn("incorrect instance of channel. The key is cancelled");
      key.cancel();
// Path: common/src/main/java/com/turn/ttorrent/common/TorrentLoggerFactory.java
// public final class TorrentLoggerFactory {
// 
//   @Nullable
//   private static volatile String staticLoggersName = null;
// 
//   public static Logger getLogger(Class<?> clazz) {
//     String name = staticLoggersName;
//     if (name == null) {
//       name = clazz.getName();
//     }
//     return LoggerFactory.getLogger(name);
//   }
// 
//   public static void setStaticLoggersName(@Nullable String staticLoggersName) {
//     TorrentLoggerFactory.staticLoggersName = staticLoggersName;
//   }
// }
// 
// Path: network/src/main/java/com/turn/ttorrent/network/ConnectionClosedException.java
// public class ConnectionClosedException extends IOException {
// 
//   public ConnectionClosedException() {
//   }
// 
//   public ConnectionClosedException(Throwable cause) {
//     super(cause);
//   }
// }
// 
// Path: network/src/main/java/com/turn/ttorrent/network/WriteAttachment.java
// public interface WriteAttachment {
// 
//   /**
//    * @return queue for offer/peek write tasks
//    */
//   BlockingQueue<WriteTask> getWriteTasks();
// 
// }


// Path: network/src/main/java/com/turn/ttorrent/network/keyProcessors/WritableKeyProcessor.java
import com.turn.ttorrent.common.TorrentLoggerFactory;
import com.turn.ttorrent.network.ConnectionClosedException;
import com.turn.ttorrent.network.WriteAttachment;
import com.turn.ttorrent.network.WriteTask;
import org.slf4j.Logger;
import java.io.EOFException;
import java.io.IOException;
import java.nio.channels.SelectableChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.SocketChannel;

package com.turn.ttorrent.network.keyProcessors;



public class WritableKeyProcessor implements KeyProcessor {

  private static final Logger logger = TorrentLoggerFactory.getLogger(WritableKeyProcessor.class);

  @Override
  public void process(SelectionKey key) throws IOException {
    SelectableChannel channel = key.channel();
    if (!(channel instanceof SocketChannel)) {
      logger.warn("incorrect instance of channel. The key is cancelled");
      key.cancel();
      return;