// Path: src/main/java/com/neverwinterdp/sparkngin/http/JSONHttpSparknginClient.java
// public class JSONHttpSparknginClient extends AbstractHttpSparknginClient {
//   
//   public JSONHttpSparknginClient(String host, int port, int bufferSize, boolean connect) throws Exception {
//     super(host, port, bufferSize, connect) ;
//     setPath("/message/json") ;
//   }
//   
//   protected Ack toAck(HttpContent content) {
//     String json = content.content().toString(CharsetUtil.UTF_8);
//     Ack ack = JSONSerializer.INSTANCE.fromString(json, Ack.class) ;
//     return ack ;
//   }
// 
// 
//   @Override
//   protected byte[] toBinData(Message message) {
//     return JSONSerializer.INSTANCE.toBytes(message) ;
//   }
// 
//   protected String toStringData(Message message) {
//     return JSONSerializer.INSTANCE.toString(message);
//   }
// 
// }


import java.io.IOException;
import org.apache.log4j.AppenderSkeleton;
import org.apache.log4j.spi.LoggingEvent;
import com.neverwinterdp.buffer.chronicle.MultiSegmentQueue;
import com.neverwinterdp.buffer.chronicle.Segment;
import com.neverwinterdp.message.Message;
import com.neverwinterdp.sparkngin.http.JSONHttpSparknginClient;
  public void setSparknginHost(String sparknginHost) {
    this.sparknginHost = sparknginHost;
  }

  public void setSparknginPort(int sparknginPort) {
    this.sparknginPort = sparknginPort;
  }

  public void setSparknginReconnectPeriod(long sparknginReconnectPeriod) {
    this.sparknginReconnectPeriod = sparknginReconnectPeriod;
  }

  public void setMessageTopic(String messageTopic) {
    this.messageTopic = messageTopic;
  }

  public boolean requiresLayout() { return false; }

  protected void append(LoggingEvent event) {
    if(queueError) return ;
    Log4jRecord record = new Log4jRecord(event) ;
    try {
      queue.writeObject(record) ;
    } catch (Exception e) {
      queueError = true ;
      e.printStackTrace();
    }
  }
  
  public class DeamonThread extends Thread {
// Path: src/main/java/com/neverwinterdp/sparkngin/http/JSONHttpSparknginClient.java
// public class JSONHttpSparknginClient extends AbstractHttpSparknginClient {
//   
//   public JSONHttpSparknginClient(String host, int port, int bufferSize, boolean connect) throws Exception {
//     super(host, port, bufferSize, connect) ;
//     setPath("/message/json") ;
//   }
//   
//   protected Ack toAck(HttpContent content) {
//     String json = content.content().toString(CharsetUtil.UTF_8);
//     Ack ack = JSONSerializer.INSTANCE.fromString(json, Ack.class) ;
//     return ack ;
//   }
// 
// 
//   @Override
//   protected byte[] toBinData(Message message) {
//     return JSONSerializer.INSTANCE.toBytes(message) ;
//   }
// 
//   protected String toStringData(Message message) {
//     return JSONSerializer.INSTANCE.toString(message);
//   }
// 
// }


// Path: src/main/java/com/neverwinterdp/sparkngin/log4j/SparknginLog4jAppender.java
import java.io.IOException;
import org.apache.log4j.AppenderSkeleton;
import org.apache.log4j.spi.LoggingEvent;
import com.neverwinterdp.buffer.chronicle.MultiSegmentQueue;
import com.neverwinterdp.buffer.chronicle.Segment;
import com.neverwinterdp.message.Message;
import com.neverwinterdp.sparkngin.http.JSONHttpSparknginClient;

  public void setSparknginHost(String sparknginHost) {
    this.sparknginHost = sparknginHost;
  }

  public void setSparknginPort(int sparknginPort) {
    this.sparknginPort = sparknginPort;
  }

  public void setSparknginReconnectPeriod(long sparknginReconnectPeriod) {
    this.sparknginReconnectPeriod = sparknginReconnectPeriod;
  }

  public void setMessageTopic(String messageTopic) {
    this.messageTopic = messageTopic;
  }

  public boolean requiresLayout() { return false; }

  protected void append(LoggingEvent event) {
    if(queueError) return ;
    Log4jRecord record = new Log4jRecord(event) ;
    try {
      queue.writeObject(record) ;
    } catch (Exception e) {
      queueError = true ;
      e.printStackTrace();
    }
  }
  
  public class DeamonThread extends Thread {
    private JSONHttpSparknginClient client = null ;