00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <SUM.h>
00018 #include <soi_key.h>
00019 #include <sys/time.h>
00020 #include <sys/errno.h>
00021 #include <rpc/rpc.h>
00022 #include <rpc/pmap_clnt.h>
00023 #include <sum_rpc.h>
00024 #include <soi_error.h>
00025 #include <printk.h>
00026
00027 char *get_eff_date(int plusdays);
00028
00029 #define TODAY (atol(get_eff_date(0)))
00030 #define TAR_FILE_SZ 500000000
00031 #define ARCH_CHUNK 20
00032 #define NOTAPEARC "/usr/local/logs/soc/NOTAPEARC"
00033
00034 extern void printkey (KEY *key);
00035 void usage();
00036 void get_cmd(int argc, char *argv[]);
00037 void setup();
00038 void goaway();
00039 void print_list(char *title, PADATA *p);
00040 void print_entry(PADATA *p);
00041 void sighandler(int sig);
00042 KEY *tapearcdo_1(KEY *params);
00043 static void tapearcprog_1(struct svc_req *rqstp, SVCXPRT *transp);
00044
00045 static struct timeval TIMEOUT = { 3, 0 };
00046 static int WRTSTATUS;
00047 uint32_t rinfo;
00048 int call_tape_svc_cnt;
00049 int TAPEARCDO_called;
00050 int curr_group_id;
00051 PADATA *walker;
00052 PADATA *aplist = NULL;
00053 KEY *alist;
00054 CLIENT *current_client, *clnttape, *clntsum;
00055 SVCXPRT *glb_transp;
00056 SVCXPRT *transp;
00057
00058 int count_list(PADATA *p);
00059 int storeunitarch(int docnt);
00060 int soi_errno = NO_ERROR;
00061 char *dbname;
00062 char *username;
00063 char thishost[MAX_STR];
00064 time_t now;
00065 int verbose = 0;
00066 int debugflg = 0;
00067 int queryflg = 0;
00068 int test60d = 0;
00069 int aminflg = 0;
00070 int archive_minimum = 0;
00071 int archive_pending = 0;
00072 int is_connected=0;
00073 int ctrlcnt = 0;
00074
00075 static struct timeval first[6], second[6];
00076 float ftmp;
00077
00078
00079 void StartTimer(int n)
00080 {
00081 gettimeofday (&first[n], NULL);
00082 }
00083
00084 float StopTimer(int n)
00085 {
00086 gettimeofday (&second[n], NULL);
00087 if (first[n].tv_usec > second[n].tv_usec) {
00088 second[n].tv_usec += 1000000;
00089 second[n].tv_sec--;
00090 }
00091 return (float) (second[n].tv_sec-first[n].tv_sec) +
00092 (float) (second[n].tv_usec-first[n].tv_usec)/1000000.0;
00093 }
00094
00095
00096
00097
00098
00099
00100 int find_tapearc()
00101 {
00102 FILE *fplog;
00103 char acmd[128], line[128], look[64];
00104 char log[] = "/usr/local/logs/SUM/find_tapearc.log";
00105 int count = 0;
00106
00107 sprintf(acmd, "ps -ef | grep tapearc 1> %s 2>&1", log);
00108 if(system(acmd)) {
00109 printf("Can't execute %s.\n", acmd);
00110 return(-1);
00111 }
00112 if((fplog=fopen(log, "r")) == NULL) {
00113 printf("Can't open %s to find tapearc\n", log);
00114 return(-1);
00115 }
00116 sprintf(look, " %s", dbname);
00117 while(fgets(line, 128, fplog)) {
00118 if (strstr(line, look) && strstr(line, "tapearc")) {
00119 if(!strstr(line, "sh ")) count++;
00120 }
00121 }
00122 fclose(fplog);
00123 return (count);
00124 }
00125
00126 int count_list(PADATA *p) {
00127 PADATA *walker = p;
00128 int count=0;
00129 while (walker) {
00130 count++;
00131 walker=walker->next;
00132 }
00133 return count;
00134 }
00135
00136
00137 void print_entry(PADATA *p) {
00138 if (!p) return;
00139 printf ("%d\t%15.6e\t%s\n", p->group_id, p->bytes, p->wd);
00140 }
00141
00142 void print_list(char *title, PADATA *p) {
00143 PADATA *walker = p;
00144 if (title) printf("\n%s\n", title);
00145 while (walker) {
00146 print_entry (walker);
00147 walker = walker->next;
00148 }
00149 }
00150
00151 int send_mail(char *fmt, ...)
00152 {
00153 va_list args;
00154 char string[1024], cmd[1024];
00155
00156 va_start(args, fmt);
00157 vsprintf(string, fmt, args);
00158
00159 sprintf(cmd, "echo \"%s\" | Mail -s \"tapearc mail\" jim@sun.stanford.edu", string);
00160 system(cmd);
00161 va_end(args);
00162 return(0);
00163 }
00164
00165 void usage()
00166 {
00167 printf("This is a stand alone program that will archive all the SUMS\n");
00168 printf("archive pending storage units to the tape_svc supported drives.\n");
00169 printf("Usage: tapearc [-v] [-q] [-d] [-n arcmin] database_name\n");
00170 printf(" where -v = verbose mode\n");
00171 printf(" -q = query only mode\n");
00172 printf(" -d = run in debug mode\n");
00173 printf(" -6 = 60 day test mode. only archive test groups\n");
00174 printf(" -n arcmin = don't archive unless # in ap list > arcmin.\n");
00175 printf("NOTE: you must be user production to run.\n");
00176 exit(1);
00177 }
00178
00179
00180 void get_cmd(int argc, char *argv[])
00181 {
00182 int c;
00183
00184 while(--argc > 0 && (*++argv)[0] == '-') {
00185 while((c = *++argv[0]))
00186 switch(c) {
00187 case 'd':
00188 debugflg=1;
00189 break;
00190 case 'v':
00191 verbose=1;
00192 break;
00193 case 'n':
00194 aminflg=1;
00195 break;
00196 case 'q':
00197 queryflg=1;
00198 break;
00199 case '6':
00200 test60d=1;
00201 break;
00202 default:
00203 usage();
00204 break;
00205 }
00206 }
00207 if(aminflg) {if(argc !=2) usage();}
00208 else if(argc != 1) usage();
00209 if (aminflg) {archive_minimum = atoi(argv[0]); dbname = argv[1];}
00210 else dbname = argv[0];
00211 }
00212
00213
00214 void goaway()
00215 {
00216 if(is_connected)
00217 if(DS_DisConnectDB())
00218 fprintf(stderr, "DS_DisconnectDB() error\n");
00219 exit(1);
00220 }
00221
00222
00223 void sighandler(int sig)
00224 {
00225 char line[80];
00226
00227
00228
00229
00230 if(ctrlcnt++ == 0) {
00231 printf("\nInterrupt not allowed during tape write operations...\n");
00232 printf("Hit ^C again for an option to abort...\n");
00233 }
00234 else {
00235 printf("Do you want to force an abort (make sure you know what you're doing) [y/n] = ");
00236 if(gets(line) == NULL) { return; }
00237 if(!strcmp(line, "y")) { goaway(); }
00238 }
00239 }
00240
00241
00242
00243 void setup()
00244 {
00245 char *cptr;
00246 int n;
00247 char pgport[32];
00248
00249 printk_set(printf, printf);
00250 gethostname(thishost, MAX_STR);
00251 cptr = index(thishost, '.');
00252 if(cptr) *cptr = (char)NULL;
00254 sprintf(thishost, "localhost");
00255 n = find_tapearc();
00256 if(n > 1) {
00257 printf("%s: Only one tapearc %s allowed at a time. I see %d\n",
00258 thishost, dbname,n);
00259
00260
00261 exit(1);
00262 }
00263
00264
00265
00266
00267
00269
00270
00271 if (signal(SIGINT, SIG_IGN) != SIG_IGN)
00272 signal(SIGINT, sighandler);
00273 if (signal(SIGTERM, SIG_IGN) != SIG_IGN)
00274 signal(SIGTERM, sighandler);
00275
00276
00277 (void) pmap_unset(TAPEARCPROG, TAPEARCVERS);
00278 transp = svctcp_create(RPC_ANYSOCK, 0, 0);
00279 if (transp == NULL) {
00280 printf("***cannot create tcp service\n");
00281 exit(1);
00282 }
00283 if (!svc_register(transp, TAPEARCPROG, TAPEARCVERS, tapearcprog_1, IPPROTO_TCP)) {
00284 printf("***unable to register (TAPEARCPROG, TAPEARCVERS, tcp)\n");
00285 exit(1);
00286 }
00287
00288 clnttape = clnt_create(thishost, TAPEPROG, TAPEVERS, "tcp");
00289 if(!clnttape) {
00290 clnt_pcreateerror("Can't get client handle to tape_svc in tapearc");
00291 printf("tapearc can't get tape_svc handle on %s\n", thishost);
00292 exit(1);
00293 }
00294 clntsum = clnt_create(thishost, SUMPROG, SUMVERS, "tcp");
00295 if(!clntsum) {
00296 clnt_pcreateerror("Can't get client handle to sum_svc in tapearc");
00297 printf("***tapearc can't get sum_svc on %s\n", thishost);
00298 exit(1);
00299 }
00300
00301
00302 if (DS_ConnectDB(dbname)) {
00303 fprintf(stderr,"Error in connecting to database %s\n", dbname);
00304 goaway();
00305 }
00306 is_connected=1;
00307 call_tape_svc_cnt = 0;
00308 }
00309
00310
00311
00312
00313 int call_tape_svc(int groupid, double bytes, uint64_t index) {
00314 int status;
00315 uint32_t retstat;
00316 char *call_err;
00317
00318 WRTSTATUS = 0;
00319 StartTimer(0);
00320 status = clnt_call(clnttape, WRITEDO, (xdrproc_t)xdr_Rkey, (char *)alist,
00321 (xdrproc_t)xdr_uint32_t, (char *)&retstat, TIMEOUT);
00322
00323
00324
00325
00326 if(status != 0) {
00327 clnt_perrno(status);
00328 printf("***Error on clnt_call() to tape_svc WRITEDO procedure\n");
00329
00330
00331 call_err = clnt_sperror(clnttape, "Err");
00332 printf("%s\n", call_err);
00333 if(status != RPC_TIMEDOUT) {
00334 printf("I'm aborting now...\n");
00335 if(is_connected)
00336 if(DS_DisConnectDB())
00337 fprintf(stderr, "DS_DisconnectDB() error\n");
00338 exit(1);
00339 }
00340 else {
00341
00342 ftmp = StopTimer(0);
00343 printf("Measured timeout was %f sec\n", ftmp);
00344 call_tape_svc_cnt++;
00345 printf("RESULT_PEND (!!ASSUMED) group_id=%d bytes=%g 1st_ds_index=%lu. Arc in progress...\n", groupid, bytes, index);
00346 return(0);
00347 }
00348 }
00349 if(retstat == RESULT_PEND) {
00350 call_tape_svc_cnt++;
00351 printf("RESULT_PEND group_id=%d bytes=%g 1st_ds_index=%lu. Arc in progress...\n",
00352 groupid, bytes, index);
00353 }
00354 else {
00355 if(retstat == NO_TAPE_IN_GROUP) {
00356 printf("Can't assign tape for group id %d\n", groupid);
00357 printf("Check tape_svc log for any error messages\n");
00358 printf("I'm aborting now...\n");
00359 if(is_connected)
00360 if(DS_DisConnectDB())
00361 fprintf(stderr, "DS_DisconnectDB() error\n");
00362 exit(1);
00363 }
00364 else if(retstat == NO_CLNTTCP_CREATE) {
00365 printf("NO_CLNTTCP_CREATE error on ret from clnt_call(clntape,WRITEDO)\n");
00366 printf("Check tape_svc log for any error messages\n");
00367 printf("I'm aborting now...\n");
00368 if(is_connected)
00369 if(DS_DisConnectDB())
00370 fprintf(stderr, "DS_DisconnectDB() error\n");
00371 exit(1);
00372 }
00373 else
00374 printf("retstat = %d on ret from clnt_call(clntape,WRITEDO)\n",retstat);
00375 }
00376 return(0);
00377 }
00378
00379 int main(int argc, char *argv[])
00380 {
00381 FILE *notapearc;
00382 PADATA *ap = NULL;
00383
00384 get_cmd(argc, argv);
00385 if(!(username = (char *)getenv("USER"))) username = "nouser";
00386
00387 if(strcmp(username, "production")) {
00388 if(strcmp(username, "jim")) {
00389 printf("!!NOTE: You must be user production to run tapearc!\n");
00390 exit(1);
00391 }
00392 }
00393 if((notapearc=fopen(NOTAPEARC, "r")) != NULL) {
00394 printf("Can't run a tapearc while Imp/Exp of tapes is active\n");
00395 fclose(notapearc);
00396 exit(-1);
00397 }
00398
00399 printf ("Current effective_date is %ld\n", TODAY);
00400 time (&now); printf ("%s\n",asctime(localtime(&now)));
00401 printf ("Datasets will be archived if there are more than %d\n",
00402 archive_minimum);
00403 setup();
00404
00405
00406 if(test60d) {
00407 aplist = NC_PaRequest_AP_60d();
00408 }
00409 else {
00410 aplist = NC_PaRequest_AP(3);
00411 }
00412 archive_pending = count_list(aplist);
00413 if (verbose || queryflg) {
00414 printf("\nThere are %d entries in the archive pending list.\n",
00415 archive_pending);
00416 print_list ("archive pending list", aplist);
00417 printf("archive pending will be grouped into %d byte tar files\n", TAR_FILE_SZ);
00418 if(queryflg) goaway();
00419 }
00420 if (archive_pending <= archive_minimum) {
00421 printf("\nThe number of archive pending entries (%d) is <= %d\n",
00422 archive_pending, archive_minimum);
00423 goaway();
00424 }
00425
00426 walker = aplist;
00427
00429 while(walker) {
00430 if(walker->group_id == 0) {
00431 setpadata(&ap, walker->wd, walker->sumid, walker->bytes, walker->status, walker->archsub, walker->effective_date, walker->group_id, walker->safe_id, walker->ds_index);
00432 }
00433 walker = walker->next;
00434 }
00435 walker = aplist;
00436 while(walker) {
00437 if(walker->group_id == 1) {
00438 setpadata(&ap, walker->wd, walker->sumid, walker->bytes, walker->status, walker->archsub, walker->effective_date, walker->group_id, walker->safe_id, walker->ds_index);
00439 }
00440 walker = walker->next;
00441 }
00442 walker = aplist;
00443 while(walker) {
00444 if(walker->group_id == 2) {
00445 setpadata(&ap, walker->wd, walker->sumid, walker->bytes, walker->status, walker->archsub, walker->effective_date, walker->group_id, walker->safe_id, walker->ds_index);
00446 }
00447 walker = walker->next;
00448 }
00449 walker = aplist;
00450 while(walker) {
00451 if(walker->group_id == 3) {
00452 setpadata(&ap, walker->wd, walker->sumid, walker->bytes, walker->status, walker->archsub, walker->effective_date, walker->group_id, walker->safe_id, walker->ds_index);
00453 }
00454 walker = walker->next;
00455 }
00456 walker = aplist;
00457 while(walker) {
00458 if(walker->group_id == 4) {
00459 setpadata(&ap, walker->wd, walker->sumid, walker->bytes, walker->status, walker->archsub, walker->effective_date, walker->group_id, walker->safe_id, walker->ds_index);
00460 }
00461 walker = walker->next;
00462 }
00463 walker = aplist;
00464 while(walker) {
00465 if(walker->group_id == 5) {
00466 setpadata(&ap, walker->wd, walker->sumid, walker->bytes, walker->status, walker->archsub, walker->effective_date, walker->group_id, walker->safe_id, walker->ds_index);
00467 }
00468 walker = walker->next;
00469 }
00470 walker = aplist;
00471 while(walker) {
00472 if(walker->group_id == 102) {
00473 setpadata(&ap, walker->wd, walker->sumid, walker->bytes, walker->status, walker->archsub, walker->effective_date, walker->group_id, walker->safe_id, walker->ds_index);
00474 }
00475 walker = walker->next;
00476 }
00477 walker = aplist;
00478 while(walker) {
00479 if(walker->group_id == 103) {
00480 setpadata(&ap, walker->wd, walker->sumid, walker->bytes, walker->status, walker->archsub, walker->effective_date, walker->group_id, walker->safe_id, walker->ds_index);
00481 }
00482 walker = walker->next;
00483 }
00484 walker = aplist;
00485 while(walker) {
00486 if(walker->group_id == 104) {
00487 setpadata(&ap, walker->wd, walker->sumid, walker->bytes, walker->status, walker->archsub, walker->effective_date, walker->group_id, walker->safe_id, walker->ds_index);
00488 }
00489 walker = walker->next;
00490 }
00491 walker = aplist;
00492 while(walker) {
00493 if(walker->group_id == 105) {
00494 setpadata(&ap, walker->wd, walker->sumid, walker->bytes, walker->status, walker->archsub, walker->effective_date, walker->group_id, walker->safe_id, walker->ds_index);
00495 }
00496 walker = walker->next;
00497 }
00498 walker = ap;
00499 printf("walker list s/b by group_id\n");
00500 while(walker) {
00501 printf("group_id=%d bytes=%15.6e\n", walker->group_id, walker->bytes);
00502 walker = walker->next;
00503 }
00504 walker = ap;
00506
00507 storeunitarch(ARCH_CHUNK);
00508 if(call_tape_svc_cnt == 0) {
00509 if(is_connected)
00510 if(DS_DisConnectDB())
00511 fprintf(stderr, "DS_DisconnectDB() error\n");
00512 exit(0);
00513 }
00514 svc_run();
00515 }
00516
00517
00518
00519
00520
00521 static void
00522 tapearcprog_1(rqstp, transp)
00523 struct svc_req *rqstp;
00524 SVCXPRT *transp;
00525 {
00526 union __svcargun {
00527 Rkey tapearcdo_1_arg;
00528 } argument;
00529 char *result;
00530
00531 bool_t (*xdr_argument)(), (*xdr_result)();
00532 char *(*local)();
00533 switch (rqstp->rq_proc) {
00534 case NULLPROC:
00535 printf("Called NULLPROC in tapearcprog_1()\n");
00536 (void) svc_sendreply(transp, (xdrproc_t)xdr_void, (char *)NULL);
00537 return;
00538 case TAPEARCDO:
00539
00540 TAPEARCDO_called = 1;
00541 xdr_argument = xdr_Rkey;
00542 xdr_result = xdr_Rkey;;
00543 local = (char *(*)()) tapearcdo_1;
00544 break;
00545 default:
00546 printf("**tapearcprog_1() dispatch default procedure %ld,ignore\n", rqstp->rq_proc);
00547 (void) svc_sendreply(transp, (xdrproc_t)xdr_void, (char *)NULL);
00548 svcerr_noproc(transp);
00549 return;
00550 }
00551 bzero((char *)&argument, sizeof(argument));
00552 if (!svc_getargs(transp, (xdrproc_t)xdr_argument, (char *)&argument)) {
00553 printf("***Error on svc_getargs()\n");
00554 svcerr_decode(transp);
00555 svc_sendreply(transp, (xdrproc_t)xdr_void, (char *)NULL);
00556 return;
00557
00558 }
00559
00560 if(!svc_sendreply(transp, (xdrproc_t)xdr_void, (char *)NULL)) {
00561 svcerr_systemerr(transp);
00562 return;
00563 }
00564 glb_transp = transp;
00565 result = (*local)(&argument, rqstp);
00566
00567
00568 if (!svc_freeargs(transp, (xdrproc_t)xdr_argument, (char *)&argument)) {
00569 printf("**unable to free arguments\n");
00570
00571 }
00572 return;
00573 }
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620 KEY *tapearcdo_1(KEY *params)
00621 {
00622 int groupid;
00623 uint64_t index;
00624
00625
00626 groupid = getkey_int(params, "group_id");
00627 index = getkey_uint64(params, "ds_index_0");
00628 if(findkey(params, "DEBUGFLG")) {
00629 debugflg = getkey_int(params, "DEBUGFLG");
00630 if(debugflg) {
00631 printf("!!TEMP in tapearcdo_1() call in tapearc. keylist is:\n");
00632 keyiterate(printkey, params);
00633 }
00634 }
00635 if(WRTSTATUS = getkey_int(params, "STATUS")) {
00636 printf("**Error return for write of group_id=%d 1st ds_index=%lu\n",
00637 groupid, index);
00638 }
00639 else {
00640 printf("Successful write for group_id=%d 1st_ds_index=%lu\n",
00641 groupid, index);
00642 }
00643 --call_tape_svc_cnt;
00644 if(storeunitarch(1)) {
00645 if(call_tape_svc_cnt == 0) {
00646 if(is_connected)
00647 if(DS_DisConnectDB())
00648 fprintf(stderr, "DS_DisconnectDB() error\n");
00649 exit(0);
00650 }
00651 }
00652
00653
00654 return((KEY *)1);
00655 }
00656
00657
00658
00659
00660
00661
00662
00663 int storeunitarch(int docnt)
00664 {
00665 int i, chunkcnt, wd_max_call_cnt;
00666 uint32_t sback;
00667 uint64_t first_index;
00668 char name[128];
00669 enum clnt_stat status;
00670 double curr_group_sz, total_bytes;
00671
00672 if(!walker) return(1);
00673 curr_group_id = walker->group_id;
00674 first_index = walker->ds_index;
00675 curr_group_sz = 0.0;
00676 i = 0;
00677 chunkcnt = 0;
00678 wd_max_call_cnt = 0;
00679 alist = newkeylist();
00680 while(walker) {
00681
00682 if(walker->archsub == DAAEDDP) {
00683 printf("Don't archive temp storage unit at %s\n", walker->wd);
00684 walker=walker->next;
00685 continue;
00686 }
00687
00688
00689 curr_group_sz += walker->bytes;
00690 if(curr_group_sz >= TAR_FILE_SZ) {
00691 total_bytes = curr_group_sz;
00692 sprintf(name, "wd_%d", i);
00693 setkey_str(&alist, name, walker->wd);
00694 sprintf(name, "effective_date_%d", i);
00695 setkey_str(&alist, name, walker->effective_date);
00696 sprintf(name, "sumid_%d", i);
00697 setkey_uint64(&alist, name, walker->sumid);
00698 sprintf(name, "bytes_%d", i);
00699 setkey_double(&alist, name, walker->bytes);
00700 sprintf(name, "status_%d", i);
00701 setkey_int(&alist, name, walker->status);
00702 sprintf(name, "archsub_%d", i);
00703 setkey_int(&alist, name, walker->archsub);
00704 sprintf(name, "group_id_%d", i);
00705 setkey_int(&alist, name, walker->group_id);
00706 sprintf(name, "safe_id_%d", i);
00707 setkey_int(&alist, name, walker->safe_id);
00708 sprintf(name, "ds_index_%d", i);
00709 setkey_uint64(&alist, name, walker->ds_index);
00710 sprintf(name, "username_%d", i);
00711 setkey_str(&alist, name, username);
00712 setkey_int(&alist, "DEBUGFLG", debugflg);
00713 chunkcnt++;
00714 i++;
00715 walker=walker->next;
00716 }
00717 else if((walker->group_id == curr_group_id) && (curr_group_sz < TAR_FILE_SZ) && (wd_max_call_cnt < MAXSUMREQCNT)) {
00718 total_bytes = curr_group_sz;
00719 wd_max_call_cnt++;
00720 sprintf(name, "wd_%d", i);
00721 setkey_str(&alist, name, walker->wd);
00722 sprintf(name, "effective_date_%d", i);
00723 setkey_str(&alist, name, walker->effective_date);
00724 sprintf(name, "sumid_%d", i);
00725 setkey_uint64(&alist, name, walker->sumid);
00726 sprintf(name, "bytes_%d", i);
00727 setkey_double(&alist, name, walker->bytes);
00728 sprintf(name, "status_%d", i);
00729 setkey_int(&alist, name, walker->status);
00730 sprintf(name, "archsub_%d", i);
00731 setkey_int(&alist, name, walker->archsub);
00732 sprintf(name, "group_id_%d", i);
00733 setkey_int(&alist, name, walker->group_id);
00734 sprintf(name, "safe_id_%d", i);
00735 setkey_int(&alist, name, walker->safe_id);
00736 sprintf(name, "ds_index_%d", i);
00737 setkey_uint64(&alist, name, walker->ds_index);
00738 sprintf(name, "username_%d", i);
00739 setkey_str(&alist, name, username);
00740 setkey_int(&alist, "DEBUGFLG", debugflg);
00741 i++;
00742 walker=walker->next;
00743 continue;
00744 }
00745 setkey_double(&alist, "total_bytes", total_bytes);
00746 setkey_int(&alist, "reqcnt", i);
00747 if(i != 0) {
00748
00749
00750
00751
00752
00753 printf("Call tape_svc here for group_id=%d bytes=%15.6e 1st ds_index=%lu\n",
00754 curr_group_id, total_bytes, first_index);
00755 }
00756 freekeylist(&alist);
00757 if(chunkcnt == docnt) {
00758 return(0);
00759 }
00760 if(walker) {
00761 curr_group_id = walker->group_id;
00762 first_index = walker->ds_index;
00763 }
00764 curr_group_sz = 0.0;
00765 wd_max_call_cnt = 0;
00766 i = 0;
00767 alist = newkeylist();
00768 }
00769 if(i != 0) {
00770 setkey_double(&alist, "total_bytes", total_bytes);
00771 setkey_int(&alist, "reqcnt", i);
00772
00773
00774
00775
00776
00777 printf("Call tape_svc here for group_id=%d bytes=%15.6e 1st ds_index=%lu\n",
00778 curr_group_id, total_bytes, first_index);
00779 }
00780 return(0);
00781 }
00782
00783
00784
00785
00786 char *get_eff_date(int plusdays)
00787 {
00788 struct timeval tvalr;
00789 struct tm *t_ptr;
00790 time_t newtime;
00791 char *timestr;
00792
00793 if(gettimeofday(&tvalr, NULL) == -1) {
00794 return("200712121212");
00795 }
00796 t_ptr = localtime(&tvalr.tv_sec);
00797 t_ptr->tm_mday = t_ptr->tm_mday + plusdays;
00798 newtime = mktime(t_ptr);
00799 t_ptr = localtime(&newtime);
00800 timestr = (char *)malloc(32);
00801 sprintf(timestr, "%04d%02d%02d%02d%02d",
00802 t_ptr->tm_year+1900, t_ptr->tm_mon+1, t_ptr->tm_mday,
00803 t_ptr->tm_hour, t_ptr->tm_min);
00804 return(timestr);
00805 }