Documentation ¶
Index ¶
- Constants
- type Client
- func (client *Client) CallCentralRPC(msg message.Message, IP string) message.Message
- func (client *Client) CallRPC(msg message.Message, IP string) message.Message
- func (client *Client) HandleIncomingMessage(msg *message.Message, reply *message.Message) error
- func (client *Client) JoinNetwork(helper string)
- func (client *Client) PrintCentralIP()
- func (client *Client) PrintClientList()
- func (client *Client) PrintPages()
- func (client *Client) ReadRequest()
- func (client *Client) WriteRequest()
- type Page
Constants ¶
const ( WRITE_MODE = "write" READ_MODE = "read" )
Page access mode types
const ( INVALIDATE = "invalidate" READ = "read_request" READ_FORWARD = "read_forward" WRITE_FORWARD = "write_forward" WRITE = "write_request" WRITE_CONFIRMATION = "write_confirmation" EMPTY = "empty" JOIN = "join" COPY = "copy" WRITE_COPY = "write_copy" FIRST = "first" // When you're the first node requesting read access to the page, so you can directly set it's ACK = "ack" I_HAVE_COPY = "i_have_copy" NEW_SERVER = "new_server" )
Message types
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { IP string Cache map[int]Page // List of pages in its cache. pageId -> Page{Content, Access Mode} ServerIP string Clientlist []string Timestamp int // scalar clock to indicate when the request was made. If there are concurrent requests, then we need to break ties }
func (*Client) CallCentralRPC ¶
func (*Client) HandleIncomingMessage ¶
The default method called by all RPCs. This method receives different types of requests, and calls the appropriate functions.
func (*Client) JoinNetwork ¶
Function called to join the network, by contacting the central manager. This is so the central manager knows about you in its metadata. The client also obtains the clientlist from the central manager, and notifies all the other clients of its existence.
func (*Client) PrintCentralIP ¶
func (client *Client) PrintCentralIP()
func (*Client) PrintClientList ¶
func (client *Client) PrintClientList()
func (*Client) PrintPages ¶ added in v1.0.0
func (client *Client) PrintPages()
func (*Client) ReadRequest ¶
func (client *Client) ReadRequest()
A requesting node will first check it's own cache and then check with the central manager, in case it doesn't have it. It may also update the record and become it's owner, if there is no other node in the network that owns this page.
func (*Client) WriteRequest ¶
func (client *Client) WriteRequest()