Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.
/ NuGet.Jobs Public archive

Commit

Permalink
Add the initial Auxiliary2AzureSearch job (#580)
Browse files Browse the repository at this point in the history
  • Loading branch information
joelverhagen committed Jul 8, 2019
1 parent 59ec164 commit 8910efe
Show file tree
Hide file tree
Showing 16 changed files with 282 additions and 13 deletions.
20 changes: 20 additions & 0 deletions NuGet.Services.Metadata.sln
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NuGet.Services.SearchServic
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NuGet.Jobs.Owners2AzureSearch", "src\NuGet.Jobs.Owners2AzureSearch\NuGet.Jobs.Owners2AzureSearch.csproj", "{F81A7CA6-97D4-4958-A9C1-FF94FCA283CB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NuGet.Jobs.Auxiliary2AzureSearch", "src\NuGet.Jobs.Auxiliary2AzureSearch\NuGet.Jobs.Auxiliary2AzureSearch.csproj", "{7E6903A4-DBE1-444E-A8E3-C1DBB58243E0}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B2B65510-309B-45F1-AA18-8E4066BFEB92}"
ProjectSection(SolutionItems) = preProject
build.ps1 = build.ps1
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -302,6 +309,18 @@ Global
{F81A7CA6-97D4-4958-A9C1-FF94FCA283CB}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{F81A7CA6-97D4-4958-A9C1-FF94FCA283CB}.Release|x64.ActiveCfg = Release|Any CPU
{F81A7CA6-97D4-4958-A9C1-FF94FCA283CB}.Release|x64.Build.0 = Release|Any CPU
{7E6903A4-DBE1-444E-A8E3-C1DBB58243E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7E6903A4-DBE1-444E-A8E3-C1DBB58243E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7E6903A4-DBE1-444E-A8E3-C1DBB58243E0}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{7E6903A4-DBE1-444E-A8E3-C1DBB58243E0}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{7E6903A4-DBE1-444E-A8E3-C1DBB58243E0}.Debug|x64.ActiveCfg = Debug|Any CPU
{7E6903A4-DBE1-444E-A8E3-C1DBB58243E0}.Debug|x64.Build.0 = Debug|Any CPU
{7E6903A4-DBE1-444E-A8E3-C1DBB58243E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7E6903A4-DBE1-444E-A8E3-C1DBB58243E0}.Release|Any CPU.Build.0 = Release|Any CPU
{7E6903A4-DBE1-444E-A8E3-C1DBB58243E0}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{7E6903A4-DBE1-444E-A8E3-C1DBB58243E0}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{7E6903A4-DBE1-444E-A8E3-C1DBB58243E0}.Release|x64.ActiveCfg = Release|Any CPU
{7E6903A4-DBE1-444E-A8E3-C1DBB58243E0}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -327,6 +346,7 @@ Global
{DD089AB9-6AB3-4ACA-8D63-C95A7935B2A7} = {97E23323-BA7A-48F0-A578-858B82B6D8FB}
{F009209D-A663-45E1-87E8-158569A0F097} = {F1C83FD9-A498-483E-ADFA-B55D82A14965}
{F81A7CA6-97D4-4958-A9C1-FF94FCA283CB} = {C86C6DEE-84E1-4E4E-8868-6755D7A8E0E4}
{7E6903A4-DBE1-444E-A8E3-C1DBB58243E0} = {C86C6DEE-84E1-4E4E-8868-6755D7A8E0E4}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D3AB83E9-02B4-4FFA-A2D0-637F0B97E626}
Expand Down
6 changes: 4 additions & 2 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ Invoke-BuildStep 'Set version metadata in AssemblyInfo.cs' {
"src\NuGet.Jobs.Db2AzureSearch\Properties\AssemblyInfo.g.cs", `
"src\NuGet.Jobs.Catalog2AzureSearch\Properties\AssemblyInfo.g.cs", `
"src\NuGet.Jobs.Owners2AzureSearch\Properties\AssemblyInfo.g.cs", `
"src\NuGet.Services.SearchService\Properties\AssemblyInfo.g.cs"
"src\NuGet.Services.SearchService\Properties\AssemblyInfo.g.cs", `
"src\NuGet.Jobs.Auxiliary2AzureSearch\Properties\AssemblyInfo.g.cs"

Foreach ($assemblyInfo in $assemblyInfos) {
Set-VersionInfo -Path (Join-Path $PSScriptRoot $assemblyInfo) -Version $SimpleVersion -Branch $Branch -Commit $CommitSHA
Expand Down Expand Up @@ -124,7 +125,8 @@ Invoke-BuildStep 'Creating artifacts' {
"src\Ng\Ng.Operations.nuspec", `
"src\NuGet.Jobs.Db2AzureSearch\NuGet.Jobs.Db2AzureSearch.nuspec", `
"src\NuGet.Jobs.Catalog2AzureSearch\NuGet.Jobs.Catalog2AzureSearch.nuspec", `
"src\NuGet.Jobs.Owners2AzureSearch\NuGet.Jobs.Owners2AzureSearch.nuspec"
"src\NuGet.Jobs.Owners2AzureSearch\NuGet.Jobs.Owners2AzureSearch.nuspec", `
"src\NuGet.Jobs.Auxiliary2AzureSearch\NuGet.Jobs.Auxiliary2AzureSearch.nuspec"

$nuspecPackages | ForEach-Object {
New-Package (Join-Path $PSScriptRoot $_) -Configuration $Configuration -BuildNumber $BuildNumber -Version $SemanticVersion -Branch $Branch
Expand Down
6 changes: 6 additions & 0 deletions src/NuGet.Jobs.Auxiliary2AzureSearch/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
</startup>
</configuration>
42 changes: 42 additions & 0 deletions src/NuGet.Jobs.Auxiliary2AzureSearch/Job.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Net;
using System.Threading.Tasks;
using Autofac;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using NuGet.Services.AzureSearch;
using NuGet.Services.AzureSearch.Auxiliary2AzureSearch;

namespace NuGet.Jobs
{
public class Job : JsonConfigurationJob
{
private const string ConfigurationSectionName = "Auxiliary2AzureSearch";

public override async Task Run()
{
ServicePointManager.DefaultConnectionLimit = 64;
ServicePointManager.MaxServicePointIdleTime = 10000;

await _serviceProvider
.GetRequiredService<Auxiliary2AzureSearchCommand>()
.ExecuteAsync();
}

protected override void ConfigureAutofacServices(ContainerBuilder containerBuilder)
{
containerBuilder.AddAzureSearch();
}

protected override void ConfigureJobServices(IServiceCollection services, IConfigurationRoot configurationRoot)
{
services.AddAzureSearch();

services.Configure<Auxiliary2AzureSearchConfiguration>(configurationRoot.GetSection(ConfigurationSectionName));
services.Configure<AzureSearchJobConfiguration>(configurationRoot.GetSection(ConfigurationSectionName));
services.Configure<AzureSearchConfiguration>(configurationRoot.GetSection(ConfigurationSectionName));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{7E6903A4-DBE1-444E-A8E3-C1DBB58243E0}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>NuGet.Jobs</RootNamespace>
<AssemblyName>NuGet.Jobs.Auxiliary2AzureSearch</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<Compile Include="Job.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\AssemblyInfo.*.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="NuGet.Jobs.Auxiliary2AzureSearch.nuspec" />
<None Include="Scripts\Functions.ps1" />
<None Include="Scripts\PostDeploy.ps1" />
<None Include="Scripts\PreDeploy.ps1" />
<None Include="Scripts\nssm.exe" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="MicroBuild.Core">
<Version>0.3.0</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NuGet.Services.AzureSearch\NuGet.Services.AzureSearch.csproj">
<Project>{1a53fe3d-8041-4773-942f-d73aef5b82b2}</Project>
<Name>NuGet.Services.AzureSearch</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<SignPath>..\..\build</SignPath>
<SignPath Condition="'$(BUILD_SOURCESDIRECTORY)' != ''">$(BUILD_SOURCESDIRECTORY)\build</SignPath>
<SignPath Condition="'$(NuGetBuildPath)' != ''">$(NuGetBuildPath)</SignPath>
<SignType Condition="'$(SignType)' == ''">none</SignType>
</PropertyGroup>
<Import Project="$(SignPath)\sign.targets" Condition="Exists('$(SignPath)\sign.targets')" />
<Import Project="$(SignPath)\sign.microbuild.targets" Condition="Exists('$(SignPath)\sign.microbuild.targets')" />
<Import Project="$(SignPath)\sign.scripts.targets" Condition="Exists('$(SignPath)\sign.scripts.targets')" />
<Import Project="..\..\sign.thirdparty.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<package>
<metadata>
<id>Auxiliary2AzureSearch</id>
<version>$version$</version>
<authors>.NET Foundation</authors>
<owners>.NET Foundation</owners>
<description>Auxiliary2AzureSearch</description>
<copyright>Copyright .NET Foundation</copyright>
</metadata>
<files>
<file src="bin\$configuration$\*.*" target="bin" />
<file src="Scripts\*.ps1" />
<file src="Scripts\nssm.exe" />
</files>
</package>
14 changes: 14 additions & 0 deletions src/NuGet.Jobs.Auxiliary2AzureSearch/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

namespace NuGet.Jobs
{
public class Program
{
public static int Main(string[] args)
{
var job = new Job();
return JobRunner.Run(job, args).GetAwaiter().GetResult();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Reflection;
using System.Runtime.InteropServices;

[assembly: AssemblyTitle("NuGet.Jobs.Auxiliary2AzureSearch")]
[assembly: ComVisible(false)]
[assembly: Guid("7e6903a4-dbe1-444e-a8e3-c1dbb58243e0")]
30 changes: 30 additions & 0 deletions src/NuGet.Jobs.Auxiliary2AzureSearch/Scripts/Functions.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Function Uninstall-NuGetService() {
Param ([string]$ServiceName)

if (Get-Service $ServiceName -ErrorAction SilentlyContinue)
{
Write-Host Removing service $ServiceName...
Stop-Service $ServiceName -Force
sc.exe delete $ServiceName
Write-Host Removed service $ServiceName.
} else {
Write-Host Skipping removal of service $ServiceName - no such service exists.
}
}

Function Install-NuGetService() {
Param ([string]$ServiceName, [string]$ServiceTitle, [string]$ScriptToRun)

Write-Host Installing service $ServiceName...

$installService = "nssm install $ServiceName $ScriptToRun"
cmd /C $installService

Set-Service -Name $ServiceName -DisplayName "$ServiceTitle - $ServiceName" -Description "Runs $ServiceTitle." -StartupType Automatic
sc.exe failure $ServiceName reset= 30 actions= restart/5000

# Run service
net start $ServiceName

Write-Host Installed service $ServiceName.
}
18 changes: 18 additions & 0 deletions src/NuGet.Jobs.Auxiliary2AzureSearch/Scripts/PostDeploy.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
. .\Functions.ps1

$jobsToInstall = $OctopusParameters["Jobs.ServiceNames"].Split("{,}")

Write-Host Installing services...

$currentDirectory = [string](Get-Location)

$jobsToInstall.Split("{;}") | %{
$serviceName = $_
$serviceTitle = $OctopusParameters["Jobs.$serviceName.Title"]
$scriptToRun = $OctopusParameters["Jobs.$serviceName.Script"]
$scriptToRun = "$currentDirectory\$scriptToRun"

Install-NuGetService -ServiceName $serviceName -ServiceTitle $serviceTitle -ScriptToRun $scriptToRun
}

Write-Host Installed services.
11 changes: 11 additions & 0 deletions src/NuGet.Jobs.Auxiliary2AzureSearch/Scripts/PreDeploy.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
. .\Functions.ps1

$jobsToInstall = $OctopusParameters["Jobs.ServiceNames"].Split("{,}")

Write-Host Removing services...

$jobsToInstall.Split("{;}") | %{
Uninstall-NuGetService -ServiceName $_
}

Write-Host Removed services.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Threading.Tasks;

namespace NuGet.Services.AzureSearch.Auxiliary2AzureSearch
{
public class Auxiliary2AzureSearchCommand
{
public async Task ExecuteAsync()
{
// TODO: implement the job
// https://github.com/NuGet/NuGetGallery/issues/6447
await Task.Yield();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

namespace NuGet.Services.AzureSearch.Auxiliary2AzureSearch
{
public class Auxiliary2AzureSearchConfiguration : AzureSearchJobConfiguration
{
public string AuxiliaryDataStorageConnectionString { get; set; }
public string AuxiliaryDataStorageContainer { get; set; }
public string AuxiliaryDataStorageDownloadsPath { get; set; }
}
}
15 changes: 4 additions & 11 deletions src/NuGet.Services.AzureSearch/DependencyInjectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using NuGet.Protocol;
using NuGet.Protocol.Catalog;
using NuGet.Protocol.Registration;
using NuGet.Services.AzureSearch.Auxiliary2AzureSearch;
using NuGet.Services.AzureSearch.Catalog2AzureSearch;
using NuGet.Services.AzureSearch.Db2AzureSearch;
using NuGet.Services.AzureSearch.Owners2AzureSearch;
Expand Down Expand Up @@ -173,17 +174,6 @@ private static void RegisterAzureSearchJobStorageServices(ContainerBuilder conta
c.Resolve<IOwnerDataClient>(),
c.Resolve<IOptionsSnapshot<Db2AzureSearchConfiguration>>(),
c.Resolve<ILogger<Db2AzureSearchCommand>>()));

containerBuilder
.Register(c => new Owners2AzureSearchCommand(
c.Resolve<IDatabaseOwnerFetcher>(),
c.Resolve<IOwnerDataClient>(),
c.Resolve<IOwnerSetComparer>(),
c.Resolve<IOwnerIndexActionBuilder>(),
c.Resolve<Func<IBatchPusher>>(),
c.Resolve<IOptionsSnapshot<AzureSearchJobConfiguration>>(),
c.Resolve<IAzureSearchTelemetryService>(),
c.Resolve<ILogger<Owners2AzureSearchCommand>>()));
}

private static void RegisterAuxiliaryDataStorageServices(ContainerBuilder containerBuilder, string key)
Expand Down Expand Up @@ -239,6 +229,9 @@ public static IServiceCollection AddAzureSearch(this IServiceCollection services
services.AddScoped(p => p.GetRequiredService<IAuxiliaryDataCache>().Get());
services.AddSingleton<IAuxiliaryFileReloader, AuxiliaryFileReloader>();

services.AddTransient<Auxiliary2AzureSearchCommand>();
services.AddTransient<Owners2AzureSearchCommand>();

services.AddTransient<IAzureSearchTelemetryService, AzureSearchTelemetryService>();
services.AddTransient<IBaseDocumentBuilder, BaseDocumentBuilder>();
services.AddTransient<ICatalogIndexActionBuilder, CatalogIndexActionBuilder>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
<Compile Include="Analysis\IdentifierCustomTokenFilter.cs" />
<Compile Include="Analysis\PackageIdCustomAnalyzer.cs" />
<Compile Include="Analysis\PackageIdCustomTokenizer.cs" />
<Compile Include="Auxiliary2AzureSearch\Auxiliary2AzureSearchCommand.cs" />
<Compile Include="Auxiliary2AzureSearch\Auxiliary2AzureSearchConfiguration.cs" />
<Compile Include="AzureSearchScoringConfiguration.cs" />
<Compile Include="BaseDocumentBuilder.cs" />
<Compile Include="DatabaseOwnerFetcher.cs" />
Expand Down

0 comments on commit 8910efe

Please sign in to comment.