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 Details

    • hasTransaction

      public boolean hasTransaction()
      Specified by:
      hasTransaction in interface org.voltdb.importer.ImporterLifecycle
    • setPriority

      public final void setPriority(int priority)
    • getPriority

      public int getPriority()
      Specified by:
      getPriority in interface org.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 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)
    • 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()
      Specified by:
      isDebugEnabled in interface org.voltdb.importer.ImporterLogger
    • 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()
    • 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