Skip to content

Commit

Permalink
Adding DataPackage
Browse files Browse the repository at this point in the history
  • Loading branch information
tsushi authored and tsushi committed Aug 12, 2016
1 parent edf2516 commit 5691b7c
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Fabric;
using System.Linq;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.ServiceFabric.Services.Communication.Runtime;
Expand Down Expand Up @@ -36,15 +37,12 @@ protected override async Task RunAsync(CancellationToken cancellationToken)
// TODO: Replace the following sample code with your own logic
// or remove this RunAsync override if it's not needed in your service.

long iterations = 0;

while (true)
while (!cancellationToken.IsCancellationRequested)
{
cancellationToken.ThrowIfCancellationRequested();

ServiceEventSource.Current.ServiceMessage(this, "Working-{0}", ++iterations);

await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken);
var dataPackage = this.Context.CodePackageActivationContext.GetDataPackageObject("TestData");
var text = File.ReadAllText(Path.Combine(dataPackage.Path, "data.txt"));
ServiceEventSource.Current.ServiceMessage(this, text);
await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -81,6 +96,22 @@
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5.2">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.5.2 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<Content Include="PackageRoot\TestData\data.txt" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<ServiceManifest Name="ConsoleRedirectPkg"
Version="1.0.1"
Version="1.0.2"
xmlns="http://schemas.microsoft.com/2011/01/fabric"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ServiceTypes>
<!-- This is the name of your ServiceType.
This name must match the string used in RegisterServiceType call in Program.cs. -->
<StatelessServiceType ServiceTypeName="ConsoleRedirectType" />
<StatelessServiceType ServiceTypeName="ConsoleRedirectType" />
</ServiceTypes>

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

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

<ConfigPackage Name="Config" Version="1.0.1" />
<DataPackage Name="TestData" Version="1.0.1" />


<Resources>
<Endpoints>
<!-- This endpoint is used by the communication listener to obtain the port on which to
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
data text sample
data text sample2
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<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">
<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">
<Parameters>
<Parameter Name="ConsoleRedirect_InstanceCount" DefaultValue="-1" />
</Parameters>
<!-- Import the ServiceManifest from the ServicePackage. The ServiceManifestName and ServiceManifestVersion
should match the Name and Version attributes of the ServiceManifest element defined in the
ServiceManifest.xml file. -->
<ServiceManifestImport>
<ServiceManifestRef ServiceManifestName="ConsoleRedirectPkg" ServiceManifestVersion="1.0.1" />
<ServiceManifestRef ServiceManifestName="ConsoleRedirectPkg" ServiceManifestVersion="1.0.2" />
<ConfigOverrides />
</ServiceManifestImport>
<DefaultServices>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@
-->
<ClusterConnectionParameters ConnectionEndpoint="" />
<ApplicationParameterFile Path="..\ApplicationParameters\Cloud.xml" />
<UpgradeDeployment Mode="Monitored" Enabled="false">
<Parameters FailureAction="Rollback" Force="True" />
</UpgradeDeployment>
</PublishProfile>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
-->
<ClusterConnectionParameters />
<ApplicationParameterFile Path="..\ApplicationParameters\Local.xml" />
<UpgradeDeployment Mode="UnmonitoredAuto" Enabled="false">
<UpgradeDeployment Mode="UnmonitoredAuto" Enabled="true">
<Parameters UpgradeReplicaSetCheckTimeoutSec="1" Force="True" />
</UpgradeDeployment>
</PublishProfile>

0 comments on commit 5691b7c

Please sign in to comment.