Is there a Quartz Thread Pool Implementation (http://javasourcecode.org/html/open-source/quartz/quartz-2.0.2/org/quartz/spi/ThreadPool.java.html) with Pooled Executor Service ? instead of using SimpleThreadPool which is using work thread model.
Thanks,
BMIS13
Take a look at ConcurrentTaskExecutor and/or ThreadPoolTaskExecutor.
http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/scheduling.html (look at the 25.2.1 section)
I wrote something similiar some time ago ExecutorThreadPool
Related
I playing with the test code to submit BIO from my own kernel module:
if i use submit_bio(&bio) - all works fine
if i use bdev->bd_queue->make_request_fn(bdev->bd_queue, &bio) then
getting in the dmesg:
__get_request: dev 8:0: request aux data allocation failed, iosched may be disturbed
My primary target is submiting BIOs to stackable device driver w/o calling the submit_bio() routine. Any ideas, pointers ?
Our hero Tom Caputi of ZFS encryption fame figured this out.
Basically the scheduler expects an io context in the task struct for the thread that's running your request.
You'll see here, the io context is created in generic_make_request_checks()
https://elixir.bootlin.com/linux/latest/source/block/blk-core.c#L2323
If it is never created for the task struct that's running your request, you'll see that message "io sched may be disturbed." A lousy message if ever there was one. "Scheduler context was not allocated for this task" would have made the problem a bit more obvious.
I'm not the kernel guy that tom is, but basically by doing this:
bdev->bd_queue->make_request_fn
your request is being handled by another thread, that doesn't have that context allocated.
Now create_io_context is not exported so you can't call it directly.
But if you call this:
https://elixir.bootlin.com/linux/latest/source/block/blk-ioc.c#L319
which is exported the io context will be allocated an no more warning message.
And I imagine there will be some io improvement because the scheduler has context to work with.
Like C++/Java, is there a way to check in Q if current thread is main thread or slave thread? I could not find any reference online about this.
q){#[value;"{a::1;`main}[]";`slave]} each 1 2
`main`main
q){#[value;"{a::1;`main}[]";`slave]} peach 1 2
`slave`slave
Basically exploit one of the differences in being in a slave thread, you can't set global values. You might also find this peach/.Q.fc guide useful .Q.fc can be a useful alternative to peach.
I have data stored in ThreadLocal (such as MDC) and I need it to update it for each request.
Using the rx-netty http client I put the value as a http header but I can't find a hook where I can read this value after the control is passed into the netty thread pool and then set it on the thread local of the netty thread.
Is this possible using some API?
You can add netty's ChannelHandler using RxNetty's PipelineConfigurator(somewhat like this: https://github.com/ReactiveX/RxNetty/blob/0.4.x/rxnetty-examples/src/main/java/io/reactivex/netty/examples/tcp/cpuintensive/CPUIntensiveServer.java#L66). Then your code will be executed in Netty's eventloop.
Once you have a sample code, I can look into it, in case you need more help.
I have a Java EE app on WebSphere 7.
My app places emails that need to be sent in a notifications table in the db.
I'd like to write code that fires every 5 or 10 minutes and scans the notification tables for entries with status "PENDING", sends the email, then updates the status as "SENT".
What's the appropriate Java EE technology to make this happen every 5 or 10 minutes? Is there somekind of "timer process" available in Java EE?
Any info is useful, thanks!
Rob
You can utilize #Schedule annotations for such purpose.
JavaEE 6 has Timer service for this
http://docs.oracle.com/javaee/6/tutorial/doc/bnboy.html
#ManagedBean
#Stateless(name="MyScheduledTaskClass")
public class MyScheduledTaskClass implements Serializable{
private Logger _log = Logger.getLogger(this.getClass());
#Schedule(minute="*/5") //minute="*/10" if you want every 10 minutes
public void executeTask(){
_log.info("Scheduled task started");
//Do some stuff here
_log.info("Scheduled task finished");
}
}
Quartz Scheduler is a good library.
WebSphere 7 runs Java EE 5 (I think), so your choices are little bit limited in that regard.
You can use a library like Quartz Scheduler, but you have to be careful to hook it up to a thread pool which is managed by the container. I believe by default it just creates threads on its own which is outright prohibited in EJBs (and strongly discouraged in the web container).
I found a nice blog post that walks you through the configuration of setting up a work manager pool on WebSphere: http://sanjsuya.wordpress.com/2012/01/19/asynchronousbean-was-spring-integration/
If you're using Spring, you can then hook up the Quartz scheduler to this thread pool fairly easily using a WorkManagerTaskExecutor. Here's some Spring documentation on that (note, it's from Spring 2, but I'm sure you more-or-less do something like this for Spring 3 as well): http://static.springsource.org/spring/docs/2.0.x/reference/scheduling.html
EDIT: the architect in me is cringing slightly (though maybe you have a good reason for doing it the way you're doing it). Why are you writing e-mails to a DB and not to a queue? That way, they could be processed at the leisure of a receiving system, and you're not overloading a whole lot of background work onto WebSphere.
If you don't need anything very fancy, you can schedule tasks with java.util.concurrent.Executors
public class Foo implements Runnable(){
public void run(){
//do stuff
}
}
And schedule to run every t milliseconds with d delay seconds
Executors.newScheduledThreadPool(10).scheduleAtFixedRate(new Foo(), d, t, TimeUnit.MILLISECONDS);
Quartz is excellent, however the Java EE spec now includes EJB timers which may suit your needs.
Is there a way to get the list of currently running threads in objective-C?
I'm mostly interested in getting the NSThreads objects, cause i want to replace the assertion handler for each running thread?
If such thing is not possible, maybe i could set my own selector to be invoked after any thread is spawn(so that i could do the assertion handler replacement over there)?
The "Assertions and Logging Programming Guide" says you can only set the assertion handler for the current thread:
You must execute these steps in the
thread which you wish to modify; one
thread cannot modify the thread
attributes dictionary of another.