public LeaseAcquireResponse TryAcquireConsumerLease(Tpg tpg, String sessionId)
 {
     Dictionary<string, string> httppParams = new Dictionary<string, string>();
     httppParams.Add(SESSION_ID, sessionId);
     httppParams.Add(HOST, Local.IPV4);
     String response = Post("/lease/consumer/acquire", httppParams, tpg);
     if (response != null)
     {
         LeaseAcquireResponse res = null;
         try
         {
             res = JSON.DeserializeObject<LeaseAcquireResponse>(response);
         }
         catch (Exception e)
         {
             Console.WriteLine(response);
             Console.WriteLine(e);
         }
         return res;
     }
     else
     {
         return null;
     }
 }
 public LeaseAcquireResponse TryRenewConsumerLease(Tpg tpg, ILease lease, String sessionId)
 {
     Dictionary<string, string> p = new Dictionary<string, string>();
     p.Add(LEASE_ID, Convert.ToString(lease.ID));
     p.Add(SESSION_ID, sessionId);
     p.Add(HOST, Local.IPV4);
     String response = Post("/lease/consumer/renew", p, tpg);
     if (response != null)
     {
         return JSON.DeserializeObject<LeaseAcquireResponse>(response);
     }
     else
     {
         return null;
     }
 }
Exemple #3
0
        public bool Equals(Tpg tpg)
        {
            if (string.IsNullOrEmpty(this.GroupID)
                || string.IsNullOrEmpty(tpg.GroupID))
            {
                return false;
            }

            if (string.IsNullOrEmpty(Topic)
                || string.IsNullOrEmpty(tpg.Topic))
            {
                return false;
            }

            return this.Partition == tpg.Partition
                && this.Topic.Equals(tpg.Topic) && this.GroupID.Equals(tpg.GroupID);
        }
 public LeaseAcquireResponse TryRenewConsumerLease(Tpg tpg, ILease lease, String sessionId)
 {
     return new LeaseAcquireResponse(false, null, new DateTime().CurrentTimeMillis() + 10 * 1000L);
 }
 public LeaseAcquireResponse TryAcquireConsumerLease(Tpg tpg, String sessionId)
 {
     long expireTime = new DateTime().CurrentTimeMillis() + 10 * 1000L;
     long leaseId = m_leaseId.AtomicIncrementAndGet();
     return new LeaseAcquireResponse(true, new DefaultLease(leaseId, expireTime), expireTime);
 }
 public ConsumerLeaseKey(Tpg tpg, String sessionId)
 {
     this.Tpg = tpg;
     SessionId = sessionId;
 }