org.apache.derby.impl.store.raw.data
Class EncryptContainerOperation

java.lang.Object
  extended by org.apache.derby.impl.store.raw.data.EncryptContainerOperation
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, Formatable, TypedFormat, Loggable, Undoable

public class EncryptContainerOperation
extends java.lang.Object
implements Undoable

Log operation to encrypt a container with a new encryption key or to encrypt an unencrypted container while configuring the database for encryption. Container is synced to the disk when encryption is is successful, there is nothing to do on a redo. If there is crash/error while configuring a database for encryption; original version of the container is put back during undo.

See Also:
Undoable, Serialized Form
Format IDLOGOP_ENCRYPT_CONTAINER the formatId is written by FormatIdOutputStream when this object is written out by writeObject
Purposeto record enctyption of container with a new encryption key.
Upgrade
Disk LayoutcontainerId(ContainerKey) the id of the container this operation applies to

Field Summary
private  ContainerKey containerId
           
 
Fields inherited from interface org.apache.derby.iapi.store.raw.Loggable
ABORT, BI_LOG, CHECKSUM, COMMIT, COMPENSATION, FILE_RESOURCE, FIRST, LAST, PREPARE, RAWSTORE, XA_NEEDLOCK
 
Constructor Summary
  EncryptContainerOperation()
           
protected EncryptContainerOperation(RawContainerHandle hdl)
           
 
Method Summary
 void doMe(Transaction tran, LogInstant instant, LimitObjectInput in)
          Containers are not encryped on a redo.
 Compensation generateUndo(Transaction tran, LimitObjectInput in)
          Generate a Compensation (EncryptContainerUndoOperation) that will rollback the changes made to the container during container encryption.
 ByteArray getPreparedLog()
          the default for prepared log is always null for all the operations that don't have optionalData.
 int getTypeFormatId()
          Return my format identifier.
 int group()
          A space operation is a RAWSTORE log record
 boolean needsRedo(Transaction xact)
          Check if this operation needs to be redone during recovery redo.
 void readExternal(java.io.ObjectInput in)
           
 void releaseResource(Transaction tran)
          Release any resource that was acquired for doMe for rollback or recovery redo.
 java.lang.String toString()
          debug
 void undoMe(Transaction tran)
          Undo of encrytpion of the container.
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

containerId

private ContainerKey containerId
Constructor Detail

EncryptContainerOperation

protected EncryptContainerOperation(RawContainerHandle hdl)
                             throws StandardException
Throws:
StandardException

EncryptContainerOperation

public EncryptContainerOperation()
Method Detail

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException
java.lang.ClassNotFoundException

getPreparedLog

public ByteArray getPreparedLog()
the default for prepared log is always null for all the operations that don't have optionalData. If an operation has optional data, the operation need to prepare the optional data for this method. Encrypt Operation has no optional data to write out

Specified by:
getPreparedLog in interface Loggable

releaseResource

public void releaseResource(Transaction tran)
Description copied from interface: Loggable
Release any resource that was acquired for doMe for rollback or recovery redo. This resource is acquired in either generateUndo (if this is a compensation operation during run time rollback or recovery rollback) or in needsRedo (if this is during recovery redo). The run time transaction context should have all the resource already acquird for run time roll forward, so there is no need to releaseResource during run time roll forward. This method must be safe to be called multiple times.

Specified by:
releaseResource in interface Loggable

group

public int group()
A space operation is a RAWSTORE log record

Specified by:
group in interface Loggable

needsRedo

public boolean needsRedo(Transaction xact)
                  throws StandardException
Check if this operation needs to be redone during recovery redo. Returns true if this op should be redone during recovery redo,

Specified by:
needsRedo in interface Loggable
Parameters:
xact - the transaction that is doing the rollback
Returns:
true, if this operation needs to be redone during recovery.
Throws:
StandardException - Standard Derby error policy
See Also:
Loggable.releaseResource(org.apache.derby.iapi.store.raw.Transaction)

getTypeFormatId

public int getTypeFormatId()
Return my format identifier.

Specified by:
getTypeFormatId in interface TypedFormat
Returns:
The identifier. (A UUID stuffed in an array of 16 bytes).

doMe

public final void doMe(Transaction tran,
                       LogInstant instant,
                       LimitObjectInput in)
                throws StandardException
Containers are not encryped on a redo. Nothing to do in this method.

Specified by:
doMe in interface Loggable
Parameters:
tran - transaction doing the operation.
instant - log instant for this operation.
in - unused by this log operation.
Throws:
StandardException - Standard Derby error policy

undoMe

public void undoMe(Transaction tran)
            throws StandardException
Undo of encrytpion of the container. Original version of the container that existed before the start of the database encryption is put back.

Parameters:
tran - the transaction that is undoing this operation
Throws:
StandardException - Standard Derby error policy

generateUndo

public Compensation generateUndo(Transaction tran,
                                 LimitObjectInput in)
                          throws StandardException
Generate a Compensation (EncryptContainerUndoOperation) that will rollback the changes made to the container during container encryption.

Specified by:
generateUndo in interface Undoable
Parameters:
tran - the transaction doing the compensating
in - optional input; not used by this operation.
Returns:
the compensation operation that will rollback this change, or null if nothing to undo.
Throws:
StandardException - Standard Derby error policy
See Also:
Loggable.releaseResource(org.apache.derby.iapi.store.raw.Transaction), Loggable.needsRedo(org.apache.derby.iapi.store.raw.Transaction)

toString

public java.lang.String toString()
debug

Overrides:
toString in class java.lang.Object

Built on Thu 2012-03-29 21:53:33+0000, from revision ???

Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.