View Javadoc

1   package org.apache.jcs.auxiliary.disk.jdbc.mysql;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.jcs.auxiliary.disk.jdbc.JDBCDiskCacheAttributes;
23  
24  /***
25   * This has additional attributes that are particular to the MySQL disk cache.
26   * <p>
27   * @author Aaron Smuts
28   */
29  public class MySQLDiskCacheAttributes
30      extends JDBCDiskCacheAttributes
31  {
32      private static final long serialVersionUID = -6535808344813320061L;
33  
34      /***
35       * For now this is a simple comma delimited list of HH:MM:SS times to optimize
36       * the table. If none is supplied, then no optimizations will be performed.
37       * <p>
38       * In the future we can add a chron like scheduling system. This is to meet
39       * a pressing current need.
40       * <p>
41       * 03:01,15:00 will cause the optimizer to run at 3 am and at 3 pm.
42       */
43      private String optimizationSchedule = null;
44  
45      /***
46       * If true, we will balk, that is return null during optimization rather than block.
47       */
48      public static final boolean DEFAULT_BALK_DURING_OPTIMIZATION = true;
49  
50      /***
51       * If true, we will balk, that is return null during optimization rather than block.
52       * <p>
53       * <a href="http://en.wikipedia.org/wiki/Balking_pattern">Balking</a>
54       */
55      private boolean balkDuringOptimization = DEFAULT_BALK_DURING_OPTIMIZATION;
56  
57      /***
58       * @param optimizationSchedule The optimizationSchedule to set.
59       */
60      public void setOptimizationSchedule( String optimizationSchedule )
61      {
62          this.optimizationSchedule = optimizationSchedule;
63      }
64  
65      /***
66       * @return Returns the optimizationSchedule.
67       */
68      public String getOptimizationSchedule()
69      {
70          return optimizationSchedule;
71      }
72  
73      /***
74       * @param balkDuringOptimization The balkDuringOptimization to set.
75       */
76      public void setBalkDuringOptimization( boolean balkDuringOptimization )
77      {
78          this.balkDuringOptimization = balkDuringOptimization;
79      }
80  
81      /***
82       * Should we return null while optimizing the table.
83       * <p>
84       * @return Returns the balkDuringOptimization.
85       */
86      public boolean isBalkDuringOptimization()
87      {
88          return balkDuringOptimization;
89      }
90  
91      /***
92       * For debugging.
93       */
94      public String toString()
95      {
96          StringBuffer buf = new StringBuffer();
97          buf.append( "\nMySQLDiskCacheAttributes" );
98          buf.append( "\n OptimizationSchedule [" + getOptimizationSchedule() + "]" );
99          buf.append( "\n BalkDuringOptimization [" + isBalkDuringOptimization() + "]" );
100         buf.append( super.toString() );
101         return buf.toString();
102     }
103 }