001package org.apache.commons.jcs.auxiliary.disk.jdbc; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import java.io.Serializable; 023 024/** 025 * This is used by various elements of the JDBC disk cache to indicate the 026 * status of a table. The MySQL disk cache, for instance, marks the status as 027 * optimizing when a scheduled optimization is taking place. This allows the 028 * cache to balk rather than block during long running optimizations. 029 * <p> 030 * @author Aaron Smuts 031 */ 032public class TableState 033 implements Serializable 034{ 035 /** Don't change. */ 036 private static final long serialVersionUID = -6625081552084964885L; 037 038 /** Name of the table whose state this reflects. */ 039 private String tableName; 040 041 /** 042 * The table is free. It can be accessed and no potentially table locking 043 * jobs are running. 044 */ 045 public static final int FREE = 0; 046 047 /** A potentially table locking deletion is running */ 048 public static final int DELETE_RUNNING = 1; 049 050 /** A table locking optimization is running. */ 051 public static final int OPTIMIZATION_RUNNING = 2; 052 053 /** we might want to add error */ 054 private int state = FREE; 055 056 /** 057 * Construct a usable table state. 058 * <p> 059 * @param tableName 060 */ 061 public TableState( String tableName ) 062 { 063 this.setTableName( tableName ); 064 } 065 066 /** 067 * @param tableName 068 * The tableName to set. 069 */ 070 public void setTableName( String tableName ) 071 { 072 this.tableName = tableName; 073 } 074 075 /** 076 * @return Returns the tableName. 077 */ 078 public String getTableName() 079 { 080 return tableName; 081 } 082 083 /** 084 * @param state 085 * The state to set. 086 */ 087 public void setState( int state ) 088 { 089 this.state = state; 090 } 091 092 /** 093 * @return Returns the state. 094 */ 095 public int getState() 096 { 097 return state; 098 } 099 100 /** 101 * Write out the values for debugging purposes. 102 * <p> 103 * @return String 104 */ 105 @Override 106 public String toString() 107 { 108 StringBuilder str = new StringBuilder(); 109 str.append( "TableState " ); 110 str.append( "\n TableName = " + getTableName() ); 111 str.append( "\n State = " + getState() ); 112 return str.toString(); 113 } 114}