本文整理汇总了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;
}
示例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;
}
}
示例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());
}
示例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());
}
示例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);
}
示例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));
}
}
示例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));
}
}
示例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;
}
}
}
示例9: SenderRunnable
import ch.qos.logback.core.helpers.CyclicBuffer; //导入依赖的package包/类
SenderRunnable(CyclicBuffer<E> cyclicBuffer, E e) {
this.cyclicBuffer = cyclicBuffer;
this.e = e;
}
示例10: processPriorToRemoval
import ch.qos.logback.core.helpers.CyclicBuffer; //导入依赖的package包/类
@Override
protected void processPriorToRemoval(CyclicBuffer<E> component) {
component.clear();
}
示例11: buildComponent
import ch.qos.logback.core.helpers.CyclicBuffer; //导入依赖的package包/类
@Override
protected CyclicBuffer<E> buildComponent(String key) {
return new CyclicBuffer<E>(bufferSize);
}
示例12: isComponentStale
import ch.qos.logback.core.helpers.CyclicBuffer; //导入依赖的package包/类
@Override
protected boolean isComponentStale(CyclicBuffer<E> eCyclicBuffer) {
return false;
}
示例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;
}
}
}
示例14: SenderRunnable
import ch.qos.logback.core.helpers.CyclicBuffer; //导入依赖的package包/类
SenderRunnable(CyclicBuffer<E> cyclicBuffer, E e) {
this.cyclicBuffer = cyclicBuffer;
this.e = e;
}
示例15: start
import ch.qos.logback.core.helpers.CyclicBuffer; //导入依赖的package包/类
public void start() {
cb = new CyclicBuffer<E>(maxSize);
super.start();
}