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 TypeMethodDescriptionbooleancallProcedure(org.voltdb.importer.Invocation invocation, org.voltdb.client.ProcedureCallback callback) This should be used importer implementations to execute a stored procedure.voidLog a DEBUG level log message.voidLog a ERROR level log message.intabstract URIReturns the resource id for which this importer was started.booleanvoidLog a INFO level log message.booleanvoidrateLimitedLog(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.voidreportInitializedStat(String procName) final voidsetImportServerAdapter(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 voidsetPriority(int priority) final booleanThis method indicates if the importer has been stopped or if it should continue running.abstract voidstop()This is called by the importer framework to stop the importer.voidCalled to stop the importer from processing more data.voidLog a WARN level log message.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.voltdb.InternalConnectionContext
getName
-
Method Details
-
hasTransaction
public boolean hasTransaction()- Specified by:
hasTransactionin interfaceorg.voltdb.importer.ImporterLifecycle
-
setPriority
public final void setPriority(int priority) -
getPriority
public int getPriority()- Specified by:
getPriorityin 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:
shouldRunin 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:
rateLimitedLogin 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:
isDebugEnabledin interfaceorg.voltdb.importer.ImporterLogger
-
debug
Log a DEBUG level log message.- Specified by:
debugin interfaceorg.voltdb.importer.ImporterLogger- Parameters:
msgFormat- Formatt- Throwable to log
-
error
Log a ERROR level log message.- Specified by:
errorin interfaceorg.voltdb.importer.ImporterLogger- Parameters:
msgFormat- Formatt- Throwable to log
-
info
Log a INFO level log message.- Specified by:
infoin interfaceorg.voltdb.importer.ImporterLogger- Parameters:
msgFormat- Formatt- Throwable to log
-
warn
Log a WARN level log message.- Specified by:
warnin 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:
stopin interfaceorg.voltdb.importer.ImporterLifecycle
-