com.sleepycat.persist.impl
Class Evolver

java.lang.Object
  extended by com.sleepycat.persist.impl.Evolver

 class Evolver
extends Object

Evolves each old format that is still relevant if necessary, using Mutations to configure deleters, renamers, and converters.

Author:
Mark Hayes

Field Summary
(package private) static int EVOLVE_FAILURE
           
(package private) static int EVOLVE_NEEDED
           
(package private) static int EVOLVE_NONE
           
 
Constructor Summary
Evolver(PersistCatalog catalog, String storePrefix, Mutations mutations, Map<String,Format> newFormats, boolean forceEvolution, boolean disallowClassChanges)
           
 
Method Summary
(package private)  void addEvolveError(Format oldFormat, Format newFormat, String scenario, String error)
          Adds a specified error when no specific mutation is involved.
(package private)  void addInvalidMutation(Format oldFormat, Format newFormat, Mutation mutation, String error)
          Adds an error for an invalid mutation.
(package private)  void addMissingMutation(Format oldFormat, Format newFormat, String error)
          Adds an error for a missing mutation.
(package private)  void addNonEntityFormat(Format oldFormat)
          Called by PersistCatalog for all non-entity formats.
(package private)  boolean areFormatsChanged()
          Returns whether any formats were changed during evolution, and therefore need to be stored in the catalog.
(package private)  boolean checkUpdatedVersion(String scenario, Format oldFormat, Format newFormat)
           
(package private)  void deleteSecondaryDatabase(String oldEntityClass, String keyName)
          Called by ComplexFormat when a secondary key is dropped.
(package private)  boolean evolveFormat(Format oldFormat)
          Called by PersistCatalog for all entity formats, and by Format.evolve methods for all potentially referenced non-entity formats.
(package private)  int evolveRequiredKeyField(Format oldParent, Format newParent, FieldInfo oldField, FieldInfo newField)
          Evolves a primary key field or composite key field.
(package private)  void finishEvolution()
          Called by PersistCatalog after calling evolveFormat or addNonEntityFormat for all old formats.
(package private)  String getErrors()
          Returns an error string if any mutations are invalid or missing, or returns null otherwise.
(package private)  Mutations getMutations()
           
(package private)  Set<Format> getSubclassFormats(Format superFormat)
          Returns the set of formats for a specific superclass format, or null if the superclass is not a complex type or has not subclasses.
(package private)  boolean isClassConverted(Format format)
           
(package private)  boolean isFormatChanged(Format format)
          Returns whether the given format was changed during evolution.
(package private)  void renameAndRemoveDatabases(Store store, Transaction txn)
           
(package private)  void renameSecondaryDatabase(String oldEntityClass, String newEntityClass, String oldKeyName, String newKeyName)
          Called by ComplexFormat when a secondary key name is changed.
(package private)  void useEvolvedFormat(Format oldFormat, Reader evolveReader, Format newFormat)
          Install an evolver Reader in the old format.
(package private)  void useOldFormat(Format oldFormat, Format newFormat)
          Use the old format and discard the new format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EVOLVE_NONE

static final int EVOLVE_NONE
See Also:
Constant Field Values

EVOLVE_NEEDED

static final int EVOLVE_NEEDED
See Also:
Constant Field Values

EVOLVE_FAILURE

static final int EVOLVE_FAILURE
See Also:
Constant Field Values
Constructor Detail

Evolver

Evolver(PersistCatalog catalog,
        String storePrefix,
        Mutations mutations,
        Map<String,Format> newFormats,
        boolean forceEvolution,
        boolean disallowClassChanges)
Method Detail

getMutations

final Mutations getMutations()

areFormatsChanged

boolean areFormatsChanged()
Returns whether any formats were changed during evolution, and therefore need to be stored in the catalog.


isFormatChanged

boolean isFormatChanged(Format format)
Returns whether the given format was changed during evolution.


getSubclassFormats

Set<Format> getSubclassFormats(Format superFormat)
Returns the set of formats for a specific superclass format, or null if the superclass is not a complex type or has not subclasses.


getErrors

String getErrors()
Returns an error string if any mutations are invalid or missing, or returns null otherwise. If non-null is returned, the store may not be opened.


addEvolveError

void addEvolveError(Format oldFormat,
                    Format newFormat,
                    String scenario,
                    String error)
Adds a specified error when no specific mutation is involved.


addInvalidMutation

void addInvalidMutation(Format oldFormat,
                        Format newFormat,
                        Mutation mutation,
                        String error)
Adds an error for an invalid mutation.


addMissingMutation

void addMissingMutation(Format oldFormat,
                        Format newFormat,
                        String error)
Adds an error for a missing mutation.


addNonEntityFormat

void addNonEntityFormat(Format oldFormat)
Called by PersistCatalog for all non-entity formats.


finishEvolution

void finishEvolution()
Called by PersistCatalog after calling evolveFormat or addNonEntityFormat for all old formats. We do not require deletion of an unreferenced class for two reasons: 1) built-in proxy classes may not be referenced, 2) the user may wish to declare persistent classes that are not yet used.


evolveFormat

boolean evolveFormat(Format oldFormat)
Called by PersistCatalog for all entity formats, and by Format.evolve methods for all potentially referenced non-entity formats.


useOldFormat

void useOldFormat(Format oldFormat,
                  Format newFormat)
Use the old format and discard the new format. Called by Format.evolve when the old and new formats are identical.


useEvolvedFormat

void useEvolvedFormat(Format oldFormat,
                      Reader evolveReader,
                      Format newFormat)
Install an evolver Reader in the old format. Called by Format.evolve when the old and new formats are not identical.


renameSecondaryDatabase

void renameSecondaryDatabase(String oldEntityClass,
                             String newEntityClass,
                             String oldKeyName,
                             String newKeyName)
Called by ComplexFormat when a secondary key name is changed.


deleteSecondaryDatabase

void deleteSecondaryDatabase(String oldEntityClass,
                             String keyName)
Called by ComplexFormat when a secondary key is dropped.


isClassConverted

boolean isClassConverted(Format format)

checkUpdatedVersion

boolean checkUpdatedVersion(String scenario,
                            Format oldFormat,
                            Format newFormat)

renameAndRemoveDatabases

void renameAndRemoveDatabases(Store store,
                              Transaction txn)
                        throws DatabaseException
Throws:
DatabaseException

evolveRequiredKeyField

int evolveRequiredKeyField(Format oldParent,
                           Format newParent,
                           FieldInfo oldField,
                           FieldInfo newField)
Evolves a primary key field or composite key field.



Copyright (c) 2004-2010 Oracle. All rights reserved.