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 Type
    Method
    Description
    boolean
    callProcedure(org.voltdb.importer.Invocation invocation, org.voltdb.client.ProcedureCallback callback)
    This should be used importer implementations to execute a stored procedure.
    void
    debug(Throwable t, String msgFormat, Object... args)
    Log a DEBUG level log message.
    void
    error(Throwable t, String msgFormat, Object... args)
    Log a ERROR level log message.
    int
    Returns the execution priority for this importer.
    abstract URI
    Returns the resource id for which this importer was started.
    Returns the name of the thread on which this importer is currently executing.
    boolean
    Returns whether the importer has a transaction ready to process.
    void
    info(Throwable t, String msgFormat, Object... args)
    Log a INFO level log message.
    boolean
    Tests whether logging is enabled at the debug level.
    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
    Called when the importer is initialized, to update statistics records used by VMC.
    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)
    Sets the execution priority for this importer.
    final boolean
    This method indicates if the importer has been stopped or if it should continue running.
    abstract void
    This is called by the importer framework to stop the importer.
    void
    Called to stop the importer from processing more data.
    void
    warn(Throwable t, String msgFormat, Object... args)
    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()
      Returns whether the importer has a transaction ready to process. The base implementation always returns true.
      Specified by:
      hasTransaction in interface org.voltdb.importer.ImporterLifecycle
      Returns:
      true if transaction ready, otherwise false.
    • setPriority

      public final void setPriority(int priority)
      Sets the execution priority for this importer.
      Parameters:
      priority - the priority
    • getPriority

      public int getPriority()
      Returns the execution priority for this importer.
      Specified by:
      getPriority in interface org.voltdb.InternalConnectionContext
      Returns:
      priority
    • 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 interface org.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 information
      callback - 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

      public void reportInitializedStat(String procName)
      Called when the importer is initialized, to update statistics records used by VMC.
      Parameters:
      procName - name of importer procedure
    • 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 interface org.voltdb.importer.ImporterLogger
      Parameters:
      level - the log level
      cause - cause exception, if there is one
      format - error message format
      args - arguments to format the error message
    • isDebugEnabled

      public boolean isDebugEnabled()
      Tests whether logging is enabled at the debug level. Useful before issuing a debug logging call, to avoid formatting a message that will not be logged.
      Specified by:
      isDebugEnabled in interface org.voltdb.importer.ImporterLogger
      Returns:
      true if debug logging enabled, otherwise false
    • debug

      public void debug(Throwable t, String msgFormat, Object... args)
      Log a DEBUG level log message.
      Specified by:
      debug in interface org.voltdb.importer.ImporterLogger
      Parameters:
      msgFormat - Format
      t - Throwable to log
    • error

      public void error(Throwable t, String msgFormat, Object... args)
      Log a ERROR level log message.
      Specified by:
      error in interface org.voltdb.importer.ImporterLogger
      Parameters:
      msgFormat - Format
      t - Throwable to log
    • info

      public void info(Throwable t, String msgFormat, Object... args)
      Log a INFO level log message.
      Specified by:
      info in interface org.voltdb.importer.ImporterLogger
      Parameters:
      msgFormat - Format
      t - Throwable to log
    • warn

      public void warn(Throwable t, String msgFormat, Object... args)
      Log a WARN level log message.
      Specified by:
      warn in interface org.voltdb.importer.ImporterLogger
      Parameters:
      msgFormat - Format
      t - Throwable to log
    • getResourceID

      public abstract URI 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

      public String getTaskThreadName()
      Returns the name of the thread on which this importer is currently executing.
      Returns:
      thread name or null
    • 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 interface org.voltdb.importer.ImporterLifecycle