示例#1
0
 protected void InstantiateTestingModules()
 {
     foreach (Module testingModule in Configuration.TestingModules)
     {
         try
         {
             DoLog(string.Format("Initializing Testing Module {0}", testingModule.Name), Constants.MessageType.Information);
             if (!string.IsNullOrEmpty(testingModule.Assembly))
             {
                 var moduleType = Type.GetType(testingModule.Assembly);
                 if (moduleType != null)
                 {
                     ICommunicationModule module = (ICommunicationModule)Activator.CreateInstance(moduleType);
                     module.Initialize(ProcessMessage, DoLog, testingModule.Config);
                     if (!TestingModules.ContainsKey(testingModule.Name))
                     {
                         TestingModules.Add(testingModule.Name, module);
                     }
                 }
                 else
                 {
                     throw new Exception("assembly not found: " + testingModule.Assembly);
                 }
             }
             else
             {
                 DoLog(string.Format("Testing module {0} not found. It will not be initialized", testingModule.Name), Constants.MessageType.Error);
             }
         }
         catch (Exception ex)
         {
             DoLog(string.Format("Critical error initializing module {0}:{1}", testingModule.Name, ex.Message), Constants.MessageType.Error);
         }
     }
 }
 public TaskManager(string serverIp, int serverPort, int receiveDataTimeout, int threadSleepTimeout)
 {
     communicationModule          = new CommunicationModule(serverIp, serverPort, receiveDataTimeout);
     startTime                    = DateTime.Now;
     divideProblemMessageQueue    = new Queue <DivideProblemMessage>();
     partialSolutionsMessageQueue = new Queue <SolutionsMessage>();
     this.threadSleepTimeout      = threadSleepTimeout;
 }
        /// <summary>
        /// Returns module with specified name
        /// or throw <see cref="Exceptions.ModuleNotFoundException"/> exception when module is not found.
        /// </summary>
        /// <param name="name">Communication module name.</param>
        /// <returns>Communication module.</returns>
        /// <exception cref="Exceptions.ModuleNotFoundException">Module with specified name does not exist.</exception>
        /// <exception cref="ArgumentNullException"><i>name</i> is null reference.</exception>
        public ICommunicationModule FindModule(string name)
        {
            ICommunicationModule mod = GetModule(name);

            if (mod == null)
            {
                throw new Exceptions.ModuleNotFoundException("Module not found.", name);
            }

            return(mod);
        }
示例#4
0
 public ComputationServer(TimeSpan nodeTimeout, ICommunicationModule communicationModule, int threadSleepTime)
 {
     solveRequests                  = new ConcurrentDictionary <ulong, SolveRequestMessage>();
     activeNodes                    = new Dictionary <ulong, NodeEntry>();
     finalSolutions                 = new List <SolutionsMessage>();
     partialSolutions               = new List <SolutionsMessage>();
     dividedProblems                = new List <PartialProblemsMessage>();
     DefaultTimeout                 = nodeTimeout;
     nodesId                        = 1;
     solutionId                     = 1;
     this.communicationModule       = communicationModule;
     this.processingThreadSleepTime = threadSleepTime;
     partialProblems                = new List <PartialProblemsMessage>();
     serializeMessageMethod         = typeof(ComputationServer).GetMethod("SerializeMessage");
 }
        /// <summary>
        /// Creates communication modules from configuration.
        /// </summary>
        /// <param name="configs">Collection of communication modules configuration.</param>
        /// <exception cref="ConfigurationErrorsException">Module with same name is already defined.</exception>
        public void CreateCommunicationModules(ArrayList configs)
        {
            foreach (object config in configs)
            {
                ICommunicationModule module = this.ModuleFactory.CreateModule(config as ICommunicationModuleCreator);
                module.Configuration = config as ICommunicationModuleConfiguration;

                if (GetModule(module.Configuration.Name) != null)
                {
                    throw new ConfigurationErrorsException(String.Format(CultureInfo.InvariantCulture,
                                                                         "Module with name '{0}' is already defined. Module name must be unique.",
                                                                         module.Configuration.Name));
                }

                this.CommunicationModules.Add(module);
            }
        }
        /// <summary>
        /// Creates collection of module dependancies from configuration.
        /// </summary>
        /// <param name="configDependencies">Configuration of module dependancies.</param>
        /// <returns>Collection of module dependencies as <see cref="Dictionary&lt;TKey, TValue&gt;"/> where depenandcy name is key and dependant module is value.</returns>
        /// <remarks>
        /// Returns a collection of modules that other module is dependent on from dependent module configuration.
        /// </remarks>
        /// <exception cref="ArgumentNullException"><i>configDependencies</i> is null reference.</exception>
        public Dictionary <string, ICommunicationModule> GenerateInternalDependencies(SerializableStringDictionary configDependencies)
        {
            if (configDependencies == null)
            {
                throw new ArgumentNullException("configDependencies");
            }

            Dictionary <string, ICommunicationModule> dependencies = new Dictionary <string, ICommunicationModule>();

            foreach (KeyValuePair <string, string> depInfo in configDependencies)
            {
                ICommunicationModule depModule = GetModule(depInfo.Value);
                if (depModule == null)
                {
                    throw new ConfigurationErrorsException(String.Format(CultureInfo.InvariantCulture,
                                                                         "Dependant module '{0}' not found.",
                                                                         depInfo.Value));
                }

                dependencies.Add(depInfo.Key, depModule);
            }

            return(dependencies);
        }
示例#7
0
 public ComputationClient(string ip, int port, int receiveTimeout)
 {
     communicationModule = new CommunicationModule(ip, port, receiveTimeout);
 }