
Adds a memory storage driver to marconi-proxy. This is ideal for testing storage implementations. Furthermore, unit tests are added for the storage layer. These tests check the fundamental behavior of the proxy storage drivers and mirrors the approach used by marconi/queues/storage. The storage interface has also been updated. The old variant keep round robin indices in storage. I found that this was a Bad Idea. This patch removes this design flaw from the implementation. Consequentially, many of the helper functions were greatly simplified. See: utils/node:weighted_select and utils/round_robin:Selector. The last set of changes relate to the transport layer. They are as follows: - redis has been torn out of the transport * storage is no longer hard-coded - partition and catalogue controllers are passed as needed to resources - resources round-robin per request, rather than only once on queue allocation - terminology update: nodes -> hosts Change-Id: I78863f7437dd9eec011cdfe7962fd88be23a3975 Implements: blueprint placement-service
89 lines
3.2 KiB
Python
89 lines
3.2 KiB
Python
# Copyright (c) 2013 Rackspace Hosting, Inc.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
# implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
"""marconi-proxy: maintains a mapping from inserted queues to partitions.
|
|
|
|
Supports the following operator API:
|
|
- [GET] /v1/partitions - lists registered partitions
|
|
- [PUT|GET|DELETE] /v1/partitions/{partition}
|
|
- [GET] /v1/catalogue
|
|
|
|
Deploy requirements:
|
|
- redis-server, default port
|
|
- gunicorn
|
|
- python >= 2.7
|
|
- falcon
|
|
- msgpack
|
|
- requests
|
|
|
|
Running:
|
|
- gunicorn marconi.proxy.app:app
|
|
"""
|
|
import falcon
|
|
|
|
from marconi.proxy.resources import catalogue
|
|
from marconi.proxy.resources import forward
|
|
from marconi.proxy.resources import health
|
|
from marconi.proxy.resources import metadata
|
|
from marconi.proxy.resources import partitions
|
|
from marconi.proxy.resources import queues
|
|
from marconi.proxy.resources import v1
|
|
|
|
# TODO(cpp-cabrera): migrate to oslo.config/stevedore
|
|
# to stop hard coding the driver
|
|
from marconi.proxy.storage.memory import driver as memory_driver
|
|
|
|
|
|
app = falcon.API()
|
|
driver = memory_driver.Driver()
|
|
catalogue_driver = driver.catalogue_controller
|
|
partitions_driver = driver.partitions_controller
|
|
|
|
# TODO(cpp-cabrera): don't encode API version in routes -
|
|
# let's handle this elsewhere
|
|
# TODO(cpp-cabrera): bring in controllers based on config
|
|
# NOTE(cpp-cabrera): Proxy-specific routes
|
|
app.add_route('/v1/partitions',
|
|
partitions.Listing(partitions_driver))
|
|
app.add_route('/v1/partitions/{partition}',
|
|
partitions.Resource(partitions_driver))
|
|
app.add_route('/v1/catalogue',
|
|
catalogue.Listing(catalogue_driver))
|
|
app.add_route('/v1/catalogue/{queue}',
|
|
catalogue.Resource(catalogue_driver))
|
|
|
|
# NOTE(cpp-cabrera): queue handling routes
|
|
app.add_route('/v1/queues',
|
|
queues.Listing(catalogue_driver))
|
|
app.add_route('/v1/queues/{queue}',
|
|
queues.Resource(partitions_driver, catalogue_driver))
|
|
|
|
# NOTE(cpp-cabrera): Marconi forwarded routes
|
|
app.add_route('/v1',
|
|
v1.Resource(partitions_driver))
|
|
app.add_route('/v1/health',
|
|
health.Resource())
|
|
app.add_route('/v1/queues/{queue}/claims',
|
|
forward.ClaimCreate(partitions_driver, catalogue_driver))
|
|
app.add_route('/v1/queues/{queue}/claims/{cid}',
|
|
forward.Claim(partitions_driver, catalogue_driver))
|
|
app.add_route('/v1/queues/{queue}/messages',
|
|
forward.MessageBulk(partitions_driver, catalogue_driver))
|
|
app.add_route('/v1/queues/{queue}/messages/{mid}',
|
|
forward.Message(partitions_driver, catalogue_driver))
|
|
app.add_route('/v1/queues/{queue}/stats',
|
|
forward.Stats(partitions_driver, catalogue_driver))
|
|
app.add_route('/v1/queues/{queue}/metadata',
|
|
metadata.Resource(partitions_driver, catalogue_driver))
|