Пример #1
0
    def __init__(self, path, name, partitioner=None, cassandra_dir=None, create_directory=True, cassandra_version=None, verbose=False):
        self.name = name
        self.nodes = {}
        self.seeds = []
        self.partitioner = partitioner
        self._config_options = {}
        self.__log_level = "INFO"
        self.__path = path
        self.__version = None
        if create_directory:
            # we create the dir before potentially downloading to throw an error sooner if need be
            os.mkdir(self.get_path())

        try:
            if cassandra_version is None:
                # at this point, cassandra_dir should always not be None, but
                # we keep this for backward compatibility (in loading old cluster)
                if cassandra_dir is not None:
                    self.__cassandra_dir = os.path.abspath(cassandra_dir)
                    self.__version = self.__get_version_from_build()
            else:
                dir, v = repository.setup(cassandra_version, verbose)
                self.__cassandra_dir = dir
                self.__version = v if v is not None else self.__get_version_from_build()

            if create_directory:
                common.validate_cassandra_dir(self.__cassandra_dir)
                self.__update_config()
        except:
            if create_directory:
                shutil.rmtree(self.get_path())
            raise
Пример #2
0
    def __init__(self, path, name, partitioner=None, cassandra_dir=None, create_directory=True, cassandra_version=None, verbose=False):
        self.name = name
        self.nodes = {}
        self.seeds = []
        self.partitioner = partitioner
        self._config_options = {}
        self.__log_level = "INFO"
        self.__path = path
        self.__version = None
        if create_directory:
            # we create the dir before potentially downloading to throw an error sooner if need be
            os.mkdir(self.get_path())

        try:
            if cassandra_version is None:
                # at this point, cassandra_dir should always not be None, but
                # we keep this for backward compatibility (in loading old cluster)
                if cassandra_dir is not None:
                    self.__cassandra_dir = os.path.abspath(cassandra_dir)
                    self.__version = self.__get_version_from_build()
            else:
                dir, v = repository.setup(cassandra_version, verbose)
                self.__cassandra_dir = dir
                self.__version = v if v is not None else self.__get_version_from_build()

            if create_directory:
                common.validate_cassandra_dir(self.__cassandra_dir)
                self.__update_config()
        except:
            if create_directory:
                shutil.rmtree(self.get_path())
            raise
Пример #3
0
 def get_cassandra_dir(self):
     """
     Returns the path to the cassandra source directory used by this node.
     """
     if self.__cassandra_dir is None:
         return self.cluster.get_cassandra_dir()
     else:
         common.validate_cassandra_dir(self.__cassandra_dir)
         return self.__cassandra_dir
Пример #4
0
 def get_cassandra_dir(self):
     """
     Returns the path to the cassandra source directory used by this node.
     """
     if self.__cassandra_dir is None:
         return self.cluster.get_cassandra_dir()
     else:
         common.validate_cassandra_dir(self.__cassandra_dir)
         return self.__cassandra_dir
Пример #5
0
def version_directory(version):
    version = version.replace(':', '_') # handle git branches like 'git:trunk'.
    dir = os.path.join(__get_dir(), version)
    if os.path.exists(dir):
        try:
            common.validate_cassandra_dir(dir)
            return dir
        except common.ArgumentError as e:
            shutil.rmtree(dir)
            return None
    else:
        return None
Пример #6
0
 def set_cassandra_dir(self, cassandra_dir=None, cassandra_version=None, verbose=False):
     """
     Sets the path to the cassandra source directory for use by this node.
     """
     if cassandra_version is None:
         self.__cassandra_dir = cassandra_dir
         if cassandra_dir is not None:
             common.validate_cassandra_dir(cassandra_dir)
     else:
         dir, v = repository.setup(cassandra_version, verbose=verbose)
         self.__cassandra_dir = dir
     self.import_config_files()
     return self
Пример #7
0
 def set_cassandra_dir(self, cassandra_dir=None, cassandra_version=None, verbose=False):
     if cassandra_version is None:
         self.__cassandra_dir = cassandra_dir
         common.validate_cassandra_dir(cassandra_dir)
         self.__version = self.__get_version_from_build()
     else:
         dir, v = repository.setup(cassandra_version, verbose)
         self.__cassandra_dir = dir
         self.__version = v if v is not None else self.__get_version_from_build()
     self.__update_config()
     for node in self.nodes.values():
         node.import_config_files()
     return self
Пример #8
0
def version_directory(version):
    version = version.replace(':',
                              '_')  # handle git branches like 'git:trunk'.
    dir = os.path.join(__get_dir(), version)
    if os.path.exists(dir):
        try:
            common.validate_cassandra_dir(dir)
            return dir
        except common.ArgumentError as e:
            shutil.rmtree(dir)
            return None
    else:
        return None
Пример #9
0
 def set_cassandra_dir(self, cassandra_dir=None, cassandra_version=None, verbose=False):
     """
     Sets the path to the cassandra source directory for use by this node.
     """
     if cassandra_version is None:
         self.__cassandra_dir = cassandra_dir
         if cassandra_dir is not None:
             common.validate_cassandra_dir(cassandra_dir)
     else:
         dir, v = repository.setup(cassandra_version, verbose=verbose)
         self.__cassandra_dir = dir
     self.import_config_files()
     return self
Пример #10
0
 def set_cassandra_dir(self, cassandra_dir=None, cassandra_version=None, verbose=False):
     if cassandra_version is None:
         self.__cassandra_dir = cassandra_dir
         common.validate_cassandra_dir(cassandra_dir)
         self.__version = self.__get_version_from_build()
     else:
         dir, v = repository.setup(cassandra_version, verbose)
         self.__cassandra_dir = dir
         self.__version = v if v is not None else self.__get_version_from_build()
     self.__update_config()
     for node in self.nodes.values():
         node.import_config_files()
     return self
Пример #11
0
 def get_cassandra_dir(self):
     common.validate_cassandra_dir(self.__cassandra_dir)
     return self.__cassandra_dir
Пример #12
0
 def get_cassandra_dir(self):
     common.validate_cassandra_dir(self.__cassandra_dir)
     return self.__cassandra_dir