public void Setup()
 {
     ownerEndpoint = new OwnerEndpoint
                     {
                         MulticastUri = new Uri("tcp://127.0.0.1"),
                         UnicastUri = new Uri("tcp://127.0.0.1")
                     };
 }
예제 #2
0
        private Lease AсquireOrLearnLease(Ballot ballot, DateTime now)
        {
            var read = register.Read(ballot);
            if (read.TxOutcome == TxOutcome.Commit)
            {
                var lease = read.Lease;
                if (LeaseIsNotSafelyExpired(lease, now))
                {
                    LogStartSleep();
                    Sleep(config.ClockDrift);
                    LogAwake();

                    // TODO: Add recursion exit condition
                    return AсquireOrLearnLease(ballotGenerator.New(localNode.SocketIdentity), DateTime.UtcNow);
                }

                if (LeaseNullOrExpired(lease, now) || IsLeaseOwner(lease))
                {
                    LogLeaseProlonged(lease);
                    var ownerEndpoint = new OwnerEndpoint {UnicastUri = rendezvousConfig.UnicastUri, MulticastUri = rendezvousConfig.MulticastUri};
                    lease = new Lease(localNode.SocketIdentity, ownerEndpoint, now + config.MaxLeaseTimeSpan);
                }

                var write = register.Write(ballot, lease);
                if (write.TxOutcome == TxOutcome.Commit)
                {
                    return lease;
                }
            }

            return null;
        }
예제 #3
0
파일: Lease.cs 프로젝트: gitter-badger/kino
 public Lease(byte[] ownerIdentity, OwnerEndpoint ownerEndpoint, DateTime expiresAt)
 {
     OwnerIdentity = ownerIdentity;
     OwnerEndpoint = ownerEndpoint;
     ExpiresAt = expiresAt;
 }
예제 #4
0
파일: Lease.cs 프로젝트: gitter-badger/kino
 public Lease(byte[] ownerIdentity, OwnerEndpoint ownerEndpoint, long expiresAt)
     : this(ownerIdentity, ownerEndpoint, new DateTime(expiresAt, DateTimeKind.Utc))
 {
 }