MEChat 1.2.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/Chat.rb +3 -0
  3. data/client.rb +2 -7
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3e81b866dee38480b59aa955074aae862729bb58570f5f712cddf9f197c5359f
4
- data.tar.gz: 408448930057f827d762744384b41bec7eea5046d25ec3311b9f4608b80a67fd
3
+ metadata.gz: df9c8aad3c6f17a909439a15eb05e47ee866ba66e812ef2146ad22d2b7bf1eae
4
+ data.tar.gz: ba2fc4b2a0bc150e711ed8adc3781a89babc2a59b913a60a63f5c72990303211
5
5
  SHA512:
6
- metadata.gz: c3f4f4f96a05311799f72b2ba0a81b2482bcd5495c2f5c1aeb3d9c8bc53d236bcb4377c2bf6757f84c387f9c4097cba4e0fce543a7d57fed5b71bc6602757454
7
- data.tar.gz: bef9f54ec1492c3eb3a6543bfb7da6e4403b3709a79d56410c47584e987594b60ea993030d31dc68823d5d6d65dc1c1a9ecf7053fbbd2dca6f7a7eb420a32527
6
+ metadata.gz: fb245e1baa6c763ef1aa4f5516d1ce41addc39a4ca2edc636cef7a165b6643fa0c54d0de814d1ce61d481dda019baeecf857d1c1cc7358dfec3fdac58e41fc4c
7
+ data.tar.gz: 486bc3b6b00de1f9646cb770d162d67f6b5517b12f73d9dd8c59b3b8700c399f26345ce624c4d79607dff701a8cac70cf69f6f9ab8363dee18dbb7b23ef476b1
data/Chat.rb CHANGED
@@ -36,10 +36,13 @@ class Chat < DistributedChat::ChatService::Service
36
36
  def request_critical_section(req,_call)
37
37
  request = {:ip => Addrinfo.getaddrinfo(req.username.split(":")[0..-2].join(":"),req.username.split(":")[-1].to_i)[0], :message => req}
38
38
  if $crit_section === 0
39
+ @logger.info "Sent reply to #{request[:ip].ip_address}:#{request[:ip].ip_port}, because I am not in critical section"
39
40
  send_reply ip: request[:ip]
40
41
  elsif $crit_section < 2 && request[:message].timestamp < $alg.clock
42
+ @logger.info "Sent reply to #{request[:ip].ip_address}:#{request[:ip].ip_port}, because I am entering critical section but my request is newer"
41
43
  send_reply ip: request[:ip]
42
44
  else
45
+ @logger.info "Delayed reply to #{request[:ip].ip_address}:#{request[:ip].ip_port}, because I am in critical section"
43
46
  $alg.requests << request
44
47
  end
45
48
  DistributedChat::Response.new status_code: 0
data/client.rb CHANGED
@@ -31,7 +31,7 @@ class Client
31
31
  $nodes.each do |node|
32
32
  begin
33
33
  chat = DistributedChat::ChatService::Stub.new("#{node.address}:#{node.port}", :this_channel_is_insecure)
34
- @logger.info "Sent request to #{node.address}:#{node.port}"
34
+ @logger.info "Sent request with timestamp #{$alg.clock} to #{node.address}:#{node.port}"
35
35
  chat.request_critical_section(DistributedChat::Request.new(
36
36
  username: "#{@ip.ip_address}:#{$port.to_s}",
37
37
  message: "Request",
@@ -70,14 +70,9 @@ class Client
70
70
  while new_msg != "exit"
71
71
  $crit_section = 1
72
72
  request_critical_section
73
- sleepdur = 0
74
73
  while $alg.replies.length < $nodes.length
75
- sleepdur += 0.1
76
- @logger.info "#{@ip.ip_address}:#{$port.to_s} waiting for replies"
77
74
  sleep 0.1
78
- if sleepdur % 5 == 0
79
- puts "Waiting for replies. #{$alg.replies.length}/#{$nodes.length} replies received"
80
- end
75
+ @logger.info "#{@ip.ip_address}:#{$port.to_s} #{$alg.replies.length}/#{$nodes.length} waiting for replies"
81
76
  end
82
77
  $crit_section = 2
83
78
  $nodes.each do |node|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: MEChat
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lukas Kaufmann