Revision bfcf9fd5
Added by Andreas Müller about 1 year ago
app-import/src/main/java/eu/etaxonomy/cdm/app/common/tasks/CacheUpdater.java | ||
---|---|---|
16 | 16 |
import org.apache.logging.log4j.Logger; |
17 | 17 |
|
18 | 18 |
import eu.etaxonomy.cdm.api.application.CdmApplicationController; |
19 |
import eu.etaxonomy.cdm.api.service.UpdateResult; |
|
20 | 19 |
import eu.etaxonomy.cdm.api.service.config.CacheUpdaterConfigurator; |
21 | 20 |
import eu.etaxonomy.cdm.app.common.CdmDestinations; |
22 | 21 |
import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor; |
... | ... | |
27 | 26 |
import eu.etaxonomy.cdm.model.agent.AgentBase; |
28 | 27 |
|
29 | 28 |
/** |
29 |
* Runs cache updater. |
|
30 |
* |
|
31 |
* Note: Requires setting the password for authentication |
|
32 |
* |
|
30 | 33 |
* @author a.mueller |
31 | 34 |
*/ |
32 | 35 |
public class CacheUpdater { |
... | ... | |
37 | 40 |
static DbSchemaValidation hbm2dll = DbSchemaValidation.VALIDATE; |
38 | 41 |
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_edit_cichorieae_preview_direct(); |
39 | 42 |
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_production_caryophyllales_genus(); |
40 |
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_int_flora_malesiana();
|
|
43 |
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_production_euromed();
|
|
41 | 44 |
|
42 | 45 |
|
43 | 46 |
static final List<String> classListStrings = Arrays.asList(new String[]{ |
... | ... | |
57 | 60 |
try { |
58 | 61 |
|
59 | 62 |
CdmApplicationController appCtr = CdmIoApplicationController.NewInstance(destination, DbSchemaValidation.VALIDATE, false); |
60 |
@SuppressWarnings("unused") |
|
61 |
UpdateResult result2 = appCtr.getOccurrenceService().updateCaches(); |
|
63 |
// @SuppressWarnings("unused")
|
|
64 |
// UpdateResult result2 = appCtr.getOccurrenceService().updateCaches();
|
|
62 | 65 |
// @SuppressWarnings("unused") |
63 | 66 |
// UpdateResult result3 = appCtr.getTaxonService().updateCaches(); |
64 | 67 |
|
65 | 68 |
config = CacheUpdaterConfigurator.NewInstance(classListStrings); |
66 |
// appCtrInit.authenticate("admin", "xxx"); |
|
69 |
//TODO set correct password here for running, but be careful not to commit it afterwards |
|
70 |
appCtr.authenticate("admin", "xxx"); |
|
67 | 71 |
UUID monitUuid = appCtr.getLongRunningTasksService().monitLongRunningTask(config); |
68 | 72 |
IRemotingProgressMonitor monitor = appCtr.getProgressMonitorService().getRemotingMonitor(monitUuid); |
69 |
while(monitor != null && (!monitor.isCanceled() || !monitor.isDone() || !monitor.isFailed())) {
|
|
73 |
while(monitor != null && (!monitor.isCanceled() && !monitor.isDone() && !monitor.isFailed())) {
|
|
70 | 74 |
try { |
71 | 75 |
Thread.sleep(10); |
72 | 76 |
} catch (InterruptedException e) { |
... | ... | |
92 | 96 |
System.out.println("Start updating caches for "+ destination.getDatabase() + "..."); |
93 | 97 |
CacheUpdater me = new CacheUpdater(); |
94 | 98 |
me.doInvoke(destination); |
99 |
System.exit(0); |
|
95 | 100 |
|
96 | 101 |
} |
97 | 102 |
|
Also available in: Unified diff
ref #9650 fix CacheUpdater