const string lookup_node_hostname( NodeID id ) const throw( NotFoundError ) { TopologyObject obj = topology->lookupObjectById( id ); if (! obj){ throw NotFoundError(); } TopologyValue tv = topology->getAttribute( obj.id(), attrNameID ); if (! tv){ throw NotFoundError(); } return tv.value().str(); }
FilesystemID lookup_filesystemID( const string & global_unique_identifier ) const throw( NotFoundError ) { TopologyRelation tr = topology->lookupRelation(pluginTopoObjectID, fsID, global_unique_identifier ); if (! tr){ throw NotFoundError(); } return tr.child(); }
NodeID lookup_node_of_device( DeviceID id ) const throw( NotFoundError ) { TopologyValue tv = topology->getAttribute(id, attrNodeID); if ( ! tv ){ throw NotFoundError(); } return tv.value().uint32(); }
const string lookup_device_local_name( DeviceID id ) const throw( NotFoundError ) { TopologyValue tv = topology->getAttribute(id, attrDeviceNameID); if ( ! tv ){ throw NotFoundError(); } return tv.value().str(); }
UniqueInterfaceID lookup_interfaceID( const string & interface, const string & implementation ) const throw( NotFoundError ) { TopologyObject obj = topology->lookupObjectByPath( {{"Interface", interface}, {"Implementation", implementation} }, pluginTopoObjectID); if (! obj){ throw NotFoundError(); } return obj.id(); }
pair<BytesShared, size_t> PaymentOperationStateHandler::byTransaction( const TransactionUUID &transactionUUID) { string query = "SELECT state, state_bytes_count FROM " + mTableName + " WHERE transaction_uuid = ?;"; sqlite3_stmt *stmt; int rc = sqlite3_prepare_v2(mDataBase, query.c_str(), -1, &stmt, 0); if (rc != SQLITE_OK) { throw IOError("PaymentOperationStateHandler::byTransaction: " "Bad query; sqlite error: " + to_string(rc)); } rc = sqlite3_bind_blob(stmt, 1, transactionUUID.data, NodeUUID::kBytesSize, SQLITE_STATIC); if (rc != SQLITE_OK) { throw IOError("PaymentOperationStateHandler::byTransaction: " "Bad binding of TransactionUUID; sqlite error: " + to_string(rc)); } rc = sqlite3_step(stmt); if (rc == SQLITE_ROW) { size_t stateBytesCount = (size_t)sqlite3_column_int(stmt, 1); BytesShared state = tryMalloc(stateBytesCount); memcpy( state.get(), sqlite3_column_blob(stmt, 0), stateBytesCount); sqlite3_reset(stmt); sqlite3_finalize(stmt); return make_pair(state, stateBytesCount); } else { sqlite3_reset(stmt); sqlite3_finalize(stmt); throw NotFoundError("PaymentOperationStateHandler::byTransaction: " "There are now records with requested transactionUUID"); } }
UniqueComponentActivityID lookup_activityID( UniqueInterfaceID id, const string & name ) const throw( NotFoundError ) { TopologyRelation tr = topology->lookupRelation(id, activityID, name ); if (! tr){ throw NotFoundError(); } return tr.child(); }
DeviceID lookup_deviceID( NodeID id, const string & local_unique_identifier ) const throw( NotFoundError ) { TopologyRelation tr = topology->lookupRelation(id, deviceID, local_unique_identifier ); if (! tr){ throw NotFoundError(); } return tr.child(); }
const string lookup_activity_name( UniqueComponentActivityID id ) const throw( NotFoundError ) { TopologyValue tv = topology->getAttribute(id, attrNameID); if ( ! tv ){ throw NotFoundError(); } return tv.value().str(); }
uint8_t const* Zip::cacheLump(int lumpIdx) { LOG_AS("Zip::cacheLump"); if(!isValidIndex(lumpIdx)) throw NotFoundError("Zip::cacheLump", invalidIndexMessage(lumpIdx, lastIndex())); ZipFile& file = reinterpret_cast<ZipFile&>(lump(lumpIdx)); LOG_TRACE("\"%s:%s\" (%u bytes%s)") << de::NativePath(composePath()).pretty() << de::NativePath(file.composePath()).pretty() << (unsigned long) file.info().size << (file.info().isCompressed()? ", compressed" : ""); // Time to create the cache? if(!d->lumpCache) { d->lumpCache = new LumpCache(lumpCount()); } uint8_t const* data = d->lumpCache->data(lumpIdx); if(data) return data; uint8_t* region = (uint8_t*) Z_Malloc(file.info().size, PU_APPSTATIC, 0); if(!region) throw Error("Zip::cacheLump", QString("Failed on allocation of %1 bytes for cache copy of lump #%2").arg(file.info().size).arg(lumpIdx)); readLump(lumpIdx, region, false); d->lumpCache->insert(lumpIdx, region); return region; }
const string lookup_interface_implementation( UniqueInterfaceID id ) const throw( NotFoundError ) { TopologyValue tv = topology->getAttribute(id, attrImplementationNameID); if ( ! tv ){ throw NotFoundError(); } return tv.value().str(); }
File1& Zip::lump(int lumpIdx) { LOG_AS("Zip"); if(!isValidIndex(lumpIdx)) throw NotFoundError("Zip::lump", invalidIndexMessage(lumpIdx, lastIndex())); d->buildLumpNodeLut(); return *reinterpret_cast<ZipFile*>((*d->lumpNodeLut)[lumpIdx]->userPointer()); }
void CutLog::LogCut(size_t index_){ if(index_ >= fCutCounts.size()) throw NotFoundError(Formatter() << "CutLog::LogCut tried to log event as cut by non-existent cut #" << index_ ); fCutCounts[index_]++; fNEvents++; }
NodeID lookup_nodeID( const string & hostname ) const throw( NotFoundError ) { TopologyRelation tr = topology->lookupRelation( pluginTopoObjectID, hostID, hostname ); if (! tr){ throw NotFoundError(); } return tr.child(); }
const string lookup_filesystem_name( FilesystemID id ) const throw( NotFoundError ) { TopologyValue tv = topology->getAttribute(id, attrFSNameID); if ( ! tv ){ throw NotFoundError(); } return tv.value().str(); }
UniqueInterfaceID lookup_interface_of_activity( UniqueComponentActivityID id ) const throw( NotFoundError ) { TopologyValue tv = topology->getAttribute(id, attrUNIDID); if ( ! tv ){ throw NotFoundError(); } return tv.value().uint32(); }
double Gaussian::GetStDev(size_t dimension_) const{ try{ return fStdDevs.at(dimension_); } catch(const std::out_of_range& e_){ throw NotFoundError("Requested Gaussian stdDev beyond function dimensionality!"); } }
std::pair<unsigned, unsigned> BinnedEDShrinker::GetBuffer(size_t dim_) const{ try{ return fBuffers.at(dim_); } catch(const std::out_of_range&){ throw NotFoundError(Formatter() << "BinnedEDShrinker::Requested buffer boundaries on non-existent dim " << dim_ << "!"); } }
double Event::GetDatum(size_t index_) const{ try{ return fObservations.at(index_); } catch(const std::out_of_range& e_){ throw NotFoundError(Formatter() << "Event::Attempted access on non-existent observable " << index_); } }
void Heaviside::AddConstraint(unsigned dim_, double pos_, Sidedness side_){ if (dim_ >= GetNDims()) throw NotFoundError("Heaviside:: Tried to add constraint on non-existent dim!"); if (side_ != MAXIMUM && side_!= MINIMUM) throw ValueError("Heaviside:: Tried to add ambiguous constraint - MAXUMUM or MINIMUM"); fStepPosition[dim_] = pos_; fSidedness[dim_] = side_; }
Event ROOTNtuple::Assemble(size_t iEvent_) const{ if (iEvent_ >= GetNEntries()) throw NotFoundError("Exceeded end of ROOT NTuple"); fNtuple -> GetEntry(iEvent_); float* vals = fNtuple -> GetArgs(); return Event(std::vector<double> (vals, vals + GetNObservables())); }
OntologyValue optimalParameterFor( OntologyAttributeID aid, const Activity * activityToStart ) const throw( NotFoundError ) override { ///@todo Check for registered plug-in? auto res = expert.find( aid ); if( res != expert.end() ) { return res->second->optimalParameterFor( aid, activityToStart ); } else { throw NotFoundError( "No optimizer plug-in found for attribute!" ); } }
const std::string Node::getAttribute( const std::string name ) const throw( NotFoundError ) { AttribList::const_iterator iter = m_attrib.begin(); while ( iter != m_attrib.end() ) { if ( (*iter)->name() == name ) return (*iter)->value(); iter++; } throw NotFoundError( Error::errAttrNotFound, this ); }
PathTree::Node const &PathTree::find(Path const &searchPath, ComparisonFlags flags) const { DENG2_GUARD(this); Node const *found = d->find(searchPath, flags); if(!found) { /// @throw NotFoundError The referenced node could not be found. throw NotFoundError("PathTree::find", "No paths found matching \"" + searchPath + "\""); } return *found; }
bool BoxCut::PassesCut(const Event& ev_) const{ double val = 0; try{ val = ev_.GetDatum(fDim); } catch(const NotFoundError&){ throw NotFoundError("Cut::Cut to non-existent data observable requested!"); } return (val < fUpperLim && val > fLowerLim); }
void FitResult::Print() const{ if(fParameterNames.size() != fBestFit.size()) throw NotFoundError(Formatter() << "Expected one name for each parameter - got " << fParameterNames.size() << " names and " << fBestFit.size() << " params" ); std::cout << "Fit Result: " << std::endl; for(size_t i = 0; i < fParameterNames.size(); i++){ std::cout << fParameterNames.at(i) << "\t" << fBestFit.at(i) << std::endl; } }
void Node::setAttribute( const std::string name, const std::string value ) throw( NotFoundError ) { AttribList::iterator iter = m_attrib.begin(); while ( iter != m_attrib.end() ) { if ( (*iter)->name() == name ) { (*iter)->value( value ); return; } iter++; } throw NotFoundError( Error::errAttrNotFound, this ); }
void *processRequest(void* pConnfd){ printf("%ld\n",(long)pthread_self()); printf("Processing Request...\n"); int connfd = *(int*) pConnfd; while(1){ pthread_mutex_lock(&mutex); //m char buffer[1501]; ssize_t count; int hostCheck = 0; char *fileName = NULL; char *fileType = NULL; char *fileBuffer = NULL; count = read(connfd, buffer, 1500); if(count == -1){ InternalServiceError(connfd); } if(count==0){ printf("Closing\n"); close(connfd); break; } buffer[count] = '\0'; // printf("%s\n",buffer); fileName = getFileName(buffer); hostCheck = checkHostHeader(buffer); if(fileName && hostCheck){ fileType = getFileType(fileName); fileBuffer = getFileBuffer(fileName); if(fileBuffer){ printf("File: %s\n", fileName); OKResponse(fileType,fileName,fileBuffer,connfd); } else NotFoundError(connfd); } else BadRequestError(connfd); pthread_mutex_unlock(&mutex); //m } close(connfd); pthread_exit(NULL); //m }
UDPEndpoint& UUID2Address::fetchFromGlobalCache( const NodeUUID &uuid) { std::stringstream url; url << "/api/v1/nodes/" << boost::lexical_cast<string>(uuid.stringUUID()) << "/"; std::stringstream host; host << mServiceIP << ":" << mServicePort; mRequest.consume(mRequest.size()); mRequestStream << "GET " << url.str() << " HTTP/1.0\r\n"; mRequestStream << "Host: " << host.str() << "\r\n"; mRequestStream << "Accept: */*\r\n"; mRequestStream << "Connection: close\r\n\r\n"; boost::asio::connect(mSocket, mEndpointIterator); boost::asio::write(mSocket, mRequest); auto result = processResponse(); switch (result.first) { case 200: { json data = json::parse(result.second)["data"]; string address = data.value("ip_address", ""); uint16_t port = static_cast<uint16_t>(data.value("port", -1)); mCache[uuid] = as::ip::udp::endpoint( as::ip::address_v4::from_string(address), port); mLastAccessTime[uuid] = chrono::steady_clock::now(); return mCache[uuid]; } default: { throw NotFoundError( "UUID2Address::fetchFromGlobalCache: " "One or sevaral request parameters are invalid."); } } }
int CLI::evaluate(int argc, char* argv[]) { if (argc > 0) { if (Group* group = find(argv[0])) { if (Command* command = group->find(argv[1])) { std::printf("evaluate: %s %s\n", group->name().c_str(), command->name().c_str()); return command->invoke(argc - 2, argv + 2); } } if (Group* group = find("")) { if (Command* command = group->find(argv[0])) { std::printf("evaluate: %s\n", command->name().c_str()); return command->invoke(argc - 1, argv + 1); } } } throw NotFoundError(); }