protected void InjectDeployments(ActorSystem system, RoleName role)
{
var deployer = Sys.AsInstanceOf<ExtendedActorSystem>().Provider.Deployer;
foreach (var str in _deployments(role))
{
var deployString = _replacements.Values.Aggregate(str, (@base, r) =>
{
var indexOf = @base.IndexOf(r.Tag, StringComparison.Ordinal);
if (indexOf == -1) return @base;
string replaceWith;
try
{
replaceWith = r.Addr;
}
catch (Exception e)
{
// might happen if all test cases are ignored (excluded) and
// controller node is finished/exited before r.addr is run
// on the other nodes
var unresolved = "akka://unresolved-replacement-" + r.Role.Name;
Log.Warning(unresolved + " due to: {0}", e.ToString());
replaceWith = unresolved;
}
return @base.Replace(r.Tag, replaceWith);
});
foreach (var pair in ConfigurationFactory.ParseString(deployString).AsEnumerable())
{
if (pair.Value.IsObject())
{
var deploy =
deployer.ParseConfig(pair.Key, new Config(new HoconRoot(pair.Value)));
deployer.SetDeploy(deploy);
}
else
{
throw new ArgumentException(String.Format("key {0} must map to deployment section, not simple value {1}",
pair.Key, pair.Value));
}
}
}
}