reef-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Julia Wang (QIUHE)" <Qiuhe.W...@microsoft.com.INVALID>
Subject RE: Tang problem
Date Fri, 14 Apr 2017 17:30:13 GMT
Hi Doug,

You are welcome! 

Tang.Test contains many sample code. They were written for not just testing but showing examples.
As those are small therefor easy to understand, it is a good resource for developers to reference.


Julia

-----Original Message-----
From: Douglas Service [mailto:dsopsrc@gmail.com] 
Sent: Thursday, April 13, 2017 3:45 PM
To: dev@reef.apache.org
Subject: Re: Tang problem

Hello Julia,

From reading your email and looking at the code, I see a number issues that I still need to
fix which I am working on now. I read the Tang documentation on the website and then looked
at many examples in the tests and elsewhere in the code, but I clearly I missed a number of
important issues so thanks for your feedback!

Doug

On Thu, Apr 13, 2017 at 10:25 AM, Julia Wang (QIUHE) < Qiuhe.Wang@microsoft.com.invalid>
wrote:

> Hi Doug,
>
> The email below was stuck in the mail box yesterday afternoon because 
> a network issue. It is now automatically sent out. As you already 
> found the issue, that is fine. But you can still look at my recommendation.
>
> Julia
> -----Original Message-----
> From: Julia Wang (QIUHE) [mailto:Qiuhe.Wang@microsoft.com.INVALID]
> Sent: Thursday, April 13, 2017 10:17 AM
> To: dev@reef.apache.org
> Subject: RE: Tang problem
>
> I am not sure why you have a parameter like this:
>             [Parameter(typeof(NetworkOptions.NetService))]
> INetworkService<string> networkService, INetworkService is an 
> interface, you don't need to define named parameter for it. You can 
> directly put the following line as a parameter in the constructor.
>
> If you really want to use named parameter for this case, then 
> NetService must be defined as a named parameter. But in your code, it 
> is defined as a RequiredParameter
>             public static readonly 
> RequiredParameter<INetworkService<string>>
> NetService = new RequiredParameter<INetworkService<string>>();
>
> You should not bind an interface into a required parameter in 
> configuration module. It should be opposite.
> .BindNamedParameter(GenericType<NetworkOptions.NetService>.Class,
> GenericType<INetworkService<string>>.Class)
>
> To fix it,
> 1. put this line in the constructor instead of [parameter...]
>         INetworkService<string> networkService
>
> 2. Define the following in the ModuleBuilder
>          public static readonly RequiredImpl<INetworkService <string>> 
> NetService = new RequiredImpl<INetworkService<string>>();
> and
>         .BindImplementation(GenericType<INetworkService 
> <string>>.Class, NetworkOptions .NetService)
>
> 3. When you create clientNetworkConfig,
>         .Set(NetworkOptions.NetService, GenericType<NetworkService<
> string>>.Class)
>
> Hope that helps.
>
> Julia
>
> -----Original Message-----
> From: Douglas Service [mailto:dsopsrc@gmail.com]
> Sent: Wednesday, April 12, 2017 3:58 PM
> To: dev@reef.apache.org
> Subject: Tang problem
>
> Given the following constructor.
>
>
>         [Inject]
>         private ClientNetworkService(
>             [Parameter(typeof(NetworkOptions.NetService))]
> INetworkService<string> networkService,
>             [Parameter(typeof(NetworkOptions.ServiceIdentifier))] 
> string serviceIdentifier,
>             [Parameter(typeof(NetworkOptions.ServicePort))] int 
> servicePort,
>             
> [Parameter(typeof(NetworkOptions.RemoteServiceIdentifier))]
> string remoteServiceIdentifier)
>
> with the following module builder
>
>
>         public sealed class ModuleBuilder : ConfigurationModuleBuilder
>         {
>             public static readonly RequiredParameter< 
> INetworkService<string>> NetService = new 
> RequiredParameter<INetworkService<string>>();
>             public static readonly RequiredParameter<string> 
> ServiceIdentifier = new RequiredParameter<string>();
>             public static readonly RequiredParameter<int> ServicePort 
> = new RequiredParameter<int>();
>             public static readonly RequiredParameter<string> 
> RemoteServiceIdentifier = new RequiredParameter<string>();
>
>             // public static readonly
> RequiredParameter<IObserver<NsMessage<string>>>
> ClientMessageHandler
>             //  = new RequiredParameter<IObserver<NsMessage<string>>>();
>             // .BindNamedParameter(GenericType<NetworkOptions.
> kService>.Class,
> NetworkService)
>             public static readonly ConfigurationModule Config = new
> ModuleBuilder()
>                 .BindImplementation(GenericType<INetworkService<
> string>>.Class,
> GenericType<NetworkService<string>>.Class)
>
> .BindNamedParameter(GenericType<NetworkOptions.NetService>.Class,
> GenericType<INetworkService<string>>.Class)
>
> .BindNamedParameter(GenericType<NetworkOptions.ServiceIdentifier>.Clas
> s,
> ServiceIdentifier)
>
> .BindNamedParameter(GenericType<NetworkOptions.ServicePort>.Class,
> ServicePort)
>                 .BindNamedParameter(GenericType<NetworkOptions.
> RemoteServiceIdentifier>.Class, RemoteServiceIdentifier)
>                 .Build();
>
>                 //
> .BindNamedParameter(GenericType<DistRNetworkOptions.MessageHandler>.Cl
> ass,
> MessageHandler)
>         }
>
> When I try to inject,
>
>            IConfiguration nameClientConf = TangFactory.GetTang().
> NewConfigurationBuilder()
>                 .BindNamedParameter<NamingConfigurationOptions.
> NameServerPort,
> int>(
>                     GenericType<NamingConfigurationOptions.
> NameServerPort>.Class,
>                     
> endpoint.Port.ToString(CultureInfo.CurrentCulture))
>
> .BindNamedParameter<NamingConfigurationOptions.NameServerAddress,
> string>(
>
> GenericType<NamingConfigurationOptions.NameServerAddress>.Class,
> endpoint.Address.ToString())
>                 .BindImplementation(GenericType<INameClient>.Class,
> GenericType<NameClient>.Class)
>                 .Build();
>
>             IConfiguration networkServiceConf = TangFactory.GetTang().
> NewConfigurationBuilder()
>                 .BindIntNamedParam<NetworkServiceOptions.
> NetworkServicePort>(servicePort.ToString())
>                 .Build();
>
>             IConfiguration handlerConf = TangFactory.GetTang().
> NewConfigurationBuilder()
>                 .BindImplementation<IObserver<NsMessage<string>>,
> ClientMessageHandler>()
>                 .Build();
>
>             !!!!!!!!!!!THROWS!!!!!!!!!!!!
>             IConfiguration clientNetworkConfig = 
> NetworkOptions.ModuleBuilder.Config
>                 .Set(NetworkOptions.ModuleBuilder.NetService,
> GenericType<INetworkService<string>>.Class)
>                 .Set(NetworkOptions.ModuleBuilder.ServiceIdentifier,
> clientId)
>                 .Set(NetworkOptions.ModuleBuilder.ServicePort,
> servicePort.ToString())
>                 
> .Set(NetworkOptions.ModuleBuilder.RemoteServiceIdentifier,
> driverId)
>                 .Build();
>
>             TangFactory.GetTang().NewInjector(
> GetRuntimeConfiguration(args.Length
> > 0 ? args[0] : Local),
>                 nameClientConf, networkServiceConf, handlerConf, 
> clientNetworkConfig).GetInstance<DistributedRClient>().Run();
>
> the line with "!!!!!!!!!!!THROWS!!!!!!!!!!!!"  throws this exception
>
>
> System.TypeInitializationException occurred
>   HResult=0x80131534
>   Message=The type initializer for 'ModuleBuilder' threw an exception.
>   Source=Org.Apache.REEF.DistributedR
>   StackTrace:
>    at Org.Apache.REEF.DistributedR.DistributedRClient.Main(String[] 
> args) in 
> E:\reef\lang\cs\Org.Apache.REEF.DistributedR\DistributedRClient.cs:lin
> e
> 184
>
> Inner Exception 1:
> ClassHierarchyException: Found declared options that were not used in
> binds: { NetService }
>
>
> However when I remove it and the corresponding code in the 
> ModuleBuilder, I also get an exception about not being able to RDistributedR class.
>
> What am i missing?
>
> Doug
>
Mime
View raw message