@Override
 public LogBinaryEvent toEvent(LogStream stream) {
   return new LogBinaryEvent(
       time,
       stream.getString(level),
       stream.getString(logger),
       message,
       stream.getTags(tags),
       stream.getString(binaryType),
       binaryData);
 }
Esempio n. 2
0
 /**
  * Ensures that room is available in the pool. If the pool is currently full, then the least
  * recently used <tt>LogStream</tt> will be removed and closed to make room. This method will
  * block if the pool is full and no <tt>LogStream</tt> objects can be closed.
  *
  * @exception IOException if an I/O error occurs
  */
 private synchronized void ensurePoolSpace() throws IOException {
   if (pool.size() >= maxPoolSize) {
     while (freeList.size() < 1) {
       try {
         wait();
       } catch (InterruptedException ie) {;
       }
     }
     StreamKey key = (StreamKey) freeList.removeFirst();
     LogStream els = (LogStream) pool.remove(key);
     els.close();
   }
 }
Esempio n. 3
0
  /**
   * Removes the given <tt>LogStream</tt> from the pool and closes it, if possible. The intent is
   * for this method to be called for unusable logs so that they will no longer be returned by a
   * subsequent call to one of the "get" methods.
   */
  synchronized void removeLogStream(LogStream stream) {
    StreamKey key = (StreamKey) stream.getKey();
    if (pool.remove(key) == null)
      throw new InternalMailboxException(
          "Not managing stream: " + stream + ":" + key + " -- remove failed");

    // Remove it from freeList, if present
    freeList.remove(key);
    try {
      stream.close();
    } catch (IOException ioe) {
      // Note the exception, but otherwise ignore
      if (persistenceLogger.isLoggable(Levels.HANDLED)) {
        persistenceLogger.log(Levels.HANDLED, "Exception closing Log", ioe);
      }
    }
  }
Esempio n. 4
0
 /**
  * Marks a stream as available for closing. A log will only be closed if a new log is requested
  * and the pool has reached its maximum size.
  */
 synchronized void releaseLogStream(LogStream stream) {
   StreamKey key = (StreamKey) stream.getKey();
   if (pool.get(key) == null)
     throw new InternalMailboxException(
         "Not managing stream: " + stream + ":" + key + " -- release failed");
   freeList.add(key);
   notifyAll();
 }