Skip to content

Commit 5691b7c

Browse files
tsushitsushi
authored andcommitted
Adding DataPackage
1 parent edf2516 commit 5691b7c

File tree

7 files changed

+52
-15
lines changed

7 files changed

+52
-15
lines changed

Chapter05/ConsoleRedirectTestApplication/ConsoleRedirect/ConsoleRedirect.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.Fabric;
44
using System.Linq;
5+
using System.IO;
56
using System.Threading;
67
using System.Threading.Tasks;
78
using Microsoft.ServiceFabric.Services.Communication.Runtime;
@@ -36,15 +37,12 @@ protected override async Task RunAsync(CancellationToken cancellationToken)
3637
// TODO: Replace the following sample code with your own logic
3738
// or remove this RunAsync override if it's not needed in your service.
3839

39-
long iterations = 0;
40-
41-
while (true)
40+
while (!cancellationToken.IsCancellationRequested)
4241
{
43-
cancellationToken.ThrowIfCancellationRequested();
44-
45-
ServiceEventSource.Current.ServiceMessage(this, "Working-{0}", ++iterations);
46-
47-
await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken);
42+
var dataPackage = this.Context.CodePackageActivationContext.GetDataPackageObject("TestData");
43+
var text = File.ReadAllText(Path.Combine(dataPackage.Path, "data.txt"));
44+
ServiceEventSource.Current.ServiceMessage(this, text);
45+
await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken);
4846
}
4947
}
5048
}

Chapter05/ConsoleRedirectTestApplication/ConsoleRedirect/ConsoleRedirect.csproj

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,21 @@
1212
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
1313
<FileAlignment>512</FileAlignment>
1414
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
15+
<PublishUrl>publish\</PublishUrl>
16+
<Install>true</Install>
17+
<InstallFrom>Disk</InstallFrom>
18+
<UpdateEnabled>false</UpdateEnabled>
19+
<UpdateMode>Foreground</UpdateMode>
20+
<UpdateInterval>7</UpdateInterval>
21+
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
22+
<UpdatePeriodically>false</UpdatePeriodically>
23+
<UpdateRequired>false</UpdateRequired>
24+
<MapFileExtensions>true</MapFileExtensions>
25+
<ApplicationRevision>0</ApplicationRevision>
26+
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
27+
<IsWebBootstrapper>false</IsWebBootstrapper>
28+
<UseApplicationTrust>false</UseApplicationTrust>
29+
<BootstrapperEnabled>true</BootstrapperEnabled>
1530
</PropertyGroup>
1631
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
1732
<DebugSymbols>true</DebugSymbols>
@@ -81,6 +96,22 @@
8196
<None Include="App.config" />
8297
<None Include="packages.config" />
8398
</ItemGroup>
99+
<ItemGroup />
100+
<ItemGroup>
101+
<BootstrapperPackage Include=".NETFramework,Version=v4.5.2">
102+
<Visible>False</Visible>
103+
<ProductName>Microsoft .NET Framework 4.5.2 %28x86 and x64%29</ProductName>
104+
<Install>true</Install>
105+
</BootstrapperPackage>
106+
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
107+
<Visible>False</Visible>
108+
<ProductName>.NET Framework 3.5 SP1</ProductName>
109+
<Install>false</Install>
110+
</BootstrapperPackage>
111+
</ItemGroup>
112+
<ItemGroup>
113+
<Content Include="PackageRoot\TestData\data.txt" />
114+
</ItemGroup>
84115
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
85116
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
86117
Other similar extension points exist, see Microsoft.Common.targets.

Chapter05/ConsoleRedirectTestApplication/ConsoleRedirect/PackageRoot/ServiceManifest.xml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<ServiceManifest Name="ConsoleRedirectPkg"
3-
Version="1.0.1"
3+
Version="1.0.2"
44
xmlns="http://schemas.microsoft.com/2011/01/fabric"
55
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
66
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
77
<ServiceTypes>
88
<!-- This is the name of your ServiceType.
99
This name must match the string used in RegisterServiceType call in Program.cs. -->
10-
<StatelessServiceType ServiceTypeName="ConsoleRedirectType" />
10+
<StatelessServiceType ServiceTypeName="ConsoleRedirectType" />
1111
</ServiceTypes>
1212

1313
<!-- Code package is your service executable. -->
14-
<CodePackage Name="Code" Version="1.0.1">
14+
<CodePackage Name="Code" Version="1.0.2">
1515
<SetupEntryPoint>
1616
<ExeHost>
1717
<Program>scripts\test.cmd</Program>
@@ -27,8 +27,11 @@
2727

2828
<!-- Config package is the contents of the Config directoy under PackageRoot that contains an
2929
independently-updateable and versioned set of custom configuration settings for your service. -->
30-
<ConfigPackage Name="Config" Version="1.0.0" />
3130

31+
<ConfigPackage Name="Config" Version="1.0.1" />
32+
<DataPackage Name="TestData" Version="1.0.1" />
33+
34+
3235
<Resources>
3336
<Endpoints>
3437
<!-- This endpoint is used by the communication listener to obtain the port on which to
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
data text sample
2+
data text sample2

Chapter05/ConsoleRedirectTestApplication/ConsoleRedirectTestApplication/ApplicationPackageRoot/ApplicationManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<ApplicationManifest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ApplicationTypeName="ConsoleRedirectTestApplicationType" ApplicationTypeVersion="1.0.1" xmlns="http://schemas.microsoft.com/2011/01/fabric">
2+
<ApplicationManifest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ApplicationTypeName="ConsoleRedirectTestApplicationType" ApplicationTypeVersion="1.0.2" xmlns="http://schemas.microsoft.com/2011/01/fabric">
33
<Parameters>
44
<Parameter Name="ConsoleRedirect_InstanceCount" DefaultValue="-1" />
55
</Parameters>
66
<!-- Import the ServiceManifest from the ServicePackage. The ServiceManifestName and ServiceManifestVersion
77
should match the Name and Version attributes of the ServiceManifest element defined in the
88
ServiceManifest.xml file. -->
99
<ServiceManifestImport>
10-
<ServiceManifestRef ServiceManifestName="ConsoleRedirectPkg" ServiceManifestVersion="1.0.1" />
10+
<ServiceManifestRef ServiceManifestName="ConsoleRedirectPkg" ServiceManifestVersion="1.0.2" />
1111
<ConfigOverrides />
1212
</ServiceManifestImport>
1313
<DefaultServices>

Chapter05/ConsoleRedirectTestApplication/ConsoleRedirectTestApplication/PublishProfiles/Cloud.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,7 @@
2222
-->
2323
<ClusterConnectionParameters ConnectionEndpoint="" />
2424
<ApplicationParameterFile Path="..\ApplicationParameters\Cloud.xml" />
25+
<UpgradeDeployment Mode="Monitored" Enabled="false">
26+
<Parameters FailureAction="Rollback" Force="True" />
27+
</UpgradeDeployment>
2528
</PublishProfile>

Chapter05/ConsoleRedirectTestApplication/ConsoleRedirectTestApplication/PublishProfiles/Local.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
-->
99
<ClusterConnectionParameters />
1010
<ApplicationParameterFile Path="..\ApplicationParameters\Local.xml" />
11-
<UpgradeDeployment Mode="UnmonitoredAuto" Enabled="false">
11+
<UpgradeDeployment Mode="UnmonitoredAuto" Enabled="true">
1212
<Parameters UpgradeReplicaSetCheckTimeoutSec="1" Force="True" />
1313
</UpgradeDeployment>
1414
</PublishProfile>

0 commit comments

Comments
 (0)