def add_request(self, request): global completion_time # Todo: Make it for both read and write. Currently all request read type if request["id"] in request_to_server_map: servers = self.allocation_policy.get_server(request["type"], request_to_server_map[request["id"]]) # print servers else: servers = self.allocation_policy.get_server(request["type"]) request_to_server_map[request["id"]] = servers for i in servers: request["request_size"] = self.dist.next() # print "fifo size: " + str(request["id"]) + " " + str(request["request_size"]) self.server_queues[i].put(request) if completion_time[i] > simulator.time: completion_time[i] = completion_time[i] + request["request_size"] else: completion_time[i] = simulator.time + request["request_size"] event = { "time": completion_time[i], "request": request, "callback": callback, "handler": self, "index": i, "type" : "completion" } simulator.schedule(event)
def add_request(self, request): self.q.put(request) self.completion_time = self.completion_time + request["request_size"] event = { "time": self.completion_time + request["request_size"], "request": request, "callback": callback } simulator.schedule(event)
def add_arrival_event(self): request = self.request.next_request() request["start_time"] = self.arrival.next_arrival() event = { "request": self.request.next_request(), "time": request["start_time"], "callback": callback } simulator.schedule(event) return
def callback(event): global event_map with open("properties.json") as fp: config = json.load(fp) # I assumed Type1 is read request if event["request"]["type"] == "read": no_of_request_required = config["server"]["noOfReadResponse"] total_request = config["server"]["readServer"] else: no_of_request_required = config["server"]["noOfWriteResponse"] total_request = config["server"]["writeServer"] # Processing of request and deleting once we reached max if event["request"]["id"] in event_map: event_map[event["request"] ["id"]] = event_map[event["request"]["id"]] + 1 else: event_map[event["request"]["id"]] = 1 if event_map[event["request"]["id"]] == no_of_request_required: #print "reached here" event["handler"].stat.collect_stats(event) new_event = { "time": simulator.time, "callback": removal, "request": event["request"], "handler": event["handler"], "index": event["index"] } simulator.schedule(new_event) elif event_map[event["request"]["id"]] == total_request: del event_map[event["request"]["id"]] return
def add_request(self, request): servers = self.allocation_policy.get_server(request["type"]) for i in servers: self.server_queues[i].put(request) request["request_size"] = self.dist.next() print "priority size: " + request["id"] + " " + str( request["request_size"]) if self.completion_time[i] > simulator.time: self.completion_time[ i] = self.completion_time[i] + request["request_size"] else: self.completion_time[ i] = simulator.time + request["request_size"] event = { "time": self.completion_time[i], "request": request, "callback": callback, "handler": self, "index": i } simulator.schedule(event)