RangerMSP GetMaxSearchResults

The Select Object for RangerMSP API has a RecordLimit field that when set, provides a maximum number Search Results that will be retrieved by the Select API method. The importance of this RecordLimit becomes apparent when considering that in the Select Object there isn’t a mechanism to specify which fields of a table to retrieve. Therefore when a RangerMSP database record is retrieved, all fields in that record are retrieved. Potentially leading to long query times and client/server timeouts if a large amount of data is retrieved due to the Select Object not containing sufficiently restrictive criteria. Such a situation could place unexpected load on both Jupiter Server and the upstream RangerMSP database.

Jupiter Server has a configuration element in the server config file called RangerMSPMaxSrchResults. This can be set in the Jupiter Server GUI app to allow for a system wide RecordLimit to be set, which a Jupiter Client can query to include in the Select Objects. The API method that a Jupiter Client calls is

RangerMSP/GetMaxSearchResults

or

RangerMSP_REST/GetMaxSearchResults

The data returned is an int

RangerMSP/GetMaxSearchResults

RangerMSPClient RangerMSPClient = new RangerMSPClient();
(RangerMSPClient.ChannelFactory.Endpoint.Binding as BasicHttpBinding).MaxReceivedMessageSize = int.MaxValue;
(RangerMSPClient.ChannelFactory.Endpoint.Binding as BasicHttpBinding).MaxBufferSize = int.MaxValue;
(RangerMSPClient.ChannelFactory.Endpoint.Binding as BasicHttpBinding).ReceiveTimeout = new TimeSpan(0, 10, 0);
(RangerMSPClient.ChannelFactory.Endpoint.Binding as BasicHttpBinding).Security.Mode = BasicHttpSecurityMode.Transport;
(RangerMSPClient.ChannelFactory.Endpoint.Binding as BasicHttpBinding).Security.Mode = BasicHttpSecurityMode.TransportWithMessageCredential;
RangerMSPClient.ChannelFactory.Credentials.UserName.UserName = User;
RangerMSPClient.ChannelFactory.Credentials.UserName.Password = Password;
uri = new UriBuilder(RangerMSPClient.ChannelFactory.Endpoint.Address.Uri);
uri.Host = localhost;
uri.Scheme = "https";
uri.Port = 22222;
RangerMSPClient.ChannelFactory.Endpoint.Address = new EndpointAddress(uri.Uri);
int maxSrchResults = RangerMSPClient.GetMaxSearchResults();

RangerMSP_REST/GetMaxSearchResults

HttpWebRequest request = (HttpWebRequest)WebRequest.Create($"https://localhost:22222/RangerMSP_REST/GetMaxSearchResults");
if (auth)
{
     request.Headers.Add("Authorization", "Basic " + GetAuthHeader(username, password));
}
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream();

//Setting Up the Stream Reader
StreamReader readerStream = new StreamReader(responseStream, System.Text.Encoding.GetEncoding("utf-8"));

string jsonRes = readerStream.ReadToEnd();
string errstr = "";
try
{
     maxSrchResults = JsonConvert.DeserializeObject<int>(jsonRes);
}
catch (Exception e)
{
     errstr = e.ToString();
}
return maxSrchResults;