1 package org.apache.jcs.auxiliary.disk.jdbc;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.Serializable;
23
24 /***
25 * This is used by various elemetns of the JDBC disk cache to indicate the
26 * status of a table. The MySQL disk cache, for instance, marks the status as
27 * optimizing when a scheduled optimizatio is taking place. This allows the
28 * cache to balk rather than block during long running optimizations.
29 * <p>
30 * @author Aaron Smuts
31 */
32 public class TableState
33 implements Serializable
34 {
35 /*** Don't change. */
36 private static final long serialVersionUID = -6625081552084964885L;
37
38 /*** Name of the table whose state this reflects. */
39 private String tableName;
40
41 /***
42 * The table is free. It can be accessed and no potentially table locking
43 * jobs are running.
44 */
45 public static final int FREE = 0;
46
47 /*** A potentially table locking deletion is running */
48 public static final int DELETE_RUNNING = 1;
49
50 /*** A table locking optimization is running. */
51 public static final int OPTIMIZATION_RUNNING = 2;
52
53 /*** we might want to add error */
54 private int state = FREE;
55
56 /***
57 * Construct a usable table state.
58 * <p>
59 * @param tableName
60 */
61 public TableState( String tableName )
62 {
63 this.setTableName( tableName );
64 }
65
66 /***
67 * @param tableName
68 * The tableName to set.
69 */
70 public void setTableName( String tableName )
71 {
72 this.tableName = tableName;
73 }
74
75 /***
76 * @return Returns the tableName.
77 */
78 public String getTableName()
79 {
80 return tableName;
81 }
82
83 /***
84 * @param state
85 * The state to set.
86 */
87 public void setState( int state )
88 {
89 this.state = state;
90 }
91
92 /***
93 * @return Returns the state.
94 */
95 public int getState()
96 {
97 return state;
98 }
99
100 /***
101 * Write out the values for debugging purposes.
102 * <p>
103 * @return String
104 */
105 public String toString()
106 {
107 StringBuffer str = new StringBuffer();
108 str.append( "TableState " );
109 str.append( "\n TableName = " + getTableName() );
110 str.append( "\n State = " + getState() );
111 return str.toString();
112 }
113 }