com.tivoli.twg.engine
Class TWGDistConfigRecordDef

java.lang.Object
  extended bycom.tivoli.twg.engine.TWGObject
      extended bycom.tivoli.twg.engine.TWGPersistentObject
          extended bycom.tivoli.twg.engine.TWGDistConfigRecordDef

public class TWGDistConfigRecordDef
extends TWGPersistentObject

Definition object for an application-specific configuration record. This persistent object defines the meta-data for a type of configuration record which will be stored, distributed, and managed by the TWGDistConfigManager. Each definition is required to provide a unchanging, unique ID token. Additional data determines which TWGManagedObject classes are supported, as well as whether the records should be replicated to the agents.

Applications may opt to subclass the TWGDistConfigRecordDef class in order to provide a handler for the handleUnsupportedDistConfigAgent() method, which is invoked when an instance of the configuration record needs to be sent to a managed object which does not support the distributed configuration agent extensions (i.e. ITD V1.x agents). Note: the superclass version of the method must still be called.


Field Summary
static int FLAGS_AGENT_OWNED_RECORDS
          Capability flag : agent-owned record (as opposed to server-owned)
static int FLAGS_GROUP_RECORDS_ALLOWED
          Capability flag : group records allowed
static int FLAGS_PUBLIC_UPDATE_ALLOWED
          Capability flag : permit update by non-owning applications
static int FLAGS_REFLECT_DATA_TO_AGENTS
          Capability flag : reflect records to agent
 
Fields inherited from class com.tivoli.twg.engine.TWGPersistentObject
CLASS_NAME, SIZEOF_BYTE, SIZEOF_CHAR, SIZEOF_DOUBLE, SIZEOF_FLOAT, SIZEOF_INT, SIZEOF_LONG, SIZEOF_SHORT
 
Constructor Summary
TWGDistConfigRecordDef()
          Default constructor : used by restoreData(): must be provided by any subclasses of TWGDistConfigRecordDef
TWGDistConfigRecordDef(java.lang.String id, java.lang.String[] mo_classes, boolean copy_to_agents, boolean public_record, boolean group_records_allowed, java.lang.String store_fname)
          Creation constructor : used to create new distributed configuration record definition.
TWGDistConfigRecordDef(java.lang.String id, java.lang.String[] mo_classes, boolean copy_to_agents, boolean public_record, boolean group_records_allowed, java.lang.String store_fname, boolean agent_owned_records)
          Creation constructor : used to create new distributed configuration record definition.
 
Method Summary
 void closeBagFile()
          Close bagfile
 void Delete()
          Destroy method : use to destroy record type and data
static void deleteAllRecordsForObject(long obj_id)
          Delete all records associated with given object ID
 void deregisterChangeListener(TWGDistConfigRecordChangeListener list)
          Deregister listener for record updates and deletes
 void Destroy()
          Delete method : use to remove object from list
 void distConfigAgentRecordDeleted(TWGManagedObject mo, long obj_id)
          Callback for reporting delete of specific record on specific managed object.
 void distConfigAgentRecordUpdated(TWGManagedObject mo, long obj_id)
          Callback for reporting add/update of specific record on specific managed object.
static void enqueueAgentRecordSynchronize(TWGManagedObject mo)
          Enqueue synchronize for given agent
static void enqueueGroupRecordSynchronize(TWGFilter flt)
          Enqueue synchronize for all members of given group
static void enqueueUnsupportedAgentRecordSynchronize(TWGManagedObject mo)
          Enqueue unsupported agent synchronize for given agent
static TWGDistConfigRecordDef findByIDString(java.lang.String id)
          Find record definition instance by ID string
static TWGDistConfigRecordHashcode[] getAllHashcodesForObject(long obj_id)
          Get all hashcodes for all records for given managed object (including groups containing managed object).
static TWGDistConfigRecordHashcode[] getAllHashcodesForObject(long obj_id, boolean only_agt_sync)
          Get all hashcodes for all records for given managed object (including groups containing managed object).
static TWGDistConfigRecord[] getAllRecordsForObject(long obj_id)
          Get all records for given managed object (including groups containing managed object).
static TWGDistConfigRecord[] getAllRecordsForObject(long obj_id, boolean only_agt_sync)
          Get all records for given managed object (including groups containing managed object).
static byte[] getCompositeHashcodeForObject(long obj_id)
          Get composite hashcode for all records for given managed object (including groups containing managed object).
static byte[] getCompositeHashcodeForObject(long obj_id, boolean only_agt_recs)
          Get composite hashcode for all records for given managed object (including groups containing managed object).
 TWGDistConfigRecordHashcode[] getHashcodesForObject(long obj_id)
          Get all hashcodes for given managed object (including groups containing managed object).
 java.lang.String getIDString()
          Get ID string
 java.lang.String getName()
          Get name (default locale)
 java.lang.String getName(java.util.Locale loc)
          Get name (given locale)
static byte[] getRecordDataForHashcodeRecord(TWGDistConfigRecordHashcode hcr)
          Read data record for given hashcode record
 TWGDistConfigRecord getRecordForObject(long obj_id)
          Get record for given object ID
 TWGDistConfigRecordHashcode getRecordHashcodeForObject(long obj_id)
          Get hashcode for record for given object.
 TWGDistConfigRecord[] getRecordsForObject(long obj_id)
          Get all records for given managed object (including groups containing managed object).
 java.io.File getRecordStorageFile()
          Get file object for our attribute storage
 void handleUnsupportedDistConfigAgent(TWGManagedObject mo, TWGDistConfigRecordHashcode[] recs, DistConfigAgentResult result_listener)
          Handler for attempts to copy records to a managed object instance which doesn't support configuration distribution (i.e.
 boolean isAgentOwned()
          Test to see if record type is agent-owned (agent version is 'master')
 boolean isAgentSyncRecord()
          Test to see if record type is synchronized with agent copy
 boolean isGroupRecordAllowed()
          Test to see if group records allowed by record type
 BagFile openBagFile()
          Open bagfile for use
 void registerChangeListener(TWGDistConfigRecordChangeListener list)
          Register listener for record updates and deletes
protected  void restoreData(TWGPersistentObjectDictionary dict, boolean do_references)
          Restore method for persistent object
protected  void saveData(TWGPersistentObjectDictionary dict)
          Save method for saving persistent state
 void setName(java.lang.String n)
          Set name of record definition
 void setName(java.lang.String nameid, java.lang.String namerb)
          Set name of record definition using resouce bundle name and ID
 void SetObjectID(long oid)
          Set object ID.
static void setRecord(TWGDistConfigRecord rec)
          Add/replace record
 void setRecordForObjects(long[] obj_ids, byte[] rec)
          Add/replace record for given object IDs
 
Methods inherited from class com.tivoli.twg.engine.TWGPersistentObject
enableAsyncWrites, fromPersistID, initialize, isNewPersistentStore, isSaveRequired, PersistID, restore, restoreAll, save, save, setSaveRequired, terminate, toPersistID
 
Methods inherited from class com.tivoli.twg.engine.TWGObject
AllObjects, AllObjects, DumpTWGObjects, FindObject, isDeleted, isNewObject, isPersistent, isPersistent, isValid, isValid, ObjectID, setDistinctObjectID
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FLAGS_REFLECT_DATA_TO_AGENTS

public static final int FLAGS_REFLECT_DATA_TO_AGENTS
Capability flag : reflect records to agent

See Also:
Constant Field Values

FLAGS_PUBLIC_UPDATE_ALLOWED

public static final int FLAGS_PUBLIC_UPDATE_ALLOWED
Capability flag : permit update by non-owning applications

See Also:
Constant Field Values

FLAGS_GROUP_RECORDS_ALLOWED

public static final int FLAGS_GROUP_RECORDS_ALLOWED
Capability flag : group records allowed

See Also:
Constant Field Values

FLAGS_AGENT_OWNED_RECORDS

public static final int FLAGS_AGENT_OWNED_RECORDS
Capability flag : agent-owned record (as opposed to server-owned)

See Also:
Constant Field Values
Constructor Detail

TWGDistConfigRecordDef

public TWGDistConfigRecordDef()
Default constructor : used by restoreData(): must be provided by any subclasses of TWGDistConfigRecordDef


TWGDistConfigRecordDef

public TWGDistConfigRecordDef(java.lang.String id,
                              java.lang.String[] mo_classes,
                              boolean copy_to_agents,
                              boolean public_record,
                              boolean group_records_allowed,
                              java.lang.String store_fname,
                              boolean agent_owned_records)
                       throws TWGPersistentObjectSaveException,
                              DuplicateObjectIDException
Creation constructor : used to create new distributed configuration record definition.

Parameters:
id - - unique ID for record definition
mo_classes - - list of managed object classes supported (null=all)
copy_to_agents - - true if record should be replicated to agents, false if only stored on server
public_record - - true if record is "public" and can be copied or deleted by other applications, false if "private" to defining application
group_records_allowed - - true if records can be tied to groups(TWGFilters), false if only supports managed objects individually
store_fname - - filename for attribute storage on server : relative to TWGEnvironment.getDataDirectory(). null="id.dcf"
agent_owned_records - - indicates that agent version of records is "master" ( if mismatch occurs, agent version is used to update server). If false, server version is "master" and is applied to agent. group_records_allowed must be 'false' and copy_to_agents must be 'true' if agent_owned_records is 'true'.
Throws:
TWGPersistentObjectSaveException - if error creating object
DuplicateObjectIDException - if duplicate record ID

TWGDistConfigRecordDef

public TWGDistConfigRecordDef(java.lang.String id,
                              java.lang.String[] mo_classes,
                              boolean copy_to_agents,
                              boolean public_record,
                              boolean group_records_allowed,
                              java.lang.String store_fname)
                       throws TWGPersistentObjectSaveException,
                              DuplicateObjectIDException
Creation constructor : used to create new distributed configuration record definition. Creates server-owned records.

Parameters:
id - - unique ID for record definition
mo_classes - - list of managed object classes supported (null=all)
copy_to_agents - - true if record should be replicated to agents, false if only stored on server
public_record - - true if record is "public" and can be copied or deleted by other applications, false if "private" to defining application
group_records_allowed - - true if records can be tied to groups(TWGFilters), false if only supports managed objects individually
store_fname - - filename for attribute storage on server : relative to TWGEnvironment.getDataDirectory(). null="id.dcf"
Throws:
TWGPersistentObjectSaveException - if error creating object
DuplicateObjectIDException - if duplicate record ID
Method Detail

SetObjectID

public void SetObjectID(long oid)
                 throws DuplicateObjectIDException
Set object ID. This method subclasses the TWGObject class's SetObjectID.

Overrides:
SetObjectID in class TWGObject
Parameters:
oid - - new object ID, or INVALID_OBJECT_ID if none
Throws:
DuplicateObjectIDException - if ID is duplicate

Destroy

public void Destroy()
             throws TWGObjectDestroyException
Delete method : use to remove object from list

Overrides:
Destroy in class TWGPersistentObject
Throws:
TWGObjectDestroyException - if error during destroy

Delete

public void Delete()
Destroy method : use to destroy record type and data

Overrides:
Delete in class TWGObject

saveData

protected void saveData(TWGPersistentObjectDictionary dict)
                 throws TWGPersistentObjectSaveException
Save method for saving persistent state

Overrides:
saveData in class TWGPersistentObject
Parameters:
dict - - dictionary to hold saved data
Throws:
TWGPersistentObjectSaveException - if save aborted

restoreData

protected void restoreData(TWGPersistentObjectDictionary dict,
                           boolean do_references)
                    throws TWGPersistentObjectRestoreException
Restore method for persistent object

Overrides:
restoreData in class TWGPersistentObject
Parameters:
dict - - dictionary containing persistent object records
do_references - - true if second pass (reference restores)
Throws:
TWGPersistentObjectRestoreException - if restore aborted

getName

public java.lang.String getName()
Get name (default locale)

Returns:
name string

getName

public java.lang.String getName(java.util.Locale loc)
Get name (given locale)

Parameters:
loc - - locale to get name relative to
Returns:
name string

setName

public void setName(java.lang.String n)
Set name of record definition

Parameters:
n - - new name

setName

public void setName(java.lang.String nameid,
                    java.lang.String namerb)
Set name of record definition using resouce bundle name and ID

Parameters:
nameid - - identifier for name
namerb - - name of resouce bundle containing name

getIDString

public java.lang.String getIDString()
Get ID string

Returns:
ID string (or null if none defined)

isAgentSyncRecord

public boolean isAgentSyncRecord()
Test to see if record type is synchronized with agent copy


isAgentOwned

public boolean isAgentOwned()
Test to see if record type is agent-owned (agent version is 'master')


isGroupRecordAllowed

public boolean isGroupRecordAllowed()
Test to see if group records allowed by record type


findByIDString

public static TWGDistConfigRecordDef findByIDString(java.lang.String id)
Find record definition instance by ID string

Parameters:
id - - ID string to search for
Returns:
matching record definition instance, or null if none

getRecordStorageFile

public java.io.File getRecordStorageFile()
Get file object for our attribute storage


openBagFile

public BagFile openBagFile()
                    throws java.io.IOException
Open bagfile for use

Throws:
java.io.IOException

closeBagFile

public void closeBagFile()
                  throws java.io.IOException
Close bagfile

Throws:
java.io.IOException

handleUnsupportedDistConfigAgent

public void handleUnsupportedDistConfigAgent(TWGManagedObject mo,
                                             TWGDistConfigRecordHashcode[] recs,
                                             DistConfigAgentResult result_listener)
Handler for attempts to copy records to a managed object instance which doesn't support configuration distribution (i.e. ITD V1.x agents, MPM agents). Implementations of this method should execute quickly, and report results asynchronously using the provided result listener (or call the super classes method to set the result code.) The method is provided with a full set of hashcode records for all records which the agent should have (of all types). The handler should use these to determine what operations are necessary to handle their records (i.e. if a record is provided in the list, it should be added or updated on the agent if it isn't a match. If the agent has a record which isn't in the list, the agent record should be deleted).

Parameters:
mo - - managed object to be distributed to
recs - - full set of record hashcodes for agent
result_listener - - Listener to report results to

getRecordForObject

public TWGDistConfigRecord getRecordForObject(long obj_id)
                                       throws java.io.IOException
Get record for given object ID

Parameters:
obj_id - - object ID (either group or managed object ID)
Throws:
java.io.IOException - if error reading record

getRecordDataForHashcodeRecord

public static byte[] getRecordDataForHashcodeRecord(TWGDistConfigRecordHashcode hcr)
Read data record for given hashcode record

Parameters:
hcr - - hashcode record

setRecordForObjects

public void setRecordForObjects(long[] obj_ids,
                                byte[] rec)
                         throws java.io.IOException,
                                InvalidObjectIDException
Add/replace record for given object IDs

Parameters:
obj_ids - - object IDs (groups or managed object ID)
rec - - record to be written : null=delete existing record
Throws:
java.io.IOException - if error writing record
InvalidObjectIDException - if bad object ID

setRecord

public static void setRecord(TWGDistConfigRecord rec)
                      throws java.io.IOException,
                             InvalidObjectIDException
Add/replace record

Parameters:
rec - - record to be written : contains all other attributes
Throws:
java.io.IOException - if error writing record
InvalidObjectIDException - if bad object ID

getRecordHashcodeForObject

public TWGDistConfigRecordHashcode getRecordHashcodeForObject(long obj_id)
                                                       throws InvalidObjectIDException
Get hashcode for record for given object. Only returns hashcode for record associated with specific object (doesn't get group blocks for managed objects).

Parameters:
obj_id - - object ID (group or managed object ID)
Throws:
InvalidObjectIDException - if bad object ID

getCompositeHashcodeForObject

public static byte[] getCompositeHashcodeForObject(long obj_id,
                                                   boolean only_agt_recs)
                                            throws InvalidObjectIDException
Get composite hashcode for all records for given managed object (including groups containing managed object).

Parameters:
obj_id - - managed object ID
Throws:
InvalidObjectIDException - if bad object ID

getCompositeHashcodeForObject

public static byte[] getCompositeHashcodeForObject(long obj_id)
                                            throws InvalidObjectIDException
Get composite hashcode for all records for given managed object (including groups containing managed object). Only includes agent-copied records

Parameters:
obj_id - - managed object ID
Throws:
InvalidObjectIDException - if bad object ID

getAllHashcodesForObject

public static TWGDistConfigRecordHashcode[] getAllHashcodesForObject(long obj_id,
                                                                     boolean only_agt_sync)
                                                              throws InvalidObjectIDException
Get all hashcodes for all records for given managed object (including groups containing managed object).

Parameters:
obj_id - - managed object ID
only_agt_sync - - true if only agent copied records should be requested
Throws:
InvalidObjectIDException - if bad object ID

getAllHashcodesForObject

public static TWGDistConfigRecordHashcode[] getAllHashcodesForObject(long obj_id)
                                                              throws InvalidObjectIDException
Get all hashcodes for all records for given managed object (including groups containing managed object). Only includes agent-copied records.

Parameters:
obj_id - - managed object ID
Throws:
InvalidObjectIDException - if bad object ID

getHashcodesForObject

public TWGDistConfigRecordHashcode[] getHashcodesForObject(long obj_id)
                                                    throws InvalidObjectIDException
Get all hashcodes for given managed object (including groups containing managed object).

Parameters:
obj_id - - managed object ID
Throws:
InvalidObjectIDException - if bad object ID

getAllRecordsForObject

public static TWGDistConfigRecord[] getAllRecordsForObject(long obj_id,
                                                           boolean only_agt_sync)
                                                    throws InvalidObjectIDException,
                                                           java.io.IOException
Get all records for given managed object (including groups containing managed object).

Parameters:
obj_id - - managed object ID
only_agt_sync - - true if only agent-copied records should be included
Throws:
InvalidObjectIDException - if bad object ID
java.io.IOException - if error reading records

getAllRecordsForObject

public static TWGDistConfigRecord[] getAllRecordsForObject(long obj_id)
                                                    throws InvalidObjectIDException,
                                                           java.io.IOException
Get all records for given managed object (including groups containing managed object). Only gets agent-copied records.

Parameters:
obj_id - - managed object ID
Throws:
InvalidObjectIDException - if bad object ID
java.io.IOException - if error reading records

getRecordsForObject

public TWGDistConfigRecord[] getRecordsForObject(long obj_id)
                                          throws InvalidObjectIDException,
                                                 java.io.IOException
Get all records for given managed object (including groups containing managed object).

Parameters:
obj_id - - managed object ID
Throws:
InvalidObjectIDException - if bad object ID
java.io.IOException - if error reading records

deleteAllRecordsForObject

public static void deleteAllRecordsForObject(long obj_id)
                                      throws java.io.IOException,
                                             InvalidObjectIDException
Delete all records associated with given object ID

Parameters:
obj_id - - object ID
Throws:
java.io.IOException
InvalidObjectIDException

enqueueAgentRecordSynchronize

public static void enqueueAgentRecordSynchronize(TWGManagedObject mo)
Enqueue synchronize for given agent

Parameters:
mo - - managed object to be sent update

enqueueGroupRecordSynchronize

public static void enqueueGroupRecordSynchronize(TWGFilter flt)
Enqueue synchronize for all members of given group


enqueueUnsupportedAgentRecordSynchronize

public static void enqueueUnsupportedAgentRecordSynchronize(TWGManagedObject mo)
Enqueue unsupported agent synchronize for given agent

Parameters:
mo - - managed object to be sent update

distConfigAgentRecordUpdated

public void distConfigAgentRecordUpdated(TWGManagedObject mo,
                                         long obj_id)
Callback for reporting add/update of specific record on specific managed object. Can be subclasses to handle delivery of client-mastered records or verification of update of client copies of server mastered records.

Parameters:
mo - - managed object targeted
obj_id - - object ID for record (MO-ID or Group ID)

distConfigAgentRecordDeleted

public void distConfigAgentRecordDeleted(TWGManagedObject mo,
                                         long obj_id)
Callback for reporting delete of specific record on specific managed object. Can be subclasses to handle delivery of client-mastered records or verification of update of client copies of server mastered records.

Parameters:
mo - - managed object targeted
obj_id - - object ID for record (MO-ID or Group ID)

registerChangeListener

public void registerChangeListener(TWGDistConfigRecordChangeListener list)
Register listener for record updates and deletes

Parameters:
list - - listener

deregisterChangeListener

public void deregisterChangeListener(TWGDistConfigRecordChangeListener list)
Deregister listener for record updates and deletes

Parameters:
list - - listener