Пример #1
0
        private string AssertLicenseAttributes(IDictionary<string, string> licenseAttributes, LicenseType licenseType)
        {
            string version;
            var errorMessage = string.Empty;

            licenseAttributes.TryGetValue("version", out version); // note that a 1.0 license might not have version

            if (version != "3.0")
            {
                if (licenseType != LicenseType.Subscription)
                {
                    throw new LicenseExpiredException("This is not a license for RavenDB 3.0");
                }
            }

            string maxRam;
            if (licenseAttributes.TryGetValue("maxRamUtilization", out maxRam))
            {
                if (string.Equals(maxRam, "unlimited", StringComparison.OrdinalIgnoreCase) == false)
                {
                    MemoryStatistics.MemoryLimit = (int)(long.Parse(maxRam) / 1024 / 1024);
                }
            }

            string maxParallel;
            if (licenseAttributes.TryGetValue("maxParallelism", out maxParallel))
            {
                if (string.Equals(maxParallel, "unlimited", StringComparison.OrdinalIgnoreCase) == false)
                {
                    MemoryStatistics.MaxParallelism = Math.Max(2, (int.Parse(maxParallel) * 2));
                }
            }
            var clasterInspector = new ClusterInspecter();

            string claster;
            if (licenseAttributes.TryGetValue("allowWindowsClustering", out claster))
            {
                if (bool.Parse(claster) == false)
                {
                    if (clasterInspector.IsRavenRunningAsClusterGenericService())
                        throw new LicenseExpiredException("Your license does not allow clustering, but RavenDB is running in clustered mode");
                }
            }
            else
            {
                if (clasterInspector.IsRavenRunningAsClusterGenericService())
                    throw new LicenseExpiredException("Your license does not allow clustering, but RavenDB is running in clustered mode");
            }

            return errorMessage;
        }
Пример #2
0
		private void AssertForV2(IDictionary<string, string> licenseAttributes)
		{
			string version;
			if (licenseAttributes.TryGetValue("version", out version) == false)
			{
				if (licenseValidator.LicenseType != LicenseType.Subscription)
					throw new LicenseExpiredException("This is not a license for RavenDB 2.0");

				// Add backward compatibility for the subscription licenses of v1
				licenseAttributes["version"] = "2.5";
				licenseAttributes["implicit20StandardLicenseBy10Subscription"] = "true";
				licenseAttributes["allowWindowsClustering"] = "false";
				licenseAttributes["numberOfDatabases"] = "unlimited";
				licenseAttributes["periodicBackup"] = "true";
				licenseAttributes["encryption"] = "false";
				licenseAttributes["compression"] = "false";
				licenseAttributes["quotas"] = "false";
				licenseAttributes["authorization"] = "true";
				licenseAttributes["documentExpiration"] = "true";
				licenseAttributes["replication"] = "true";
				licenseAttributes["versioning"] = "true";
				licenseAttributes["maxSizeInMb"] = "unlimited";

				string oem;
				if (licenseValidator.LicenseAttributes.TryGetValue("OEM", out oem) &&
					"true".Equals(oem, StringComparison.OrdinalIgnoreCase))
				{
					licenseAttributes["OEM"] = "true";
					licenseAttributes["maxRamUtilization"] = "6442450944";
					licenseAttributes["maxParallelism"] = "3";

				}
				else
				{
					licenseAttributes["OEM"] = "false";
					licenseAttributes["maxRamUtilization"] = "12884901888";
					licenseAttributes["maxParallelism"] = "6";
				}
			}
			else
			{
				if (version != "1.2" && version != "2.0" && version != "2.5" && version != "3.0")
					throw new LicenseExpiredException("This is not a license for RavenDB 2.x");
			}

			string maxRam;
			if (licenseAttributes.TryGetValue("maxRamUtilization", out maxRam))
			{
				if (string.Equals(maxRam, "unlimited", StringComparison.OrdinalIgnoreCase) == false)
				{
					MemoryStatistics.MemoryLimit = (int)(long.Parse(maxRam) / 1024 / 1024);
				}
			}

			string maxParallel;
			if (licenseAttributes.TryGetValue("maxParallelism", out maxParallel))
			{
				if (string.Equals(maxParallel, "unlimited", StringComparison.OrdinalIgnoreCase) == false)
				{
					MemoryStatistics.MaxParallelism = int.Parse(maxParallel);
				}
			}

			var clasterInspector = new ClusterInspecter();

			string claster;
			if (licenseAttributes.TryGetValue("allowWindowsClustering", out claster))
			{
				if (bool.Parse(claster) == false)
				{
					if (clasterInspector.IsRavenRunningAsClusterGenericService())
						throw new InvalidOperationException("Your license does not allow clustering, but RavenDB is running in clustered mode");
				}
			}
			else
			{
				if (clasterInspector.IsRavenRunningAsClusterGenericService())
					throw new InvalidOperationException("Your license does not allow clustering, but RavenDB is running in clustered mode");
			}
		}
Пример #3
0
		private void AssertForV2(IDictionary<string, string> licenseAttributes)
		{
			string version;
			if (licenseAttributes.TryGetValue("version", out version) == false)
				throw new LicenseExpiredException("This is not a license for RavenDB 2.0");

			if(version != "1.2" && version != "2.0")
				throw new LicenseExpiredException("This is not a license for RavenDB 2.0");

			string maxRam;
			if (licenseAttributes.TryGetValue("maxRamUtilization", out maxRam))
			{
				if (string.Equals(maxRam, "unlimited",StringComparison.InvariantCultureIgnoreCase) == false)
				{
					MemoryStatistics.MemoryLimit = (int)(long.Parse(maxRam) / 1024 / 1024);
				}
			}
			
			string maxParallel;
			if (licenseAttributes.TryGetValue("maxParallelism", out maxParallel))
			{
				if (string.Equals(maxParallel, "unlimited", StringComparison.InvariantCultureIgnoreCase) == false)
				{
					MemoryStatistics.MaxParallelism = int.Parse(maxParallel);
				}
			}

			var clasterInspector = new ClusterInspecter();

			string claster;
			if (licenseAttributes.TryGetValue("allowWindowsClustering", out claster))
			{
				if(bool.Parse(claster) == false)
				{
					if (clasterInspector.IsRavenRunningAsClusterGenericService())
						throw new InvalidOperationException("Your license does not allow clustering, but RavenDB is running in clustered mode");
				}
			}
			else
			{
				if (clasterInspector.IsRavenRunningAsClusterGenericService())
					throw new InvalidOperationException("Your license does not allow clustering, but RavenDB is running in clustered mode");
			}
		}