|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||

java.lang.Objectjava.lang.Thread
de.unikassel.android.sdcframework.util.AbstractWorkerThread
de.unikassel.android.sdcframework.transmission.TransferManagerImpl
public class TransferManagerImpl
Implementation of the transfer manager which is the main access component for the transmission module.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.lang.Thread |
|---|
Thread.State, Thread.UncaughtExceptionHandler |
| Field Summary | |
|---|---|
private ObservableAlarm |
alarm
The observable wake up alarm |
private EventObserver<AlarmEvent> |
alarmObserver
The alarm observer to delegate to |
static int |
COLLECTING
The internal COLLECTING state of the transfer service |
private static long |
CONNECTION_WAKE_UP_TIME
The internal wake up time in case of lost connection ( milli seconds ) |
private NetworkConnectionObserver |
connectionObserver
The network connection observer |
private Object |
connectionWaitLock
The wait lock for unavailable connection |
private SampleCollection |
currentSamples
The current sample collection to transfer |
private AtomicInteger |
currentState
The current state |
private DatabaseManager |
dbManager
The database adapter used for DB access |
private FileManager |
fileManager
The manager for the file access and archive creation |
private ObservableAlarm |
forcedActivationAlarm
The observable wake up alarm for forced transmission |
private Object |
frequencyWaitLock
The frequency wait lock |
private SampleGatheringController |
gatheringController
The controller for the sample gather task |
static int |
INIT
The internal COLLECTING state of the transfer service |
static long |
INITIAL_DELAY
The start delay after transfer manager is activated. |
private AtomicLong |
lastExecutionTimeStamp
The time stamp of last execution cycle |
static long |
MIN_FREQUENCY
The internal lower limit of wait time in seconds |
private AtomicLong |
minFrequency
The minimal transfer frequency in milliseconds |
static int |
PREPARATION
The internal PREPARATION state of the transfer service |
private Object |
protocolWaitLock
The wait lock for invalid url |
private Object |
sampleWaitLock
The sample rate wait lock |
private ObservableEventSource<TransferEvent> |
transferEventSource
The event source for the observable transfer events. |
static int |
TRANSMISSION
The internal transmission state of the transfer service |
private UploadManager |
uploadManager
The upload manager |
private static int |
WAIT_TIME_FOR_CONFIG_CHANGES
The time to wait at maximum for configuration changes if transfer fails due to invalid settings |
private WakeLockHolder |
wakeLockHolder
The wake lock maintainer |
| Fields inherited from class java.lang.Thread |
|---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
|---|---|
TransferManagerImpl(Context applicationContext,
TransmissionConfiguration config,
DatabaseManager dbManager,
UUID uuid,
Class<?> controlActivityClass)
Constructor |
|
| Method Summary | |
|---|---|
private void |
addSamples(Collection<DatabaseSample> samples)
Does add a collection of database samples to the current sample collection for transmission |
protected void |
doCleanUp()
The clean up method executed on termination |
private void |
doPickSamplesFromDatabase()
Does remove available samples from the database. |
private boolean |
doPrepareArchive()
Does create the archive for transmission |
void |
doReactOnUploadError()
|
protected void |
doSignalConnectionStateChange()
Method to signal connection state changes |
protected void |
doSignalFrequencyChange()
Method to signal frequency changes |
protected void |
doSignalProtocolChange()
Method to signal protocol changes |
protected void |
doSignalSampleRateChanged()
Method to signal sample rate changes |
private boolean |
doTransferArchive()
Does upload the archive to the configured host |
void |
doWaitForSamples(long waitTime)
Method to wait for samples available for transmission |
protected void |
doWork()
The working method executed in the running loop if started |
boolean |
forcedActivation()
Does force an activation of the transfer service. |
String |
getCurrentArchiveFileName()
Method to access the filename of the current archive |
private long |
getCurrentRecordCount()
Getter for the record count in the database |
int |
getCurrentState()
Getter for the current state |
int |
getMaxSampleCount()
Getter for the maximum sample count to transfer |
long |
getMinFrequency()
Getter for the minimum frequency to set |
int |
getMinSampleCount()
Getter for the minimum sample count to transfer |
long |
getTimeStamp()
Getter for the time stamp of last execution |
boolean |
hasObservers()
Test method for observers. |
void |
notify(TransferEvent data)
Does set the changed flag and notifies all observers |
void |
onCreate(Context applicationContext)
Creation method |
void |
onDestroy(Context applicationContext)
Destroy method |
void |
onEvent(ObservableEventSource<? extends NetworkStateChangeEvent> eventSource,
NetworkStateChangeEvent observedEvent)
This method is called whenever the observed object does create an observed event |
void |
onPause(Context applicationContext)
Pause method |
void |
onResume(Context applicationContext)
Resume method |
void |
onSampleRateChanged()
Method to react on signaled sample rate changes |
void |
registerEventObserver(EventObserver<? extends TransferEvent> observer)
Does register an observer |
void |
removeAllObservers()
Does remove all registered observers |
void |
unregisterEventObserver(EventObserver<? extends TransferEvent> observer)
Does delete a registered observer |
void |
updateConfiguration(Context context,
TransmissionConfiguration config)
Method to update the component by a configuration |
| Methods inherited from class de.unikassel.android.sdcframework.util.AbstractWorkerThread |
|---|
doTerminate, hasTerminated, isLogging, isWorking, logMessage, run, setLogging, start, startWork, stopWork |
| Methods inherited from class java.lang.Thread |
|---|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, stop, stop, suspend, toString, yield |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface de.unikassel.android.sdcframework.util.facade.WorkerThread |
|---|
doTerminate, hasTerminated, isLogging, isWorking, setLogging, startWork, stopWork |
| Field Detail |
|---|
private static final int WAIT_TIME_FOR_CONFIG_CHANGES
public static final int INIT
public static final int COLLECTING
public static final int PREPARATION
public static final int TRANSMISSION
public static final long MIN_FREQUENCY
public static final long INITIAL_DELAY
private static final long CONNECTION_WAKE_UP_TIME
private final DatabaseManager dbManager
private final FileManager fileManager
private final UploadManager uploadManager
private final AtomicInteger currentState
private final NetworkConnectionObserver connectionObserver
private final Object connectionWaitLock
private final Object protocolWaitLock
private final Object frequencyWaitLock
private final Object sampleWaitLock
private final AtomicLong minFrequency
private final AtomicLong lastExecutionTimeStamp
private final SampleCollection currentSamples
private final SampleGatheringController gatheringController
private final ObservableAlarm alarm
private final ObservableAlarm forcedActivationAlarm
private final EventObserver<AlarmEvent> alarmObserver
private final WakeLockHolder wakeLockHolder
private final ObservableEventSource<TransferEvent> transferEventSource
| Constructor Detail |
|---|
public TransferManagerImpl(Context applicationContext,
TransmissionConfiguration config,
DatabaseManager dbManager,
UUID uuid,
Class<?> controlActivityClass)
applicationContext - the application contextconfig - the current transmission configurationdbManager - the database manager to useuuid - the unique device identifier created by the servicecontrolActivityClass - the control activity class or null| Method Detail |
|---|
public boolean forcedActivation()
TransferManager
forcedActivation in interface TransferManagerpublic final void onCreate(Context applicationContext)
LifeCycleObject
onCreate in interface LifeCycleObjectapplicationContext - the application contextpublic final void onResume(Context applicationContext)
LifeCycleObject
onResume in interface LifeCycleObjectapplicationContext - the application contextpublic final void onPause(Context applicationContext)
LifeCycleObject
onPause in interface LifeCycleObjectapplicationContext - the application contextpublic void onDestroy(Context applicationContext)
LifeCycleObject
onDestroy in interface LifeCycleObjectapplicationContext - the application contextprotected final void doCleanUp()
AbstractWorkerThread
doCleanUp in class AbstractWorkerThread
public final void updateConfiguration(Context context,
TransmissionConfiguration config)
UpdatableTransmissionComponent
updateConfiguration in interface UpdatableTransmissionComponent<TransmissionConfiguration>context - the application contextconfig - the configuration to update fromprotected final void doWork()
AbstractWorkerThread
doWork in class AbstractWorkerThread
public void doWaitForSamples(long waitTime)
throws InterruptedException
waitTime - the time to wait
InterruptedException - in case of thread interruption
public void doReactOnUploadError()
throws InterruptedException
InterruptedExceptionprivate final boolean doTransferArchive()
private final boolean doPrepareArchive()
private final void doPickSamplesFromDatabase()
private final void addSamples(Collection<DatabaseSample> samples)
samples - the database sample collection to add to current sample collectionprivate long getCurrentRecordCount()
public final long getMinFrequency()
public final int getMinSampleCount()
public final int getMaxSampleCount()
public final int getCurrentState()
public final long getTimeStamp()
public final String getCurrentArchiveFileName()
public void onEvent(ObservableEventSource<? extends NetworkStateChangeEvent> eventSource,
NetworkStateChangeEvent observedEvent)
EventObserver
onEvent in interface EventObserver<NetworkStateChangeEvent>eventSource - the event generatorobservedEvent - the event created by the observed objectpublic void onSampleRateChanged()
SampleRateChangeResponder
onSampleRateChanged in interface SampleRateChangeResponderprotected void doSignalProtocolChange()
protected void doSignalConnectionStateChange()
protected void doSignalSampleRateChanged()
protected void doSignalFrequencyChange()
public void notify(TransferEvent data)
ObservableEventSource
notify in interface ObservableEventSource<TransferEvent>data - the observable event data to create notifications forpublic boolean hasObservers()
ObservableEventSource
hasObservers in interface ObservableEventSource<TransferEvent>public void registerEventObserver(EventObserver<? extends TransferEvent> observer)
ObserverRegistration
registerEventObserver in interface ObserverRegistration<TransferEvent>observer - the observer to addpublic void unregisterEventObserver(EventObserver<? extends TransferEvent> observer)
ObserverRegistration
unregisterEventObserver in interface ObserverRegistration<TransferEvent>observer - the observer to deletepublic void removeAllObservers()
ObserverRegistration
removeAllObservers in interface ObserverRegistration<TransferEvent>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||