private static void WriteConfigFile <T>(Package file, IConfigurationSerializer <T> serializer) where T : class, new() { var fileName = serializer.Filename; var part = file.CreatePart(new Uri("/" + fileName, UriKind.Relative), String.Empty, CompressionOption.Maximum); serializer.Save(serializer.Get(), part.GetStream()); }
private ClientLauncher( ClientService clientService, JavaClientLauncher javaClientLauncher, REEFFileNames reefFileNames, IConfigurationSerializer configurationSerializer, DriverClientParameters driverRuntimeProto, IRuntimeProtoProvider runtimeProtoProvider) { _clientService = clientService; _javaClientLauncher = javaClientLauncher; _reefFileNames = reefFileNames; _configurationSerializer = configurationSerializer; _driverClientConfiguration = driverRuntimeProto.Proto; runtimeProtoProvider.SetParameters(_driverClientConfiguration); _grpcServer = new Server { Services = { BridgeClient.BindService(clientService) }, Ports = { new ServerPort("localhost", 0, ServerCredentials.Insecure) } }; _grpcServer.Start(); Log.Log(Level.Info, "Server port any {0}", _grpcServer.Ports.Any()); foreach (var serverPort in _grpcServer.Ports) { Log.Log(Level.Info, "Server port {0}", serverPort.BoundPort); _grpcServerPort = serverPort.BoundPort; } }
public PostgresRepositoryFactory(ILoggerFactory loggerFactory, IOptions <PostgresOptions> options, IClock clock, IConfigurationSerializer configurationSerializer, ITaskInstanceFactory taskInstanceFactory) { _loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory)); _clock = clock ?? throw new ArgumentNullException(nameof(clock)); _configurationSerializer = configurationSerializer ?? throw new ArgumentNullException(nameof(configurationSerializer)); _taskInstanceFactory = taskInstanceFactory ?? throw new ArgumentNullException(nameof(taskInstanceFactory)); _log = loggerFactory.CreateLogger <PostgresRepositoryFactory>(); _options = options.Value; }
private CloseTaskTestDriver(IEvaluatorRequestor evaluatorRequestor, [Parameter(typeof(DisposeMessage))] string disposeMessage, [Parameter(typeof(TaskConfigurationString))] string taskConfigString, IConfigurationSerializer avroConfigurationSerializer) { _requestor = evaluatorRequestor; _disposeMessage = disposeMessage; _taskConfiguration = avroConfigurationSerializer.FromString(taskConfigString); }
/// <summary> /// Static configuration loader /// </summary> /// <param name="serializer"></param> /// <param name="fileName"></param> /// <returns></returns> protected static TConfig Current(IConfigurationSerializer serializer, string fileName) { var serialized = LoadFromFile(fileName); if (string.IsNullOrEmpty(serialized)) { return(default(TConfig)); } return(serializer.DeserializeObject <TConfig>(serialized)); }
public XmlConfigurationService(string configurationName) { if (String.IsNullOrEmpty(configurationName)) { throw new ArgumentNullException(nameof(configurationName)); } _configContainer = new Lazy <Dictionary <string, string> >(() => InitContainer(configurationName)); _configurationSerializer = new XmlConfigurationSerializer(); }
private DriverServiceClient( IConfigurationSerializer configurationSerializer, [Parameter(Value = typeof(DriverServicePort))] int driverServicePort) { _configurationSerializer = configurationSerializer; Logger.Log(Level.Info, "Binding to driver service at port {0}", driverServicePort); var driverServiceChannel = new Channel("127.0.0.1", driverServicePort, ChannelCredentials.Insecure); _driverServiceStub = new DriverService.DriverServiceClient(driverServiceChannel); Logger.Log(Level.Info, "Channel state {0}", driverServiceChannel.State); }
public void TestFromJsonString() { IConfigurationSerializer serializerImpl = (IConfigurationSerializer)TangFactory.GetTang().NewInjector().GetInstance(typeof(IConfigurationSerializer)); ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder(); cb.BindImplementation(GenericType<ITask>.Class, GenericType<HelloTask>.Class); IConfiguration conf = cb.Build(); string jsonStr = serializerImpl.ToString(conf); IConfiguration c = serializerImpl.FromString(jsonStr); Assert.NotNull(c); string jsonStr2 = serializerImpl.ToString(c); IConfiguration c1 = serializerImpl.FromString(jsonStr2); Assert.NotNull(c1); }
public void SmokeTestConfig() { // Here we set some configuration values. In true tang style, // you won't be able to set them more than once ConfigurationModule's // implementation is complete. Type fooType = typeof(Org.Apache.Reef.Tang.Test.Format.IFoo); IConfiguration c = MyConfigurationModule.Conf .Set(MyConfigurationModule.TheFoo, GenericType <FooImpl> .Class) .Set(MyConfigurationModule.FooNess, "12") .Build(); IFoo f = (IFoo)TangFactory.GetTang().NewInjector(c).GetInstance(fooType); Assert.AreEqual(f.getFooness(), 12); AvroConfigurationSerializer serializerCs = new AvroConfigurationSerializer(); serializerCs.ToFileStream(c, "TangTestCs.avroconf"); var c3 = serializerCs.FromFileStream("TangTestCs.avroconf"); IFoo f3 = (IFoo)TangFactory.GetTang().NewInjector(c3).GetInstance(fooType); Assert.AreEqual(f3.getFooness(), 12); serializerCs.ToFile(c, "TangTestCs1.avro"); var c4 = serializerCs.FromFile("TangTestCs1.avro"); IFoo f4 = (IFoo)TangFactory.GetTang().NewInjector(c4).GetInstance(fooType); Assert.AreEqual(f4.getFooness(), 12); IConfigurationSerializer serializerImpl = (IConfigurationSerializer)TangFactory.GetTang().NewInjector().GetInstance(typeof(IConfigurationSerializer)); serializerImpl.ToFile(c, "TangTestCs1.avro"); var c5 = serializerImpl.FromFile("TangTestCs1.avro"); IFoo f5 = (IFoo)TangFactory.GetTang().NewInjector(c5).GetInstance(fooType); Assert.AreEqual(f5.getFooness(), 12); //this is to test the file generated from Java. name,value b=must be recognized by C# class hierarchy AvroConfigurationSerializer serializer = new AvroConfigurationSerializer(); var avroConfig = serializer.AvroDeseriaizeFromFile("Evaluator.conf"); Assert.IsNotNull(avroConfig); }
public void SmokeTestConfig() { // Here we set some configuration values. In true tang style, // you won't be able to set them more than once ConfigurationModule's // implementation is complete. Type fooType = typeof(Org.Apache.REEF.Tang.Tests.Format.IFoo); IConfiguration c = MyConfigurationModule.Conf .Set(MyConfigurationModule.TheFoo, GenericType <FooImpl> .Class) .Set(MyConfigurationModule.FooNess, "12") .Build(); IFoo f = (IFoo)TangFactory.GetTang().NewInjector(c).GetInstance(fooType); Assert.Equal(f.getFooness(), 12); AvroConfigurationSerializer serializerCs = new AvroConfigurationSerializer(); serializerCs.ToFileStream(c, "TangTestCs.avroconf"); var c3 = serializerCs.FromFileStream("TangTestCs.avroconf"); IFoo f3 = (IFoo)TangFactory.GetTang().NewInjector(c3).GetInstance(fooType); Assert.Equal(f3.getFooness(), 12); serializerCs.ToFile(c, "TangTestCs1.avro"); var c4 = serializerCs.FromFile("TangTestCs1.avro"); IFoo f4 = (IFoo)TangFactory.GetTang().NewInjector(c4).GetInstance(fooType); Assert.Equal(f4.getFooness(), 12); IConfigurationSerializer serializerImpl = (IConfigurationSerializer) TangFactory.GetTang().NewInjector().GetInstance(typeof(IConfigurationSerializer)); serializerImpl.ToFile(c, "TangTestCs1.avro"); var c5 = serializerImpl.FromFile("TangTestCs1.avro"); IFoo f5 = (IFoo)TangFactory.GetTang().NewInjector(c5).GetInstance(fooType); Assert.Equal(f5.getFooness(), 12); }
public SetConfiguration(IConfigurationSerializer serializer, IEncryptor encryptor, IUserConsole userConsole) { _serializer = serializer; _encryptor = encryptor; _userConsole = userConsole; Command = (app) => { app.Description = Messages.ChangeConfigurationDescription; var settings = app.Argument("settings", Messages.SettingDescription, true).Values; var deleteOption = app.Option("-d|--delete", Messages.DeleteRepoOptionDescription, CommandOptionType.NoValue); app.OnExecuteAsync(async token => { var configuration = await _serializer.ReadConfiguration(); var args = settings.Select(s => ParseSetting(s)); var delete = deleteOption.Values.Count > 0; foreach (var arg in args) { switch (arg.Item1) { case ("jenkinsurl"): configuration.JenkinsUrl = GetNewSettingValue(arg, delete); break; case ("username"): configuration.UserName = GetNewSettingValue(arg, delete); break; case ("token"): configuration.Token = GetNewSettingValue(arg, delete); break; case ("password"): configuration.Password = GetNewSettingValue(arg, delete, true); break; case ("repository"): { if (string.IsNullOrWhiteSpace(arg.Item2)) { var repositoryName = _userConsole.ReadInput("repository name"); var jenkinsJob = _userConsole.ReadInput("jenkins job"); configuration.Repository[repositoryName] = jenkinsJob; break; } var repositories = arg.Item2.Split(MultiRepositoriesSeparator); if (delete) { if (repositories.Any(s => s == DefaultPipelineKey)) { throw new JenoException(Messages.RemoveDefaultJobError); } foreach (var repository in repositories) { if (configuration.Repository.ContainsKey(repository)) { configuration.Repository.Remove(repository); } } break; } if (repositories.Any(s => !s.Contains(RepositoryPipelineSeparator))) { throw new JenoException(Messages.WrongReposFormat); } var repos = repositories.Select(s => (s.Split(RepositoryPipelineSeparator)[0], s.Split(RepositoryPipelineSeparator)[1])); if (repos.Select(s => s.Item1).Any(s => string.IsNullOrWhiteSpace(s))) { throw new JenoException(Messages.MissingRepoName); } foreach (var repo in repos) { configuration.Repository[repo.Item1] = repo.Item2; } break; } default: throw new JenoException($"{Messages.UnsupportedSetting}{arg.Item1}"); } ; } try { await _serializer.SaveConfiguration(configuration); } catch (UnauthorizedAccessException) { throw new JenoException(Messages.CannotSaveConfigurationChangesErrorMessage); } return(JenoCodes.Ok); }); }; }
public InputSerializer(IConfigurationSerializer configurationSerializer) { this.ConfigurationSerializer = configurationSerializer; }
public ConfigurationBuilder(IPathResolver pathResolver, IConfigurationSerializer configurationSerializer) { _pathResolver = pathResolver; _configurationSerializer = configurationSerializer; }
protected Configuration(IConfigurationSerializer serializer) : base(serializer) { }
protected ConfigurationReader(IConfigurationSerializer serializer) { _serializer = serializer; }
private DriverLauncher(IConfigurationSerializer configurationSerializer) { _configurationSerializer = configurationSerializer; }
public void Load_uses_serializer([Frozen] IConfigurationSerializer serializer, [Frozen] object testSource, [Frozen] string rootSectionName, ObjectConfigurationProvider sut) { sut.Load(); Mock.Get(serializer).Verify(p => p.Serialize(testSource, rootSectionName), Times.Once); }
public ObjectConfigurationSource(IConfigurationSerializer serializer, object source, string rootSectionName) { _rootSectionName = rootSectionName ?? throw new ArgumentNullException(nameof(rootSectionName)); _source = source ?? throw new ArgumentNullException(nameof(source)); _serializer = serializer ?? throw new ArgumentNullException(nameof(serializer)); }
/// <summary> /// Instantiates an new instance using the given <paramref name="serializer"/> to properly serializes and deserialize <see cref="IConfigurationGroup"/>s. /// </summary> /// <param name="serializer"></param> public BinaryConfigurationSerializer(IConfigurationSerializer <StringBuilder> serializer) : this() => Serializer = serializer ?? throw new ArgumentNullException(nameof(serializer));
/// <inheritdoc /> public AppConfiguration(IConfigurationSerializer serializer) : base(serializer) { }