per zoom workers
This commit is contained in:
parent
3ac14934dd
commit
645a4be524
@ -14,12 +14,21 @@ func getTileKey(tc *coords.TileCoords) string {
|
|||||||
strconv.Itoa(tc.Zoom) + "/" + strconv.Itoa(tc.LayerId)
|
strconv.Itoa(tc.Zoom) + "/" + strconv.Itoa(tc.LayerId)
|
||||||
}
|
}
|
||||||
|
|
||||||
func renderMapblocks(ctx *app.App, jobs chan *coords.TileCoords, mblist []*mapblockparser.MapBlock) int {
|
func renderMapblocks(ctx *app.App, mblist []*mapblockparser.MapBlock) int {
|
||||||
tileRenderedMap := make(map[string]bool)
|
tileRenderedMap := make(map[string]bool)
|
||||||
tilecount := 0
|
tilecount := 0
|
||||||
totalRenderedMapblocks.Add(float64(len(mblist)))
|
totalRenderedMapblocks.Add(float64(len(mblist)))
|
||||||
|
|
||||||
for i := 12; i >= 1; i-- {
|
for i := 12; i >= 1; i-- {
|
||||||
|
|
||||||
|
//Spin up workers
|
||||||
|
jobs := make(chan *coords.TileCoords, ctx.Config.RenderingQueue)
|
||||||
|
done := make(chan bool, 1)
|
||||||
|
|
||||||
|
for i := 0; i < ctx.Config.RenderingJobs; i++ {
|
||||||
|
go worker(ctx, jobs, done)
|
||||||
|
}
|
||||||
|
|
||||||
for _, mb := range mblist {
|
for _, mb := range mblist {
|
||||||
//13
|
//13
|
||||||
|
|
||||||
@ -60,6 +69,10 @@ func renderMapblocks(ctx *app.App, jobs chan *coords.TileCoords, mblist []*mapbl
|
|||||||
//dispatch re-render
|
//dispatch re-render
|
||||||
jobs <- tc
|
jobs <- tc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//spin down worker pool
|
||||||
|
close(jobs)
|
||||||
|
<-done
|
||||||
}
|
}
|
||||||
|
|
||||||
return tilecount
|
return tilecount
|
||||||
|
@ -2,7 +2,6 @@ package tilerendererjob
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"mapserver/app"
|
"mapserver/app"
|
||||||
"mapserver/coords"
|
|
||||||
"mapserver/settings"
|
"mapserver/settings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -13,7 +12,7 @@ type IncrementalRenderEvent struct {
|
|||||||
LastMtime int64 `json:"lastmtime"`
|
LastMtime int64 `json:"lastmtime"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func incrementalRender(ctx *app.App, jobs chan *coords.TileCoords) {
|
func incrementalRender(ctx *app.App) {
|
||||||
|
|
||||||
lastMtime := ctx.Settings.GetInt64(settings.SETTING_LAST_MTIME, 0)
|
lastMtime := ctx.Settings.GetInt64(settings.SETTING_LAST_MTIME, 0)
|
||||||
|
|
||||||
@ -36,7 +35,7 @@ func incrementalRender(ctx *app.App, jobs chan *coords.TileCoords) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
tiles := renderMapblocks(ctx, jobs, result.List)
|
tiles := renderMapblocks(ctx, result.List)
|
||||||
|
|
||||||
lastMtime = result.LastMtime
|
lastMtime = result.LastMtime
|
||||||
ctx.Settings.SetInt64(settings.SETTING_LAST_MTIME, lastMtime)
|
ctx.Settings.SetInt64(settings.SETTING_LAST_MTIME, lastMtime)
|
||||||
|
@ -2,7 +2,6 @@ package tilerendererjob
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"mapserver/app"
|
"mapserver/app"
|
||||||
"mapserver/coords"
|
|
||||||
"mapserver/settings"
|
"mapserver/settings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -13,7 +12,7 @@ type InitialRenderEvent struct {
|
|||||||
Progress float64 `json:"progress"`
|
Progress float64 `json:"progress"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func initialRender(ctx *app.App, jobs chan *coords.TileCoords) {
|
func initialRender(ctx *app.App) {
|
||||||
logrus.Info("Starting initial rendering job")
|
logrus.Info("Starting initial rendering job")
|
||||||
lastMtime := ctx.Settings.GetInt64(settings.SETTING_LAST_MTIME, 0)
|
lastMtime := ctx.Settings.GetInt64(settings.SETTING_LAST_MTIME, 0)
|
||||||
|
|
||||||
@ -44,7 +43,7 @@ func initialRender(ctx *app.App, jobs chan *coords.TileCoords) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tiles := renderMapblocks(ctx, jobs, result.List)
|
tiles := renderMapblocks(ctx, result.List)
|
||||||
|
|
||||||
t := time.Now()
|
t := time.Now()
|
||||||
elapsed := t.Sub(start)
|
elapsed := t.Sub(start)
|
||||||
|
@ -2,24 +2,17 @@ package tilerendererjob
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"mapserver/app"
|
"mapserver/app"
|
||||||
"mapserver/coords"
|
|
||||||
"mapserver/settings"
|
"mapserver/settings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Job(ctx *app.App) {
|
func Job(ctx *app.App) {
|
||||||
initMetrics()
|
initMetrics()
|
||||||
|
|
||||||
jobs := make(chan *coords.TileCoords, ctx.Config.RenderingQueue)
|
|
||||||
|
|
||||||
for i := 0; i < ctx.Config.RenderingJobs; i++ {
|
|
||||||
go worker(ctx, jobs)
|
|
||||||
}
|
|
||||||
|
|
||||||
if ctx.Settings.GetBool(settings.SETTING_INITIAL_RUN, true) {
|
if ctx.Settings.GetBool(settings.SETTING_INITIAL_RUN, true) {
|
||||||
initialRender(ctx, jobs)
|
initialRender(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
incrementalRender(ctx, jobs)
|
incrementalRender(ctx)
|
||||||
|
|
||||||
panic("render job interrupted!")
|
panic("render job interrupted!")
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
func worker(ctx *app.App, coords <-chan *coords.TileCoords) {
|
func worker(ctx *app.App, coords <-chan *coords.TileCoords, done chan bool) {
|
||||||
for tc := range coords {
|
for tc := range coords {
|
||||||
//render tile
|
//render tile
|
||||||
|
|
||||||
@ -24,4 +24,6 @@ func worker(ctx *app.App, coords <-chan *coords.TileCoords) {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
done <- true
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user