Removed StorageEngine class and it's hierarchy

This class doesn't have any logic in it so it can be safely removed

Change-Id: Iba3fe676df320a1d1cb48022f090df8d9e17b7aa
This commit is contained in:
Alexei Kornienko 2014-04-16 02:03:18 +03:00 committed by Alexei Kornienko
parent 2633eb8c99
commit 37193c3b75
9 changed files with 100 additions and 169 deletions

View File

@ -80,11 +80,8 @@ def get_connection(url):
LOG.debug(_('looking for %(name)r driver in %(namespace)r') % (
{'name': engine_name,
'namespace': STORAGE_ENGINE_NAMESPACE}))
mgr = driver.DriverManager(STORAGE_ENGINE_NAMESPACE,
engine_name,
invoke_on_load=True)
return mgr.driver.get_connection(url)
mgr = driver.DriverManager(STORAGE_ENGINE_NAMESPACE, engine_name)
return mgr.driver(url)
class SampleFilter(object):

View File

@ -18,10 +18,8 @@
"""Base classes for storage engines
"""
import abc
import datetime
import math
import six
from six import moves
@ -105,15 +103,6 @@ class Pagination(object):
self.sort_dirs = sort_dirs
@six.add_metaclass(abc.ABCMeta)
class StorageEngine(object):
"""Base class for storage engines."""
@abc.abstractmethod
def get_connection(self, url):
"""Return a Connection instance based on the url."""
class Connection(object):
"""Base class for storage system connections."""

View File

@ -42,7 +42,17 @@ from ceilometer import utils
LOG = log.getLogger(__name__)
class DB2Storage(base.StorageEngine):
AVAILABLE_CAPABILITIES = {
'resources': {'query': {'simple': True,
'metadata': True}},
'statistics': {'groupby': True,
'query': {'simple': True,
'metadata': True},
'aggregation': {'standard': True}}
}
class Connection(pymongo_base.Connection):
"""The db2 storage for Ceilometer
Collections::
@ -68,26 +78,6 @@ class DB2Storage(base.StorageEngine):
}
"""
def get_connection(self, url):
"""Return a Connection instance based on the url.
"""
return Connection(url)
AVAILABLE_CAPABILITIES = {
'resources': {'query': {'simple': True,
'metadata': True}},
'statistics': {'groupby': True,
'query': {'simple': True,
'metadata': True},
'aggregation': {'standard': True}}
}
class Connection(pymongo_base.Connection):
"""DB2 connection.
"""
CAPABILITIES = utils.update_nested(pymongo_base.Connection.CAPABILITIES,
AVAILABLE_CAPABILITIES)
CONNECTION_POOL = pymongo_base.ConnectionPool()

View File

@ -42,7 +42,20 @@ from ceilometer import utils
LOG = log.getLogger(__name__)
class HBaseStorage(base.StorageEngine):
AVAILABLE_CAPABILITIES = {
'meters': {'query': {'simple': True,
'metadata': True}},
'resources': {'query': {'simple': True,
'metadata': True}},
'samples': {'query': {'simple': True,
'metadata': True}},
'statistics': {'query': {'simple': True,
'metadata': True},
'aggregation': {'standard': True}},
}
class Connection(base.Connection):
"""Put the data into a HBase database
Collections:
@ -108,32 +121,8 @@ class HBaseStorage(base.StorageEngine):
if not determined
"""
@staticmethod
def get_connection(url):
"""Return a Connection instance based on the configuration settings.
"""
return Connection(url)
AVAILABLE_CAPABILITIES = {
'meters': {'query': {'simple': True,
'metadata': True}},
'resources': {'query': {'simple': True,
'metadata': True}},
'samples': {'query': {'simple': True,
'metadata': True}},
'statistics': {'query': {'simple': True,
'metadata': True},
'aggregation': {'standard': True}},
}
class Connection(base.Connection):
"""HBase connection.
"""
CAPABILITIES = utils.update_nested(base.Connection.CAPABILITIES,
AVAILABLE_CAPABILITIES)
_memory_instance = None
PROJECT_TABLE = "project"

View File

@ -25,18 +25,8 @@ from ceilometer.storage import base
LOG = log.getLogger(__name__)
class LogStorage(base.StorageEngine):
"""Log the data
"""
def get_connection(self, url):
"""Return a Connection instance based on the url.
"""
return Connection(url)
class Connection(base.Connection):
"""Base class for storage system connections.
"""Log the data.
"""
def upgrade(self):

View File

@ -49,7 +49,24 @@ cfg.CONF.import_opt('time_to_live', 'ceilometer.storage',
LOG = log.getLogger(__name__)
class MongoDBStorage(base.StorageEngine):
AVAILABLE_CAPABILITIES = {
'resources': {'query': {'simple': True,
'metadata': True}},
'statistics': {'groupby': True,
'query': {'simple': True,
'metadata': True},
'aggregation': {'standard': True,
'selectable': {'max': True,
'min': True,
'sum': True,
'avg': True,
'count': True,
'stddev': True,
'cardinality': True}}}
}
class Connection(pymongo_base.Connection):
"""Put the data into a MongoDB database
Collections::
@ -75,35 +92,8 @@ class MongoDBStorage(base.StorageEngine):
}
"""
def get_connection(self, url):
"""Return a Connection instance based on the url.
"""
return Connection(url)
AVAILABLE_CAPABILITIES = {
'resources': {'query': {'simple': True,
'metadata': True}},
'statistics': {'groupby': True,
'query': {'simple': True,
'metadata': True},
'aggregation': {'standard': True,
'selectable': {'max': True,
'min': True,
'sum': True,
'avg': True,
'count': True,
'stddev': True,
'cardinality': True}}}
}
class Connection(pymongo_base.Connection):
"""MongoDB connection.
"""
CAPABILITIES = utils.update_nested(pymongo_base.Connection.CAPABILITIES,
AVAILABLE_CAPABILITIES)
CONNECTION_POOL = pymongo_base.ConnectionPool()
REDUCE_GROUP_CLEAN = bson.code.Code("""

View File

@ -48,61 +48,6 @@ from ceilometer import utils
LOG = log.getLogger(__name__)
class SQLAlchemyStorage(base.StorageEngine):
"""Put the data into a SQLAlchemy database.
Tables::
- user
- { id: user uuid }
- source
- { id: source id }
- project
- { id: project uuid }
- meter
- meter definition
- { id: meter def id
name: meter name
type: meter type
unit: meter unit
}
- sample
- the raw incoming data
- { id: sample id
meter_id: meter id (->meter.id)
user_id: user uuid (->user.id)
project_id: project uuid (->project.id)
resource_id: resource uuid (->resource.id)
resource_metadata: metadata dictionaries
volume: sample volume
timestamp: datetime
message_signature: message signature
message_id: message uuid
}
- resource
- the metadata for resources
- { id: resource uuid
resource_metadata: metadata dictionaries
project_id: project uuid (->project.id)
user_id: user uuid (->user.id)
}
- sourceassoc
- the relationships
- { sample_id: sample id (->sample.id)
project_id: project uuid (->project.id)
resource_id: resource uuid (->resource.id)
user_id: user uuid (->user.id)
source_id: source id (->source.id)
}
"""
@staticmethod
def get_connection(url):
"""Return a Connection instance based on the url.
"""
return Connection(url)
META_TYPE_MAP = {bool: models.MetaBool,
str: models.MetaText,
unicode: models.MetaText,
@ -238,7 +183,52 @@ def make_query_from_filter(session, query, sample_filter, require_meter=True):
class Connection(base.Connection):
"""SqlAlchemy connection."""
"""Put the data into a SQLAlchemy database.
Tables::
- user
- { id: user uuid }
- source
- { id: source id }
- project
- { id: project uuid }
- meter
- meter definition
- { id: meter def id
name: meter name
type: meter type
unit: meter unit
}
- sample
- the raw incoming data
- { id: sample id
meter_id: meter id (->meter.id)
user_id: user uuid (->user.id)
project_id: project uuid (->project.id)
resource_id: resource uuid (->resource.id)
resource_metadata: metadata dictionaries
volume: sample volume
timestamp: datetime
message_signature: message signature
message_id: message uuid
}
- resource
- the metadata for resources
- { id: resource uuid
resource_metadata: metadata dictionaries
project_id: project uuid (->project.id)
user_id: user uuid (->user.id)
}
- sourceassoc
- the relationships
- { sample_id: sample id (->sample.id)
project_id: project uuid (->project.id)
resource_id: resource uuid (->resource.id)
user_id: user uuid (->user.id)
source_id: source id (->source.id)
}
"""
CAPABILITIES = utils.update_nested(base.Connection.CAPABILITIES,
AVAILABLE_CAPABILITIES)

View File

@ -18,17 +18,13 @@
"""Tests for ceilometer/storage/impl_log.py
"""
import mock
from ceilometer.openstack.common import test
from ceilometer.storage import impl_log
class ConnectionTest(test.BaseTestCase):
def test_get_connection(self):
conf = mock.Mock()
log_stg = impl_log.LogStorage()
conn = log_stg.get_connection(conf)
conn = impl_log.Connection(None)
conn.record_metering_data({'counter_name': 'test',
'resource_id': __name__,
'counter_volume': 1,

View File

@ -136,13 +136,13 @@ ceilometer.poll.central =
ceilometer.storage =
log = ceilometer.storage.impl_log:LogStorage
mongodb = ceilometer.storage.impl_mongodb:MongoDBStorage
mysql = ceilometer.storage.impl_sqlalchemy:SQLAlchemyStorage
postgresql = ceilometer.storage.impl_sqlalchemy:SQLAlchemyStorage
sqlite = ceilometer.storage.impl_sqlalchemy:SQLAlchemyStorage
hbase = ceilometer.storage.impl_hbase:HBaseStorage
db2 = ceilometer.storage.impl_db2:DB2Storage
log = ceilometer.storage.impl_log:Connection
mongodb = ceilometer.storage.impl_mongodb:Connection
mysql = ceilometer.storage.impl_sqlalchemy:Connection
postgresql = ceilometer.storage.impl_sqlalchemy:Connection
sqlite = ceilometer.storage.impl_sqlalchemy:Connection
hbase = ceilometer.storage.impl_hbase:Connection
db2 = ceilometer.storage.impl_db2:Connection
ceilometer.compute.virt =
libvirt = ceilometer.compute.virt.libvirt.inspector:LibvirtInspector