1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.server.core.api;
21
22 import org.apache.directory.api.ldap.model.cursor.Cursor;
23 import org.apache.directory.api.ldap.model.entry.Entry;
24 import org.apache.directory.api.ldap.model.message.SearchRequest;
25
26
27
28
29
30
31
32
33
34
35 public class SearchRequestContainer
36 {
37
38 private SearchRequest searchRequest;
39
40
41 private long sizeLimit;
42
43
44 private int count;
45
46
47 private long timeLimit;
48
49
50 private long initialTime;
51
52
53 private Cursor<Entry> cursor;
54
55
56
57
58
59
60
61
62 public SearchRequestContainer( SearchRequest searchRequest, Cursor<Entry> cursor )
63 {
64 this.searchRequest = searchRequest;
65 this.cursor = cursor;
66 this.sizeLimit = searchRequest.getSizeLimit();
67 this.timeLimit = searchRequest.getTimeLimit() * 1000L;
68
69
70 count = 0;
71 initialTime = System.currentTimeMillis();
72 }
73
74
75
76
77
78 public SearchRequest getSearchRequest()
79 {
80 return searchRequest;
81 }
82
83
84
85
86
87 public long getSizeLimit()
88 {
89 return sizeLimit;
90 }
91
92
93
94
95
96 public int getCount()
97 {
98 return count;
99 }
100
101
102
103
104
105
106
107 public boolean isSizeLimitReached()
108 {
109 return ( sizeLimit > 0 ) && ( count >= sizeLimit );
110 }
111
112
113
114
115
116 public void increment()
117 {
118 this.count++;
119 }
120
121
122
123
124
125 public int getTimeLimit()
126 {
127 return ( int ) ( timeLimit / 1000L );
128 }
129
130
131
132
133
134
135
136 public boolean isTimeLimitReached()
137 {
138 long currentTime = System.currentTimeMillis();
139
140 return ( timeLimit > 0 ) && ( initialTime + timeLimit < currentTime );
141 }
142
143
144
145
146
147 public long getInitialTime()
148 {
149 return initialTime;
150 }
151
152
153
154
155
156 public Cursor<Entry> getCursor()
157 {
158 return cursor;
159 }
160
161
162
163
164
165 public String toString()
166 {
167 long elapsed = System.currentTimeMillis() - initialTime;
168
169 return "SRContainer : <" + searchRequest.getMessageId() + ", nbSent : " + count + ", elapsed : " + elapsed + ">";
170 }
171 }