Storage Unit Management Subsystem (SUMS)
#ifndef SUM_INCL #define SUM_VERSION_NUM (1.0) #define DBCONNECT "DSOWNER/HMI4SDO@hmidb" #include #include
typedef uint64_t SUMID_t;
#define ARCH 1 #define TEMP 2 #define PERM 4 #define TOUCH 8 #define RETRIEVE 16 #define NORETRIEVE 32 #define FULL 1024
#define SUM_INCL #endif
This is found in sum_rpc.h:
typedef struct SUM_struct {
- SUMID_t uid;
CLIENT *cl;
SUM_info_t *sinfo; int debugflg; int mode; int tdays; int group; int storeset; double bytes; char *dsname; char *username; char *history_comment; int reqcnt; uint64_t *dsix_ptr; char **wd;
} SUM_t;
typedef struct SUMEXP_struct {
- SUMID_t uid;
int reqcnt;
char *host; char **src; char **dest;
} SUMEXP_t;
SUM_t *SUM_open(char *server, char *db, int (*history)(const char *fmt, ...))
- A DRMS instance opens a session with SUMS. It gives the server name to connect to, defaults to SUMSERVER env else SUMSERVER define. The db name has been depricated and has no effect. The db will be the one that sum_svc was started with, e.g. sum_svc hmidb. The history is a printf type logging function. Returns a pointer to a SUM handle that is used to identify this user for this session. Returns NULL on failure. Currently the dsix_ptr[] and wd[] arrays are malloc'd to size SUMARRAYSZ (64).
int SUM_close(SUM_t *sum, int (*history)(const char *fmt, ...))
- Closes the session. Returns 0 on success, else error code. Will release all read-only storage and release all uncommitted allocated storage and free any other resources for this SUM handle.
int SUM_get(SUM_t *sum, int (*history)(const char *fmt, ...))
- Gets the location of the storage units given by the dsindexes. Marks the storage units as open for read. Return 0 on success with data available, 1 on error, or RESULT_PEND when the data will come from tape (call SUM_poll() or SUM_wait() to get completion msg. NOTE: Caller must check
sum->status for any errors after SUM_poll() or final SUM_wait()). NOTE: You can call to get any number of storage unit (reqcnt). One completion message will be received when all units are online. If you get back an error status, you will not know if any particular storage unit failed. All the reqcnt storage units stand or fall as a team. If you want resolution at the individual storage unit level, you should make seperate SUM_get() calls. If you make another SUM_get() call before you do a SUM_wait() there will be two completion messages pending and SUM_wait() will return after the first one and you will not know which one did complete and there will still be another one pending. So keep the SUM_get()/SUM_wait() calls paired, unless you want to explicitly program for something more complex.
The caller sets: SUMID = the open id mode = RETRIEVE | NORETRIEVE to get any offline dataunits from tape
- storage or not. Also TOUCH if want to change online retention time.
tdays = touch days for online retention. Always used regardless of TOUCH mode
- if the SU was read from tape.
reqcnt = Number of dsindex values given below to get dsix_ptr= Pointer to array of reqcnt uint64_t to indicate DB index of
- the dataunits
The function returns: Error code = 1, else 0 on success with:
- wd = Array of char * pointing to the wd of each dsindex given. Value
- is empty string for any non-existing storage unit, or an offline storage unit when mode = NORETRIEVE.
else RESULT_PEND when result msg will be sent later.
int SUM_alloc(SUM_t *sum, int (*history)(const char *fmt, ...))
- Assigns storage from /SUM and does mkdir and reports wd. The dir is owned by the calling user. This is used when an application wants to make datarecords and put them in the managed /SUM storage. The application makes a SUM_alloc() call for each storage unit that it wants to output datarecords to. Also used internally to allocate storage for dataunits being retrieved from tape. (An application can make multiple SUM_alloc() calls, while previously there was only one alloc for any pe map file. Note that there is no longer any subdir naming template as prog:, level:, and series: no longer exits. Also the dsindex in now assinged at the start rather then at the end of storage unit (dataset) creation. ) NOTE: Currently you are restricted to make only one alloc at a time, i.e. reqcnt must be 1.
The caller sets: SUMID = the open id bytes = number of bytes to allocate
The function returns: Error code, else 0 on success with: dsix_ptr= Pointer to dsindex assigned to this storage unit. The application
- associates this dsindex with every datarecord that it creates in this storage unit.
wd = Pointer to string giving the allocated wd. It is of the form of
- /SUM2/D123456/ where D123456 is a unique number supplied by the DB for each SUM_alloc() call (acutally can be the dsindex). The datasegment records are created under this wd by the application with file names of the form record_666.segment_001.fits. Where 666 represents the unique record number assigned by the JSOC Data Record Managment System and 001 represents the first of possible multiple datasegments written. (Check with Rasmus.)
int SUM_alloc2(SUM_t *sum, uint64_t sunum, int (*history)(const char *fmt, ...))
- Assigns storage from /SUM for the given sunum (i.e. ds_index) and does mkdir and reports wd. NOTE: This is designed to replicate locally, data from a remote SUMS. The sunum must not be from the range of assigned sunum's for the callers local SUMS. The sunum will first be validated as not belonging to this SUMS. The dir is owned by the calling user. The application makes a SUM_alloc2() call for each storage unit that it wants to replicate data segments to. NOTE: Currently you are restricted to make only one alloc at a time, i.e. reqcnt must be 1.
The caller sets in sum: SUMID = the open id bytes = number of bytes to allocate
The function returns: Error code, else 0 on success with: dsix_ptr= Pointer to dsindex assigned to this storage unit. In this case,
- it will be the given sunum.
wd = Pointer to string giving the allocated wd. It is of the form of
- /SUM2/D123456/ where 123456 is the given sunum.
int SUM_put(SUM_t *sum, int (*history)(const char *fmt, ...))
- Puts storage units from allocated storage to the DB catalog. Upon success the wd is owned by production. NOTE: Currently you are restricted to make only one put at a time, i.e. reqcnt must be 1.
The caller sets: SUMID = the open id mode = [ARCH | TEMP | PERM] + TOUCH for a normal, temporary or permanent
- cataloging with touch option to give tdays below
tdays = If TOUCH applies, number of days to retain the storage unit dsname = dataseries name group = the storage group # for this dataseries reqcnt = Number of dsindex values given below to put dsix_ptr= Pointer to array of reqcnt uint64_t to indicate DB index of
- the dataunits
wd = Array of char * pointing to the wd of each dsindex given. Value
- is NULL for any missing dataset
int SUM_poll(SUM_t *sum)
- Check if a previous request is complete.
- Return 0 = msg complete, the sum has been updated
- TIMEOUTMSG = msg still pending, try again later
- ERRMSG = fatal error
NOTE: Upon msg complete return, sum->status != 0 if error anywhere in the
- path of the request that initially returned the RESULT_PEND status.
int SUM_wait(SUM_t *sum)
- Wait until previous request is complete
- Return 0 = msg complete, the sum has been updated
- ERRMSG = fatal error
NOTE: Upon msg complete return, sum->status != 0 if error anywhere in the
- path of the request that initially returned the RESULT_PEND status.
int SUM_info(SUM_t *sum, uint64_t sunum, int (*history)(const char *fmt, ...))
- Returns the sum_main table info for the given sunum (i.e. ds_index)
Sample use:
- SUM_info_t *sinfo; if(SUM_info(sum, 2650355, printf)) {
- printf("Fail on SUM_info() in main3\n");
sinfo = sum->sinfo; printf("sum_info online_loc = %s\n", sinfo->online_loc); printf("sum_info online_status = %s\n", sinfo->online_status); printf("sum_info archive_status = %s\n", sinfo->archive_status); printf("sum_info creat_date = %s\n", sinfo->creat_date); printf("sum_info arch_tape = %s\n", sinfo->arch_tape); printf("sum_info arch_tape_fn = %d\n", sinfo->arch_tape_fn); printf("sum_info arch_tape_date = %s\n", sinfo->arch_tape_date);
The function returns: Error code, else 0 on success with sum->sinfo pointing to: typedef struct SUM_info_struct {
- uint64_t sunum; //aka ds_index char online_loc[80]; char online_status[5]; char archive_status[5]; char offsite_ack[5]; char history_comment[80]; char owning_series[80]; int storage_group; double bytes; char creat_date[32]; char username[10]; char arch_tape[20]; int arch_tape_fn; char arch_tape_date[32]; char safe_tape[20]; int safe_tape_fn; char safe_tape_date[32]; int pa_status; int pa_substatus; char effective_date[20];
} SUM_info_t;
int SUM_delete_series(char *filename, int (*history)(const char *fmt, ...))