Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Droth 3297 improve logging #2026

Merged
merged 7 commits into from
Jun 22, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -312,23 +312,32 @@ class Digiroad2Api(val roadLinkService: RoadLinkService,

get("/massTransitStops") {
val user = userProvider.getCurrentUser()
val bbox = params.get("bbox").map(constructBoundingRectangle).getOrElse(halt(BadRequest("Bounding box was missing")))
validateBoundingBox(bbox)
massTransitStopService.getByBoundingBox(user, bbox).map { stop =>
Map("id" -> stop.id,
"linkId" -> stop.linkId,
"name" -> extractPropertyValue("nimi_suomeksi", stop.propertyData, values => values.headOption.getOrElse("")),
"nationalId" -> stop.nationalId,
"stopTypes" -> stop.stopTypes,
"municipalityNumber" -> stop.municipalityCode,
"lat" -> stop.lat,
"lon" -> stop.lon,
"validityDirection" -> stop.validityDirection,
"bearing" -> stop.bearing,
"validityPeriod" -> stop.validityPeriod,
"floating" -> stop.floating,
"linkSource" -> stop.linkSource.value,
"propertyData" -> stop.propertyData)
val bbox = LogUtils.time(logger, "TEST LOG massTransitStops construct bbox"){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kannattaako nyt tätä operaatiota oikein logitaa, ei taida olla hirveen oleelinen samoin toi validate boudingbox mut ei tää nyt varmaan haitta.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lähinnä menin sillä periaatteella, että "ei jätetä mitään kiveä kääntämättä". Todennäköisesti turhaa lokittaa tätä mutta ei haittaakaan

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

joo eipä se pahaa tee

params.get("bbox").map(constructBoundingRectangle).getOrElse(halt(BadRequest("Bounding box was missing")))
}
LogUtils.time(logger, "TEST LOG massTransitStops validate bbox") {
validateBoundingBox(bbox)
}
val massTransitStops = LogUtils.time(logger, "TEST LOG massTransitStops get by bbox") {
massTransitStopService.getByBoundingBox(user, bbox)
}
LogUtils.time(logger, "TEST LOG massTransitStops map asset fields, asset count: " + massTransitStops.size) {
massTransitStops.map { stop =>
Map("id" -> stop.id,
"linkId" -> stop.linkId,
"name" -> extractPropertyValue("nimi_suomeksi", stop.propertyData, values => values.headOption.getOrElse("")),
"nationalId" -> stop.nationalId,
"stopTypes" -> stop.stopTypes,
"municipalityNumber" -> stop.municipalityCode,
"lat" -> stop.lat,
"lon" -> stop.lon,
"validityDirection" -> stop.validityDirection,
"bearing" -> stop.bearing,
"validityPeriod" -> stop.validityPeriod,
"floating" -> stop.floating,
"linkSource" -> stop.linkSource.value,
"propertyData" -> stop.propertyData)
}
}
}

Expand Down Expand Up @@ -654,13 +663,14 @@ class Digiroad2Api(val roadLinkService: RoadLinkService,
LogUtils.time(logger,"TEST LOG Total time getRoadLinksFromVVH with bbox"){
val boundingRectangle = LogUtils.time(logger, "TEST LOG Constructing boundingBox")(constructBoundingRectangle(bbox))
validateBoundingBox(boundingRectangle)
val roadLinkSeq = LogUtils.time(logger, "TEST LOG Get and enrich RoadLinks from VVH")(roadLinkService.getRoadLinksFromVVH(boundingRectangle, municipalities))
val roadLinkSeq = LogUtils.time(logger, "TEST LOG Get and enrich RoadLinks from VVH with bbox")(roadLinkService.getRoadLinksFromVVH(boundingRectangle, municipalities))
val roadLinks = if(withRoadAddress) {
val viiteInformation = LogUtils.time(logger, "TEST LOG Get Viite road address for links")(roadAddressService.roadLinkWithRoadAddress(roadLinkSeq))
val vkmInformation = LogUtils.time(logger, "TEST LOG Get Temp road address for links")(roadAddressService.roadLinkWithRoadAddressTemp(viiteInformation.filterNot(_.attributes.contains("VIITE_ROAD_NUMBER"))))
val viiteInformation = LogUtils.time(logger, "TEST LOG Get Viite road address for links, link count: " + roadLinkSeq.size)(roadAddressService.roadLinkWithRoadAddress(roadLinkSeq))
val missingViiteAddress = viiteInformation.filterNot(_.attributes.contains("VIITE_ROAD_NUMBER"))
val vkmInformation = LogUtils.time(logger, "TEST LOG Get Temp road address for links, link count: " + missingViiteAddress.size)(roadAddressService.roadLinkWithRoadAddressTemp(missingViiteAddress))
viiteInformation.filter(_.attributes.contains("VIITE_ROAD_NUMBER")) ++ vkmInformation
} else roadLinkSeq
LogUtils.time(logger, "TEST LOG Partition roadLinks")(partitionRoadLinks(roadLinks,withLaneInfo = withLaneInfo))
LogUtils.time(logger, "TEST LOG Partition roadLinks, link count: " + roadLinks.size)(partitionRoadLinks(roadLinks,withLaneInfo = withLaneInfo))
}
}

Expand All @@ -686,7 +696,7 @@ class Digiroad2Api(val roadLinkService: RoadLinkService,
private def partitionRoadLinks(roadLinks: Seq[RoadLink],withLaneInfo: Boolean = false): Seq[Seq[Map[String, Any]]] = {
val linkWithLane = if(withLaneInfo) lanesWithRoadlink(roadLinks) else roadLinks
val partitionedRoadLinks = RoadLinkPartitioner.partition(linkWithLane)
LogUtils.time(logger, "TEST LOG roadLinkToApiWithLaneInfo")(
LogUtils.time(logger, "TEST LOG roadLinkToApiWithLaneInfo, link count: " + partitionedRoadLinks.flatten.size)(
partitionedRoadLinks.map(r=>{roadLinkToApiWithLaneInfo(r,withLaneInfo=withLaneInfo)})
)
}
Expand Down Expand Up @@ -1659,9 +1669,15 @@ class Digiroad2Api(val roadLinkService: RoadLinkService,

get("/manoeuvres") {
params.get("bbox").map { bbox =>
val boundingRectangle = constructBoundingRectangle(bbox)
validateBoundingBox(boundingRectangle)
manoeuvreService.getByBoundingBox(boundingRectangle, Set())
val boundingRectangle = LogUtils.time(logger, "TEST LOG manoeuvres construct bbox") {
constructBoundingRectangle(bbox)
}
LogUtils.time(logger, "TEST LOG manoeuvres validate bbox") {
validateBoundingBox(boundingRectangle)
}
LogUtils.time(logger, "TEST LOG Get manoeuvres by bbox total operation") {
manoeuvreService.getByBoundingBox(boundingRectangle, Set())
}
} getOrElse {
BadRequest("Missing mandatory 'bbox' parameter")
}
Expand Down
3 changes: 2 additions & 1 deletion digiroad2-oracle/src/main/resources/clear-db.sql
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ drop table if exists user_notification cascade;
drop table if exists validity_period_property_value cascade;
drop table if exists vallu_xml_ids cascade;
drop table if exists val_period_property_value_hist cascade;

drop table if exists roadlink cascade;
drop table if exists roadlinkex cascade;
drop sequence if exists grouped_id_seq cascade;
drop sequence if exists lrm_position_primary_key_seq cascade;
drop sequence if exists manoeuvre_id_seq cascade;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
create table roadlink (
kmtkid varchar(40),
objectid numeric(38,0),
mtkid numeric(38,0),
drid numeric(38,0),
linkid numeric(38,0),
sourceinfo integer,
adminclass integer,
municipalitycode integer,
mtkgroup integer,
mtkclass numeric(38,0),
roadname_fi varchar(80),
roadname_se varchar(80),
roadname_sm varchar(80),
roadnumber numeric(38,0),
roadpartnumber integer,
surfacetype integer,
constructiontype integer,
directiontype integer,
verticallevel integer,
horizontalaccuracy numeric(38,0),
verticalaccuracy numeric(38,0),
vectortype numeric(5,0),
geometrylength numeric(11,3),
minanleft numeric(38,0),
maxanleft numeric(38,0),
minanright numeric(38,0),
maxanright numeric(38,0),
validfrom timestamp,
created_date timestamp,
created_user varchar(64),
last_edited_date timestamp,
geometry_edited_date timestamp,
validationstatus integer,
updatenumber integer,
objectstatus integer,
subtype integer,
shape geometry(linestringzm,3067),
se_anno_cad_data bytea,
mtkhereflip integer,
from_left numeric(38,0),
to_left numeric(38,0),
from_right numeric(38,0),
to_right numeric(38,0),
startnode numeric(38,0),
endnode numeric(38,0),
constraint roadlink_linkid unique (linkid) deferrable initially deferred,
constraint roadlink_mtkid unique (mtkid) deferrable initially deferred
);
alter table roadlink add primary key (linkid);

create index roadlink_spatial_index on roadlink using gist (shape);
create index adminclass_index on roadlink (adminclass);
create index constructio_index on roadlink (constructiontype);
create index linkid_index on roadlink (linkid);
create index mtkclass_index on roadlink (mtkclass);
create index mtkid_index on roadlink (mtkid);
create index municipality_index on roadlink (municipalitycode);
create index updatenumbe_index on roadlink (updatenumber);
create index updatenumber_adminclass_municipalitycode_index on roadlink (updatenumber,adminclass,municipalitycode);
create index updatenumbe_adminclass_index on roadlink (updatenumber,adminclass);
create index mtkid_mtkhereflip_index on roadlink (mtkid,mtkhereflip);
create index linkid_mtkc_index on roadlink (linkid,mtkclass);
create index muni_mtkc_index on roadlink (municipalitycode,mtkclass);
create index roadnum_mtkc_index on roadlink (roadnumber,mtkclass);
create index endnode_municipalitycode_index on roadlink (endnode,municipalitycode);
create index startnode_municipalitycode_index on roadlink (startnode,municipalitycode);

create table roadlinkex (
objectid numeric(38,0),
drid numeric(38,0),
linkid numeric(38,0),
sourceinfo integer,
adminclass integer,
municipalitycode integer,
mtkgroup integer,
mtkclass numeric(38,0),
roadname_fi varchar(80),
roadname_se varchar(80),
roadname_sm varchar(80),
roadnumber numeric(38,0),
roadpartnumber integer,
surfacetype integer,
constructiontype integer,
directiontype integer,
verticallevel integer,
horizontalaccuracy numeric(38,0),
verticalaccuracy numeric(38,0),
vectortype integer,
geometrylength double precision,
minanleft numeric(38,0),
maxanleft numeric(38,0),
minanright numeric(38,0),
maxanright numeric(38,0),
validfrom timestamp,
created_date timestamp,
created_user varchar(64),
last_edited_date timestamp,
geometry_edited_date timestamp,
validationstatus integer,
feedbackstatus integer,
feedbackinfo varchar(255),
objectstatus integer,
subtype integer,
jobid numeric(38,0),
shape geometry(linestringzm,3067),
se_anno_cad_data bytea,
from_left numeric(38,0),
to_left numeric(38,0),
from_right numeric(38,0),
to_right numeric(38,0),
estimated_completion timestamp,
track_code integer,
cust_class varchar(50),
cust_id_str varchar(50),
cust_id_num numeric(38,0),
cust_owner numeric(38,0),
constraint roadlinkex_linkid unique (linkid) deferrable initially deferred
);

alter table roadlinkex add primary key (linkid);

create index roadlinkex_spatial_index on roadlinkex using gist(shape);
create index roadlinkex_adminclass_index on roadlinkex (adminclass);
create index roadlinkex_jobid_index on roadlinkex (jobid);
create index roadlinkex_municipalitycode_index on roadlinkex (municipalitycode);
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ class RoadLinkService(val vvhClient: VVHClient, val eventbus: DigiroadEventBus,
Await.result(vvhClient.roadLinkChangeInfo.fetchByBoundsAndMunicipalitiesF(bounds, municipalities).zip(vvhClient.roadLinkData.fetchByMunicipalitiesAndBoundsF(bounds, municipalities)), atMost = Duration.Inf)
)
withDynTransaction {
LogUtils.time(logger, "TEST LOG enrichRoadLinksFromVVH")(
LogUtils.time(logger, "TEST LOG enrichRoadLinksFromVVH, link count: " + links.size)(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TEST LOG enrichRoadLinksFromVVH from boundingbox request

(enrichRoadLinksFromVVH(links), changes)
)
}
Expand Down Expand Up @@ -1340,7 +1340,7 @@ class RoadLinkService(val vvhClient: VVHClient, val eventbus: DigiroadEventBus,

def enrichRoadLinksFromVVH(allVvhRoadLinks: Seq[VVHRoadlink]): Seq[RoadLink] = {
val vvhRoadLinks = allVvhRoadLinks.filterNot(_.featureClass == FeatureClass.WinterRoads)
LogUtils.time(logger,"TEST LOG roadLinkDataByLinkId"){getRoadLinkDataByLinkIds(vvhRoadLinks)}
LogUtils.time(logger,"TEST LOG roadLinkDataByLinkId, link count: " + vvhRoadLinks.size){getRoadLinkDataByLinkIds(vvhRoadLinks)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TEST LOG roadLinkDataByLinkId -> TEST LOG enrich roadLinkDataByLinkId vaikkapa

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import fi.liikennevirasto.digiroad2.postgis.PostGISDatabase
import fi.liikennevirasto.digiroad2.process.AssetValidatorInfo
import fi.liikennevirasto.digiroad2.service.RoadLinkService
import fi.liikennevirasto.digiroad2.service.pointasset.TrafficSignInfo
import fi.liikennevirasto.digiroad2.util.LogUtils
import fi.liikennevirasto.digiroad2.{DigiroadEventBus, GeometryUtils, Point, _}
import org.joda.time.DateTime
import org.slf4j.LoggerFactory
Expand Down Expand Up @@ -64,8 +65,12 @@ class ManoeuvreService(roadLinkService: RoadLinkService, eventBus: DigiroadEvent
}

def getByBoundingBox(bounds: BoundingRectangle, municipalities: Set[Int]): Seq[Manoeuvre] = {
val roadLinks = roadLinkService.getRoadLinksFromVVH(bounds)
getByRoadLinks(roadLinks)
val roadLinks = LogUtils.time(logger, "TEST LOG manoeuvres get roadlinks by bbox") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

varmaan yhtenäisempää käyttää boundingbox sanaa kuin bbox, helpottaa filterointia kun vaan yksi formaatti

roadLinkService.getRoadLinksFromVVH(bounds)
}
LogUtils.time(logger, "TEST LOG manoeuvres get assets by roadlinks, roadlink count: " + roadLinks.size) {
getByRoadLinks(roadLinks)
}
}

def updateManoeuvre(userName: String, oldManoeuvreId: Long, manoeuvreUpdates: ManoeuvreUpdates, modifiedDate: Option[DateTime]): Long = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import fi.liikennevirasto.digiroad2.linearasset.{RoadLink, RoadLinkLike}
import fi.liikennevirasto.digiroad2.model.LRMPosition
import fi.liikennevirasto.digiroad2.service.RoadLinkService
import fi.liikennevirasto.digiroad2.user.User
import fi.liikennevirasto.digiroad2.util.GeometryTransform
import fi.liikennevirasto.digiroad2.util.{GeometryTransform, LogUtils}
import org.joda.time.{DateTime, LocalDate}
import org.slf4j.LoggerFactory
import slick.driver.JdbcDriver.backend.Database.dynamicSession
Expand Down Expand Up @@ -216,8 +216,12 @@ trait MassTransitStopService extends PointAssetOperations {
}

override def getByBoundingBox(user: User, bounds: BoundingRectangle) : Seq[PersistedMassTransitStop] = {
val roadLinks = roadLinkService.getRoadLinksWithComplementaryFromVVH(bounds)
super.getByBoundingBox(user, bounds, roadLinks, Seq(), floatingAdjustment(adjustmentOperation, createPersistedAssetObject))
val roadLinks = LogUtils.time(logger, "TEST LOG Get and enrich roadlinks and complementaries"){
roadLinkService.getRoadLinksWithComplementaryFromVVH(bounds)
}
LogUtils.time(logger, "TEST LOG Get massTransitStop assets by bounding box") {
super.getByBoundingBox(user, bounds, roadLinks, Seq(), floatingAdjustment(adjustmentOperation, createPersistedAssetObject))
}
}

override def getNormalAndComplementaryById(id: Long, roadLink: RoadLink): Option[PersistedAsset] = {
Expand Down