示例#1
0
 private void AssertCanCast(NodeDescription nodeDescription)
 {
     if (!this.CanCast(nodeDescription))
     {
         throw new ConvertEntityToNodeException(nodeDescription, this.entity);
     }
 }
示例#2
0
    private Dictionary <NodeDescription.Type, List <System.Type> > GetNodeTypes()
    {
        Dictionary <NodeDescription.Type, List <System.Type> > types = new Dictionary <NodeDescription.Type, List <System.Type> >();

        List <System.Type> marrowTypes = new List <System.Type>();

        System.Reflection.Assembly assembly = System.Reflection.Assembly.GetAssembly(typeof(MarrowNode));
        foreach (System.Type type in assembly.GetTypes())
        {
            if (type.IsClass && !type.IsAbstract && type.IsSubclassOf(typeof(MarrowNode)))
            {
                marrowTypes.Add(type);
            }
        }

        foreach (var v in System.Enum.GetValues(typeof(NodeDescription.Type)))
        {
            NodeDescription.Type t = (NodeDescription.Type)v;
            types.Add(t, new List <System.Type>());
        }

        foreach (System.Type type in marrowTypes)
        {
            NodeDescription attr = (NodeDescription)System.Attribute.GetCustomAttribute(type, typeof(NodeDescription));
            types[attr.GetNodeType()].Add(type);
        }

        return(types);
    }
示例#3
0
 public void SetDisplay(NodeDescription description)
 {
     image.sprite          = description.nodeSprite;
     image.color           = description.color;
     title.text            = description.nodeName;
     this.description.text = description.nodeDescription;
 }
示例#4
0
        private static void DiffValue(Diff3Node diff3, ref NodeDescription baseNodeDesc, ref NodeDescription asset1NodeDesc, ref NodeDescription asset2NodeDesc)
        {
            var node            = diff3.Asset1Node ?? diff3.Asset2Node ?? diff3.BaseNode;
            var dataVisitMember = node as DataVisitMember;

            if (dataVisitMember != null)
            {
                var specificAssetAttribute = dataVisitMember.MemberDescriptor.GetCustomAttributes <DiffUseSpecificAssetAttribute>(true).FirstOrDefault();
                if (specificAssetAttribute != null)
                {
                    if (specificAssetAttribute is DiffUseAsset1Attribute)
                    {
                        diff3.ChangeType = Diff3ChangeType.MergeFromAsset1;
                    }
                    else if (specificAssetAttribute is DiffUseAsset2Attribute)
                    {
                        diff3.ChangeType = Diff3ChangeType.MergeFromAsset2;
                    }
                    else
                    {
                        throw new InvalidOperationException();
                    }
                    return;
                }
            }

            var baseAsset1Equals = Equals(baseNodeDesc.Instance, asset1NodeDesc.Instance);
            var baseAsset2Equals = Equals(baseNodeDesc.Instance, asset2NodeDesc.Instance);
            var asset1And2Equals = Equals(asset1NodeDesc.Instance, asset2NodeDesc.Instance);

            diff3.ChangeType = baseAsset1Equals && baseAsset2Equals
                ? Diff3ChangeType.None
                : baseAsset2Equals ? Diff3ChangeType.MergeFromAsset1 : baseAsset1Equals ? Diff3ChangeType.MergeFromAsset2 : asset1And2Equals ? Diff3ChangeType.MergeFromAsset1And2 : Diff3ChangeType.Conflict;
        }
示例#5
0
            public AudioSignalNode(NodeDescription description, IResourceHandle <GlobalEngine> engineHandle, NodeContext nodeContext) : base(nodeContext)
            {
                this.description = description;
                FSignalInstance  = (AudioSignal)Activator.CreateInstance(description.Signal);
                FEngineHandle    = engineHandle;

                foreach (var input in description.Inputs)
                {
                    FInputsMap.Add(input.Name, new MyPin()
                    {
                        Name = input.Name, Type = input.Type, Value = input.DefaultValue
                    });
                }

                Inputs = FInputsMap.Values.ToArray();

                foreach (var output in description.Outputs)
                {
                    FOutputsMap.Add(output.Name, new MyPin()
                    {
                        Name = output.Name, Type = output.Type, Value = output.DefaultValue
                    });
                }

                Outputs = FOutputsMap.Values.ToArray();
            }
示例#6
0
        public GlymaNode(IRelationship relationship, INode node)
        {
            Relationship = relationship;
            Proxy        = node;

            double x, y;

            if (!double.TryParse(FindRelationshipBindedMetadata("XPosition"), out x))
            {
                x = 0;
            }
            XPosition = x;
            if (!double.TryParse(FindRelationshipBindedMetadata("YPosition"), out y))
            {
                y = 0;
            }
            YPosition = y;

            NodeVideo = new NodeVideo(FindMetadata("Video.Source"), FindMetadata("Video.StartPosition"), FindMetadata("Video.EndPosition"));

            if (FindMetadata("DescriptionType") != string.Empty)
            {
                NodeDescription = new NodeDescription(FindMetadata("DescriptionType"), FindMetadata("Description"));
            }
            else if (FindMetadata("Description.Type") != string.Empty)
            {
                NodeDescription = new NodeDescription(FindMetadata("Description.Type"), FindMetadata("Description.Content"), FindMetadata("Description.Url"));
            }
            else
            {
                NodeDescription = new NodeDescription(null, null);
            }
        }
示例#7
0
 public EntityState(Type nodeClass, NodeDescription nodeDescription)
 {
     this.nodeDescription = nodeDescription;
     this.fields          = new Dictionary <Type, FieldInfo>();
     this.CreateNode(nodeClass);
     this.ParseFields();
 }
        public IActionResult PostDescription([FromBody] NodeDescription value)
        {
            try
            {
                if (value.Id == 0)
                {
                    BadRequest("Id cannot be 0(Zero)");
                }
                var nodeDescription = _cgDbContext.NodeDescriptions.FirstOrDefault(s => s.Id == value.Id);
                if (nodeDescription == null)
                {
                    nodeDescription = new NodeDescription()
                    {
                        Id = value.Id,
                    };
                    _cgDbContext.NodeDescriptions.Add(nodeDescription);
                }

                nodeDescription.Title       = value.Title;
                nodeDescription.Description = value.Description;
                nodeDescription.IsCondition = value.IsCondition;


                _cgDbContext.SaveChanges();
                return(Ok(nodeDescription));
            }
            catch (Exception ex)
            {
                return(BadRequest("An error has occured cannot save data"));
            }
        }
示例#9
0
        public async Task ShouldReturnAllNodesWithSpecifiedNameWhenGetNodesCalled()
        {
            //Given
            const string hostname = "node1";
            var          desc     = new NodeDescription();

            desc.Hostname = hostname;
            _swarmClient.GetNodes().Returns(x => {
                return(Task.FromResult <IEnumerable <NodeListResponse> >(new [] { _any.Create <NodeListResponse>(),
                                                                                  _any.Build <NodeListResponse>().With(t => t.Description, desc).Create() }));
            });
            var nodeService    = new NodeService(_swarmClient, _loggerFactory);
            var nodeController = new NodeController(nodeService);

            //When
            var response = await nodeController.GetNode(hostname, SwarmRole.Unknown);

            var jsonResult = response as JsonResult;
            var value      = jsonResult?.Value as IEnumerable <NodeListResponse>;

            //Then
            Assert.NotNull(jsonResult);
            Assert.NotNull(value);
            Assert.Equal(200, jsonResult.StatusCode);
            Assert.Equal(1, value.Count());
        }
示例#10
0
        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                var hashCode = 41;
                // Suitable nullity checks etc, of course :)
                if (Class != null)
                {
                    hashCode = hashCode * 59 + Class.GetHashCode();
                }
                if (AssignedLabels != null)
                {
                    hashCode = hashCode * 59 + AssignedLabels.GetHashCode();
                }
                if (Mode != null)
                {
                    hashCode = hashCode * 59 + Mode.GetHashCode();
                }
                if (NodeDescription != null)
                {
                    hashCode = hashCode * 59 + NodeDescription.GetHashCode();
                }
                if (NodeName != null)
                {
                    hashCode = hashCode * 59 + NodeName.GetHashCode();
                }

                hashCode = hashCode * 59 + NumExecutors.GetHashCode();
                if (Description != null)
                {
                    hashCode = hashCode * 59 + Description.GetHashCode();
                }
                if (Jobs != null)
                {
                    hashCode = hashCode * 59 + Jobs.GetHashCode();
                }
                if (PrimaryView != null)
                {
                    hashCode = hashCode * 59 + PrimaryView.GetHashCode();
                }

                hashCode = hashCode * 59 + QuietingDown.GetHashCode();

                hashCode = hashCode * 59 + SlaveAgentPort.GetHashCode();
                if (UnlabeledLoad != null)
                {
                    hashCode = hashCode * 59 + UnlabeledLoad.GetHashCode();
                }

                hashCode = hashCode * 59 + UseCrumbs.GetHashCode();

                hashCode = hashCode * 59 + UseSecurity.GetHashCode();
                if (Views != null)
                {
                    hashCode = hashCode * 59 + Views.GetHashCode();
                }
                return(hashCode);
            }
        }
示例#11
0
    public static void AddConnection(NodeDescription out_node, string out_key, NodeDescription in_node, string in_key)
    {
        WireableSocket out_socket = out_node.Outputs[out_key];
        WireableSocket in_socket  = in_node.Inputs[in_key];

        out_socket.ConnectedSocket = in_socket;
        in_socket.ConnectedSocket  = out_socket;
    }
示例#12
0
 private void SendNodeRemovedForCollectors(NodeDescription nodeDescription)
 {
     Collections.Enumerator <EntityListener> enumerator = Collections.GetEnumerator <EntityListener>(this.entityListeners);
     while (enumerator.MoveNext())
     {
         enumerator.Current.OnNodeRemoved(this, nodeDescription);
     }
 }
        public async Task <string> ProcessGetClusterConfigurationAsync(string apiVersion, TimeSpan timeout, CancellationToken cancellationToken)
        {
            UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Entering ProcessGetClusterConfigurationAsync.");
            try
            {
                UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Retrieve current cluster resource from StoreManager.");
                StandAloneCluster cluster = await this.storeManager.GetClusterResourceAsync(
                    Constants.ClusterReliableDictionaryKey, this.cancellationToken).ConfigureAwait(false);

                if (cluster == null || cluster.Current == null)
                {
                    // read from fabric data root
                    string fabricDataRoot = FabricEnvironment.GetDataRoot();
                    string jsonConfigPath = Path.Combine(fabricDataRoot, System.Fabric.FabricDeployer.Constants.FileNames.BaselineJsonClusterConfig); // TODO: Needs to come from image store
                    return(File.ReadAllText(jsonConfigPath));
                }
                else
                {
                    var      nodesFromFM = new Dictionary <string, NodeDescription>();
                    NodeList nodes       = await StandaloneUtility.GetNodesFromFMAsync(this.fabricClient, this.cancellationToken).ConfigureAwait(false);

                    for (int i = 0; i < nodes.Count; ++i)
                    {
                        if (nodes[i].NodeStatus != System.Fabric.Query.NodeStatus.Invalid && !UpgradeOrchestrationMessageProcessor.IsGhostNode(nodes[i]))
                        {
                            NodeDescription nodeDesc = new NodeDescription()
                            {
                                FaultDomain   = nodes[i].FaultDomain.ToString(),
                                UpgradeDomain = nodes[i].UpgradeDomain,
                                IPAddress     = nodes[i].IpAddressOrFQDN,
                                NodeTypeRef   = nodes[i].NodeType,
                                NodeName      = nodes[i].NodeName
                            };
                            nodesFromFM.Add(nodes[i].NodeName, nodeDesc);
                        }
                    }

                    cluster.Topology.Nodes = nodesFromFM;

                    UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Construct StandAloneJsonModel from current cluster resource.");
                    var jsonModel = StandAloneInstallerJsonModelBase.ConstructByApiVersion(cluster.Current.CSMConfig, cluster.Topology, cluster.Current.CSMConfig.Version.Version, apiVersion);
                    UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Serializing current json model.");
                    var serializerSettings = new JsonSerializerSettings
                    {
                        Formatting                 = Formatting.Indented,
                        NullValueHandling          = NullValueHandling.Ignore,
                        PreserveReferencesHandling = PreserveReferencesHandling.None
                    };
                    serializerSettings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter());
                    return(JsonConvert.SerializeObject(jsonModel, serializerSettings));
                }
            }
            catch (Exception e)
            {
                UpgradeOrchestrationTrace.TraceSource.WriteWarning(TraceType, "ProcessStartUpgradeAsync exception: {0}", e);
                throw UpgradeOrchestrationMessageProcessor.ConvertToComException(e);
            }
        }
示例#14
0
    void Start()
    {
        Node = GetComponent <NodeDescription>();

        if (Node.ReferenceNode.module_id == 0 && Node.ReferenceNode.node_id == 1)
        {
            enabled = false;
        }
    }
示例#15
0
        public void OnNodeRemoved(Entity entity, NodeDescription nodeDescription)
        {
            IEnumerator <Handler> enumerator = this.handlerCollector.GetHandlersWithoutContext(nodeDescription).GetEnumerator();

            while (enumerator.MoveNext())
            {
                enumerator.Current.ChangeVersion();
            }
        }
示例#16
0
        private static void DiffValue(Diff3Node diff3, ref NodeDescription baseNodeDesc, ref NodeDescription asset1NodeDesc, ref NodeDescription asset2NodeDesc)
        {
            var baseAsset1Equals = Equals(baseNodeDesc.Instance, asset1NodeDesc.Instance);
            var baseAsset2Equals = Equals(baseNodeDesc.Instance, asset2NodeDesc.Instance);
            var asset1And2Equals = Equals(asset1NodeDesc.Instance, asset2NodeDesc.Instance);

            diff3.ChangeType = baseAsset1Equals && baseAsset2Equals
                ? Diff3ChangeType.None
                : baseAsset2Equals ? Diff3ChangeType.MergeFromAsset1 : baseAsset1Equals ? Diff3ChangeType.MergeFromAsset2 : asset1And2Equals ? Diff3ChangeType.MergeFromAsset1And2 : Diff3ChangeType.Conflict;
        }
 public BT_BehaviorDelegator(NodeDescription.BT_NodeType type, UpdateDelegate onUpdate, InitDelegate onInit = null, EnterDelegate onEnter = null, ExitDelegate onExit = null, TerminateDelegate onTerm = null)
 {
     Description.Type = type;
     
     initDel = onInit;
     enterDel = onEnter;
     updateDel = onUpdate;
     exitDel = onExit;
     terminateDel = onTerm;
 }
示例#18
0
        public ICollection <Entity> GetEntities(NodeDescription nodeDescription)
        {
            HashSet <Entity> set;

            if (nodeDescription.IsEmpty)
            {
                throw new EmptyNodeNotSupportedException();
            }
            return(!this.entitiesByDescription.TryGetValue(nodeDescription, out set) ? ((ICollection <Entity>)Collections.EmptyList <Entity>()) : ((ICollection <Entity>)set));
        }
示例#19
0
 public void OnNodeRemoved(Entity entity, NodeDescription node)
 {
     Collections.Enumerator <KeyValuePair <Type, BroadcastInvokeDataStorage> > enumerator = Collections.GetEnumerator <KeyValuePair <Type, BroadcastInvokeDataStorage> >(this.handlersByType);
     while (enumerator.MoveNext())
     {
         KeyValuePair <Type, BroadcastInvokeDataStorage> current = enumerator.Current;
         ICollection <Handler> handlers = this.handlerCollector.GetHandlers(current.Key, node);
         KeyValuePair <Type, BroadcastInvokeDataStorage> pair2 = enumerator.Current;
         pair2.Value.Remove(entity, handlers);
     }
 }
        public void Attach(Entity entity, NodeDescription nodeDescription)
        {
            ICollection <Entity> is2;

            if (!this.entitiesByDescription.TryGetValue(nodeDescription, out is2))
            {
                is2 = new HashSet <Entity>();
                this.entitiesByDescription[nodeDescription] = is2;
            }
            is2.Add(entity);
        }
示例#21
0
 internal static NodeDescriptionGA ReadFromInternal(NodeDescription nodeDescription)
 {
     return(new NodeDescriptionGA
     {
         NodeName = nodeDescription.NodeName,
         IPAddress = nodeDescription.IPAddress,
         FaultDomain = nodeDescription.FaultDomain,
         UpgradeDomain = nodeDescription.UpgradeDomain,
         NodeTypeRef = nodeDescription.NodeTypeRef
     });
 }
示例#22
0
    public void RemoveNode(NodeDescription node)
    {
        if (CurrentGraph == null || CurrentGraphNodes == null || (node.ReferenceNode.module_id == 0 && node.ReferenceNode.node_id == 1))
        {
            return;
        }

        CurrentGraph.RemoveNode(node.ReferenceNode);
        CurrentGraphNodes.Remove(node.ReferenceNode.guid);
        Destroy(node.gameObject);
    }
示例#23
0
        public void Attach(Entity entity, NodeDescription nodeDescription)
        {
            HashSet <Entity> set;

            if (!this.entitiesByDescription.TryGetValue(nodeDescription, out set))
            {
                set = new HashSet <Entity>();
                this.entitiesByDescription.Add(nodeDescription, set);
            }
            set.Add(entity);
        }
    public NodeDescription GetDescription(Node node)
    {
        NodeDescription description = new NodeDescription
        {
            nodeSprite      = node.rend.sprite,
            nodeName        = node.nodeName,
            nodeDescription = node.nodeDescription
        };

        return(SetNodeDescription(node, description));
    }
示例#25
0
        internal static NodeDescription CreateNodeDescription(string nodeName, string nodeTypeRef, string iPAddress, string faultDomain, string upgradeDomain)
        {
            NodeDescription nodeDescription = new NodeDescription();

            nodeDescription.NodeName      = nodeName;
            nodeDescription.NodeTypeRef   = nodeTypeRef;
            nodeDescription.IPAddress     = iPAddress;
            nodeDescription.FaultDomain   = faultDomain;
            nodeDescription.UpgradeDomain = upgradeDomain;

            return(nodeDescription);
        }
示例#26
0
        private static ICollection <Type> GetMissingComponents(Entity entity, NodeDescription nodeDescription)
        {
            List <Type> list = new List <Type>();

            foreach (Type type in nodeDescription.Components)
            {
                if (!entity.HasComponent(type))
                {
                    list.Add(type);
                }
            }
            return(list);
        }
示例#27
0
    public void Open(Node node)
    {
        DeactivateAll();
        nodeMainMenu.SetActive(true);
        nodeMainMenu.GetComponent <OpenNodeMenu>().SetNode(node);
        upperMenu.SetActive(true);

        if (node != null)
        {
            nodeInfoMenu.SetActive(true);
            NodeDescription description = nodeUtil.GetDescription(node);
            nodeInfoMenu.GetComponent <InfoMenu>().SetDisplay(description);
        }
    }
示例#28
0
        protected ICollection <NodeDescription> GetRemovedNodes(EntityInternal entity, Type componentClass)
        {
            BitSet componentsBitId          = entity.ComponentsBitId;
            List <NodeDescription> instance = flowInstances.listNodeDescription.GetInstance();

            Collections.Enumerator <NodeDescription> enumerator = Collections.GetEnumerator <NodeDescription>(NodeDescriptionRegistry.GetNodeDescriptionsByNotComponent(componentClass));
            while (enumerator.MoveNext())
            {
                NodeDescription current = enumerator.Current;
                if (componentsBitId.Mask(current.NodeComponentBitId) && (!componentsBitId.MaskNot(current.NotNodeComponentBitId) && entity.NodeDescriptionStorage.Contains(current)))
                {
                    instance.Add(current);
                }
            }
            return(instance);
        }
        public NodeDescription GetDescription(Type type)
        {
            if (!type.IsSubclassOf(typeof(Node)))
            {
                throw new ArgumentException();
            }

            NodeDescription description;

            if (!_mapDescriptions.TryGetValue(type, out description) || description == null)
            {
                description            = new NodeDescription(type);
                _mapDescriptions[type] = description;
            }

            return(description);
        }
示例#30
0
        public NetDescription BuildDescription(int inputs, IEnumerable <LayerSpec> layers)
        {
            var nodes   = new List <NodeDescription>();
            var outputs = layers.Last().NumberOfNodes;

            var lastIds = new int[inputs];

            for (var i = 0; i < inputs; i++)
            {
                lastIds[i] = i;
            }
            var fromInput = true;

            int nodeId = 0;

            foreach (var layer in layers)
            {
                var newIds = new List <int>();
                for (var i = 0; i < layer.NumberOfNodes; i++)
                {
                    var newNode = new NodeDescription()
                    {
                        NodeId     = nodeId++,
                        Aggregator = layer.Aggregator,
                        Processor  = layer.Activator,
                        Inputs     = lastIds.Select(id => new NodeInputDescription()
                        {
                            FromInputVector = fromInput,
                            InputId         = id,
                            Weight          = GetWeight(inputs, outputs)
                        }).ToArray(),
                        Weight = GetWeight(inputs, outputs)
                    };
                    newIds.Add(newNode.NodeId);
                    nodes.Add(newNode);
                }
                lastIds   = newIds.ToArray();
                fromInput = false;
            }

            return(new NetDescription()
            {
                Nodes = nodes.ToArray(),
                Outputs = lastIds.ToArray()
            });
        }
示例#31
0
        private static HashSet <Type> GetComponentsFromNodes(IList <HandlerArgument> handlerArguments)
        {
            HashSet <Type> set = new HashSet <Type>();

            foreach (HandlerArgument argument in handlerArguments)
            {
                NodeDescription nodeDescription = argument.NodeDescription;
                foreach (Type type in nodeDescription.Components)
                {
                    set.Add(type);
                }
                foreach (Type type2 in nodeDescription.NotComponents)
                {
                    set.Add(type2);
                }
            }
            return(set);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="NodeManagerReceiverActor"/> class.
        /// </summary>
        public NodeManagerReceiverActor()
        {
            var config = Context.System.Settings.Config;
            var nodeIdString = config.GetString("ClusterKit.NodeManager.NodeId");
            Guid nodeId;
            if (!Guid.TryParse(nodeIdString, out nodeId))
            {
                nodeId = Guid.NewGuid();
            }

            try
            {
                this.description = new NodeDescription
                {
                    IsInitialized = true,
                    NodeAddress = Cluster.Get(Context.System).SelfAddress,
                    NodeTemplate = config.GetString("ClusterKit.NodeManager.NodeTemplate"),
                    ContainerType = config.GetString("ClusterKit.NodeManager.ContainerType"),
                    NodeTemplateVersion = config.GetInt("ClusterKit.NodeManager.NodeTemplateVersion"),
                    NodeId = nodeId,
                    StartTimeStamp = this.startTimeStamp,
                    Roles = config.GetStringList("akka.cluster.roles")?.ToList() ?? new List<string>(),
                    Modules = AppDomain.CurrentDomain.GetAssemblies()
                                .Where(a => a.GetTypes().Any(t => t.IsSubclassOf(typeof(BaseInstaller))))
                                .Select(
                                    a =>
                                        new PackageDescription
                                        {
                                            Id = a.GetName().Name,
                                            Version = a.GetName().Version.ToString(),
                                            BuildDate = a.GetCustomAttributes<AssemblyMetadataAttribute>()
                                                        .FirstOrDefault(attr => attr.Key == "BuildDate")?.Value
                                        })
                                .OrderBy(a => a.Id)
                                .ToList()
                };
            }
            catch (ReflectionTypeLoadException exception)
            {
                foreach (var loaderException in exception.LoaderExceptions)
                {
                    Context.GetLogger()
                        .Error(loaderException, "{Type}: exception during assemblies read", this.GetType().Name);
                    if (loaderException.InnerException != null)
                    {
                        Context.GetLogger()
                            .Error(loaderException.InnerException, "{Type}: Inner exception", this.GetType().Name);
                    }
                }

                throw;
            }

            this.Receive<NodeDescriptionRequest>(m => this.Sender.Tell(this.description));
            this.ReceiveAsync<ShutdownMessage>(
                async m =>
                    {
                        var cluster = Cluster.Get(Context.System);
                        var system = Context.System;
                        await cluster.LeaveAsync();
                        await system.Terminate();
                    });
        }