110 lines
3.5 KiB
Plaintext
110 lines
3.5 KiB
Plaintext
///////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Microsoft Research Singularity
|
|
//
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
//
|
|
// File: Services\Tests\BenchmarkProxy\BenchmarkJournalProducer.sg
|
|
//
|
|
// Note:
|
|
//
|
|
using System;
|
|
using Microsoft.SingSharp;
|
|
using Microsoft.SingSharp.Reflection;
|
|
using Microsoft.Singularity;
|
|
using Microsoft.Singularity.Channels;
|
|
using Microsoft.Singularity.Configuration;
|
|
using Microsoft.Singularity.Directory;
|
|
using Microsoft.Singularity.Resiliency;
|
|
using Microsoft.Singularity.Security;
|
|
using Microsoft.Singularity.ServiceManager;
|
|
using Microsoft.Singularity.Services;
|
|
|
|
[assembly: Transform(typeof(ServiceResourceTransform))]
|
|
[assembly: ApplicationPublisherAttribute("singularity.microsoft.com")]
|
|
[assembly: AssertPrivilegeAttribute("$register-privilege.localhost")]
|
|
|
|
namespace Microsoft.Singularity.Services.Benchmark
|
|
{
|
|
[Category("Service")]
|
|
internal sealed class Parameters
|
|
{
|
|
[Endpoint]
|
|
public readonly TRef<ManagedServiceContract.Exp:Start> serviceContractRef;
|
|
|
|
[Endpoint]
|
|
public readonly TRef<DirectoryServiceContract.Imp:Ready> directoryContractRef;
|
|
|
|
[Endpoint]
|
|
public readonly TRef<DirectoryServiceContract.Exp:Start> substituteDSRef;
|
|
|
|
[Endpoint]
|
|
public readonly TRef<ManagedProxyContract.Imp:Start> proxyContractRef;
|
|
|
|
reflective private Parameters();
|
|
}
|
|
|
|
internal class BenchmarkJournalProducer : JournalProducer
|
|
{
|
|
internal BenchmarkJournalProducer()
|
|
{
|
|
base();
|
|
}
|
|
|
|
protected override bool Accept(ServiceContract.Exp:Start! ep)
|
|
{
|
|
// ep must be a type of CounterContract.Exp
|
|
BenchmarkContract.Exp:Start cep = ep
|
|
as BenchmarkContract.Exp:Start;
|
|
return (cep != null);
|
|
}
|
|
|
|
protected override void Substitute([Claims]ServiceContract.Exp:Start! ep,
|
|
out ServiceContract.Exp! newEp)
|
|
{
|
|
Journalet! journalet;
|
|
ServiceContract.Exp:Start! serverEp;
|
|
|
|
journalet = new BenchmarkJournalet(this, ep);
|
|
journalet.CreateServerEndpoint(out serverEp);
|
|
journalet.Start();
|
|
RegisterJournalet(journalet);
|
|
newEp = serverEp;
|
|
}
|
|
|
|
internal static int AppMain(Parameters! config)
|
|
{
|
|
ManagedServiceContract.Exp:Start ep;
|
|
DirectoryServiceContract.Imp:Ready dep;
|
|
DirectoryServiceContract.Exp:Start fep;
|
|
ManagedProxyContract.Imp:Start mep;
|
|
|
|
ep = config.serviceContractRef.Acquire();
|
|
dep = config.directoryContractRef.Acquire();
|
|
fep = config.substituteDSRef.Acquire();
|
|
mep = config.proxyContractRef.Acquire();
|
|
|
|
if (ep == null || dep == null || fep == null || mep == null) {
|
|
delete ep;
|
|
delete dep;
|
|
delete fep;
|
|
delete mep;
|
|
return -1;
|
|
}
|
|
|
|
DebugStub.Print("Start BenchmarkJournalProcuder\n");
|
|
|
|
JournalProducer jp = new BenchmarkJournalProducer();
|
|
try {
|
|
jp.Start(ep, dep, fep, mep);
|
|
}
|
|
catch (Exception e) {
|
|
DebugStub.WriteLine(e.ToString());
|
|
DebugStub.WriteLine(e.StackTrace);
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
}
|
|
}
|