1 package org
.lwes
.journaller
;
6 import org
.apache
.commons
.logging
.Log
;
7 import org
.apache
.commons
.logging
.LogFactory
;
8 import org
.apache
.hadoop
.conf
.Configuration
;
9 import org
.apache
.hadoop
.fs
.FileSystem
;
10 import org
.apache
.hadoop
.fs
.Path
;
11 import org
.apache
.hadoop
.io
.BytesWritable
;
12 import org
.apache
.hadoop
.io
.NullWritable
;
13 import org
.apache
.hadoop
.io
.SequenceFile
;
14 import org
.kohsuke
.args4j
.CmdLineException
;
15 import org
.lwes
.Event
;
16 import org
.lwes
.EventSystemException
;
17 import org
.lwes
.db
.EventTemplateDB
;
19 import java
.io
.IOException
;
21 public class SequenceDejournaller
extends DeJournaller
{
23 private static transient Log log
= LogFactory
.getLog(SequenceDejournaller
.class);
26 Configuration conf
= new Configuration();
28 SequenceFile
.Reader reader
= null;
30 if (log
.isDebugEnabled()) {
31 log
.debug("Opening file: " + getFileName());
33 fs
= FileSystem
.get(conf
);
34 Path p
= new Path(getFileName());
35 reader
= new SequenceFile
.Reader(fs
, p
, conf
);
37 BytesWritable key
= (BytesWritable
) reader
.getKeyClass().newInstance();
38 NullWritable value
= NullWritable
.get();
40 EventTemplateDB templ
= new EventTemplateDB();
41 while (reader
.next(key
, value
)) {
42 Event evt
= new Event(key
.getBytes(), false, templ
);
43 if (log
.isDebugEnabled()) {
44 log
.debug("read a k/v: "+evt
.toOneLineString());
49 catch (IOException e
) {
50 log
.error(e
.getMessage(), e
);
52 catch (InstantiationException e
) {
53 log
.error(e
.getMessage(), e
);
55 catch (IllegalAccessException e
) {
56 log
.error(e
.getMessage(), e
);
58 catch (EventSystemException e
) {
59 log
.error(e
.getMessage(), e
);
66 catch (IOException e
) {
67 log
.error(e
.getMessage(), e
);
73 public static void main(String
[] args
) {
74 SequenceDejournaller dj
= new SequenceDejournaller();
76 dj
.parseArguments(args
);
78 catch (CmdLineException e
) {
79 log
.error(e
.getMessage(), e
);