WorkManager - PowerPoint PPT Presentation

1 / 13
About This Presentation
Title:

WorkManager

Description:

org.terracotta.channel. V2.0 - Channels. Channel Manager ... org.terracotta.workmanager..* ChannelMaster implements WorkManager ... – PowerPoint PPT presentation

Number of Views:89
Avg rating:3.0/5.0
Slides: 14
Provided by: terra5
Category:

less

Transcript and Presenter's Notes

Title: WorkManager


1
WorkManager
  • V2.0

2
High Level APIs (CommonJ)
  • Interface Work extends Runnable
  • Interface WorkListener
  • Interface WorkManager
  • WorkItem schedule(Work work)
  • WorkItem schedule(Work, WorkListener listener)
  • waitForAll(Collection workItems, long timeout)
  • waitForAny(Collection workItems, long timeout)

3
Typical Invocation
  • someQuery ()
  • Collection pending new some collection
  • SetltWorkgt work generate some work items
  • For (Work w work)
  • WorkItem wi workManager.schedule(w, timeout)
  • pending.add(wi)
  • workManager.waitForAll(pending, timeout)

4
Simple Implementation
Worker
run() Work w lbq.take()
w.setStatus(ACCEPTED) w.run()
w.setStatus(COMPLETED)
Worker
Executor
Executor
LBQ
LBQ
schedule(Work w) lbq.put(w) waitForAll()
for (Work w work) if (work.completed())

SimpleWorkManager ltimplements WorkManagergt
LBQ
5
Version 2.0 - Channels
  • Goals
  • Eliminate Lock Contention
  • Send
  • Receive
  • Eliminate Lock Contention on work complete
  • Try DMI vs. LinkedBlockingQueue
  • Reimplement waitForAll() and waitForAny()
  • Dynamically Adapt to Adds
  • Dynamically Adapt to Removes
  • Support Reschedule of Work

6
Architecture - 2xMxN Channels
ChannelWorker
ChannelWorker
ChannelWorker
ChannelWorker
ChannelManager
ChannelMaster
ChannelMaster
ChannelMaster
7
V2.0 - Channels
org.terracotta.channel
Interface ChannelltTgt put(T t) take(T t)
poll(T t)
Interface ChannelFactoryltTgt ChannelltTgt create()
Interface Handle
Interface ListenerltTgt event(T t)
DMIChannel
Channel Manager addChannel(Handle s, Handle d,
Channel channel) registerChannelListener(Handle
s, ListenerltChannelMessagegt l)
BatchingChannel
LBQChannel
org.terracotta.workmanager..
Interface Router MutableWorkItem
schedule(MutableWorkItem workItem)
addOutboundChannel(Channelltgt channel, Handle
destination) addReturnChannel(Channelltgt
channel, Handle source)
RoundRobinRouter
SingleRouter
ChannelMaster implements WorkManager
ChannelWorker implements Worker
NodeManager
8
Master
Master M0
M0W2
M0W1
M0W0
M0W3
Router
9
Worker
Worker W0
run() Work w lbq.take()
w.setStatus(ACCEPTED) w.run()
w.setStatus(COMPLETED)
Executor
LBQ
ChannelWorkItem setStatus() if (status
completed) channel.put(this)
M0W0
M1W0
M2W0
10
Batching
BatchingChannelltTgt implements ChannelltTgt
put(T t) batch.put(t) if (batch.full())
flush() flush() channel.Put(batch)
batch new Batch()
batch
channel
LBQltTgt(batchSize)
ChannelltLinkedBlockingQueueltTgtgt channel
11
Batching vs. Non-Batching
Batching
Batching Channel
Batch
Batch
Batch
Batch
T
T
T
T
T
T
T
T
T
T
T
T
T
T
T
T
Batching
Channel
T
T
T
T
T
T
T
T
T
T
T
T
T
T
T
T
12
Usage
MASTER ChannelFactoryltBlockingQueueltChannelWorkIt
emgt batchFactory ChannelFactoryltChannelWorkItemgt
factory ChannelManagerltChannelWorkItemgt
channelManager Router router batchFactory
new BlockingQueueChannel.FactoryltBlockingQueueltCha
nnelWorkItemgtgt() factory new
BatchingChannel.FactoryltChannelWorkItemgt(100,
batchFactory) channelManager new
ChannelManagerltChannelWorkItemgt() router new
RoundRobinRouter() workManager new
ChannelMaster(channelManager, router, factory)
WORKER ChannelFactoryltChannelWorkItemgt
factory ChannelManagerltChannelWorkItemgt
channelManager factory new
BlockingQueueChannel.FactoryltChannelWorkItemgt() c
hannelManager new ChannelManagerltChannelWorkItem
gt() new CachedThreadPoolWorkExecutorltCha
nnelWorkItemgt(Executors.newCachedThreadPool(),

new ChannelWorker(channelManager,

factory)).start()
13
Results
  • Simple Implementation
  • ??? 100s? TPS
  • Channel Implementation DMI
  • 1 Node 550 TPS
  • Channel Implementation LBQ w/out Batching
  • 1 Node 600 TPS
  • 2 Nodes 750 TPS
  • 3 Nodes 1000 TPS
  • Channel Implementation LBQ w/Batching
  • 1 Node 1000 TPS
  • 2 Nodes ??? TPS
  • 3 Nodes 2500 TPS

Note Results are for 2.0GHz Dual Proc Xeon,
HotSpot 1.5 JVM with no GC tuning
2.0 GHZ
Write a Comment
User Comments (0)
About PowerShow.com