Mercurial Hosting > luan
diff src/goodjava/lucene/backup/BackupIndexWriter.java @ 1690:973d3039c421
backup server checks client domain
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 12 Jun 2022 20:13:24 -0600 |
parents | 445048f9eca7 |
children | 1578324d2aac |
line wrap: on
line diff
--- a/src/goodjava/lucene/backup/BackupIndexWriter.java Sun Jun 12 18:48:01 2022 -0600 +++ b/src/goodjava/lucene/backup/BackupIndexWriter.java Sun Jun 12 20:13:24 2022 -0600 @@ -32,20 +32,22 @@ public final class BackupIndexWriter extends LoggingIndexWriter { private static final Logger logger = LoggerFactory.getLogger(BackupIndexWriter.class); public static String[] backupDomains; + private final String domain; private final String name; private final File dir; private boolean isSyncPending = false; private final ExecutorService exec = Executors.newSingleThreadExecutor(); - public BackupIndexWriter(LuceneIndexWriter indexWriter,File logDir,long logTime,String name) + public BackupIndexWriter(LuceneIndexWriter indexWriter,File logDir,long logTime,String domain,String name) throws IOException { super(indexWriter,logDir,logTime); if( backupDomains == null ) throw new RuntimeException("must set backupDomains"); + this.domain = domain; this.name = name; File f = new File(System.getProperty("java.io.tmpdir")); - dir = new File(f,"goodjava.lucene/"+name); + dir = new File(f,"goodjava.lucene/"+domain+"~"+name); IoUtils.mkdirs(dir); } @@ -140,7 +142,7 @@ for( String backupDomain : backupDomains ) { RpcClient rpc = BackupServer.rpcClient(backupDomain); try { - RpcCall call = new RpcCall("login",name); + RpcCall call = new RpcCall("login",domain,name); rpc.write(call); rpc.read(); call = new RpcCall("check",logInfo); @@ -186,7 +188,7 @@ } } - public static BackupIndexWriter newWithRestore(LuceneIndexWriter indexWriter,File logDir,long logTime,String name) + public static BackupIndexWriter newWithRestore(LuceneIndexWriter indexWriter,File logDir,long logTime,String domain,String name) throws IOException { if( !logDir.exists() ) { @@ -194,7 +196,7 @@ try { RpcCall call; RpcResult result; - call = new RpcCall("exists",name); + call = new RpcCall("exists",domain,name); rpc.write(call); result = rpc.read(); boolean exists = (Boolean)result.returnValues[0]; @@ -202,7 +204,7 @@ logger.error("restoring "+logDir+" from backup"); File zip = File.createTempFile("luan_",".zip"); IoUtils.delete(zip); - call = new RpcCall("login",name); + call = new RpcCall("login",domain,name); rpc.write(call); rpc.read(); call = new RpcCall("zip"); @@ -222,7 +224,7 @@ } rpc.close(); } - return new BackupIndexWriter(indexWriter,logDir,logTime,name); + return new BackupIndexWriter(indexWriter,logDir,logTime,domain,name); } }