public async Task <IEnumerable <TopologyResult> > AnalyzeTopology(CModelFramework internalModel)
        {
            List <Task <TopologyResult> > topologyTasks = new List <Task <TopologyResult> >();

            int index = 0;

            //for (int i = 0; i < 50; i++)
            //{
            //	int partitionKey = GetPartitionKey(i);
            //	ITopologyAnalyzer topologyAnalyzer = TopologyAnalyzerClient.CreateClient(partitionKey);
            //	topologyTasks.Add(topologyAnalyzer.AnalyzeTopology(internalModel, internalModel.Roots.First().Key));
            //}

            foreach (var root in internalModel.Roots)
            {
                int partitionKey = GetPartitionKey(index);
                ITopologyAnalyzer topologyAnalyzer = TopologyAnalyzerClient.CreateClient(partitionKey);

                topologyTasks.Add(topologyAnalyzer.AnalyzeTopology(internalModel, root.Key));
                //topologyTasks[index].Start();

                index++;
            }

            List <TopologyResult> topologyResults = (await Task.WhenAll(topologyTasks)).ToList();

            return(topologyResults);
        }
        public void RunSparseMatrixApplication(string path)
        {
            internalModel = new CModelFramework();

            // Read data from files
            internalModelBuilder = new CInternalModelBuilder(internalModel, path);
            internalModelBuilder.ReadSchemaFromFile();

            // Create matrix model
            matrixModel        = new CSparseMatrix();
            matrixModelBuilder = new CMatrixModelBuilder(matrixModel, internalModel);
            matrixModelBuilder.CreateInitialLidDictionary();
            matrixModelBuilder.CreateInitialMatrixModel();
            matrixModelBuilder.InsertSwitchDeviceFromInternalToMatrixModel();

            // Analyze topology
            topologyAnalyser = new CTopologyAnalyzer(matrixModel, matrixModelBuilder.LIDtoIND, matrixModelBuilder.INDtoLID, internalModel);
            //topologyAnalyser.AnalyzeTopology(internalModel.Roots);
            foreach (var root in internalModel.Roots.Values)
            {
                if (root.UpToDate == false)     //obradjuju se samo neazurni koreni
                {
                    topologyAnalyser.UpdateRootTopology(root);
                }
            }

            return;
        }
Beispiel #3
0
 public CTopologyAnalyzer(CSparseMatrix matrixModel, Dictionary <long, long> LIDtoIND, List <long> INDtoLID, CModelFramework internalModel)
 {
     this.matrixModel     = matrixModel;
     this.LIDtoIND        = LIDtoIND;
     this.INDtoLID        = INDtoLID;
     this.bfScanner       = new BreadthFirstScanner <ActiveNodeInfo>();
     this.visitedBranches = new Dictionary <long, CVisitedBranch>(100);
     this.visitedNodes    = new Dictionary <long, CVisitedNode>(100);
     this.loops           = new Dictionary <long, bool[]>();
     this.rootsInParallel = new Dictionary <long, MPRoot>();
     this.internalModel   = internalModel;
 }
Beispiel #4
0
        public Task <TopologyResult> AnalyzeTopology(CModelFramework internalModel, long rootId)
        {
            ServiceEventSource.Current.ServiceMessage(this.Context, $"TopologyStatelessService.Analyze started. PartitionID = {Context.PartitionId} Root id = 0x{rootId:x16}.");

            // Create matrix model
            CSparseMatrix       matrixModel        = new CSparseMatrix();
            CMatrixModelBuilder matrixModelBuilder = new CMatrixModelBuilder(matrixModel, internalModel);

            matrixModelBuilder.CreateInitialLidDictionary();
            matrixModelBuilder.CreateInitialMatrixModel();
            matrixModelBuilder.InsertSwitchDeviceFromInternalToMatrixModel();

            CTopologyAnalyzer topologyAnalyzer = new CTopologyAnalyzer(matrixModel, matrixModelBuilder.LIDtoIND, matrixModelBuilder.INDtoLID, internalModel);

            if (!internalModel.Roots.ContainsKey(rootId))
            {
                Logger.LogError($"Root with id 0x{rootId:X16} is not in internal model");
            }

            MPRoot root = internalModel.Roots[rootId];

            if (!root.UpToDate)                 //obradjuju se samo neazurni koreni
            {
                topologyAnalyzer.UpdateRootTopology(root);
            }


            List <MPNode>   nodes    = topologyAnalyzer.InternalModel.Nodes.Values.Where(node => node.OwnerCircuit[0] == rootId || node.Lid == rootId).ToList();
            List <MPBranch> branches = topologyAnalyzer.InternalModel.Branches.Values.Where(branch => branch.OwnerCircuit[0] == rootId || branch.Lid == rootId).ToList();

            ServiceEventSource.Current.ServiceMessage(this.Context, $"TopologyStatelessService.Analyze finished for root 0x{rootId:x16} Nodes: {nodes.Count} Branches: {branches.Count}");

            try
            {
                return(Task.FromResult(new TopologyResult(nodes, branches, rootId)));
            }
            catch (Exception e)
            {
                ServiceEventSource.Current.ServiceMessage(this.Context, $"{e.Message}");
                return(null);
            }
        }
Beispiel #5
0
 public async Task <IEnumerable <TopologyResult> > AnalyzeTopology(CModelFramework internalModel)
 {
     return(await InvokeWithRetryAsync(client => client.Channel.AnalyzeTopology(internalModel)));
 }
 public CMatrixModelBuilder(CSparseMatrix matrixModel, CModelFramework internalModel)
 {
     this.matrixModel   = matrixModel;
     this.internalModel = internalModel;
 }
 public async Task <TopologyResult> AnalyzeTopology(CModelFramework internalModel, long rootId)
 {
     return(await InvokeWithRetryAsync(client => client.Channel.AnalyzeTopology(internalModel, rootId)));
 }