-
Notifications
You must be signed in to change notification settings - Fork 4
plugin sdk server management
Plugins run as roles that can be assigned to multiple servers for high availability and failover.
Plugin Role
↓
Assigned to Server A (Priority 1)
Assigned to Server B (Priority 2)
Assigned to Server C (Priority 3)
↓
Runs on highest priority available server
↓
Fails over to next server if current fails
Key concepts:
- Plugins are roles that can run on multiple servers
- Priority determines which server runs the plugin
- Automatic failover to next priority server on failure
- Manual server selection supported
- Server rejection allows plugins to control where they run
Servers are assigned to plugin roles in Config Tool:
Path: System → Roles → [Plugin Role] → Properties → Servers
Administrators can:
- Add/remove servers
- Set server priorities
- Enable/disable automatic failover
- Manually select running server
Servers have priority levels (1 = highest):
Priority 1: Primary server (preferred)
Priority 2: Secondary server (backup)
Priority 3: Tertiary server (last resort)
Automatic failover behavior:
- Plugin runs on highest priority available server
- If that server fails, plugin fails over to next priority
- When higher priority server recovers, plugin can failover back (if enabled)
Automatically switches to highest priority server when available:
protected override void OnPluginLoaded()
{
// Enable automatic priority-based failover
SetForceExecutionByPriority(true);
}When enabled:
- Plugin always runs on highest priority available server
- Automatically fails back to higher priority servers when they recover
- Good for active-passive failover scenarios
When disabled:
- Plugin stays on current server until failure
- Manual intervention required to switch servers
- Good for active-active scenarios
Administrator manually controls which server runs the plugin:
// Get current server
Guid currentServer = GetCurrentServer();
// Manually switch to different server
SetCurrentServer(targetServerGuid);Use cases:
- Maintenance operations
- Load balancing
- Testing
- Troubleshooting
Available through Plugin base class:
Returns GUID of server currently running the plugin:
protected override void OnPluginLoaded()
{
Guid serverGuid = GetCurrentServer();
var server = Engine.GetEntity<Server>(serverGuid);
Logger.TraceInformation($"Plugin running on server: {server.Name}");
}Returns:
- Server GUID
Returns information about all assigned servers:
protected override void OnPluginLoaded()
{
Dictionary<Guid, ServerInfos> servers = GetServersInfo();
foreach (var kvp in servers)
{
Guid serverGuid = kvp.Key;
ServerInfos info = kvp.Value;
Logger.TraceInformation($"Server: {serverGuid}, Order: {info.Order}");
}
}ServerInfos properties:
-
Order- Server priority order (lower numbers = higher priority) -
NetworkBinding- Network binding configuration for the server
Programmatically add a server to the role:
private void AddBackupServer(Guid serverGuid)
{
AddServer(serverGuid);
Logger.TraceInformation($"Added server {serverGuid} to plugin role");
}Considerations:
- Server must exist in system
- Duplicate adds are ignored
- Priority assigned automatically (lowest available)
- Config Tool reflects change immediately
Remove a server from the role:
private void RemoveServer(Guid serverGuid)
{
RemoveRoleServer(serverGuid);
Logger.TraceInformation($"Removed server {serverGuid} from plugin role");
}Considerations:
- Cannot remove server if plugin is currently running on it
- Must switch to different server first
- Config Tool reflects change immediately
Manually switch to specific server:
private void FailoverToBackup(Guid backupServerGuid)
{
Logger.TraceInformation($"Failing over to backup server {backupServerGuid}");
SetCurrentServer(backupServerGuid);
}Behavior:
- Stops plugin on current server
- Starts plugin on target server
- May cause brief service interruption
- Target server must be in role's server list
Important
SetCurrentServer throws if ForceExecutionByPriority is enabled. Disable it first with SetForceExecutionByPriority(false) before manually switching servers.
Control automatic priority-based failover:
protected override void OnPluginLoaded()
{
// Enable automatic failover to highest priority server
SetForceExecutionByPriority(true);
}Effect:
-
true- Auto-failover to highest priority available server -
false- Stay on current server until failure
Plugins can reject servers that don't meet requirements:
Reject current server and trigger failover:
protected override void OnPluginLoaded()
{
if (!ValidateServerRequirements())
{
Guid currentServer = GetCurrentServer();
RejectServer(currentServer, "Required hardware not available");
Logger.TraceWarning($"Rejected server {currentServer}");
return; // Don't continue initialization
}
// Server meets requirements
AcceptServer(GetCurrentServer());
}When rejected:
- Plugin stops on rejected server
- Security Center attempts to start plugin on next priority server
- Rejection reason logged and visible in Config Tool
- Server remains in role's server list but marked as rejected
Explicitly accept current server:
protected override void OnPluginLoaded()
{
if (ValidateServerRequirements())
{
AcceptServer(GetCurrentServer());
Logger.TraceInformation("Server accepted");
}
}When to use:
- After validating server requirements
- Confirms plugin can run on this server
- Good practice for explicit acceptance
Hardware requirements:
private bool ValidateServerRequirements()
{
// Check for required hardware
if (!IsSerialPortAvailable())
{
Logger.TraceError("Serial port not available");
return false;
}
// Check for required network access
if (!CanReachExternalSystem())
{
Logger.TraceError("Cannot reach external system");
return false;
}
return true;
}Resource requirements:
private bool ValidateServerRequirements()
{
// Check available memory
var availableMemory = GetAvailableMemory();
if (availableMemory < RequiredMemoryMB)
{
Logger.TraceError($"Insufficient memory: {availableMemory}MB < {RequiredMemoryMB}MB");
return false;
}
// Check disk space
var availableDisk = GetAvailableDiskSpace();
if (availableDisk < RequiredDiskSpaceGB)
{
Logger.TraceError($"Insufficient disk space");
return false;
}
return true;
}Software requirements:
private bool ValidateServerRequirements()
{
// Check for required assemblies
if (!IsAssemblyAvailable("ThirdParty.Hardware.dll"))
{
Logger.TraceError("Required assembly not found");
return false;
}
// Check for required services
if (!IsServiceRunning("RequiredService"))
{
Logger.TraceError("Required Windows service not running");
return false;
}
return true;
}Plugin running on Server A
↓
Server A fails or priority changes
↓
1. Dispose() called on Server A
↓
2. Plugin stops on Server A
↓
3. Constructor called on Server B
↓
4. Initialize() called on Server B
↓
5. OnPluginLoaded() called on Server B
↓
6. OnPluginStart() called on Server B
↓
Plugin running on Server B
Important
- Complete lifecycle executes on each server
- No state automatically transferred between servers
- Must persist state externally (database, file share)
- Each instance is independent
Use database:
public class MyPlugin : Plugin, IPluginDatabaseSupport
{
protected override void OnPluginStart()
{
// Load state from database
LoadStateFromDatabase();
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
// Save state to database
SaveStateToDatabase();
}
}
}Use configuration:
protected override void OnPluginLoaded()
{
// Load state from configuration
var config = LoadConfiguration();
RestoreState(config.SavedState);
}
private void OnStateChanged()
{
// Persist state to configuration
var config = LoadConfiguration();
config.SavedState = CaptureState();
UpdateConfiguration(config);
}For plugins that don't require failover (stateless operations):
protected override void OnPluginLoaded()
{
// Disable automatic failover
SetForceExecutionByPriority(false);
// Each instance processes independently
StartProcessingQueue();
}Use cases:
- Stateless query processing
- Parallel data processing
- Distributed workloads
protected override void OnPluginLoaded()
{
Guid currentServer = GetCurrentServer();
var server = Engine.GetEntity<Server>(currentServer);
// Configure based on server location
if (server.CustomProperties.Contains("Location:Europe"))
{
ConfigureForEuropeRegion();
}
else if (server.CustomProperties.Contains("Location:Asia"))
{
ConfigureForAsiaRegion();
}
}- Plugin SDK Overview - Plugin architecture
- Plugin SDK Lifecycle - Lifecycle during failover
- Plugin SDK Database - Persisting state across servers
- Plugin SDK State Management - Reporting server status
-
Security Center SDK Developer Guide Overview of the SDK framework and how to build integrations with Security Center.
-
Platform SDK
- Platform SDK Overview Introduction to the Platform SDK and core concepts.
- SDK Certificates Details certificates, licensing, and connection validation.
- Entity Guide Explains the core entity model, inheritance, and how to work with entities.
- Entity Cache Guide Describes the engine's local entity cache and synchronization.
- SDK Transactions Covers batching operations for performance and consistency.
- ReportManager Querying entities and activity data from Security Center.
- Events and Actions Subscribing to events and handling actions.
- Logging with the Genetec SDK How to configure logging, diagnostics, and debug methods.
- Referencing SDK Assemblies Best practices for referencing assemblies and resolving them at runtime.
- SDK Compatibility Guide Understanding backward compatibility and versioning in the SDK.
-
Plugin SDK
- Plugin SDK Overview Introduction to plugin architecture and capabilities.
- Plugin SDK Certificates SDK certificate requirements for plugin roles.
- Plugin SDK Lifecycle Initialization and disposal patterns.
- Plugin SDK Threading Threading model, QueueUpdate, and async patterns.
- Plugin SDK Configuration Configuration storage and monitoring.
- Plugin SDK Restricted Configuration Secure credential storage and admin-only configuration.
- Plugin SDK Database Database integration and schema management.
- Plugin SDK Events Event subscription and handling.
- Plugin SDK Queries Query processing and response handling.
- Plugin SDK Request Manager Request/response communication with clients.
- Plugin SDK Entity Ownership Understanding plugin-owned entities, running state management, and ownership release.
- Plugin SDK Entity Mappings Using EntityMappings for plugin-specific configuration and external system integration.
- Plugin SDK State Management Reporting plugin health and diagnostics.
- Plugin SDK Server Management High availability and server failover.
- Custom Privileges Defining and enforcing custom privileges.
- Resolving Non-SDK Assemblies Handling third-party dependencies in plugins and workspace modules.
- Deploying Plugins Registering and deploying plugins and workspace modules.
-
- Macro SDK Developer Guide Complete guide to creating server-side automation scripts in Security Center using C#.
- Getting Started Setup, authentication, and basic configuration for the Web SDK.
- Referencing Entities Entity discovery, search capabilities, and parameter formats.
- Entity Operations CRUD operations, multi-value fields, and method execution.
- Partitions Managing partitions, entity membership, and user access control.
- Custom Fields Creating, reading, writing, and filtering custom entity fields.
- Custom Card Formats Managing custom credential card format definitions.
- Actions Control operations for doors, cameras, macros, and notifications.
- Events and Alarms Real-time event monitoring, alarm monitoring, and custom events.
- Incidents Incident management, creation, and attachment handling.
- Reports Activity reports, entity queries, and historical data retrieval.
- Performance Guide Optimization tips and best practices for efficient API usage.
- Reference Entity GUIDs, EntityType enumeration, and EventType enumeration.
- Under the Hood Technical architecture, query reflection, and SDK internals.
- Troubleshooting Common error resolution and debugging techniques.
- Media Gateway Guide Setup and configuration of the Media Gateway role for video streaming.
- Web Player Guide Complete guide to integrating GWP for live and playback video streaming.
- Web Player API Reference Full API documentation with interfaces, methods, properties, and events.
- Web Player Sample Application Comprehensive demo showcasing all GWP features with timeline and PTZ controls.
- Genetec Web Player Multiplexing Sample Multi-camera grid demo using a shared WebSocket connection.