Removed redundant metaclass declarations in MapR plugin

Change-Id: Ifad8f7521be49c5564f43e6df78f2d49fb753ba0
Implements: blueprint mapr-refactor-singleton
This commit is contained in:
Artem Osadchyi 2015-09-30 17:25:22 +03:00
parent 5240195f4b
commit ca5294a801
20 changed files with 14 additions and 73 deletions

View File

@ -14,11 +14,13 @@
from oslo_serialization import jsonutils as json
import six
from sahara import context
import sahara.exceptions as e
from sahara.i18n import _
import sahara.plugins.exceptions as ex
from sahara.plugins.mapr.util import general as g
from sahara.plugins.mapr.util import service_utils as su
import sahara.plugins.provisioning as p
from sahara.utils import files as files
@ -26,6 +28,7 @@ from sahara.utils import files as files
_INSTALL_PACKAGES_TIMEOUT = 3600
@six.add_metaclass(g.Singleton)
class Service(object):
def __init__(self):
self._name = None
@ -219,12 +222,3 @@ class Service(object):
def post_configure_sh(self, cluster_context, instances):
pass
class Single(type):
_instances = {}
def __call__(cls, *args, **kwargs):
if cls not in cls._instances:
cls._instances[cls] = super(Single, cls).__call__(*args, **kwargs)
return cls._instances[cls]

View File

@ -13,8 +13,6 @@
# under the License.
import six
import sahara.plugins.mapr.domain.node_process as np
import sahara.plugins.mapr.domain.service as s
import sahara.plugins.mapr.util.commands as cmd
@ -29,7 +27,6 @@ DRILL = np.NodeProcess(
)
@six.add_metaclass(s.Single)
class Drill(s.Service):
def __init__(self):
super(Drill, self).__init__()
@ -51,28 +48,24 @@ class Drill(s.Service):
cmd.re_configure_sh(instance, cluster_context)
@six.add_metaclass(s.Single)
class DrillV07(Drill):
def __init__(self):
super(DrillV07, self).__init__()
self._version = '0.7'
@six.add_metaclass(s.Single)
class DrillV08(Drill):
def __init__(self):
super(DrillV08, self).__init__()
self._version = '0.8'
@six.add_metaclass(s.Single)
class DrillV09(Drill):
def __init__(self):
super(DrillV09, self).__init__()
self._version = '0.9'
@six.add_metaclass(s.Single)
class DrillV11(Drill):
def __init__(self):
super(DrillV11, self).__init__()

View File

@ -13,8 +13,6 @@
# under the License.
import six
import sahara.plugins.mapr.domain.node_process as np
import sahara.plugins.mapr.domain.service as s
import sahara.plugins.mapr.util.validation_utils as vu
@ -28,7 +26,6 @@ FLUME = np.NodeProcess(
)
@six.add_metaclass(s.Single)
class Flume(s.Service):
def __init__(self):
super(Flume, self).__init__()

View File

@ -13,8 +13,6 @@
# under the License.
import six
import sahara.plugins.mapr.domain.configuration_file as bcf
import sahara.plugins.mapr.domain.node_process as np
import sahara.plugins.mapr.domain.service as s
@ -75,7 +73,6 @@ class HBase(s.Service):
return [hbase_site]
@six.add_metaclass(s.Single)
class HBaseV094(HBase):
def __init__(self):
super(HBaseV094, self).__init__()
@ -83,7 +80,6 @@ class HBaseV094(HBase):
self._dependencies = [('mapr-hbase', self.version)]
@six.add_metaclass(s.Single)
class HBaseV0987(HBase):
def __init__(self):
super(HBaseV0987, self).__init__()
@ -91,7 +87,6 @@ class HBaseV0987(HBase):
self._dependencies = [('mapr-hbase', self.version)]
@six.add_metaclass(s.Single)
class HBaseV0989(HBase):
def __init__(self):
super(HBaseV0989, self).__init__()
@ -103,7 +98,6 @@ class HBaseV0989(HBase):
)
@six.add_metaclass(s.Single)
class HBaseV09812(HBase):
def __init__(self):
super(HBaseV09812, self).__init__()

View File

@ -14,7 +14,6 @@
from oslo_log import log as logging
import six
import sahara.plugins.mapr.domain.configuration_file as bcf
import sahara.plugins.mapr.domain.node_process as np
@ -121,7 +120,6 @@ class Hive(s.Service):
return self.SCHEMA_PATH_TEMPLATE % args
@six.add_metaclass(s.Single)
class HiveV013(Hive):
def __init__(self):
super(HiveV013, self).__init__()
@ -129,7 +127,6 @@ class HiveV013(Hive):
self._dependencies = [('mapr-hive', self.version)]
@six.add_metaclass(s.Single)
class HiveV10(Hive):
def __init__(self):
super(HiveV10, self).__init__()

View File

@ -13,8 +13,6 @@
# under the License.
import six
import sahara.plugins.mapr.domain.node_process as np
import sahara.plugins.mapr.domain.service as s
import sahara.plugins.mapr.util.commands as cmd
@ -29,7 +27,6 @@ HTTP_FS = np.NodeProcess(
)
@six.add_metaclass(s.Single)
class HttpFS(s.Service):
def __init__(self):
super(HttpFS, self).__init__()

View File

@ -18,7 +18,6 @@ import random
import string
from oslo_log import log as logging
import six
import sahara.plugins.mapr.domain.configuration_file as bcf
import sahara.plugins.mapr.domain.node_process as np
@ -53,7 +52,6 @@ HUE_LIVY = np.NodeProcess(
)
@six.add_metaclass(s.Single)
class Hue(s.Service):
def __init__(self):
super(Hue, self).__init__()
@ -208,21 +206,18 @@ class Hue(s.Service):
return ''.join(generator.choice(ascii_alphanum) for _ in range(length))
@six.add_metaclass(s.Single)
class HueV360(Hue):
def __init__(self):
super(HueV360, self).__init__()
self._version = '3.6.0'
@six.add_metaclass(s.Single)
class HueV370(Hue):
def __init__(self):
super(HueV370, self).__init__()
self._version = '3.7.0'
@six.add_metaclass(s.Single)
class HueV381(Hue):
def __init__(self):
super(HueV381, self).__init__()

View File

@ -13,8 +13,6 @@
# under the License.
import six
import sahara.plugins.mapr.domain.configuration_file as bcf
import sahara.plugins.mapr.domain.node_process as np
import sahara.plugins.mapr.domain.service as s
@ -76,7 +74,6 @@ class Impala(s.Service):
cmd.chown(instance, 'mapr:mapr', self.service_dir(cluster_context))
@six.add_metaclass(s.Single)
class ImpalaV141(Impala):
def __init__(self):
super(ImpalaV141, self).__init__()

View File

@ -13,8 +13,6 @@
# under the License.
import six
import sahara.plugins.mapr.domain.node_process as np
import sahara.plugins.mapr.domain.service as s
import sahara.plugins.mapr.util.validation_utils as vu
@ -27,7 +25,6 @@ MAHOUT = np.NodeProcess(
)
@six.add_metaclass(s.Single)
class Mahout(s.Service):
def __init__(self):
super(Mahout, self).__init__()
@ -37,14 +34,12 @@ class Mahout(s.Service):
self._validation_rules = [vu.at_least(1, MAHOUT)]
@six.add_metaclass(s.Single)
class MahoutV09(Mahout):
def __init__(self):
super(MahoutV09, self).__init__()
self._version = '0.9'
@six.add_metaclass(s.Single)
class MahoutV010(Mahout):
def __init__(self):
super(MahoutV010, self).__init__()

View File

@ -13,8 +13,6 @@
# under the License.
import six
import sahara.plugins.mapr.domain.node_process as np
import sahara.plugins.mapr.domain.service as s
import sahara.plugins.mapr.util.validation_utils as vu
@ -44,7 +42,6 @@ METRICS = np.NodeProcess(
)
@six.add_metaclass(s.Single)
class Management(s.Service):
def __init__(self):
super(Management, self).__init__()

View File

@ -12,8 +12,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import six
import sahara.plugins.mapr.domain.configuration_file as bcf
import sahara.plugins.mapr.domain.node_process as np
import sahara.plugins.mapr.domain.service as s
@ -42,7 +40,6 @@ JACKSON_MAPPER_ASL = ('plugins/mapr/services/swift/resources/'
'jackson-mapper-asl-1.9.13.jar')
@six.add_metaclass(s.Single)
class MapReduce(s.Service):
cluster_mode = 'classic'

View File

@ -14,7 +14,6 @@
from oslo_log import log as logging
import six
from sahara import context
from sahara.i18n import _
@ -50,7 +49,6 @@ NFS = np.NodeProcess(
)
@six.add_metaclass(s.Single)
class MapRFS(s.Service):
_CREATE_DISK_LIST = 'plugins/mapr/resources/create_disk_list_file.sh'
_DISK_SETUP_CMD = '/opt/mapr/server/disksetup -F /tmp/disk.list'

View File

@ -30,7 +30,6 @@ LOG = logging.getLogger(__name__)
db_spec = c.namedtuple('DatabaseSpec', ['db_name', 'user', 'password'])
@six.add_metaclass(s.Single)
class MySQL(s.Service):
METRICS_SPECS = db_spec('metrics', 'maprmetrics', 'mapr')
HUE_SPECS = db_spec('hue', 'maprhue', 'mapr')

View File

@ -14,7 +14,6 @@
from oslo_log import log as logging
import six
import sahara.plugins.mapr.domain.configuration_file as bcf
import sahara.plugins.mapr.domain.node_process as np
@ -34,7 +33,6 @@ OOZIE = np.NodeProcess(
)
@six.add_metaclass(s.Single)
class Oozie(s.Service):
def __init__(self):
super(Oozie, self).__init__()
@ -116,7 +114,6 @@ class Oozie(s.Service):
OOZIE.start(instances)
@six.add_metaclass(s.Single)
class OozieV401(Oozie):
def __init__(self):
super(OozieV401, self).__init__()
@ -124,7 +121,6 @@ class OozieV401(Oozie):
self._dependencies = [('mapr-oozie-internal', self.version)]
@six.add_metaclass(s.Single)
class OozieV410(Oozie):
def __init__(self):
super(OozieV410, self).__init__()

View File

@ -13,8 +13,6 @@
# under the License.
import six
import sahara.plugins.mapr.domain.node_process as np
import sahara.plugins.mapr.domain.service as s
import sahara.plugins.mapr.util.validation_utils as vu
@ -27,7 +25,6 @@ PIG = np.NodeProcess(
)
@six.add_metaclass(s.Single)
class Pig(s.Service):
def __init__(self):
super(Pig, self).__init__()
@ -37,14 +34,12 @@ class Pig(s.Service):
self._validation_rules = [vu.at_least(1, PIG)]
@six.add_metaclass(s.Single)
class PigV013(Pig):
def __init__(self):
super(PigV013, self).__init__()
self._version = '0.13'
@six.add_metaclass(s.Single)
class PigV014(Pig):
def __init__(self):
super(PigV014, self).__init__()

View File

@ -74,7 +74,6 @@ SPARK_SLAVE = SparkWorker(
)
@six.add_metaclass(s.Single)
class Spark(s.Service):
def __init__(self):
super(Spark, self).__init__()

View File

@ -13,8 +13,6 @@
# under the License.
import six
import sahara.plugins.mapr.domain.node_process as np
import sahara.plugins.mapr.domain.service as s
import sahara.plugins.mapr.util.commands as cmd
@ -34,7 +32,6 @@ SQOOP_2_CLIENT = np.NodeProcess(
)
@six.add_metaclass(s.Single)
class Sqoop2(s.Service):
def __init__(self):
super(Sqoop2, self).__init__()

View File

@ -14,7 +14,6 @@
from oslo_log import log as logging
import six
import sahara.plugins.mapr.domain.service as s
import sahara.plugins.mapr.services.maprfs.maprfs as maprfs
@ -23,7 +22,6 @@ import sahara.utils.files as f
LOG = logging.getLogger(__name__)
@six.add_metaclass(s.Single)
class Swift(s.Service):
HADOOP_SWIFT_JAR = ('plugins/mapr/services/swift/'
'resources/hadoop-swift-latest.jar')

View File

@ -13,8 +13,6 @@
# under the License.
import six
import sahara.plugins.mapr.domain.configuration_file as bcf
import sahara.plugins.mapr.domain.node_process as np
import sahara.plugins.mapr.domain.service as s
@ -111,7 +109,6 @@ class YARN(s.Service):
return template % file_name
@six.add_metaclass(s.Single)
class YARNv241(YARN):
def __init__(self):
super(YARNv241, self).__init__()
@ -123,7 +120,6 @@ class YARNv241(YARN):
]
@six.add_metaclass(s.Single)
class YARNv251(YARN):
def __init__(self):
super(YARNv251, self).__init__()
@ -135,7 +131,6 @@ class YARNv251(YARN):
]
@six.add_metaclass(s.Single)
class YARNv270(YARN):
def __init__(self):
super(YARNv270, self).__init__()

View File

@ -190,3 +190,14 @@ def download(remote, url, output=None, run_as=None):
args = {'url': url, 'output': '-O %s' % output if output else ''}
command = _run_as(run_as, 'wget -q %(output)s %(url)s' % args)
remote.execute_command(command, timeout=600)
class Singleton(type):
instances = {}
def __call__(cls, *args, **kwargs):
if cls not in cls.instances:
new_instance = super(Singleton, cls).__call__(*args, **kwargs)
cls.instances[cls] = new_instance
return cls.instances[cls]