예제 #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);
    }
  }