Skip to content

Commit 726e197

Browse files
authored
Initial check-in of Kudu 1.12 (#1)
1 parent 855f437 commit 726e197

File tree

152 files changed

+18545
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

152 files changed

+18545
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,3 +348,6 @@ MigrationBackup/
348348

349349
# Ionide (cross platform F# VS Code tools) working folder
350350
.ionide/
351+
352+
# Include Kudu binaries
353+
!**/kudu/bin/

.nuget/icon.png

3.62 KB
Loading

kudu-binary.sln

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.30128.74
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Knet.Kudu.Binary", "src\Knet.Kudu.Binary\Knet.Kudu.Binary.csproj", "{E522DC5D-6DAA-4A97-A587-37F112670E18}"
7+
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{8BB323C7-55FF-40FA-B47E-3C29E8DB4114}"
9+
EndProject
10+
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Any CPU = Debug|Any CPU
13+
Release|Any CPU = Release|Any CPU
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{E522DC5D-6DAA-4A97-A587-37F112670E18}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17+
{E522DC5D-6DAA-4A97-A587-37F112670E18}.Debug|Any CPU.Build.0 = Debug|Any CPU
18+
{E522DC5D-6DAA-4A97-A587-37F112670E18}.Release|Any CPU.ActiveCfg = Release|Any CPU
19+
{E522DC5D-6DAA-4A97-A587-37F112670E18}.Release|Any CPU.Build.0 = Release|Any CPU
20+
EndGlobalSection
21+
GlobalSection(SolutionProperties) = preSolution
22+
HideSolutionNode = FALSE
23+
EndGlobalSection
24+
GlobalSection(NestedProjects) = preSolution
25+
{E522DC5D-6DAA-4A97-A587-37F112670E18} = {8BB323C7-55FF-40FA-B47E-3C29E8DB4114}
26+
EndGlobalSection
27+
GlobalSection(ExtensibilityGlobals) = postSolution
28+
SolutionGuid = {BC6B5B1D-E3DC-4394-B2AB-CBF974E7E2D0}
29+
EndGlobalSection
30+
EndGlobal
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System.Collections.Generic;
2+
3+
namespace Knet.Kudu.Binary
4+
{
5+
public class ExecutableInfo
6+
{
7+
/// <summary>
8+
/// Path to the executable.
9+
/// </summary>
10+
public string ExePath { get; }
11+
12+
/// <summary>
13+
/// Any environment variables that should be set when running the executable.
14+
/// </summary>
15+
public IReadOnlyDictionary<string, string> EnvironmentVariables { get; }
16+
17+
public ExecutableInfo(string exePath, IReadOnlyDictionary<string, string> environmentVariables)
18+
{
19+
ExePath = exePath;
20+
EnvironmentVariables = environmentVariables;
21+
}
22+
}
23+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>netstandard2.0</TargetFrameworks>
5+
<NoWarn>CS1591</NoWarn>
6+
7+
<PackageId>$(AssemblyName)</PackageId>
8+
<Version>0.1.0-preview.1</Version>
9+
<Authors>xqrzd</Authors>
10+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
11+
<Description>Native Apache Kudu binary for testing</Description>
12+
<PackageIcon>icon.png</PackageIcon>
13+
<PackageProjectUrl>https://github.com/xqrzd/kudu-binary-net</PackageProjectUrl>
14+
<RepositoryUrl>https://github.com/xqrzd/kudu-binary-net</RepositoryUrl>
15+
</PropertyGroup>
16+
17+
<ItemGroup>
18+
<None Include="..\..\.nuget\icon.png" Pack="true" PackagePath="" Visible="false" />
19+
<Content Include="runtimes\**" PackagePath="runtimes" Visible="false" />
20+
</ItemGroup>
21+
22+
</Project>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
namespace Knet.Kudu.Binary
2+
{
3+
/// <summary>
4+
/// Simple struct to provide various properties of a binary artifact to callers.
5+
/// </summary>
6+
public class KuduBinaryInfo
7+
{
8+
/// <summary>
9+
/// Return the binary directory of an extracted artifact.
10+
/// </summary>
11+
public string BinDir { get; }
12+
13+
/// <summary>
14+
/// Return the SASL module directory of an extracted artifact.
15+
/// May be null if unknown.
16+
/// </summary>
17+
public string SaslDir { get; }
18+
19+
public KuduBinaryInfo(string binDir)
20+
: this(binDir, null)
21+
{
22+
}
23+
24+
public KuduBinaryInfo(string binDir, string saslDir)
25+
{
26+
BinDir = binDir;
27+
SaslDir = saslDir;
28+
}
29+
}
30+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Runtime.InteropServices;
5+
6+
namespace Knet.Kudu.Binary
7+
{
8+
public static class KuduBinaryLocator
9+
{
10+
private const string SaslPathName = "SASL_PATH";
11+
12+
/// <summary>
13+
/// Retrieve info needed to start Kudu.
14+
/// </summary>
15+
/// <param name="exeName">The binary to look for (eg 'kudu-tserver').</param>
16+
public static ExecutableInfo FindBinary(string exeName)
17+
{
18+
var artifactInfo = FindBinaryLocation();
19+
20+
var executable = Path.Combine(artifactInfo.BinDir, exeName);
21+
if (!File.Exists(executable))
22+
{
23+
throw new FileNotFoundException($"Cannot find executable {exeName} " +
24+
$"in binary directory {artifactInfo.BinDir}");
25+
}
26+
27+
var env = new Dictionary<string, string>();
28+
if (artifactInfo.SaslDir != null)
29+
{
30+
env.Add(SaslPathName, artifactInfo.SaslDir);
31+
}
32+
33+
return new ExecutableInfo(executable, env);
34+
}
35+
36+
private static KuduBinaryInfo FindBinaryLocation()
37+
{
38+
var appPath = AppContext.BaseDirectory;
39+
var rid = GetRid();
40+
41+
var artifactRoot = Path.Combine(appPath, "runtimes", rid, "native", "kudu");
42+
var binPath = Path.Combine(artifactRoot, "bin");
43+
if (Directory.Exists(binPath))
44+
{
45+
// Only set the saslDir property if we find it in the artifact,
46+
// since that affects whether the caller needs to set SASL_PATH
47+
// when executing the binaries.
48+
var saslDir = Path.Combine(artifactRoot, "lib", "sasl2");
49+
50+
if (!Directory.Exists(saslDir))
51+
{
52+
saslDir = null;
53+
}
54+
55+
return new KuduBinaryInfo(binPath, saslDir);
56+
}
57+
58+
throw new Exception("Unable to find Kudu");
59+
}
60+
61+
private static string GetRid()
62+
{
63+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) &&
64+
RuntimeInformation.OSArchitecture == Architecture.X64)
65+
{
66+
return "linux-x64";
67+
}
68+
69+
throw new NotSupportedException($"{RuntimeInformation.OSDescription} " +
70+
$"{RuntimeInformation.OSArchitecture} is not supported");
71+
}
72+
}
73+
}

0 commit comments

Comments
 (0)