1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.qos.logback.core.spi;
15
16 import ch.qos.logback.core.helpers.CyclicBuffer;
17
18 import java.util.*;
19
20
21
22
23
24
25 public class CyclicBufferTracker<E> extends AbstractComponentTracker<CyclicBuffer<E>> {
26
27 static final int DEFAULT_NUMBER_OF_BUFFERS = 64;
28
29 static final int DEFAULT_BUFFER_SIZE = 256;
30 int bufferSize = DEFAULT_BUFFER_SIZE;
31
32 public CyclicBufferTracker() {
33 super();
34 setMaxComponents(DEFAULT_NUMBER_OF_BUFFERS);
35 }
36
37 public int getBufferSize() {
38 return bufferSize;
39 }
40
41 public void setBufferSize(int bufferSize) {
42 this.bufferSize = bufferSize;
43 }
44
45 @Override
46 protected void processPriorToRemoval(CyclicBuffer<E> component) {
47 component.clear();
48 }
49
50 @Override
51 protected CyclicBuffer<E> buildComponent(String key) {
52 return new CyclicBuffer<E>(bufferSize);
53 }
54
55 @Override
56 protected boolean isComponentStale(CyclicBuffer<E> eCyclicBuffer) {
57 return false;
58 }
59
60
61 List<String> liveKeysAsOrderedList() {
62 return new ArrayList<String>(liveMap.keySet());
63 }
64
65 List<String> lingererKeysAsOrderedList() {
66 return new ArrayList<String>(lingerersMap.keySet());
67
68 }
69
70 }