how can i select the active processes on specific activity in camunda - camunda

... or more specific i want to know
for each process
for each process step
how many processes are on this step
at the moment and more nice for more than x minutes
The REST interface https://docs.camunda.org/manual/7.5/reference/rest/execution/get-query-count/ gives me the count only for a specific step, not for all. And for processes with many step i dont want to query (feeled) thousand times to get the information.
In the database i tried this, but i gives my redundant not specific active on this step count. But i dont need to rework my queries when something is changing.
select job.proc_def_key_, job.act_id_, count(ex.id_)
from camunda.act_ru_jobdef job, camunda.act_ru_execution ex
where job.proc_def_id_ = ex.proc_def_id_
and ex.business_key_ is not null
group by job.proc_def_key_, job.act_id_
order by job.proc_def_key_, job.act_id_

Related

Anylogic: How to create multiple orders at one moment?

I have created a schedule in Anylogic within the population of agents "customer", where customers have to create orders and send it to "terminals". Every day, the amount of orders that has to be send to terminals is different for every customer. I want to create multiple orders at once (every day, that is the start column within the schedule), and the amount I want to create is the value column within the schedule. How to do this?
As you can see below, now just one order is created every day (with the amount as parameter), but I want to create this amount of orders at that one day/moment. Thank you for the help!
The schedule data looks like:
You could do something like this:
You will have to set the parameters of your agent in the source and on the exit block you do send(agent,main.terminals(0))
If you have missing data instead of 0 in your value, use this in your agents per arrival:
selectFrom(db_table)
.where(db_table.name.eq(name))
.where(db_table.start.eq(getDayOfWeek()-1))
.count()>0
?
selectFrom(db_table)
.where(db_table.name.eq(name))
.where(db_table.start.eq(getDayOfWeek()-1))
.uniqueResult(db_table.value, int.class)
:
0
I would add dates to my schedule data, such as 28-12-2021 15:28. Then type something big into the Repeat every section. This is how I do it (my unit is always 1, but you can have any number instead):

How to find resource intensive and time consuming queries in WX2?

Is there a way to find the resource intensive and time consuming queries in WX2?
I tried to check SYS.IPE_COMMAND and SYS.IPE_TRANSACTION tables but of no help.
The best way to identify such queries when they are still running is to connect as SYS with Kognitio Console and use Tools | Identify Problem Queries. This runs a number of queries against Kognitio virtual tables to understand how long current queries have been running, how much RAM they are using, etc. The most intensive queries are at the top of the list, ranked by the final column, "Relative Severity".
For queries which ran in the past, you can look in IPE_COMMAND to see duration but only for non-SELECT queries - this is because SELECT queries default to only logging the DECLARE CURSOR statement, which basically just measures compile time rather than run time. To see details for SELECT queries you should join to IPE_TRANSACTION to find the start and end time for the transaction.
For non-SELECT queries, IPE_COMMAND contains a breakdown of the time taken in a number of columns (all times in ms):
SM_TIME shows the compile time
TM_TIME shows the interpreter time
QUEUE_TIME shows the time the query was queued
TOTAL_TIME aggregates the above information
If it is for historic view image commands as mentioned in the comments, you can query
... SYS.IPE_COMMAND WHERE COMMAND IMATCHING 'create view image' AND TOTAL_TIME > 300000"
If it is for currently running commands you can look in SYS.IPE_CURTRANS and join to IPE_TRANSACTION to find the start time of the transaction (assuming your CVI runs in its own transaction - if not, you will need to look in IPE_COMMAND to find when the last statement in this TNO completed and use that as the start time)

In second batch, exclude workers from first batch

How do I run a second batch on a HIT but ensure I have a new set of workers? I want to make a small change to the HIT and start a new batch, but I don't want any of the workers who participated in the first batch to participate in the second.
Your best bet is to add assignments to your existing HITs (you can do this easily through the RUI), which will exclude workers who have already done those HITs.
But, before you do that, you'll need to change the HITs, which is more difficult (but relatively easy through the API using a ChangeHITTypeOfHIT operation for title/description/duration/qualification changes). If you need to change the Question parameter of a HIT (the actual displayed content of the HIT) or the amount it pays (reward), then you need to create new HITs and send them out as a new batch.
To prevent workers from redoing the HITs you can either put a qualification on the HIT and assign all of your current workers to a score below that level.
Or, you can put a note on the HIT saying that duplicate work will be unpaid. If you do this, you should include a link on the HIT that takes workers to a list of past workerids so that they can check whether they've already done the task.
Update 2018:
You don't need to modify the content of the HIT anymore.
Instead, you assign a qualification to the previous participants in a csv sheet.
Then, in the new HIT, you set as requirement that this qualification "has not been granted".
Detailed explanation at the bottom here and step-by-step procedure describe in this pdf.

Designing a timer functionality in VC++

I was implemnting some functionaliy in which i get a set of queries on database One shouldnt loose the query for a certain time lets say some 5min unless and untill the query is executed fine (this is incase the DB is down, we dont loose the query). so, what i was thinking to do is to set a sort of timer for each query through a different thread and wait on it for that time frame, and at the end if it still exists, remove it from the queue, but, i am not happy with this solution as i have to create as many threads as the number of queries. is there a better way to design this (environment is vc++), If the question is unclear, please let me know, i will try to frame it better.
One thread is enough to check lets say every 10 seconds that you do not have queries in that queue of yours whose due time has been reached and so should be aborted / rolled back.
Queues are usually grown from one end and erased from other end so you have to check only if the query on the end where the oldest items are has not reached its due time.

Processing web feed multiple times a day

Ok, here is in brief the deal: I spider the web (all kind of data, blogs/news/forums) as it appears on internet. Then I process this feed and do analysis on processed data. Spidering is not a big deal. I can get it pretty much in real time as internet gets new data. Processing is a bottleneck, it involves some computationally heavy algorithms.
I am in pursuit of building a strategy to schedule my spiders. The big goal is to make sure that analysis that is produced as end result reflects effect of as much recent input as possible. Start to think of it, the obvious objective is to make sure data does not pile up. I get the data through spiders, pass on to processing code, wait till processing gets over and then spider more. This time bringing all the data which appeared while I was waiting for processing to get over. Okay this is a very broad thought.
Can some of you share your thoughts, may be think loud. If you were me what would go in your mind. I hope I am making sense with my question. This is not a search engine indexing by the way.
It appears that you want to keep the processors from falling too far behind the spiders. I would imagine that you want to be able to scale this out as well.
My recommendation is that you implement a queue using an client/server SQL databse. MySQL would work nicely for this purpose.
Design Objectives
Keep the spiders from getting too far ahead of the processors
Allow for a balance of power between spiders and processors (keeping each busy)
Keep data as fresh as possible
Scale out and up as needed
Queue:
Create a queue to store the data from the spiders before it is processed. This could be done in several ways, but it does not sound like IO is your bottleneck.
A simple approach would be to have an SQL table with this layout:
TABLE Queue
Queue_ID int unsigned not null auto_increment primary key
CreateDate datetime not null
Status enum ('New', 'Processing')
Data blob not null
# pseudo code
function get_from_queue()
# in SQL
START TRANSACTION;
SELECT Queue_ID, Data FROM Queue WHERE Status = 'New' LIMIT 1 FOR UPDATE;
UPDATE Queue SET Status = 'Processing' WHERE Queue_ID = (from above)
COMMIT
# end sql
return Data# or false in the case of no records found
# pseudo code
function count_from_queue()
# in SQL
SELECT COUNT(*) FROM Queue WHERE Status = 'New'
# end sql
return (the count)
Spider:
So you have multiple spider processes.. They each say:
if count_from_queue() < 10:
# do the spider thing
# save it in the queue
else:
# sleep awhile
repeat
In this way, each spider will be either resting or spidering. The decision (in this case) is based on if there are less than 10 pending items to process. You would tune this to your purposes.
Processor
So you have multiple processor processes.. They each say:
Data = get_from_queue()
if Data:
# process it
# remove it from the queue
else:
# sleep awhile
repeat
In this way, each processor will be either resting or processing.
In summary:
Whether you have this running on one computer, or 20, a queue will provide the control you need to ensure that all parts are in sync, and not getting too far ahead of each other.