示例#1
0
  @Override
  public void run() {
    ThreadCategory.setPrefix(m_logPrefix);
    ThreadCategory log = ThreadCategory.getInstance(getClass());

    Event re = null;
    try {
      re = ConvertToEvent.make(m_packet, m_ueiList);
    } catch (UnsupportedEncodingException e1) {
      log.debug("Failure to convert package");
    } catch (MessageDiscardedException e) {
      log.debug("Message discarded, returning without enqueueing event.");
      return;
    }

    log.debug("Sending received packet to the queue");

    SyslogHandler.queueManager.putInQueue(re);
    // delay a random period of time
    try {
      Thread.sleep((new Random()).nextInt(100));
    } catch (InterruptedException e) {
      log.debug("Syslogd: Interruption " + e);
    }
  }
示例#2
0
  public void send(Object obj) {

    ThreadCategory log = ThreadCategory.getInstance(getClass());
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oos = null;
    try {
      oos = new ObjectOutputStream(baos);
      oos.writeObject(obj);
      oos.flush();
      byte arr[] = baos.toByteArray();
      if (arr == null) return;
      SendInfo(arr);
      if (baos != null) baos.close();
      if (oos != null) oos.close();
    } catch (Exception e) {
      log.debug("Exception in Sending data to server.", e);
    }
  }
示例#3
0
 private DatagramPacket copyPacket(final DatagramPacket packet) {
   byte[] message = new byte[packet.getLength()];
   System.arraycopy(packet.getData(), 0, message, 0, packet.getLength());
   InetAddress addr = null;
   try {
     addr =
         InetAddress.getByAddress(
             packet.getAddress().getHostName(), packet.getAddress().getAddress());
     DatagramPacket retPacket =
         new DatagramPacket(
             message, packet.getOffset(), packet.getLength(), addr, packet.getPort());
     return retPacket;
   } catch (UnknownHostException e) {
     ThreadCategory.getInstance(getClass())
         .warn("unable to clone InetAddress object for " + packet.getAddress());
   }
   return null;
 }
示例#4
0
 private final ThreadCategory log() {
   return ThreadCategory.getInstance(getClass());
 }
示例#5
0
 private ThreadCategory log() {
   return ThreadCategory.getInstance(UdpEventSocket.class);
 }