comparison src/goodjava/lucene/backup/BackupIndexWriter.java @ 1799:1578324d2aac

backup logging
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 22 Feb 2024 08:34:55 -0700
parents 973d3039c421
children
comparison
equal deleted inserted replaced
1798:f8eba0442956 1799:1578324d2aac
20 import goodjava.io.IoUtils; 20 import goodjava.io.IoUtils;
21 import goodjava.rpc.RpcClient; 21 import goodjava.rpc.RpcClient;
22 import goodjava.rpc.RpcCall; 22 import goodjava.rpc.RpcCall;
23 import goodjava.rpc.RpcResult; 23 import goodjava.rpc.RpcResult;
24 import goodjava.rpc.RpcException; 24 import goodjava.rpc.RpcException;
25 import goodjava.rpc.RpcError;
25 import goodjava.lucene.api.LuceneIndexWriter; 26 import goodjava.lucene.api.LuceneIndexWriter;
26 import goodjava.lucene.logging.LoggingIndexWriter; 27 import goodjava.lucene.logging.LoggingIndexWriter;
27 import goodjava.lucene.logging.LogFile; 28 import goodjava.lucene.logging.LogFile;
28 import goodjava.logging.Logger; 29 import goodjava.logging.Logger;
29 import goodjava.logging.LoggerFactory; 30 import goodjava.logging.LoggerFactory;
58 59
59 @Override public synchronized void commit() throws IOException { 60 @Override public synchronized void commit() throws IOException {
60 super.commit(); 61 super.commit();
61 //sync(); 62 //sync();
62 if( !isSyncPending ) { 63 if( !isSyncPending ) {
63 exec.execute(sync); 64 exec.execute(syncR);
64 isSyncPending = true; 65 isSyncPending = true;
65 } 66 }
66 } 67 }
67 68
68 @Override protected boolean doCheck(SortField sortField) throws IOException { 69 @Override protected boolean doCheck(SortField sortField) throws IOException {
71 runSyncWithChecksum(); 72 runSyncWithChecksum();
72 return ok; 73 return ok;
73 } 74 }
74 75
75 public void runSync() { 76 public void runSync() {
76 exec(sync); 77 execR(syncR);
77 } 78 }
78 79
79 public void runSyncWithChecksum() { 80 public void runSyncWithChecksum() {
80 exec(syncWithChecksum); 81 execR(syncWithChecksum);
81 } 82 }
82 83
83 private void exec(Runnable r) { 84 private void execR(Runnable r) {
84 try { 85 try {
85 exec.submit(r).get(); 86 exec.submit(r).get();
86 } catch(InterruptedException e) { 87 } catch(InterruptedException e) {
87 throw new RuntimeException(e); 88 throw new RuntimeException(e);
88 } catch(ExecutionException e) { 89 } catch(ExecutionException e) {
91 throw (RuntimeException)cause; 92 throw (RuntimeException)cause;
92 throw new RuntimeException(e); 93 throw new RuntimeException(e);
93 } 94 }
94 } 95 }
95 96
96 private final Runnable sync = new Runnable() { 97 private final Runnable syncR = new Runnable() {
97 public void run() { 98 public void run() {
98 try { 99 try {
99 sync(false); 100 sync(false);
100 } catch(ConnectException e) { 101 } catch(ConnectException e) {
101 logger.error("sync failed: "+e.getMessage()); 102 logger.error("sync failed: "+e.getMessage());
102 } catch(IOException e) { 103 } catch(IOException e) {
103 throw new RuntimeException(e); 104 throw new RuntimeException(e);
105 } catch(RpcError e) {
106 logger.error("",e);
107 throw e;
104 } 108 }
105 } 109 }
106 }; 110 };
107 111
108 private final Runnable syncWithChecksum = new Runnable() { 112 private final Runnable syncWithChecksum = new Runnable() {