コード例 #1
0
 public CacheManager(Statistics statistics, TraceFile traceFile, HazelcastClient client, string scenarioId, List<string> elementSetsPut, WebServiceManager webServiceManager)
 {
     this.statistics = statistics;
     this.traceFile = traceFile;
     this.client = client;
     this.scenarioId = scenarioId;
     this.elementSetsPut = elementSetsPut;
     this.webServiceManager = webServiceManager;
 }
コード例 #2
0
        public PrefetchMonitor(ArrayList outputLinks, TraceFile traceFile, ITimeSpan timeHorizon)
        {
            this.traceFile = traceFile;
            this.timeHorizon = timeHorizon;
            items = new Dictionary<string, LinkQuantityInfo>();

            foreach (DataOutputLink link in outputLinks)
            {
                var linkId = getLinkId(link.link);
                var linkInfo = new LinkQuantityInfo(linkId);
                items[linkId] = linkInfo;
            }
        }
コード例 #3
0
        public PrefetchManager(TraceFile traceFile, Statistics statistics, HazelcastClient hazelcastClient, string scenarioId, ArrayList outputLinks, ITimeSpan timeHorizon, bool isEnabled, WebServiceManager webServiceManager)
        {
            this.traceFile = traceFile;
            this.statistics = statistics;
            this.hazelcastClient = hazelcastClient;
            this.scenarioId = scenarioId;
            this.isEnabled = isEnabled;
            this.webServiceManager = webServiceManager;

            mapValueSet = hazelcastClient.getMap<string, ValueSetEntry>("valueSet");
            queueValueSetRequest = hazelcastClient.getQueue<ValueSetRequestEntry>("valueSetRequest");

            prefetchMonitor = new PrefetchMonitor(outputLinks, traceFile, timeHorizon);
        }
コード例 #4
0
        public override void Initialize(IArgument[] properties)
        {
            // read the component arguments from the omi file
            var arguments = new Dictionary<string, string>();
            for (var i = 0; i < properties.Length; i++)
            {
                arguments.Add(properties[i].Key, properties[i].Value);
            }

            // obtain our parameters (assume all parameters are specified
            // via a file or the omi file)
            enablePrefetching = Convert.ToBoolean(arguments["param_enable_prefetching"]);
            var instanceAddress = arguments["param_instance_address"];
            var instanceAssignment = arguments["param_instance_assignment"];
            compositionId = arguments["param_composition_id"];
            perId = arguments["param_per_id"];
            var configFile = arguments["param_config_file"];

            // generate a unique id to use as the scenario id
            //this.scenarioId = "S" + GetUniqueId();
            scenarioId = "S" + GetFixedId();

            // remember our path
            filePath = Path.GetDirectoryName(Path.GetFullPath(configFile));

            // each instance uses a different port which is based on the
            // instance's id number
            var port = 5701 + Convert.ToInt32(instanceAssignment);

            // read the element set file
            var elementSets = ElementSetReader.read("ElementSet.xml");

            // read the config file
            var componentProperties = ComponentProperties.read(configFile, this, elementSets);
            var extras = componentProperties.getExtras();
            foreach (var nextKey in extras.Keys)
            {
                arguments[nextKey] = extras[nextKey];
            }

            // set our data members
            simulationStartTime = componentProperties.getStartDateTime();
            simulationEndTime = componentProperties.getEndDateTime();
            inputs = componentProperties.getInputExchangeItems();
            outputs = componentProperties.getOutputExchangeItems();
            modelId = componentProperties.getModelId();
            modelDescription = componentProperties.getModelDescription();

            // create the trace file
            traceFile = new TraceFile(ModelID + "-" + compositionId + "-" + scenarioId);
            traceFile.Append("Initialize");
            traceFile.Append("Version: " + ModelID + " v" + version);
            traceFile.Append("Instance Address: " + instanceAddress);
            traceFile.Append("Instance Assignment: " + instanceAssignment);
            traceFile.Append("Instance Port: " + port);
            traceFile.Append("Composition ID: " + compositionId);
            traceFile.Append("Per ID: " + perId);
            traceFile.Append("Enable Prefetching: " + enablePrefetching);
            traceFile.Append("Path: " + filePath);
            traceFile.Append("ScenarioId: " + scenarioId);
            traceFile.Append("UniqueId: " + GetUniqueId());

            webServiceManager = new WebServiceManager();
            webServiceManager.Read("WebServices.xml");

            // give the instances a chance to start - PERFORMANCE STUDY
            /*int delay = 1000 * (30 + Convert.ToInt32(this.compositionId));
            this.traceFile.Append("Pausing startup: " + delay);
            System.Threading.Thread.Sleep(delay);*/

            /*if (this.compositionId == "0" && this.perId == "0")
            {
                this.traceFile.Append("NO Extended startup delay");
            }
            else
            {
                this.traceFile.Append("EXTENDED startup delay");
                System.Threading.Thread.Sleep(1000 * 60 * 15);
            }*/

            traceFile.Append("Connecting to instance");
            ConnectToInstance(instanceAddress, Convert.ToString(port), webServiceManager.WebServiceInfoList);

            traceFile.Append("Finishing startup");

            statistics = new Statistics(compositionId, perId);

            cacheManager = new CacheManager(statistics, traceFile, client, scenarioId, elementSetsPut, webServiceManager);

            initializeWasInvoked = true;

            runtimeWatch = new Stopwatch();
            runtimeWatch.Start();

            traceFile.Append("Finished initialization");
        }
コード例 #5
0
        public void Initialize(Hashtable properties)
        {
            try
            {
                // read the element set file
                var elementSets = ElementSetReader.read("ElementSets.xml");

                // read the config file
                var filename = (String)properties["ConfigFile"];
                var componentProperties = ComponentProperties.read(filename, component, elementSets);
                var extras = componentProperties.getExtras();
                foreach (var nextKey in extras.Keys)
                    properties[nextKey] = extras[nextKey];

                // save the standard properties
                _timeStepLength = componentProperties.getTimeStepInSeconds();
                _inputs = componentProperties.getInputExchangeItems();
                _outputs = componentProperties.getOutputExchangeItems();
                _simulationStartTime = componentProperties.getStartDateTime();
                _simulationEndTime = componentProperties.getEndDateTime();
                _modelId = componentProperties.getModelId();
                _modelDescription = componentProperties.getModelDescription();

                // save any extra properties
                _processingTime = Int32.Parse((String)properties["processingTime"]);

                //var c = (SimpleComponent)component;
                //c.EnableParallel = bool.Parse((string)properties["enableParallel"]);

                // setup the log file
                _traceFile = new TraceFile(_modelId);

                _traceFile.Append("Initialize");
                _traceFile.Append("Version: " + _modelId + " v" + version);
                _traceFile.Append("TimeHorizon:" + _simulationStartTime + "-" + _simulationEndTime);
                _traceFile.Append("TimeStep:" + _timeStepLength);
                _traceFile.Append("ProcessingTime:" + _processingTime);
                //_traceFile.Append("Parallel: " + c.EnableParallel);
            }
            catch (Exception e)
            {
                _traceFile.Exception(e);
            }
        }