want to reset values after some time using scheduler or db event - scheduled-tasks

I have a jsp like:
rule 1 : value
rule 2 : value
Time interval in min :value
I am saving these values to DB
depending on the value of time interval field I want to reset the value of rule 1 and rule 2 to a default value in DB
This time interval can be changed any time even before previous interval is not completed,means it needs to be updated dynamically whatever approach I choose
I am using Sprig MVC and oracle
I opted for
ThreadPoolTaskScheduler
but now problem is as soon as I used
threadPoolTaskScheduler.schedule(runnableObj,trigger);
it is getting executed immediately and then executes on proper interval of 1 min but I want to skip first execution for that I have used PeriodicTrigger
which has method named setInitialDelay() but it is not delaying it
Please provide some insight for this kind of problems as I am doing it first time

I think I solved it using ThreadPoolTaskScheduler
For more info visit http://www.baeldung.com/spring-task-scheduler
Some interesting Spring Scheduling information.

Related

Grafana 2 queries in same panel but set query interval difference

I have 2 queries in a grafana panel.
I want to run Query A every 5 min
I want to run Query B every 10 min, so I can check the value difference between each query using transform.
How can I set the query interval, I know I can change scrape interval but my goal here is to check pending messages and if it doesnt change in 10 min trigger an alert. I am trying to get a count at 1st minute and get count again at 10th minute. check the difference using transform and trigger an alert if no change (messages are not getting processed )
using grafana 7
Thanks !

date parameter updated with time Anylogic

I'm using Anylogic and I would like to assign a parameter of type date to each agent (agent is a customer), called DueDate, that represents deadline to his machine failure. My goal is to update value parameter and make it shorter as model time passes (because the failure date is coming). There is some function or code that I can use? I also want to assign a priority parameter to agent that increases when failure date is nearest, so that in queue a customer with a failure nearest is processed before agents with lower priority. How can I do?
Thanks at all
This question seems to contradict itself somewhat. The parameter described is a Due Date, therefore, by definition, should be fixed. Yet, parameter value should be updated as failure date is coming. Do you mean that there should be two parameters: 1) Due Date and 2) remaining time until Due Date? If so this can be achieve like this:
Due Date - if you want to set due date at 10 time units after model start, you can make a parameter (call it p_dueDate of type ) and use timeToDate(100.0) function (help entry).
Remaining time - create a function in the agent f_getRemainingTime() with this code:
return dateToTime(p_dueDate) - time();
where dateToTime() will convert the p_dueDate value back into a double value representing simulation's time units and time() returns current simulation time (also as a double value).
so, let's say for a model starting on 1st Jan with time units = days; offset of 10 will result in p_dueDate = 10th Jan and on 3rd of Jan f_getRemainingTime() will return 7.0.

Set trigger time of periods in Zabbix

I have a host that I monitor in 08:00-20:00 and trigger which acts when no ping.
Sometimes a host can be switched off in period of 20:00-08:00. I want in this situation dont't to trigger that act till 10:00 next day. Is it possible?
You can use the time() trigger function. Appending this to the existing function should work (replace ... with the reference to the same item as already in the expression):
and time(...) > 080000 and time(...) < 200000
Note that this will make the trigger ignore the time period outside of the bounds, so it will fire at 08:00 only if the problem condition still persists. Not sure how 10:00 fits in your original description.
On newer versions of Zabbix you can set Working hours for items, so the collect just will happens in a specific range..
https://www.zabbix.com/documentation/2.0/manual/appendix/time_period

Tableau - Finding Records that happened within X amount of time

I have some experience with Tableau as I have migrated into a Data Analyst position with not a ton of experience and am hitting a wall with if it is even possible to perform the calculation within Tableau.
The general base of my data would look like (Limiting it to the two fields we need)
Case # | Tech Dispatch Time (PST) | Full Time (Y/N)
2017-0001| MM/DD/YYYY 16:34:21 | 0
2017-0002| MM/DD/YYYY 20:43:00 | 1
2017-0003| MM/DD/YYYY 22:00:05 | 0
We are looking to see how often a dispatch happens within X amount of time to determine our efficiency in dispatching our teams. If these were happening on the same record, a basic DATEDIFF and IF function would work, but I am at a loss on how to state that IF there is another dispatch in say 180 minutes, 1, else 0.
Is this something I will have to do outside of Tableau within say SQL or PowerPivot? Or is this a function that Tableau could calculate as well?
Thank you for your time and assistance with this matter,
Andy M.
Create a parameter to define your 'x',
Then create a calculated field with below Formula(I called it time block)
//We need to add 0.5 to Roundup
ROUND((DATEDIFF('minute',[Tech Dispatch Time],NOW())/[x])+0.5,0)
Now you can use it in your viz
Use the LOOKUP() function. It allows you to find other rows' values relative to the current row.
DateDiff("minute", [Tech Dispatch Time (PST)], Lookup(MIN([Tech Dispatch Time (PST)]), -1))
The sample data you have in your question presents a problem though. The Tech Dispatch Time (PST) field only has the time portion. To accurately calculate time difference, you need a date with the time. Otherwise, you will end up with negative times if the two cases span across midnight.
Since this is a table calc, you'll also have to set the partitioning and addressing dimensions and sort order by editing the table calc to get the effect you want.

Server-side Fetchxml returns different results

One of our procedures lets users bulk-insert related records by picking a view and then hitting a ribbon button. The form is saved, a flag is set, and a plugin then does its job.
We are using a subgrid with a view selector to let users pick or create their own views on the fly. Once a view is selected, the number of results (provided is lte 5k) is shown.
When a plugin runs the very same fetchxml server side (Retrieve of userquery or savedquery, then Retrieve + FetchExpression), the results change. We get not only a different number of records but also some records are different.
We concluded that the issue has to do with timezones. Some filters included "on-or-after" operators along with date values.
Example:
<filter type="and">
<condition attribute="modifiedon" operator="on-or-after" value="2011-01-01" />
<condition attribute="modifiedon" operator="on-or-before" value="2011-12-31" />
</filter>
The plugin ran as admin. Changing the plugin user has no effect - as if the current user timezone is not considered when pulling out records from the CRM using a FetchExpression.
How can I ensure that a fetchxml expression returns the same results client-side and server-side?
Probably related: MSDN thread.
Thanks for your time.
Edit: following Daryl's suggestion, I ran a SQL trace. Results are puzzling. Dates are correctly offset for client-side queries (ran from CRM, i.e. Advanced Find) - this means the fetchxml is correctly translated using the user's timezone settings. This does not happen for the same query, server-side; the output SQL contains the date filters "as-is", with no timezone offset. I assumed the same translation happened no matter the origin of the query execution context.
Edit 2: A flag in an hidden region of code (my last debugging resort) was preventing the plugin from instantiating the service in the running user's context. Everything runs fine now. Thanks everyone for your time and your help, it's much appreciated.
When working with dates, always remember to convert to utc since that is how CRM stores them in the database.
The native CRM Advanced find is going to look at whatever the current user's time zone is, and convert that whatever time they enter into the advanced find to UTC before performing a SQL query. Your plugin control will need to do the same thing. These are the steps you'll need to perform before putting the criteria in the Fetch Xml / Linq Expression / Query Expression.
Get the user's UserSetting.TimeZoneCode via their SystemUserId.
Lookup the TimeZoneDefinition.StandardName for the TimeZoneCode from step 1
Call TimeZoneInfo.FindSystemTimeZoneById() passing in the Standard Name from step 2 (you can combine steps 1 and 2 into a single query, but I prefer to cache the results of step three using the input from step 1 for a slight performance improvement. ie. use a dictionary with the TimeZoneCode as the key and the TimeZoneInfo as the value)
Use this function to get the UTC value for the time that you're going to use in your plugin query:
public static DateTime ConvertTimeToUTC(DateTime time, TimeZoneInfo timeZone)
{
if (time.Kind != DateTimeKind.Unspecified)
{
// If the DateTime is created with a specific time zone(ie DateTime.Now), getting the offset will
// blow chow if it isn't the correct time zone:
// The UTC Offset of the local dateTime parameter does not match the offset argument.
//Parameter name: offset
// This quick check will recreate the serverLocal time as unspecified
time = new DateTime(
time.Year,
time.Month,
time.Day,
time.Hour,
time.Minute,
time.Second,
time.Millisecond);
}
var offest = new DateTimeOffset(time, timeZone.GetUtcOffset(time));
return offest.UtcDateTime;
}