/* * Clear out the hcache for this particular file * from all the client nodes' hcaches. * We ensure that the owner who issued the operation * is not called back. */ void cb_clear_hashes(char *fname, unsigned long bitmap, int owner_cb_id) { int i; if (fname == NULL) { return; } LOG(stderr, DEBUG_MSG, SUBSYS_META, "cb_clear_hashes called by owner %d for %s\n", owner_cb_id, fname); i = FindFirstBit((unsigned char *)&bitmap, sizeof(bitmap)); while (i >= 0) { CLIENT **pclnt; /* i is the cb_index using which we can now make RPC callbacks */ if (i == owner_cb_id) { LOG(stderr, DEBUG_MSG, SUBSYS_META, "skipping callback id %d\n", i); i = FindNextBit((unsigned char *)&bitmap, 4, i + 1); continue; } LOG(stderr, DEBUG_MSG, SUBSYS_META, "callback id %d\n", i); pclnt = get_cb_handle(i); if (*pclnt == NULL) { errno = ECONNREFUSED; } else { enum clnt_stat result; inv_args arg; inv_resp resp; arg.id.type = FILEBYNAME; arg.id.identify_u.name = fname; /* Special callback identifier to indicate entire file */ arg.begin_chunk = -1; arg.nchunks = 0; result = capfsd_invalidate_1(arg, &resp, *pclnt); if (result != RPC_SUCCESS) { LOG(stderr, DEBUG_MSG, SUBSYS_META, "capfsd_invalidate_1 [2] to %d returned %d\n", i, result); clnt_perror(*pclnt, "capfs_invalidate_1 [2] :"); /* make it reconnect */ put_cb_handle(pclnt, 1); } else { LOG(stderr, DEBUG_MSG, SUBSYS_META, "capfsd_invalidate_1 [2] to %d returned %d\n", i, resp.status); put_cb_handle(pclnt, 0); } } i = FindNextBit((unsigned char *)&bitmap, 4, i + 1); } return; }
const_iterator & operator++ () { if (currentBit_ < CAPACITY) { ++currentBit_; FindNextBit(); } return *this; }
void Advance() { if (AtEnd()) { return; } ++current_; FindNextBit(); }
/*********************************************************************** ** FillTable() ** ** This function will insert the specified number of records into an SQL ** table. The table will be emptied first, before records are inserted. ************************************************************************/ short FillTable(TableDescription *TablePtr) { NomadInfo *NPtr; TableInfo *TPtr; ColumnInfo *pCol; ReturnStatus *RSPtr; long record_num=0; char parm_string[80]; char fields[80]; short i; long record_count; RETCODE rc; HSTMT hstmt; char command_line[SQL_MAX_COMMAND_LENGTH]; short abort_flag; short zerosum_value; short last_process_id_column; NPtr=TablePtr->NomadInfoPtr; TPtr=TablePtr->TableInfoPtr; hstmt=TablePtr->hstmt; /* if there are any records in the table to delete, then try to */ /* delete them because we must start with a clean table */ sprintf(command_line,"DELETE FROM %s",TPtr->TableName); rc=SQLExecDirect(hstmt,command_line,SQL_NTS); if(!CHECKRC(SQL_SUCCESS,rc,"SQLExecDirect")){ printf("%s return code=%d on %s\n",g_errstr,rc,command_line); LogAllErrors(NULL,NULL,hstmt); if(rc!=SQL_SUCCESS_WITH_INFO) return(FAILURE); } /*>>>need to handle the case of an entry sequenced file which we */ /*>>>can not delete from. Maybe check if it has any records in it */ /*>>>so, for now we'll just ignore any errors */ /* next, fill SQL tables with random inserts */ /* allocate record bitmaps for each table to keep track of which */ /* records have been written */ NPtr->BitmapPtr=QACreateBitmap(NPtr->max_records); if(NPtr->BitmapPtr==NULL){ LogMsg(ERRMSG+LINEAFTER, "unable to allocate space for table's bitmap\n"); return(FAILURE); } /* build the SQL INSERT statement */ if(strcmp(TPtr->ColPtr[0].CName,"SYSKEY")==0){ strcpy(fields,"SYSKEY,*"); } else strcpy(fields,"*"); sprintf(command_line,"INSERT INTO %s (%s) VALUES(?p0", TPtr->TableName,fields); for(i=1;i<TPtr->NumOfCol;i++){ sprintf(parm_string,",?p%d",i); strncat(command_line,parm_string,6); } strncat(command_line,")",2); gTrace=1; rc=SQLPrepare(hstmt,command_line,SQL_NTS); if(!CHECKRC(SQL_SUCCESS,rc,"SQLPrepare")){ LogAllErrors(NULL,NULL,hstmt); return(FAILURE); } /* are we going to fill the table with random inserts? */ if(NPtr->InitialFillMethod==FILLRANDOMLY){ if(gTrace){ LogMsg(0," -- filling table %s randomly with %ld records\n", TPtr->TableName,NPtr->InitialRecordCount); } /* randomly fill table with records */ for(record_count=0;record_count<NPtr->InitialRecordCount;record_count++){ /* randomly choose a record number which has not been chosen before */ record_num=FindNextBit(BIT_OFF,NPtr->BitmapPtr, LongRand(NPtr->max_records),CIRCULAR_SEARCH); /* if no unused records remain then something is wrong */ if(record_num<0)return(FAILURE); /* fill each field with random data appropriate to its type */ /* randomly fill values into all columns */ RSPtr=BindAndFillAllParams(hstmt,TPtr); if(RSPtr!=NULL){ LogMsg(ERRMSG+LINEAFTER, "couldn't generate random data values for all columns\n" "probable cause: row contains an unsupported data type\n" "I will continue, inserting the row as is\n"); FreeReturnStatus(RSPtr); } /* set key-column(s) */ RSPtr=SetKeyColumnValue2(TablePtr,record_num); if(RSPtr!=NULL){ LogMsg(ERRMSG+LINEAFTER, "couldn't set data value for all key columns\n" "probable cause: row contains an unsupported data type\n" "I will continue, inserting the row as is\n"); FreeReturnStatus(RSPtr); } /* set abort-column */ abort_flag=0; pCol=&(TPtr->ColPtr[NPtr->abort_column]); rc=SQLBindParameter(hstmt,(short)(NPtr->abort_column+1),SQL_PARAM_INPUT,SQL_C_SHORT, pCol->pTypeInfo->SQLDataType,pCol->DataTypeLen,0, &abort_flag,1,NULL); if(!CHECKRC(SQL_SUCCESS,rc,"SQLBindParameter")){ LogAllErrors(NULL,NULL,hstmt); if(gDebug) assert(FALSE); return(FAILURE); } /* set zerosum-column */ zerosum_value=0; pCol=&(TPtr->ColPtr[NPtr->zerosum_column]); rc=SQLBindParameter(hstmt,(short)(NPtr->zerosum_column+1),SQL_PARAM_INPUT,SQL_C_SHORT, pCol->pTypeInfo->SQLDataType,pCol->DataTypeLen,0, &zerosum_value,0,NULL); if(!CHECKRC(SQL_SUCCESS,rc,"SQLBindParameter")){ LogAllErrors(NULL,NULL,hstmt); if(gDebug) assert(FALSE); return(FAILURE); } /* set last process id column */ last_process_id_column=0; pCol=&(TPtr->ColPtr[NPtr->last_process_id_column]); rc=SQLBindParameter(hstmt,(short)(NPtr->last_process_id_column+1),SQL_PARAM_INPUT,SQL_C_SHORT, pCol->pTypeInfo->SQLDataType,pCol->DataTypeLen,0, &last_process_id_column,0,NULL); if(!CHECKRC(SQL_SUCCESS,rc,"SQLBindParameter")){ LogAllErrors(NULL,NULL,hstmt); if(gDebug) assert(FALSE); return(FAILURE); } /* EXECUTE the previously prepared INSERT statement */ rc=SQLExecute(hstmt); if(!CHECKRC(SQL_SUCCESS,rc,"SQLExecute")){ LogAllErrors(NULL,NULL,hstmt); assert(FALSE); if(rc!=SQL_SUCCESS_WITH_INFO) return(FAILURE); } /* once sucessfully inserted (or hit allowable error) then mark bit... */ /* ...in bitmap for this table */ SetBit(BIT_ON,NPtr->BitmapPtr,record_num); }/* end: for */ } /* end: if random inserts */ /* fill the table with sequential inserts starting at record zero */ else { if(gTrace){ LogMsg(0," %s\n" " -- filling table %s sequentially starting with 0 for %ld records\n", TPtr->TableName,command_line,NPtr->InitialRecordCount); } for(record_count=0;i<NPtr->InitialRecordCount;record_count++){ /* fill each field with random data appropriate to its type */ /* randomly fill values into all columns */ RSPtr=BindAndFillAllParams(hstmt,TPtr); if(RSPtr!=NULL){ LogMsg(ERRMSG+LINEAFTER, "couldn't generate random data values for all columns\n" "probable cause: row contains an unsupported data type\n" "I will continue, inserting the row as is\n"); FreeReturnStatus(RSPtr); } /* set key-column(s) */ RSPtr=SetKeyColumnValue2(TablePtr,i); if(RSPtr!=NULL){ LogMsg(ERRMSG+LINEAFTER, "couldn't set data value for all key columns\n" "probable cause: row contains an unsupported data type\n" "I will continue, inserting the row as is\n"); FreeReturnStatus(RSPtr); } /* set abort-column */ abort_flag=0; pCol=&(TPtr->ColPtr[NPtr->abort_column]); rc=SQLBindParameter(hstmt,(short)(NPtr->abort_column+1),SQL_PARAM_INPUT,SQL_C_SHORT, pCol->pTypeInfo->SQLDataType,pCol->DataTypeLen,0, &abort_flag,1,NULL); if(!CHECKRC(SQL_SUCCESS,rc,"SQLBindParameter")){ LogAllErrors(NULL,NULL,hstmt); if(gDebug) assert(FALSE); return(FAILURE); } /* set zerosum-column */ zerosum_value=0; pCol=&(TPtr->ColPtr[NPtr->zerosum_column]); rc=SQLBindParameter(hstmt,(short)(NPtr->zerosum_column+1),SQL_PARAM_INPUT,SQL_C_SHORT, pCol->pTypeInfo->SQLDataType,pCol->DataTypeLen,0, &zerosum_value,0,NULL); if(!CHECKRC(SQL_SUCCESS,rc,"SQLBindParameter")){ LogAllErrors(NULL,NULL,hstmt); if(gDebug) assert(FALSE); return(FAILURE); } /* set last process id column */ last_process_id_column=0; pCol=&(TPtr->ColPtr[NPtr->last_process_id_column]); rc=SQLBindParameter(hstmt,(short)(NPtr->last_process_id_column+1),SQL_PARAM_INPUT,SQL_C_SHORT, pCol->pTypeInfo->SQLDataType,pCol->DataTypeLen,0, &last_process_id_column,0,NULL); if(!CHECKRC(SQL_SUCCESS,rc,"SQLBindParameter")){ LogAllErrors(NULL,NULL,hstmt); if(gDebug) assert(FALSE); return(FAILURE); } /* EXECUTE the previously prepared INSERT statement */ rc=SQLExecute(hstmt); if(!CHECKRC(SQL_SUCCESS,rc,"SQLExecute")){ LogAllErrors(NULL,NULL,hstmt); if(rc!=SQL_SUCCESS_WITH_INFO) return(FAILURE); } /* once sucessfully inserted (or hit allowable error) then mark bit... */ /* ...in bitmap for this table */ SetBit(BIT_ON,NPtr->BitmapPtr,i); } } /* perform an UPDATE STATISTICS on the table, mainly to get rid of */ /* that annoying warning from SQL about no statistics available */ /* whenever anyone accesses the table */ sprintf(command_line,"UPDATE STATISTICS FOR TABLE %s ON EVERY COLUMN", TPtr->TableName); rc=SQLExecDirect(hstmt,command_line,SQL_NTS); if(!CHECKRC(SQL_SUCCESS,rc,"SQLExecDirect")){ printf("return code=%d on %s\n",rc,command_line); LogAllErrors(NULL,NULL,hstmt); if(rc!=SQL_SUCCESS_WITH_INFO) return(FAILURE); } return(SUCCESS); } /* end: FillTable() */
const_iterator(const BitSet & bitSet, unsigned int bitFrom) : bitSet_(bitSet), currentBit_(bitFrom) { FindNextBit(); }
void Reset() { current_ = 0; FindNextBit(); }
ConstIterator(const BitSet & set) : set_(set), current_(0) { FindNextBit(); }