comparison src/goodjava/lucene/backup/BackupIndexWriter.java @ 1509:0ba144491a42

lucene.backup zip
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 17 May 2020 14:29:33 -0600
parents 86c5e7000ecf
children 31b543826ca9
comparison
equal deleted inserted replaced
1508:86c5e7000ecf 1509:0ba144491a42
9 import java.util.Map; 9 import java.util.Map;
10 import java.util.HashMap; 10 import java.util.HashMap;
11 import java.util.Arrays; 11 import java.util.Arrays;
12 import java.util.concurrent.Executors; 12 import java.util.concurrent.Executors;
13 import java.util.concurrent.ExecutorService; 13 import java.util.concurrent.ExecutorService;
14 import javax.net.ssl.SSLSocket;
15 import org.apache.lucene.search.SortField; 14 import org.apache.lucene.search.SortField;
16 import goodjava.io.IoUtils; 15 import goodjava.io.IoUtils;
17 import goodjava.rpc.RpcClient; 16 import goodjava.rpc.RpcClient;
18 import goodjava.rpc.RpcCall; 17 import goodjava.rpc.RpcCall;
19 import goodjava.rpc.RpcResult; 18 import goodjava.rpc.RpcResult;
119 fileInfo.put("checksum",log.checksum()); 118 fileInfo.put("checksum",log.checksum());
120 logInfo.add(fileInfo); 119 logInfo.add(fileInfo);
121 logMap.put(log.file.getName(),log); 120 logMap.put(log.file.getName(),log);
122 } 121 }
123 for( String backupDomain : backupDomains ) { 122 for( String backupDomain : backupDomains ) {
124 RpcClient rpc = rpcClient(backupDomain); 123 RpcClient rpc = BackupServer.rpcClient(backupDomain);
125 RpcCall call = new RpcCall("check",name,logInfo); 124 RpcCall call = new RpcCall("check",name,logInfo);
126 try { 125 try {
127 while(true) { 126 while(true) {
128 rpc.write(call); 127 rpc.write(call);
129 RpcResult result = rpc.read(); 128 RpcResult result = rpc.read();
162 for( File f : dir.listFiles() ) { 161 for( File f : dir.listFiles() ) {
163 IoUtils.delete(f); 162 IoUtils.delete(f);
164 } 163 }
165 } 164 }
166 165
167 static RpcClient rpcClient(String backupDomain) throws IOException {
168 Socket socket;
169 if( BackupServer.cipherSuites == null ) {
170 socket = new Socket(backupDomain,BackupServer.port);
171 } else {
172 socket = IoUtils.getSSLSocketFactory().createSocket(backupDomain,BackupServer.port);
173 ((SSLSocket)socket).setEnabledCipherSuites(BackupServer.cipherSuites);
174 }
175 return new RpcClient(socket);
176 }
177 } 166 }