/// <summary> /// Initializes a new instance of the <see cref="CaptureOrderProcessingStrategy"/> class. /// </summary> /// <param name="paymentProviderFactory">The payment provider factory.</param> /// <param name="transactionDataProvider">The transaction Data Provider.</param> /// <param name="pipelineWrapper">The pipeline wrapper.</param> public CaptureOrderProcessingStrategy(PaymentProviderFactory paymentProviderFactory, ITransactionData transactionDataProvider, PipelineWrapper pipelineWrapper) { Assert.ArgumentNotNull(paymentProviderFactory, "paymentProviderFactory"); Assert.ArgumentNotNull(transactionDataProvider, "transactionDataProvider"); Assert.ArgumentNotNull(pipelineWrapper, "pipelineWrapper"); this.paymentProviderFactory = paymentProviderFactory; this.transactionDataProvider = transactionDataProvider; this.pipelineWrapper = pipelineWrapper; }
public void CtorSavesPipelineReference() { // Arrange. var expectedPipeline = RunspaceFactory .CreateRunspace() .CreatePipeline(); // Act. var wrapper = new PipelineWrapper(expectedPipeline); // Assert. Assert.AreEqual(expectedPipeline, wrapper.Pipeline); }
public void InvokeDelegatesToWrappedPipeline() { // Arrange. var runspace = RunspaceFactory.CreateRunspace(); runspace.Open(); var expectedPipeline = runspace.CreatePipeline("1+1"); var wrapper = new PipelineWrapper(expectedPipeline); // Act. var res = wrapper.Invoke(); // Assert. Assert.AreEqual(2, (int)res[0].BaseObject); }
public virtual DiscoveryItem Discover(PipelineWrapper pipelineWrapper, string taxonomy) { if (string.IsNullOrWhiteSpace(taxonomy)) { return(null); } var current = pipelineWrapper.DiscoveryRoots.FirstOrDefault(r => taxonomy.StartsWith(r.Name)); if (current == null) { return(null); } var path = taxonomy.Substring(current.Name.Length).Split('.').ToList(); while (true) { if (current.Members == null) { current.Members = new List <DiscoveryItem>(); GetMembers(current.Type, current); return(current); } if (path.Count == 0) { break; } var name = path[0]; path.RemoveAt(0); if (string.IsNullOrWhiteSpace(name)) { continue; } current = current.Members.FirstOrDefault(f => f.Name == name); if (current == null) { throw new Exception("Discovery could not find the member " + name); } } return(null); }
/// <exception cref="InvalidOperationException"> /// <paramref name="required"/> is <see langword="true"/> and either <paramref name="vertexShader"/> or <paramref name="fragmentShader"/> is unavailable (their <see cref="Shader.Available"/> property is <see langword="false"/>), or /// <c>glLinkProgram</c> call did not produce expected result /// </exception> public Pipeline CreatePipeline(VertexLayout vertexLayout, Shader vertexShader, Shader fragmentShader, bool required, string memo) { // if the shaders aren't available, the pipeline isn't either if (!vertexShader.Available || !fragmentShader.Available) { string errors = $"Vertex Shader:\r\n {vertexShader.Errors} \r\n-------\r\nFragment Shader:\r\n{fragmentShader.Errors}"; if (required) { throw new InvalidOperationException($"Couldn't build required GL pipeline:\r\n{errors}"); } var pipeline = new Pipeline(this, null, false, null, null, null) { Errors = errors }; return(pipeline); } bool success = true; var vsw = vertexShader.Opaque as ShaderWrapper; var fsw = fragmentShader.Opaque as ShaderWrapper; var sws = new[] { vsw, fsw }; ErrorCode errcode; int pid = GL.CreateProgram(); GL.AttachShader(pid, vsw.sid); errcode = GL.GetError(); GL.AttachShader(pid, fsw.sid); errcode = GL.GetError(); GL.LinkProgram(pid); errcode = GL.GetError(); string resultLog = GL.GetProgramInfoLog(pid); if (errcode != ErrorCode.NoError) { if (required) { throw new InvalidOperationException($"Error creating pipeline (error returned from glLinkProgram): {errcode}\r\n\r\n{resultLog}"); } else { success = false; } } GL.GetProgram(pid, GetProgramParameterName.LinkStatus, out var linkStatus); if (linkStatus == 0) { if (required) { throw new InvalidOperationException($"Error creating pipeline (link status false returned from glLinkProgram): \r\n\r\n{resultLog}"); } else { success = false; } resultLog = GL.GetProgramInfoLog(pid); Util.DebugWriteLine(resultLog); } //need to work on validation. apparently there are some weird caveats to glValidate which make it complicated and possibly excuses (barely) the intel drivers' dysfunctional operation //"A sampler points to a texture unit used by fixed function with an incompatible target" // //info: //http://www.opengl.org/sdk/docs/man/xhtml/glValidateProgram.xml //This function mimics the validation operation that OpenGL implementations must perform when rendering commands are issued while programmable shaders are part of current state. //glValidateProgram checks to see whether the executables contained in program can execute given the current OpenGL state //This function is typically useful only during application development. // //So, this is no big deal. we shouldn't be calling validate right now anyway. //conclusion: glValidate is very complicated and is of virtually no use unless your draw calls are returning errors and you want to know why //GL.ValidateProgram(pid); //errcode = GL.GetError(); //resultLog = GL.GetProgramInfoLog(pid); //if (errcode != ErrorCode.NoError) // throw new InvalidOperationException($"Error creating pipeline (error returned from glValidateProgram): {errcode}\r\n\r\n{resultLog}"); //int validateStatus; //GL.GetProgram(pid, GetProgramParameterName.ValidateStatus, out validateStatus); //if (validateStatus == 0) // throw new InvalidOperationException($"Error creating pipeline (validateStatus status false returned from glValidateProgram): \r\n\r\n{resultLog}"); //set the program to active, in case we need to set sampler uniforms on it GL.UseProgram(pid); //get all the attributes (not needed) List <AttributeInfo> attributes = new List <AttributeInfo>(); GL.GetProgram(pid, GetProgramParameterName.ActiveAttributes, out var nAttributes); for (int i = 0; i < nAttributes; i++) { int size, length; string name = new System.Text.StringBuilder(1024).ToString(); ActiveAttribType type; GL.GetActiveAttrib(pid, i, 1024, out length, out size, out type, out name); attributes.Add(new AttributeInfo() { Handle = new IntPtr(i), Name = name }); } //get all the uniforms List <UniformInfo> uniforms = new List <UniformInfo>(); GL.GetProgram(pid, GetProgramParameterName.ActiveUniforms, out var nUniforms); List <int> samplers = new List <int>(); for (int i = 0; i < nUniforms; i++) { int size, length; string name = new System.Text.StringBuilder(1024).ToString(); GL.GetActiveUniform(pid, i, 1024, out length, out size, out var type, out name); errcode = GL.GetError(); int loc = GL.GetUniformLocation(pid, name); var ui = new UniformInfo { Name = name, Opaque = loc }; if (type == ActiveUniformType.Sampler2D) { ui.IsSampler = true; ui.SamplerIndex = samplers.Count; ui.Opaque = loc | (samplers.Count << 24); samplers.Add(loc); } uniforms.Add(ui); } // deactivate the program, so we don't accidentally use it GL.UseProgram(0); if (!vertexShader.Available) { success = false; } if (!fragmentShader.Available) { success = false; } var pw = new PipelineWrapper { pid = pid, VertexShader = vertexShader, FragmentShader = fragmentShader, SamplerLocs = samplers }; return(new Pipeline(this, pw, success, vertexLayout, uniforms, memo)); }
public Pipeline CreatePipeline(VertexLayout vertexLayout, Shader vertexShader, Shader fragmentShader, bool required, string memo) { //if the shaders arent available, the pipeline isn't either if (!vertexShader.Available || !fragmentShader.Available) { string errors = string.Format("Vertex Shader:\r\n {0} \r\n-------\r\nFragment Shader:\r\n{1}", vertexShader.Errors, fragmentShader.Errors); if (required) { throw new InvalidOperationException("Couldn't build required GL pipeline:\r\n" + errors); } var pipeline = new Pipeline(this, null, false, null, null, null); pipeline.Errors = errors; return(pipeline); } bool success = true; var vsw = vertexShader.Opaque as ShaderWrapper; var fsw = fragmentShader.Opaque as ShaderWrapper; var sws = new[] { vsw, fsw }; bool mapVariables = vsw.MapCodeToNative != null || fsw.MapCodeToNative != null; ErrorCode errcode; int pid = GL.CreateProgram(); GL.AttachShader(pid, vsw.sid); errcode = GL.GetError(); GL.AttachShader(pid, fsw.sid); errcode = GL.GetError(); //NOT BEING USED NOW: USING SEMANTICS INSTEAD ////bind the attribute locations from the vertex layout ////as we go, look for attribute mappings (CGC will happily reorder and rename our attribute mappings) ////what's more it will _RESIZE_ them but this seems benign..somehow.. ////WELLLLLLL we wish we could do that by names ////but the shaders dont seem to be adequate quality (oddly named attributes.. texCoord vs texCoord1). need to use semantics instead. //foreach (var kvp in vertexLayout.Items) //{ // string name = kvp.Value.Name; // //if (mapVariables) // //{ // // foreach (var sw in sws) // // { // // if (sw.MapNativeToCode.ContainsKey(name)) // // { // // name = sw.MapNativeToCode[name]; // // break; // // } // // } // //} // if(mapVariables) { // ////proxy for came-from-cgc // //switch (kvp.Value.Usage) // //{ // // case AttributeUsage.Position: // //} // } // //GL.BindAttribLocation(pid, kvp.Key, name); //} GL.LinkProgram(pid); errcode = GL.GetError(); string resultLog = GL.GetProgramInfoLog(pid); if (errcode != ErrorCode.NoError) { if (required) { throw new InvalidOperationException("Error creating pipeline (error returned from glLinkProgram): " + errcode + "\r\n\r\n" + resultLog); } else { success = false; } } int linkStatus; GL.GetProgram(pid, GetProgramParameterName.LinkStatus, out linkStatus); if (linkStatus == 0) { if (required) { throw new InvalidOperationException("Error creating pipeline (link status false returned from glLinkProgram): " + "\r\n\r\n" + resultLog); } else { success = false; } } //need to work on validation. apparently there are some weird caveats to glValidate which make it complicated and possibly excuses (barely) the intel drivers' dysfunctional operation //"A sampler points to a texture unit used by fixed function with an incompatible target" // //info: //http://www.opengl.org/sdk/docs/man/xhtml/glValidateProgram.xml //This function mimics the validation operation that OpenGL implementations must perform when rendering commands are issued while programmable shaders are part of current state. //glValidateProgram checks to see whether the executables contained in program can execute given the current OpenGL state //This function is typically useful only during application development. // //So, this is no big deal. we shouldnt be calling validate right now anyway. //conclusion: glValidate is very complicated and is of virtually no use unless your draw calls are returning errors and you want to know why //GL.ValidateProgram(pid); //errcode = GL.GetError(); //resultLog = GL.GetProgramInfoLog(pid); //if (errcode != ErrorCode.NoError) // throw new InvalidOperationException("Error creating pipeline (error returned from glValidateProgram): " + errcode + "\r\n\r\n" + resultLog); //int validateStatus; //GL.GetProgram(pid, GetProgramParameterName.ValidateStatus, out validateStatus); //if (validateStatus == 0) // throw new InvalidOperationException("Error creating pipeline (validateStatus status false returned from glValidateProgram): " + "\r\n\r\n" + resultLog); //set the program to active, in case we need to set sampler uniforms on it GL.UseProgram(pid); //get all the attributes (not needed) List <AttributeInfo> attributes = new List <AttributeInfo>(); int nAttributes; GL.GetProgram(pid, GetProgramParameterName.ActiveAttributes, out nAttributes); for (int i = 0; i < nAttributes; i++) { int size, length; string name = new System.Text.StringBuilder(1024).ToString(); ActiveAttribType type; GL.GetActiveAttrib(pid, i, 1024, out length, out size, out type, out name); attributes.Add(new AttributeInfo() { Handle = new IntPtr(i), Name = name }); } //get all the uniforms List <UniformInfo> uniforms = new List <UniformInfo>(); int nUniforms; GL.GetProgram(pid, GetProgramParameterName.ActiveUniforms, out nUniforms); List <int> samplers = new List <int>(); for (int i = 0; i < nUniforms; i++) { int size, length; ActiveUniformType type; string name = new System.Text.StringBuilder(1024).ToString().ToString(); GL.GetActiveUniform(pid, i, 1024, out length, out size, out type, out name); errcode = GL.GetError(); int loc = GL.GetUniformLocation(pid, name); //translate name if appropriate //not sure how effective this approach will be, due to confusion of vertex and fragment uniforms if (mapVariables) { if (vsw.MapCodeToNative.ContainsKey(name)) { name = vsw.MapCodeToNative[name]; } if (fsw.MapCodeToNative.ContainsKey(name)) { name = fsw.MapCodeToNative[name]; } } var ui = new UniformInfo(); ui.Name = name; ui.Opaque = loc; if (type == ActiveUniformType.Sampler2D) { ui.IsSampler = true; ui.SamplerIndex = samplers.Count; ui.Opaque = loc | (samplers.Count << 24); samplers.Add(loc); } uniforms.Add(ui); } //deactivate the program, so we dont accidentally use it GL.UseProgram(0); if (!vertexShader.Available) { success = false; } if (!fragmentShader.Available) { success = false; } var pw = new PipelineWrapper() { pid = pid, VertexShader = vertexShader, FragmentShader = fragmentShader, SamplerLocs = samplers }; return(new Pipeline(this, pw, success, vertexLayout, uniforms, memo)); }
public Pipeline CreatePipeline(VertexLayout vertexLayout, Shader vertexShader, Shader fragmentShader, bool required, string memo) { if (!vertexShader.Available || !fragmentShader.Available) { string errors = string.Format("Vertex Shader:\r\n {0} \r\n-------\r\nFragment Shader:\r\n{1}", vertexShader.Errors, fragmentShader.Errors); if (required) { throw new InvalidOperationException("Couldn't build required GL pipeline:\r\n" + errors); } var pipeline = new Pipeline(this, null, false, null, null, null); pipeline.Errors = errors; return(pipeline); } VertexElement[] ves = new VertexElement[vertexLayout.Items.Count]; int stride = 0; foreach (var kvp in vertexLayout.Items) { var item = kvp.Value; d3d9.DeclarationType decltype = DeclarationType.Float1; switch (item.AttribType) { case gl.VertexAttribPointerType.Float: if (item.Components == 1) { decltype = DeclarationType.Float1; } else if (item.Components == 2) { decltype = DeclarationType.Float2; } else if (item.Components == 3) { decltype = DeclarationType.Float3; } else if (item.Components == 4) { decltype = DeclarationType.Float4; } else { throw new NotSupportedException(); } stride += 4 * item.Components; break; default: throw new NotSupportedException(); } d3d9.DeclarationUsage usage = DeclarationUsage.Position; byte usageIndex = 0; switch (item.Usage) { case AttributeUsage.Position: usage = DeclarationUsage.Position; break; case AttributeUsage.Texcoord0: usage = DeclarationUsage.TextureCoordinate; break; case AttributeUsage.Texcoord1: usage = DeclarationUsage.TextureCoordinate; usageIndex = 1; break; case AttributeUsage.Color0: usage = DeclarationUsage.Color; break; default: throw new NotSupportedException(); } ves[kvp.Key] = new VertexElement(0, (short)item.Offset, decltype, DeclarationMethod.Default, usage, usageIndex); } var pw = new PipelineWrapper() { VertexDeclaration = new VertexDeclaration(dev, ves), VertexShader = vertexShader.Opaque as ShaderWrapper, FragmentShader = fragmentShader.Opaque as ShaderWrapper, VertexStride = stride, }; //scan uniforms from constant tables //handles must be disposed later (with the pipeline probably) var uniforms = new List <UniformInfo>(); var fs = pw.FragmentShader; var vs = pw.VertexShader; var fsct = fs.bytecode.ConstantTable; var vsct = vs.bytecode.ConstantTable; foreach (var ct in new[] { fsct, vsct }) { Queue <Tuple <string, EffectHandle> > todo = new Queue <Tuple <string, EffectHandle> >(); int n = ct.Description.Constants; for (int i = 0; i < n; i++) { var handle = ct.GetConstant(null, i); todo.Enqueue(Tuple.Create("", handle)); } while (todo.Count != 0) { var tuple = todo.Dequeue(); var prefix = tuple.Item1; var handle = tuple.Item2; var descr = ct.GetConstantDescription(handle); //Console.WriteLine("D3D UNIFORM: " + descr.Name); if (descr.StructMembers != 0) { string newprefix = prefix + descr.Name + "."; for (int j = 0; j < descr.StructMembers; j++) { var subhandle = ct.GetConstant(handle, j); todo.Enqueue(Tuple.Create(newprefix, subhandle)); } continue; } UniformInfo ui = new UniformInfo(); UniformWrapper uw = new UniformWrapper(); ui.Opaque = uw; string name = prefix + descr.Name; //mehhh not happy about this stuff if (fs.MapCodeToNative != null || vs.MapCodeToNative != null) { string key = name.TrimStart('$'); if (descr.Rows != 1) { key = key + "[0]"; } if (fs.MapCodeToNative != null && ct == fsct) { if (fs.MapCodeToNative.ContainsKey(key)) { name = fs.MapCodeToNative[key]; } } if (vs.MapCodeToNative != null && ct == vsct) { if (vs.MapCodeToNative.ContainsKey(key)) { name = vs.MapCodeToNative[key]; } } } ui.Name = name; uw.Description = descr; uw.EffectHandle = handle; uw.FS = (ct == fsct); uw.CT = ct; if (descr.Type == ParameterType.Sampler2D) { ui.IsSampler = true; ui.SamplerIndex = descr.RegisterIndex; uw.SamplerIndex = descr.RegisterIndex; } uniforms.Add(ui); } } pw.fsct = fsct; pw.vsct = vsct; return(new Pipeline(this, pw, true, vertexLayout, uniforms, memo)); }
public Pipeline CreatePipeline(VertexLayout vertexLayout, Shader vertexShader, Shader fragmentShader, bool required, string memo) { if (!vertexShader.Available || !fragmentShader.Available) { string errors = string.Format("Vertex Shader:\r\n {0} \r\n-------\r\nFragment Shader:\r\n{1}", vertexShader.Errors, fragmentShader.Errors); if (required) throw new InvalidOperationException("Couldn't build required GL pipeline:\r\n" + errors); var pipeline = new Pipeline(this, null, false, null, null, null); pipeline.Errors = errors; return pipeline; } VertexElement[] ves = new VertexElement[vertexLayout.Items.Count]; int stride = 0; foreach (var kvp in vertexLayout.Items) { var item = kvp.Value; d3d9.DeclarationType decltype = DeclarationType.Float1; switch (item.AttribType) { case gl.VertexAttribPointerType.Float: if (item.Components == 1) decltype = DeclarationType.Float1; else if (item.Components == 2) decltype = DeclarationType.Float2; else if (item.Components == 3) decltype = DeclarationType.Float3; else if (item.Components == 4) decltype = DeclarationType.Float4; else throw new NotSupportedException(); stride += 4 * item.Components; break; default: throw new NotSupportedException(); } d3d9.DeclarationUsage usage = DeclarationUsage.Position; byte usageIndex = 0; switch(item.Usage) { case AttributeUsage.Position: usage = DeclarationUsage.Position; break; case AttributeUsage.Texcoord0: usage = DeclarationUsage.TextureCoordinate; break; case AttributeUsage.Texcoord1: usage = DeclarationUsage.TextureCoordinate; usageIndex = 1; break; case AttributeUsage.Color0: usage = DeclarationUsage.Color; break; default: throw new NotSupportedException(); } ves[kvp.Key] = new VertexElement(0, (short)item.Offset, decltype, DeclarationMethod.Default, usage, usageIndex); } var pw = new PipelineWrapper() { VertexDeclaration = new VertexDeclaration(dev, ves), VertexShader = vertexShader.Opaque as ShaderWrapper, FragmentShader = fragmentShader.Opaque as ShaderWrapper, VertexStride = stride, }; //scan uniforms from constant tables //handles must be disposed later (with the pipeline probably) var uniforms = new List<UniformInfo>(); var fs = pw.FragmentShader; var vs = pw.VertexShader; var fsct = fs.bytecode.ConstantTable; var vsct = vs.bytecode.ConstantTable; foreach(var ct in new[]{fsct,vsct}) { Queue<Tuple<string,EffectHandle>> todo = new Queue<Tuple<string,EffectHandle>>(); int n = ct.Description.Constants; for (int i = 0; i < n; i++) { var handle = ct.GetConstant(null, i); todo.Enqueue(Tuple.Create("", handle)); } while(todo.Count != 0) { var tuple = todo.Dequeue(); var prefix = tuple.Item1; var handle = tuple.Item2; var descr = ct.GetConstantDescription(handle); //Console.WriteLine("D3D UNIFORM: " + descr.Name); if (descr.StructMembers != 0) { string newprefix = prefix + descr.Name + "."; for (int j = 0; j < descr.StructMembers; j++) { var subhandle = ct.GetConstant(handle, j); todo.Enqueue(Tuple.Create(newprefix, subhandle)); } continue; } UniformInfo ui = new UniformInfo(); UniformWrapper uw = new UniformWrapper(); ui.Opaque = uw; string name = prefix + descr.Name; //mehhh not happy about this stuff if (fs.MapCodeToNative != null || vs.MapCodeToNative != null) { string key = name.TrimStart('$'); if (descr.Rows != 1) key = key + "[0]"; if (fs.MapCodeToNative != null && ct == fsct) if (fs.MapCodeToNative.ContainsKey(key)) name = fs.MapCodeToNative[key]; if (vs.MapCodeToNative != null && ct == vsct) if (vs.MapCodeToNative.ContainsKey(key)) name = vs.MapCodeToNative[key]; } ui.Name = name; uw.Description = descr; uw.EffectHandle = handle; uw.FS = (ct == fsct); uw.CT = ct; if (descr.Type == ParameterType.Sampler2D) { ui.IsSampler = true; ui.SamplerIndex = descr.RegisterIndex; uw.SamplerIndex = descr.RegisterIndex; } uniforms.Add(ui); } } pw.fsct = fsct; pw.vsct = vsct; return new Pipeline(this, pw, true, vertexLayout, uniforms,memo); }
public Pipeline CreatePipeline(VertexLayout vertexLayout, Shader vertexShader, Shader fragmentShader, bool required, string memo) { //if the shaders arent available, the pipeline isn't either if (!vertexShader.Available || !fragmentShader.Available) { string errors = string.Format("Vertex Shader:\r\n {0} \r\n-------\r\nFragment Shader:\r\n{1}", vertexShader.Errors, fragmentShader.Errors); if (required) throw new InvalidOperationException("Couldn't build required GL pipeline:\r\n" + errors); var pipeline = new Pipeline(this, null, false, null, null, null); pipeline.Errors = errors; return pipeline; } bool success = true; var vsw = vertexShader.Opaque as ShaderWrapper; var fsw = fragmentShader.Opaque as ShaderWrapper; var sws = new[] { vsw,fsw }; bool mapVariables = vsw.MapCodeToNative != null || fsw.MapCodeToNative != null; ErrorCode errcode; int pid = GL.CreateProgram(); GL.AttachShader(pid, vsw.sid); errcode = GL.GetError(); GL.AttachShader(pid, fsw.sid); errcode = GL.GetError(); //NOT BEING USED NOW: USING SEMANTICS INSTEAD ////bind the attribute locations from the vertex layout ////as we go, look for attribute mappings (CGC will happily reorder and rename our attribute mappings) ////what's more it will _RESIZE_ them but this seems benign..somehow.. ////WELLLLLLL we wish we could do that by names ////but the shaders dont seem to be adequate quality (oddly named attributes.. texCoord vs texCoord1). need to use semantics instead. //foreach (var kvp in vertexLayout.Items) //{ // string name = kvp.Value.Name; // //if (mapVariables) // //{ // // foreach (var sw in sws) // // { // // if (sw.MapNativeToCode.ContainsKey(name)) // // { // // name = sw.MapNativeToCode[name]; // // break; // // } // // } // //} // if(mapVariables) { // ////proxy for came-from-cgc // //switch (kvp.Value.Usage) // //{ // // case AttributeUsage.Position: // //} // } // //GL.BindAttribLocation(pid, kvp.Key, name); //} GL.LinkProgram(pid); errcode = GL.GetError(); string resultLog = GL.GetProgramInfoLog(pid); if (errcode != ErrorCode.NoError) if (required) throw new InvalidOperationException("Error creating pipeline (error returned from glLinkProgram): " + errcode + "\r\n\r\n" + resultLog); else success = false; int linkStatus; GL.GetProgram(pid, GetProgramParameterName.LinkStatus, out linkStatus); if (linkStatus == 0) if (required) throw new InvalidOperationException("Error creating pipeline (link status false returned from glLinkProgram): " + "\r\n\r\n" + resultLog); else success = false; //need to work on validation. apparently there are some weird caveats to glValidate which make it complicated and possibly excuses (barely) the intel drivers' dysfunctional operation //"A sampler points to a texture unit used by fixed function with an incompatible target" // //info: //http://www.opengl.org/sdk/docs/man/xhtml/glValidateProgram.xml //This function mimics the validation operation that OpenGL implementations must perform when rendering commands are issued while programmable shaders are part of current state. //glValidateProgram checks to see whether the executables contained in program can execute given the current OpenGL state //This function is typically useful only during application development. // //So, this is no big deal. we shouldnt be calling validate right now anyway. //conclusion: glValidate is very complicated and is of virtually no use unless your draw calls are returning errors and you want to know why //GL.ValidateProgram(pid); //errcode = GL.GetError(); //resultLog = GL.GetProgramInfoLog(pid); //if (errcode != ErrorCode.NoError) // throw new InvalidOperationException("Error creating pipeline (error returned from glValidateProgram): " + errcode + "\r\n\r\n" + resultLog); //int validateStatus; //GL.GetProgram(pid, GetProgramParameterName.ValidateStatus, out validateStatus); //if (validateStatus == 0) // throw new InvalidOperationException("Error creating pipeline (validateStatus status false returned from glValidateProgram): " + "\r\n\r\n" + resultLog); //set the program to active, in case we need to set sampler uniforms on it GL.UseProgram(pid); //get all the attributes (not needed) List<AttributeInfo> attributes = new List<AttributeInfo>(); int nAttributes; GL.GetProgram(pid, GetProgramParameterName.ActiveAttributes, out nAttributes); for (int i = 0; i < nAttributes; i++) { int size, length; var sbName = new System.Text.StringBuilder(1024); ActiveAttribType type; GL.GetActiveAttrib(pid, i, 1024, out length, out size, out type, sbName); attributes.Add(new AttributeInfo() { Handle = new IntPtr(i), Name = sbName.ToString() }); } //get all the uniforms List<UniformInfo> uniforms = new List<UniformInfo>(); int nUniforms; GL.GetProgram(pid,GetProgramParameterName.ActiveUniforms,out nUniforms); List<int> samplers = new List<int>(); for (int i = 0; i < nUniforms; i++) { int size, length; ActiveUniformType type; var sbName = new System.Text.StringBuilder(1024); GL.GetActiveUniform(pid, i, 1024, out length, out size, out type, sbName); errcode = GL.GetError(); string name = sbName.ToString(); int loc = GL.GetUniformLocation(pid, name); //translate name if appropriate //not sure how effective this approach will be, due to confusion of vertex and fragment uniforms if (mapVariables) { if (vsw.MapCodeToNative.ContainsKey(name)) name = vsw.MapCodeToNative[name]; if (fsw.MapCodeToNative.ContainsKey(name)) name = fsw.MapCodeToNative[name]; } var ui = new UniformInfo(); ui.Name = name; ui.Opaque = loc; if (type == ActiveUniformType.Sampler2D) { ui.IsSampler = true; ui.SamplerIndex = samplers.Count; ui.Opaque = loc | (samplers.Count << 24); samplers.Add(loc); } uniforms.Add(ui); } //deactivate the program, so we dont accidentally use it GL.UseProgram(0); if (!vertexShader.Available) success = false; if (!fragmentShader.Available) success = false; var pw = new PipelineWrapper() { pid = pid, VertexShader = vertexShader, FragmentShader = fragmentShader, SamplerLocs = samplers }; return new Pipeline(this, pw, success, vertexLayout, uniforms, memo); }
public Pipeline CreatePipeline(VertexLayout vertexLayout, Shader vertexShader, Shader fragmentShader, bool required) { VertexElement[] ves = new VertexElement[vertexLayout.Items.Count]; foreach (var kvp in vertexLayout.Items) { var item = kvp.Value; d3d9.DeclarationType decltype = DeclarationType.Float1; switch (item.AttribType) { case gl.VertexAttribPointerType.Float: if (item.Components == 1) decltype = DeclarationType.Float1; else if (item.Components == 2) decltype = DeclarationType.Float2; else if (item.Components == 3) decltype = DeclarationType.Float3; else if (item.Components == 4) decltype = DeclarationType.Float4; else throw new NotSupportedException(); break; default: throw new NotSupportedException(); } d3d9.DeclarationUsage usage = DeclarationUsage.Position; byte usageIndex = 0; switch(item.Usage) { case AttributeUsage.Position: usage = DeclarationUsage.Position; break; case AttributeUsage.Texcoord0: usage = DeclarationUsage.TextureCoordinate; break; case AttributeUsage.Texcoord1: usage = DeclarationUsage.TextureCoordinate; usageIndex = 1; break; case AttributeUsage.Color0: usage = DeclarationUsage.Color; break; default: throw new NotSupportedException(); } ves[kvp.Key] = new VertexElement(0, (short)item.Offset, decltype, DeclarationMethod.Default, usage, usageIndex); } var pw = new PipelineWrapper(); pw.VertexDeclaration = new VertexDeclaration(dev, ves); Pipeline pipeline = new Pipeline(this,IntPtr.Zero,true, vertexLayout, new List<UniformInfo>()); pipeline.Opaque = pw; return pipeline; }
public Pipeline CreatePipeline(VertexLayout vertexLayout, Shader vertexShader, Shader fragmentShader, bool required) { VertexElement[] ves = new VertexElement[vertexLayout.Items.Count]; foreach (var kvp in vertexLayout.Items) { var item = kvp.Value; d3d9.DeclarationType decltype = DeclarationType.Float1; switch (item.AttribType) { case gl.VertexAttribPointerType.Float: if (item.Components == 1) { decltype = DeclarationType.Float1; } else if (item.Components == 2) { decltype = DeclarationType.Float2; } else if (item.Components == 3) { decltype = DeclarationType.Float3; } else if (item.Components == 4) { decltype = DeclarationType.Float4; } else { throw new NotSupportedException(); } break; default: throw new NotSupportedException(); } d3d9.DeclarationUsage usage = DeclarationUsage.Position; byte usageIndex = 0; switch (item.Usage) { case AttributeUsage.Position: usage = DeclarationUsage.Position; break; case AttributeUsage.Texcoord0: usage = DeclarationUsage.TextureCoordinate; break; case AttributeUsage.Texcoord1: usage = DeclarationUsage.TextureCoordinate; usageIndex = 1; break; case AttributeUsage.Color0: usage = DeclarationUsage.Color; break; default: throw new NotSupportedException(); } ves[kvp.Key] = new VertexElement(0, (short)item.Offset, decltype, DeclarationMethod.Default, usage, usageIndex); } var pw = new PipelineWrapper(); pw.VertexDeclaration = new VertexDeclaration(dev, ves); Pipeline pipeline = new Pipeline(this, IntPtr.Zero, true, vertexLayout, new List <UniformInfo>()); pipeline.Opaque = pw; return(pipeline); }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected: //ORIGINAL LINE: public EnterpriseReadReplicaEditionModule(final org.neo4j.graphdb.factory.module.PlatformModule platformModule, final org.neo4j.causalclustering.discovery.DiscoveryServiceFactory discoveryServiceFactory, org.neo4j.causalclustering.identity.MemberId myself) public EnterpriseReadReplicaEditionModule(PlatformModule platformModule, DiscoveryServiceFactory discoveryServiceFactory, MemberId myself) { LogService logging = platformModule.Logging; IoLimiterConflict = new ConfigurableIOLimiter(platformModule.Config); platformModule.JobScheduler.TopLevelGroupName = "ReadReplica " + myself; Dependencies dependencies = platformModule.Dependencies; Config config = platformModule.Config; FileSystemAbstraction fileSystem = platformModule.FileSystem; PageCache pageCache = platformModule.PageCache; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.io.layout.DatabaseLayout databaseLayout = platformModule.storeLayout.databaseLayout(config.get(org.neo4j.graphdb.factory.GraphDatabaseSettings.active_database)); DatabaseLayout databaseLayout = platformModule.StoreLayout.databaseLayout(config.Get(GraphDatabaseSettings.active_database)); LifeSupport life = platformModule.Life; ThreadToTransactionBridgeConflict = dependencies.SatisfyDependency(new ThreadToStatementContextBridge(GetGlobalAvailabilityGuard(platformModule.Clock, logging, platformModule.Config))); this.AccessCapabilityConflict = new ReadOnly(); WatcherServiceFactoryConflict = dir => CreateFileSystemWatcherService(fileSystem, dir, logging, platformModule.JobScheduler, config, FileWatcherFileNameFilter()); dependencies.SatisfyDependencies(WatcherServiceFactoryConflict); ReadReplicaLockManager emptyLockManager = new ReadReplicaLockManager(); LocksSupplierConflict = () => emptyLockManager; StatementLocksFactoryProviderConflict = locks => (new StatementLocksFactorySelector(locks, config, logging)).select(); IdContextFactoryConflict = IdContextFactoryBuilder.of(new EnterpriseIdTypeConfigurationProvider(config), platformModule.JobScheduler).withFileSystem(fileSystem).build(); TokenHoldersProviderConflict = databaseName => new TokenHolders(new DelegatingTokenHolder(new ReadOnlyTokenCreator(), Org.Neo4j.Kernel.impl.core.TokenHolder_Fields.TYPE_PROPERTY_KEY), new DelegatingTokenHolder(new ReadOnlyTokenCreator(), Org.Neo4j.Kernel.impl.core.TokenHolder_Fields.TYPE_LABEL), new DelegatingTokenHolder(new ReadOnlyTokenCreator(), Org.Neo4j.Kernel.impl.core.TokenHolder_Fields.TYPE_RELATIONSHIP_TYPE)); File contextDirectory = platformModule.StoreLayout.storeDirectory(); life.Add(dependencies.SatisfyDependency(new KernelData(fileSystem, pageCache, contextDirectory, config, platformModule.DataSourceManager))); HeaderInformationFactoryConflict = TransactionHeaderInformationFactory.DEFAULT; SchemaWriteGuardConflict = () => { }; TransactionStartTimeoutConflict = config.Get(GraphDatabaseSettings.transaction_start_timeout).toMillis(); ConstraintSemanticsConflict = new EnterpriseConstraintSemantics(); PublishEditionInfo(dependencies.ResolveDependency(typeof(UsageData)), platformModule.DatabaseInfo, config); CommitProcessFactoryConflict = ReadOnly(); ConnectionTrackerConflict = dependencies.SatisfyDependency(CreateConnectionTracker()); _logProvider = platformModule.Logging.InternalLogProvider; LogProvider userLogProvider = platformModule.Logging.UserLogProvider; _logProvider.getLog(this.GetType()).info(string.Format("Generated new id: {0}", myself)); RemoteMembersResolver hostnameResolver = chooseResolver(config, platformModule.Logging); ConfigureDiscoveryService(discoveryServiceFactory, dependencies, config, _logProvider); _topologyService = discoveryServiceFactory.ReadReplicaTopologyService(config, _logProvider, platformModule.JobScheduler, myself, hostnameResolver, ResolveStrategy(config, _logProvider)); life.Add(dependencies.SatisfyDependency(_topologyService)); // We need to satisfy the dependency here to keep users of it, such as BoltKernelExtension, happy. dependencies.SatisfyDependency(SslPolicyLoader.create(config, _logProvider)); DuplexPipelineWrapperFactory pipelineWrapperFactory = pipelineWrapperFactory(); PipelineWrapper serverPipelineWrapper = pipelineWrapperFactory.ForServer(config, dependencies, _logProvider, CausalClusteringSettings.ssl_policy); PipelineWrapper clientPipelineWrapper = pipelineWrapperFactory.ForClient(config, dependencies, _logProvider, CausalClusteringSettings.ssl_policy); PipelineWrapper backupServerPipelineWrapper = pipelineWrapperFactory.ForServer(config, dependencies, _logProvider, OnlineBackupSettings.ssl_policy); NettyPipelineBuilderFactory clientPipelineBuilderFactory = new NettyPipelineBuilderFactory(clientPipelineWrapper); NettyPipelineBuilderFactory serverPipelineBuilderFactory = new NettyPipelineBuilderFactory(serverPipelineWrapper); NettyPipelineBuilderFactory backupServerPipelineBuilderFactory = new NettyPipelineBuilderFactory(backupServerPipelineWrapper); SupportedProtocolCreator supportedProtocolCreator = new SupportedProtocolCreator(config, _logProvider); ApplicationSupportedProtocols supportedCatchupProtocols = supportedProtocolCreator.CreateSupportedCatchupProtocol(); ICollection <ModifierSupportedProtocols> supportedModifierProtocols = supportedProtocolCreator.CreateSupportedModifierProtocols(); ApplicationProtocolRepository applicationProtocolRepository = new ApplicationProtocolRepository(Protocol_ApplicationProtocols.values(), supportedCatchupProtocols); ModifierProtocolRepository modifierProtocolRepository = new ModifierProtocolRepository(Org.Neo4j.causalclustering.protocol.Protocol_ModifierProtocols.values(), supportedModifierProtocols); System.Func <CatchUpResponseHandler, ChannelInitializer <SocketChannel> > channelInitializer = handler => { ProtocolInstallerRepository <ProtocolInstaller.Orientation.Client> protocolInstallerRepository = new ProtocolInstallerRepository <ProtocolInstaller.Orientation.Client>(singletonList(new CatchupProtocolClientInstaller.Factory(clientPipelineBuilderFactory, _logProvider, handler)), ModifierProtocolInstaller.allClientInstallers); Duration handshakeTimeout = config.Get(CausalClusteringSettings.handshake_timeout); return(new HandshakeClientInitializer(applicationProtocolRepository, modifierProtocolRepository, protocolInstallerRepository, clientPipelineBuilderFactory, handshakeTimeout, _logProvider, userLogProvider)); }; long inactivityTimeoutMs = config.Get(CausalClusteringSettings.catch_up_client_inactivity_timeout).toMillis(); CatchUpClient catchUpClient = life.Add(new CatchUpClient(_logProvider, Clocks.systemClock(), inactivityTimeoutMs, channelInitializer)); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final System.Func<org.neo4j.kernel.internal.DatabaseHealth> databaseHealthSupplier = () -> platformModule.dataSourceManager.getDataSource().getDependencyResolver().resolveDependency(org.neo4j.kernel.internal.DatabaseHealth.class); System.Func <DatabaseHealth> databaseHealthSupplier = () => platformModule.DataSourceManager.DataSource.DependencyResolver.resolveDependency(typeof(DatabaseHealth)); StoreFiles storeFiles = new StoreFiles(fileSystem, pageCache); LogFiles logFiles = BuildLocalDatabaseLogFiles(platformModule, fileSystem, databaseLayout, config); LocalDatabase localDatabase = new LocalDatabase(databaseLayout, storeFiles, logFiles, platformModule.DataSourceManager, databaseHealthSupplier, GetGlobalAvailabilityGuard(platformModule.Clock, platformModule.Logging, platformModule.Config), _logProvider); System.Func <TransactionCommitProcess> writableCommitProcess = () => new TransactionRepresentationCommitProcess(localDatabase.DataSource().DependencyResolver.resolveDependency(typeof(TransactionAppender)), localDatabase.DataSource().DependencyResolver.resolveDependency(typeof(StorageEngine))); LifeSupport txPulling = new LifeSupport(); int maxBatchSize = config.Get(CausalClusteringSettings.read_replica_transaction_applier_batch_size); CommandIndexTracker commandIndexTracker = platformModule.Dependencies.satisfyDependency(new CommandIndexTracker()); BatchingTxApplier batchingTxApplier = new BatchingTxApplier(maxBatchSize, () => localDatabase.DataSource().DependencyResolver.resolveDependency(typeof(TransactionIdStore)), writableCommitProcess, platformModule.Monitors, platformModule.Tracers.pageCursorTracerSupplier, platformModule.VersionContextSupplier, commandIndexTracker, _logProvider); TimerService timerService = new TimerService(platformModule.JobScheduler, _logProvider); ExponentialBackoffStrategy storeCopyBackoffStrategy = new ExponentialBackoffStrategy(1, config.Get(CausalClusteringSettings.store_copy_backoff_max_wait).toMillis(), TimeUnit.MILLISECONDS); RemoteStore remoteStore = new RemoteStore(platformModule.Logging.InternalLogProvider, fileSystem, platformModule.PageCache, new StoreCopyClient(catchUpClient, platformModule.Monitors, _logProvider, storeCopyBackoffStrategy), new TxPullClient(catchUpClient, platformModule.Monitors), new TransactionLogCatchUpFactory(), config, platformModule.Monitors); CopiedStoreRecovery copiedStoreRecovery = new CopiedStoreRecovery(config, platformModule.KernelExtensionFactories, platformModule.PageCache); txPulling.Add(copiedStoreRecovery); CompositeSuspendable servicesToStopOnStoreCopy = new CompositeSuspendable(); StoreCopyProcess storeCopyProcess = new StoreCopyProcess(fileSystem, pageCache, localDatabase, copiedStoreRecovery, remoteStore, _logProvider); ConnectToRandomCoreServerStrategy defaultStrategy = new ConnectToRandomCoreServerStrategy(); defaultStrategy.Inject(_topologyService, config, _logProvider, myself); UpstreamDatabaseStrategySelector upstreamDatabaseStrategySelector = CreateUpstreamDatabaseStrategySelector(myself, config, _logProvider, _topologyService, defaultStrategy); CatchupPollingProcess catchupProcess = new CatchupPollingProcess(_logProvider, localDatabase, servicesToStopOnStoreCopy, catchUpClient, upstreamDatabaseStrategySelector, timerService, config.Get(CausalClusteringSettings.pull_interval).toMillis(), batchingTxApplier, platformModule.Monitors, storeCopyProcess, databaseHealthSupplier, _topologyService); dependencies.SatisfyDependencies(catchupProcess); txPulling.Add(batchingTxApplier); txPulling.Add(catchupProcess); txPulling.Add(new WaitForUpToDateStore(catchupProcess, _logProvider)); ExponentialBackoffStrategy retryStrategy = new ExponentialBackoffStrategy(1, 30, TimeUnit.SECONDS); life.Add(new ReadReplicaStartupProcess(remoteStore, localDatabase, txPulling, upstreamDatabaseStrategySelector, retryStrategy, _logProvider, platformModule.Logging.UserLogProvider, storeCopyProcess, _topologyService)); CheckPointerService checkPointerService = new CheckPointerService(() => localDatabase.DataSource().DependencyResolver.resolveDependency(typeof(CheckPointer)), platformModule.JobScheduler, Group.CHECKPOINT); RegularCatchupServerHandler catchupServerHandler = new RegularCatchupServerHandler(platformModule.Monitors, _logProvider, localDatabase.storeId, localDatabase.dataSource, localDatabase.isAvailable, fileSystem, null, checkPointerService); InstalledProtocolHandler installedProtocolHandler = new InstalledProtocolHandler(); // TODO: hook into a procedure Server catchupServer = (new CatchupServerBuilder(catchupServerHandler)).serverHandler(installedProtocolHandler).catchupProtocols(supportedCatchupProtocols).modifierProtocols(supportedModifierProtocols).pipelineBuilder(serverPipelineBuilderFactory).userLogProvider(userLogProvider).debugLogProvider(_logProvider).listenAddress(config.Get(transaction_listen_address)).serverName("catchup-server").build(); TransactionBackupServiceProvider transactionBackupServiceProvider = new TransactionBackupServiceProvider(_logProvider, userLogProvider, supportedCatchupProtocols, supportedModifierProtocols, backupServerPipelineBuilderFactory, catchupServerHandler, installedProtocolHandler); Optional <Server> backupCatchupServer = transactionBackupServiceProvider.ResolveIfBackupEnabled(config); servicesToStopOnStoreCopy.Add(catchupServer); backupCatchupServer.ifPresent(servicesToStopOnStoreCopy.add); life.Add(catchupServer); // must start last and stop first, since it handles external requests backupCatchupServer.ifPresent(life.add); }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected: //ORIGINAL LINE: public EnterpriseCoreEditionModule(final org.neo4j.graphdb.factory.module.PlatformModule platformModule, final org.neo4j.causalclustering.discovery.DiscoveryServiceFactory discoveryServiceFactory) public EnterpriseCoreEditionModule(PlatformModule platformModule, DiscoveryServiceFactory discoveryServiceFactory) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.kernel.impl.util.Dependencies dependencies = platformModule.dependencies; Dependencies dependencies = platformModule.Dependencies; Config = platformModule.Config; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.logging.internal.LogService logging = platformModule.logging; LogService logging = platformModule.Logging; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.io.fs.FileSystemAbstraction fileSystem = platformModule.fileSystem; FileSystemAbstraction fileSystem = platformModule.FileSystem; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.io.layout.DatabaseLayout databaseLayout = platformModule.storeLayout.databaseLayout(config.get(org.neo4j.graphdb.factory.GraphDatabaseSettings.active_database)); DatabaseLayout databaseLayout = platformModule.StoreLayout.databaseLayout(Config.get(GraphDatabaseSettings.active_database)); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.kernel.lifecycle.LifeSupport life = platformModule.life; LifeSupport life = platformModule.Life; CoreMonitor.register(logging.InternalLogProvider, logging.UserLogProvider, platformModule.Monitors); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.io.File dataDir = config.get(org.neo4j.graphdb.factory.GraphDatabaseSettings.data_directory); File dataDir = Config.get(GraphDatabaseSettings.data_directory); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.causalclustering.core.state.ClusterStateDirectory clusterStateDirectory = new org.neo4j.causalclustering.core.state.ClusterStateDirectory(dataDir, databaseLayout.databaseDirectory(), false); ClusterStateDirectory clusterStateDirectory = new ClusterStateDirectory(dataDir, databaseLayout.DatabaseDirectory(), false); try { clusterStateDirectory.Initialize(fileSystem); } catch (ClusterStateException e) { throw new Exception(e); } dependencies.SatisfyDependency(clusterStateDirectory); AvailabilityGuard globalGuard = GetGlobalAvailabilityGuard(platformModule.Clock, logging, platformModule.Config); ThreadToTransactionBridgeConflict = dependencies.SatisfyDependency(new ThreadToStatementContextBridge(globalGuard)); LogProvider = logging.InternalLogProvider; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final System.Func<org.neo4j.kernel.internal.DatabaseHealth> databaseHealthSupplier = () -> platformModule.dataSourceManager.getDataSource().getDependencyResolver().resolveDependency(org.neo4j.kernel.internal.DatabaseHealth.class); System.Func <DatabaseHealth> databaseHealthSupplier = () => platformModule.DataSourceManager.DataSource.DependencyResolver.resolveDependency(typeof(DatabaseHealth)); WatcherServiceFactoryConflict = directory => CreateFileSystemWatcherService(fileSystem, directory, logging, platformModule.JobScheduler, Config, FileWatcherFileNameFilter()); dependencies.SatisfyDependencies(WatcherServiceFactoryConflict); LogFiles logFiles = BuildLocalDatabaseLogFiles(platformModule, fileSystem, databaseLayout); LocalDatabase localDatabase = new LocalDatabase(databaseLayout, new StoreFiles(fileSystem, platformModule.PageCache), logFiles, platformModule.DataSourceManager, databaseHealthSupplier, globalGuard, LogProvider); IdentityModule identityModule = new IdentityModule(platformModule, clusterStateDirectory.Get()); ClusteringModule clusteringModule = GetClusteringModule(platformModule, discoveryServiceFactory, clusterStateDirectory, identityModule, dependencies, databaseLayout); // We need to satisfy the dependency here to keep users of it, such as BoltKernelExtension, happy. dependencies.SatisfyDependency(SslPolicyLoader.create(Config, LogProvider)); PipelineWrapper clientPipelineWrapper = PipelineWrapperFactory().forClient(Config, dependencies, LogProvider, CausalClusteringSettings.SslPolicy); PipelineWrapper serverPipelineWrapper = PipelineWrapperFactory().forServer(Config, dependencies, LogProvider, CausalClusteringSettings.SslPolicy); PipelineWrapper backupServerPipelineWrapper = PipelineWrapperFactory().forServer(Config, dependencies, LogProvider, OnlineBackupSettings.ssl_policy); NettyPipelineBuilderFactory clientPipelineBuilderFactory = new NettyPipelineBuilderFactory(clientPipelineWrapper); NettyPipelineBuilderFactory serverPipelineBuilderFactory = new NettyPipelineBuilderFactory(serverPipelineWrapper); NettyPipelineBuilderFactory backupServerPipelineBuilderFactory = new NettyPipelineBuilderFactory(backupServerPipelineWrapper); _topologyService = clusteringModule.TopologyService(); long logThresholdMillis = Config.get(CausalClusteringSettings.UnknownAddressLoggingThrottle).toMillis(); SupportedProtocolCreator supportedProtocolCreator = new SupportedProtocolCreator(Config, LogProvider); ApplicationSupportedProtocols supportedRaftProtocols = supportedProtocolCreator.CreateSupportedRaftProtocol(); ICollection <ModifierSupportedProtocols> supportedModifierProtocols = supportedProtocolCreator.CreateSupportedModifierProtocols(); ApplicationProtocolRepository applicationProtocolRepository = new ApplicationProtocolRepository(Org.Neo4j.causalclustering.protocol.Protocol_ApplicationProtocols.values(), supportedRaftProtocols); ModifierProtocolRepository modifierProtocolRepository = new ModifierProtocolRepository(Org.Neo4j.causalclustering.protocol.Protocol_ModifierProtocols.values(), supportedModifierProtocols); ProtocolInstallerRepository <Org.Neo4j.causalclustering.protocol.ProtocolInstaller_Orientation_Client> protocolInstallerRepository = new ProtocolInstallerRepository <Org.Neo4j.causalclustering.protocol.ProtocolInstaller_Orientation_Client>(asList(new RaftProtocolClientInstallerV2.Factory(clientPipelineBuilderFactory, LogProvider), new RaftProtocolClientInstallerV1.Factory(clientPipelineBuilderFactory, LogProvider)), Org.Neo4j.causalclustering.protocol.ModifierProtocolInstaller_Fields.AllClientInstallers); Duration handshakeTimeout = Config.get(CausalClusteringSettings.HandshakeTimeout); HandshakeClientInitializer channelInitializer = new HandshakeClientInitializer(applicationProtocolRepository, modifierProtocolRepository, protocolInstallerRepository, clientPipelineBuilderFactory, handshakeTimeout, LogProvider, platformModule.Logging.UserLogProvider); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.causalclustering.messaging.SenderService raftSender = new org.neo4j.causalclustering.messaging.SenderService(channelInitializer, logProvider); SenderService raftSender = new SenderService(channelInitializer, LogProvider); life.Add(raftSender); this._clientInstalledProtocols = raftSender.installedProtocols; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.causalclustering.logging.MessageLogger<org.neo4j.causalclustering.identity.MemberId> messageLogger = createMessageLogger(config, life, identityModule.myself()); MessageLogger <MemberId> messageLogger = CreateMessageLogger(Config, life, identityModule.Myself()); RaftOutbound raftOutbound = new RaftOutbound(_topologyService, raftSender, clusteringModule.ClusterIdentity(), LogProvider, logThresholdMillis); Outbound <MemberId, Org.Neo4j.causalclustering.core.consensus.RaftMessages_RaftMessage> loggingOutbound = new LoggingOutbound <MemberId, Org.Neo4j.causalclustering.core.consensus.RaftMessages_RaftMessage>(raftOutbound, identityModule.Myself(), messageLogger); _consensusModule = new ConsensusModule(identityModule.Myself(), platformModule, loggingOutbound, clusterStateDirectory.Get(), _topologyService); dependencies.SatisfyDependency(_consensusModule.raftMachine()); _replicationModule = new ReplicationModule(_consensusModule.raftMachine(), identityModule.Myself(), platformModule, Config, loggingOutbound, clusterStateDirectory.Get(), fileSystem, LogProvider, globalGuard, localDatabase); _coreStateMachinesModule = new CoreStateMachinesModule(identityModule.Myself(), platformModule, clusterStateDirectory.Get(), Config, _replicationModule.Replicator, _consensusModule.raftMachine(), dependencies, localDatabase); IdContextFactoryConflict = IdContextFactoryBuilder.of(_coreStateMachinesModule.idTypeConfigurationProvider, platformModule.JobScheduler).withIdGenerationFactoryProvider(ignored => _coreStateMachinesModule.idGeneratorFactory).withFactoryWrapper(generator => new FreeIdFilteredIdGeneratorFactory(generator, _coreStateMachinesModule.freeIdCondition)).build(); // TODO: this is broken, coreStateMachinesModule.tokenHolders should be supplier, somehow... this.TokenHoldersProviderConflict = databaseName => _coreStateMachinesModule.tokenHolders; this.LocksSupplierConflict = _coreStateMachinesModule.locksSupplier; this.CommitProcessFactoryConflict = _coreStateMachinesModule.commitProcessFactory; this.AccessCapabilityConflict = new LeaderCanWrite(_consensusModule.raftMachine()); InstalledProtocolHandler serverInstalledProtocolHandler = new InstalledProtocolHandler(); this._coreServerModule = new CoreServerModule(identityModule, platformModule, _consensusModule, _coreStateMachinesModule, clusteringModule, _replicationModule, localDatabase, databaseHealthSupplier, clusterStateDirectory.Get(), clientPipelineBuilderFactory, serverPipelineBuilderFactory, backupServerPipelineBuilderFactory, serverInstalledProtocolHandler); TypicallyConnectToRandomReadReplicaStrategy defaultStrategy = new TypicallyConnectToRandomReadReplicaStrategy(2); defaultStrategy.Inject(_topologyService, Config, LogProvider, identityModule.Myself()); UpstreamDatabaseStrategySelector catchupStrategySelector = CreateUpstreamDatabaseStrategySelector(identityModule.Myself(), Config, LogProvider, _topologyService, defaultStrategy); Org.Neo4j.causalclustering.catchup.CatchupAddressProvider_PrioritisingUpstreamStrategyBasedAddressProvider catchupAddressProvider = new Org.Neo4j.causalclustering.catchup.CatchupAddressProvider_PrioritisingUpstreamStrategyBasedAddressProvider(_consensusModule.raftMachine(), _topologyService, catchupStrategySelector); RaftServerModule.CreateAndStart(platformModule, _consensusModule, identityModule, _coreServerModule, localDatabase, serverPipelineBuilderFactory, messageLogger, catchupAddressProvider, supportedRaftProtocols, supportedModifierProtocols, serverInstalledProtocolHandler); _serverInstalledProtocols = serverInstalledProtocolHandler.installedProtocols; EditionInvariants(platformModule, dependencies, Config, logging, life); life.Add(_coreServerModule.membershipWaiterLifecycle); }