Cache.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <dirent.h>
#include <pvm3.h>
#include <assert.h>
#include "Cache.h"
#include "constants.h"
#include "DataSpace.h"
#include "Task.h"
#include "prod_cons.h"
#include "hash.h"

Include dependency graph for Cache.c:

Go to the source code of this file.

Defines

#define _CACHE_C_
#define KEY_INT
#define VAL_VOID
#define TASK_FILENAME_SIZE   100
#define TASK_DIRNAME_SIZE   ((1000+TASK_FILENAME_SIZE)*sizeof(char))

Functions

int createDir (char *dirName)
void * writerThread (void *arg)
void initCacheStruct (int filterId, int instanceId)
void initCache (int filterId, int instanceId)
void destroyCache ()
int cachePutData (char *key, void *data, int dataSz)
void * cacheGetData (int taskId, char *key, int *dataSz)
int cacheRemoveData (char *key)
int * cacheGetTaskDeps (int taskId, int *depsSz)
TaskIdListgetFinishedTasks ()
int cacheRecoverTasks (TaskIdList *tasks)
void setCreator ()
int cacheSetCurrentTask (int task)
int cacheGetCurrentTask ()
void cacheSetCurrentWork (int work)
int cacheGetCurrentWork ()
int cacheRunTask (int taskId)
int cacheCreateTask (int taskId, int *deps, int depSize, char *metadata, int metaSize)
int cacheEndTask (int taskId)
int cacheGetRunningTasks (int *numTasks, int **taskList)
int defaultRecoveryCallback (int newTaskId, int *newTaskDep, int depSize, char *metadata, int metaSize)
int cacheRegisterRecoverCallback (RecoverCallback_t *callback)
void cacheSetUseTasks ()
int cacheGetUseTasks ()
void cacheSetForwardTaskMsgs (int forward)
int cacheGetForwardTaskMsgs ()
int * cacheGetFinishedTasks (int *numTasks)
Cache___getCache ()
 This function is for internel testing only.

Variables

Cachecache = NULL


Define Documentation

#define _CACHE_C_
 

Definition at line 1 of file Cache.c.

#define KEY_INT
 

Definition at line 18 of file Cache.c.

#define TASK_DIRNAME_SIZE   ((1000+TASK_FILENAME_SIZE)*sizeof(char))
 

Definition at line 26 of file Cache.c.

Referenced by cacheRecoverTasks(), createDir(), initCacheStruct(), and writerThread().

#define TASK_FILENAME_SIZE   100
 

Definition at line 25 of file Cache.c.

Referenced by cacheRecoverTasks(), and writerThread().

#define VAL_VOID
 

Definition at line 19 of file Cache.c.


Function Documentation

Cache* ___getCache  ) 
 

This function is for internel testing only.

Definition at line 859 of file Cache.c.

References cache.

int cacheCreateTask int  taskId,
int *  deps,
int  depSize,
char *  metadata,
int  metaSize
 

Definition at line 657 of file Cache.c.

References cache, Cache::currentWork, and Cache::tasks.

Referenced by dsCreateTask(), dsReadBuffer(), and dsReadNonBlockingBuffer().

int cacheEndTask int  taskId  ) 
 

Definition at line 743 of file Cache.c.

References cache, cacheRunTask(), Cache::currentTask, Cache::currentWork, _task_::dependsOnMe, E_NO_SUCH_TASK, E_TASK_NOT_RUNNING, _task_::endedTasks, finished, getTaskState(), _task_::myDeps, running, Cache::runningTasks, setTaskState(), DataSpaceId::task, taskIdListAdd(), taskIdListGet(), taskIdListGetSize(), Cache::tasks, Cache::terminatedTasks, and DataSpaceId::work.

Referenced by dsEndTask(), and dsReadBuffer().

Here is the call graph for this function:

int cacheGetCurrentTask  ) 
 

Definition at line 621 of file Cache.c.

References cache, and Cache::currentTask.

Referenced by cacheGetTaskDeps(), dsGetCurrentTask(), dsMCast(), and dsSend().

int cacheGetCurrentWork  ) 
 

Definition at line 629 of file Cache.c.

References cache, and Cache::currentWork.

void* cacheGetData int  taskId,
char *  key,
int *  dataSz
 

Definition at line 266 of file Cache.c.

References cache, Cache::currentTask, Cache::currentWork, finished, getData(), getTaskDataSpace(), getTaskState(), DataSpaceId::task, Cache::tasks, and DataSpaceId::work.

Referenced by dsGetData().

Here is the call graph for this function:

int* cacheGetFinishedTasks int *  numTasks  ) 
 

Definition at line 854 of file Cache.c.

References cache, taskIdListToArray(), and Cache::terminatedTasks.

Referenced by dsGetFinishedTasks().

Here is the call graph for this function:

int cacheGetForwardTaskMsgs  ) 
 

Definition at line 850 of file Cache.c.

References cache, and Cache::forwardTaskMsgs.

Referenced by dsCreateTask(), dsEndTask(), dsReadBuffer(), and dsReadNonBlockingBuffer().

int cacheGetRunningTasks int *  numTasks,
int **  taskList
 

Definition at line 811 of file Cache.c.

References cache, and Cache::runningTasks.

Referenced by dsGetRunningTasks().

int* cacheGetTaskDeps int  taskId,
int *  depsSz
 

Todo:
Define access verifications for this function

Definition at line 334 of file Cache.c.

References cache, cacheGetCurrentTask(), Cache::currentWork, getTaskMyDeps(), DataSpaceId::task, taskIdListGet(), taskIdListGetSize(), Cache::tasks, and DataSpaceId::work.

Referenced by dsGetTaskDeps().

Here is the call graph for this function:

int cacheGetUseTasks  ) 
 

Definition at line 842 of file Cache.c.

References cache, and Cache::useTasks.

int cachePutData char *  key,
void *  data,
int  dataSz
 

Definition at line 234 of file Cache.c.

References cache, createDataSpace(), createTask(), Cache::currentTask, Cache::currentWork, E_NO_SUCH_TASK, getTaskDataSpace(), INITIAL_CAPACITY, putData(), DataSpaceId::task, Cache::tasks, and DataSpaceId::work.

Referenced by dsPutData().

Here is the call graph for this function:

int cacheRecoverTasks TaskIdList tasks  ) 
 

Todo:
make cache capable of saving/recovering multiple works
Todo:
test: mother inserted, then child child insered then mother
Todo:
verify if mother points to the real child

Definition at line 400 of file Cache.c.

References cache, Cache::currentWork, destroyTask(), E_COULD_NOT_RECOVER_TASK, finished, Cache::finishedTasksDir, _task_::id, _task_::mother, readTask(), setTaskState(), DataSpaceId::task, TASK_DIRNAME_SIZE, TASK_FILENAME_SIZE, taskAddChild(), taskIdListAdd(), taskIdListGet(), taskIdListGetSize(), taskIdListSortAscendig(), Cache::tasks, taskTakeChildren(), Cache::terminatedTasks, and DataSpaceId::work.

Here is the call graph for this function:

int cacheRegisterRecoverCallback RecoverCallback_t callback  ) 
 

Definition at line 833 of file Cache.c.

References cache, and Cache::recoverCallback.

Referenced by dsRegisterRecoverCallback().

int cacheRemoveData char *  key  ) 
 

Definition at line 308 of file Cache.c.

References cache, Cache::currentTask, Cache::currentWork, getTaskDataSpace(), removeData(), DataSpaceId::task, Cache::tasks, and DataSpaceId::work.

Referenced by dsRemoveData().

Here is the call graph for this function:

int cacheRunTask int  taskId  ) 
 

Definition at line 633 of file Cache.c.

References cache, Cache::currentTask, Cache::currentWork, running, Cache::runningTasks, setTaskState(), DataSpaceId::task, Cache::tasks, and DataSpaceId::work.

Referenced by cacheEndTask().

Here is the call graph for this function:

int cacheSetCurrentTask int  task  ) 
 

Definition at line 602 of file Cache.c.

References cache, Cache::currentTask, Cache::currentWork, E_NO_SUCH_TASK, E_TASK_NOT_RUNNING, getTaskState(), running, DataSpaceId::task, Cache::tasks, and DataSpaceId::work.

Referenced by dsSetCurrentTask().

Here is the call graph for this function:

void cacheSetCurrentWork int  work  ) 
 

Definition at line 625 of file Cache.c.

References cache, and Cache::currentWork.

void cacheSetForwardTaskMsgs int  forward  ) 
 

Definition at line 846 of file Cache.c.

References cache, and Cache::forwardTaskMsgs.

void cacheSetUseTasks  ) 
 

Definition at line 838 of file Cache.c.

References cache, and Cache::useTasks.

Referenced by dsUseTasks().

int createDir char *  dirName  ) 
 

Todo:
move this to oher place. cser?

Definition at line 33 of file Cache.c.

References TASK_DIRNAME_SIZE.

Referenced by writerThread().

int defaultRecoveryCallback int  newTaskId,
int *  newTaskDep,
int  depSize,
char *  metadata,
int  metaSize
 

Definition at line 828 of file Cache.c.

References dsCreateTask().

Referenced by initCacheStruct().

Here is the call graph for this function:

void destroyCache  ) 
 

Definition at line 212 of file Cache.c.

References cache, destroy_prod_cons(), Cache::finishedTasksDir, put(), Cache::runningTasks, FinishedTask::task, Cache::taskBuffer, FinishedTask::taskId, taskIdListDestroy(), Cache::tasks, Cache::terminatedTasks, FinishedTask::workId, and Cache::writeThreadDescriptor.

Here is the call graph for this function:

TaskIdList* getFinishedTasks  ) 
 

Definition at line 373 of file Cache.c.

References cache, Cache::finishedTasksDir, taskIdListAdd(), and taskIdListCreate().

Here is the call graph for this function:

void initCache int  filterId,
int  instanceId
 

Definition at line 203 of file Cache.c.

References cache, initCacheStruct(), writerThread(), and Cache::writeThreadDescriptor.

Here is the call graph for this function:

void initCacheStruct int  filterId,
int  instanceId
 

Todo:
remove garbage files from previous executions

Definition at line 169 of file Cache.c.

References cache, create_prod_cons(), Cache::currentTask, Cache::currentWork, defaultRecoveryCallback(), Cache::finishedTasksDir, Cache::forwardTaskMsgs, Cache::IAmTaskCreator, ID_LIST_INIT_SIZE, INITIAL_CAPACITY, PROD_CONS_SIZE, Cache::recoverCallback, Cache::runningTasks, TASK_DIRNAME_SIZE, Cache::taskBuffer, taskIdListCreate(), Cache::tasks, Cache::terminatedTasks, and Cache::useTasks.

Referenced by initCache().

Here is the call graph for this function:

void setCreator  ) 
 

Definition at line 598 of file Cache.c.

References cache, and Cache::IAmTaskCreator.

void* writerThread void *  arg  ) 
 

Todo:
make cache capable of saving/recovering multiple works

Definition at line 66 of file Cache.c.

References cache, createDir(), Cache::finishedTasksDir, get(), FinishedTask::task, TASK_DIRNAME_SIZE, TASK_FILENAME_SIZE, Cache::taskBuffer, FinishedTask::taskId, and writeTask().

Referenced by initCache().

Here is the call graph for this function:


Variable Documentation

Cache* cache = NULL
 

Definition at line 29 of file Cache.c.

Referenced by ___getCache(), cacheCreateTask(), cacheEndTask(), cacheGetCurrentTask(), cacheGetCurrentWork(), cacheGetData(), cacheGetFinishedTasks(), cacheGetForwardTaskMsgs(), cacheGetRunningTasks(), cacheGetTaskDeps(), cacheGetUseTasks(), cachePutData(), cacheRecoverTasks(), cacheRegisterRecoverCallback(), cacheRemoveData(), cacheRunTask(), cacheSetCurrentTask(), cacheSetCurrentWork(), cacheSetForwardTaskMsgs(), cacheSetUseTasks(), destroyCache(), getFinishedTasks(), initCache(), initCacheStruct(), setCreator(), and writerThread().


Generated on Tue Jan 17 19:19:06 2006 for Void by  doxygen 1.4.6