Commit 0c6b6ed4 authored by igoshin's avatar igoshin Committed by Matija Obreza
Browse files

Final version of user story "Scheduled job execution"

#10488
parent fdcb6ec9
......@@ -40,6 +40,7 @@ import org.genesys2.server.service.ContentService;
import org.genesys2.server.service.GeoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -190,6 +191,7 @@ public class GeoServiceImpl implements GeoService {
@Override
@Transactional(readOnly = false)
@Scheduled(cron = "${scheduler.country.data.cron}")
public void updateCountryData() throws IOException {
// update current countries
updateGeoNamesCountries();
......
......@@ -42,6 +42,7 @@ import org.genesys2.server.service.worker.SGSVUpdate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.RowCallbackHandler;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
......@@ -85,7 +86,7 @@ public class AdminController {
private GenesysLowlevelRepository genesysLowlevelRepository;
@RequestMapping("/")
public String root() {
public String root(Model model) {
return "/admin/index";
}
......@@ -185,9 +186,9 @@ public class AdminController {
list.clear();
System.err.println("FOOBAR!");
final Set<Long> toRemove = new HashSet<Long>();
// Remove stupid stuff
// List<Long> aliasesToRemove = new ArrayList<Long>();
genesysLowlevelRepository.listAccessionsAlias(new RowCallbackHandler() {
......@@ -215,7 +216,7 @@ public class AdminController {
for (Object[] alias : existingAliases) {
System.err.println("" + accessionId + " = " + ArrayUtils.toString(alias, "NULL"));
}
for (int i = 0; i < existingAliases.size() - 1; i++) {
Object[] name1 = existingAliases.get(i);
if (toRemove.contains(name1[0]))
......@@ -265,7 +266,7 @@ public class AdminController {
return score;
}
});
this.genesysService.removeAliases(toRemove);
return "redirect:/admin/";
......
......@@ -32,5 +32,6 @@
<import resource="spring-security-acl.xml" />
<import resource="spring-security.xml" />
<import resource="spring-mail.xml" />
<import resource="spring-scheduler.xml" />
</beans>
......@@ -53,11 +53,6 @@
</property>
</bean>
<bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
<property name="corePoolSize" value="4" />
<property name="maxPoolSize" value="16" />
</bean>
<!-- Has to be here, otherwise JSP TAGLIB doesn't pick it up -->
<bean id="webExpressionHandler" class="org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler">
<property name="permissionEvaluator" ref="permissionEvaluator" />
......
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd"
default-autowire="no">
<task:annotation-driven executor="taskExecutor" scheduler="taskScheduler"/>
<context:component-scan base-package="org.genesys2.server.scheduler"/>
<task:executor id="taskExecutor"
pool-size="${executor.core.pool.size}-${executor.max.pool.size}"
queue-capacity="${executor.queue.capacity}"/>
<task:scheduler id="taskScheduler" pool-size="${scheduler.max.pool.size}"/>
</beans>
\ No newline at end of file
......@@ -19,8 +19,8 @@ base.url=http://localhost:8080
db.url=jdbc:mysql://localhost/genesys4?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
db.driverClassName = com.mysql.jdbc.Driver
db.username = root
db.password =
db.showSql=true
db.password =
db.showSql=false
db.hbm2ddl=do-nothing
c3p0.acquireIncrement=1
......@@ -80,3 +80,19 @@ google.consumerKey=
google.consumerSecret=
#executor properties
executor.core.pool.size=4
executor.max.pool.size=16
executor.queue.capacity=100
#scheduler properties
scheduler.max.pool.size=16
# second, minute, hour, day, month, weekday
# Month and weekday names can be given as the first three letters of the English names.
# call country updater every six hours
scheduler.country.data.cron=10 47 */6 * * ?
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment