示例#1
0
        public GriddedReportRequestResponse Invoke(GriddedReportRequestArgument arg)
        {
            _log.LogInformation("In GridRequestComputeFunc.Invoke()");

            try
            {
                // Supply the TRex ID of the Ignite node currently running this code to permit processing contexts to send
                // sub grid results to it.
                arg.TRexNodeID = TRexNodeID.ThisNodeID(StorageMutability.Immutable);
                _log.LogInformation($"Assigned TRexNodeId from local node is {arg.TRexNodeID}");

                var request = new GriddedReportComputeFuncExecutor(arg);

                _log.LogInformation("Executing request.ExecuteAsync()");

                if (!request.ExecuteAsync().WaitAndUnwrapException())
                {
                    _log.LogError("Request execution failed");
                }

                return(request.GriddedReportRequestResponse);
            }
            catch (Exception e)
            {
                _log.LogError(e, "Exception occurred in GriddedReportRequestComputeFunc.Invoke()");
                return(new GriddedReportRequestResponse {
                    ResultStatus = Types.RequestErrorStatus.Exception
                });
            }
            finally
            {
                _log.LogInformation("Exiting GridRequestComputeFunc.Invoke()");
            }
        }
示例#2
0
        public TINSurfaceResult Invoke(TINSurfaceRequestArgument arg)
        {
            _log.LogInformation("In TINSurfaceRequestComputeFunc.Invoke()");

            try
            {
                // Export requests can be a significant resource commitment. Ensure TPaaS will be listening...
                PerformTPaaSRequestLivelinessCheck(arg);

                // Supply the TRex ID of the Ignite node currently running this code to permit processing contexts to send
                // sub grid results to it.
                arg.TRexNodeID = TRexNodeID.ThisNodeID(StorageMutability.Immutable);

                _log.LogInformation($"Assigned TRexNodeId from local node is {arg.TRexNodeID}");

                var request = new TINSurfaceExportExecutor(arg.ProjectID, arg.Filters, arg.Tolerance, arg.TRexNodeID, arg.LiftParams);

                _log.LogInformation("Executing request.ExecuteAsync()");

                if (!request.ExecuteAsync().WaitAndUnwrapException())
                {
                    _log.LogError("Request execution failed");
                }

                var result = new TINSurfaceResult();
                using var ms = RecyclableMemoryStreamManagerHelper.Manager.GetStream();
                if (request.SurfaceSubGridsResponse.TIN != null)
                {
                    request.SurfaceSubGridsResponse.TIN.SaveToStream(Consts.DefaultCoordinateResolution, Consts.DefaultElevationResolution, false, ms);
                    result.data = ms.ToArray();
                }

                return(result);
            }
            catch (Exception e)
            {
                _log.LogError(e, "Exception requesting a TTM surface");
                return(new TINSurfaceResult {
                    ResultStatus = Types.RequestErrorStatus.Exception
                });
            }
            finally
            {
                _log.LogInformation("Exiting TINSurfaceRequestComputeFunc.Invoke()");
            }
        }
示例#3
0
        public PatchRequestResponse Invoke(PatchRequestArgument arg)
        {
            _log.LogInformation("In PatchRequestComputeFunc.Invoke()");

            try
            {
                // Export requests can be a significant resource commitment. Ensure TPaaS will be listening...
                PerformTPaaSRequestLivelinessCheck(arg);

                // Supply the TRex ID of the Ignite node currently running this code to permit processing contexts to send
                // sub grid results to it.
                arg.TRexNodeID = TRexNodeID.ThisNodeID(StorageMutability.Immutable);

                _log.LogInformation($"Assigned TRexNodeId from local node is {arg.TRexNodeID}");

                var request = new PatchExecutor(arg.ProjectID, arg.Mode, arg.Filters, arg.ReferenceDesign,
                                                arg.TRexNodeID, arg.DataPatchNumber, arg.DataPatchSize, arg.LiftParams);

                _log.LogInformation("Executing request.ExecuteAsync()");

                if (!request.ExecuteAsync().WaitAndUnwrapException())
                {
                    _log.LogError("Request execution failed");
                }

                return(request.PatchSubGridsResponse);
            }
            catch (Exception e)
            {
                _log.LogError(e, "Exception requesting patch");
                return(new PatchRequestResponse {
                    ResultStatus = Types.RequestErrorStatus.Exception
                });
            }
            finally
            {
                _log.LogInformation("Exiting PatchRequestComputeFunc.Invoke()");
            }
        }
示例#4
0
        /// <summary>
        /// Quantized Mesh Response.
        /// </summary>
        public QuantizedMeshResponse Invoke(QuantizedMeshRequestArgument arg)
        {
            _log.LogInformation("In QuantizedMeshRequestComputeFunc.Invoke()");

            try
            {
                // Quantized mesh requests can be a significant resource commitment. Ensure TPaaS will be listening...
                PerformTPaaSRequestLivelinessCheck(arg);

                // Supply the TRex ID of the Ignite node currently running this code to permit processing contexts to send
                // subgrid results to it.
                arg.TRexNodeID = TRexNodeID.ThisNodeID(StorageMutability.Immutable);

                _log.LogDebug($"Assigned TRexNodeId from local node is {arg.TRexNodeID}");

                var request = new QMTileExecutor(arg.ProjectID, arg.Filters, arg.X, arg.Y, arg.Z, arg.DisplayMode, arg.HasLighting, arg.TRexNodeID);

                _log.LogInformation("Executing request.Execute()");

                if (!request.ExecuteAsync().WaitAndUnwrapException())
                {
                    _log.LogError("Request execution failed");
                }

                return(request.QMTileResponse);
            }
            catch (Exception e)
            {
                _log.LogError(e, "Exception requesting quantized mesh");
                return(new QuantizedMeshResponse {
                    ResultStatus = Types.RequestErrorStatus.Exception
                });
            }
            finally
            {
                _log.LogDebug("Exiting QuantizedMeshRequestComputeFunc.Invoke()");
            }
        }
示例#5
0
        public CSVExportRequestResponse Invoke(CSVExportRequestArgument arg)
        {
            _log.LogInformation($"In {nameof(Invoke)}");

            try
            {
                // Export requests can be a significant resource commitment. Ensure TPaaS will be listening...
                PerformTPaaSRequestLivelinessCheck(arg);

                // Supply the TRex ID of the Ignite node currently running this code to permit processing contexts to send
                // sub grid results to it.
                arg.TRexNodeID = TRexNodeID.ThisNodeID(StorageMutability.Immutable);
                _log.LogInformation($"Assigned TRexNodeId from local node is {arg.TRexNodeID}");

                var request = new CSVExportComputeFuncExecutor(arg);

                _log.LogInformation("Executing request.ExecuteAsync()");

                if (!request.ExecuteAsync().WaitAndUnwrapException())
                {
                    _log.LogError("Request execution failed");
                }

                return(request.CSVExportRequestResponse);
            }
            catch (Exception e)
            {
                _log.LogError(e, "Exception exporting CSV file");
                return(new CSVExportRequestResponse {
                    ResultStatus = Types.RequestErrorStatus.Exception
                });
            }
            finally
            {
                _log.LogInformation($"Out {nameof(Invoke)}");
            }
        }
示例#6
0
        /// <summary>
        /// Constructor that creates a new server instance with a set of roles
        /// </summary>
        /// <param name="roles"></param>
        public ImmutableClientServer(string[] roles)
        {
            if (immutableTRexGrid == null)
            {
                // Attempt to attach to an already existing Ignite instance
                Log.LogInformation("Getting Immutable grid");
                immutableTRexGrid = DIContext.Obtain <ITRexGridFactory>()?.Grid(StorageMutability.Immutable);
                Log.LogInformation($"Got {immutableTRexGrid?.Name}");

                // If there was no connection obtained, attempt to create a new instance
                if (immutableTRexGrid == null)
                {
                    var roleNames = roles.Aggregate("|", (s1, s2) => s1 + s2 + "|");

                    TRexNodeID = Guid.NewGuid();

                    //Log.LogInformation($"Creating new Ignite node with Roles = {roleNames} & TRexNodeId = {TRexNodeID}");

                    var cfg = new IgniteConfiguration
                    {
                        IgniteInstanceName = TRexGrids.ImmutableGridName(),
                        ClientMode         = true,

                        JvmOptions = new List <string>()
                        {
                            "-DIGNITE_QUIET=false",
                            "-Djava.net.preferIPv4Stack=true",
                            "-XX:+UseG1GC",
                            "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED",
                            "--add-exports=java.base/sun.nio.ch=ALL-UNNAMED",
                            "--add-exports=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED",
                            "--add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED",
                            "--add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED",
                            "--illegal-access=permit"
                        },

                        JvmMaxMemoryMb     = DIContext.Obtain <IConfigurationStore>().GetValueInt(IGNITE_JVM_MAX_HEAP_SIZE_MB, DEFAULT_IGNITE_JVM_MAX_HEAP_SIZE_MB),
                        JvmInitialMemoryMb = DIContext.Obtain <IConfigurationStore>().GetValueInt(IGNITE_JVM_INITIAL_HEAP_SIZE_MB, DEFAULT_IGNITE_JVM_INITIAL_HEAP_SIZE_MB),

                        UserAttributes = new Dictionary <string, object>
                        {
                            { "TRexNodeId", TRexNodeID.ToString() }
                        },

                        Logger = new TRexIgniteLogger(DIContext.Obtain <IConfigurationStore>(), Logger.CreateLogger("ImmutableClientServer")),

                        // Set an Ignite metrics heartbeat of 10 seconds
                        MetricsLogFrequency = new TimeSpan(0, 0, 0, 10),

                        PublicThreadPoolSize = DIContext.Obtain <IConfigurationStore>().GetValueInt(IGNITE_PUBLIC_THREAD_POOL_SIZE, DEFAULT_IGNITE_PUBLIC_THREAD_POOL_SIZE),
                        SystemThreadPoolSize = DIContext.Obtain <IConfigurationStore>().GetValueInt(IGNITE_SYSTEM_THREAD_POOL_SIZE, DEFAULT_IGNITE_SYSTEM_THREAD_POOL_SIZE),

                        PeerAssemblyLoadingMode = PeerAssemblyLoadingMode.CurrentAppDomain,

                        BinaryConfiguration = new BinaryConfiguration
                        {
                            Serializer = new BinarizableSerializer()
                        },

                        // Add the TRex progressive request custom thread pool
                        ExecutorConfiguration = new List <ExecutorConfiguration>
                        {
                            new ExecutorConfiguration
                            {
                                Name = BaseIgniteClass.TREX_PROGRESSIVE_QUERY_CUSTOM_THREAD_POOL_NAME,
                                Size = DIContext.Obtain <IConfigurationStore>().GetValueInt(PROGRESSIVE_REQUEST_CUSTOM_POOL_SIZE, DEFAULT_PROGRESSIVE_REQUEST_CUSTOM_POOL_SIZE)
                            }
                        }
                    };

                    foreach (var roleName in roles)
                    {
                        cfg.UserAttributes.Add($"{ServerRoles.ROLE_ATTRIBUTE_NAME}-{roleName}", "True");
                    }

                    bool.TryParse(Environment.GetEnvironmentVariable("IS_KUBERNETES"), out var isKubernetes);
                    cfg = isKubernetes ? setKubernetesIgniteConfiguration(cfg) : setLocalIgniteConfiguration(cfg);

                    try
                    {
                        immutableTRexGrid = DIContext.Obtain <ITRexGridFactory>()?.Grid(TRexGrids.ImmutableGridName(), cfg);
                    }
                    catch (Exception e)
                    {
                        Log.LogError(e, $"Creation of new Ignite node with Role = {roleNames} & TRexNodeId = {TRexNodeID} failed with Exception:");
                        throw;
                    }
                    finally
                    {
                        Log.LogInformation($"Completed creation of new Ignite node with Role = {roleNames} & TRexNodeId = {TRexNodeID}");
                    }
                }
            }
        }
示例#7
0
        public TileRenderResponse Invoke(TileRenderRequestArgument arg)
        {
            try
            {
                // Tile requests can be a significant resource commitment. Ensure TPaaS will be listening...
                PerformTPaaSRequestLivelinessCheck(arg);

                var requestStopWatch = Stopwatch.StartNew();

                _log.LogInformation("In TileRenderRequestComputeFunc.Invoke()");

                try
                {
                    // Supply the TRex ID of the Ignite node currently running this code to permit processing contexts to send
                    // sub grid results to it.
                    arg.TRexNodeID = TRexNodeID.ThisNodeID(StorageMutability.Immutable);

                    _log.LogInformation($"Assigned TRexNodeId from local node is {arg.TRexNodeID}");

                    var render = new RenderOverlayTile
                                     (arg.ProjectID,
                                     arg.Mode,
                                     new XYZ(arg.Extents.MinX, arg.Extents.MinY),
                                     new XYZ(arg.Extents.MaxX, arg.Extents.MaxY),
                                     arg.CoordsAreGrid,
                                     arg.PixelsX, arg.PixelsY,
                                     arg.Filters,
                                     arg.ReferenceDesign,
                                     arg.Palette,
                                     Color.Black,
                                     arg.TRexNodeID,
                                     arg.LiftParams,
                                     arg.VolumeType);

                    _log.LogInformation("Executing render.ExecuteAsync()");

                    using var bmp = render.ExecuteAsync().WaitAndUnwrapException();
                    _log.LogInformation($"Render status = {render.ResultStatus}");

                    if (bmp == null)
                    {
                        _log.LogInformation("Null bitmap returned by executor");

                        return(new TileRenderResponse
                        {
                            TileBitmapData = null,
                            ResultStatus = render.ResultStatus
                        });
                    }

                    using var image  = SKImage.FromBitmap(bmp);
                    using var data   = image.Encode(SKEncodedImageFormat.Png, 100);
                    using var stream = RecyclableMemoryStreamManagerHelper.Manager.GetStream();
                    data.SaveTo(stream);

                    return(new TileRenderResponse
                    {
                        TileBitmapData = stream.ToArray(),
                        ResultStatus = render.ResultStatus
                    });
                }
                finally
                {
                    _log.LogInformation($"Exiting TileRenderRequestComputeFunc.Invoke() in {requestStopWatch.Elapsed}");

                    // Flag tile renders that take more than 20 seconds to render...
                    if (requestStopWatch.Elapsed > _tileRequestTimeSpanWarnLimit)
                    {
                        _log.LogInformation($"Tile render request required more than {_tileRequestTimeSpanWarnLimit} to complete");
                    }
                }
            }
            catch (Exception e)
            {
                _log.LogError(e, "Exception occurred in TileRenderRequestComputeFunc.Invoke()");
                return(new TileRenderResponse {
                    ResultStatus = Types.RequestErrorStatus.Exception
                });
            }
        }