annotate src/goodjava/lucene/backup/BackupIndexWriter.java @ 1538:634f6765830e

use goodjava/lucene/logging
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 07 Aug 2020 21:42:16 -0600
parents 31b543826ca9
children 736ec76bbf42
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1488
af55cfad6e12 start lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 package goodjava.lucene.backup;
af55cfad6e12 start lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2
af55cfad6e12 start lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 import java.io.File;
1499
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
4 import java.io.InputStream;
1488
af55cfad6e12 start lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 import java.io.IOException;
1499
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
6 import java.net.Socket;
1488
af55cfad6e12 start lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7 import java.util.List;
af55cfad6e12 start lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8 import java.util.ArrayList;
1499
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
9 import java.util.Map;
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
10 import java.util.HashMap;
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
11 import java.util.Arrays;
1504
f443542d8650 threading
Franklin Schmidt <fschmidt@gmail.com>
parents: 1502
diff changeset
12 import java.util.concurrent.Executors;
f443542d8650 threading
Franklin Schmidt <fschmidt@gmail.com>
parents: 1502
diff changeset
13 import java.util.concurrent.ExecutorService;
1508
86c5e7000ecf lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents: 1506
diff changeset
14 import org.apache.lucene.search.SortField;
1488
af55cfad6e12 start lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15 import goodjava.io.IoUtils;
1499
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
16 import goodjava.rpc.RpcClient;
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
17 import goodjava.rpc.RpcCall;
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
18 import goodjava.rpc.RpcResult;
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
19 import goodjava.rpc.RpcException;
1488
af55cfad6e12 start lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20 import goodjava.lucene.api.LuceneIndexWriter;
1499
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
21 import goodjava.logging.Logger;
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
22 import goodjava.logging.LoggerFactory;
1488
af55cfad6e12 start lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23 import goodjava.lucene.logging.LoggingIndexWriter;
af55cfad6e12 start lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 import goodjava.lucene.logging.LogFile;
af55cfad6e12 start lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25
af55cfad6e12 start lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
26
af55cfad6e12 start lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
27 public class BackupIndexWriter extends LoggingIndexWriter {
1499
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
28 private static final Logger logger = LoggerFactory.getLogger(BackupIndexWriter.class);
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
29 public static String[] backupDomains;
1488
af55cfad6e12 start lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
30 private final String name;
1512
31b543826ca9 lucene.backup login
Franklin Schmidt <fschmidt@gmail.com>
parents: 1509
diff changeset
31 private final String password;
1488
af55cfad6e12 start lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
32 private final File dir;
1499
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
33 private boolean isSyncPending = false;
1504
f443542d8650 threading
Franklin Schmidt <fschmidt@gmail.com>
parents: 1502
diff changeset
34 private final ExecutorService exec = Executors.newSingleThreadExecutor();
1488
af55cfad6e12 start lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
35
1512
31b543826ca9 lucene.backup login
Franklin Schmidt <fschmidt@gmail.com>
parents: 1509
diff changeset
36 public BackupIndexWriter(LuceneIndexWriter indexWriter,File logDir,String name,String password) throws IOException {
1488
af55cfad6e12 start lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
37 super(indexWriter,logDir);
1499
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
38 if( backupDomains == null )
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
39 throw new RuntimeException("must set backupDomains");
1488
af55cfad6e12 start lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
40 this.name = name;
1512
31b543826ca9 lucene.backup login
Franklin Schmidt <fschmidt@gmail.com>
parents: 1509
diff changeset
41 this.password = password;
1488
af55cfad6e12 start lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
42 File f = new File(System.getProperty("java.io.tmpdir"));
af55cfad6e12 start lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
43 dir = new File(f,"goodjava.lucene/"+name);
1501
Franklin Schmidt <fschmidt@gmail.com>
parents: 1500
diff changeset
44 IoUtils.mkdirs(dir);
1488
af55cfad6e12 start lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
45 }
af55cfad6e12 start lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
46
1504
f443542d8650 threading
Franklin Schmidt <fschmidt@gmail.com>
parents: 1502
diff changeset
47 public synchronized void close() throws IOException {
f443542d8650 threading
Franklin Schmidt <fschmidt@gmail.com>
parents: 1502
diff changeset
48 super.close();
f443542d8650 threading
Franklin Schmidt <fschmidt@gmail.com>
parents: 1502
diff changeset
49 exec.shutdown();
f443542d8650 threading
Franklin Schmidt <fschmidt@gmail.com>
parents: 1502
diff changeset
50 }
f443542d8650 threading
Franklin Schmidt <fschmidt@gmail.com>
parents: 1502
diff changeset
51
1488
af55cfad6e12 start lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
52 public synchronized void commit() throws IOException {
af55cfad6e12 start lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
53 super.commit();
1499
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
54 //sync();
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
55 if( !isSyncPending ) {
1504
f443542d8650 threading
Franklin Schmidt <fschmidt@gmail.com>
parents: 1502
diff changeset
56 exec.execute(sync);
1499
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
57 isSyncPending = true;
1488
af55cfad6e12 start lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
58 }
af55cfad6e12 start lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
59 }
af55cfad6e12 start lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
60
1538
634f6765830e use goodjava/lucene/logging
Franklin Schmidt <fschmidt@gmail.com>
parents: 1512
diff changeset
61 protected boolean doCheck(SortField sortField) throws IOException {
634f6765830e use goodjava/lucene/logging
Franklin Schmidt <fschmidt@gmail.com>
parents: 1512
diff changeset
62 boolean ok = super.doCheck(sortField);
634f6765830e use goodjava/lucene/logging
Franklin Schmidt <fschmidt@gmail.com>
parents: 1512
diff changeset
63 if( ok )
634f6765830e use goodjava/lucene/logging
Franklin Schmidt <fschmidt@gmail.com>
parents: 1512
diff changeset
64 runSyncWithChecksum();
634f6765830e use goodjava/lucene/logging
Franklin Schmidt <fschmidt@gmail.com>
parents: 1512
diff changeset
65 return ok;
1508
86c5e7000ecf lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents: 1506
diff changeset
66 }
86c5e7000ecf lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents: 1506
diff changeset
67
1499
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
68 public void runSync() {
1504
f443542d8650 threading
Franklin Schmidt <fschmidt@gmail.com>
parents: 1502
diff changeset
69 try {
f443542d8650 threading
Franklin Schmidt <fschmidt@gmail.com>
parents: 1502
diff changeset
70 exec.submit(sync).get();
f443542d8650 threading
Franklin Schmidt <fschmidt@gmail.com>
parents: 1502
diff changeset
71 } catch(Exception e) {
f443542d8650 threading
Franklin Schmidt <fschmidt@gmail.com>
parents: 1502
diff changeset
72 throw new RuntimeException(e);
f443542d8650 threading
Franklin Schmidt <fschmidt@gmail.com>
parents: 1502
diff changeset
73 }
1499
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
74 }
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
75
1508
86c5e7000ecf lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents: 1506
diff changeset
76 public void runSyncWithChecksum() {
86c5e7000ecf lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents: 1506
diff changeset
77 try {
86c5e7000ecf lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents: 1506
diff changeset
78 exec.submit(syncWithChecksum).get();
86c5e7000ecf lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents: 1506
diff changeset
79 } catch(Exception e) {
86c5e7000ecf lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents: 1506
diff changeset
80 throw new RuntimeException(e);
86c5e7000ecf lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents: 1506
diff changeset
81 }
86c5e7000ecf lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents: 1506
diff changeset
82 }
86c5e7000ecf lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents: 1506
diff changeset
83
1499
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
84 private final Runnable sync = new Runnable() {
1504
f443542d8650 threading
Franklin Schmidt <fschmidt@gmail.com>
parents: 1502
diff changeset
85 public void run() {
1499
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
86 try {
1508
86c5e7000ecf lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents: 1506
diff changeset
87 sync(false);
1499
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
88 } catch(IOException e) {
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
89 throw new RuntimeException(e);
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
90 }
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
91 }
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
92 };
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
93
1508
86c5e7000ecf lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents: 1506
diff changeset
94 private final Runnable syncWithChecksum = new Runnable() {
86c5e7000ecf lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents: 1506
diff changeset
95 public void run() {
86c5e7000ecf lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents: 1506
diff changeset
96 try {
86c5e7000ecf lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents: 1506
diff changeset
97 sync(true);
86c5e7000ecf lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents: 1506
diff changeset
98 } catch(IOException e) {
86c5e7000ecf lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents: 1506
diff changeset
99 throw new RuntimeException(e);
86c5e7000ecf lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents: 1506
diff changeset
100 }
86c5e7000ecf lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents: 1506
diff changeset
101 }
86c5e7000ecf lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents: 1506
diff changeset
102 };
86c5e7000ecf lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents: 1506
diff changeset
103
86c5e7000ecf lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents: 1506
diff changeset
104 private void sync(boolean withChecksum) throws IOException {
1499
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
105 List<LogFile> logs = new ArrayList<LogFile>();
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
106 synchronized(this) {
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
107 isSyncPending = false;
1500
Franklin Schmidt <fschmidt@gmail.com>
parents: 1499
diff changeset
108 clearDir();
1499
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
109 for( LogFile log : this.logs ) {
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
110 File f = new File(dir,log.file.getName());
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
111 IoUtils.link(log.file,f);
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
112 logs.add( new LogFile(f) );
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
113 }
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
114 }
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
115 List logInfo = new ArrayList();
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
116 Map<String,LogFile> logMap = new HashMap<String,LogFile>();
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
117 for( LogFile log : logs ) {
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
118 Map fileInfo = new HashMap();
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
119 fileInfo.put("name",log.file.getName());
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
120 fileInfo.put("end",log.end());
1508
86c5e7000ecf lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents: 1506
diff changeset
121 if( withChecksum )
86c5e7000ecf lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents: 1506
diff changeset
122 fileInfo.put("checksum",log.checksum());
1499
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
123 logInfo.add(fileInfo);
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
124 logMap.put(log.file.getName(),log);
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
125 }
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
126 for( String backupDomain : backupDomains ) {
1509
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
127 RpcClient rpc = BackupServer.rpcClient(backupDomain);
1499
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
128 try {
1512
31b543826ca9 lucene.backup login
Franklin Schmidt <fschmidt@gmail.com>
parents: 1509
diff changeset
129 RpcCall call = new RpcCall("login",name,password);
31b543826ca9 lucene.backup login
Franklin Schmidt <fschmidt@gmail.com>
parents: 1509
diff changeset
130 rpc.write(call);
31b543826ca9 lucene.backup login
Franklin Schmidt <fschmidt@gmail.com>
parents: 1509
diff changeset
131 rpc.read();
31b543826ca9 lucene.backup login
Franklin Schmidt <fschmidt@gmail.com>
parents: 1509
diff changeset
132 call = new RpcCall("check",logInfo);
1499
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
133 while(true) {
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
134 rpc.write(call);
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
135 RpcResult result = rpc.read();
1512
31b543826ca9 lucene.backup login
Franklin Schmidt <fschmidt@gmail.com>
parents: 1509
diff changeset
136 //logger.info(Arrays.asList(result.returnValues).toString());
1499
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
137 String status = (String)result.returnValues[0];
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
138 if( status.equals("ok") ) {
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
139 break;
1508
86c5e7000ecf lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents: 1506
diff changeset
140 } else if( status.equals("missing") || status.equals("bad_checksum") ) {
1499
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
141 String fileName = (String)result.returnValues[1];
1508
86c5e7000ecf lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents: 1506
diff changeset
142 if( status.equals("bad_checksum") )
86c5e7000ecf lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents: 1506
diff changeset
143 logger.error("bad_checksum "+fileName);
1499
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
144 LogFile log = logMap.get(fileName);
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
145 long len = log.end() - 8;
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
146 InputStream in = log.input();
1512
31b543826ca9 lucene.backup login
Franklin Schmidt <fschmidt@gmail.com>
parents: 1509
diff changeset
147 call = new RpcCall(in,len,"add",logInfo,fileName);
1499
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
148 } else if( status.equals("incomplete") ) {
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
149 String fileName = (String)result.returnValues[1];
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
150 long logEnd = (Long)result.returnValues[2];
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
151 LogFile log = logMap.get(fileName);
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
152 long len = log.end() - logEnd;
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
153 InputStream in = log.input();
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
154 in.skip(logEnd-8);
1512
31b543826ca9 lucene.backup login
Franklin Schmidt <fschmidt@gmail.com>
parents: 1509
diff changeset
155 call = new RpcCall(in,len,"append",logInfo,fileName);
1499
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
156 } else
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
157 throw new RuntimeException("status "+status);
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
158 }
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
159 } catch(RpcException e) {
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
160 logger.warn("",e);
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
161 }
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
162 rpc.close();
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
163 }
1500
Franklin Schmidt <fschmidt@gmail.com>
parents: 1499
diff changeset
164 clearDir();
Franklin Schmidt <fschmidt@gmail.com>
parents: 1499
diff changeset
165 }
Franklin Schmidt <fschmidt@gmail.com>
parents: 1499
diff changeset
166
Franklin Schmidt <fschmidt@gmail.com>
parents: 1499
diff changeset
167 private void clearDir() throws IOException {
Franklin Schmidt <fschmidt@gmail.com>
parents: 1499
diff changeset
168 for( File f : dir.listFiles() ) {
Franklin Schmidt <fschmidt@gmail.com>
parents: 1499
diff changeset
169 IoUtils.delete(f);
Franklin Schmidt <fschmidt@gmail.com>
parents: 1499
diff changeset
170 }
1499
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
171 }
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
172
1488
af55cfad6e12 start lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
173 }