bool operator==( const CSIPluginContainerInfo& left, const CSIPluginContainerInfo& right) { // Order of services is not important. if (left.services_size() != right.services_size()) { return false; } vector<bool> used(right.services_size(), false); for (int i = 0; i < left.services_size(); i++) { bool found = false; for (int j = 0; j < right.services_size(); j++) { if (left.services(i) == right.services(j) && !used[j]) { found = used[j] = true; break; } } if (!found) { return false; } } return left.has_command() == right.has_command() && (!left.has_command() || left.command() == right.command()) && Resources(left.resources()) == Resources(right.resources()) && left.has_container() == right.has_container() && (!left.has_container() || left.container() == right.container()); }
bool operator == (const Task& left, const Task& right) { // Order of task statuses is important. if (left.statuses().size() != right.statuses().size()) { return false; } for (int i = 0; i < left.statuses().size(); i++) { if (left.statuses().Get(i) != right.statuses().Get(i)) { return false; } } return left.name() == right.name() && left.task_id() == right.task_id() && left.framework_id() == right.framework_id() && left.executor_id() == right.executor_id() && left.slave_id() == right.slave_id() && left.state() == right.state() && Resources(left.resources()) == Resources(right.resources()) && left.status_update_state() == right.status_update_state() && left.status_update_uuid() == right.status_update_uuid() && left.labels() == right.labels() && left.discovery() == right.discovery(); }
bool operator==(const AgentInfo& left, const AgentInfo& right) { return left.hostname() == right.hostname() && Resources(left.resources()) == Resources(right.resources()) && Attributes(left.attributes()) == Attributes(right.attributes()) && left.id() == right.id() && left.port() == right.port(); }
Texture2D::~Texture2D() { glDeleteTextures(1, &texID); Resources().FreeShader(vertexShader); Resources().FreeShader(fragmentShader); Resources().FreeShaderProgram(shaderProgram); Resources().FreeRectangle(); }
bool operator == (const SlaveInfo& left, const SlaveInfo& right) { return left.hostname() == right.hostname() && Resources(left.resources()) == Resources(right.resources()) && internal::Attributes(left.attributes()) == internal::Attributes(right.attributes()) && left.id() == right.id() && left.checkpoint() == right.checkpoint() && left.port() == right.port(); }
inline bool operator == (const Task& left, const Task& right) { return left.name() == right.name() && left.task_id() == right.task_id() && left.framework_id() == right.framework_id() && left.slave_id() == right.slave_id() && left.state() == right.state() && Resources(left.resources()) == Resources(right.resources()) && left.has_executor_id() == right.has_executor_id() && (!left.has_executor_id() || (left.executor_id() == right.executor_id())); }
/************************************************************************* * SEQ-SPLITTER-VIEW *************************************************************************/ SeqSplitterView::SeqSplitterView( BRect frame, const char* name, uint32 resizeMask, uint32 flags, orientation direction) : inherited(frame, name, resizeMask, flags), mDirection(direction), mDrawingFlags(0), mMouseDown(false), mPointDown(0, 0), mFrameDown(0, 0, 0, 0) { if (!gHrzCursor) gHrzCursor = Resources().FindCursor("Hrz Splitter"); if (!gVrtCursor) gVrtCursor = Resources().FindCursor("Vrt Splitter"); }
bool operator == (const ExecutorInfo& left, const ExecutorInfo& right) { return left.executor_id() == right.executor_id() && left.data() == right.data() && Resources(left.resources()) == Resources(right.resources()) && left.command() == right.command() && left.framework_id() == right.framework_id() && left.name() == right.name() && left.source() == right.source() && left.container() == right.container() && left.discovery() == right.discovery(); }
ParticleSystem::~ParticleSystem() { glDeleteBuffers(1, &vertexBuffer); for (ParticleEmitter* emitter : emitters) { delete emitter; } Resources().FreeShaderProgram(shaderProgram); Resources().FreeShader(vertexShader); Resources().FreeShader(geometryShader); Resources().FreeShader(fragmentShader); }
ParticleSystem::ParticleSystem(ParticleType particleType, int maxParticleCount) { vertexShader = Resources().CreateShader(PARTICLE_VERT, PARTICLE_VERT_LENGTH, GL_VERTEX_SHADER); geometryShader = Resources().CreateShader(PARTICLE_GEOM, PARTICLE_GEOM_LENGTH, GL_GEOMETRY_SHADER); fragmentShader = Resources().CreateShader(PARTICLE_FRAG, PARTICLE_FRAG_LENGTH, GL_FRAGMENT_SHADER); shaderProgram = Resources().CreateShaderProgram({ vertexShader, geometryShader, fragmentShader }); this->particleType = particleType; this->maxParticleCount = maxParticleCount; particleCount = 0; BindPointData(); }
inline bool operator == (const SlaveInfo& left, const SlaveInfo& right) { return left.hostname() == right.hostname() && left.webui_hostname() == right.webui_hostname() && Resources(left.resources()) == Resources(right.resources()) && internal::Attributes(left.attributes()) == internal::Attributes(right.attributes()) && left.has_webui_port() == right.has_webui_port() && (!left.has_webui_port() || (left.webui_port() == right.webui_port())) && left.has_id() == right.has_id() && (!left.has_id() || (left.id() == right.id())) && left.has_checkpoint() == right.has_checkpoint() && (!left.has_checkpoint() || (left.checkpoint() == right.checkpoint())); }
inline bool operator == (const ExecutorInfo& left, const ExecutorInfo& right) { return left.executor_id() == right.executor_id() && left.has_framework_id() == right.has_framework_id() && (!left.has_framework_id() || (left.framework_id() == right.framework_id())) && left.command() == right.command() && Resources(left.resources()) == Resources(right.resources()) && left.has_name() == right.has_name() && (!left.has_name() || (left.name() == right.name())) && left.has_source() == right.has_source() && (!left.has_source() || (left.source() == right.source())) && left.has_data() == right.has_data() && (!left.has_data() || (left.data() == right.data())); }
// internal void InitializeUX() [instance] :42 void Payment::InitializeUX1() { ::g::Fuse::Resources::FileImageSource* temp = ::g::Fuse::Resources::FileImageSource::New1(); ::g::Uno::UX::Resource* temp1 = ::g::Uno::UX::Resource::New1(::STRINGS[0/*"iconFile"*/], temp); temp->File(::g::Uno::UX::BundleFileSource::New1(::g::WelcomeAnimation_bundle::paymentfbc7c195())); ::g::Uno::Collections::ICollection::Add_ex(uInterface(uPtr(Resources()), ::g::Uno::Collections::ICollection_typeof()->MakeType(::g::Uno::UX::Resource_typeof())), temp1); }
// This is a simple end to end test that makes sure a master using log // storage with ZooKeeper can successfully launch a task. TEST_F(RegistrarZooKeeperTest, TaskRunning) { Try<Owned<cluster::Master>> master = StartMaster(); ASSERT_SOME(master); MockExecutor exec(DEFAULT_EXECUTOR_ID); TestContainerizer containerizer(&exec); Owned<MasterDetector> detector = master.get()->createDetector(); Try<Owned<cluster::Slave>> slave = StartSlave(detector.get(), &containerizer); ASSERT_SOME(slave); MockScheduler sched; MesosSchedulerDriver driver( &sched, DEFAULT_FRAMEWORK_INFO, master.get()->pid, DEFAULT_CREDENTIAL); EXPECT_CALL(sched, registered(&driver, _, _)); Future<vector<Offer>> offers; EXPECT_CALL(sched, resourceOffers(&driver, _)) .WillOnce(FutureArg<1>(&offers)) .WillRepeatedly(Return()); // Ignore subsequent offers. driver.start(); AWAIT_READY(offers); EXPECT_NE(0u, offers->size()); TaskInfo task = createTask(offers.get()[0], "dummy", DEFAULT_EXECUTOR_ID); EXPECT_CALL(exec, registered(_, _, _, _)); EXPECT_CALL(exec, launchTask(_, _)) .WillOnce(SendStatusUpdateFromTask(TASK_RUNNING)); Future<Nothing> resourcesUpdated; EXPECT_CALL(containerizer, update(_, Resources(offers.get()[0].resources()))) .WillOnce(DoAll(FutureSatisfy(&resourcesUpdated), Return(Nothing()))); Future<TaskStatus> status; EXPECT_CALL(sched, statusUpdate(&driver, _)) .WillOnce(FutureArg<1>(&status)); driver.launchTasks(offers.get()[0].id(), {task}); AWAIT_READY(status); EXPECT_EQ(TASK_RUNNING, status->state()); AWAIT_READY(resourcesUpdated); EXPECT_CALL(exec, shutdown(_)) .Times(AtMost(1)); driver.stop(); driver.join(); }
bool operator==( const ResourceProviderInfo& left, const ResourceProviderInfo& right) { if (left.id() != right.id()) { return false; } if (Attributes(left.attributes()) != Attributes(right.attributes())) { return false; } if (Resources(left.resources()) != Resources(right.resources())) { return false; } return true; }
MockSlaveUsage(int executors) : results(ResourceUsage()) { for (int i = 0; i < executors; i++) { ResourceHelper::addExecutor( results, CREATE_EXECUTOR_INFO(std::to_string(i + 1), "exit 1"), Resources(), ResourceHelper::createStatistics()); } }
const BBitmap* SeqImageManager::FindBitmap(const char *name) const { ArpASSERT( name ); BAutolock l(const_cast<BLocker*>(&mAccess)); if (mShutdown) return 0; return Resources().FindBitmap(name); }
ALERROR CExtension::CreateExtensionStub (const CString &sFilespec, EFolderTypes iFolder, CExtension **retpExtension, CString *retsError) // CreateExtensionStub // // Loads enough of the given file to get the entities and the root element. { ALERROR error; // Open up the file CResourceDb Resources(sFilespec, true); if (error = Resources.Open(DFOPEN_FLAG_READ_ONLY, retsError)) return error; // Create a object to receive all the entities CExternalEntityTable *pEntities = new CExternalEntityTable; // Load the main XML file and get the entities CXMLElement *pGameFile; if (error = Resources.LoadGameFileStub(&pGameFile, pEntities, retsError)) { delete pEntities; return error; } // Create the extension // // If sucessful then pExtension takes ownership of pEntities. CExtension *pExtension; error = CreateExtensionFromRoot(sFilespec, pGameFile, iFolder, pEntities, 0, &pExtension, retsError); // Clean up delete pGameFile; // Error if (error) { delete pEntities; return error; } // Done *retpExtension = pExtension; return NOERROR; }
Resources CumulativeResources(BWAPI::Player* player) { if (player==NULL) { player = BWAPI::Broodwar->self(); } int gatheredMinerals = player->gatheredMinerals(); int gatheredGas = player->gatheredGas(); int freeSupply = player->supplyTotal() - player->supplyUsed(); return Resources(gatheredMinerals, gatheredGas, freeSupply); }
void PlayerCity::ResourceUpdate() { if (!m_client->m_connected) return; amf3object obj = amf3object(); obj["cmd"] = "server.ResourceUpdate"; obj["data"] = amf3object(); amf3object & data = obj["data"]; data["castleId"] = this->m_castleid; data["resource"] = Resources(); m_client->m_main->SendObject(m_client, obj); }
bool operator==(const OperationStatus& left, const OperationStatus& right) { if (left.has_operation_id() != right.has_operation_id()) { return false; } if (left.has_operation_id() && left.operation_id() != right.operation_id()) { return false; } if (left.state() != right.state()) { return false; } if (left.has_message() != right.has_message()) { return false; } if (left.has_message() && left.message() != right.message()) { return false; } if (Resources(left.converted_resources()) != Resources(right.converted_resources())) { return false; } if (left.has_uuid() != right.has_uuid()) { return false; } if (left.has_uuid() && left.uuid() != right.uuid()) { return false; } return true; }
Texture2D::Texture2D(const char *source, int sourceLength) { glGenTextures(1, &texID); glBindTexture(GL_TEXTURE_2D, texID); // Load texture from file. int components; unsigned char* data = stbi_load_from_memory(reinterpret_cast<const unsigned char*>(source), sourceLength, &width, &height, &components, 0); if (data == NULL) Log() << "Couldn't load headerized image.\n"; // Give the image to OpenGL. glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, Format(components), GL_UNSIGNED_BYTE, data); stbi_image_free(data); // When MAGnifying the image (no bigger mipmap available), use LINEAR filtering. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // When MINifying the image, use a LINEAR blend of two mipmaps, each filtered LINEARLY too. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); // Repeat texture when texture coordinates outside 0.0-1.0. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); // Generate mipmaps, by the way. glGenerateMipmap(GL_TEXTURE_2D); // For rendering. rectangle = Resources().CreateRectangle(); vertexShader = Resources().CreateShader(DEFAULT2D_VERT, DEFAULT2D_VERT_LENGTH, GL_VERTEX_SHADER); fragmentShader = Resources().CreateShader(TEXTURE2D_FRAG, TEXTURE2D_FRAG_LENGTH, GL_FRAGMENT_SHADER); shaderProgram = Resources().CreateShaderProgram({ vertexShader, fragmentShader }); }
void CSMWorld::ResourcesManager::listResources() { static const char * const sMeshTypes[] = { "nif", 0 }; addResources (Resources ("meshes", UniversalId::Type_Mesh, sMeshTypes)); addResources (Resources ("icons", UniversalId::Type_Icon)); addResources (Resources ("music", UniversalId::Type_Music)); addResources (Resources ("sound", UniversalId::Type_SoundRes)); addResources (Resources ("textures", UniversalId::Type_Texture)); addResources (Resources ("videos", UniversalId::Type_Video)); }
void CSMWorld::ResourcesManager::setVFS(const VFS::Manager *vfs) { mVFS = vfs; mResources.clear(); addResources (Resources (vfs, "meshes", UniversalId::Type_Mesh, getMeshExtensions())); addResources (Resources (vfs, "icons", UniversalId::Type_Icon)); addResources (Resources (vfs, "music", UniversalId::Type_Music)); addResources (Resources (vfs, "sound", UniversalId::Type_SoundRes)); addResources (Resources (vfs, "textures", UniversalId::Type_Texture)); addResources (Resources (vfs, "video", UniversalId::Type_Video)); }
MediaResourceManagerService::ResourceTable::ResourceTable() { // Populate types of resources. for (int type = 0; type < NUM_OF_RESOURCE_TYPES; type++) { ssize_t index = mMap.add(static_cast<ResourceType>(type), Resources()); Resources& resources = mMap.editValueAt(index); int available; switch (type) { case HW_VIDEO_DECODER: available = VIDEO_DECODER_COUNT; break; case HW_VIDEO_ENCODER: available = VIDEO_ENCODER_COUNT; break; default: available = 0; break; } resources.mSlots.insertAt(0, available); } }
amf3object PlayerCity::ToObject() { amf3object obj = amf3object(); //obj["heroes"] = HeroArray(); obj["buildingQueues"] = amf3array(); obj["heros"] = HeroArray(); obj["status"] = m_status; obj["allowAlliance"] = false; obj["resource"] = Resources(); obj["logUrl"] = m_logurl; obj["fieldId"] = m_tileid; obj["usePACIFY_SUCCOUR_OR_PACIFY_PRAY"] = 1;//Unknown value (was set to 1) obj["transingTrades"] = amf3array(); obj["troop"] = Troops(); obj["id"] = m_castleid; obj["name"] = m_cityname; obj["buildings"] = Buildings(); obj["fortification"] = Fortifications(); obj["trades"] = amf3array(); obj["fields"] = amf3array();//tiles owned? obj["goOutForBattle"] = false; obj["hasEnemy"] = false; return obj; }
void GenerateWordList (const CString &sDataFile, CXMLElement *pCmdLine) // GenerateWordList // // Generate a list of unique words used in the game { ALERROR error; int i; CString sError; // Open the XML file CResourceDb Resources(sDataFile); if (error = Resources.Open()) { printf("Unable to initialize data file.\n"); return; } CXMLElement *pGameFile; if (error = Resources.LoadGameFile(&pGameFile, NULL, &sError)) { printf("%s\n", sError.GetASCIIZPointer()); return; } // Create the context CSymbolTable WordList(FALSE, TRUE); TraverseCtx Ctx; Ctx.pWordList = &WordList; // Recursive descent ParseWordList(Ctx, pGameFile); // Parse all modules too CXMLElement *pModules = pGameFile->GetContentElementByTag(MODULES_TAG); if (pModules) { for (i = 0; i < pModules->GetContentElementCount(); i++) { CXMLElement *pModule = pModules->GetContentElement(i); CXMLElement *pModuleXML; if (error = Resources.LoadModule(NULL_STR, pModule->GetAttribute(FILENAME_ATTRIB), &pModuleXML, &sError)) { printf("%s\n", sError.GetASCIIZPointer()); return; } ParseWordList(Ctx, pModuleXML); } } // Print out the word list for (i = 0; i < WordList.GetCount(); i++) printf("%s\n", WordList.GetKey(i).GetASCIIZPointer()); }
BBitmap* ArpVaccineFilterAddOn::Image(BPoint requestedSize) const { const BBitmap* bm = Resources().FindBitmap("Class Icon"); if (bm) return new BBitmap(bm); return NULL; }
void GenerateEffectImage (CUniverse &Universe, CXMLElement *pCmdLine) { CString sError; int i, j; // Input file CString sInput = pCmdLine->GetAttribute(CONSTLIT("input")); if (sInput.IsBlank()) { printf("Input file required.\n"); return; } // Output file (optional) CString sFilespec = pCmdLine->GetAttribute(CONSTLIT("output")); if (!sFilespec.IsBlank()) sFilespec = pathAddExtensionIfNecessary(sFilespec, CONSTLIT(".bmp")); // Load a resource file so that we can create a design load context CResourceDb Resources(CONSTLIT("Transcendence")); if (Resources.Open(DFOPEN_FLAG_READ_ONLY, &sError) != NOERROR) { printf("%s\n", (LPSTR)sError); return; } CExternalEntityTable *pEntities; if (Resources.LoadEntities(&sError, &pEntities) != NOERROR) { printf("%s\n", sError.GetASCIIZPointer()); return; } // Generate a list of effect render structures TArray<SEffectRender> Effects; // Load the input file CFileReadBlock InputFile(sInput); if (InputFile.Open() != NOERROR) { printf("Unable to open input file: %s\n", sInput.GetASCIIZPointer()); return; } // Parse the file CXMLElement *pRenderFile; if (CXMLElement::ParseXML(&InputFile, pEntities, &pRenderFile, &sError) != NOERROR) { printf("%s\n", sError.GetASCIIZPointer()); return; } // Keep track of the max cell size and frame count int cxCellWidth = 0; int cyCellHeight = 0; int iCellsPerEffect = 1; // Generate structures SDesignLoadCtx LoadCtx; LoadCtx.sResDb = Resources.GetFilespec(); LoadCtx.pResDb = &Resources; LoadCtx.bNoVersionCheck = true; for (i = 0; i < pRenderFile->GetContentElementCount(); i++) { CXMLElement *pRender = pRenderFile->GetContentElement(i); CXMLElement *pEffectDesc = pRender->GetContentElementByTag(CONSTLIT("Effect")); if (pEffectDesc == NULL) { printf("<Effect> tag required.\n"); return; } SEffectRender *pEffect = Effects.Insert(); // Parse the effect if (pEffect->pEffectCreator.LoadEffect(LoadCtx, CONSTLIT("none"), pEffectDesc, NULL_STR) != NOERROR) { printf("%s\n", LoadCtx.sError.GetASCIIZPointer()); return; } // Bind if (pEffect->pEffectCreator.Bind(LoadCtx) != NOERROR) { printf("%s\n", LoadCtx.sError.GetASCIIZPointer()); return; } // Create a painter pEffect->pPainter = pEffect->pEffectCreator->CreatePainter(); if (pEffect->pPainter == NULL) { printf("Unable to create painter.\n"); return; } // Render specs int cyHeight = pRender->GetAttributeIntegerBounded(CONSTLIT("height"), 0, -1, 128); int cxWidth = pRender->GetAttributeIntegerBounded(CONSTLIT("width"), 0, -1, 128); cxCellWidth = Max(cxCellWidth, cxWidth); cyCellHeight = Max(cyCellHeight, cyHeight); // Figure out how many animation cells pEffect->iLifetime = Max(1, pEffect->pEffectCreator->GetLifetime()); iCellsPerEffect = Max(iCellsPerEffect, pEffect->iLifetime); } // Create the resulting image CImageGrid Output; Output.Create(iCellsPerEffect * Effects.GetCount(), cxCellWidth, cyCellHeight); // Paint for (i = 0; i < Effects.GetCount(); i++) { SEffectRender *pEffect = &Effects[i]; SViewportPaintCtx Ctx; for (j = 0; j < pEffect->iLifetime; j++) { int x, y; Output.GetCellCenter(i * iCellsPerEffect + j, &x, &y); // Create a context Ctx.iTick = j; // Paint the effect pEffect->pPainter->Paint(Output.GetImage(), x, y, Ctx); // Update pEffect->pPainter->OnUpdate(); } } // Output OutputImage(Output.GetImage(), sFilespec); }
Try<Nothing> TooHighCpuUsageDetector::consume(const ResourceUsage& in) { Contentions product; if (in.total_size() == 0) { return Error(std::string(NAME) + " No total in ResourceUsage"); } Resources totalAgentResources(in.total()); Option<double_t> totalAgentCpus = totalAgentResources.cpus(); if (totalAgentCpus.isNone()) { return Error(std::string(NAME) + " No total cpus in ResourceUsage"); } double_t agentSumValue = 0; uint64_t beExecutors = 0; for (const ResourceUsage_Executor& inExec : in.executors()) { if (!inExec.has_executor_info()) { SERENITY_LOG(ERROR) << "Executor <unknown>" << " does not include executor_info"; // Filter out these executors. continue; } if (!inExec.has_statistics()) { SERENITY_LOG(ERROR) << "Executor " << inExec.executor_info().executor_id().value() << " does not include statistics."; // Filter out these executors. continue; } Try<double_t> value = this->cpuUsageGetFunction(inExec); if (value.isError()) { SERENITY_LOG(ERROR) << value.error(); continue; } agentSumValue += value.get(); if (!Resources(inExec.allocated()).revocable().empty()) { beExecutors++; } } // Debug only SERENITY_LOG(INFO) << "Sum = " << agentSumValue << " vs total = " << totalAgentCpus.get(); double_t lvl = agentSumValue / totalAgentCpus.get(); if (lvl > this->cfgUtilizationThreshold) { if (beExecutors == 0) { SERENITY_LOG(INFO) << "No BE tasks - only high host utilization"; } else { SERENITY_LOG(INFO) << "Creating CPU contention, because of the value" << " above the threshold. " << agentSumValue << "/" << totalAgentCpus.get(); product.push_back(createContention(totalAgentCpus.get() - agentSumValue, Contention_Type_CPU)); } } // Continue pipeline. this->produce(product); return Nothing(); }