void ProcessUnitServiceImpl::getProcessUnit(google::protobuf::RpcController* controller, const org::esb::rpc::ProcessUnitRequest* request, org::esb::rpc::ProcessUnitResponse* response, google::protobuf::Closure* done) { assert(mServer); LOGDEBUG("getProcessUnit"); LOGDEBUG(request->node().DebugString()); org::esb::signal::Message msg; msg.setProperty("processunitcontroller", std::string("GET_PROCESS_UNIT")); org::esb::signal::Messenger::getInstance().sendRequest(msg); boost::shared_ptr<org::esb::hive::job::ProcessUnit >un = msg.getProperty<boost::shared_ptr<org::esb::hive::job::ProcessUnit > >("processunit"); if (!un) { controller->SetFailed("could not get the ProcessUnit from the ProcessUnitController"); return; } std::string data; org::esb::io::StringOutputStream sos(data); org::esb::io::ObjectOutputStream oos(&sos); oos.writeObject(*un.get()); response->mutable_unit_data()->set_serialized_data(data.c_str(), data.length()); response->set_status("OK"); LOGDEBUG("sended data length=" << data.length()); }
// doDraw //-------------------------------------------------------------------------- void VehicleSelectionView::doDraw( Surface& dest ) { Objective* obj = ObjectiveInterface::getObjective(CURRENT_SELECTED_OUTPOST_ID); if ( !obj || obj->occupying_player != PlayerInterface::getLocalPlayer() ) { // Desktop::setVisibilityNoDoAnything("VehicleSelectionView", false); changeMade = false; return; } char strBuf[256]; const int color = Color::white; // Draw a line attaching the VehicleSelectionView to its outpost. {if (WorldInputCmdProcessor::isObjectiveSelected()) { // Draw a line connecting the vehicleSelectionView and the objective. iRect gameViewRect; WorldViewInterface::getViewWindow(&gameViewRect); iXY objectivePos(WorldInputCmdProcessor::getSelectedObjectiveWorldPos()); objectivePos -= gameViewRect.getLocation(); iXY a(VehicleSelectionView::getLocation() + VehicleSelectionView::getSize() / 2); iXY b(objectivePos); // Calculate the starting point on the outside of the vehicleSelectionView box. fXY v2oSlope(Math::unitDirection(a, b)); a.x += int(v2oSlope.x * float(VehicleSelectionView::getWidth() / 2)); a.y += int(v2oSlope.y * float(VehicleSelectionView::getHeight() / 2)); // Calculate the starting point on the outside of the objective box. iXY objectiveOutlineSize(3, 3); //fXY o2vSlope(Math::unitDirection(b, a)); //b.x += o2vSlope.x * float(objectiveOutlineSize.x); //b.y += o2vSlope.y * float(objectiveOutlineSize.y); //screen.drawLine(a, b, Color::white); iRect r(objectivePos.x - objectiveOutlineSize.x, objectivePos.y - objectiveOutlineSize.y, objectiveOutlineSize.x, objectiveOutlineSize.y); screen->fillRect(r, Color::white); //int xOffset = (strlen(WorldInputCmdProcessor::getSelectedObjectiveName()) * CHAR_XPIX) / 2; //screen.bltStringShadowed(r.min.x - xOffset, r.min.y - 15, WorldInputCmdProcessor::getSelectedObjectiveName(), Color::white, Color::black); iXY oos(objectiveOutlineSize); iXY cpos; if (v2oSlope.x > 0 && v2oSlope.y > 0) { cpos = iXY(getEndX(), getEndY()); r = iRect(cpos.x - oos.x, cpos.y-oos.y, oos.x, oos.y); } if (v2oSlope.x > 0 && v2oSlope.y <= 0) { cpos = iXY(getEndX(), getLocationY()); r = iRect(cpos.x - oos.x, cpos.y-oos.y, oos.x, oos.y); } if (v2oSlope.x <= 0 && v2oSlope.y > 0) { cpos = iXY(getLocationX(), getEndY()); r = iRect(cpos.x - oos.x, cpos.y-oos.y, oos.x, oos.y); } if (v2oSlope.x <= 0 && v2oSlope.y <= 0) { cpos = iXY(getLocationX(), getLocationY()); r = iRect(cpos.x - oos.x, cpos.y-oos.y, oos.x, oos.y); } // screen->drawLine(cpos, b, Color::white); screen->fillRect(r, Color::white); //screen.bltLookup(r, Palette::darkGray256.getColorArray()); //screen.drawButtonBorder(r, Color::white, Color::gray96); // Draw the name of the outpost. }} bltViewBackground(dest); int remaining_time = 0; int generation_time = 0; if ( obj->unit_generation_on_flag ) { remaining_time = obj->unit_generation_timer.getTimeLeft(); UnitProfile* profile = UnitProfileInterface::getUnitProfile(obj->unit_generation_type); generation_time = profile->regen_time; } if (vsvUnitGenOn) { sprintf(strBuf, "%s", getUnitName(vsvSelectedUnit)); dest.bltString( productionUnitPos.x, productionUnitPos.y, strBuf, color); sprintf(strBuf, "%01d:%02d/%01d:%02d", remaining_time / 60, remaining_time % 60, generation_time / 60, generation_time % 60); dest.bltString( timeRequiredPos.x, timeRequiredPos.y, strBuf, color); } else { sprintf(strBuf, "%s", _("power off")); dest.bltString( productionUnitPos.x, productionUnitPos.y, strBuf, color); dest.bltString( timeRequiredPos.x, timeRequiredPos.y, strBuf, color); } int unitPerPlayer = GameConfig::game_maxunits / GameConfig::game_maxplayers; sprintf(strBuf, "%d/%d", int(UnitInterface::getUnitCount(PlayerInterface::getLocalPlayerIndex())), unitPerPlayer); dest.bltString(unitsBuiltPos.x, unitsBuiltPos.y, strBuf, color); drawUnitProfileInfo(dest, iXY(0, unitProfileDataY), highlightedUnitType); //sprintf(strBuf, "%01d:%02d", ( (int) outpost_status.unit_generation_time_remaining ) / 60, ( (int) outpost_status.unit_generation_time_remaining) % 60 ); //clientArea.bltString(timeRemainingPos, strBuf, color); View::doDraw( dest ); } // end VehicleSelectionView::doDraw
// doDraw //-------------------------------------------------------------------------- void VehicleSelectionView::doDraw(Surface &viewArea, Surface &clientArea) { char strBuf[256]; const int color = Color::white; // Draw a line attaching the VehicleSelectionView to its outpost. {if (WorldInputCmdProcessor::isObjectiveSelected()) { // Draw a line connecting the vehicleSelectionView and the objective. iRect gameViewRect; WorldViewInterface::getViewWindow(&gameViewRect); iXY objectivePos(WorldInputCmdProcessor::getSelectedObjectiveWorldPos()); objectivePos -= gameViewRect.min; iXY a(VehicleSelectionView::min + VehicleSelectionView::getSize() / 2); iXY b(objectivePos); // Calculate the starting point on the outside of the vehicleSelectionView box. fXY v2oSlope(Math::unitDirection(a, b)); a.x += int(v2oSlope.x * float(VehicleSelectionView::getSizeX() / 2)); a.y += int(v2oSlope.y * float(VehicleSelectionView::getSizeY() / 2)); // Calculate the starting point on the outside of the objective box. iXY objectiveOutlineSize(3, 3); //fXY o2vSlope(Math::unitDirection(b, a)); //b.x += o2vSlope.x * float(objectiveOutlineSize.x); //b.y += o2vSlope.y * float(objectiveOutlineSize.y); //screen.drawLine(a, b, Color::white); iRect r(objectivePos - objectiveOutlineSize, objectivePos + objectiveOutlineSize); //bltBlendRect(screen, r); screen->fillRect(r, Color::white); //int xOffset = (strlen(WorldInputCmdProcessor::getSelectedObjectiveName()) * CHAR_XPIX) / 2; //screen.bltStringShadowed(r.min.x - xOffset, r.min.y - 15, WorldInputCmdProcessor::getSelectedObjectiveName(), Color::white, Color::black); iXY oos(objectiveOutlineSize); iXY cornerPos; if (v2oSlope.x > 0 && v2oSlope.y > 0) { cornerPos = iXY(max.x, max.y); r = iRect(cornerPos - oos, cornerPos + oos); } if (v2oSlope.x > 0 && v2oSlope.y <= 0) { cornerPos = iXY(max.x, min.y); r = iRect(cornerPos - oos, cornerPos + oos); } if (v2oSlope.x <= 0 && v2oSlope.y > 0) { cornerPos = iXY(min.x, max.y); r = iRect(cornerPos - oos, cornerPos + oos); } if (v2oSlope.x <= 0 && v2oSlope.y <= 0) { cornerPos = iXY(min.x, min.y); r = iRect(cornerPos - oos, cornerPos + oos); } screen->drawLine(cornerPos, b, Color::white); screen->fillRect(r, Color::white); //screen.bltLookup(r, Palette::darkGray256.getColorArray()); //screen.drawButtonBorder(r, Color::white, Color::gray96); // Draw the name of the outpost. }} bltViewBackground(viewArea); OutpostStatus outpost_status; outpost_status = ObjectiveInterface::getOutpostStatus( CURRENT_SELECTED_OUTPOST_ID ); if (vsvUnitGenOn) { sprintf(strBuf, "%s", getUnitName(vsvSelectedUnit)); clientArea.bltString( productionUnitPos.x, productionUnitPos.y, strBuf, color); sprintf(strBuf, "%01d:%02d/%01d:%02d", ((int)outpost_status.unit_generation_time_remaining) / 60, ((int)outpost_status.unit_generation_time_remaining) % 60, ((int)outpost_status.unit_generation_time) / 60, ((int)outpost_status.unit_generation_time) % 60); clientArea.bltString( timeRequiredPos.x, timeRequiredPos.y, strBuf, color); } else { sprintf(strBuf, "power off"); clientArea.bltString( productionUnitPos.x, productionUnitPos.y, strBuf, color); sprintf(strBuf, "power off"); clientArea.bltString( timeRequiredPos.x, timeRequiredPos.y, strBuf, color); } int unitPerPlayer = gameconfig->maxunits / gameconfig->maxplayers; sprintf(strBuf, "%d/%d", int(UnitInterface::getUnitCount(PlayerInterface::getLocalPlayerIndex())), unitPerPlayer); clientArea.bltString(unitsBuiltPos.x, unitsBuiltPos.y, strBuf, color); drawUnitProfileInfo(clientArea, iXY(0, unitProfileDataY), highlightedUnitType); //sprintf(strBuf, "%01d:%02d", ( (int) outpost_status.unit_generation_time_remaining ) / 60, ( (int) outpost_status.unit_generation_time_remaining) % 60 ); //clientArea.bltString(timeRemainingPos, strBuf, color); View::doDraw(viewArea, clientArea); } // end VehicleSelectionView::doDraw
void TileOpDriver::apply(QString in, vector<Envelope> envelopes, double buffer, QString out) { // create a job pp::Job job; job.setVerbose(Log::getInstance().getLevel() <= Log::Debug); // set the name job.setName("TileOpDriver"); // be nice and don't start the reduce tasks until most of the map tasks are done. job.getConfiguration().setDouble("mapred.reduce.slowstart.completed.maps", 0.98); // set the input/output pp::Hdfs fs; job.setInput(fs.getAbsolutePath(in.toStdString())); job.setOutput(fs.getAbsolutePath(out.toStdString())); if (_op == 0) { throw HootException("You must specify an operation."); } stringstream ss; ObjectOutputStream oos(ss); oos.writeObject(*_op); oos.flush(); LOG_INFO("oos size: " << ss.str().size()); job.getConfiguration().setBytes(TileOpReducer::opKey(), ss.str()); job.getConfiguration().set(TileOpMapper::envelopesKey(), _toString(envelopes)); job.getConfiguration().set(TileOpMapper::replacementsKey(), fs.getAbsolutePath(in.toStdString())); job.getConfiguration().setDouble(TileOpMapper::maxWaySizeKey(), buffer); job.getConfiguration().setDouble(TileOpMapper::bufferKey(), buffer); // read the max ids from in and write them to the configuration MapStats stats; stats.readDir(in); stats.write(job.getConfiguration()); // setup the mapper and reducer classes. job.setMapperClass(TileOpMapper::className()); job.setReducerClass(TileOpReducer::className()); job.setInputFormatClass(PbfInputFormat::className()); job.setRecordReaderClass(PbfRecordReader::className()); job.setRecordWriterClass(PbfRecordWriter::className()); // Adds all libraries in this directory to the job. job.addLibraryDirs(conf().getList("hoot.hadoop.libpath", "${HOOT_HOME}/lib/;${HOOT_HOME}/local/lib/;${HADOOP_HOME}/c++/Linux-amd64-64/lib/;" "${HOOT_HOME}/pretty-pipes/lib/")); LOG_INFO("Hoot home: " << conf().getString("foo", "${HOOT_HOME}")); const std::vector<std::string>& dirs = job.getLibraryDirs(); for (size_t i = 0; i < dirs.size(); i++) { LOG_INFO("lib dir: " << dirs[i]); } job.addFile(ConfPath::search("hoot.json").toStdString()); // if GDAL isn't installed on all nodes, then we'll need to copy over the projection info. QString gdalData = QString(getenv("GDAL_DATA")); if (gdalData != "") { QDir gdalDir(gdalData); if (gdalDir.exists() == false) { LOG_WARN("Could not find GDAL_DIR: " << gdalData); } else { QStringList filters; filters << "*.csv"; QFileInfoList fil = gdalDir.entryInfoList(filters, QDir::Files); for (int i = 0; i < fil.size(); i++) { LOG_INFO("Adding GDAL_DATA file: " << fil[i].absoluteFilePath()); job.addFile(fil[i].absoluteFilePath().toStdString()); } } } // This library will be used to provide mapper/reducer classes and anything else referenced // by the factory. job.addPlugin(getenv("HOOT_HOME") + string("/lib/libHootHadoop.so.1")); // serialize all the configuration settings. job.getConfiguration().set(settingsConfKey().toStdString(), conf().toString().toUtf8().constData()); _addDefaultJobSettings(job); QStringList fileDeps = conf().getList(fileDepsKey(), QStringList()); for (int i = 0; i < fileDeps.size(); i++) { job.addFile(fileDeps[i].toStdString()); } // conflation runs can go for a _long_ time. Setting timeout to 6 hours. job.getConfiguration().setInt("mapred.task.timeout", 6 * 3600 * 1000); // run the job. job.run(); }