Package org.voltdb.importer
Class AbstractImporter
java.lang.Object
org.voltdb.importer.AbstractImporter
- All Implemented Interfaces:
org.voltdb.importer.ImporterLifecycle
,org.voltdb.importer.ImporterLogger
,org.voltdb.InternalConnectionContext
public abstract class AbstractImporter
extends Object
implements org.voltdb.InternalConnectionContext, org.voltdb.importer.ImporterLifecycle, org.voltdb.importer.ImporterLogger
Abstract class that must be extended to create custom importers in VoltDB server.
The sequence of calls when the importer is started up is:
- Find the importer factory in the OSGi bundle as a service
- Validate and setup configuration using factory.createImporterConfigurations
- Create an importer instance using factory.createImporter for every resource that must be run on this server
- Start the importers by calling accept. Each of this will be called in its own thread.
Importers should do their work in the implementation of accept.
Importer implementations should do their work in a
while (shouldRun())
loop, which will make sure that that the importer will stop its work when the framework calls stop.
The framework stops the importer by calling stopImporter
, which will stop the executor service and
call stop
on the importer instance to close resources used by the specific importer.
stop(resourceID)
will also be called on the importer instances when the resources are redistributed
because of addition/deletion of nodes to the cluster.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
callProcedure
(org.voltdb.importer.Invocation invocation, org.voltdb.client.ProcedureCallback callback) This should be used importer implementations to execute a stored procedure.void
Log a DEBUG level log message.void
Log a ERROR level log message.int
abstract URI
Returns the resource id for which this importer was started.boolean
void
Log a INFO level log message.boolean
void
rateLimitedLog
(org.voltcore.logging.Level level, Throwable cause, String format, Object... args) This rate limited log must be used by the importers to log messages that may happen frequently and must be rate limited.void
reportInitializedStat
(String procName) final void
setImportServerAdapter
(org.voltdb.importer.ImporterServerAdapter adapter) Passes in the server adapter that may be used by this importer to access the server, like calling a procedure.final void
setPriority
(int priority) final boolean
This method indicates if the importer has been stopped or if it should continue running.abstract void
stop()
This is called by the importer framework to stop the importer.void
Called to stop the importer from processing more data.void
Log a WARN level log message.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.voltdb.InternalConnectionContext
getName
-
Method Details
-
hasTransaction
public boolean hasTransaction()- Specified by:
hasTransaction
in interfaceorg.voltdb.importer.ImporterLifecycle
-
setPriority
public final void setPriority(int priority) -
getPriority
public int getPriority()- Specified by:
getPriority
in interfaceorg.voltdb.InternalConnectionContext
-
setImportServerAdapter
public final void setImportServerAdapter(org.voltdb.importer.ImporterServerAdapter adapter) Passes in the server adapter that may be used by this importer to access the server, like calling a procedure.- Parameters:
adapter
- the server adapter that may be used by this to access the server.
-
shouldRun
public final boolean shouldRun()This method indicates if the importer has been stopped or if it should continue running. This should be checked by importer implementations regularly to determine if the importer should continue its execution.- Specified by:
shouldRun
in interfaceorg.voltdb.importer.ImporterLifecycle
- Returns:
- returns true if the importer execution should continue; false otherwise
-
callProcedure
public boolean callProcedure(org.voltdb.importer.Invocation invocation, org.voltdb.client.ProcedureCallback callback) This should be used importer implementations to execute a stored procedure.- Parameters:
invocation
- Invocation object with procedure name and parameter informationcallback
- the callback that will receive procedure invocation status- Returns:
- returns true if the procedure execution went through successfully; false otherwise
-
stopImporter
public void stopImporter()Called to stop the importer from processing more data. -
reportInitializedStat
-
rateLimitedLog
public void rateLimitedLog(org.voltcore.logging.Level level, Throwable cause, String format, Object... args) This rate limited log must be used by the importers to log messages that may happen frequently and must be rate limited.- Specified by:
rateLimitedLog
in interfaceorg.voltdb.importer.ImporterLogger
- Parameters:
level
- the log levelcause
- cause exception, if there is oneformat
- error message formatargs
- arguments to format the error message
-
isDebugEnabled
public boolean isDebugEnabled()- Specified by:
isDebugEnabled
in interfaceorg.voltdb.importer.ImporterLogger
-
debug
Log a DEBUG level log message.- Specified by:
debug
in interfaceorg.voltdb.importer.ImporterLogger
- Parameters:
msgFormat
- Formatt
- Throwable to log
-
error
Log a ERROR level log message.- Specified by:
error
in interfaceorg.voltdb.importer.ImporterLogger
- Parameters:
msgFormat
- Formatt
- Throwable to log
-
info
Log a INFO level log message.- Specified by:
info
in interfaceorg.voltdb.importer.ImporterLogger
- Parameters:
msgFormat
- Formatt
- Throwable to log
-
warn
Log a WARN level log message.- Specified by:
warn
in interfaceorg.voltdb.importer.ImporterLogger
- Parameters:
msgFormat
- Formatt
- Throwable to log
-
getResourceID
Returns the resource id for which this importer was started. There will be unique resource id per importer for each importer type.- Returns:
- the unique resource id that is used by this importer
-
getTaskThreadName
-
stop
public abstract void stop()This is called by the importer framework to stop the importer. Any importer specific resources should be closed and released here.- Specified by:
stop
in interfaceorg.voltdb.importer.ImporterLifecycle
-