private DeployedCodePackage GetDummyDeployedServiceCodepackage(string dummyCodePackageVersion) { var dummyEntryPoint = new CodePackageEntryPoint( string.Empty, // entry-point location 0, // process id string.Empty, // runas username EntryPointStatus.Started, DateTime.UtcNow, // next activation utc null, // codepack statistics 0 /*codepack instance id*/); var dummyCodePack = new DeployedCodePackage( string.Empty, // codepack name dummyCodePackageVersion, // codepack version dummyEntryPoint, // setup entrypoint string.Empty, // servicemanifest name string.Empty, // Default ServicePackageActivationId 0, // run frequency interval HostType.ExeHost, HostIsolationMode.None, DeploymentStatus.Active, dummyEntryPoint /*entrypoint*/); return(dummyCodePack); }
/// <summary> /// Serializes the object to JSON. /// </summary> /// <param name="writer">The <see cref="T: Newtonsoft.Json.JsonWriter" /> to write to.</param> /// <param name="obj">The object to serialize to JSON.</param> internal static void Serialize(JsonWriter writer, CodePackageEntryPoint obj) { // Required properties are always serialized, optional properties are serialized when not null. writer.WriteStartObject(); writer.WriteProperty(obj.Status, "Status", EntryPointStatusConverter.Serialize); if (obj.EntryPointLocation != null) { writer.WriteProperty(obj.EntryPointLocation, "EntryPointLocation", JsonWriterExtensions.WriteStringValue); } if (obj.ProcessId != null) { writer.WriteProperty(obj.ProcessId, "ProcessId", JsonWriterExtensions.WriteStringValue); } if (obj.RunAsUserName != null) { writer.WriteProperty(obj.RunAsUserName, "RunAsUserName", JsonWriterExtensions.WriteStringValue); } if (obj.CodePackageEntryPointStatistics != null) { writer.WriteProperty(obj.CodePackageEntryPointStatistics, "CodePackageEntryPointStatistics", CodePackageEntryPointStatisticsConverter.Serialize); } if (obj.NextActivationTime != null) { writer.WriteProperty(obj.NextActivationTime, "NextActivationTime", JsonWriterExtensions.WriteDateTimeValue); } if (obj.InstanceId != null) { writer.WriteProperty(obj.InstanceId, "InstanceId", JsonWriterExtensions.WriteStringValue); } if (obj.ContainerId != null) { writer.WriteProperty(obj.ContainerId, "ContainerId", JsonWriterExtensions.WriteStringValue); } writer.WriteEndObject(); }
private static EntrypointAndType GetCodepackageEntrypointToRestart(RestartDeployedCodePackageAction action, DeployedCodePackage codepackage) { if (codepackage == null || (codepackage.EntryPoint == null && codepackage.SetupEntryPoint == null)) { throw new FabricException( StringHelper.Format(StringResources.Error_CodePackageNotDeployedOnNode, action.ApplicationName, action.CodePackageName, action.NodeName), FabricErrorCode.CodePackageNotFound); } CodePackageEntryPoint restartedEntryPoint = null; EntryPointType restartedEntryPointType = EntryPointType.None; if (codepackage.EntryPoint != null && codepackage.EntryPoint.EntryPointStatus == EntryPointStatus.Started) { restartedEntryPoint = codepackage.EntryPoint; restartedEntryPointType = EntryPointType.Main; } else if (codepackage.SetupEntryPoint != null && codepackage.SetupEntryPoint.EntryPointStatus == EntryPointStatus.Started) { restartedEntryPoint = codepackage.SetupEntryPoint; restartedEntryPointType = EntryPointType.Setup; } if (restartedEntryPoint == null || restartedEntryPointType == EntryPointType.None) { throw new InvalidOperationException(StringResources.Error_CodePackageCannotBeRestarted); } if (action.CodePackageInstanceId != 0 && restartedEntryPoint.CodePackageInstanceId != action.CodePackageInstanceId) { throw new FabricException(StringResources.Error_InstanceIdMismatch, FabricErrorCode.InstanceIdMismatch); } return(new EntrypointAndType(restartedEntryPoint, restartedEntryPointType)); }
public EntrypointAndType(CodePackageEntryPoint entryPoint, EntryPointType entryPointType) { this.EntryPoint = entryPoint; this.EntryPointType = entryPointType; }