Relocate DATADIR to backends
It simply makes sense that the definition of DATADIR belongs to backends. After all, some of them may not even have any. Coincidentially, a few unnecessary imports are dropped. By the way, on the object server side, diskfile.py provides DATADIR in the same way already. Change-Id: I60bfd522c77c4a0ee13697a2e31141777c7e2398
This commit is contained in:
parent
429445d97b
commit
a7cfcc3d7a
@ -19,8 +19,7 @@ from swift import gettext_ as _
|
||||
from random import random
|
||||
|
||||
import swift.common.db
|
||||
from swift.account import server as account_server
|
||||
from swift.account.backend import AccountBroker
|
||||
from swift.account.backend import AccountBroker, DATADIR
|
||||
from swift.common.utils import get_logger, audit_location_generator, \
|
||||
config_true_value, dump_recon_cache, ratelimit_sleep
|
||||
from swift.common.daemon import Daemon
|
||||
@ -49,8 +48,7 @@ class AccountAuditor(Daemon):
|
||||
self.rcache = os.path.join(self.recon_cache_path, "account.recon")
|
||||
|
||||
def _one_audit_pass(self, reported):
|
||||
all_locs = audit_location_generator(self.devices,
|
||||
account_server.DATADIR, '.db',
|
||||
all_locs = audit_location_generator(self.devices, DATADIR, '.db',
|
||||
mount_check=self.mount_check,
|
||||
logger=self.logger)
|
||||
for path, device, partition in all_locs:
|
||||
|
@ -28,6 +28,8 @@ from swift.common.utils import normalize_timestamp, lock_parent_directory
|
||||
from swift.common.db import DatabaseBroker, DatabaseConnectionError, \
|
||||
PENDING_CAP, PICKLE_PROTOCOL, utf8encode
|
||||
|
||||
DATADIR = 'accounts'
|
||||
|
||||
|
||||
class AccountBroker(DatabaseBroker):
|
||||
"""Encapsulates working with an account database."""
|
||||
|
@ -23,8 +23,7 @@ from time import time, ctime
|
||||
from eventlet import GreenPool, sleep, Timeout
|
||||
|
||||
import swift.common.db
|
||||
from swift.account.server import DATADIR
|
||||
from swift.account.backend import AccountBroker
|
||||
from swift.account.backend import AccountBroker, DATADIR
|
||||
from swift.common.direct_client import direct_delete_container, \
|
||||
direct_delete_object, direct_get_container
|
||||
from swift.common.exceptions import ClientException
|
||||
|
@ -13,13 +13,12 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from swift.account import server as account_server
|
||||
from swift.account.backend import AccountBroker
|
||||
from swift.account.backend import AccountBroker, DATADIR
|
||||
from swift.common import db_replicator
|
||||
|
||||
|
||||
class AccountReplicator(db_replicator.Replicator):
|
||||
server_type = 'account'
|
||||
brokerclass = AccountBroker
|
||||
datadir = account_server.DATADIR
|
||||
datadir = DATADIR
|
||||
default_port = 6002
|
||||
|
@ -21,7 +21,7 @@ from swift import gettext_ as _
|
||||
from eventlet import Timeout
|
||||
|
||||
import swift.common.db
|
||||
from swift.account.backend import AccountBroker
|
||||
from swift.account.backend import AccountBroker, DATADIR
|
||||
from swift.account.utils import account_listing_response
|
||||
from swift.common.db import DatabaseConnectionError, DatabaseAlreadyExists
|
||||
from swift.common.request_helpers import get_param, get_listing_content_type, \
|
||||
@ -40,9 +40,6 @@ from swift.common.swob import HTTPAccepted, HTTPBadRequest, \
|
||||
from swift.common.request_helpers import is_sys_or_user_meta
|
||||
|
||||
|
||||
DATADIR = 'accounts'
|
||||
|
||||
|
||||
class AccountController(object):
|
||||
"""WSGI controller for the account server."""
|
||||
|
||||
|
@ -21,8 +21,7 @@ from random import random
|
||||
from eventlet import Timeout
|
||||
|
||||
import swift.common.db
|
||||
from swift.container import server as container_server
|
||||
from swift.container.backend import ContainerBroker
|
||||
from swift.container.backend import ContainerBroker, DATADIR
|
||||
from swift.common.utils import get_logger, audit_location_generator, \
|
||||
config_true_value, dump_recon_cache, ratelimit_sleep
|
||||
from swift.common.daemon import Daemon
|
||||
@ -49,8 +48,7 @@ class ContainerAuditor(Daemon):
|
||||
self.rcache = os.path.join(self.recon_cache_path, "container.recon")
|
||||
|
||||
def _one_audit_pass(self, reported):
|
||||
all_locs = audit_location_generator(self.devices,
|
||||
container_server.DATADIR, '.db',
|
||||
all_locs = audit_location_generator(self.devices, DATADIR, '.db',
|
||||
mount_check=self.mount_check,
|
||||
logger=self.logger)
|
||||
for path, device, partition in all_locs:
|
||||
|
@ -28,6 +28,8 @@ from swift.common.utils import normalize_timestamp, lock_parent_directory
|
||||
from swift.common.db import DatabaseBroker, DatabaseConnectionError, \
|
||||
PENDING_CAP, PICKLE_PROTOCOL, utf8encode
|
||||
|
||||
DATADIR = 'containers'
|
||||
|
||||
|
||||
class ContainerBroker(DatabaseBroker):
|
||||
"""Encapsulates working with a container database."""
|
||||
|
@ -13,15 +13,14 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from swift.container import server as container_server
|
||||
from swift.container.backend import ContainerBroker
|
||||
from swift.container.backend import ContainerBroker, DATADIR
|
||||
from swift.common import db_replicator
|
||||
|
||||
|
||||
class ContainerReplicator(db_replicator.Replicator):
|
||||
server_type = 'container'
|
||||
brokerclass = ContainerBroker
|
||||
datadir = container_server.DATADIR
|
||||
datadir = DATADIR
|
||||
default_port = 6001
|
||||
|
||||
def report_up_to_date(self, full_info):
|
||||
|
@ -23,7 +23,7 @@ from xml.etree.cElementTree import Element, SubElement, tostring
|
||||
from eventlet import Timeout
|
||||
|
||||
import swift.common.db
|
||||
from swift.container.backend import ContainerBroker
|
||||
from swift.container.backend import ContainerBroker, DATADIR
|
||||
from swift.common.db import DatabaseAlreadyExists
|
||||
from swift.common.container_sync_realms import ContainerSyncRealms
|
||||
from swift.common.request_helpers import get_param, get_listing_content_type, \
|
||||
@ -43,8 +43,6 @@ from swift.common.swob import HTTPAccepted, HTTPBadRequest, HTTPConflict, \
|
||||
HTTPPreconditionFailed, HTTPMethodNotAllowed, Request, Response, \
|
||||
HTTPInsufficientStorage, HTTPException, HeaderKeyDict
|
||||
|
||||
DATADIR = 'containers'
|
||||
|
||||
|
||||
class ContainerController(object):
|
||||
"""WSGI Controller for the container server."""
|
||||
|
@ -23,8 +23,7 @@ from struct import unpack_from
|
||||
from eventlet import sleep, Timeout
|
||||
|
||||
import swift.common.db
|
||||
from swift.container import server as container_server
|
||||
from swift.container.backend import ContainerBroker
|
||||
from swift.container.backend import ContainerBroker, DATADIR
|
||||
from swift.common.container_sync_realms import ContainerSyncRealms
|
||||
from swift.common.direct_client import direct_get_object
|
||||
from swift.common.internal_client import delete_object, put_object
|
||||
@ -168,9 +167,7 @@ class ContainerSync(Daemon):
|
||||
sleep(random() * self.interval)
|
||||
while True:
|
||||
begin = time()
|
||||
all_locs = audit_location_generator(self.devices,
|
||||
container_server.DATADIR,
|
||||
'.db',
|
||||
all_locs = audit_location_generator(self.devices, DATADIR, '.db',
|
||||
mount_check=self.mount_check,
|
||||
logger=self.logger)
|
||||
for path, device, partition in all_locs:
|
||||
@ -187,8 +184,7 @@ class ContainerSync(Daemon):
|
||||
"""
|
||||
self.logger.info(_('Begin container sync "once" mode'))
|
||||
begin = time()
|
||||
all_locs = audit_location_generator(self.devices,
|
||||
container_server.DATADIR, '.db',
|
||||
all_locs = audit_location_generator(self.devices, DATADIR, '.db',
|
||||
mount_check=self.mount_check,
|
||||
logger=self.logger)
|
||||
for path, device, partition in all_locs:
|
||||
|
@ -25,8 +25,7 @@ from tempfile import mkstemp
|
||||
from eventlet import spawn, patcher, Timeout
|
||||
|
||||
import swift.common.db
|
||||
from swift.container.backend import ContainerBroker
|
||||
from swift.container.server import DATADIR
|
||||
from swift.container.backend import ContainerBroker, DATADIR
|
||||
from swift.common.bufferedhttp import http_connect
|
||||
from swift.common.exceptions import ConnectionTimeout
|
||||
from swift.common.ring import Ring
|
||||
|
@ -24,7 +24,7 @@ from mock import patch
|
||||
from contextlib import nested
|
||||
|
||||
from swift.account import reaper
|
||||
from swift.account.server import DATADIR
|
||||
from swift.account.backend import DATADIR
|
||||
from swift.common.exceptions import ClientException
|
||||
from swift.common.utils import normalize_timestamp
|
||||
|
||||
|
@ -26,9 +26,9 @@ from tempfile import mkdtemp, NamedTemporaryFile
|
||||
import mock
|
||||
import simplejson
|
||||
|
||||
from swift.container.backend import DATADIR
|
||||
from swift.common import db_replicator
|
||||
from swift.common.utils import normalize_timestamp
|
||||
from swift.container import server as container_server
|
||||
from swift.common.exceptions import DriveNotMounted
|
||||
from swift.common.swob import HTTPException
|
||||
|
||||
@ -247,7 +247,7 @@ class TestReplicator(db_replicator.Replicator):
|
||||
server_type = 'container'
|
||||
ring_file = 'container.ring.gz'
|
||||
brokerclass = FakeBroker
|
||||
datadir = container_server.DATADIR
|
||||
datadir = DATADIR
|
||||
default_port = 1000
|
||||
|
||||
|
||||
|
@ -25,8 +25,7 @@ from eventlet import spawn, Timeout, listen
|
||||
|
||||
from swift.common import utils
|
||||
from swift.container import updater as container_updater
|
||||
from swift.container import server as container_server
|
||||
from swift.container.backend import ContainerBroker
|
||||
from swift.container.backend import ContainerBroker, DATADIR
|
||||
from swift.common.ring import RingData
|
||||
from swift.common.utils import normalize_timestamp
|
||||
|
||||
@ -84,7 +83,7 @@ class TestContainerUpdater(unittest.TestCase):
|
||||
'account_suppression_time': 0
|
||||
})
|
||||
cu.run_once()
|
||||
containers_dir = os.path.join(self.sda1, container_server.DATADIR)
|
||||
containers_dir = os.path.join(self.sda1, DATADIR)
|
||||
os.mkdir(containers_dir)
|
||||
cu.run_once()
|
||||
self.assert_(os.path.exists(containers_dir))
|
||||
@ -167,7 +166,7 @@ class TestContainerUpdater(unittest.TestCase):
|
||||
'concurrency': '1',
|
||||
'node_timeout': '15',
|
||||
})
|
||||
containers_dir = os.path.join(self.sda1, container_server.DATADIR)
|
||||
containers_dir = os.path.join(self.sda1, DATADIR)
|
||||
os.mkdir(containers_dir)
|
||||
subdir = os.path.join(containers_dir, 'subdir')
|
||||
os.mkdir(subdir)
|
||||
|
Loading…
Reference in New Issue
Block a user