View Javadoc
1   /*
2    * Copyright 2012-2021 CodeLibs Project and the Others.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13   * either express or implied. See the License for the specific language
14   * governing permissions and limitations under the License.
15   */
16  package org.codelibs.fess.crawler.interval;
17  
18  import org.codelibs.fess.crawler.interval.impl.DefaultIntervalController;
19  import org.codelibs.fess.helper.IntervalControlHelper;
20  import org.codelibs.fess.util.ComponentUtil;
21  
22  public class FessIntervalController extends DefaultIntervalController {
23  
24      public long getDelayMillisAfterProcessing() {
25          return delayMillisAfterProcessing;
26      }
27  
28      public void setDelayMillisAfterProcessing(final long delayMillisAfterProcessing) {
29          this.delayMillisAfterProcessing = delayMillisAfterProcessing;
30      }
31  
32      public long getDelayMillisAtNoUrlInQueue() {
33          return delayMillisAtNoUrlInQueue;
34      }
35  
36      public void setDelayMillisAtNoUrlInQueue(final long delayMillisAtNoUrlInQueue) {
37          this.delayMillisAtNoUrlInQueue = delayMillisAtNoUrlInQueue;
38      }
39  
40      public long getDelayMillisBeforeProcessing() {
41          return delayMillisBeforeProcessing;
42      }
43  
44      public void setDelayMillisBeforeProcessing(final long delayMillisBeforeProcessing) {
45          this.delayMillisBeforeProcessing = delayMillisBeforeProcessing;
46      }
47  
48      public long getDelayMillisForWaitingNewUrl() {
49          return delayMillisForWaitingNewUrl;
50      }
51  
52      public void setDelayMillisForWaitingNewUrl(final long delayMillisForWaitingNewUrl) {
53          this.delayMillisForWaitingNewUrl = delayMillisForWaitingNewUrl;
54      }
55  
56      @Override
57      protected void delayForWaitingNewUrl() {
58          ComponentUtil.getSystemHelper().calibrateCpuLoad();
59          try {
60              final IntervalControlHelper intervalControlHelper = ComponentUtil.getIntervalControlHelper();
61              intervalControlHelper.checkCrawlerStatus();
62              intervalControlHelper.delayByRules();
63          } catch (final Exception e) {}
64  
65          super.delayForWaitingNewUrl();
66      }
67  }