edu.sc.seis.sod.hibernate
Class SodDB

java.lang.Object
  extended by edu.sc.seis.fissuresUtil.hibernate.AbstractHibernateDB
      extended by edu.sc.seis.sod.hibernate.SodDB

public class SodDB
extends AbstractHibernateDB


Field Summary
static java.lang.Class<? extends AbstractEventChannelPair> defaultEcpClass
           
 java.lang.Class<? extends AbstractEventChannelPair> ecpClass
           
 
Fields inherited from class edu.sc.seis.fissuresUtil.hibernate.AbstractHibernateDB
DEBUG_SESSION_CREATION, DEBUG_SESSION_CREATION_SECONDS
 
Constructor Summary
protected SodDB()
          database should use one of EventVectorPair or EventChannelPair.
 
Method Summary
static void configHibernate(org.hibernate.cfg.Configuration config)
           
 EventChannelPair createEventChannelPair(StatefulEvent event, ChannelImpl chan, EventStationPair esp)
           
 EventNetworkPair createEventNetworkPair(StatefulEvent event, NetworkAttrImpl net)
           
 EventStationPair createEventStationPair(StatefulEvent event, StationImpl station)
           
static java.lang.Class<? extends AbstractEventChannelPair> discoverDbEcpClass()
           
 java.util.List<AbstractEventChannelPair> getAll(CacheEvent event)
           
 java.util.List<RecordSectionItem> getBestForRecordSection(java.lang.String orientationId, java.lang.String recordSectionId, CacheEvent event)
           
 java.util.List<ChannelImpl> getChannelsForRecordSection(java.lang.String orientationId, CacheEvent event, boolean best)
           
 SodConfig getConfig(int configid)
           
 SodConfig getCurrentConfig()
           
 Version getDBVersion()
           
 EventChannelPair getECP(CacheEvent event, ChannelImpl chan)
           
 java.lang.Class<? extends AbstractEventChannelPair> getEcpClass()
           
 java.util.List<CacheEvent> getEventsForStation(StationImpl sta)
           
 java.util.List<AbstractEventChannelPair> getFailed(CacheEvent event)
           
 java.util.List<AbstractEventChannelPair> getFailed(CacheEvent event, StationImpl station)
           
 java.util.List<AbstractEventChannelPair> getFailed(StationImpl station)
           
 int getMaxRetries()
           
 TimeInterval getMinRetryDelay()
           
 AbstractEventChannelPair getNextECP()
          next successful event-channel to process.
 EventNetworkPair getNextENP()
          next successful event-network to process.
 EventNetworkPair getNextENPFromCache()
          next successful event-network to process from cache.
 EventStationPair getNextESP()
          next successful event-station to process.
 EventStationPair getNextESPFromCache()
          next successful event-station to process from memory cache.
 AbstractEventChannelPair getNextRetryECPFromCache()
           
 int getNumEventNetworkWorkUnits(Standing standing)
           
 int getNumFailed(CacheEvent event)
           
 int getNumFailed(CacheEvent event, StationImpl station)
           
 int getNumFailed(StationImpl station)
           
 int getNumRetry(CacheEvent event)
           
 int getNumRetry(CacheEvent event, StationImpl station)
           
 int getNumRetry(StationImpl station)
           
 int getNumSuccessful()
           
 int getNumSuccessful(CacheEvent event)
           
 int getNumSuccessful(CacheEvent event, StationImpl station)
           
 int getNumSuccessful(StationImpl station)
           
 int getNumWorkUnits(Standing standing)
           
 QueryTime getQueryTime(java.lang.String serverName, java.lang.String serverDNS)
           
 java.util.List<java.lang.String> getRecordSectionId(CacheEvent event)
          Finds the recordsectionids for this event
 RecordSectionItem getRecordSectionItem(java.lang.String orientationId, java.lang.String recordSectionId, CacheEvent event, ChannelImpl channel)
           
 RecordSectionItem getRecordSectionItemForEvent(CacheEvent event, ChannelImpl channel)
           
 java.util.List<RecordSectionItem> getRecordSectionItemList(java.lang.String orientationId, java.lang.String recordSectionId, CacheEvent event)
           
 java.util.List<java.lang.String> getRecordSectionOrientations(CacheEvent event)
          Finds the recordsection orientationids for this event
 java.util.List<AbstractEventChannelPair> getRetry(CacheEvent event)
           
 java.util.List<AbstractEventChannelPair> getRetry(CacheEvent event, StationImpl station)
           
 java.util.List<AbstractEventChannelPair> getRetry(StationImpl station)
           
 java.util.List<AbstractEventChannelPair> getRetryToDo()
           
static SodDB getSingleton()
           
 java.util.List<StationImpl> getStationsForEvent(CacheEvent event)
           
 java.util.List<StationImpl> getStationsForRecordSection(java.lang.String orientationId, java.lang.String recordSectionId, CacheEvent event, boolean best)
           
 java.util.List<AbstractEventChannelPair> getSuccessful(CacheEvent event)
           
 java.util.List<AbstractEventChannelPair> getSuccessful(CacheEvent event, StationImpl station)
           
 java.util.List<AbstractEventChannelPair> getSuccessful(StationImpl station)
           
 java.util.List<CacheEvent> getSuccessfulEventsForStation(StationImpl sta)
           
 java.util.List<StationImpl> getSuccessfulStationsForEvent(CacheEvent event)
           
 java.util.List<CacheEvent> getUnsuccessfulEventsForStation(StationImpl sta)
           
 java.util.List<StationImpl> getUnsuccessfulStationsForEvent(CacheEvent event)
           
 void initHQLStmts()
           
 boolean isENPTodo()
           
 boolean isESPTodo()
           
 boolean isRetryTodo()
           
 void offerEventNetworkPairs(java.util.List<EventNetworkPair> staPairList)
           
 void offerEventStationPair(java.util.List<EventStationPair> staPairList)
           
 void populateENPToDo()
           
 void populateESPToDo()
           
 void populateRetryToDo()
           
 EventVectorPair put(EventVectorPair eventVectorPair)
           
 long put(RecordSectionItem item)
           
 int putConfig(SodConfig sodConfig)
           
protected  Version putDBVersion()
           
 int putQueryTime(QueryTime qtime)
           
 java.util.List<RecordSectionItem> recordSectionsForEvent(CacheEvent event)
           
 void reopenSuspendedEventChannelPairs(java.lang.String processingRule, boolean vector)
           
static void setDefaultEcpClass(java.lang.Class<? extends AbstractEventChannelPair> ecpClass)
           
 boolean updateBestForRecordSection(java.lang.String orientationId, java.lang.String recordSectionId, CacheEvent event, ChannelId[] channelIds)
           
 
Methods inherited from class edu.sc.seis.fissuresUtil.hibernate.AbstractHibernateDB
commit, createSession, deploySchema, flush, getReadOnlySession, getSession, getTXID, getUnitCache, intern, internUnit, internUnit, isSessionOpen, rollback
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultEcpClass

public static java.lang.Class<? extends AbstractEventChannelPair> defaultEcpClass

ecpClass

public java.lang.Class<? extends AbstractEventChannelPair> ecpClass
Constructor Detail

SodDB

protected SodDB()
database should use one of EventVectorPair or EventChannelPair. Using AbstractEventChannelPair results in very slow union in selects in hsqldb. By specifying which table we are using, the queries are several orders of magnitude faster and do not use huge amounts of memory, which matters a lot when the number of ecps becomes large.

Parameters:
ecpClass -
Method Detail

configHibernate

public static void configHibernate(org.hibernate.cfg.Configuration config)

reopenSuspendedEventChannelPairs

public void reopenSuspendedEventChannelPairs(java.lang.String processingRule,
                                             boolean vector)

createEventNetworkPair

public EventNetworkPair createEventNetworkPair(StatefulEvent event,
                                               NetworkAttrImpl net)

offerEventNetworkPairs

public void offerEventNetworkPairs(java.util.List<EventNetworkPair> staPairList)

offerEventStationPair

public void offerEventStationPair(java.util.List<EventStationPair> staPairList)

createEventStationPair

public EventStationPair createEventStationPair(StatefulEvent event,
                                               StationImpl station)

createEventChannelPair

public EventChannelPair createEventChannelPair(StatefulEvent event,
                                               ChannelImpl chan,
                                               EventStationPair esp)

isESPTodo

public boolean isESPTodo()

isENPTodo

public boolean isENPTodo()

getNextENPFromCache

public EventNetworkPair getNextENPFromCache()
next successful event-network to process from cache. Returns null if no more events in cache.


getNextENP

public EventNetworkPair getNextENP()
next successful event-network to process. Returns null if no more events.


populateENPToDo

public void populateENPToDo()

getNextESPFromCache

public EventStationPair getNextESPFromCache()
next successful event-station to process from memory cache. Returns null if no more esp in memory.


getNextESP

public EventStationPair getNextESP()
next successful event-station to process. Returns null if no more events.


populateESPToDo

public void populateESPToDo()

getNextECP

public AbstractEventChannelPair getNextECP()
next successful event-channel to process. Returns null if no more events.


getNextRetryECPFromCache

public AbstractEventChannelPair getNextRetryECPFromCache()

isRetryTodo

public boolean isRetryTodo()

getRetryToDo

public java.util.List<AbstractEventChannelPair> getRetryToDo()

populateRetryToDo

public void populateRetryToDo()

getNumWorkUnits

public int getNumWorkUnits(Standing standing)

getNumEventNetworkWorkUnits

public int getNumEventNetworkWorkUnits(Standing standing)

getECP

public EventChannelPair getECP(CacheEvent event,
                               ChannelImpl chan)

put

public EventVectorPair put(EventVectorPair eventVectorPair)

getMinRetryDelay

public TimeInterval getMinRetryDelay()

getMaxRetries

public int getMaxRetries()

getNumSuccessful

public int getNumSuccessful()

getNumSuccessful

public int getNumSuccessful(CacheEvent event)

getNumSuccessful

public int getNumSuccessful(StationImpl station)

getNumSuccessful

public int getNumSuccessful(CacheEvent event,
                            StationImpl station)

getNumFailed

public int getNumFailed(StationImpl station)

getNumFailed

public int getNumFailed(CacheEvent event,
                        StationImpl station)

getNumFailed

public int getNumFailed(CacheEvent event)

getNumRetry

public int getNumRetry(StationImpl station)

getNumRetry

public int getNumRetry(CacheEvent event)

getNumRetry

public int getNumRetry(CacheEvent event,
                       StationImpl station)

getAll

public java.util.List<AbstractEventChannelPair> getAll(CacheEvent event)

getSuccessful

public java.util.List<AbstractEventChannelPair> getSuccessful(CacheEvent event)

getSuccessful

public java.util.List<AbstractEventChannelPair> getSuccessful(StationImpl station)

getSuccessful

public java.util.List<AbstractEventChannelPair> getSuccessful(CacheEvent event,
                                                              StationImpl station)

getFailed

public java.util.List<AbstractEventChannelPair> getFailed(StationImpl station)

getFailed

public java.util.List<AbstractEventChannelPair> getFailed(CacheEvent event,
                                                          StationImpl station)

getFailed

public java.util.List<AbstractEventChannelPair> getFailed(CacheEvent event)

getRetry

public java.util.List<AbstractEventChannelPair> getRetry(StationImpl station)

getRetry

public java.util.List<AbstractEventChannelPair> getRetry(CacheEvent event)

getRetry

public java.util.List<AbstractEventChannelPair> getRetry(CacheEvent event,
                                                         StationImpl station)

getStationsForEvent

public java.util.List<StationImpl> getStationsForEvent(CacheEvent event)

getSuccessfulStationsForEvent

public java.util.List<StationImpl> getSuccessfulStationsForEvent(CacheEvent event)

getUnsuccessfulStationsForEvent

public java.util.List<StationImpl> getUnsuccessfulStationsForEvent(CacheEvent event)

getEventsForStation

public java.util.List<CacheEvent> getEventsForStation(StationImpl sta)

getSuccessfulEventsForStation

public java.util.List<CacheEvent> getSuccessfulEventsForStation(StationImpl sta)

getUnsuccessfulEventsForStation

public java.util.List<CacheEvent> getUnsuccessfulEventsForStation(StationImpl sta)

put

public long put(RecordSectionItem item)

getRecordSectionItemForEvent

public RecordSectionItem getRecordSectionItemForEvent(CacheEvent event,
                                                      ChannelImpl channel)

getRecordSectionId

public java.util.List<java.lang.String> getRecordSectionId(CacheEvent event)
Finds the recordsectionids for this event


getRecordSectionOrientations

public java.util.List<java.lang.String> getRecordSectionOrientations(CacheEvent event)
Finds the recordsection orientationids for this event


getRecordSectionItem

public RecordSectionItem getRecordSectionItem(java.lang.String orientationId,
                                              java.lang.String recordSectionId,
                                              CacheEvent event,
                                              ChannelImpl channel)

getStationsForRecordSection

public java.util.List<StationImpl> getStationsForRecordSection(java.lang.String orientationId,
                                                               java.lang.String recordSectionId,
                                                               CacheEvent event,
                                                               boolean best)

getChannelsForRecordSection

public java.util.List<ChannelImpl> getChannelsForRecordSection(java.lang.String orientationId,
                                                               CacheEvent event,
                                                               boolean best)

getBestForRecordSection

public java.util.List<RecordSectionItem> getBestForRecordSection(java.lang.String orientationId,
                                                                 java.lang.String recordSectionId,
                                                                 CacheEvent event)

updateBestForRecordSection

public boolean updateBestForRecordSection(java.lang.String orientationId,
                                          java.lang.String recordSectionId,
                                          CacheEvent event,
                                          ChannelId[] channelIds)

getRecordSectionItemList

public java.util.List<RecordSectionItem> getRecordSectionItemList(java.lang.String orientationId,
                                                                  java.lang.String recordSectionId,
                                                                  CacheEvent event)

recordSectionsForEvent

public java.util.List<RecordSectionItem> recordSectionsForEvent(CacheEvent event)

putConfig

public int putConfig(SodConfig sodConfig)

getCurrentConfig

public SodConfig getCurrentConfig()

getConfig

public SodConfig getConfig(int configid)

getQueryTime

public QueryTime getQueryTime(java.lang.String serverName,
                              java.lang.String serverDNS)

putQueryTime

public int putQueryTime(QueryTime qtime)

getDBVersion

public Version getDBVersion()

putDBVersion

protected Version putDBVersion()

initHQLStmts

public void initHQLStmts()

discoverDbEcpClass

public static java.lang.Class<? extends AbstractEventChannelPair> discoverDbEcpClass()

setDefaultEcpClass

public static void setDefaultEcpClass(java.lang.Class<? extends AbstractEventChannelPair> ecpClass)

getEcpClass

public java.lang.Class<? extends AbstractEventChannelPair> getEcpClass()

getSingleton

public static SodDB getSingleton()