Exemplo n.º 1
0
def start_objstore(node_ip_address, redis_address, cleanup=True):
    """This method starts an object store process.

  Args:
    node_ip_address (str): The ip address of the node running the object store.
    redis_address (str): The address of the Redis instance to connect to.
    cleanup (bool): True if using Ray in local mode. If cleanup is true, then
      this process will be killed by serices.cleanup() when the Python process
      that imported services exits.

  Return:
    A tuple of the Plasma store socket name, the Plasma manager socket name, and
      the plasma manager port.
  """
    # Compute a fraction of the system memory for the Plasma store to use.
    system_memory = psutil.virtual_memory().total
    plasma_store_memory = int(system_memory * 0.75)
    # Start the Plasma store.
    plasma_store_name, p1 = plasma.start_plasma_store(
        plasma_store_memory=plasma_store_memory,
        use_profiler=RUN_PLASMA_STORE_PROFILER)
    # Start the plasma manager.
    plasma_manager_name, p2, plasma_manager_port = plasma.start_plasma_manager(
        plasma_store_name,
        redis_address,
        run_profiler=RUN_PLASMA_MANAGER_PROFILER)
    if cleanup:
        all_processes.append(p1)
        all_processes.append(p2)

    return plasma_store_name, plasma_manager_name, plasma_manager_port
Exemplo n.º 2
0
 def setUp(self):
   # Start Plasma store.
   plasma_store_name, self.p = plasma.start_plasma_store(use_valgrind=USE_VALGRIND)
   # Connect to Plasma.
   self.plasma_client = plasma.PlasmaClient(plasma_store_name, None, 64)
   # For the eviction test
   self.plasma_client2 = plasma.PlasmaClient(plasma_store_name, None, 0)
Exemplo n.º 3
0
  def setUp(self):
    # Start two PlasmaStores.
    store_name1, self.p2 = plasma.start_plasma_store(use_valgrind=USE_VALGRIND)
    store_name2, self.p3 = plasma.start_plasma_store(use_valgrind=USE_VALGRIND)
    # Start a Redis server.
    redis_address = services.start_redis("127.0.0.1")
    # Start two PlasmaManagers.
    manager_name1, self.p4, self.port1 = plasma.start_plasma_manager(store_name1, redis_address, use_valgrind=USE_VALGRIND)
    manager_name2, self.p5, self.port2 = plasma.start_plasma_manager(store_name2, redis_address, use_valgrind=USE_VALGRIND)
    # Connect two PlasmaClients.
    self.client1 = plasma.PlasmaClient(store_name1, manager_name1)
    self.client2 = plasma.PlasmaClient(store_name2, manager_name2)

    # Store the processes that will be explicitly killed during tearDown so
    # that a test case can remove ones that will be killed during the test.
    # NOTE: If this specific order is changed, valgrind will fail.
    self.processes_to_kill = [self.p4, self.p5, self.p2, self.p3]
Exemplo n.º 4
0
 def setUp(self):
     # Start Plasma store.
     plasma_store_name, self.p1 = plasma.start_plasma_store()
     self.plasma_client = plasma.PlasmaClient(plasma_store_name)
     # Start a local scheduler.
     scheduler_name, self.p2 = photon.start_local_scheduler(
         plasma_store_name, use_valgrind=USE_VALGRIND)
     # Connect to the scheduler.
     self.photon_client = photon.PhotonClient(scheduler_name)
Exemplo n.º 5
0
    def setUp(self):
        # Start one Redis server and N pairs of (plasma, photon)
        redis_path = os.path.join(
            os.path.abspath(os.path.dirname(__file__)),
            "../../core/src/common/thirdparty/redis/src/redis-server")
        redis_module = os.path.join(
            os.path.dirname(os.path.abspath(__file__)),
            "../../core/src/common/redis_module/libray_redis_module.so")
        assert os.path.isfile(redis_path)
        assert os.path.isfile(redis_module)
        node_ip_address = "127.0.0.1"
        redis_port = new_port()
        redis_address = "{}:{}".format(node_ip_address, redis_port)
        self.redis_process = subprocess.Popen([
            redis_path, "--port",
            str(redis_port), "--loglevel", "warning", "--loadmodule",
            redis_module
        ])
        time.sleep(0.1)
        # Create a Redis client.
        self.redis_client = redis.StrictRedis(host=node_ip_address,
                                              port=redis_port)
        # Start one global scheduler.
        self.p1 = global_scheduler.start_global_scheduler(
            redis_address, use_valgrind=USE_VALGRIND)
        self.plasma_store_pids = []
        self.plasma_manager_pids = []
        self.local_scheduler_pids = []
        self.plasma_clients = []
        self.photon_clients = []

        for i in range(NUM_CLUSTER_NODES):
            # Start the Plasma store. Plasma store name is randomly generated.
            plasma_store_name, p2 = plasma.start_plasma_store()
            self.plasma_store_pids.append(p2)
            # Start the Plasma manager.
            # Assumption: Plasma manager name and port are randomly generated by the plasma module.
            plasma_manager_name, p3, plasma_manager_port = plasma.start_plasma_manager(
                plasma_store_name, redis_address)
            self.plasma_manager_pids.append(p3)
            plasma_address = "{}:{}".format(node_ip_address,
                                            plasma_manager_port)
            plasma_client = plasma.PlasmaClient(plasma_store_name,
                                                plasma_manager_name)
            self.plasma_clients.append(plasma_client)
            # Start the local scheduler.
            local_scheduler_name, p4 = photon.start_local_scheduler(
                plasma_store_name,
                plasma_manager_name=plasma_manager_name,
                plasma_address=plasma_address,
                redis_address=redis_address,
                static_resource_list=[10, 0])
            # Connect to the scheduler.
            photon_client = photon.PhotonClient(local_scheduler_name,
                                                NIL_ACTOR_ID)
            self.photon_clients.append(photon_client)
            self.local_scheduler_pids.append(p4)
Exemplo n.º 6
0
 def setUp(self):
   # Start two PlasmaStores.
   store_name1, self.p2 = plasma.start_plasma_store(use_valgrind=USE_VALGRIND)
   store_name2, self.p3 = plasma.start_plasma_store(use_valgrind=USE_VALGRIND)
   # Start a Redis server.
   redis_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), "../../common/thirdparty/redis/src/redis-server")
   redis_port = 6379
   with open(os.devnull, "w") as FNULL:
     self.redis_process = subprocess.Popen([redis_path,
                                            "--port", str(redis_port)],
                                            stdout=FNULL)
   time.sleep(0.1)
   # Start two PlasmaManagers.
   redis_address = "{}:{}".format("127.0.0.1", redis_port)
   manager_name1, self.p4, self.port1 = plasma.start_plasma_manager(store_name1, redis_address, use_valgrind=USE_VALGRIND)
   manager_name2, self.p5, self.port2 = plasma.start_plasma_manager(store_name2, redis_address, use_valgrind=USE_VALGRIND)
   # Connect two PlasmaClients.
   self.client1 = plasma.PlasmaClient(store_name1, manager_name1)
   self.client2 = plasma.PlasmaClient(store_name2, manager_name2)
Exemplo n.º 7
0
def start_objstore(node_ip_address, redis_address, object_manager_port=None,
                   cleanup=True, redirect_output=False, objstore_memory=None):
  """This method starts an object store process.

  Args:
    node_ip_address (str): The IP address of the node running the object store.
    redis_address (str): The address of the Redis instance to connect to.
    object_manager_port (int): The port to use for the object manager. If this
      is not provided, one will be generated randomly.
    cleanup (bool): True if using Ray in local mode. If cleanup is true, then
      this process will be killed by serices.cleanup() when the Python process
      that imported services exits.
    redirect_output (bool): True if stdout and stderr should be redirected to
      /dev/null.

  Return:
    A tuple of the Plasma store socket name, the Plasma manager socket name, and
      the plasma manager port.
  """
  if objstore_memory is None:
    # Compute a fraction of the system memory for the Plasma store to use.
    system_memory = psutil.virtual_memory().total
    if sys.platform == "linux" or sys.platform == "linux2":
      # On linux we use /dev/shm, its size is half the size of the physical
      # memory. To not overflow it, we set the plasma memory limit to 0.4 times
      # the size of the physical memory.
      objstore_memory = int(system_memory * 0.4)
      # Compare the requested memory size to the memory available in /dev/shm.
      shm_fd = os.open("/dev/shm", os.O_RDONLY)
      try:
        shm_fs_stats = os.fstatvfs(shm_fd)
        # The value shm_fs_stats.f_bsize is the block size and the value
        # shm_fs_stats.f_bavail is the number of available blocks.
        shm_avail = shm_fs_stats.f_bsize * shm_fs_stats.f_bavail
        if objstore_memory > shm_avail:
          print("Warning: Reducing object store memory because /dev/shm has only {} bytes available. You may be able to free up space by deleting files in /dev/shm. If you are inside a Docker container, you may need to pass an argument with the flag '--shm-size' to 'docker run'.".format(shm_avail))
          objstore_memory = int(shm_avail * 0.8)
      finally:
        os.close(shm_fd)
    else:
      objstore_memory = int(system_memory * 0.8)
  # Start the Plasma store.
  plasma_store_name, p1 = plasma.start_plasma_store(plasma_store_memory=objstore_memory, use_profiler=RUN_PLASMA_STORE_PROFILER, redirect_output=redirect_output)
  # Start the plasma manager.
  if object_manager_port is not None:
    plasma_manager_name, p2, plasma_manager_port = plasma.start_plasma_manager(plasma_store_name, redis_address, plasma_manager_port=object_manager_port, node_ip_address=node_ip_address, num_retries=1, run_profiler=RUN_PLASMA_MANAGER_PROFILER, redirect_output=redirect_output)
    assert plasma_manager_port == object_manager_port
  else:
    plasma_manager_name, p2, plasma_manager_port = plasma.start_plasma_manager(plasma_store_name, redis_address, node_ip_address=node_ip_address, run_profiler=RUN_PLASMA_MANAGER_PROFILER, redirect_output=redirect_output)
  if cleanup:
    all_processes[PROCESS_TYPE_PLASMA_STORE].append(p1)
    all_processes[PROCESS_TYPE_PLASMA_MANAGER].append(p2)

  return ObjectStoreAddress(plasma_store_name, plasma_manager_name,
                            plasma_manager_port)
Exemplo n.º 8
0
  def setUp(self):
    # Start a Plasma store.
    self.store_name, self.p2 = plasma.start_plasma_store(use_valgrind=USE_VALGRIND)
    # Start a Redis server.
    self.redis_address = services.start_redis("127.0.0.1")
    # Start a PlasmaManagers.
    manager_name, self.p3, self.port1 = plasma.start_plasma_manager(
        self.store_name,
        self.redis_address,
        use_valgrind=USE_VALGRIND)
    # Connect a PlasmaClient.
    self.client = plasma.PlasmaClient(self.store_name, manager_name)

    # Store the processes that will be explicitly killed during tearDown so
    # that a test case can remove ones that will be killed during the test.
    self.processes_to_kill = [self.p2, self.p3]
Exemplo n.º 9
0
 def setUp(self):
   # Start a Redis server.
   redis_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), "../../common/thirdparty/redis/src/redis-server")
   node_ip_address = "127.0.0.1"
   redis_port = new_port()
   redis_address = "{}:{}".format(node_ip_address, redis_port)
   self.redis_process = subprocess.Popen([redis_path, "--port", str(redis_port), "--loglevel", "warning"])
   time.sleep(0.1)
   # Create a Redis client.
   self.redis_client = redis.StrictRedis(host=node_ip_address, port=redis_port)
   # Start the global scheduler.
   self.p1 = global_scheduler.start_global_scheduler(redis_address, USE_VALGRIND)
   # Start the Plasma store.
   plasma_store_name, self.p2 = plasma.start_plasma_store()
   # Start the local scheduler.
   local_scheduler_name, self.p3 = photon.start_local_scheduler(plasma_store_name, redis_address=redis_address)
   # Connect to the scheduler.
   self.photon_client = photon.PhotonClient(local_scheduler_name)