@@ -142,25 +142,30 @@ public final ILoggingEvent select (final String key)
142
142
try {
143
143
final OperationStatus outcome = this .eventDatabase .get (null , keyEntry , eventEntry , null );
144
144
if (outcome != OperationStatus .SUCCESS ) {
145
- this .callbacks .handleException (new DatabaseException (), "bdb datastore encountered an error while getting the event `%s`; aborting!" , key );
145
+ this .callbacks .handleException (
146
+ new DatabaseException (),
147
+ "bdb datastore encountered an error while getting the event `%s`; aborting!" , key );
146
148
return (null );
147
149
}
148
150
} catch (final DatabaseException exception ) {
149
- this .callbacks .handleException (exception , "bdb datastore encountered an error while getting the event `%s`; aborting!" , key );
151
+ this .callbacks .handleException (
152
+ exception , "bdb datastore encountered an error while getting the event `%s`; aborting!" , key );
150
153
return (null );
151
154
}
152
155
final Object object ;
153
156
try {
154
157
object = this .serializer .deserialize (eventEntry .getData (), eventEntry .getOffset (), eventEntry .getSize ());
155
158
} catch (final Throwable exception ) {
156
- this .callbacks .handleException (exception , "bdb datastore encountered an error while deserializing the event `%s`; aborting!" , key );
159
+ this .callbacks .handleException (
160
+ exception , "bdb datastore encountered an error while deserializing the event `%s`; aborting!" , key );
157
161
return (null );
158
162
}
159
163
final ILoggingEvent event ;
160
164
try {
161
165
event = ILoggingEvent .class .cast (object );
162
166
} catch (final ClassCastException exception ) {
163
- this .callbacks .handleException (exception , "bdb datastore encountered ane error while deserializing the event `%s`; aborting!" , key );
167
+ this .callbacks .handleException (
168
+ exception , "bdb datastore encountered ane error while deserializing the event `%s`; aborting!" , key );
164
169
return (null );
165
170
}
166
171
return (event );
@@ -172,7 +177,8 @@ public final String store (final ILoggingEvent event)
172
177
try {
173
178
eventData = this .serializer .serialize (event );
174
179
} catch (final Throwable exception ) {
175
- this .callbacks .handleException (exception , "bdb datastore encountered an error while serealizing the event; aborting!" );
180
+ this .callbacks .handleException (
181
+ exception , "bdb datastore encountered an error while serealizing the event; aborting!" );
176
182
return (null );
177
183
}
178
184
final byte [] keyBytes = this .buildKey (eventData , event .getTimeStamp ());
@@ -182,38 +188,43 @@ public final String store (final ILoggingEvent event)
182
188
try {
183
189
final OperationStatus outcome = this .eventDatabase .put (null , keyEntry , eventEntry );
184
190
if (outcome != OperationStatus .SUCCESS ) {
185
- this .callbacks .handleException (new DatabaseException (), "bdb datastore encountered an error while storing the event `%s`; aborting!" , key );
191
+ this .callbacks .handleException (
192
+ new DatabaseException (),
193
+ "bdb datastore encountered an error while storing the event `%s`; aborting!" , key );
186
194
return (null );
187
195
}
188
196
} catch (final DatabaseException exception ) {
189
- this .callbacks .handleException (new DatabaseException (), "bdb datastore encountered an error while storing the event `%s`; aborting!" , key );
197
+ this .callbacks .handleException (
198
+ new DatabaseException (), "bdb datastore encountered an error while storing the event `%s`; aborting!" ,
199
+ key );
190
200
return (null );
191
201
}
192
202
return (key );
193
203
}
194
204
195
- private final byte [] buildKey ( final byte [] data , final long timestamp )
205
+ final Database getLuceneBlockDatabase ( )
196
206
{
197
- return (this .buildKey (data , 0 , data .length , timestamp ));
207
+ return (this .luceneBlockDatabase );
208
+ }
209
+
210
+ final Database getLuceneFileDatabase ()
211
+ {
212
+ return (this .luceneFileDatabase );
198
213
}
199
214
200
215
private final byte [] buildKey (final byte [] data , final int offset , final int size , final long timestamp )
201
216
{
202
- final byte [] timestampBytes = new byte [] {
203
- (byte )((timestamp >> 56 ) & 0xff ),
204
- (byte )((timestamp >> 48 ) & 0xff ),
205
- (byte )((timestamp >> 40 ) & 0xff ),
206
- (byte )((timestamp >> 32 ) & 0xff ),
207
- (byte )((timestamp >> 24 ) & 0xff ),
208
- (byte )((timestamp >> 16 ) & 0xff ),
209
- (byte )((timestamp >> 8 ) & 0xff ),
210
- (byte )((timestamp >> 0 ) & 0xff ),
211
- };
217
+ final byte [] timestampBytes =
218
+ new byte [] {(byte ) ((timestamp >> 56 ) & 0xff ), (byte ) ((timestamp >> 48 ) & 0xff ),
219
+ (byte ) ((timestamp >> 40 ) & 0xff ), (byte ) ((timestamp >> 32 ) & 0xff ),
220
+ (byte ) ((timestamp >> 24 ) & 0xff ), (byte ) ((timestamp >> 16 ) & 0xff ),
221
+ (byte ) ((timestamp >> 8 ) & 0xff ), (byte ) ((timestamp >> 0 ) & 0xff ),};
212
222
final MessageDigest hasher ;
213
223
try {
214
- hasher = MessageDigest .getInstance (defaultHashAlgorithm );
224
+ hasher = MessageDigest .getInstance (BdbDatastore . defaultHashAlgorithm );
215
225
} catch (final NoSuchAlgorithmException exception ) {
216
- this .callbacks .handleException (exception , "bdb datastore encountered an error while creating the key for the event; aborting!" );
226
+ this .callbacks .handleException (
227
+ exception , "bdb datastore encountered an error while creating the key for the event; aborting!" );
217
228
return (null );
218
229
}
219
230
hasher .update (data , offset , size );
@@ -224,28 +235,24 @@ private final byte[] buildKey (final byte[] data, final int offset, final int si
224
235
return (keyBytes );
225
236
}
226
237
227
- private final String formatKey (final byte [] bytes ) {
238
+ private final byte [] buildKey (final byte [] data , final long timestamp )
239
+ {
240
+ return (this .buildKey (data , 0 , data .length , timestamp ));
241
+ }
242
+
243
+ private final String formatKey (final byte [] bytes )
244
+ {
228
245
final StringBuilder builder = new StringBuilder ();
229
246
for (final byte b : bytes ) {
230
247
final String s = Integer .toHexString (b & 0xff );
231
248
if (s .length () == 1 )
232
- builder .append ('0' ) .append (s );
249
+ builder .append ('0' ).append (s );
233
250
else
234
251
builder .append (s );
235
252
}
236
253
return (builder .toString ());
237
254
}
238
255
239
- final Database getLuceneBlockDatabase ()
240
- {
241
- return (this .luceneBlockDatabase );
242
- }
243
-
244
- final Database getLuceneFileDatabase ()
245
- {
246
- return (this .luceneFileDatabase );
247
- }
248
-
249
256
private final Callbacks callbacks ;
250
257
private Environment environment ;
251
258
private final EnvironmentConfig environmentConfiguration ;
@@ -261,9 +268,9 @@ final Database getLuceneFileDatabase ()
261
268
private final Serializer serializer ;
262
269
263
270
public static final String defaultEventDatabaseName = "events" ;
271
+ public static final String defaultHashAlgorithm = "MD5" ;
264
272
public static final String defaultLuceneBlockDatabaseName = "lucene-blocks" ;
265
273
public static final String defaultLuceneFileDatabaseName = "lucene-files" ;
266
- public static final String defaultHashAlgorithm = "MD5" ;
267
274
268
275
private final class Callbacks
269
276
implements
0 commit comments