예제 #1
0
 public static void receive_merge(WebApp webapp, Client client)
     throws SearchLibException, IOException {
   File tempDir = getTempReceiveDir(client);
   File clientDir = client.getDirectory();
   Client newClient = null;
   lockClientDir(clientDir);
   try {
     client.close();
     new ReplicationMerge(tempDir, clientDir);
     newClient =
         ClientFactory.INSTANCE.newClient(
             clientDir, true, true, ClientFactory.INSTANCE.properties.getSilentBackupUrl());
     newClient.writeReplCheck();
   } finally {
     unlockClientDir(clientDir, newClient);
   }
   PushEvent.eventClientSwitch.publish(client);
   FileUtils.deleteDirectory(tempDir);
 }
예제 #2
0
 public static void receive_switch(WebApp webapp, Client client)
     throws SearchLibException, NamingException, IOException {
   File trashDir = getTrashReceiveDir(client);
   File clientDir = client.getDirectory();
   if (trashDir.exists()) FileUtils.deleteDirectory(trashDir);
   Client newClient = null;
   List<Client> clientDepends = findDepends(client.getIndexName());
   lockClientDir(clientDir);
   try {
     lockClients(clientDepends);
     closeClients(clientDepends);
     try {
       client.trash(trashDir);
       getTempReceiveDir(client).renameTo(clientDir);
       File pathToMoveFile = new File(clientDir, PATH_TO_MOVE);
       if (pathToMoveFile.exists()) {
         for (String pathToMove : FileUtils.readLines(pathToMoveFile)) {
           File from = new File(trashDir, pathToMove);
           File to = new File(clientDir, pathToMove);
           FileUtils.moveFile(from, to);
         }
         if (!pathToMoveFile.delete())
           throw new IOException("Unable to delete the file: " + pathToMoveFile.getAbsolutePath());
       }
       newClient =
           ClientFactory.INSTANCE.newClient(
               clientDir, true, true, ClientFactory.INSTANCE.properties.getSilentBackupUrl());
       newClient.writeReplCheck();
     } finally {
       unlockClients(clientDepends);
     }
   } finally {
     unlockClientDir(clientDir, newClient);
   }
   PushEvent.eventClientSwitch.publish(client);
   FileUtils.deleteDirectory(trashDir);
 }