Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
wim-beck committed Jan 15, 2016
1 parent ddd3b12 commit a2fddcf
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 124 deletions.
6 changes: 3 additions & 3 deletions RunConfiguration/Delay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

namespace IS4U.RunConfiguration
{
public class Delay : Step
{
public class Delay : Step
{
/// <summary>
/// Default constructor.
/// </summary>
Expand Down Expand Up @@ -59,5 +59,5 @@ public override void Run()
{
Thread.Sleep(Seconds * 1000);
}
}
}
}
14 changes: 7 additions & 7 deletions RunConfiguration/LinearSequence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@

namespace IS4U.RunConfiguration
{
/// <summary>
/// Represents a linear sequence.
/// </summary>
public class LinearSequence : Sequence
{
/// <summary>
/// Represents a linear sequence.
/// </summary>
public class LinearSequence : Sequence
{
private Logger logger = LogManager.GetLogger("");

/// <summary>
Expand Down Expand Up @@ -73,7 +73,7 @@ public LinearSequence(XElement runConfig)
Count = 0;
}

/// <summary>
/// <summary>
/// Executes a linear execution of the different steps.
/// </summary>
/// <param name="sequences">Dictionary with as keys sequence names and a list of seps as values.</param>
Expand Down Expand Up @@ -115,5 +115,5 @@ public override void Run()
Thread.Sleep(delay);
}
}
}
}
}
50 changes: 25 additions & 25 deletions RunConfiguration/ManagementAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,22 @@

namespace IS4U.RunConfiguration
{
/// <summary>
/// Represents a management agent.
/// </summary>
public class ManagementAgent : Step
{
private Logger logger = LogManager.GetLogger("");
/// <summary>
/// Represents a management agent.
/// </summary>
public class ManagementAgent : Step
{
private Logger logger = LogManager.GetLogger("");

/// <summary>
/// Default constructor.
/// </summary>
public ManagementAgent() { }
/// <summary>
/// Default constructor.
/// </summary>
public ManagementAgent() { }

/// <summary>
/// Initialize method. This will initialize the default run profile.
/// Since this step does not has to run different steps, the dictionary is not used.
/// </summary>
/// <summary>
/// Initialize method. This will initialize the default run profile.
/// Since this step does not has to run different steps, the dictionary is not used.
/// </summary>
/// <param name="sequences">Dictionary with as keys sequence names and a list of seps as values.</param>
/// <param name="defaultProfile">Default run profile.</param>
/// <param name="count">Number of times this method is called.</param>
Expand All @@ -49,23 +49,23 @@ public override void Initialize(Dictionary<string, Sequence> sequences, string d
DefaultRunProfile = defaultProfile;
}

/// <summary>
/// Runs the default run profile of the run configuration (initialized before) or a predefined run profile
/// (stored in the Action variable).
/// </summary>
/// <summary>
/// Runs the default run profile of the run configuration (initialized before) or a predefined run profile
/// (stored in the Action variable).
/// </summary>
/// <param name="sequences">Dictionary with as keys sequence names and a list of seps as values.</param>
/// <param name="defaultProfile">Default run profile.</param>
/// <param name="count">Number of times this method is called.</param>
/// <param name="configParameters">Global configuration parameters.</param>
public override void Run(Dictionary<string, Sequence> sequences, string defaultProfile, int count, GlobalConfig configParameters)
{
{
string runProfile = defaultProfile;
if (!string.IsNullOrEmpty(Action))
{
runProfile = Action;
}
if (!string.IsNullOrEmpty(Action))
{
runProfile = Action;
}
run(runProfile);
}
}

/// <summary>
/// Runs the default run profile of the run configuration (initialized before) or a predefined run profile
Expand Down Expand Up @@ -110,5 +110,5 @@ private void run(string runProfile)
logger.Error(message);
}
}
}
}
}
24 changes: 12 additions & 12 deletions RunConfiguration/ParallelSequence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,33 @@

namespace IS4U.RunConfiguration
{
/// <summary>
/// Represents a parallel sequence.
/// </summary>
public class ParallelSequence : Sequence
{
/// <summary>
/// Represents a parallel sequence.
/// </summary>
public class ParallelSequence : Sequence
{
private Logger logger = LogManager.GetLogger("");

/// <summary>
/// Default constructor.
/// </summary>
public ParallelSequence() : base() { }

/// <summary>
/// Starts a thread for each step it needs to run.
/// </summary>
/// <summary>
/// Starts a thread for each step it needs to run.
/// </summary>
/// <param name="sequences">Dictionary with as keys sequence names and a list of seps as values.</param>
/// <param name="defaultProfile">Default run profile.</param>
/// <param name="count">Number of times this method is called.</param>
/// <param name="configParameters">Global configuration parameters.</param>
public override void Run(Dictionary<string, Sequence> sequences, string defaultProfile, int count, GlobalConfig configParameters)
{
{
string runProfile = defaultProfile;
if (!string.IsNullOrEmpty(Action))
{
runProfile = Action;
}
int delay = ConfigParameters.DelayInParallelSequence * 1000;
int delay = ConfigParameters.DelayInParallelSequence * 1000;
List<Thread> threads = new List<Thread>();

if (sequences.ContainsKey(Name))
Expand All @@ -76,7 +76,7 @@ public override void Run(Dictionary<string, Sequence> sequences, string defaultP
{
logger.Error(string.Format("Sequence '{0}' not found.", Name));
}
}
}

/// <summary>
///
Expand All @@ -85,5 +85,5 @@ public override void Run()
{
throw new Exception("Object of type ParallelSequence does not support run operation without parameters.");
}
}
}
}
154 changes: 77 additions & 77 deletions RunConfiguration/RunJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,84 +26,84 @@

namespace IS4U.RunConfiguration
{
/// <summary>
/// Job to run the run configurations that are triggered by the scheduler.
/// Jobs are not allowed to run concurrent, only one job of this type will be executing on the same time.
/// </summary>
[DisallowConcurrentExecution]
public class RunJob : IInterruptableJob
{
private SchedulerConfig schedulerConfig;
private Logger logger = LogManager.GetLogger("");
/// <summary>
/// Job to run the run configurations that are triggered by the scheduler.
/// Jobs are not allowed to run concurrent, only one job of this type will be executing on the same time.
/// </summary>
[DisallowConcurrentExecution]
public class RunJob : IInterruptableJob
{
private SchedulerConfig schedulerConfig;
private Logger logger = LogManager.GetLogger("");

/// <summary>
/// Execute the run profile specified in the job data map of the trigger.
/// </summary>
/// <param name="context">Job execution context.</param>
public void Execute(IJobExecutionContext context)
{
try
{
if (context.Trigger.JobDataMap.ContainsKey("RunConfigName"))
{
string workingDirectory = string.Empty;
using (RegistryKey key = Registry.LocalMachine.OpenSubKey(Constant.SCHEDULER_KEY, false))
{
if (key != null)
{
workingDirectory = key.GetValue("Location").ToString();
}
}
if (!string.IsNullOrEmpty(workingDirectory))
{
string runConfig = context.Trigger.JobDataMap.GetString("RunConfigName");
schedulerConfig = new SchedulerConfig(Path.Combine(workingDirectory, Constant.RUN_CONFIG_FILE));
if (schedulerConfig != null)
{
schedulerConfig.Run(runConfig);
}
else
{
logger.Error("Scheduler configuration not found.");
throw new JobExecutionException("Scheduler configuration not found.");
}
}
else
{
logger.Error("Working directory not found.");
throw new JobExecutionException("Working directory not found.");
}
}
else
{
logger.Error("No run configuration specified.");
throw new JobExecutionException("No run configuration specified.");
}
}
catch (Exception ex)
{
/// <summary>
/// Execute the run profile specified in the job data map of the trigger.
/// </summary>
/// <param name="context">Job execution context.</param>
public void Execute(IJobExecutionContext context)
{
try
{
if (context.Trigger.JobDataMap.ContainsKey("RunConfigName"))
{
string workingDirectory = string.Empty;
using (RegistryKey key = Registry.LocalMachine.OpenSubKey(Constant.SCHEDULER_KEY, false))
{
if (key != null)
{
workingDirectory = key.GetValue("Location").ToString();
}
}
if (!string.IsNullOrEmpty(workingDirectory))
{
string runConfig = context.Trigger.JobDataMap.GetString("RunConfigName");
schedulerConfig = new SchedulerConfig(Path.Combine(workingDirectory, Constant.RUN_CONFIG_FILE));
if (schedulerConfig != null)
{
schedulerConfig.Run(runConfig);
}
else
{
logger.Error("Scheduler configuration not found.");
throw new JobExecutionException("Scheduler configuration not found.");
}
}
else
{
logger.Error("Working directory not found.");
throw new JobExecutionException("Working directory not found.");
}
}
else
{
logger.Error("No run configuration specified.");
throw new JobExecutionException("No run configuration specified.");
}
}
catch (Exception ex)
{
logger.Error(string.Concat("Unknown error: ", ex.Message, ex.StackTrace));
throw new JobExecutionException(string.Concat("Unknown error: ", ex.Message));
}
}
throw new JobExecutionException(string.Concat("Unknown error: ", ex.Message));
}
}

/// <summary>
/// Interrupt this job. Invoke 'Stop' on all management agents.
/// </summary>
public void Interrupt()
{
ManagementScope mgmtScope = new ManagementScope(Constant.FIM_WMI_NAMESPACE);
SelectQuery query = new SelectQuery(string.Format("Select * from MIIS_ManagementAgent"));
using (ManagementObjectSearcher searcher = new ManagementObjectSearcher(mgmtScope, query))
{
foreach (ManagementObject obj in searcher.Get())
{
using (ManagementObject wmiMaObject = obj)
{
wmiMaObject.InvokeMethod("Stop", new object[] { });
}
}
}
}
}
/// <summary>
/// Interrupt this job. Invoke 'Stop' on all management agents.
/// </summary>
public void Interrupt()
{
ManagementScope mgmtScope = new ManagementScope(Constant.FIM_WMI_NAMESPACE);
SelectQuery query = new SelectQuery(string.Format("Select * from MIIS_ManagementAgent"));
using (ManagementObjectSearcher searcher = new ManagementObjectSearcher(mgmtScope, query))
{
foreach (ManagementObject obj in searcher.Get())
{
using (ManagementObject wmiMaObject = obj)
{
wmiMaObject.InvokeMethod("Stop", new object[] { });
}
}
}
}
}
}

0 comments on commit a2fddcf

Please sign in to comment.