Proxy

Proxy Server

class swift.proxy.server.AccountController(app, account_name, **kwargs)

Bases: swift.proxy.server.Controller

WSGI controller for account requests

GETorHEAD(req)

Handler for HTTP GET/HEAD requests.

class swift.proxy.server.Application(conf, memcache, logger=None, account_ring=None, container_ring=None, object_ring=None)

Bases: swift.proxy.server.BaseApplication

WSGI application for the proxy server.

check_rate_limit(req, path_parts)

Check for rate limiting.

Parameters:
  • req – webob.Request object
  • path_parts – parsed path dictionary
handle_request(req)

Wraps the BaseApplication.handle_request and logs the request.

posthooklogger(env, req)
class swift.proxy.server.BaseApplication(conf, memcache, logger=None, account_ring=None, container_ring=None, object_ring=None)

Bases: object

Base WSGI application for the proxy server

check_rate_limit(req, path_parts)

Check for rate limiting.

get_controller(path)

Get the controller to handle a request.

Parameters:
  • path – path from request
Returns:

tuple of (controller class, path dictionary)

handle_request(req)

Entry point for proxy server. Should return a WSGI-style callable (such as webob.Response).

Parameters:
  • req – webob.Request object
posthooklogger(env, req)
update_request(req)
class swift.proxy.server.ContainerController(app, account_name, container_name, **kwargs)

Bases: swift.proxy.server.Controller

WSGI controller for container requests

DELETE(*a, **kw)

HTTP DELETE request handler.

GETorHEAD(req)

Handler for HTTP GET/HEAD requests.

PUT(*a, **kw)

HTTP PUT request handler.

class swift.proxy.server.Controller(app)

Bases: object

Base WSGI controller class for the proxy

GET(*a, **kw)

Handler for HTTP GET requests.

GETorHEAD_base(req, server_type, partition, nodes, path, attempts)

Base handler for HTTP GET or HEAD requests.

Parameters:
  • req – webob.Request object
  • server_type – server type
  • partition – partition
  • nodes – nodes
  • path – path for the request
  • attempts – number of attempts to try
Returns:

webob.Response object

HEAD(*a, **kw)

Handler for HTTP HEAD requests.

account_info(account)

Get account information, and also verify that the account exists.

Parameters:
  • account – name of the account to get the info for
Returns:

tuple of (account partition, account nodes) or (None, None) if it does not exist

best_response(req, statuses, reasons, bodies, server_type, etag=None)

Given a list of responses from several servers, choose the best to return to the API.

Parameters:
  • req – webob.Request object
  • statuses – list of statuses returned
  • reasons – list of reasons for each status
  • bodies – bodies of each response
  • server_type – type of server the responses came from
  • etag – etag
Returns:

webob.Response object with the correct status, body, etc. set

container_info(account, container)

Get container information and thusly verify container existance. This will also make a call to account_info to verify that the account exists.

Parameters:
  • account – account name for the container
  • container – container name to look up
Returns:

tuple of (container partition, container nodes) or (None, None) if the container does not exist

error_increment(node)

Handles incrementing error counts when talking to nodes.

Parameters:
  • node – dictionary of node to increment the error count for
error_limit(node)

Mark a node as error limited.

Parameters:
  • node – dictionary of node to error limit
error_limited(node)

Check if the node is currently error limited.

Parameters:
  • node – dictionary of node to check
Returns:

True if error limited, False otherwise

error_occurred(node, msg)

Handle logging, and handling of errors.

Parameters:
  • node – dictionary of node to handle errors for
  • msg – error message
exception_occurred(node, typ, additional_info)

Handle logging of generic exceptions.

Parameters:
  • node – dictionary of node to log the error for
  • typ – server type
  • additional_info – additional information to log
get_update_nodes(partition, nodes, ring)

Returns ring.replica_count nodes; the nodes will not be error limited, if possible.

iter_nodes(partition, nodes, ring)

Node iterator that will first iterate over the normal nodes for a partition and then the handoff partitions for the node.

Parameters:
  • partition – partition to iterate nodes for
  • nodes – list of node dicts from the ring
  • ring – ring to get handoff nodes from
class swift.proxy.server.ObjectController(app, account_name, container_name, object_name, **kwargs)

Bases: swift.proxy.server.Controller

WSGI controller for object requests.

COPY(*a, **kw)

HTTP COPY request handler.

DELETE(*a, **kw)

HTTP DELETE request handler.

GETorHEAD(req)

Handle HTTP GET or HEAD requests.

POST(*a, **kw)

HTTP POST request handler.

PUT(*a, **kw)

HTTP PUT request handler.

node_post_or_delete(req, partition, node, path)

Handle common POST/DELETE functionality

Parameters:
  • req – webob.Request object
  • partition – partition for the object
  • node – node dictionary for the object
  • path – path to send for the request
swift.proxy.server.public(func)

Decorator to declare which methods are public accessible as HTTP requests

Parameters:
  • func – function to make public
swift.proxy.server.update_headers(response, headers)

Helper function to update headers in the response.

Parameters:
  • response – webob.Response object
  • headers – dictionary headers

Table Of Contents

Previous topic

Partitioned Consistent Hash Ring

Next topic

Account

This Page