コード例 #1
0
 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;
     }
 }
コード例 #2
0
 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;
     }
 }
コード例 #3
0
ファイル: Tpg.cs プロジェクト: sdgdsffdsfff/hermes.net
        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);
        }
コード例 #4
0
 public LeaseAcquireResponse TryRenewConsumerLease(Tpg tpg, ILease lease, String sessionId)
 {
     return new LeaseAcquireResponse(false, null, new DateTime().CurrentTimeMillis() + 10 * 1000L);
 }
コード例 #5
0
 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);
 }
コード例 #6
0
 public ConsumerLeaseKey(Tpg tpg, String sessionId)
 {
     this.Tpg = tpg;
     SessionId = sessionId;
 }