DocumentDB TransientFaultHandling for Core - asp.net-core

I am trying to migrate my code to Core.
I was using DocumentDB TransientFaultHandling package, but I can't seem to find it for a Core library.
Is it still best practice to use it, or are there other options for achieving the same results?
TIA

The current SDK (both Core and Full Framework) already include the fault handling that was part of the TransientFaultHandling package, not entirely the same since you can't define an exponential logic, but it works on the most common scenarios.
It's on the ConnectionPolicy settings:
var _dbClient = new DocumentClient("Db_uri", "Db_key", new ConnectionPolicy()
{
MaxConnectionLimit=100,
ConnectionMode = ConnectionMode.Direct,
ConnectionProtocol = Protocol.Tcp,
RetryOptions = new RetryOptions() { MaxRetryAttemptsOnThrottledRequests=3, MaxRetryWaitTimeInSeconds=60 }
});

Related

system_cpu_usage is Nan when compiled in native

In my quarkus application i'm using micrometer to retrieve metrics (like in this guide : https://quarkus.io/guides/micrometer).
In JVM mode everything works fine, but in native mode system_cpu_usage is "Nan".
I tried bumping micrometer to 1.8.4 and adding :
{
"name":"com.sun.management.OperatingSystemMXBean", "allPublicMethods": true
},
to my reflect-config.json but no luck. I also tried generating the reflect-config (and other native configuration files) with the graalvm tracing agent but still no luck.
This may be a bug.
Micrometer is looking for a few known implementations of the MXBean:
https://github.com/micrometer-metrics/micrometer/blob/b087856355667abf9bf2386265edef8642e0e077/micrometer-core/src/main/java/io/micrometer/core/instrument/binder/system/ProcessorMetrics.java#L55
private static final List<String> OPERATING_SYSTEM_BEAN_CLASS_NAMES = Arrays.asList(
"com.ibm.lang.management.OperatingSystemMXBean", // J9
"com.sun.management.OperatingSystemMXBean" // HotSpot
);
so that it can find the methods that it should be invoking...
https://github.com/micrometer-metrics/micrometer/blob/b087856355667abf9bf2386265edef8642e0e077/micrometer-core/src/main/java/io/micrometer/core/instrument/binder/system/ProcessorMetrics.java#L80
this.operatingSystemBean = ManagementFactory.getOperatingSystemMXBean();
this.operatingSystemBeanClass = getFirstClassFound(OPERATING_SYSTEM_BEAN_CLASS_NAMES);
Method getCpuLoad = detectMethod("getCpuLoad");
this.systemCpuUsage = getCpuLoad != null ? getCpuLoad : detectMethod("getSystemCpuLoad");
this.processCpuUsage = detectMethod("getProcessCpuLoad");
(Note specifically "getFirstClassFound", which is constrained against the first list).
Speculation on my part, but I suspect Graal is returning a different type, which is possible from here:
https://github.com/oracle/graal/blob/6ba65dad76a4f54fa59e1ed2a62dedd3afe39928/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/management/ManagementSupport.java#L166
would take some digging to know which, but I would open an issue with Micrometer so we can sort it out.

DiffGrams for .NET Core. We are upgrading our project to .NET Core 3.x so need to find the DiffGrams used in the previous version of .NET

We are upgrading our .NET 2.0 application to .NET Core 3.x there's a DiffGrams used to capture the Table field updates (before/after values) used for Auditing purpose. I have to achieve the similar in the .NET Core 3.x. I am not sure which one is the equivalent for .NET Core 3.x.
Could you anyone help me guide on this? Thank you.
DataSet.WriteXml/DataSet.ReadXml method applies to .NET Core 3.x.
The WriteXml method provides a way to write either data only, or both data and schema from a DataSet into an XML document.
private void WriteXmlToFile(DataSet thisDataSet)
{
if (thisDataSet == null) { return; }
// Create a file name to write to.
string filename = "XmlDoc.xml";
// Create the FileStream to write with.
System.IO.FileStream stream = new System.IO.FileStream
(filename, System.IO.FileMode.Create);
// Create an XmlTextWriter with the fileStream.
System.Xml.XmlTextWriter xmlWriter =
new System.Xml.XmlTextWriter(stream,
System.Text.Encoding.Unicode);
// Write to the file with the WriteXml method.
thisDataSet.WriteXml(xmlWriter, XmlWriteMode.DiffGram);
xmlWriter.Close();
}
The resultant XML code is rooted in the <diffgr:diffgram> node and contains up to three distinct data sections, as follows:
<diffgr:diffgram>
<MyDataSet>
:
</MyDataSet>
<diffgr:before>
:
</diffgr:before>
<diffgr:errors>
:
</diffgr:errors>
</diffgr:diffgram>

How to cache with EFCore in ASP.NET Core

I have a select query on a table which gives the last searches on the website.
This is for inspiration, and does not require to be updated for every page call, therefore I would like to cache these searches as it begins to show some performances impact.
My website uses ASP.NET Core and EFCore.
I believe there is no built-in way to do that on a single line.
What would be the best approach?
I am thinking about updating every 10 minutes the 300 last searches in memory and pick few of them randomly.
Up to now I have found these two options which I could use:
Raw cache method for ASP.Net Core
How to cache resources in Asp.net core?
EFCore open-source extension, which includes much more than just caching
http://entityframework-plus.net/
The solution I am using:
in startup.cs:
services.AddMemoryCache();
in view/controller:
var LAST_SEARCHS_COUNT = 5;
var lastSearchs = await Cache.GetOrCreateAsync<List<Search>>("LAST_SEARCHS"
,(k)=> {
k.AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(10);
return (from s in DbContext.Searchs
orderby s.CreationTime descending
select s).Take(LAST_SEARCHS_COUNT * 40).ToListAsync();
});
The impact is quite significant, with calls count divided by more than 100:
You can use Response Caching
[ResponseCache(VaryByHeader = "User-Agent", Duration = 30)]
public IActionResult About2()
{
Also Response Caching Middleware
You could also keep a static instance of the DataContext and make sure change tracking is enabled. That will keep it in memory to track changes. It might get slow though.

RallyDev: ConversationPost- How to query for Discussions in RallyDev Story

I am using the following RallyApi service to communicate with RallyDev:
https://rally1.rallydev.com/slm/webservice/1.40/RallyService
I have the following method:
public HierarchicalRequirement GetFeedbackById(string usid)
{
var query = string.Format("(FormattedID = \"{0}\")", usid);
const string orderByString = "CreationDate desc";
var rallyService = GetRallyService();
var rtnval = rallyService.query(Workspace, Projs["XXX"], true, true,"HierarchicalRequirement", query,
orderByString, true, 1, 20).Results[0] as HierarchicalRequirement;
return rtnval;
}
Although I am successfully retrieving the "HierarchicalRquirement" object using the "FormattedID", I am not able to load the associated "ConversationPost" objects for this story, Since all the nested complex objects of the "HierarchicalRquirement" contains the "ref" and "reffield" property and nothing else.
Could you please let me know if there is a way to actively load all the associated discussions when we query for the story or if there is a query as follows:
rallyService.query(Workspace, Projs["XXX"], true, true, "ConversationPost", query, orderByString, true, 1, 20)
Using the above can I search for discussions(ConversationPost) using FormattedID?
Thanks for your help.
Regards,
Varun
You're right on target with your use of rallyService.read(). With SOAP, even with fetchFullObjects=true, any Artifact attributes that are themselves Rally objects, are hydrated with refs to those object.
Especially if you're just getting started with building your integration, I'd highly recommend using REST:
http://developer.help.rallydev.com/rest-apis
instead of SOAP.
REST is more robust, more performant, and, the soon-to-be-released Webservices API 1.41, will be the final API release to have SOAP support. Webservices 2.x will be REST-only, so using REST will be essential to anyone wanting new Webservices features moving forward.

JIRA, get a parent issue via SOAP api

I need to obtain a parent issue of given issue via SOAP API, or even using database. It seems to be very basic objective, however I didn't find any useful information in internet. Besides, I didn't find any fields in jira's db tables (jiraissue) to set the parent issue of an issue.
Additional info: Jira 5.1, c# .Net
As far as I know there is no way to do this using the SOAP directly.
One possible solution would be using the Jira Scripting Suite. You can create a post-function that will run after the Open status that will copy the parent to a custom field using getParentObject. Then you could use the SOAP function getCustomFields to get the parent.
Another solution via REST API:
Issue issue = getRestClient().getIssueClient().getIssue(task.getKey(), new NullProgressMonitor());
Field issueParent = issue.getField("parent");
if (issueParent  !=null){
    JSONObject jsonParent = (JSONObject)issueParent.getValue();
    BasicIssue partsedIssue = null;
    try {
        partsedIssue = new BasicIssueJsonParser().parse(jsonParent);
    } catch (JSONException e1) {
        e1.printStackTrace();
    }
    System.out.println("parent key: "+partsedIssue.getKey());
}