Package org.jesterj.ingest.scanners
Class JdbcScanner
- java.lang.Object
-
- org.jesterj.ingest.model.impl.StepImpl
-
- org.jesterj.ingest.model.impl.ScannerImpl
-
- org.jesterj.ingest.scanners.JdbcScanner
-
- All Implemented Interfaces:
java.lang.Iterable<Document>,java.lang.Runnable,java.util.Collection<Document>,java.util.concurrent.BlockingQueue<Document>,java.util.Queue<Document>,Active,Configurable,DeferredBuilding,Scanner,Step
public class JdbcScanner extends ScannerImpl
Scans a JDBC source such as an RDBMS (e.g. MySQL). Obtains a connection through the specified JDBC driver and extracts rows using the specified SQL statement; converts extracted rows to documents and passes the documents downstream.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classJdbcScanner.BuilderHandles configuration parameters for the JDBC scanner.-
Nested classes/interfaces inherited from class org.jesterj.ingest.model.impl.ScannerImpl
ScannerImpl.ScanOp
-
-
Field Summary
-
Fields inherited from class org.jesterj.ingest.model.impl.ScannerImpl
activeScans, CREATE_DOC_HASH, CREATE_FT_KEYSPACE, CREATE_FT_TABLE, CREATE_INDEX_STATUS, DDL_TIMEOUT, DEF_MAX_ERROR_RETRY, FTI_ORIGIN, NEW_CONTENT_FOUND_MSG, SCAN_ORIGIN, TIMEOUT
-
Fields inherited from interface org.jesterj.ingest.model.Configurable
VALID_NAME
-
Fields inherited from interface org.jesterj.ingest.model.Step
JJ_PLAN_NAME, JJ_PLAN_VERSION
-
-
Constructor Summary
Constructors Constructor Description JdbcScanner()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactivate()Begin processing.voiddeactivate()Stop processing.java.util.Optional<Document>fetchById(java.lang.String id, java.lang.String origination)Load a document based on the document's id.java.lang.StringgetContentColumn()protected java.lang.StringgetDatabasePkColumnName()The name of the column containing the database primary key.intgetFetchSize()java.lang.StringgetJdbcDriver()java.lang.StringgetJdbcPassword()java.lang.StringgetJdbcUrl()java.lang.StringgetJdbcUser()intgetQueryTimeout()ScannerImpl.ScanOpgetScanOperation()The default scan operation is to check the cassandra database for records marked dirty or restart and process those records using the scanner's document fetching logic (empty by default)java.lang.StringgetSqlStatement()booleanisAutoCommit()booleanisScanning()True if a new scan may be started.-
Methods inherited from class org.jesterj.ingest.model.impl.ScannerImpl
add, addAll, addPredecessor, clear, contains, containsAll, docFound, drainTo, drainTo, element, getCassandra, getInterval, getLogger, isActivePriorSteps, isEmpty, isHashing, isHeuristicallyDirty, isRemembering, isScanActive, iterator, keySpace, offer, offer, peek, poll, poll, processDirty, processPendingDocs, put, remainingCapacity, remove, remove, removeAll, retainAll, run, scanFinished, scanStarted, sendToNext, setCassandra, setInterval, take, toArray, toArray
-
Methods inherited from class org.jesterj.ingest.model.impl.StepImpl
addDeferred, executeDeferred, forEach, getBatchSize, getDownstreamOutputSteps, getEligibleNextSteps, getName, getNextSteps, getNextSteps, getOutputDestinationNames, getPatternForStep, getPlan, getPriorSteps, getProcessor, getRouter, isActive, isOutputStep, parallelStream, removeIf, reportException, size, spliterator, stream, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, size, spliterator, stream, toArray
-
Methods inherited from interface org.jesterj.ingest.model.Configurable
getName, isValidName
-
Methods inherited from interface org.jesterj.ingest.model.DeferredBuilding
addDeferred, executeDeferred
-
Methods inherited from interface org.jesterj.ingest.model.Scanner
getDocumentTracker, getIdFunction
-
Methods inherited from interface org.jesterj.ingest.model.Step
getBatchSize, getDownstreamOutputSteps, getEligibleNextSteps, getNextSteps, getNextSteps, getOutputDestinationNames, getPlan, getPriorSteps, getRouter, isOutputDestinationThisStep, isOutputStep
-
-
-
-
Method Detail
-
activate
public void activate()
Description copied from interface:ActiveBegin processing. This is the on switch.- Specified by:
activatein interfaceActive- Overrides:
activatein classScannerImpl
-
deactivate
public void deactivate()
Description copied from interface:ActiveStop processing. This is the stop switch.- Specified by:
deactivatein interfaceActive- Overrides:
deactivatein classScannerImpl
-
getScanOperation
public ScannerImpl.ScanOp getScanOperation()
Description copied from class:ScannerImplThe default scan operation is to check the cassandra database for records marked dirty or restart and process those records using the scanner's document fetching logic (empty by default)- Specified by:
getScanOperationin interfaceScanner- Specified by:
getScanOperationin classScannerImpl- Returns:
- a
Runnableobject that locates documents.
-
getDatabasePkColumnName
protected java.lang.String getDatabasePkColumnName()
The name of the column containing the database primary key.- Returns:
- the configured pk column name or the docIdField name for the plan by default (which is 'id' by default).
-
isScanning
public boolean isScanning()
Description copied from interface:ScannerTrue if a new scan may be started. Implementations may choose not to start a new scan until the old one has completed. This value is independent ofActive.isActive().- Returns:
- true if a new scan should be started
-
fetchById
public java.util.Optional<Document> fetchById(java.lang.String id, java.lang.String origination)
Description copied from interface:ScannerLoad a document based on the document's id.- Parameters:
id- the id of the document, see alsoDocument.getId()origination- A constant indicating the source (scanner or fti) for debugging- Returns:
- An optional that contains the document if it is possible to retrieve the document by ID
-
getJdbcDriver
public java.lang.String getJdbcDriver()
-
getJdbcUrl
public java.lang.String getJdbcUrl()
-
getJdbcUser
public java.lang.String getJdbcUser()
-
getJdbcPassword
public java.lang.String getJdbcPassword()
-
getSqlStatement
public java.lang.String getSqlStatement()
-
getFetchSize
public int getFetchSize()
-
isAutoCommit
public boolean isAutoCommit()
-
getQueryTimeout
public int getQueryTimeout()
-
getContentColumn
public java.lang.String getContentColumn()
-
-