Ejemplo n.º 1
0
        public List <byte[]> getSyncData(NodeSlot id)
        {
            if (syncData.ContainsKey(id))
            {
                return(syncData[id]);
            }

            return(null);
        }
Ejemplo n.º 2
0
        public byte[] getData(NodeSlot id)
        {
            if (data.ContainsKey(id))
            {
                return(data[id]);
            }

            return(null);
        }
Ejemplo n.º 3
0
        public void StoreSyncResults(List <byte[]> newData, int nodeId, int slotPos)
        {
            NodeSlot slot = new NodeSlot(nodeId, slotPos);

            if (syncData.ContainsKey(slot))
            {
                syncData.Remove(slot);
            }
            syncData.Add(slot, newData);
        }
        public void AddDependency(int originId, int originSlot, int targetSlot)
        {
            if (dependencies.ContainsKey(targetSlot))
            {
                throw new DataSlotAlreadyInUseException("Slot " + targetSlot + " of node " + Id + " has already been assigned");
            }

            NodeSlot nodeSlot = new NodeSlot(originId, originSlot);

            dependencies.Add(targetSlot, nodeSlot);
        }
Ejemplo n.º 5
0
        public void StoreResults(List <byte[]> newData, int nodeId, bool preventCaching = false)
        {
            for (int i = 0; i < newData.Count; i++)
            {
                NodeSlot slot = new NodeSlot(nodeId, i);

                if (data.ContainsKey(slot))
                {
                    data.Remove(slot);
                }
                data.Add(slot, newData[i]);
            }

            if (!preventCaching)
            {
                SaveCache(newData, nodeId);
            }
            ClearIrrelevantData(nodeId);
        }
        public void AddDependent(int targetId, int targetSlot, int originSlot)
        {
            NodeSlot nodeSlot = new NodeSlot(targetId, targetSlot);

            if (!dependents.ContainsKey(originSlot))
            {
                dependents.Add(originSlot, new List <NodeSlot>());
            }
            if (dependents[originSlot].Contains(nodeSlot))
            {
                //clean up unused slot
                if (dependents[originSlot].Count == 0)
                {
                    dependents.Remove(originSlot);
                }

                throw new DataSlotAlreadyInUseException("Slot " + targetSlot + " of node " + Id + " has already been assigned");
            }

            dependents[originSlot].Add(nodeSlot);
            totalDependents++;
        }
 public static bool isInvalid(NodeSlot check)
 {
     return(check.NodeId < 0 || check.SlotPos < -1);
 }