31
31
import java .util .stream .Stream ;
32
32
33
33
import org .apache .accumulo .core .client .admin .TabletAvailability ;
34
+ import org .apache .accumulo .core .conf .AccumuloConfiguration ;
35
+ import org .apache .accumulo .core .conf .Property ;
34
36
import org .apache .accumulo .core .dataImpl .KeyExtent ;
35
37
import org .apache .accumulo .core .gc .thrift .GCStatus ;
36
38
import org .apache .accumulo .core .gc .thrift .GcCycleStats ;
@@ -80,6 +82,7 @@ public class GarbageCollectWriteAheadLogsTest {
80
82
81
83
@ Test
82
84
public void testRemoveUnusedLog () throws Exception {
85
+ AccumuloConfiguration conf = EasyMock .createMock (AccumuloConfiguration .class );
83
86
ServerContext context = EasyMock .createMock (ServerContext .class );
84
87
VolumeManager fs = EasyMock .createMock (VolumeManager .class );
85
88
EasyMock .expect (fs .moveToTrash (EasyMock .anyObject ())).andReturn (false ).anyTimes ();
@@ -88,6 +91,8 @@ public void testRemoveUnusedLog() throws Exception {
88
91
89
92
GCStatus status = new GCStatus (null , null , null , new GcCycleStats ());
90
93
94
+ EasyMock .expect (context .getConfiguration ()).andReturn (conf ).times (2 );
95
+ EasyMock .expect (conf .getCount (Property .GC_DELETE_WAL_THREADS )).andReturn (8 ).anyTimes ();
91
96
tserverSet .scanServers ();
92
97
EasyMock .expectLastCall ();
93
98
EasyMock .expect (tserverSet .getCurrentServers ()).andReturn (Collections .singleton (server1 ));
@@ -97,7 +102,7 @@ public void testRemoveUnusedLog() throws Exception {
97
102
EasyMock .expect (fs .deleteRecursively (path )).andReturn (true ).once ();
98
103
marker .removeWalMarker (server1 , id );
99
104
EasyMock .expectLastCall ().once ();
100
- EasyMock .replay (context , fs , marker , tserverSet );
105
+ EasyMock .replay (conf , context , fs , marker , tserverSet );
101
106
var gc = new GarbageCollectWriteAheadLogs (context , fs , tserverSet , marker ) {
102
107
@ Override
103
108
protected Map <UUID ,Path > getSortedWALogs () {
@@ -113,26 +118,30 @@ Stream<TabletMetadata> createStore(Set<TServerInstance> liveTservers) {
113
118
assertThrows (IllegalStateException .class , () -> gc .collect (status ),
114
119
"Should only be able to call collect once" );
115
120
116
- EasyMock .verify (context , fs , marker , tserverSet );
121
+ EasyMock .verify (conf , context , fs , marker , tserverSet );
117
122
}
118
123
119
124
@ Test
120
125
public void testKeepClosedLog () throws Exception {
126
+ AccumuloConfiguration conf = EasyMock .createMock (AccumuloConfiguration .class );
121
127
ServerContext context = EasyMock .createMock (ServerContext .class );
122
128
VolumeManager fs = EasyMock .createMock (VolumeManager .class );
123
129
WalStateManager marker = EasyMock .createMock (WalStateManager .class );
124
130
LiveTServerSet tserverSet = EasyMock .createMock (LiveTServerSet .class );
125
131
126
132
GCStatus status = new GCStatus (null , null , null , new GcCycleStats ());
127
133
134
+ EasyMock .expect (context .getConfiguration ()).andReturn (conf ).times (2 );
135
+ EasyMock .expect (conf .getCount (Property .GC_DELETE_WAL_THREADS )).andReturn (8 ).anyTimes ();
128
136
tserverSet .scanServers ();
129
137
EasyMock .expectLastCall ();
130
138
EasyMock .expect (tserverSet .getCurrentServers ()).andReturn (Collections .singleton (server1 ));
131
139
132
140
EasyMock .expect (marker .getAllMarkers ()).andReturn (markers ).once ();
133
141
EasyMock .expect (marker .state (server1 , id )).andReturn (new Pair <>(WalState .CLOSED , path ));
134
- EasyMock .replay (context , marker , tserverSet , fs );
142
+ EasyMock .replay (conf , context , marker , tserverSet , fs );
135
143
var gc = new GarbageCollectWriteAheadLogs (context , fs , tserverSet , marker ) {
144
+
136
145
@ Override
137
146
protected Map <UUID ,Path > getSortedWALogs () {
138
147
return Collections .emptyMap ();
@@ -144,12 +153,12 @@ Stream<TabletMetadata> createStore(Set<TServerInstance> liveTservers) {
144
153
}
145
154
};
146
155
gc .collect (status );
147
-
148
- EasyMock .verify (context , marker , tserverSet , fs );
156
+ EasyMock .verify (conf , context , marker , tserverSet , fs );
149
157
}
150
158
151
159
@ Test
152
160
public void deleteUnreferencedLogOnDeadServer () throws Exception {
161
+ AccumuloConfiguration conf = EasyMock .createMock (AccumuloConfiguration .class );
153
162
ServerContext context = EasyMock .createMock (ServerContext .class );
154
163
VolumeManager fs = EasyMock .createMock (VolumeManager .class );
155
164
EasyMock .expect (fs .moveToTrash (EasyMock .anyObject ())).andReturn (false ).anyTimes ();
@@ -158,6 +167,8 @@ public void deleteUnreferencedLogOnDeadServer() throws Exception {
158
167
159
168
GCStatus status = new GCStatus (null , null , null , new GcCycleStats ());
160
169
170
+ EasyMock .expect (context .getConfiguration ()).andReturn (conf ).times (2 );
171
+ EasyMock .expect (conf .getCount (Property .GC_DELETE_WAL_THREADS )).andReturn (8 ).anyTimes ();
161
172
tserverSet .scanServers ();
162
173
EasyMock .expectLastCall ();
163
174
EasyMock .expect (tserverSet .getCurrentServers ()).andReturn (Collections .singleton (server1 ));
@@ -170,7 +181,7 @@ public void deleteUnreferencedLogOnDeadServer() throws Exception {
170
181
EasyMock .expectLastCall ().once ();
171
182
marker .forget (server2 );
172
183
EasyMock .expectLastCall ().once ();
173
- EasyMock .replay (context , fs , marker , tserverSet );
184
+ EasyMock .replay (conf , context , fs , marker , tserverSet );
174
185
var gc = new GarbageCollectWriteAheadLogs (context , fs , tserverSet , marker ) {
175
186
@ Override
176
187
protected Map <UUID ,Path > getSortedWALogs () {
@@ -183,27 +194,29 @@ Stream<TabletMetadata> createStore(Set<TServerInstance> liveTservers) {
183
194
}
184
195
};
185
196
gc .collect (status );
186
-
187
- EasyMock .verify (context , fs , marker , tserverSet );
197
+ EasyMock .verify (conf , context , fs , marker , tserverSet );
188
198
}
189
199
190
200
@ Test
191
201
public void ignoreReferenceLogOnDeadServer () throws Exception {
202
+ AccumuloConfiguration conf = EasyMock .createMock (AccumuloConfiguration .class );
192
203
ServerContext context = EasyMock .createMock (ServerContext .class );
193
204
VolumeManager fs = EasyMock .createMock (VolumeManager .class );
194
205
WalStateManager marker = EasyMock .createMock (WalStateManager .class );
195
206
LiveTServerSet tserverSet = EasyMock .createMock (LiveTServerSet .class );
196
207
197
208
GCStatus status = new GCStatus (null , null , null , new GcCycleStats ());
198
209
210
+ EasyMock .expect (context .getConfiguration ()).andReturn (conf ).times (2 );
211
+ EasyMock .expect (conf .getCount (Property .GC_DELETE_WAL_THREADS )).andReturn (8 ).anyTimes ();
199
212
tserverSet .scanServers ();
200
213
EasyMock .expectLastCall ();
201
214
EasyMock .expect (tserverSet .getCurrentServers ()).andReturn (Collections .singleton (server1 ));
202
215
203
216
EasyMock .expect (marker .getAllMarkers ()).andReturn (markers2 ).once ();
204
217
EasyMock .expect (marker .state (server2 , id )).andReturn (new Pair <>(WalState .OPEN , path ));
205
218
206
- EasyMock .replay (context , fs , marker , tserverSet );
219
+ EasyMock .replay (conf , context , fs , marker , tserverSet );
207
220
GarbageCollectWriteAheadLogs gc =
208
221
new GarbageCollectWriteAheadLogs (context , fs , tserverSet , marker ) {
209
222
@ Override
@@ -218,7 +231,7 @@ Stream<TabletMetadata> createStore(Set<TServerInstance> liveTservers) {
218
231
};
219
232
gc .collect (status );
220
233
221
- EasyMock .verify (context , fs , marker , tserverSet );
234
+ EasyMock .verify (conf , context , fs , marker , tserverSet );
222
235
}
223
236
224
237
}
0 commit comments