com.bigdata.journal
Interface IConcurrencyManager

All Superinterfaces:
IServiceShutdown
All Known Implementing Classes:
ConcurrencyManager, Journal

public interface IConcurrencyManager
extends IServiceShutdown

Interface for managing concurrent access to resources (indices).

Version:
$Id: IConcurrencyManager.java 2265 2009-10-26 12:51:06Z thompsonbry $
Author:
Bryan Thompson
See Also:
AbstractTask, Base class for tasks to be executed with concurrency control.

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.bigdata.service.IServiceShutdown
IServiceShutdown.Options
 
Method Summary
 ICounterSet getCounters()
          Return declared counters.
 IResourceManager getResourceManager()
          The object used to manage local resources.
 ILocalTransactionManager getTransactionManager()
          The client side of the transaction manager.
 WriteExecutorService getWriteService()
          The service on which read-write tasks are executed.
<T> List<Future<T>>
invokeAll(Collection<? extends AbstractTask<T>> tasks)
          Executes the given tasks, returning a list of Futures holding their status and results when all complete.
 List<Future> invokeAll(Collection<? extends AbstractTask> tasks, long timeout, TimeUnit unit)
          Executes the given tasks, returning a list of Futures holding their status and results when all complete or the timeout expires, whichever happens first.
 void shutdown()
          Normal shutdown - running tasks will run to completion, but no new tasks will start.
 void shutdownNow()
          Immediate shutdown - running tasks are cancelled rather than being permitted to complete.
<T> Future<T>
submit(AbstractTask<T> task)
          Submit a task (asynchronous).
 
Methods inherited from interface com.bigdata.service.IServiceShutdown
isOpen
 

Method Detail

getTransactionManager

ILocalTransactionManager getTransactionManager()
The client side of the transaction manager.


getResourceManager

IResourceManager getResourceManager()
The object used to manage local resources.


shutdown

void shutdown()
Normal shutdown - running tasks will run to completion, but no new tasks will start.

Specified by:
shutdown in interface IServiceShutdown
See Also:
shutdownNow()

shutdownNow

void shutdownNow()
Immediate shutdown - running tasks are cancelled rather than being permitted to complete.

Specified by:
shutdownNow in interface IServiceShutdown
See Also:
shutdown()

getCounters

ICounterSet getCounters()
Return declared counters.


submit

<T> Future<T> submit(AbstractTask<T> task)
Submit a task (asynchronous). Tasks will execute asynchronously in the appropriate thread pool with as much concurrency as possible.

Note: Unisolated write tasks will NOT return before the next group commit (exceptions may be thrown if the task fails or the commit fails). The purpose of group commits is to provide higher throughput for writes on the store by only syncing the data to disk periodically rather than after every write. Group commits are scheduled by the #commitService. The trigger conditions for group commits may be configured using ConcurrencyManager.Options. If you are using the store in a single threaded context then you may set Options#WRITE_SERVICE_CORE_POOL_SIZE to ONE (1) which has the effect of triggering commit immediately after each unisolated write. However, note that you can not sync a disk more than ~ 30-40 times per second so your throughput in write operations per second will never exceed that for a single-threaded application writing on a hard disk. (Your mileage can vary if you are writing on a transient store or using a durable medium other than disk).

Note: The isolated indices used by a read-write transaction are NOT thread-safe. Therefore a partial order is imposed over concurrent tasks for the same transaction that seek to read or write on the same index(s). Full concurrency is allowed when different transactions access the same index(s), but write-write conflicts MAY be detected during commit processing.

Note: The following exceptions MAY be wrapped by Future.get() for tasks submitted via this method:

ValidationError
An unisolated write task was attempting to commit the write set for a transaction but validation failed. You may retry the entire transaction.
InterruptedException
A task was interrupted during execution and before the task had completed normally. You MAY retry the task, but note that this exception is also generated when tasks are cancelled when the journal is being shutdown() after the timeout has expired or shutdownNow(). In either of these cases the task will not be accepted by the journal.

Parameters:
task - The task.
Returns:
The Future that may be used to resolve the outcome of the task.
Throws:
RejectedExecutionException - if task cannot be scheduled for execution (typically the queue has a limited capacity and is full)
NullPointerException - if task is null

invokeAll

<T> List<Future<T>> invokeAll(Collection<? extends AbstractTask<T>> tasks)
                          throws InterruptedException
Executes the given tasks, returning a list of Futures holding their status and results when all complete. Note that a completed task could have terminated either normally or by throwing an exception. The results of this method are undefined if the given collection is modified while this operation is in progress.

Note: Contract is per ExecutorService.invokeAll(Collection)

Parameters:
tasks - The tasks.
Returns:
Their Futures.
Throws:
InterruptedException - if interrupted while waiting, in which case unfinished tasks are cancelled.
NullPointerException - if tasks or any of its elements are null
RejectedExecutionException - if any task cannot be scheduled for execution

invokeAll

List<Future> invokeAll(Collection<? extends AbstractTask> tasks,
                       long timeout,
                       TimeUnit unit)
                       throws InterruptedException
Executes the given tasks, returning a list of Futures holding their status and results when all complete or the timeout expires, whichever happens first. Note that a completed task could have terminated either normally or by throwing an exception. The results of this method are undefined if the given collection is modified while this operation is in progress.

Note: Contract is based on ExecutorService.invokeAll(Collection, long, TimeUnit) but only the Futures of the submitted tasks are returned.

Parameters:
tasks - The tasks.
Returns:
The Futures of all tasks that were submitted prior to the expiration of the timeout.
Throws:
InterruptedException - if interrupted while waiting, in which case unfinished tasks are cancelled.
NullPointerException - if tasks or any of its elements are null
RejectedExecutionException - if any task cannot be scheduled for execution FIXME Figure out why a generic for the future type causes errors under some java 1.6.0_07 and 1.6.0_10 compilers. It does not seem to be a problem in the variant w/o the timeout, which is very, very strange.

getWriteService

WriteExecutorService getWriteService()
The service on which read-write tasks are executed.



Copyright © 2006-2012 SYSTAP, LLC. All Rights Reserved.