This commit is contained in:
Shinsuke Sugaya 2014-09-12 14:09:46 +09:00
parent 9c524e6fc9
commit 278b8e97b5
12 changed files with 268 additions and 9 deletions

View file

@ -510,7 +510,7 @@ CREATE INDEX IDX_SESSION_NAME_EXPIRED ON CRAWLING_SESSION (NAME, EXPIRED_TIME);
INSERT INTO PUBLIC.SCHEDULED_JOB(ID, NAME, TARGET, CRON_EXPRESSION, SCRIPT_TYPE, SCRIPT_DATA, CRAWLER, JOB_LOGGING, AVAILABLE, SORT_ORDER, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME, DELETED_BY, DELETED_TIME, VERSION_NO) VALUES
(1, 'Crawler', 'all', '0 0 0 * * ?', 'groovy', 'return container.getComponent("crawlJob").execute(executor);', 'T', 'T', 'T', 0, 'system', TIMESTAMP '2013-01-01 00:00:00.000', 'system', TIMESTAMP '2013-01-01 00:00:00.000', NULL, NULL, 0),
(2, 'Minutely Tasks', 'all', '0 * * * * ?', 'groovy', 'return container.getComponent("minutelyJob").execute();', 'F', 'F', 'T', 10, 'system', TIMESTAMP '2013-01-01 00:00:00.000', 'system', TIMESTAMP '2013-01-01 00:00:00.000', NULL, NULL, 0),
(3, 'Hourly Tasks', 'all', '0 0 * * * ?', 'groovy', 'return container.getComponent("hourlyJob").execute();', 'F', 'F', 'T', 20, 'system', TIMESTAMP '2013-01-01 00:00:00.000', 'system', TIMESTAMP '2013-01-01 00:00:00.000', NULL, NULL, 0),
(4, 'Daily Tasks', 'all', '0 0 0 * * ?', 'groovy', 'return container.getComponent("dailyJob").execute();', 'F', 'F', 'T', 30, 'system', TIMESTAMP '2013-01-01 00:00:00.000', 'system', TIMESTAMP '2013-01-01 00:00:00.000', NULL, NULL, 0);
(2, 'Minutely Tasks', 'all', '0 * * * * ?', 'groovy', 'return container.getComponent("aggregateLogJob").execute();', 'F', 'F', 'T', 10, 'system', TIMESTAMP '2013-01-01 00:00:00.000', 'system', TIMESTAMP '2013-01-01 00:00:00.000', NULL, NULL, 0),
(3, 'Hourly Tasks', 'all', '0 0 * * * ?', 'groovy', 'return container.getComponent("updateStatsJob").execute()+container.getComponent("updateHotWordJob").execute();', 'F', 'F', 'T', 20, 'system', TIMESTAMP '2013-01-01 00:00:00.000', 'system', TIMESTAMP '2013-01-01 00:00:00.000', NULL, NULL, 0),
(4, 'Daily Tasks', 'all', '0 0 0 * * ?', 'groovy', 'return container.getComponent("purgeLogJob").execute();', 'F', 'F', 'T', 30, 'system', TIMESTAMP '2013-01-01 00:00:00.000', 'system', TIMESTAMP '2013-01-01 00:00:00.000', NULL, NULL, 0);

View file

@ -509,7 +509,7 @@ CREATE INDEX IDX_SEARCH_FIELD_LOG_NAME ON SEARCH_FIELD_LOG (NAME);
CREATE INDEX IDX_SESSION_NAME_EXPIRED ON CRAWLING_SESSION (NAME, EXPIRED_TIME);
INSERT INTO SCHEDULED_JOB (ID, NAME, TARGET, CRON_EXPRESSION, SCRIPT_TYPE, SCRIPT_DATA, CRAWLER, JOB_LOGGING, AVAILABLE, SORT_ORDER, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME, VERSION_NO) VALUES (1, 'Crawler', 'all', '0 0 0 * * ?', 'groovy', 'return container.getComponent("crawlJob").execute(executor);', 'T', 'T', 'T', 0, 'system', '2000-01-01 00:00:00', 'system', '2000-01-01 00:00:00', 0);
INSERT INTO SCHEDULED_JOB (ID, NAME, TARGET, CRON_EXPRESSION, SCRIPT_TYPE, SCRIPT_DATA, CRAWLER, JOB_LOGGING, AVAILABLE, SORT_ORDER, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME, VERSION_NO) VALUES (2, 'Minutely Tasks', 'all', '0 * * * * ?', 'groovy', 'return container.getComponent("minutelyJob").execute();', 'F', 'F', 'T', 10, 'system', '2000-01-01 00:00:00', 'system', '2000-01-01 00:00:00', 0);
INSERT INTO SCHEDULED_JOB (ID, NAME, TARGET, CRON_EXPRESSION, SCRIPT_TYPE, SCRIPT_DATA, CRAWLER, JOB_LOGGING, AVAILABLE, SORT_ORDER, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME, VERSION_NO) VALUES (3, 'Hourly Tasks', 'all', '0 0 * * * ?', 'groovy', 'return container.getComponent("hourlyJob").execute();', 'F', 'F', 'T', 20, 'system', '2000-01-01 00:00:00', 'system', '2000-01-01 00:00:00', 0);
INSERT INTO SCHEDULED_JOB (ID, NAME, TARGET, CRON_EXPRESSION, SCRIPT_TYPE, SCRIPT_DATA, CRAWLER, JOB_LOGGING, AVAILABLE, SORT_ORDER, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME, VERSION_NO) VALUES (4, 'Daily Tasks', 'all', '0 0 0 * * ?', 'groovy', 'return container.getComponent("dailyJob").execute();', 'F', 'F', 'T', 30, 'system', '2000-01-01 00:00:00', 'system', '2000-01-01 00:00:00', 0);
INSERT INTO SCHEDULED_JOB (ID, NAME, TARGET, CRON_EXPRESSION, SCRIPT_TYPE, SCRIPT_DATA, CRAWLER, JOB_LOGGING, AVAILABLE, SORT_ORDER, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME, VERSION_NO) VALUES (2, 'Minutely Tasks', 'all', '0 * * * * ?', 'groovy', 'return container.getComponent("aggregateLogJob").execute();', 'F', 'F', 'T', 10, 'system', '2000-01-01 00:00:00', 'system', '2000-01-01 00:00:00', 0);
INSERT INTO SCHEDULED_JOB (ID, NAME, TARGET, CRON_EXPRESSION, SCRIPT_TYPE, SCRIPT_DATA, CRAWLER, JOB_LOGGING, AVAILABLE, SORT_ORDER, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME, VERSION_NO) VALUES (3, 'Hourly Tasks', 'all', '0 0 * * * ?', 'groovy', 'return container.getComponent("updateStatsJob").execute()+container.getComponent("updateHotWordJob").execute();', 'F', 'F', 'T', 20, 'system', '2000-01-01 00:00:00', 'system', '2000-01-01 00:00:00', 0);
INSERT INTO SCHEDULED_JOB (ID, NAME, TARGET, CRON_EXPRESSION, SCRIPT_TYPE, SCRIPT_DATA, CRAWLER, JOB_LOGGING, AVAILABLE, SORT_ORDER, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME, VERSION_NO) VALUES (4, 'Daily Tasks', 'all', '0 0 0 * * ?', 'groovy', 'return container.getComponent("purgeLogJob").execute();', 'F', 'F', 'T', 30, 'system', '2000-01-01 00:00:00', 'system', '2000-01-01 00:00:00', 0);

View file

@ -535,7 +535,7 @@ CREATE SEQUENCE SEARCH_FIELD_LOG_SEQ START WITH 1 INCREMENT BY 50;
CREATE SEQUENCE FAVORITE_LOG_SEQ START WITH 1 INCREMENT BY 50;
INSERT INTO SCHEDULED_JOB (ID, NAME, TARGET, CRON_EXPRESSION, SCRIPT_TYPE, SCRIPT_DATA, CRAWLER, JOB_LOGGING, AVAILABLE, SORT_ORDER, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME, VERSION_NO) VALUES (1, 'Crawler', 'all', '0 0 0 * * ?', 'groovy', 'return container.getComponent("crawlJob").execute(executor);', 'T', 'T', 'T', 0, 'system', to_date('2000-01-01', 'yyyy-MM-dd'), 'system', to_date('2000-01-01', 'yyyy-MM-dd'), 0);
INSERT INTO SCHEDULED_JOB (ID, NAME, TARGET, CRON_EXPRESSION, SCRIPT_TYPE, SCRIPT_DATA, CRAWLER, JOB_LOGGING, AVAILABLE, SORT_ORDER, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME, VERSION_NO) VALUES (2, 'Minutely Tasks', 'all', '0 * * * * ?', 'groovy', 'return container.getComponent("minutelyJob").execute();', 'F', 'F', 'T', 10, 'system', to_date('2000-01-01', 'yyyy-MM-dd'), 'system', to_date('2000-01-01', 'yyyy-MM-dd'), 0);
INSERT INTO SCHEDULED_JOB (ID, NAME, TARGET, CRON_EXPRESSION, SCRIPT_TYPE, SCRIPT_DATA, CRAWLER, JOB_LOGGING, AVAILABLE, SORT_ORDER, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME, VERSION_NO) VALUES (3, 'Hourly Tasks', 'all', '0 0 * * * ?', 'groovy', 'return container.getComponent("hourlyJob").execute();', 'F', 'F', 'T', 20, 'system', to_date('2000-01-01', 'yyyy-MM-dd'), 'system', to_date('2000-01-01', 'yyyy-MM-dd'), 0);
INSERT INTO SCHEDULED_JOB (ID, NAME, TARGET, CRON_EXPRESSION, SCRIPT_TYPE, SCRIPT_DATA, CRAWLER, JOB_LOGGING, AVAILABLE, SORT_ORDER, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME, VERSION_NO) VALUES (4, 'Daily Tasks', 'all', '0 0 0 * * ?', 'groovy', 'return container.getComponent("dailyJob").execute();', 'F', 'F', 'T', 30, 'system', to_date('2000-01-01', 'yyyy-MM-dd'), 'system', to_date('2000-01-01', 'yyyy-MM-dd'), 0);
INSERT INTO SCHEDULED_JOB (ID, NAME, TARGET, CRON_EXPRESSION, SCRIPT_TYPE, SCRIPT_DATA, CRAWLER, JOB_LOGGING, AVAILABLE, SORT_ORDER, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME, VERSION_NO) VALUES (2, 'Minutely Tasks', 'all', '0 * * * * ?', 'groovy', 'return container.getComponent("aggregateLogJob").execute();', 'F', 'F', 'T', 10, 'system', to_date('2000-01-01', 'yyyy-MM-dd'), 'system', to_date('2000-01-01', 'yyyy-MM-dd'), 0);
INSERT INTO SCHEDULED_JOB (ID, NAME, TARGET, CRON_EXPRESSION, SCRIPT_TYPE, SCRIPT_DATA, CRAWLER, JOB_LOGGING, AVAILABLE, SORT_ORDER, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME, VERSION_NO) VALUES (3, 'Hourly Tasks', 'all', '0 0 * * * ?', 'groovy', 'return container.getComponent("updateStatsJob").execute()+container.getComponent("updateHotWordJob").execute();', 'F', 'F', 'T', 20, 'system', to_date('2000-01-01', 'yyyy-MM-dd'), 'system', to_date('2000-01-01', 'yyyy-MM-dd'), 0);
INSERT INTO SCHEDULED_JOB (ID, NAME, TARGET, CRON_EXPRESSION, SCRIPT_TYPE, SCRIPT_DATA, CRAWLER, JOB_LOGGING, AVAILABLE, SORT_ORDER, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME, VERSION_NO) VALUES (4, 'Daily Tasks', 'all', '0 0 0 * * ?', 'groovy', 'return container.getComponent("purgeLogJob").execute();', 'F', 'F', 'T', 30, 'system', to_date('2000-01-01', 'yyyy-MM-dd'), 'system', to_date('2000-01-01', 'yyyy-MM-dd'), 0);

View file

@ -0,0 +1,46 @@
/*
* Copyright 2009-2014 the CodeLibs Project and the Others.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
package jp.sf.fess.job;
import jp.sf.fess.helper.SearchLogHelper;
import jp.sf.fess.util.ComponentUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class AggregateLogJob {
private static final Logger logger = LoggerFactory
.getLogger(AggregateLogJob.class);
public String execute() {
final SearchLogHelper searchLogHelper = ComponentUtil
.getSearchLogHelper();
final StringBuilder resultBuf = new StringBuilder();
try {
searchLogHelper.storeSearchLog();
} catch (final Exception e) {
logger.error("Failed to store a search log.", e);
resultBuf.append(e.getMessage()).append("\n");
}
return resultBuf.toString();
}
}

View file

@ -31,6 +31,7 @@ import org.seasar.framework.container.SingletonS2Container;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Deprecated
public class DailyJob {
private static final Logger logger = LoggerFactory

View file

@ -23,6 +23,7 @@ import org.seasar.framework.container.SingletonS2Container;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Deprecated
public class HourlyJob {
private static final Logger logger = LoggerFactory

View file

@ -22,6 +22,7 @@ import jp.sf.fess.util.ComponentUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Deprecated
public class MinutelyJob {
private static final Logger logger = LoggerFactory

View file

@ -0,0 +1,99 @@
/*
* Copyright 2009-2014 the CodeLibs Project and the Others.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
package jp.sf.fess.job;
import java.util.Date;
import jp.sf.fess.Constants;
import jp.sf.fess.service.CrawlingSessionService;
import jp.sf.fess.service.JobLogService;
import jp.sf.fess.service.SearchLogService;
import jp.sf.fess.service.UserInfoService;
import jp.sf.fess.util.ComponentUtil;
import org.codelibs.core.util.DynamicProperties;
import org.seasar.framework.container.SingletonS2Container;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class PurgeLogJob {
private static final Logger logger = LoggerFactory
.getLogger(PurgeLogJob.class);
public String execute() {
final CrawlingSessionService crawlingSessionService = SingletonS2Container
.getComponent(CrawlingSessionService.class);
final SearchLogService searchLogService = SingletonS2Container
.getComponent(SearchLogService.class);
final JobLogService jobLogService = SingletonS2Container
.getComponent(JobLogService.class);
final UserInfoService userInfoService = SingletonS2Container
.getComponent(UserInfoService.class);
final DynamicProperties crawlerProperties = ComponentUtil
.getCrawlerProperties();
final StringBuilder resultBuf = new StringBuilder();
// purge crawling sessions
try {
crawlingSessionService.deleteBefore(new Date());
} catch (final Exception e) {
logger.error("Failed to purge crawling sessions.", e);
resultBuf.append(e.getMessage()).append("\n");
}
// purge search logs
try {
final String value = crawlerProperties.getProperty(
Constants.PURGE_SEARCH_LOG_DAY_PROPERTY,
Constants.DEFAULT_PURGE_DAY);
final int days = Integer.parseInt(value);
searchLogService.deleteBefore(days);
} catch (final Exception e) {
logger.error("Failed to purge search logs.", e);
resultBuf.append(e.getMessage()).append("\n");
}
// purge job logs
try {
final String value = crawlerProperties.getProperty(
Constants.PURGE_JOB_LOG_DAY_PROPERTY,
Constants.DEFAULT_PURGE_DAY);
final int days = Integer.parseInt(value);
jobLogService.deleteBefore(days);
} catch (final Exception e) {
logger.error("Failed to purge job logs.", e);
resultBuf.append(e.getMessage()).append("\n");
}
// purge user info
try {
final String value = crawlerProperties.getProperty(
Constants.PURGE_USER_INFO_DAY_PROPERTY,
Constants.DEFAULT_PURGE_DAY);
final int days = Integer.parseInt(value);
userInfoService.deleteBefore(days);
} catch (final Exception e) {
logger.error("Failed to purge user info.", e);
resultBuf.append(e.getMessage()).append("\n");
}
return resultBuf.toString();
}
}

View file

@ -0,0 +1,47 @@
/*
* Copyright 2009-2014 the CodeLibs Project and the Others.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
package jp.sf.fess.job;
import jp.sf.fess.helper.HotSearchWordHelper;
import jp.sf.fess.util.ComponentUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class UpdateHotWordJob {
private static final Logger logger = LoggerFactory
.getLogger(UpdateHotWordJob.class);
public String execute() {
final HotSearchWordHelper hotSearchWordHelper = ComponentUtil
.getHotSearchWordHelper();
final StringBuilder resultBuf = new StringBuilder();
// hot words
try {
hotSearchWordHelper.reload();
} catch (final Exception e) {
logger.error("Failed to store a search log.", e);
resultBuf.append(e.getMessage()).append("\n");
}
return resultBuf.toString();
}
}

View file

@ -0,0 +1,55 @@
/*
* Copyright 2009-2014 the CodeLibs Project and the Others.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
package jp.sf.fess.job;
import jp.sf.fess.service.SearchFieldLogService;
import jp.sf.fess.util.ComponentUtil;
import org.seasar.framework.container.SingletonS2Container;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class UpdateStatsJob {
private static final Logger logger = LoggerFactory
.getLogger(UpdateStatsJob.class);
public String execute() {
final SearchFieldLogService searchFieldLogService = SingletonS2Container
.getComponent(SearchFieldLogService.class);
final StringBuilder resultBuf = new StringBuilder();
try {
// update stats fields
searchFieldLogService.updateFieldLabels();
} catch (final Exception e) {
logger.error("Failed to execute the hourly task.", e);
resultBuf.append(e.getMessage()).append("\n");
}
try {
ComponentUtil.getKeyMatchHelper().update();
} catch (final Exception e) {
logger.error("Failed to execute the hourly task.", e);
resultBuf.append(e.getMessage()).append("\n");
}
return resultBuf.toString();
}
}

View file

@ -10,6 +10,15 @@
<!-- Jobs -->
<component name="crawlJob" class="jp.sf.fess.job.CrawlJob" instance="prototype">
</component>
<component name="aggregateLogJob" class="jp.sf.fess.job.AggregateLogJob" instance="prototype">
</component>
<component name="purgeLogJob" class="jp.sf.fess.job.PurgeLogJob" instance="prototype">
</component>
<component name="updateHotWordJob" class="jp.sf.fess.job.UpdateHotWordJob" instance="prototype">
</component>
<component name="updateStatsJob" class="jp.sf.fess.job.UpdateStatsJob" instance="prototype">
</component>
<!-- Deprecated -->
<component name="minutelyJob" class="jp.sf.fess.job.MinutelyJob" instance="prototype">
</component>
<component name="hourlyJob" class="jp.sf.fess.job.HourlyJob" instance="prototype">