An capability that represents a dependency between apps
Inheritance: IComparable
Exemple #1
0
 /// <summary>
 /// Gets instances that depend on a capability
 /// </summary>
 /// <param name="capability"></param>
 /// <returns></returns>
 public IEnumerable<AppInstance> GetDependents(Capability capability)
 {
     if (!dependents.ContainsKey(capability))
     {
         dependents[capability] = new SortedSet<string>();
     }
     return dependents[capability].Select(instanceId => instances[instanceId]);
 }
Exemple #2
0
 /// <summary>
 /// Gets instances that provide a capability
 /// </summary>
 /// <param name="capability"></param>
 /// <returns></returns>
 public IEnumerable<AppInstance> GetProviders(Capability capability)
 {
     if (!providers.ContainsKey(capability))
     {
         providers[capability] = new SortedSet<string>();
     }
     return providers[capability].Select(instanceId => instances[instanceId]);
 }
        public void TestCompareTo_Version()
        {
            var a = new Capability("capA", new Version("1.0"));
            var b = new Capability("capA", new Version("1.1"));

            Assert.IsTrue(a.CompareTo(b) < 0);
            Assert.IsTrue(b.CompareTo(a) > 0);
        }
        public void TestCompareTo_Equal()
        {
            var a = new Capability("capA", new Version("1.0"));
            var b = new Capability("capA", new Version("1.0"));

            Assert.IsTrue(a.CompareTo(b) == 0);
            Assert.IsTrue(a.Equals(b));
        }
        public void TestCompareTo_Sort()
        {
            var a = new Capability("capA", new Version("1.0"));
            var b = new Capability("capB", new Version("1.0"));
            var c = new Capability("capB", new Version("1.1"));

            var list = new List<Capability>() { c, b, a };
            list.Sort();

            Assert.AreSame(a, list[0]);
            Assert.AreSame(b, list[1]);
            Assert.AreSame(c, list[2]);
        }
Exemple #6
0
        /// <summary>
        /// Copy all information from the manifest into the new app instance
        /// and add it to the registry
        /// </summary>
        /// <param name="registry">the registry being visited</param>
        public override void VisitRegistry(Registry registry)
        {
            // Drop the connection if the instance ID is a duplicate
            if (registry.HasInstance(manifest.InstanceId))
            {
                failure = new ManifestFail("Instance ID " + manifest.InstanceId + " already in use", instance);
                return;
            }

            if (manifest.InstanceId != null)
            {
                instance.InstanceId = manifest.InstanceId;
            }
            instance.Name = manifest.Name;
            instance.Version = new Version(manifest.Version);
            instance.ApiVersion = (uint) manifest.API;
            instance.Description = manifest.Description;
            instance.DisplayName = manifest.DisplayName;
            foreach (string capability in manifest.Capabilities.Keys)
            {
                var c = new Capability(
                    capability,
                    new Version(manifest.Capabilities[capability])
                );
                instance.AddCapability(c);
            }
            foreach (string capability in manifest.Dependencies.Keys)
            {
                var c = new Capability(
                    capability,
                    new Version(manifest.Dependencies[capability])
                );
                instance.AddDependency(c);
            }
            registry.Register(instance);

            // We have to send the message to the instance on our own
            instance.AppStatus = Status.down;
            instance.Send("APP_MANIFEST_OK " + okMsg.Serialize());
            Log.Info(instance.DisplayName + " created with instance ID " + instance.InstanceId);
        }
Exemple #7
0
 /// <summary>
 /// Returns all instances that depend on or provide a capability
 /// </summary>
 /// <param name="capability"></param>
 /// <returns></returns>
 public IEnumerable<AppInstance> GetAllRelated(Capability capability)
 {
     var all = dependents[capability];
     all.UnionWith(providers[capability]);
     return all.Select(instanceId => instances[instanceId]);
 }