本文整理汇总了C#中GrainId.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# GrainId.ToString方法的具体用法?C# GrainId.ToString怎么用?C# GrainId.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GrainId
的用法示例。
在下文中一共展示了GrainId.ToString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessActivationRequest
public async Task<RemoteClusterActivationResponse> ProcessActivationRequest(GrainId grain, string requestClusterId, int hopCount = 0)
{
// check if the requesting cluster id is in the current configuration view of this cluster
// if not, reject the message.
var multiClusterConfiguration = Runtime.Silo.CurrentSilo.LocalMultiClusterOracle?.GetMultiClusterConfiguration();
if (multiClusterConfiguration == null || !multiClusterConfiguration.Clusters.Contains(requestClusterId))
{
logger.Warn(ErrorCode.GlobalSingleInstance_WarningInvalidOrigin,
"GSIP:Rsp {0} Origin={1} GSI request rejected because origin is not in MC configuration", grain.ToString(), requestClusterId);
return new RemoteClusterActivationResponse(ActivationResponseStatus.Failed);
}
var forwardAddress = router.CheckIfShouldForward(grain, 0, "ProcessActivationRequest");
// on all silos other than first, we insert a retry delay and recheck owner before forwarding
if (hopCount > 0 && forwardAddress != null)
{
await Task.Delay(LocalGrainDirectory.RETRY_DELAY);
forwardAddress = router.CheckIfShouldForward(grain, hopCount, "ProcessActivationRequest(recheck)");
}
if (forwardAddress == null)
{
return ProcessRequestLocal(grain, requestClusterId);
}
else
{
if (logger.IsVerbose2)
logger.Verbose("GSIP:Rsp {0} Origin={1} forward to {2}", grain.ToString(), requestClusterId, forwardAddress);
var clusterGrainDir = InsideRuntimeClient.Current.InternalGrainFactory.GetSystemTarget<IClusterGrainDirectory>(Constants.ClusterDirectoryServiceId, forwardAddress);
return await clusterGrainDir.ProcessActivationRequest(grain, requestClusterId, hopCount + 1);
}
}
示例2: Start
internal async Task Start(StatisticsProviderManager statsManager, IMessageCenter transport, GrainId clientId)
{
runtimeStats.Start();
// Configure Metrics
IProvider statsProvider = null;
if (!string.IsNullOrEmpty(config.StatisticsProviderName))
{
var extType = config.StatisticsProviderName;
statsProvider = statsManager.GetProvider(extType);
var metricsDataPublisher = statsProvider as IClientMetricsDataPublisher;
if (metricsDataPublisher == null)
{
var msg = String.Format("Trying to create {0} as a metrics publisher, but the provider is not configured."
, extType);
throw new ArgumentException(msg, "ProviderType (configuration)");
}
var configurableMetricsDataPublisher = metricsDataPublisher as IConfigurableClientMetricsDataPublisher;
if (configurableMetricsDataPublisher != null)
{
configurableMetricsDataPublisher.AddConfiguration(
config.DeploymentId, config.DNSHostName, clientId.ToString(), transport.MyAddress.Endpoint.Address);
}
tableStatistics = new ClientTableStatistics(transport, metricsDataPublisher, runtimeStats)
{
MetricsTableWriteInterval = config.StatisticsMetricsTableWriteInterval
};
}
else if (config.UseAzureSystemStore)
{
// Hook up to publish client metrics to Azure storage table
var publisher = AssemblyLoader.LoadAndCreateInstance<IClientMetricsDataPublisher>(Constants.ORLEANS_AZURE_UTILS_DLL, logger);
await publisher.Init(config, transport.MyAddress.Endpoint.Address, clientId.ToParsableString());
tableStatistics = new ClientTableStatistics(transport, publisher, runtimeStats)
{
MetricsTableWriteInterval = config.StatisticsMetricsTableWriteInterval
};
}
// Configure Statistics
if (config.StatisticsWriteLogStatisticsToTable)
{
if (statsProvider != null)
{
logStatistics.StatsTablePublisher = statsProvider as IStatisticsPublisher;
// Note: Provider has already been Init-ialized above.
}
else if (config.UseAzureSystemStore)
{
var statsDataPublisher = AssemblyLoader.LoadAndCreateInstance<IStatisticsPublisher>(Constants.ORLEANS_AZURE_UTILS_DLL, logger);
await statsDataPublisher.Init(false, config.DataConnectionString, config.DeploymentId,
transport.MyAddress.Endpoint.ToString(), clientId.ToParsableString(), config.DNSHostName);
logStatistics.StatsTablePublisher = statsDataPublisher;
}
}
logStatistics.Start();
}
示例3: RemoveGrain
/// <summary>
/// Removes the grain (and, effectively, all its activations) from the diretcory
/// </summary>
/// <param name="grain"></param>
internal void RemoveGrain(GrainId grain)
{
lock (lockable)
{
partitionData.Remove(grain);
}
if (log.IsVerbose3) log.Verbose3("Removing grain {0}", grain.ToString());
}
示例4: RemoveActivation
/// <summary>
/// Removes an activation of the given grain from the partition
/// </summary>
/// <param name="grain"></param>
/// <param name="activation"></param>
/// <param name="force"></param>
internal void RemoveActivation(GrainId grain, ActivationId activation, bool force)
{
lock (lockable)
{
if (partitionData.ContainsKey(grain) && partitionData[grain].RemoveActivation(activation, force))
{
partitionData.Remove(grain);
}
}
if (log.IsVerbose3) log.Verbose3("Removing activation for grain {0}", grain.ToString());
}
示例5: AddActivation
/// <summary>
/// Adds a new activation to the directory partition
/// </summary>
/// <param name="grain"></param>
/// <param name="activation"></param>
/// <param name="silo"></param>
/// <returns>The version associated with this directory mapping</returns>
internal virtual int AddActivation(GrainId grain, ActivationId activation, SiloAddress silo)
{
if (!IsValidSilo(silo))
{
return GrainInfo.NO_ETAG;
}
lock (lockable)
{
if (!partitionData.ContainsKey(grain))
{
partitionData[grain] = new GrainInfo();
}
partitionData[grain].AddActivation(activation, silo);
}
if (log.IsVerbose3) log.Verbose3("Adding activation for grain {0}", grain.ToString());
return partitionData[grain].VersionTag;
}
示例6: RemoveActivation
/// <summary>
/// Removes an activation of the given grain from the partition
/// </summary>
/// <param name="grain">the identity of the grain</param>
/// <param name="activation">the id of the activation</param>
/// <param name="cause">reason for removing the activation</param>
/// <param name="entry">returns the entry, if found </param>
/// <param name="wasRemoved">returns whether the entry was actually removed</param>
internal void RemoveActivation(GrainId grain, ActivationId activation, UnregistrationCause cause, out IActivationInfo entry, out bool wasRemoved)
{
wasRemoved = false;
entry = null;
lock (lockable)
{
if (partitionData.ContainsKey(grain) && partitionData[grain].RemoveActivation(activation, cause, out entry, out wasRemoved))
// if the last activation for the grain was removed, we remove the entire grain info
partitionData.Remove(grain);
}
if (log.IsVerbose3)
log.Verbose3("Removing activation for grain {0} cause={1} was_removed={2}", grain.ToString(), cause, wasRemoved);
}
示例7: ProcessRequestLocal
private RemoteClusterActivationResponse ProcessRequestLocal(GrainId grain, string requestClusterId)
{
RemoteClusterActivationResponse response;
//This function will be called only on the Owner silo.
try
{
ActivationAddress address;
int version;
GrainDirectoryEntryStatus existingActivationStatus = router.DirectoryPartition.TryGetActivation(grain, out address, out version);
//Return appropriate protocol response, given current mc status
switch (existingActivationStatus)
{
case GrainDirectoryEntryStatus.Invalid:
response = RemoteClusterActivationResponse.Pass;
break;
case GrainDirectoryEntryStatus.Owned:
response = new RemoteClusterActivationResponse(ActivationResponseStatus.Failed)
{
ExistingActivationAddress = new AddressAndTag()
{
Address = address,
VersionTag = version
},
ClusterId = clusterId,
Owned = true
};
break;
case GrainDirectoryEntryStatus.Cached:
case GrainDirectoryEntryStatus.RaceLoser:
response = RemoteClusterActivationResponse.Pass;
break;
case GrainDirectoryEntryStatus.RequestedOwnership:
case GrainDirectoryEntryStatus.Doubtful:
var iWin = MultiClusterUtils.ActivationPrecedenceFunc(grain, clusterId, requestClusterId);
if (iWin)
{
response = new RemoteClusterActivationResponse(ActivationResponseStatus.Failed)
{
ExistingActivationAddress = new AddressAndTag()
{
Address = address,
VersionTag = version
},
ClusterId = clusterId,
Owned = false
};
}
else
{
response = RemoteClusterActivationResponse.Pass;
//update own activation status to race loser.
if (existingActivationStatus == GrainDirectoryEntryStatus.RequestedOwnership)
{
logger.Verbose2("GSIP:Rsp {0} Origin={1} RaceLoser", grain.ToString(), requestClusterId);
var success = router.DirectoryPartition.UpdateClusterRegistrationStatus(grain, address.Activation, GrainDirectoryEntryStatus.RaceLoser, GrainDirectoryEntryStatus.RequestedOwnership);
if (!success)
{
// there was a race. retry.
logger.Verbose2("GSIP:Rsp {0} Origin={1} Retry", grain.ToString(), requestClusterId);
return ProcessRequestLocal(grain, requestClusterId);
}
}
}
break;
default:
throw new InvalidOperationException("Invalid MultiClusterStatus value");
}
}
catch (Exception ex)
{
//LOG exception
response = new RemoteClusterActivationResponse(ActivationResponseStatus.Faulted)
{
ResponseException = ex
};
}
if (logger.IsVerbose)
logger.Verbose("GSIP:Rsp {0} Origin={1} Result={2}", grain.ToString(), requestClusterId, response);
return response;
}
示例8: AddActivation
/// <summary>
/// Adds a new activation to the directory partition
/// </summary>
/// <param name="grain"></param>
/// <param name="activation"></param>
/// <param name="silo"></param>
/// <returns>The version associated with this directory mapping</returns>
internal virtual int AddActivation(GrainId grain, ActivationId activation, SiloAddress silo)
{
if (!IsValidSilo(silo))
{
return GrainInfo.NO_ETAG;
}
IGrainInfo grainInfo;
lock (lockable)
{
if (!partitionData.TryGetValue(grain, out grainInfo))
{
partitionData[grain] = grainInfo = new GrainInfo();
}
grainInfo.AddActivation(activation, silo);
}
if (log.IsVerbose3) log.Verbose3("Adding activation for grain {0}", grain.ToString());
return grainInfo.VersionTag;
}