Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/lithnet/miis-autosync
Browse files Browse the repository at this point in the history
  • Loading branch information
ryannewington committed Apr 28, 2018
2 parents b5cac85 + 3f64544 commit 762e59e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ internal void ResolvePartitions(ManagementAgent ma)
{
if (c.ID == p.ID || string.Equals(c.Name, p.Name, StringComparison.OrdinalIgnoreCase))
{
logger.Trace($"Matched existing partition {c.ID}/{p.ID}/{c.Name}/{p.Name}");
c.UpdateConfiguration(p);
found = true;
break;
Expand All @@ -78,16 +79,20 @@ internal void ResolvePartitions(ManagementAgent ma)

if (!found)
{
logger.Trace($"Partition is missing from MA {c.ID}/{c.Name}");
c.IsMissing = true;
}
}

foreach (Partition p in ma.Partitions.Values.Where(t => t.Selected && this.Partitions.GetItemOrNull(t.ID) == null))
{
logger.Trace($"New partition found in MA {p.ID}/{p.Name}");
PartitionConfiguration c = new PartitionConfiguration(p);
MAConfigDiscovery.DoAutoRunProfileDiscovery(c, ma);
this.Partitions.Add(c);
}

logger.Trace($"{this.Partitions.Count} partitions are defined for the controller");
}

[DataMember(Name = "partitions")]
Expand Down Expand Up @@ -153,6 +158,14 @@ internal string GetRunProfileName(MARunProfileType type, string partitionName)
return null;
}

if (!p.IsActive)
{
logger.Warn($"Could not map run profile {type} for partition {partitionName} ({p.ID}) because the partition is not active");
return null;
}

logger.Trace($"Found partition {p.ID} from name {partitionName}");

return this.GetRunProfileName(type, p);
}

Expand All @@ -161,7 +174,7 @@ internal string GetRunProfileName(MARunProfileType type, PartitionConfiguration
switch (type)
{
case MARunProfileType.DeltaImport:
return partition.ScheduledImportRunProfileName;
return partition.DeltaImportRunProfileName;

case MARunProfileType.FullImport:
return partition.FullImportRunProfileName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public PartitionConfiguration GetItemOrNull(Guid partitionID)

public PartitionConfiguration GetItemOrNull(string name)
{
return this.FirstOrDefault(t => t.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase));
return this.SingleOrDefault(t => t.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase));
}

public PartitionConfiguration GetDefaultOrFirstActivePartition()
Expand Down

0 comments on commit 762e59e

Please sign in to comment.