Custom Locking
Sometimes it is necessary to create a customized schedule step. Often the primary requirement is a need to customize locking. For example:
- You may have an ECMA 2 MA that must run imports and exports exclusively with no other MAs running (such as the Microsoft Lotus Notes MA)
- You may need to coordinate an MA between two different MIM servers so they are not e.g. importing and exporting on the same table at the same time on two different servers.
- You may have a run program step that can't run at the same time as a particular MA or that can't run at the same time as a related task on another server.
All the above requirements can be met by sub-classing an existing schedule step definition and overriding the list of locks. This is because the Identity Panel scheduler provides for schedule step isolation based on the Shared and Exclusive step locks.
Creating a Custom Step
- Start a new C# class library project in Visual Studio. Choose a project name with the form "SoftwareIDM.<name>". This is because the run-step loading mechanism only reads assemblies that start with the SoftwareIDM namespace.
- Add references to SoftwareIDM.PanelModel.dll, and SoftwareIDM.SyncModel.dll. These may be found in C:\Program Files\SoftwareIDM\PanelTools\lib on a server with Panel Service installed.
- Create a .cs class file to implement your custom step, and add the following includes:
using System;
using System.Reflection;
using SoftwareIDM.PanelModel.Attributes;
using SoftwareIDM.PanelModel.Models;
using SoftwareIDM.SyncModel.Extension; - Implement the IKnownTypes interface, and sub-class a schedule step (such as RunMA). See below for a sample implementation that runs an MA without allowing overlap with any other MAs on the same server.
- Build the project and copy the output extension to Identity Panel web server: C:\Program Files\SoftwareIDM\IdentityPanelWeb\Web
- Edit config.json: go to the types section, and add a new line in the form: "Custom": "SoftwareIDM.Custom.ModelTypes, SoftwareIDM.Custom"
Sample Step
public class ModelTypes : IKnownTypes { public IEnumerable Types<Type>() { foreach (var type in Assembly.GetExecutingAssembly().ExportedTypes) { if (type.GetCustomAttribute<ClassDoc>() != null) { yield return type; } } } } [ClassDoc(Name = "Exclusive Run MA", Description = "Sub-class run Run MA that locks entire environment.")] public class ExclusiveMARun : RunMA { /// /// Exclusive on Environment regardless of step type /// public override List<ScheduleLock> Locks(string scheduler) { return new List<ScheduleLock>() { new ScheduleLock(Environment.ToString(), ScheduleLockLevel.Exclusive) }; } public override Type RunType() { return PanelModel.Helpers.TypeHelper.Get("Extension", "RunMA", "SyncClient"); } }
Comments
0 comments
Please sign in to leave a comment.