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

Add priority queue implementation #124

Merged
merged 8 commits into from
Dec 2, 2016
Merged

Add priority queue implementation #124

merged 8 commits into from
Dec 2, 2016

Conversation

rmarianski
Copy link
Member

Connects to #18

@zerebubuth, @nvkelso, @iandees could you review please?

Instead of using an integer index into the list of queues, use the queue
name itself as the id for mapping purposes.
def job_done(self, coord_message):
queue_name = self.get_queue_name_for_zoom(coord_message.coord.zoom)
if queue_name is None:
# TODO log? should this assert instead?
Copy link
Member

Choose a reason for hiding this comment

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

I think we should assert here. Presumably this would mean that tilequeue has rendered a zoom level for which it wasn't configured, which seems to me like an error condition. Should we assume that get_queue_name_for_zoom will return a valid queue name always, and have an assertion in that method (or use [] instead of get())?

Copy link
Member Author

Choose a reason for hiding this comment

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

Added assert in 22ea268.

And upon further thought, I think that you're right that we'd want it to fail fast when it didn't find a queue for a particular input. That suggests either the mapping is wrong/incomplete, or the input coordinate is invalid, which I think we'd want to know about right away. I'll go ahead and make this change.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated in c4749ef.

type: mem
name: <sqs queue/queue file name/redis key>
name: <sqs queue/queue file name/redis key/list of queue names>
Copy link
Member

Choose a reason for hiding this comment

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

This list and the list in the line above should be in the same order.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch, updated in b6df7a3.

zoom-queue-map:
# keys are <start-zoom>-<end-zoom> (inclusive) ranges
# values are the queue name to use for zooms in that range
0-10: queue-1
Copy link
Member

Choose a reason for hiding this comment

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

Should the queue names be descriptive of the zooms, or generic?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is just sample config, but for what we actually do I was planning on using generic names, in descending priority order, ie 1 is higher priority than 2, and so on. That way if we change our mapping policy in the future we won't have to re-create queues to represent the new configuration.


def __call__(self, zoom):
assert isinstance(zoom, int)
assert 0 <= zoom <= 20
Copy link
Member

Choose a reason for hiding this comment

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

We've standardized around 21 in house styles and Tangram.

except (ValueError, KeyError):
assert not 'Invalid zoom range: %s' % zoom_range

assert (0 <= zoom_start <= 20 and
Copy link
Member

Choose a reason for hiding this comment

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

Ditto 21

@@ -68,9 +69,12 @@ def read(self, max_to_read=1):
data = message.get_body()
coord = deserialize_coord(data)
if coord is None:
# log?
# TODO log?
Copy link
Member

Choose a reason for hiding this comment

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

;)



def coord_is_valid(coord):
if coord.zoom < 0 or coord.zoom > 20:
Copy link
Member

Choose a reason for hiding this comment

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

Ditto 21

@nvkelso
Copy link
Member

nvkelso commented Dec 2, 2016 via email

@rmarianski
Copy link
Member Author

Tracking the zoom 20 -> 21 bump in https://github.com/mapzen/tile-tasks/issues/152

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants