fixed init with migration (no schema) and duplicated missing ping
This commit is contained in:
parent
c3a4e78218
commit
15e0ab59fd
4 changed files with 37 additions and 18 deletions
|
@ -66,7 +66,7 @@ public class AsyncServiceSpringConfig implements AsyncConfigurer {
|
||||||
public Executor examAPIPingThreadPoolTaskExecutor() {
|
public Executor examAPIPingThreadPoolTaskExecutor() {
|
||||||
final ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
final ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||||
executor.setCorePoolSize(10);
|
executor.setCorePoolSize(10);
|
||||||
executor.setMaxPoolSize(20);
|
executor.setMaxPoolSize(100);
|
||||||
executor.setQueueCapacity(0);
|
executor.setQueueCapacity(0);
|
||||||
executor.setThreadNamePrefix("SEBPingService-");
|
executor.setThreadNamePrefix("SEBPingService-");
|
||||||
executor.initialize();
|
executor.initialize();
|
||||||
|
|
|
@ -73,7 +73,7 @@ public class SEBServerMigrationStrategy implements FlywayMigrationStrategy {
|
||||||
SEBServerInit.INIT_LOGGER.info("----> Found pending migrations: {}", pendingMigrations.length);
|
SEBServerInit.INIT_LOGGER.info("----> Found pending migrations: {}", pendingMigrations.length);
|
||||||
// If we are in a distributed setup only apply migration task if this is the master service
|
// If we are in a distributed setup only apply migration task if this is the master service
|
||||||
// or if there was no data base initialization yet at all.
|
// or if there was no data base initialization yet at all.
|
||||||
if (this.webserviceInfo.isDistributed()) {
|
if (this.webserviceInfo.isDistributed() && this.webserviceInfoDAO.isInitialized()) {
|
||||||
|
|
||||||
SEBServerInit.INIT_LOGGER.info("----> This is distributed setup, check master...");
|
SEBServerInit.INIT_LOGGER.info("----> This is distributed setup, check master...");
|
||||||
|
|
||||||
|
|
|
@ -78,21 +78,24 @@ public class WebserviceInit implements ApplicationListener<ApplicationReadyEvent
|
||||||
SEBServerInit.INIT_LOGGER.info("----> ");
|
SEBServerInit.INIT_LOGGER.info("----> ");
|
||||||
SEBServerInit.INIT_LOGGER.info("----> Register Webservice: {}", this.webserviceInfo.getWebserviceUUID());
|
SEBServerInit.INIT_LOGGER.info("----> Register Webservice: {}", this.webserviceInfo.getWebserviceUUID());
|
||||||
|
|
||||||
try {
|
if (this.webserviceInfoDAO.isInitialized()) {
|
||||||
final boolean register = this.webserviceInfoDAO.register(
|
this.registerWebservice();
|
||||||
this.webserviceInfo.getWebserviceUUID(),
|
|
||||||
InetAddress.getLocalHost().getHostAddress());
|
|
||||||
if (register) {
|
|
||||||
SEBServerInit.INIT_LOGGER.info("----> Successfully register Webservice instance");
|
|
||||||
}
|
|
||||||
} catch (final Exception e) {
|
|
||||||
SEBServerInit.INIT_LOGGER.error("----> Failed to register webservice: ", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apply migration if needed and possible
|
// Apply migration if needed and possible
|
||||||
SEBServerInit.INIT_LOGGER.info("----> ");
|
SEBServerInit.INIT_LOGGER.info("----> ");
|
||||||
this.sebServerMigrationStrategy.applyMigration();
|
this.sebServerMigrationStrategy.applyMigration();
|
||||||
SEBServerInit.INIT_LOGGER.info("----> ");
|
SEBServerInit.INIT_LOGGER.info("----> ");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
// Apply migration if needed and possible
|
||||||
|
SEBServerInit.INIT_LOGGER.info("----> ");
|
||||||
|
this.sebServerMigrationStrategy.applyMigration();
|
||||||
|
SEBServerInit.INIT_LOGGER.info("----> ");
|
||||||
|
|
||||||
|
this.registerWebservice();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
SEBServerInit.INIT_LOGGER.info("----> ");
|
SEBServerInit.INIT_LOGGER.info("----> ");
|
||||||
SEBServerInit.INIT_LOGGER.info("----> Initialize Services...");
|
SEBServerInit.INIT_LOGGER.info("----> Initialize Services...");
|
||||||
|
@ -155,6 +158,22 @@ public class WebserviceInit implements ApplicationListener<ApplicationReadyEvent
|
||||||
SEBServerInit.INIT_LOGGER.info("----> *********************************************************");
|
SEBServerInit.INIT_LOGGER.info("----> *********************************************************");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean registerWebservice() {
|
||||||
|
boolean registered = false;
|
||||||
|
try {
|
||||||
|
final String webserviceUUID = this.webserviceInfo.getWebserviceUUID();
|
||||||
|
final String hostAddress = InetAddress.getLocalHost().getHostAddress();
|
||||||
|
registered = this.webserviceInfoDAO.register(webserviceUUID, hostAddress);
|
||||||
|
if (registered) {
|
||||||
|
SEBServerInit.INIT_LOGGER.info("----> Successfully register Webservice instance. uuid: {}, address: {}",
|
||||||
|
webserviceUUID, hostAddress);
|
||||||
|
}
|
||||||
|
} catch (final Exception e) {
|
||||||
|
SEBServerInit.INIT_LOGGER.error("----> Failed to register webservice: ", e);
|
||||||
|
}
|
||||||
|
return registered;
|
||||||
|
}
|
||||||
|
|
||||||
@PreDestroy
|
@PreDestroy
|
||||||
public void gracefulShutdown() {
|
public void gracefulShutdown() {
|
||||||
SEBServerInit.INIT_LOGGER.info("*********************************************************");
|
SEBServerInit.INIT_LOGGER.info("*********************************************************");
|
||||||
|
|
|
@ -115,12 +115,12 @@ public class ExamSessionControlTask implements DisposableBean {
|
||||||
|
|
||||||
updateMaster();
|
updateMaster();
|
||||||
|
|
||||||
this.sebClientConnectionService.updatePingEvents();
|
|
||||||
|
|
||||||
if (!this.webserviceInfo.isMaster()) {
|
if (!this.webserviceInfo.isMaster()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.sebClientConnectionService.updatePingEvents();
|
||||||
|
|
||||||
if (log.isTraceEnabled()) {
|
if (log.isTraceEnabled()) {
|
||||||
log.trace("Run exam session update task");
|
log.trace("Run exam session update task");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue