001package org.apache.commons.jcs3.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 */ 030public class TableState 031 implements Serializable 032{ 033 /** Don't change. */ 034 private static final long serialVersionUID = -6625081552084964885L; 035 036 /** Name of the table whose state this reflects. */ 037 private String tableName; 038 039 /** 040 * The table is free. It can be accessed and no potentially table locking 041 * jobs are running. 042 */ 043 public static final int FREE = 0; 044 045 /** A potentially table locking deletion is running */ 046 public static final int DELETE_RUNNING = 1; 047 048 /** A table locking optimization is running. */ 049 public static final int OPTIMIZATION_RUNNING = 2; 050 051 /** we might want to add error */ 052 private int state = FREE; 053 054 /** 055 * Construct a usable table state. 056 * <p> 057 * @param tableName 058 */ 059 public TableState( final String tableName ) 060 { 061 this.setTableName( tableName ); 062 } 063 064 /** 065 * @param tableName 066 * The tableName to set. 067 */ 068 public void setTableName( final String tableName ) 069 { 070 this.tableName = tableName; 071 } 072 073 /** 074 * @return Returns the tableName. 075 */ 076 public String getTableName() 077 { 078 return tableName; 079 } 080 081 /** 082 * @param state 083 * The state to set. 084 */ 085 public void setState( final int state ) 086 { 087 this.state = state; 088 } 089 090 /** 091 * @return Returns the state. 092 */ 093 public int getState() 094 { 095 return state; 096 } 097 098 /** 099 * Write out the values for debugging purposes. 100 * <p> 101 * @return String 102 */ 103 @Override 104 public String toString() 105 { 106 final StringBuilder str = new StringBuilder(); 107 str.append( "TableState " ); 108 str.append( "\n TableName = " + getTableName() ); 109 str.append( "\n State = " + getState() ); 110 return str.toString(); 111 } 112}