User Tools

Site Tools


cs330_f2016:labz

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
cs330_f2016:labz [2017/03/23 00:30]
dhart
cs330_f2016:labz [2021/06/30 23:42] (current)
Line 1: Line 1:
-**Note: Specs incomplete, proceed at own risk.** 
- 
 ====Objective:​==== ====Objective:​====
  
 To gain more significant experience in programming elixir, by implementing a server and constructing a supervisor tree. To gain more significant experience in programming elixir, by implementing a server and constructing a supervisor tree.
  
----- +===Pre-requisites:​===
-====Pre-requisites:​====+
  
 For this lab, you will need the [[http://​liftothers.org/​dokuwiki/​doku.php?​id=cs330_f2016:​lab13scaffold|scaffolding code]]. For this lab, you will need the [[http://​liftothers.org/​dokuwiki/​doku.php?​id=cs330_f2016:​lab13scaffold|scaffolding code]].
  
-The provided modules create a mock data center with inter module dependencies. ​+The provided modules create a mock data center with inter module dependencies. ​**You do not need to modify this code**
  
 ---- ----
Line 22: Line 19:
 ====Part 1: Name Server:==== ====Part 1: Name Server:====
  
-In class, we learned that we could put processes on a global process registration system ​with using Process.register(...). However, we want to implement this behavior on a local scale, so only processes that depend on each other need to know about each other. This is done by implementing a local name server.+In class, we learned that we could put processes on a global process registration system using Process.register(...). However, we want to implement this behavior on a local scale, so only processes that depend on each other know about each other. This is done by implementing a local name server.
  
 You will construct a module named NameServer. The purpose of this module is to register names, in the form of atoms, to Pid's. Note that this must be done using your own data structure, such as a map, not the global process registration. You will construct a module named NameServer. The purpose of this module is to register names, in the form of atoms, to Pid's. Note that this must be done using your own data structure, such as a map, not the global process registration.
Line 37: Line 34:
 </​code>​ </​code>​
  
-The name Server ​should return :ok to all other synchronous calls, and discard all other asynchronous calls. You can assume name and Pid are valid.+These simple calls allow modules to register themselves with the local name server so that they can easily talk to each other. ​The name server ​should return :ok to all other synchronous calls, and discard all other asynchronous calls. You can assume name and Pid are valid.
  
-We have been have provided a skeleton ​+We have provided a skeleton ​of some GenServer code [[http://​liftothers.org/​dokuwiki/​doku.php?​id=cs330_f2016:​lab13genserver|here]].
  
- +===Hints:​===
-Any time a pid goes down you will need to remove it from the name server, this is best done by placing a monitor on the pid before you put it into your data structure. +
- +
-====Hints:====+
  
 We strongly encourage that your server implements Elixir'​s GenServer behavior. More info is found here. [[https://​hexdocs.pm/​elixir/​GenServer.html| GenServer]] We strongly encourage that your server implements Elixir'​s GenServer behavior. More info is found here. [[https://​hexdocs.pm/​elixir/​GenServer.html| GenServer]]
Line 54: Line 48:
 Example: Example:
 <code elixir> <code elixir>
-def handle_call({:​register,​ name}, pid, mymap) do+def handle_call({:​register,​ name}, ​{pid, _from}, mymap) do
   ...   ...
   {:reply, :ok, mymap}   {:reply, :ok, mymap}
 end end
-</​code ​elixir> +</​code>​
- +
-Monitors are in the Process module, documentation is found [[https://​hexdocs.pm/​elixir/​Process.html#​monitor/​1|here]]. When a process is monitoring another, and the monitored process goes down the monitoring process will receive a message of the form ''​{:​DOWN,​ monitorRef, Type, Object, Info}''​ where monitorRef is the same object returned from the ''​Process.monitor(pid)''​ call. In a GenServer this tuple is given to the handle_info callback. +
  
 ---- ----
-===Part 2: Supervisor tree===+====Part 2: Supervisor tree:====
  
 You've been asked to construct the supervisor tree for a series of connected modules in a virtual "data center"​. Information for the modules and dependencies can be found below. Each module will be registered in the name server that you coded above. Each process will be started by a node in a supervisor tree. You've been asked to construct the supervisor tree for a series of connected modules in a virtual "data center"​. Information for the modules and dependencies can be found below. Each module will be registered in the name server that you coded above. Each process will be started by a node in a supervisor tree.
Line 109: Line 100:
 </​code>​ </​code>​
  
-From there, if you have implemented your code properly, you should be able to crash any module without the system going down. The module and its dependencies should just restart and continue working. You can crash a specific module using the included ''​Crasher''​ module. For example,+From there, if you have implemented your supervisor ​properly, you should be able to crash any module without the system going down. The module and its dependencies should just restart and continue working. You can crash a specific module using the included ''​Crasher''​ module. For example,
  
 <code elixir> <code elixir>
Line 123: Line 114:
  
 ---- ----
-====Hints:====+===Hints:​===
  
 Don't create your own supervisor, use the built in ''​Supervisor''​ behavior. You will also need to create sub supervisors started by upper level ones. Don't create your own supervisor, use the built in ''​Supervisor''​ behavior. You will also need to create sub supervisors started by upper level ones.
Line 133: Line 124:
 Helpful links:\\ Helpful links:\\
 https://​hexdocs.pm/​elixir/​Supervisor.html \\ https://​hexdocs.pm/​elixir/​Supervisor.html \\
 +
 +----
 +====Submitting Your Lab====
 +For submitting this lab, please put all of your code into a single file called "​Elixir2.ex"​. This should include all of the code from the provided modules, all of the code for you name server, and all of your code for your supervisor modules. ​
  
cs330_f2016/labz.1490229056.txt.gz · Last modified: 2021/06/30 23:40 (external edit)