void MatrixBlock::gather_reduced_matrix() { int info; if(world.rank() != 0) { std::vector<mpi::request> requests(4); requests[0] = world.isend(0, COUPLING_UPPER_1, this->coupling_correction_upper[0]); if (world.rank() != world.size() - 1) { requests[1] = world.isend(0, COUPLING_UPPER_M, this->coupling_correction_upper[this->block_size-1]); requests[2] = world.isend(0, COUPLING_LOWER_1, this->coupling_correction_lower[0]); requests[3] = world.isend(0, COUPLING_LOWER_M, this->coupling_correction_lower[this->block_size-1]); } mpi::wait_all(requests.begin(), requests.end()); } else { std::vector<mpi::request> requests(4*(world.size()-2)+1); for(int i=1; i < world.size(); i++) { requests[4*(i-1)] = world.irecv(i, COUPLING_UPPER_1, this->reduced_diag[2*i-1]); if(i != world.size() - 1) { requests[4*(i-1)+1] = world.irecv(i, COUPLING_UPPER_M, this->reduced_lower_diag[2*i-1]); requests[4*(i-1)+2] = world.irecv(i, COUPLING_LOWER_1, this->reduced_upper_diag[2*i-1]); requests[4*(i-1)+3] = world.irecv(i, COUPLING_LOWER_M, this->reduced_diag[2*i]); } this->reduced_diag[0] = this->coupling_correction_lower[this->block_size-1]; for(int i=0; i < (world.size()-1); i++) { this->reduced_upper_diag[2*i] = this->reduced_lower_diag[2*i] = 1; } } mpi::wait_all(requests.begin(), requests.end()); } if(world.rank() == 0) { int reduced_size = 2*(world.size()-1); dgttrf_ (& reduced_size, this->reduced_lower_diag, this->reduced_diag, this->reduced_upper_diag, this->reduced_U_upper_diag2, this->reduced_pivot_permutations, & info); } }
nsresult MediaKeySystemAccessManager::Observe(nsISupports* aSubject, const char* aTopic, const char16_t* aData) { EME_LOG("MediaKeySystemAccessManager::Observe %s", aTopic); if (!strcmp(aTopic, "gmp-path-added")) { nsTArray<PendingRequest> requests(Move(mRequests)); // Retry all pending requests, but this time fail if the CDM is not installed. for (PendingRequest& request : requests) { RetryRequest(request); } } else if (!strcmp(aTopic, "timer-callback")) { // Find the timer that expired and re-run the request for it. nsCOMPtr<nsITimer> timer(do_QueryInterface(aSubject)); for (size_t i = 0; i < mRequests.Length(); i++) { if (mRequests[i].mTimer == timer) { EME_LOG("MediaKeySystemAccessManager::AwaitInstall resuming request"); PendingRequest request = mRequests[i]; mRequests.RemoveElementAt(i); RetryRequest(request); break; } } } return NS_OK; }
void DistMap::Translate ( vector<Int>& localInds, const vector<int>& origOwners ) const { DEBUG_CSE const Int numLocalInds = localInds.size(); // Count how many indices we need each process to map // Avoid unncessary branching within the loop by avoiding RowToProcess vector<int> requestSizes( commSize_, 0 ); for( Int s=0; s<numLocalInds; ++s ) { const Int i = localInds[s]; if( i < numSources_ ) ++requestSizes[origOwners[s]]; } // Send our requests and find out what we need to fulfill vector<int> fulfillSizes( commSize_ ); mpi::AllToAll( requestSizes.data(), 1, fulfillSizes.data(), 1, comm_ ); // Prepare for the AllToAll to exchange request sizes vector<int> requestOffs, fulfillOffs; const int numRequests = Scan( requestSizes, requestOffs ); const int numFulfills = Scan( fulfillSizes, fulfillOffs ); // Pack the requested information vector<int> requests( numRequests ); auto offs = requestOffs; for( Int s=0; s<numLocalInds; ++s ) { const Int i = localInds[s]; if( i < numSources_ ) requests[offs[origOwners[s]]++] = i; } // Perform the first index exchange vector<int> fulfills( numFulfills ); mpi::AllToAll ( requests.data(), requestSizes.data(), requestOffs.data(), fulfills.data(), fulfillSizes.data(), fulfillOffs.data(), comm_ ); // Map all of the indices in 'fulfills' for( int s=0; s<numFulfills; ++s ) { const Int i = fulfills[s]; const Int iLocal = i - blocksize_*commRank_; DEBUG_ONLY( if( iLocal < 0 || iLocal >= (Int)map_.size() ) LogicError ("invalid request: i=",i,", iLocal=",iLocal, ", commRank=",commRank_,", blocksize=",blocksize_); ) fulfills[s] = map_[iLocal]; }
void ApiWrap::gotReplyTo(ChannelData *channel, const MTPmessages_Messages &msgs, mtpRequestId req) { switch (msgs.type()) { case mtpc_messages_messages: { const MTPDmessages_messages &d(msgs.c_messages_messages()); App::feedUsers(d.vusers); App::feedChats(d.vchats); App::feedMsgs(d.vmessages, NewMessageExisting); } break; case mtpc_messages_messagesSlice: { const MTPDmessages_messagesSlice &d(msgs.c_messages_messagesSlice()); App::feedUsers(d.vusers); App::feedChats(d.vchats); App::feedMsgs(d.vmessages, NewMessageExisting); } break; case mtpc_messages_channelMessages: { const MTPDmessages_channelMessages &d(msgs.c_messages_channelMessages()); if (channel) { channel->ptsReceived(d.vpts.v); } else { LOG(("App Error: received messages.channelMessages when no channel was passed! (ApiWrap::gotReplyTo)")); } if (d.has_collapsed()) { // should not be returned LOG(("API Error: channels.getMessages and messages.getMessages should not return collapsed groups! (ApiWrap::gotReplyTo)")); } App::feedUsers(d.vusers); App::feedChats(d.vchats); App::feedMsgs(d.vmessages, NewMessageExisting); } break; } ReplyToRequests *requests(replyToRequests(channel, true)); if (requests) { for (ReplyToRequests::iterator i = requests->begin(); i != requests->cend();) { if (i.value().req == req) { for (QList<HistoryReply*>::const_iterator j = i.value().replies.cbegin(), e = i.value().replies.cend(); j != e; ++j) { if (*j) { (*j)->updateReplyTo(true); } else { App::main()->updateReplyTo(); } } i = requests->erase(i); } else { ++i; } } if (channel && requests->isEmpty()) { _channelReplyToRequests.remove(channel); } } }
bool PaintingTasks::serviceRequests() { if (requests().isEmpty()) return false; for (auto& request : requests()) { RenderObject* renderer = request->element->renderer(); if (!renderer || !renderer->isBox()) continue; request->context = PaintingContext::create(request->element, toRenderBox(renderer)->size()); } Vector<OwnPtr<RequestTask>> local; swap(requests(), local); for (const auto& request : local) { if (!request->context) continue; request->callback->handleEvent(request->context.get()); } return true; }
void MediaKeySystemAccessManager::Shutdown() { EME_LOG("MediaKeySystemAccessManager::Shutdown"); nsTArray<PendingRequest> requests(Move(mRequests)); for (PendingRequest& request : requests) { // Cancel all requests; we're shutting down. request.CancelTimer(); request.RejectPromise(NS_LITERAL_CSTRING("Promise still outstanding at MediaKeySystemAccessManager shutdown")); } if (mAddedObservers) { nsCOMPtr<nsIObserverService> obsService = mozilla::services::GetObserverService(); if (obsService) { obsService->RemoveObserver(this, "gmp-path-added"); mAddedObservers = false; } } }
void UnitTestSTKParallelDistributedIndex::test_generate_bad() { typedef stk::parallel::DistributedIndex PDIndex ; stk::ParallelMachine comm = MPI_COMM_WORLD ; int mpi_rank = stk::parallel_machine_rank(comm); int mpi_size = stk::parallel_machine_size(comm); PDIndex::KeySpanVector partition_spans ; generate_test_spans_10x10000( partition_spans ); PDIndex di( comm , partition_spans ); std::vector<size_t> requests( partition_spans.size() , 0u ); std::vector< PDIndex::KeyTypeVector > generated_keys ; //------------------------------ for ( size_t i = 0 ; i < requests.size() ; ++i ) { requests[i] = 10 ; } if( mpi_rank == mpi_size -1 ) { requests.clear(); } ASSERT_THROW( di.generate_new_keys( requests , generated_keys ), std::runtime_error ); if( mpi_rank == mpi_size -1 ) { requests.push_back(2*(partition_spans[0].second - partition_spans[0].first)); } ASSERT_THROW( di.generate_new_keys( requests , generated_keys ), std::runtime_error ); for ( size_t i = 0 ; i < requests.size() ; ++i ) { requests[i] = partition_spans[i].second - partition_spans[i].first ; } ASSERT_THROW( di.generate_new_keys( requests , generated_keys ), std::runtime_error ); }
void ApiWrap::itemRemoved(HistoryItem *item) { if (HistoryReply *reply = item->toHistoryReply()) { ChannelData *channel = reply->history()->peer->asChannel(); ReplyToRequests *requests(replyToRequests(channel, true)); if (requests) { ReplyToRequests::iterator i = requests->find(reply->replyToId()); if (i != requests->cend()) { for (QList<HistoryReply*>::iterator j = i->replies.begin(); j != i->replies.end();) { if ((*j) == reply) { j = i->replies.erase(j); } else { ++j; } } if (i->replies.isEmpty()) { requests->erase(i); } } if (channel && requests->isEmpty()) { _channelReplyToRequests.remove(channel); } } } }
NS_IMETHODIMP SmsManager::Send(const jsval& aNumber, const nsAString& aMessage, jsval* aReturn) { nsresult rv; nsIScriptContext* sc = GetContextForEventHandlers(&rv); NS_ENSURE_STATE(sc); JSContext* cx = sc->GetNativeContext(); NS_ASSERTION(cx, "Failed to get a context!"); if (!aNumber.isString() && !(aNumber.isObject() && JS_IsArrayObject(cx, &aNumber.toObject()))) { return NS_ERROR_INVALID_ARG; } JSObject* global = sc->GetNativeGlobal(); NS_ASSERTION(global, "Failed to get global object!"); JSAutoRequest ar(cx); JSAutoCompartment ac(cx, global); if (aNumber.isString()) { return Send(cx, global, aNumber.toString(), aMessage, aReturn); } // Must be an object then. if (!aNumber.isObject()) { return NS_ERROR_FAILURE; } JSObject& numbers = aNumber.toObject(); uint32_t size; if (!JS_GetArrayLength(cx, &numbers, &size)) { return NS_ERROR_FAILURE; } JS::AutoValueVector requests(cx); if (!requests.resize(size)) { return NS_ERROR_FAILURE; } JSString *str; for (uint32_t i = 0; i < size; ++i) { jsval number; if (!JS_GetElement(cx, &numbers, i, &number)) { return NS_ERROR_INVALID_ARG; } str = JS_ValueToString(cx, number); if (!str) { return NS_ERROR_FAILURE; } nsresult rv = Send(cx, global, str, aMessage, &requests[i]); NS_ENSURE_SUCCESS(rv, rv); } JSObject* obj = JS_NewArrayObject(cx, requests.length(), requests.begin()); if (!obj) { return NS_ERROR_FAILURE; } aReturn->setObject(*obj); return NS_OK; }
bool element_death_use_case_1(stk::ParallelMachine pm) { //set up the mesh stk::mesh::fixtures::GridFixture fixture(pm); stk::mesh::BulkData& mesh = fixture.bulk_data(); stk::mesh::MetaData& fem_meta = fixture.fem_meta(); const stk::mesh::EntityRank element_rank = stk::topology::ELEMENT_RANK; const stk::mesh::EntityRank side_rank = fem_meta.side_rank(); fem_meta.commit(); mesh.modification_begin(); fixture.generate_grid(); mesh.modification_end(); stk::mesh::skin_mesh(mesh); // Nothing happens on iteration #0, // so the initial mesh should pass this validation. if ( ! validate_iteration( pm, fixture, 0) ) { return false ; } stk::mesh::Part & dead_part = *fixture.dead_part(); stk::mesh::PartVector dead_parts; dead_parts.push_back( & dead_part); bool passed = true; stk::mesh::EntityRank mesh_rank = element_rank; for (int iteration = 0; iteration <NUM_ITERATIONS; ++iteration) { //find the entities to kill in this iteration stk::mesh::EntityVector entities_to_kill = entities_to_be_killed(mesh, iteration, element_rank); // find the parallel-consistent closure of the entities to be killed // The closure of an entity includes the entity and any lower ranked // entities which are reachable through relations. For example, the // closure of an element consist of the element and the faces, edges, // and nodes that are attached to the element through relations. // // The find closure function will return a sorted parallel consistent vector // which contains all the entities that make up the closure of the input // vector. stk::mesh::EntityVector entities_closure; stk::mesh::find_closure(mesh, entities_to_kill, entities_closure); // find the boundary of the entities we're killing stk::mesh::EntitySideVector boundary; stk::mesh::boundary_analysis(mesh, entities_closure, mesh_rank, boundary); // Find the sides that need to be created. // Sides need to be created when the outside // of the boundary is both live and owned and // a side separating the live and dead doesn't // already exist. stk::mesh::Selector select_owned = fem_meta.locally_owned_part(); stk::mesh::Selector select_live = ! dead_part ; stk::mesh::Selector select_live_and_owned = select_live & select_owned; std::vector<stk::mesh::EntitySideComponent> skin; find_sides_to_be_created(mesh, boundary, select_live_and_owned, skin, side_rank); mesh.modification_begin(); // Kill entities by moving them to the dead part. for (stk::mesh::EntityVector::iterator itr = entities_to_kill.begin(); itr != entities_to_kill.end(); ++itr) { mesh.change_entity_parts(*itr, dead_parts); } // Ask for new entities to represent the sides between the live and dead entities // std::vector<size_t> requests(fem_meta.entity_rank_count(), 0); requests[side_rank] = skin.size(); // generate_new_entities creates new blank entities of the requested ranks stk::mesh::EntityVector requested_entities; mesh.generate_new_entities(requests, requested_entities); // Create boundaries between live and dead entities // by creating a relation between the new entities and the live entities for ( size_t i = 0; i < skin.size(); ++i) { stk::mesh::Entity entity = skin[i].entity; const unsigned side_ordinal = skin[i].side_ordinal; stk::mesh::Entity side = requested_entities[i]; stk::mesh::declare_element_side(mesh, entity, side, side_ordinal); } mesh.modification_end(); //the modification_end() will communicate which entities have been changed //to other processes. //find lower ranked entity that are only related to the dead entities //and kill them for (stk::mesh::EntityRank irank = stk::topology::BEGIN_RANK; irank <= side_rank; ++irank) { stk::mesh::EntityRank rank = static_cast<stk::mesh::EntityRank>(side_rank - irank); stk::mesh::EntityVector kill_list; find_lower_rank_entities_to_kill( mesh, entities_closure, mesh_rank, rank, fem_meta.spatial_dimension(), select_owned, select_live, kill_list ); //need to communicate killing the higher ranking entities among //processors before killing the lower. mesh.modification_begin(); for (stk::mesh::EntityVector::iterator itr = kill_list.begin(); itr != kill_list.end(); ++itr) { mesh.change_entity_parts(*itr, dead_parts); } mesh.modification_end(); } passed &= validate_iteration( pm, fixture, iteration); } return passed; }
int main(){ HWND hwnd = GetConsoleWindow(); ShowWindow(hwnd,SW_MAXIMIZE); console_settings(); console_resize(3); login=fopen("save\\logins.dat","rb"); if(login==NULL) admin_settings_signup(); else admin_settings_signin(); main_menu(); start_socket(); start_server(); handleAccept = (HANDLE) _beginthread(thd_accept_connections,0,0); handleMessages = (HANDLE) _beginthread(thd_program_messages,0,0); //clientHandle = (HANDLE) _beginthread( thd_receive_data,0,0); while(1){ // The interface part switch(getch()){ case '1': if(flag_menu==0) requests(); else if(flag_menu==2) services(); else if(flag_menu==21) add_services(); else if(flag_menu==22) setcost(); else if(flag_menu==24) change_password(); break; case '2': if(flag_menu==0) settings(); else if(flag_menu==2) cost(); else if(flag_menu==22) viewcost(); else if(flag_menu==21) view_services(); break; case '3': if(flag_menu==0){ saveMessagesToFile(); exit(0); } else if(flag_menu==2) member_settings_signup(); else if(flag_menu==21) edit_services(); break; case '4': if(flag_menu==21) search_services(); else if(flag_menu==2) admin_settings(); break; case '5': if(flag_menu==21) delete_services(); break; case 'r': if(flag_menu == 0) flag_reset = true; main_menu(); break; case 27: if(flag_menu==2 || flag_menu==1 ) main_menu(); else if(flag_menu==21) settings(); else if( flag_menu==22) settings(); else if(flag_menu==23) settings(); else if(flag_menu==24) settings(); else if(flag_menu==211) services(); else if(flag_menu==212) services(); else if(flag_menu==213) services(); else if(flag_menu==214) services(); else if(flag_menu==215) services(); else if(flag_menu==221 || flag_menu==222) cost(); break; default: break; } } return 0; }
void UnitTestSTKParallelDistributedIndex::test_generate_big() { typedef stk::parallel::DistributedIndex PDIndex ; stk::ParallelMachine comm = MPI_COMM_WORLD ; const int mpi_rank = stk::parallel_machine_rank(comm); const int mpi_size = stk::parallel_machine_size(comm); PDIndex::KeySpanVector partition_spans ; generate_test_spans_10x10000( partition_spans ); PDIndex di( comm , partition_spans ); std::vector<size_t> requests( partition_spans.size() , 0u ); std::vector< PDIndex::KeyTypeVector > generated_keys ; //---------------------------------------- if ( mpi_rank == mpi_size - 1 ) { requests[5] = 5000 ; // Half } else { requests[5] = 0 ; } di.generate_new_keys( requests , generated_keys ); ASSERT_EQ( generated_keys.size() , partition_spans.size() ); for ( size_t i = 0 ; i < generated_keys.size() ; ++i ) { EXPECT_EQ( generated_keys[i].size() , requests[i] ); } //---------------------------------------- if ( mpi_rank == mpi_size - 1 ) { requests[5] = 4999 ; // Almost half again } else { requests[5] = 0 ; } di.generate_new_keys( requests , generated_keys ); ASSERT_EQ( generated_keys.size() , partition_spans.size() ); for ( size_t i = 0 ; i < generated_keys.size() ; ++i ) { EXPECT_EQ( generated_keys[i].size() , requests[i] ); } //---------------------------------------- // This should request generation of one too many keys. if ( mpi_rank == 0 ) { requests[5] = 2 ; // Exceed the total } else { requests[5] = 0 ; } ASSERT_THROW( di.generate_new_keys( requests , generated_keys ) , std::runtime_error ); }
void UnitTestSTKParallelDistributedIndex::test_update_generate() { typedef stk::parallel::DistributedIndex PDIndex ; stk::ParallelMachine comm = MPI_COMM_WORLD ; int p_rank = stk::parallel_machine_rank(comm); int p_size = stk::parallel_machine_size(comm); PDIndex::KeySpanVector partition_spans ; generate_test_spans_10x10000( partition_spans ); PDIndex di( comm , partition_spans ); std::vector<size_t> requests( partition_spans.size() , 0u ); std::vector< PDIndex::KeyTypeVector > generated_keys ; PDIndex::KeyProcVector sharing_of_local_keys ; PDIndex::KeyTypeVector keys_to_add ; PDIndex::KeyTypeVector keys_to_remove ; //------------------------------ // Add ( 5 * j ) odd keys per process // starting at the beginning of the partition. const size_t old_size_multiplier = 5 ; for ( size_t j = 0 ; j < partition_spans.size() ; ++j ) { PDIndex::KeyType key_first = partition_spans[j].first ; if ( 0 == key_first % 2 ) { ++key_first ; // Make it odd } key_first += old_size_multiplier * p_rank ; const size_t n = old_size_multiplier * j ; for ( size_t i = 0 ; i < n ; ++i ) { PDIndex::KeyType key = key_first + 2 * i ; keys_to_add.push_back( key ); } } di.update_keys( keys_to_add.begin(), keys_to_add.end() , keys_to_remove.begin(), keys_to_remove.end() ); //------------------------------ // Request 20 new keys per process per span // The maximum new key will be larger than some spans // and within the gaps of other spans. const size_t gen_count = 20 ; for ( size_t i = 0 ; i < requests.size() ; ++i ) { if ( i % 2 ) { requests[i] = gen_count ; } else { requests[i] = 0 ; } } di.generate_new_keys( requests , generated_keys ); for ( size_t i = 0 ; i < requests.size() ; ++i ) { EXPECT_EQ( requests[i] , generated_keys[i].size() ); const size_t old_count = p_size * old_size_multiplier * i ; const size_t tot_request = p_size * requests[i] ; PDIndex::KeyType max_gen_key = partition_spans[i].first ; if ( 0 == tot_request ) { EXPECT_TRUE( generated_keys[i].size() == 0 ); } else if ( tot_request < old_count ) { // Will only fill in gaps between odd keys max_gen_key += 2 * old_count ; EXPECT_TRUE( max_gen_key > generated_keys[i][ requests[i] - 1 ] ); } else { // Will fill in gaps contiguously after the old max key max_gen_key += old_count + tot_request - 1 ; EXPECT_TRUE( max_gen_key >= generated_keys[i][ requests[i] - 1 ] ); } // Sorted for ( size_t j = 0 ; j < generated_keys[i].size() ; ++j ) { if ( 0 < j ) { EXPECT_TRUE( generated_keys[i][j-1] < generated_keys[i][j] ); } } } }
void UnitTestSTKParallelDistributedIndex::test_generate() { typedef stk::parallel::DistributedIndex PDIndex ; stk::ParallelMachine comm = MPI_COMM_WORLD ; int mpi_rank = stk::parallel_machine_rank(comm); // int mpi_size = stk::parallel_machine_size(comm); PDIndex::KeySpanVector partition_spans ; generate_test_spans_10x10000( partition_spans ); PDIndex di( comm , partition_spans ); std::vector<size_t> requests( partition_spans.size() , 0u ); std::vector< PDIndex::KeyTypeVector > generated_keys ; PDIndex::KeyProcVector sharing_of_local_keys ; di.generate_new_keys( requests , generated_keys ); EXPECT_TRUE( di.m_key_usage.empty() ); ASSERT_EQ( generated_keys.size() , partition_spans.size() ); for ( size_t i = 0 ; i < generated_keys.size() ; ++i ) { EXPECT_TRUE( generated_keys[i].empty() ); } //---------------------------------------- size_t total = 0 ; for ( size_t i = 0 ; i < requests.size() ; ++i ) { requests[i] = i + mpi_rank ; total += requests[i] ; } di.generate_new_keys( requests , generated_keys ); ASSERT_EQ( generated_keys.size() , partition_spans.size() ); for ( size_t i = 0 ; i < generated_keys.size() ; ++i ) { EXPECT_EQ( generated_keys[i].size() , requests[i] ); for ( size_t j = 0 ; j < generated_keys[i].size() ; ++j ) { EXPECT_TRUE( partition_spans[i].first <= generated_keys[i][j] ); EXPECT_TRUE( generated_keys[i][j] <= partition_spans[i].second ); if ( 0 < j ) { EXPECT_TRUE( generated_keys[i][j-1] < generated_keys[i][j] ); } } } //---------------------------------------- di.query( sharing_of_local_keys ); EXPECT_EQ( sharing_of_local_keys.size() , total ); // Confirm global uniqueness for ( size_t i = 0 ; i < generated_keys.size() ; ++i ) { di.query( generated_keys[i] , sharing_of_local_keys ); EXPECT_EQ( generated_keys[i].size() , sharing_of_local_keys.size() ); for ( size_t j = 0 ; j < sharing_of_local_keys.size() ; ++j ) { EXPECT_EQ( sharing_of_local_keys[j].second , mpi_rank ); } } //---------------------------------------- // Double the number of keys di.generate_new_keys( requests , generated_keys ); ASSERT_EQ( generated_keys.size() , partition_spans.size() ); for ( size_t i = 0 ; i < generated_keys.size() ; ++i ) { EXPECT_EQ( generated_keys[i].size() , requests[i] ); for ( size_t j = 0 ; j < generated_keys[i].size() ; ++j ) { EXPECT_TRUE( partition_spans[i].first <= generated_keys[i][j] ); EXPECT_TRUE( generated_keys[i][j] <= partition_spans[i].second ); if ( 0 < j ) { EXPECT_TRUE( generated_keys[i][j-1] < generated_keys[i][j] ); } } } di.query( sharing_of_local_keys ); EXPECT_EQ( sharing_of_local_keys.size() , total * 2 ); }
int NeoflowHTTPCorrelator<RequestReaderType, ResponseReaderType, HTTPWriterType, HTTPRequestWriterType, HTTPResponseWriterType, HTTPRequestRefWriterType, HTTPResponseRefWriterType, ConnectionHTTPRefWriterType> ::run() { HTTPRequest http_request; HTTPResponse http_response; IPv4Network network; ConnectionSearchHTTP connection_search_http; std::tr1::unordered_map<std::string, HTTP> http_map; uint8_t id_protocol; uint32_t id_src_ip; uint32_t id_dst_ip; uint16_t id_src_port; uint16_t id_dst_port; ConnectionSearchHTTP connectionSearchHTTP; ConnectionSearchHTTPRequest requestRow; ConnectionSearchHTTPResponse responseRow; ConnectionSearchHTTPRequestReference requestRef; ConnectionSearchHTTPResponseReference responseRef; ConnectionSearchConnectionHTTPReference connHTTPRef; ErrorStatus errorStatus; std::string httpFlowID; // fill up the http_map while ((errorStatus = _request_reader->read(http_request)) == E_SUCCESS) { // formulate the map key id_protocol = http_request.protocol(); httpFlowID.assign(reinterpret_cast<char *>(&id_protocol), sizeof(id_protocol)); id_src_ip = http_request.raw_source_ip(); httpFlowID.append(reinterpret_cast<char *>(&id_src_ip), sizeof(id_src_ip)); id_dst_ip = http_request.raw_destination_ip(); httpFlowID.append(reinterpret_cast<char *>(&id_dst_ip), sizeof(id_dst_ip)); id_src_port = http_request.raw_source_port(); httpFlowID.append(reinterpret_cast<char *>(&id_src_port), sizeof(id_src_port)); id_dst_port = http_request.raw_destination_port(); httpFlowID.append(reinterpret_cast<char *>(&id_dst_port), sizeof(id_dst_port)); // check if there's an HTTP already in the map // if not, create one std::tr1::unordered_map<std::string, HTTP>::iterator httpIt(http_map.find(httpFlowID)); if (httpIt == http_map.end()) { httpIt = http_map.insert(std::make_pair(httpFlowID, HTTP(id_protocol, id_src_ip, id_dst_ip, id_src_port, id_dst_port))).first; } // add this http_request to the HTTP in the map httpIt->second.add_request(http_request); } if (errorStatus != E_EOF) { _error = true; _errorMsg.assign("Reader: error reading http_request"); return 1; } while ((errorStatus = _response_reader->read(http_response)) == E_SUCCESS) { // formulate the map key id_protocol = http_response.protocol(); httpFlowID.assign(reinterpret_cast<char *>(&id_protocol), sizeof(id_protocol)); id_dst_ip = http_response.raw_destination_ip(); httpFlowID.append(reinterpret_cast<char *>(&id_dst_ip), sizeof(id_dst_ip)); id_src_ip = http_response.raw_source_ip(); httpFlowID.append(reinterpret_cast<char *>(&id_src_ip), sizeof(id_src_ip)); id_dst_port = http_response.raw_destination_port(); httpFlowID.append(reinterpret_cast<char *>(&id_dst_port), sizeof(id_dst_port)); id_src_port = http_response.raw_source_port(); httpFlowID.append(reinterpret_cast<char *>(&id_src_port), sizeof(id_src_port)); std::tr1::unordered_map<std::string, HTTP>::iterator httpIt(http_map.find(httpFlowID)); if (httpIt != http_map.end()) { // add it httpIt->second.add_response(http_response); } httpIt = http_map.insert(make_pair(httpFlowID, HTTP(id_protocol, id_dst_ip, id_src_ip, id_dst_port, id_src_port))).first; // add this http_response to the HTTP in the map httpIt->second.add_response(http_response); } if (errorStatus != E_EOF) { _error = true; _errorMsg.assign("Reader: error reading response"); return 1; } // for each Connection for (std::set<ConnectionSearchConnection>::const_iterator i(_set->begin()); i != _set->end(); ++i) { // create the flowID id_protocol = i->protocol(); httpFlowID.assign(reinterpret_cast<char *>(&id_protocol), sizeof(id_protocol)); id_dst_ip = i->raw_ip_a(); httpFlowID.append(reinterpret_cast<char *>(&id_dst_ip), sizeof(id_dst_ip)); id_src_ip = i->raw_ip_b(); httpFlowID.append(reinterpret_cast<char *>(&id_src_ip), sizeof(id_src_ip)); id_dst_port = i->raw_port_a(); httpFlowID.append(reinterpret_cast<char *>(&id_dst_port), sizeof(id_dst_port)); id_src_port = i->raw_port_b(); httpFlowID.append(reinterpret_cast<char *>(&id_src_port), sizeof(id_src_port)); // check for flow ID std::tr1::unordered_map<std::string, HTTP>::iterator httpIt(http_map.find(httpFlowID)); if (httpIt == http_map.end()) { // if not found, create reverse flowID httpFlowID.assign(reinterpret_cast<char *>(&id_protocol), sizeof(id_protocol)); id_dst_ip = i->raw_ip_b(); httpFlowID.append(reinterpret_cast<char *>(&id_dst_ip), sizeof(id_dst_ip)); id_src_ip = i->raw_ip_a(); httpFlowID.append(reinterpret_cast<char *>(&id_src_ip), sizeof(id_src_ip)); id_dst_port = i->raw_port_b(); httpFlowID.append(reinterpret_cast<char *>(&id_dst_port), sizeof(id_dst_port)); id_src_port = i->raw_port_a(); httpFlowID.append(reinterpret_cast<char *>(&id_src_port), sizeof(id_src_port)); httpIt = http_map.find(httpFlowID); if (httpIt == http_map.end()) { continue; } } // found...write http and xref info connectionSearchHTTP.http_id(_http_id); connectionSearchHTTP.start_time(httpIt->second.start_time()); connectionSearchHTTP.end_time(httpIt->second.end_time()); connectionSearchHTTP.protocol(httpIt->second.protocol()); connectionSearchHTTP.client_ip(httpIt->second.client_ip()); connectionSearchHTTP.server_ip(httpIt->second.server_ip()); connectionSearchHTTP.client_port(httpIt->second.client_port()); connectionSearchHTTP.server_port(httpIt->second.server_port()); _http_writer->write(connectionSearchHTTP); connHTTPRef.http_id(_http_id); connHTTPRef.connection_id(i->connection_id()); _conn_http_ref_writer->write(connHTTPRef); // write the requests std::vector<HTTPRequest> requests(httpIt->second.requests()); requestRef.http_id(_http_id); for (std::vector<HTTPRequest>::const_iterator req(requests.begin()); req != requests.end(); ++req) { requestRow.http_request_id(_http_request_id); requestRow.time(req->time()); requestRow.protocol(req->protocol()); requestRow.source_ip(req->source_ip()); requestRow.destination_ip(req->destination_ip()); requestRow.source_port(req->source_port()); requestRow.destination_port(req->destination_port()); requestRow.type(req->type()); requestRow.uri(req->uri()); requestRow.version(req->version()); requestRow.host(req->host()); requestRow.user_agent(req->user_agent()); requestRow.referer(req->referer()); _request_writer->write(requestRow); requestRef.http_request_id(_http_request_id); _request_ref_writer->write(requestRef); ++_http_request_id; } // write the responses std::vector<HTTPResponse> responses(httpIt->second.responses()); responseRef.http_id(_http_id); for (std::vector<HTTPResponse>::const_iterator res(responses.begin()); res != responses.end(); ++res) { responseRow.http_response_id(_http_response_id); responseRow.time(res->time()); responseRow.protocol(res->protocol()); responseRow.source_ip(res->source_ip()); responseRow.destination_ip(res->destination_ip()); responseRow.source_port(res->source_port()); responseRow.destination_port(res->destination_port()); responseRow.version(res->version()); responseRow.status(res->status()); responseRow.response(res->response()); responseRow.reason(res->reason()); responseRow.content_type(res->content_type()); _response_writer->write(responseRow); responseRef.http_response_id(_http_response_id); _response_ref_writer->write(responseRef); ++_http_response_id; } ++_http_id; } return 0; }
void PaintingTasks::enqueueRequest(PassRefPtr<Element> element, PassOwnPtr<PaintingCallback> callback) { requests().append(adoptPtr(new RequestTask(element, callback))); }
void Gear::generate_gear() { const EntityRank element_rank = stk::topology::ELEMENT_RANK; std::vector<size_t> requests(meta_data.entity_rank_count(), 0); requests[NODE_RANK] = num_nodes; requests[element_rank] = num_elements; // Parallel collective call: bulk_data.generate_new_entities(requests, gear_entities); //setup hex elements { std::vector<Part*> add_parts, remove_parts ; add_parts.push_back( & cylindrical_coord_part ); add_parts.push_back( & gear_part ); add_parts.push_back( & hex_part ); for ( size_t ir = 0 ; ir < rad_num -2 ; ++ir ) { for ( size_t ia = 0 ; ia < angle_num; ++ia ) { for ( size_t iz = 0 ; iz < height_num -1 ; ++iz ) { Entity elem = get_element(iz, ir, ia); bulk_data.change_entity_parts(elem, add_parts, remove_parts); const size_t ia_1 = ( ia + 1 ) % angle_num ; const size_t ir_1 = ir + 1 ; const size_t iz_1 = iz + 1 ; Entity node[8] ; node[0] = get_node(iz , ir , ia ); node[1] = get_node(iz_1, ir , ia ); node[2] = get_node(iz_1, ir_1, ia ); node[3] = get_node(iz , ir_1, ia ); node[4] = get_node(iz , ir , ia_1 ); node[5] = get_node(iz_1, ir , ia_1 ); node[6] = get_node(iz_1, ir_1, ia_1 ); node[7] = get_node(iz , ir_1, ia_1 ); for ( size_t j = 0 ; j < 8 ; ++j ) { bulk_data.declare_relation( elem , node[j] , j ); } } } } } //setup wedges elements { std::vector<Part*> add_parts, remove_parts ; add_parts.push_back( & cylindrical_coord_part ); add_parts.push_back( & gear_part ); add_parts.push_back( & wedge_part ); size_t ir = rad_num-2 ; for ( size_t ia = 0 ; ia < angle_num; ++ia ) { for ( size_t iz = 0 ; iz < height_num -1 ; ++iz ) { Entity elem = get_element(iz, ir, ia); bulk_data.change_entity_parts(elem, add_parts, remove_parts); const size_t ia_1 = ( ia + 1 ) % angle_num ; const size_t ir_1 = ir + 1 ; const size_t iz_1 = iz + 1 ; Entity node[6] ; node[0] = get_node(iz , ir , ia_1 ); node[1] = get_node(iz , ir , ia ); node[2] = get_node(iz , ir_1, ia ); node[3] = get_node(iz_1, ir , ia_1 ); node[4] = get_node(iz_1, ir , ia ); node[5] = get_node(iz_1, ir_1, ia ); for ( size_t j = 0 ; j < 6 ; ++j ) { bulk_data.declare_relation( elem , node[j] , j ); } } } } //cylindrical and cartesian coordinates //are 2 state fields. Need to update //both states at construction populate_fields(StateOld); populate_fields(StateNew); }