globus_i_gass_cache.h

00001 /*
00002  * Copyright 1999-2006 University of Chicago
00003  * 
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  * 
00008  * http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifndef GLOBUS_DONT_DOCUMENT_INTERNAL
00018 
00023 #include "globus_symboltable.h"
00024 
00025 /* defines the environment variable to be used as default cache dir.         */
00026 #define GLOBUS_L_GASS_CACHE_DEFAULT_DIR_ENV_VAR "GLOBUS_GASS_CACHE_DEFAULT"
00027 #define GLOBUS_L_GASS_CACHE_DEBUG               "GLOBUS_GASS_CACHE_DEBUG"
00028 
00029 /* if GLOBUS_L_GASS_CACHE_DEFAULT_DIR_ENV_VAR is not defined in user env. */
00030 /* we use $HOME and  GLOBUS_L_GASS_CACHE_DEFAULT_DIR_NAME below */
00031 /* before V0.9:
00032 #define GLOBUS_L_GASS_CACHE_DEFAULT_DIR_NAME    "/.globus_gass_cache"
00033 */
00034 #define GLOBUS_L_DOT_GLOBUS_DIR_NAME            "/.globus"
00035 #define GLOBUS_L_GASS_CACHE_DEFAULT_DIR_NAME    "/.gass_cache"
00036 #define GLOBUS_L_GASS_CACHE_GLOBAL_DIR          "global"
00037 #define GLOBUS_L_GASS_CACHE_LOCAL_DIR           "local"
00038 #define GLOBUS_L_GASS_CACHE_TMP_DIR             "tmp"
00039 #define GLOBUS_L_GASS_CACHE_LOG_DIR             "log"
00040 
00041 /* Files are created with 777 and the access restriction is left to umask    */
00042 #ifdef _WIN32
00043 #define GLOBUS_L_GASS_CACHE_MODE_RWX    (_S_IRWXU)
00044 #define GLOBUS_L_GASS_CACHE_MODE_RW     (_S_IRUSR|_S_IWUSR)
00045 #else
00046 #define GLOBUS_L_GASS_CACHE_MODE_RWX    \
00047         (S_IRWXU|S_IRWXG|S_IRWXO)
00048 #define GLOBUS_L_GASS_CACHE_MODE_RW     \
00049         (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
00050 #endif
00051 #define GLOBUS_L_GASS_CACHE_DIR_MODE            GLOBUS_L_GASS_CACHE_MODE_RWX
00052 #define GLOBUS_L_GASS_CACHE_DATAFILE_MODE       GLOBUS_L_GASS_CACHE_MODE_RWX
00053 #define GLOBUS_L_GASS_CACHE_UNIQFILE_MODE       GLOBUS_L_GASS_CACHE_MODE_RWX
00054 #define GLOBUS_L_GASS_CACHE_URLFILE_MODE        GLOBUS_L_GASS_CACHE_MODE_RW
00055 #define GLOBUS_L_GASS_CACHE_TAGFILE_MODE        GLOBUS_L_GASS_CACHE_MODE_RW
00056 #define GLOBUS_L_GASS_CACHE_SKEWFILE_MODE       GLOBUS_L_GASS_CACHE_MODE_RW
00057 
00058 /* Length of sleep while waiting for ready */
00059 #define LOCK_SLEEP_USEC         500000
00060 
00061 /* Special file names */
00062 #define DATA_FILE               "data"          /* Name of the data file */
00063 #define DATA_FILE_PAT           "data"          /* Pattern for matching */
00064 #define DATA_FILE_PAT_LEN       4               /*  It's length */
00065 #define UDATA_FILE              "data."         /* Uniq data file name */
00066 #define UDATA_FILE_PAT          "data."         /* Uniq data file pattern */
00067 #define UDATA_FILE_PAT_LEN      5               /*  Length of it */
00068 #define LOCK_FILE               "lock"          /* Name of the lock file */
00069 #define URL_FILE                "url"           /* Name of the URL file */
00070 #define TAG_FILE                "tag"           /* Name of the tag file */
00071 #define UNIQ_NAME_FORMAT        "%s_%lx_%lx"
00072 #define UNIQ_NAME_MAX           (20 + MAXHOSTNAMELEN) /* Reserved for uniq */
00073 /* Largest possible file */
00074 #define MAX_FILENAME_LEN        ( DATA_FILE_PAT_LEN + UNIQ_NAME_MAX )
00075 
00076 /* Time limits, etc. */
00077 #define LOCK_MAX_SECONDS        30
00078 #define LOCK_SLEEP_USEC         500000
00079 #define NOTREADY_MAX_SECONDS    300     /* mtime age before NR "broken" */
00080 #define NOTREADY_CHECK_SECONDS  10      /* Seconds between NR lock checks. */
00081 #define SKEWCALC_SECONDS        3600    /* Seconds between skew calcs. */
00082 #define EBUSY_SLEEP_USEC        10000   /* Retry delay after EBUSY */
00083 
00084 /*
00085  * RedHat 6.2 link seems to return ENOENT sometimes even though it
00086  * *does* exist & stat() says so.  So, we'll stat() it, and, if it does
00087  * exist, sleep a bit & try again.  These define how long to wait before
00088  * the retry, and how many times we're willing to try before giving up.
00089 */
00090 #define LINKBUG_SLEEP_USEC      50000   /* Sleep before trying link() again */
00091 #define LINKBUG_MAX_RETRY       100     /* Max times to retry.. */
00092 
00093 /* Various functions will keep trying in several cases, but should
00094    eventually give up.  This controls how many times to try before
00095    that.. */
00096 #define MAKE_DIRTREE_MAX_TRIES  100
00097 #define UNLINK_MAX_TRIES        20
00098 #define CREATE_MAX_TRIES        20
00099 
00100 /* If compilled with LOCK_TOUT defined, the lock will timeout after
00101    LOCK_TOUT try to get the lock, if the file to lock is older than
00102    LOCK_TOUT*LOOP_TIME
00103    
00104    LOOPTIME is currently define as 50000 (50ms)
00105    If I define  LOCK_TOUT 600, I will wait until the lock file and temp file
00106    are untouched for more than 30s before I break the lock.*/
00107 #define LOCK_TOUT 600
00108     
00109 #define GLOBUS_L_GASS_CACHE_NULL_TAG "null"
00110 
00111 
00112 
00113 /******************************************************************************
00114  macro to trace the code during debug phase and to log the cache activity
00115 ******************************************************************************/
00116 
00117 #ifdef DEBUG 
00118 
00119 #define CACHE_TRACE(_f_)\
00120         globus_l_gass_cache_trace(__FILE__,__LINE__, (_f_) )
00121 #define CACHE_TRACE2(_f_,_a1_)\
00122         globus_l_gass_cache_trace(__FILE__,__LINE__, (_f_),(_a1_) )
00123 #define CACHE_TRACE3(_f_,_a1_,_a2_)\
00124         globus_l_gass_cache_trace(__FILE__,__LINE__, (_f_),(_a1_),(_a2_) )
00125 #define CACHE_TRACE4(_f_,_a1_,_a2_,_a3_)\
00126         globus_l_gass_cache_trace(__FILE__,__LINE__,\
00127         (_f_),(_a1_),(_a2_),(_a3_) )
00128 #define CACHE_TRACE5(_f_,_a1_,_a2_,_a3_,_a4_)\
00129         globus_l_gass_cache_trace(__FILE__,__LINE__,\
00130         (_f_),(_a1_),(_a2_),(_a3_),(_a4_) )
00131 
00132 #ifdef GLOBUS_L_GASS_CACHE_LOG 
00133 #define GLOBUS_L_GASS_CACHE_LG(_f_)\
00134         globus_l_gass_cache_trace(__FILE__,__LINE__, (_f_) );\
00135         globus_l_gass_cache_log(cache_handle->log_FILE, (_f_) )
00136 #define GLOBUS_L_GASS_CACHE_LG2(_f_,_a1_)\
00137         globus_l_gass_cache_trace(__FILE__,__LINE__, (_f_),(_a1_) );\
00138         globus_l_gass_cache_log(cache_handle->log_FILE, (_f_),(_a1_) )
00139 #define GLOBUS_L_GASS_CACHE_LG3(_f_,_a1_,_a2_)\
00140         globus_l_gass_cache_trace(__FILE__,__LINE__, (_f_),(_a1_),(_a2_) );\
00141         globus_l_gass_cache_log(cache_handle->log_FILE, (_f_),(_a1_),(_a2_) )
00142 #define GLOBUS_L_GASS_CACHE_LG4(_f_,_a1_,_a2_,_a3_)\
00143         globus_l_gass_cache_trace(__FILE__,__LINE__,(_f_),(_a1_),(_a2_),(_a3_) );\
00144         globus_l_gass_cache_log(cache_handle->log_FILE,(_f_),(_a1_),(_a2_),(_a3_) )
00145 
00146 #else
00147 #define GLOBUS_L_GASS_CACHE_LG(_f_)
00148 #define GLOBUS_L_GASS_CACHE_LG2(_f_,_a1_)
00149 #define GLOBUS_L_GASS_CACHE_LG3(_f_,_a1_,_a2_)
00150 #define GLOBUS_L_GASS_CACHE_LG4(_f_,_a1_,_a2_,_a3_)
00151 #endif
00152 
00153 #else
00154 
00155 #define CACHE_TRACE(_f_)
00156 #define CACHE_TRACE2(_f_,_a1_)
00157 #define CACHE_TRACE3(_f_,_a1_,_a2_)
00158 #define CACHE_TRACE4(_f_,_a1_,_a2_,_a3_)
00159 #define CACHE_TRACE5(_f_,_a1_,_a2_,_a3_,_a4_)
00160 #ifdef GLOBUS_L_GASS_CACHE_LOG 
00161 #define GLOBUS_L_GASS_CACHE_LG(_f_)\
00162         globus_l_gass_cache_log(cache_handle->log_FILE, _f_ ); 
00163 #define GLOBUS_L_GASS_CACHE_LG2(_f_,_a1_)\
00164         globus_l_gass_cache_log(cache_handle->log_FILE, (_f_),(_a1_) ); 
00165 #define GLOBUS_L_GASS_CACHE_LG3(_f_,_a1_,_a2_)\
00166         globus_l_gass_cache_log(cache_handle->log_FILE,\
00167         (_f_),(_a1_),(_a2_) ); 
00168 #define GLOBUS_L_GASS_CACHE_LG4(_f_,_a1_,_a2_,_a3_)\
00169         globus_l_gass_cache_log(cache_handle->log_FILE,\
00170         (_f_),(_a1_),(_a2_),(_a3_) ); 
00171 #else
00172 #define GLOBUS_L_GASS_CACHE_LG(_f_)
00173 #define GLOBUS_L_GASS_CACHE_LG2(_f_,_a1_)
00174 #define GLOBUS_L_GASS_CACHE_LG3(_f_,_a1_,_a2_)
00175 #define GLOBUS_L_GASS_CACHE_LG4(_f_,_a1_,_a2_,_a3_)
00176 #endif
00177 
00178 typedef struct globus_i_gass_cache_t
00179 {
00180     /* dirty hack to know if this cache has been opened/init. */
00181     void*       init;
00182 
00183     /* version number read out of the state file */
00184     char        *cache_directory_path;
00185     char        *global_directory_path;
00186     char        *local_directory_path;
00187     char        *tmp_directory_path;
00188 
00189     /* Current lengths */
00190     int         global_dir_len;
00191     int         local_dir_len;
00192     int         tmp_dir_len;
00193 
00194     /* Max lengths */
00195     int         max_mangled_url;
00196     int         max_mangled_tag;
00197 
00198     /* Valid mangling options */
00199     unsigned    mangling_options;
00200 
00201     /* Cache directory type (hierarchial, flat,...) */
00202     int         cache_type;
00203 
00204     /* Cache MD5 directory levels (for non flat) */
00205     int         directory_levels;
00206 
00207     /* Logging info */
00208     FILE*       log_FILE;
00209     char        *log_file_name;
00210 }
00211 globus_i_gass_cache_t;
00212 
00213 
00214                                                                               
00215 #endif
00216 
00217 #endif /* GLOBUS_DONT_DOCUMENT_INTERNAL */

Generated on 28 Oct 2014 for globus_gass_cache by  doxygen 1.4.7