예제 #1
0
# limitations under the License.

import heapq
import itertools

from oslo.config import cfg

from marconi.common import decorators
from marconi.common.storage import select
from marconi.common import utils as common_utils
from marconi.openstack.common import log
from marconi.queues import storage
from marconi.queues.storage import errors
from marconi.queues.storage import utils

LOG = log.getLogger(__name__)

_CATALOG_OPTIONS = [
    cfg.IntOpt('storage', default='sqlite',
               help='Catalog storage driver.'),
]

_CATALOG_GROUP = 'sharding:catalog'

# NOTE(kgriffs): E.g.: 'marconi-sharding:5083853/my-queue'
_SHARD_CACHE_PREFIX = 'sharding:'

# TODO(kgriffs): If a queue is migrated, everyone's
# caches need to have the relevant entry invalidated
# before "unfreezing" the queue, rather than waiting
# on the TTL.
예제 #2
0
# 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.
import functools

import sqlalchemy as sa
from sqlalchemy import exc
from sqlalchemy.sql import func as sfunc

from marconi.openstack.common import log as logging
from marconi.queues.storage import errors
from marconi.queues.storage.sqlalchemy import tables

LOG = logging.getLogger(__name__)
UNIX_EPOCH_AS_JULIAN_SEC = 2440587.5 * 86400.0


def raises_conn_error(func):
    """Handles sqlalchemy DisconnectionError

    When sqlalchemy detects a disconnect from the database server, it
    retries a number of times. After failing that number of times, it
    will convert the internal DisconnectionError into an
    InvalidRequestError. This decorator handles that error.
    """
    @functools.wraps(func)
    def wrapper(*args, **kwargs):
        try:
            return func(*args, **kwargs)