View Javadoc
1   package org.apache.commons.jcs3.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.commons.jcs3.auxiliary.disk.jdbc.JDBCDiskCacheAttributes;
23  
24  /**
25   * This has additional attributes that are particular to the MySQL disk cache.
26   */
27  public class MySQLDiskCacheAttributes
28      extends JDBCDiskCacheAttributes
29  {
30      /** Don't change. */
31      private static final long serialVersionUID = -6535808344813320061L;
32  
33      /**
34       * For now this is a simple comma delimited list of HH:MM:SS times to optimize
35       * the table. If none is supplied, then no optimizations will be performed.
36       * <p>
37       * In the future we can add a chron like scheduling system. This is to meet
38       * a pressing current need.
39       * <p>
40       * 03:01,15:00 will cause the optimizer to run at 3 am and at 3 pm.
41       */
42      private String optimizationSchedule;
43  
44      /**
45       * If true, we will balk, that is return null during optimization rather than block.
46       */
47      public static final boolean DEFAULT_BALK_DURING_OPTIMIZATION = true;
48  
49      /**
50       * If true, we will balk, that is return null during optimization rather than block.
51       * <p>
52       * <a href="http://en.wikipedia.org/wiki/Balking_pattern">Balking</a>
53       */
54      private boolean balkDuringOptimization = DEFAULT_BALK_DURING_OPTIMIZATION;
55  
56      /**
57       * @param optimizationSchedule The optimizationSchedule to set.
58       */
59      public void setOptimizationSchedule( final String optimizationSchedule )
60      {
61          this.optimizationSchedule = optimizationSchedule;
62      }
63  
64      /**
65       * @return Returns the optimizationSchedule.
66       */
67      public String getOptimizationSchedule()
68      {
69          return optimizationSchedule;
70      }
71  
72      /**
73       * @param balkDuringOptimization The balkDuringOptimization to set.
74       */
75      public void setBalkDuringOptimization( final boolean balkDuringOptimization )
76      {
77          this.balkDuringOptimization = balkDuringOptimization;
78      }
79  
80      /**
81       * Should we return null while optimizing the table.
82       * <p>
83       * @return Returns the balkDuringOptimization.
84       */
85      public boolean isBalkDuringOptimization()
86      {
87          return balkDuringOptimization;
88      }
89  
90      /**
91       * For debugging.
92       * <p>
93       * @return debug string
94       */
95      @Override
96      public String toString()
97      {
98          final StringBuilder buf = new StringBuilder();
99          buf.append( "\nMySQLDiskCacheAttributes" );
100         buf.append( "\n OptimizationSchedule [" + getOptimizationSchedule() + "]" );
101         buf.append( "\n BalkDuringOptimization [" + isBalkDuringOptimization() + "]" );
102         buf.append( super.toString() );
103         return buf.toString();
104     }
105 }