Skip to content

Commit

Permalink
Begin implementing run request handler...
Browse files Browse the repository at this point in the history
Implementing background job class. Also implemented process to fix up warden protocol buffer classes.
  • Loading branch information
lukebakken committed Jun 6, 2013
1 parent abf3fbe commit 9f8960b
Show file tree
Hide file tree
Showing 47 changed files with 554 additions and 60 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
@@ -0,0 +1,3 @@
[submodule "src/IronFoundry.Warden.Protocol/warden"]
path = src/IronFoundry.Warden.Protocol/warden
url = https://github.com/cloudfoundry/warden.git
49 changes: 49 additions & 0 deletions src/IronFoundry.Warden.Protocol/CopyAndFixUpProto.ps1
@@ -0,0 +1,49 @@
Set-StrictMode -Version Latest

$warden_proto_dir = '.\warden\warden-protocol\lib\warden\protocol\pb'
$target_proto_dir = '.\pb'

if (!(Test-Path $warden_proto_dir))
{
Write-Error "Directory '$warden_proto_dir' containing *.proto files does not exist, exiting."
exit 1
}

mkdir -ErrorAction SilentlyContinue $target_proto_dir

$std_replace_text = "package IronFoundry.Warden.Protocol;`r`nimport `"info.proto`";`r`n"

$warden_proto_files = Get-ChildItem $warden_proto_dir -File -Filter '*.proto'
foreach ($proto_file in $warden_proto_files)
{
$repl_text = $std_replace_text
if ($proto_file.Name -eq 'info.proto')
{
$repl_text = 'package IronFoundry.Warden.Protocol;'
}
elseif (($proto_file.Name -eq 'run.proto') -or ($proto_file.Name -eq 'spawn.proto'))
{
$repl_text = "package IronFoundry.Warden.Protocol;`r`nimport `"info.proto`";`r`nimport `"resource_limits.proto`";`r`n"
}
(Get-Content -Path $proto_file.FullName) | ForEach-Object {
$_ -replace 'package warden;', $repl_text
} | Set-Content (Join-Path $target_proto_dir $proto_file.Name)
}

# Per-file tweaks
# info.proto
(Get-Content -Path .\pb\info.proto) | ForEach-Object {
$_ -replace 'memory_stat', 'memory_stat_info' `
-replace 'cpu_stat', 'cpu_stat_info' `
-replace 'disk_stat', 'disk_stat_info' `
-replace 'bandwidth_stat', 'bandwidth_stat_info'
} | Set-Content .\pb\info.proto

# create.proto
(Get-Content -Path .\pb\create.proto) | ForEach-Object { $_ -replace 'Mode mode', 'Mode bind_mount_mode' } | Set-Content .\pb\create.proto

# message.proto
(Get-Content -Path .\pb\message.proto) | ForEach-Object { $_ -replace 'Type type', 'Type message_type' } | Set-Content .\pb\message.proto

# run.proto
(Get-Content -Path .\pb\run.proto) | ForEach-Object { $_ -replace 'optional uint32 exit_status', 'required uint32 exit_status' } | Set-Content .\pb\run.proto
31 changes: 26 additions & 5 deletions src/IronFoundry.Warden.Protocol/Messages.cs
Expand Up @@ -8,6 +8,7 @@
//------------------------------------------------------------------------------

// Generated from: copy_in.proto
// Note: requires additional types generated from: info.proto
namespace IronFoundry.Warden.Protocol
{
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"CopyInRequest")]
Expand Down Expand Up @@ -53,6 +54,7 @@ public partial class CopyInResponse : global::ProtoBuf.IExtensible

}
// Generated from: copy_out.proto
// Note: requires additional types generated from: info.proto
namespace IronFoundry.Warden.Protocol
{
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"CopyOutRequest")]
Expand Down Expand Up @@ -107,6 +109,7 @@ public partial class CopyOutResponse : global::ProtoBuf.IExtensible

}
// Generated from: create.proto
// Note: requires additional types generated from: info.proto
namespace IronFoundry.Warden.Protocol
{
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"CreateRequest")]
Expand Down Expand Up @@ -223,6 +226,7 @@ public string Handle

}
// Generated from: destroy.proto
// Note: requires additional types generated from: info.proto
namespace IronFoundry.Warden.Protocol
{
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"DestroyRequest")]
Expand Down Expand Up @@ -254,6 +258,7 @@ public partial class DestroyResponse : global::ProtoBuf.IExtensible

}
// Generated from: echo.proto
// Note: requires additional types generated from: info.proto
namespace IronFoundry.Warden.Protocol
{
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"EchoRequest")]
Expand Down Expand Up @@ -292,6 +297,7 @@ public string Message

}
// Generated from: error.proto
// Note: requires additional types generated from: info.proto
namespace IronFoundry.Warden.Protocol
{
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ErrorResponse")]
Expand Down Expand Up @@ -821,6 +827,7 @@ public ulong OutBurst

}
// Generated from: limit_bandwidth.proto
// Note: requires additional types generated from: info.proto
namespace IronFoundry.Warden.Protocol
{
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"LimitBandwidthRequest")]
Expand Down Expand Up @@ -880,6 +887,7 @@ public ulong Burst

}
// Generated from: limit_disk.proto
// Note: requires additional types generated from: info.proto
namespace IronFoundry.Warden.Protocol
{
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"LimitDiskRequest")]
Expand Down Expand Up @@ -1127,6 +1135,7 @@ public ulong ByteHard

}
// Generated from: limit_memory.proto
// Note: requires additional types generated from: info.proto
namespace IronFoundry.Warden.Protocol
{
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"LimitMemoryRequest")]
Expand Down Expand Up @@ -1208,8 +1217,10 @@ public partial class LinkResponse : global::ProtoBuf.IExtensible
{
public LinkResponse() {}

private uint _exitStatus;
[global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"exit_status", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]

private uint _exitStatus = default(uint);
[global::ProtoBuf.ProtoMember(1, IsRequired = false, Name=@"exit_status", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
[global::System.ComponentModel.DefaultValue(default(uint))]
public uint ExitStatus
{
get { return _exitStatus; }
Expand Down Expand Up @@ -1249,6 +1260,7 @@ public IronFoundry.Warden.Protocol.InfoResponse Info

}
// Generated from: list.proto
// Note: requires additional types generated from: info.proto
namespace IronFoundry.Warden.Protocol
{
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ListRequest")]
Expand Down Expand Up @@ -1280,6 +1292,7 @@ public partial class ListResponse : global::ProtoBuf.IExtensible

}
// Generated from: message.proto
// Note: requires additional types generated from: info.proto
namespace IronFoundry.Warden.Protocol
{
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"Message")]
Expand Down Expand Up @@ -1370,6 +1383,7 @@ public enum Type

}
// Generated from: net_in.proto
// Note: requires additional types generated from: info.proto
namespace IronFoundry.Warden.Protocol
{
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"NetInRequest")]
Expand Down Expand Up @@ -1433,6 +1447,7 @@ public uint ContainerPort

}
// Generated from: net_out.proto
// Note: requires additional types generated from: info.proto
namespace IronFoundry.Warden.Protocol
{
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"NetOutRequest")]
Expand Down Expand Up @@ -1482,6 +1497,7 @@ public partial class NetOutResponse : global::ProtoBuf.IExtensible

}
// Generated from: ping.proto
// Note: requires additional types generated from: info.proto
namespace IronFoundry.Warden.Protocol
{
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"PingRequest")]
Expand All @@ -1506,6 +1522,7 @@ public partial class PingResponse : global::ProtoBuf.IExtensible

}
// Generated from: resource_limits.proto
// Note: requires additional types generated from: info.proto
namespace IronFoundry.Warden.Protocol
{
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ResourceLimits")]
Expand Down Expand Up @@ -1655,8 +1672,8 @@ public ulong Stack

}
// Generated from: run.proto
// Note: requires additional types generated from: resource_limits.proto
// Note: requires additional types generated from: info.proto
// Note: requires additional types generated from: resource_limits.proto
namespace IronFoundry.Warden.Protocol
{
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"RunRequest")]
Expand Down Expand Up @@ -1747,6 +1764,7 @@ public IronFoundry.Warden.Protocol.InfoResponse Info

}
// Generated from: spawn.proto
// Note: requires additional types generated from: info.proto
// Note: requires additional types generated from: resource_limits.proto
namespace IronFoundry.Warden.Protocol
{
Expand Down Expand Up @@ -1811,6 +1829,7 @@ public uint JobId

}
// Generated from: stop.proto
// Note: requires additional types generated from: info.proto
namespace IronFoundry.Warden.Protocol
{
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"StopRequest")]
Expand Down Expand Up @@ -1910,8 +1929,10 @@ public string Data
get { return _data; }
set { _data = value; }
}
private uint _exitStatus;
[global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"exit_status", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]

private uint _exitStatus = default(uint);
[global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"exit_status", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
[global::System.ComponentModel.DefaultValue(default(uint))]
public uint ExitStatus
{
get { return _exitStatus; }
Expand Down
1 change: 0 additions & 1 deletion src/IronFoundry.Warden.Protocol/ParseProto.ps1
Expand Up @@ -23,7 +23,6 @@ foreach ($proto_file in $proto_files)
$protogen_args += "-i:$in_name"
}

# NB: we can't use -p:fixCase due to type clashes
$protogen_output = & $protogen_exe -p:fixCase -q $protogen_args

Pop-Location -Verbose
Expand Down
2 changes: 2 additions & 0 deletions src/IronFoundry.Warden.Protocol/pb/copy_in.proto
Expand Up @@ -24,6 +24,8 @@
//

package IronFoundry.Warden.Protocol;
import "info.proto";


message CopyInRequest {
required string handle = 1;
Expand Down
2 changes: 2 additions & 0 deletions src/IronFoundry.Warden.Protocol/pb/copy_out.proto
Expand Up @@ -27,6 +27,8 @@
//

package IronFoundry.Warden.Protocol;
import "info.proto";


message CopyOutRequest {
required string handle = 1;
Expand Down
2 changes: 2 additions & 0 deletions src/IronFoundry.Warden.Protocol/pb/create.proto
Expand Up @@ -36,6 +36,8 @@
//

package IronFoundry.Warden.Protocol;
import "info.proto";


message CreateRequest {
message BindMount {
Expand Down
2 changes: 2 additions & 0 deletions src/IronFoundry.Warden.Protocol/pb/destroy.proto
Expand Up @@ -24,6 +24,8 @@
//

package IronFoundry.Warden.Protocol;
import "info.proto";


message DestroyRequest {
required string handle = 1;
Expand Down
2 changes: 2 additions & 0 deletions src/IronFoundry.Warden.Protocol/pb/echo.proto
Expand Up @@ -16,6 +16,8 @@
//

package IronFoundry.Warden.Protocol;
import "info.proto";


message EchoRequest {
required string message = 1;
Expand Down
2 changes: 2 additions & 0 deletions src/IronFoundry.Warden.Protocol/pb/error.proto
Expand Up @@ -11,6 +11,8 @@
//

package IronFoundry.Warden.Protocol;
import "info.proto";


message ErrorResponse {
optional string message = 2;
Expand Down
2 changes: 2 additions & 0 deletions src/IronFoundry.Warden.Protocol/pb/limit_bandwidth.proto
Expand Up @@ -16,6 +16,8 @@
//

package IronFoundry.Warden.Protocol;
import "info.proto";


message LimitBandwidthRequest {
required string handle = 1;
Expand Down
2 changes: 2 additions & 0 deletions src/IronFoundry.Warden.Protocol/pb/limit_disk.proto
Expand Up @@ -32,6 +32,8 @@
//

package IronFoundry.Warden.Protocol;
import "info.proto";


message LimitDiskRequest {
required string handle = 1;
Expand Down
2 changes: 2 additions & 0 deletions src/IronFoundry.Warden.Protocol/pb/limit_memory.proto
Expand Up @@ -22,6 +22,8 @@
//

package IronFoundry.Warden.Protocol;
import "info.proto";


message LimitMemoryRequest {
required string handle = 1;
Expand Down
5 changes: 3 additions & 2 deletions src/IronFoundry.Warden.Protocol/pb/link.proto
Expand Up @@ -25,16 +25,17 @@
//

package IronFoundry.Warden.Protocol;

import "info.proto";


message LinkRequest {
required string handle = 1;

required uint32 job_id = 2;
}

message LinkResponse {
required uint32 exit_status = 1;
optional uint32 exit_status = 1;
optional string stdout = 2;
optional string stderr = 3;
optional InfoResponse info = 4;
Expand Down
2 changes: 2 additions & 0 deletions src/IronFoundry.Warden.Protocol/pb/list.proto
Expand Up @@ -16,6 +16,8 @@
//

package IronFoundry.Warden.Protocol;
import "info.proto";


message ListRequest {
}
Expand Down
2 changes: 2 additions & 0 deletions src/IronFoundry.Warden.Protocol/pb/message.proto
@@ -1,6 +1,8 @@
// nodoc

package IronFoundry.Warden.Protocol;
import "info.proto";


message Message {
enum Type {
Expand Down
2 changes: 2 additions & 0 deletions src/IronFoundry.Warden.Protocol/pb/net_in.proto
Expand Up @@ -25,6 +25,8 @@
//

package IronFoundry.Warden.Protocol;
import "info.proto";


message NetInRequest {
required string handle = 1;
Expand Down
2 changes: 2 additions & 0 deletions src/IronFoundry.Warden.Protocol/pb/net_out.proto
Expand Up @@ -23,6 +23,8 @@
//

package IronFoundry.Warden.Protocol;
import "info.proto";


message NetOutRequest {
required string handle = 1;
Expand Down
2 changes: 2 additions & 0 deletions src/IronFoundry.Warden.Protocol/pb/ping.proto
Expand Up @@ -16,6 +16,8 @@
//

package IronFoundry.Warden.Protocol;
import "info.proto";


message PingRequest {
}
Expand Down
2 changes: 2 additions & 0 deletions src/IronFoundry.Warden.Protocol/pb/resource_limits.proto
Expand Up @@ -10,6 +10,8 @@
//

package IronFoundry.Warden.Protocol;
import "info.proto";


message ResourceLimits {
optional uint64 as = 1;
Expand Down

0 comments on commit 9f8960b

Please sign in to comment.