當前位置: 首頁>>代碼示例>>Java>>正文


Java CyclicBuffer類代碼示例

本文整理匯總了Java中ch.qos.logback.core.helpers.CyclicBuffer的典型用法代碼示例。如果您正苦於以下問題:Java CyclicBuffer類的具體用法?Java CyclicBuffer怎麽用?Java CyclicBuffer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CyclicBuffer類屬於ch.qos.logback.core.helpers包,在下文中一共展示了CyclicBuffer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getOrCreate

import ch.qos.logback.core.helpers.CyclicBuffer; //導入依賴的package包/類
public CyclicBuffer<E> getOrCreate(String key, long timestamp) {
  TEntry<E> te = getFromEitherList(key);
  if (te == null) {
    CyclicBuffer<E> cb = new CyclicBuffer<E>(bufferSize);
    te = new TEntry<E>(key, cb, timestamp);
    liveList.add(te);
    if (liveList.size() > maxComponents) {
      Collections.sort(liveList);
      liveList.remove(0);
    }
  } else {
    te.timestamp = timestamp;
    Collections.sort(liveList);
  }
  return te.value;
}
 
開發者ID:cscfa,項目名稱:bartleby,代碼行數:17,代碼來源:CyclicBufferTrackerT.java

示例2: play

import ch.qos.logback.core.helpers.CyclicBuffer; //導入依賴的package包/類
void play(SimulationEvent simulationEvent,
          ComponentTracker<CyclicBuffer<Object>> tracker) {
  String key = simulationEvent.key;
  long timestamp = simulationEvent.timestamp;
  EventType eventType = simulationEvent.eventType;
  switch (eventType) {
    case INSERT:
      tracker.getOrCreate(key, timestamp);
      break;
    case END_OF_LIFE:
      tracker.endOfLife(key);
      break;
    case REMOVE_STALE:
      tracker.removeStaleComponents(timestamp);
      break;
  }
}
 
開發者ID:cscfa,項目名稱:bartleby,代碼行數:18,代碼來源:CyclicBufferTrackerSimulator.java

示例3: smoke

import ch.qos.logback.core.helpers.CyclicBuffer; //導入依賴的package包/類
@Test
public void smoke() {
  long now = 3000;
  CyclicBuffer<Object> cb = tracker.getOrCreate(key, now);
  assertEquals(cb, tracker.getOrCreate(key, now++));
  now += CyclicBufferTracker.DEFAULT_TIMEOUT + 1000;
  tracker.removeStaleComponents(now);
  assertEquals(0, tracker.liveKeysAsOrderedList().size());
  assertEquals(0, tracker.getComponentCount());
}
 
開發者ID:cscfa,項目名稱:bartleby,代碼行數:11,代碼來源:CyclicBufferTrackerTest.java

示例4: destroy

import ch.qos.logback.core.helpers.CyclicBuffer; //導入依賴的package包/類
@Test
public void destroy() {
  long now = 3000;
  CyclicBuffer<Object> cb = tracker.getOrCreate(key, now);
  cb.add(new Object());
  assertEquals(1, cb.length());
  tracker.endOfLife(key);
  now += CyclicBufferTracker.LINGERING_TIMEOUT + 10;
  tracker.removeStaleComponents(now);
  assertEquals(0, tracker.liveKeysAsOrderedList().size());
  assertEquals(0, tracker.getComponentCount());
  assertEquals(0, cb.length());
}
 
開發者ID:cscfa,項目名稱:bartleby,代碼行數:14,代碼來源:CyclicBufferTrackerTest.java

示例5: subAppend

import ch.qos.logback.core.helpers.CyclicBuffer; //導入依賴的package包/類
/**
 * Perform SMTPAppender specific appending actions, mainly adding the event to
 * a cyclic buffer.
 */
protected void subAppend(CyclicBuffer<ILoggingEvent> cb, ILoggingEvent event) {
  if(includeCallerData) {
    event.getCallerData();
  }
  event.prepareForDeferredProcessing();
  cb.add(event);
}
 
開發者ID:cscfa,項目名稱:bartleby,代碼行數:12,代碼來源:SMTPAppender.java

示例6: fillBuffer

import ch.qos.logback.core.helpers.CyclicBuffer; //導入依賴的package包/類
@Override
protected void fillBuffer(CyclicBuffer<ILoggingEvent> cb, StringBuffer sbuf) {
  int len = cb.length();
  for (int i = 0; i < len; i++) {
    ILoggingEvent event = cb.get();
    sbuf.append(layout.doLayout(event));
  }
}
 
開發者ID:cscfa,項目名稱:bartleby,代碼行數:9,代碼來源:SMTPAppender.java

示例7: fillBuffer

import ch.qos.logback.core.helpers.CyclicBuffer; //導入依賴的package包/類
@Override
protected void fillBuffer(CyclicBuffer<IAccessEvent> cb, StringBuffer sbuf) {
  int len = cb.length();
  for (int i = 0; i < len; i++) {
    // sbuf.append(MimeUtility.encodeText(layout.format(cb.getOrCreate())));
    IAccessEvent event = cb.get();
    sbuf.append(layout.doLayout(event));
  }
}
 
開發者ID:cscfa,項目名稱:bartleby,代碼行數:10,代碼來源:SMTPAppender.java

示例8: append

import ch.qos.logback.core.helpers.CyclicBuffer; //導入依賴的package包/類
/**
 * Perform SMTPAppender specific appending actions, delegating some of them to a subclass and checking if the event
 * triggers an e-mail to be sent.
 */
protected void append(E eventObject) {
    if (!checkEntryConditions()) {
        return;
    }

    String key = discriminator.getDiscriminatingValue(eventObject);
    long now = System.currentTimeMillis();
    final CyclicBuffer<E> cb = cbTracker.getOrCreate(key, now);
    subAppend(cb, eventObject);

    try {
        if (eventEvaluator.evaluate(eventObject)) {
            // clone the CyclicBuffer before sending out asynchronously
            CyclicBuffer<E> cbClone = new CyclicBuffer<E>(cb);
            // see http://jira.qos.ch/browse/LBCLASSIC-221
            cb.clear();

            if (asynchronousSending) {
                // perform actual sending asynchronously
                SenderRunnable senderRunnable = new SenderRunnable(cbClone,
                        eventObject);
                context.getExecutorService().execute(senderRunnable);
            } else {
                // synchronous sending
                sendBuffer(cbClone, eventObject);
            }
        }
    } catch (EvaluationException ex) {
        errorCount++;

        if (errorCount < CoreConstants.MAX_ERROR_COUNT) {
            addError("SMTPAppender's EventEvaluator threw an Exception-",
                    ex);
        }
    }

    // immediately remove the buffer if asked by the user
    if (eventMarksEndOfLife(eventObject)) {
        cbTracker.endOfLife(key);
    }

    cbTracker.removeStaleComponents(now);

    if ((lastTrackerStatusPrint + delayBetweenStatusMessages) < now) {
        addInfo("SMTPAppender [" + name + "] is tracking ["
                + cbTracker.getComponentCount() + "] buffers");
        lastTrackerStatusPrint = now;

        // quadruple 'delay' assuming less than max delay
        if (delayBetweenStatusMessages < MAX_DELAY_BETWEEN_STATUS_MESSAGES) {
            delayBetweenStatusMessages *= 4;
        }
    }
}
 
開發者ID:zhaojunfei,項目名稱:lemon,代碼行數:59,代碼來源:SMTPAppenderBase.java

示例9: SenderRunnable

import ch.qos.logback.core.helpers.CyclicBuffer; //導入依賴的package包/類
SenderRunnable(CyclicBuffer<E> cyclicBuffer, E e) {
    this.cyclicBuffer = cyclicBuffer;
    this.e = e;
}
 
開發者ID:zhaojunfei,項目名稱:lemon,代碼行數:5,代碼來源:SMTPAppenderBase.java

示例10: processPriorToRemoval

import ch.qos.logback.core.helpers.CyclicBuffer; //導入依賴的package包/類
@Override
protected void processPriorToRemoval(CyclicBuffer<E> component) {
  component.clear();
}
 
開發者ID:cscfa,項目名稱:bartleby,代碼行數:5,代碼來源:CyclicBufferTracker.java

示例11: buildComponent

import ch.qos.logback.core.helpers.CyclicBuffer; //導入依賴的package包/類
@Override
protected CyclicBuffer<E> buildComponent(String key) {
  return  new CyclicBuffer<E>(bufferSize);
}
 
開發者ID:cscfa,項目名稱:bartleby,代碼行數:5,代碼來源:CyclicBufferTracker.java

示例12: isComponentStale

import ch.qos.logback.core.helpers.CyclicBuffer; //導入依賴的package包/類
@Override
protected boolean isComponentStale(CyclicBuffer<E> eCyclicBuffer) {
  return false;
}
 
開發者ID:cscfa,項目名稱:bartleby,代碼行數:5,代碼來源:CyclicBufferTracker.java

示例13: append

import ch.qos.logback.core.helpers.CyclicBuffer; //導入依賴的package包/類
/**
 * Perform SMTPAppender specific appending actions, delegating some of them to
 * a subclass and checking if the event triggers an e-mail to be sent.
 */
protected void append(E eventObject) {

  if (!checkEntryConditions()) {
    return;
  }

  String key = discriminator.getDiscriminatingValue(eventObject);
  long now = System.currentTimeMillis();
  final CyclicBuffer<E> cb = cbTracker.getOrCreate(key, now);
  subAppend(cb, eventObject);

  try {
    if (eventEvaluator.evaluate(eventObject)) {
      // clone the CyclicBuffer before sending out asynchronously
      CyclicBuffer<E> cbClone = new CyclicBuffer<E>(cb);
      // see http://jira.qos.ch/browse/LBCLASSIC-221
      cb.clear();

      if (asynchronousSending) {
        // perform actual sending asynchronously
        SenderRunnable senderRunnable = new SenderRunnable(cbClone, eventObject);
        context.getExecutorService().execute(senderRunnable);
      } else {
        // synchronous sending
        sendBuffer(cbClone, eventObject);
      }
    }
  } catch (EvaluationException ex) {
    errorCount++;
    if (errorCount < CoreConstants.MAX_ERROR_COUNT) {
      addError("SMTPAppender's EventEvaluator threw an Exception-", ex);
    }
  }

  // immediately remove the buffer if asked by the user
  if (eventMarksEndOfLife(eventObject)) {
    cbTracker.endOfLife(key);
  }

  cbTracker.removeStaleComponents(now);

  if (lastTrackerStatusPrint + delayBetweenStatusMessages < now) {
    addInfo("SMTPAppender [" + name + "] is tracking [" + cbTracker.getComponentCount() + "] buffers");
    lastTrackerStatusPrint = now;
    // quadruple 'delay' assuming less than max delay
    if (delayBetweenStatusMessages < MAX_DELAY_BETWEEN_STATUS_MESSAGES) {
      delayBetweenStatusMessages *= 4;
    }
  }
}
 
開發者ID:cscfa,項目名稱:bartleby,代碼行數:55,代碼來源:SMTPAppenderBase.java

示例14: SenderRunnable

import ch.qos.logback.core.helpers.CyclicBuffer; //導入依賴的package包/類
SenderRunnable(CyclicBuffer<E> cyclicBuffer, E e) {
  this.cyclicBuffer = cyclicBuffer;
  this.e = e;
}
 
開發者ID:cscfa,項目名稱:bartleby,代碼行數:5,代碼來源:SMTPAppenderBase.java

示例15: start

import ch.qos.logback.core.helpers.CyclicBuffer; //導入依賴的package包/類
public void start() {
  cb = new CyclicBuffer<E>(maxSize);
  super.start();
}
 
開發者ID:cscfa,項目名稱:bartleby,代碼行數:5,代碼來源:CyclicBufferAppender.java


注:本文中的ch.qos.logback.core.helpers.CyclicBuffer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。