def setUpClass(cls): # auto-discovery with unicast on the same host only works if all nodes are configured with the same port range transport_port_range = bind_range(range_size=cls.NUM_SERVERS) for i in range(cls.NUM_SERVERS): layer = CrateNode( crate_dir=crate_path(), version=(4, 0, 0), settings={ 'cluster.name': cls.__class__.__name__, 'node.name': cls.node_name(i), 'psql.port': 0, 'transport.tcp.port': transport_port_range, }, env={ 'JAVA_HOME': os.environ.get('JAVA_HOME', ''), 'CRATE_HEAP_SIZE': '256M' } ) layer.start() cls.HTTP_PORTS.append(layer.addresses.http.port) cls.CRATES.append(layer) dsn = cls.random_dns() num_nodes = 0 # wait until all nodes joined the cluster with connect(dsn) as conn: c = conn.cursor() while num_nodes < len(cls.CRATES): c.execute("select * from sys.nodes") num_nodes = len(c.fetchall()) time.sleep(5)
def setUp(self): self.crates = [] self.clients = [] self.node_names = [] # auto-discovery with unicast on the same host only works if all nodes are configured with the same port range transport_port_range = bind_range(range_size=self.num_servers) for i in range(self.num_servers): layer = GracefulStopCrateLayer( crate_dir=crate_path(), settings={ 'cluster.name': self.__class__.__name__, 'node.name': self.node_name(i), 'transport.tcp.port': transport_port_range, }, env={ **os.environ.copy(), 'CRATE_HEAP_SIZE': '256M' }, version=(4, 0, 0) ) layer.start() self.clients.append(Client(layer.http_url)) self.crates.append(layer) self.node_names.append(self.node_name(i)) client = self.random_client() num_nodes = 0 # wait until all nodes joined the cluster while num_nodes < len(self.crates): response = client.sql("select * from sys.nodes") num_nodes = response.get("rowcount", 0) time.sleep(.5)
def setUp(self): self.crates = [] self.clients = [] self.node_names = [] # auto-discovery with unicast on the same host only works if all nodes are configured with the same port range transport_port_range = bind_range(range_size=self.num_servers) for i in range(self.num_servers): layer = GracefulStopCrateLayer( self.node_name(i), crate_path(), host='localhost', port=bind_port(), transport_port=transport_port_range, settings={ # The disk.watermark settings can be removed once crate-python > 0.21.1 has been released "cluster.routing.allocation.disk.watermark.low": "100k", "cluster.routing.allocation.disk.watermark.high": "10k", "cluster.routing.allocation.disk.watermark.flood_stage": "1k", }, env=os.environ.copy(), cluster_name=self.__class__.__name__) layer.start() self.clients.append(Client(layer.crate_servers)) self.crates.append(layer) self.node_names.append(self.node_name(i)) client = self.random_client() num_nodes = 0 # wait until all nodes joined the cluster while num_nodes < len(self.crates): response = client.sql("select * from sys.nodes") num_nodes = response.get("rowcount", 0) time.sleep(.5)
def setUpClass(cls): # auto-discovery with unicast on the same host only works if all nodes are configured with the same port range transport_port_range = bind_range(range_size=cls.NUM_SERVERS) for i in range(cls.NUM_SERVERS): http_port = bind_port() layer = CrateLayer( cls.node_name(i), crate_path(), host='localhost', port=http_port, transport_port=transport_port_range, settings=CRATE_SETTINGS, env={'JAVA_HOME': os.environ.get('JAVA_HOME', '')}, cluster_name=cls.__class__.__name__) layer.start() cls.HTTP_PORTS.append(http_port) cls.CRATES.append(layer) dsn = cls.random_dns() num_nodes = 0 # wait until all nodes joined the cluster while num_nodes < len(cls.CRATES): with connect(dsn) as conn: c = conn.cursor() c.execute("select * from sys.nodes") num_nodes = len(c.fetchall()) time.sleep(5)