当前位置: 首页>>代码示例>>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;未经允许,请勿转载。