def prepare(self, params=None): try: # mandatory if not passed by method self._cluster_name = params[0] # mandatory if not passed by method self.set_cluster_type(params[1]) self._cluster_location = params[2] self._datasegment_name = params[3] except (IndexError, TypeError): # Use default for non existent indexes pass except ValueError: raise PyOrientBadMethodCallException( params[1] + ' is not a valid data cluster type', []) if self.get_protocol() < 24: self._append((FIELD_STRING, self._cluster_type)) self._append((FIELD_STRING, self._cluster_name)) self._append((FIELD_STRING, self._cluster_location)) self._append((FIELD_STRING, self._datasegment_name)) else: self._append((FIELD_STRING, self._cluster_name)) if self.get_protocol() >= 18: self._append((FIELD_SHORT, self._new_cluster_id)) return super(DataClusterAddMessage, self).prepare()
def prepare(self, params=None): if isinstance(params, tuple) or isinstance(params, list): try: # mandatory if not passed by method # raise Exception if None if isinstance(params[0], tuple) or isinstance(params[0], list): self._cluster_ids = params[0] else: raise PyOrientBadMethodCallException( "Cluster IDs param must be an instance of Tuple or List.", []) self._count_tombstones = params[1] except (IndexError, TypeError): # Use default for non existent indexes pass self._append((FIELD_SHORT, len(self._cluster_ids))) for x in self._cluster_ids: self._append((FIELD_SHORT, x)) self._append((FIELD_BOOLEAN, self._count_tombstones)) return super(DataClusterCountMessage, self).prepare()
def set_storage_type(self, storage_type): if storage_type in STORAGE_TYPES: # user choice storage if present self._storage_type = storage_type else: raise PyOrientBadMethodCallException( storage_type + ' is not a valid storage type', []) return self
def set_db_type(self, db_type): if db_type in DB_TYPES: # user choice storage if present self._db_type = db_type else: raise PyOrientBadMethodCallException( db_type + ' is not a valid database type', []) return self
def set_cluster_type(self, _cluster_type): if _cluster_type in CLUSTER_TYPES: # user choice storage if present self._cluster_type = _cluster_type else: raise PyOrientBadMethodCallException( _cluster_type + ' is not a valid cluster type', []) return self
def set_serialization_type(self, serialization_type): #TODO Implement version 22 of the protocol if serialization_type == SERIALIZATION_SERIAL_BIN: raise NotImplementedError if serialization_type in SERIALIZATION_TYPES: # user choice storage if present self._serialization_type = serialization_type else: raise PyOrientBadMethodCallException( serialization_type + ' is not a valid serialization type', []) return self