本文整理汇总了C#中ActivationId类的典型用法代码示例。如果您正苦于以下问题:C# ActivationId类的具体用法?C# ActivationId怎么用?C# ActivationId使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ActivationId类属于命名空间,在下文中一共展示了ActivationId类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetAddress
public static ActivationAddress GetAddress(SiloAddress silo, GrainId grain, ActivationId activation, MultiClusterStatus status = MultiClusterStatus.Owned)
{
// Silo part is not mandatory
if (grain == null) throw new ArgumentNullException("grain");
return new ActivationAddress(silo, grain, activation, status);
}
示例2: GetAddress
public static ActivationAddress GetAddress(SiloAddress silo, GrainId grain, ActivationId activation)
{
// Silo part is not mandatory
if (grain == null) throw new ArgumentNullException("grain");
return new ActivationAddress(silo, grain, activation);
}
示例3: ActivationAddress
private ActivationAddress(SiloAddress silo, GrainId grain, ActivationId activation, MultiClusterStatus status)
{
Silo = silo;
Grain = grain;
Activation = activation;
Status = status;
}
示例4: AddSingleActivation
public ActivationAddress AddSingleActivation(GrainId grain, ActivationId act, SiloAddress silo)
{
SingleInstance = true;
if (Instances.Count > 0)
{
var item = Instances.First();
return ActivationAddress.GetAddress(item.Value.SiloAddress, grain, item.Key);
}
else
{
Instances.Add(act, new ActivationInfo(silo));
VersionTag = rand.Next();
return ActivationAddress.GetAddress(silo, grain, act);
}
}
示例5: AddSingleActivation
public ActivationAddress AddSingleActivation(GrainId grain, ActivationId act, SiloAddress silo, MultiClusterStatus registrationStatus = MultiClusterStatus.Owned)
{
SingleInstance = true;
if (Instances.Count > 0)
{
var item = Instances.First();
return ActivationAddress.GetAddress(item.Value.SiloAddress, grain, item.Key);
}
else
{
Instances.Add(act, new ActivationInfo(silo, registrationStatus));
VersionTag = rand.Next();
return ActivationAddress.GetAddress(silo, grain, act, registrationStatus);
}
}
示例6: AddActivation
public bool AddActivation(ActivationId act, SiloAddress silo)
{
if (SingleInstance && (Instances.Count > 0) && !Instances.ContainsKey(act))
{
throw new InvalidOperationException(
"Attempting to add a second activation to an existing grain in single activation mode");
}
IActivationInfo info;
if (Instances.TryGetValue(act, out info))
{
if (info.SiloAddress.Equals(silo))
{
// just refresh, no need to generate new VersionTag
return false;
}
}
Instances[act] = new ActivationInfo(silo);
VersionTag = rand.Next();
return true;
}
示例7: CacheOrUpdateRemoteClusterRegistration
public void CacheOrUpdateRemoteClusterRegistration(GrainId grain, ActivationId oldActivation, ActivationAddress otherClusterAddress)
{
lock (lockable)
{
if (partitionData.ContainsKey(grain))
{
partitionData[grain].CacheOrUpdateRemoteClusterRegistration(grain, oldActivation,
otherClusterAddress.Activation, otherClusterAddress.Silo);
}
else
{
AddSingleActivation(grain, otherClusterAddress.Activation, otherClusterAddress.Silo,
GrainDirectoryEntryStatus.Cached);
}
}
}
示例8: DeactivateOnIdle
public void DeactivateOnIdle(ActivationId id)
{
ActivationData data;
if (!Catalog.TryGetActivationData(id, out data)) return; // already gone
data.ResetKeepAliveRequest(); // DeactivateOnIdle method would undo / override any current “keep alive” setting, making this grain immideately avaliable for deactivation.
Catalog.DeactivateActivationOnIdle(data);
}
示例9: 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());
}
示例10: IsReentrantGrain
internal bool IsReentrantGrain(ActivationId running)
{
ActivationData target;
GrainTypeData data;
return TryGetActivationData(running, out target) &&
target.GrainInstance != null &&
GrainTypeManager.TryGetData(TypeUtils.GetFullName(target.GrainInstanceType), out data) &&
data.IsReentrant;
}
示例11: CanInterleave
internal bool CanInterleave(ActivationId running, Message message)
{
ActivationData target;
GrainTypeData data;
return TryGetActivationData(running, out target) &&
target.GrainInstance != null &&
GrainTypeManager.TryGetData(TypeUtils.GetFullName(target.GrainInstanceType), out data) &&
(data.IsReentrant || data.MayInterleave((InvokeMethodRequest)message.BodyObject));
}
示例12: LookUpActivations
/// <summary>
/// Returns a list of activations (along with the version number of the list) for the given grain.
/// If the grain is not found, null is returned.
/// </summary>
/// <param name="grain"></param>
/// <returns></returns>
internal AddressesAndTag LookUpActivations(GrainId grain)
{
var result = new AddressesAndTag();
ActivationId[] activationIds;
IActivationInfo[] activationInfos;
const int arrayReusingThreshold = 100;
int grainInfoInstancesCount;
lock (lockable)
{
IGrainInfo graininfo;
if (!partitionData.TryGetValue(grain, out graininfo))
{
return result;
}
result.VersionTag = graininfo.VersionTag;
grainInfoInstancesCount = graininfo.Instances.Count;
if (grainInfoInstancesCount < arrayReusingThreshold)
{
if ((activationIds = activationIdsHolder) == null)
{
activationIdsHolder = activationIds = new ActivationId[arrayReusingThreshold];
}
if ((activationInfos = activationInfosHolder) == null)
{
activationInfosHolder = activationInfos = new IActivationInfo[arrayReusingThreshold];
}
}
else
{
activationIds = new ActivationId[grainInfoInstancesCount];
activationInfos = new IActivationInfo[grainInfoInstancesCount];
}
graininfo.Instances.Keys.CopyTo(activationIds, 0);
graininfo.Instances.Values.CopyTo(activationInfos, 0);
}
result.Addresses = new List<ActivationAddress>(grainInfoInstancesCount);
for (var i = 0; i < grainInfoInstancesCount; i++)
{
var activationInfo = activationInfos[i];
if (IsValidSilo(activationInfo.SiloAddress))
{
result.Addresses.Add(ActivationAddress.GetAddress(activationInfo.SiloAddress, grain, activationIds[i]));
}
activationInfos[i] = null;
activationIds[i] = null;
}
return result;
}
示例13: 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;
}
示例14: UpdateClusterRegistrationStatus
public bool UpdateClusterRegistrationStatus(GrainId grain, ActivationId activationId, MultiClusterStatus registrationStatus, MultiClusterStatus? compareWith = null)
{
lock (lockable)
{
if (partitionData.ContainsKey(grain))
{
return partitionData[grain].UpdateClusterRegistrationStatus(activationId, registrationStatus, compareWith);
}
return false;
}
}
示例15: UpdateClusterRegistrationStatus
public bool UpdateClusterRegistrationStatus(GrainId grain, ActivationId activationId, GrainDirectoryEntryStatus registrationStatus, GrainDirectoryEntryStatus? compareWith = null)
{
lock (lockable)
{
IGrainInfo graininfo;
if (partitionData.TryGetValue(grain, out graininfo))
{
return graininfo.UpdateClusterRegistrationStatus(activationId, registrationStatus, compareWith);
}
return false;
}
}