public void Constructor_Defaults()
        {
            LeaseInfo info = new LeaseInfo();

            Assert.Equal(LeaseInfo.Default_DurationInSecs, info.DurationInSecs);
            Assert.Equal(LeaseInfo.Default_RenewalIntervalInSecs, info.RenewalIntervalInSecs);
        }
        public void ToJson_Correct()
        {
            JsonLeaseInfo jinfo = new JsonLeaseInfo()
            {
                RenewalIntervalInSecs      = 100,
                DurationInSecs             = 200,
                RegistrationTimestamp      = 1457973741708,
                LastRenewalTimestamp       = 1457973741708,
                LastRenewalTimestampLegacy = 1457973741708,
                EvictionTimestamp          = 1457973741708,
                ServiceUpTimestamp         = 1457973741708
            };

            LeaseInfo result = LeaseInfo.FromJson(jinfo);

            jinfo = result.ToJson();

            Assert.Equal(100, result.RenewalIntervalInSecs);
            Assert.Equal(200, result.DurationInSecs);
            Assert.Equal(1457973741708, DateTimeConversions.ToJavaMillis(new DateTime(result.RegistrationTimestamp, DateTimeKind.Utc)));
            Assert.Equal(1457973741708, DateTimeConversions.ToJavaMillis(new DateTime(result.LastRenewalTimestamp, DateTimeKind.Utc)));
            Assert.Equal(1457973741708, DateTimeConversions.ToJavaMillis(new DateTime(result.LastRenewalTimestampLegacy, DateTimeKind.Utc)));
            Assert.Equal(1457973741708, DateTimeConversions.ToJavaMillis(new DateTime(result.EvictionTimestamp, DateTimeKind.Utc)));
            Assert.Equal(1457973741708, DateTimeConversions.ToJavaMillis(new DateTime(result.ServiceUpTimestamp, DateTimeKind.Utc)));
        }
Exemplo n.º 3
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            // string id = ProjectID.Text;
            string name = ProjectName.Text;
            string type = ProjectType.SelectedValue;

            // string p_message = "";

            //objBLL = new MetisBLL();
            //objBLL.insertProject(id, name, type, out p_message);
            //string tt = id;
            //string[] str = tt.Split('_');
            //int test = Convert.ToInt32(str[1]);
            //test += 1;
            //id = str[0] + Convert.ToString(test);

            try
            {
                kService         = new ApplicationService();
                kService.Timeout = 300000;
                if (lease == null)
                {
                    lease = kService.CreateLease("sysadmin", "kalido", "StreeboEDW", null, LeaseInfoDetail.All);
                }
                lblStartTime.Text = DateTime.Now.ToString();
                CreateSubjects();
                lblEndTime.Text = DateTime.Now.ToString();

                kService.DestroyLease(lease.Token);
            }
            catch (Exception Ex)
            {
                lblError.Text = "This exception occured: " + Ex.Message;
            }
        }
Exemplo n.º 4
0
 /**
  * <summary>Renew lease time for all keys current namespace</summary>
  * <param name="leaseInfo">Lease time to set</param>
  * <param name="gasInfo">Gas specified for transaction execution</param>
  */
 public async Task RenewAll(LeaseInfo leaseInfo = null, GasInfo gasInfo = null)
 {
     await SendTransaction(new JObject
     {
         ["Lease"] = leaseInfo == null ? "0" : leaseInfo.Value
     }, "post", "renewleaseall", gasInfo);
 }
Exemplo n.º 5
0
 /**
  * <summary>Create <paramref name="key" /> with <paramref name="value" /> in current namespace</summary>
  * <param name="key">String key to create</param>
  * <param name="value">String value of key</param>
  * <param name="leaseInfo">Lease time for new key</param>
  * <param name="gasInfo">Gas specified for transaction execution</param>
  * <exception cref="Exceptions.KeyAlreadyExistsException"></exception>
  * <exception cref="Exceptions.KeyContainsSlashException"></exception>
  */
 public async Task Create(string key, string value, LeaseInfo leaseInfo = null, GasInfo gasInfo = null)
 {
     if (key.Contains("/"))
     {
         throw new KeyContainsSlashException();
     }
     if (key.Equals(""))
     {
         throw new KeyEmptyException();
     }
     try
     {
         await SendTransaction(new JObject
         {
             ["Key"]   = key,
             ["Value"] = value,
             ["Lease"] = leaseInfo == null ? "0" : leaseInfo.Value
         }, "post", "create", gasInfo);
     }
     catch (TransactionExecutionException ex)
     {
         if (ex.Message.Contains("already exists"))
         {
             throw new KeyAlreadyExistsException();
         }
         throw;
     }
 }
        public void FromConfig_Correct()
        {
            EurekaInstanceConfig config = new EurekaInstanceConfig();
            LeaseInfo            info   = LeaseInfo.FromConfig(config);

            Assert.Equal(config.LeaseRenewalIntervalInSeconds, info.RenewalIntervalInSecs);
            Assert.Equal(config.LeaseExpirationDurationInSeconds, info.DurationInSecs);
        }
Exemplo n.º 7
0
 /**
  * <summary>Renew lease time of a key in current namespace</summary>
  * <param name="key">Key to update</param>
  * <param name="leaseInfo">Lease time to set</param>
  * <param name="gasInfo">Gas specified for transaction execution</param>
  */
 public async Task Renew(string key, LeaseInfo leaseInfo = null, GasInfo gasInfo = null)
 {
     await SendTransaction(new JObject
     {
         ["Key"]   = key,
         ["Lease"] = leaseInfo == null ? "0" : leaseInfo.Value
     }, "post", "renewlease", gasInfo);
 }
Exemplo n.º 8
0
 /**
  * <summary>Update Key's value to <paramref name="value" /> in current namespace</summary>
  * <param name="key">String key to update</param>
  * <param name="value">String value of key</param>
  * <param name="leaseInfo">Lease time which to set after updating</param>
  * <param name="gasInfo">Gas specified for transaction execution</param>
  */
 public async Task Update(string key, string value, LeaseInfo leaseInfo = null, GasInfo gasInfo = null)
 {
     await SendTransaction(new JObject
     {
         ["Key"]   = key,
         ["Value"] = value,
         ["Lease"] = leaseInfo == null ? "0" : leaseInfo.Value
     }, "post", "update", gasInfo);
 }
        public virtual void RefreshLeaseInfo()
        {
            if (InstanceInfo == null || InstanceConfig == null)
            {
                return;
            }

            if (InstanceInfo.LeaseInfo == null)
            {
                return;
            }

            if (InstanceInfo.LeaseInfo.DurationInSecs != InstanceConfig.LeaseExpirationDurationInSeconds ||
                InstanceInfo.LeaseInfo.RenewalIntervalInSecs != InstanceConfig.LeaseRenewalIntervalInSeconds)
            {
                LeaseInfo newLease = new LeaseInfo()
                {
                    DurationInSecs        = InstanceConfig.LeaseExpirationDurationInSeconds,
                    RenewalIntervalInSecs = InstanceConfig.LeaseRenewalIntervalInSeconds
                };
                InstanceInfo.LeaseInfo = newLease;
                InstanceInfo.IsDirty   = true;
            }
        }
Exemplo n.º 10
0
 internal static CfLeaseInfo FromLeaseInfo(LeaseInfo source)
 {
     return(source == null ? null : new CfLeaseInfo(source.LeaseBegin, source.LeaseEnd, source.AutoRenew));
 }