Model Operations

Use ttGridAdmin commands in this section to apply the latest version of the model to the grid, delete a version of the model, export a version of the model to a JSON file, import a version of the model from a JSON file (to become the latest version), compare two versions of the model, or list information about all versions of the model.

Note:

The latest version of the model is the version that is pending for edits and updates. It has not yet been applied to the model. The current version of the model is the version most recently applied to the model. Only the latest version of the model is editable. All other versions are read-only. When the latest version is applied, it becomes the current version and a copy is made to serve as the initial latest version.

Apply the Latest Version of the Model (modelApply)

The modelApply command applies the latest version of the model to the grid, implementing previous operations. This includes actions such as creating physical installations and instances according to installation and instance objects that have been defined in the model.

ttGridAdmin modelApply [-nostart]
                       [-details]

Options

The modelApply command has the options:

Option Description

-nostart

By default, the modelApply command automatically starts new TimesTen Scaleout instances when they are created for the grid. If you specify -nostart, the instances are created but not started.

-details

Displays additional information about the operations being performed by the command.

Examples

This example shows typical output.

% ttGridAdmin modelApply
Creating new model version............................................OK
Exporting current model (version 1)...................................OK
Identifying any deleted objects.......................................OK
Verifying installations...............................................OK
Creating new installations............................................OK
Verifying instances...................................................OK
Creating new instances................................................OK
Updating grid state...................................................OK
Configuring instance authentication...................................OK
Pushing new configuration files to each instance......................OK
Making model version 1 current, version 2 writable....................OK
Checking ssh connectivity of new instances............................OK
Starting new management instance......................................OK
Configuring standby management instance...............................OK
ttGridAdmin modelApply complete

(Output will vary depending on your situation, such as whether installations or instances in the model already existed, either from being created manually or from any previous modelApply commands that were only partially successful.)

Notes

  • When a grid is created, version 1 of the model is created automatically. When modelApply is run on the grid for the first time, version 1 of the model is made read-only and version 2 is created. Version 2 is an exact copy of version 1 and is read-write. Version 1 is then applied to the grid. Subsequent changes made to the model are made to version 2, until modelApply is run again, at which time version 3 is created, and so on. There is always a writable version of the model available.

  • At any given point, the writable version of the model, which has not yet been applied to the grid, is referred to as the latest version. The version that has been applied and is operational in the grid is referred to as the current version. (The current version and all previous versions are read-only.)

  • The modelApply command communicates with each instance in the grid and creates or updates configuration files on each instance, including timesten.conf, as needed. The command runs these operations in parallel as much as possible, but still may take a significant amount of time to complete. Complete all the steps in getting from one desired configuration to another desired configuration before applying the model.

  • It may not always be possible for modelApply to complete all of its operations, such as if a host is down. If there are problems, modelApply creates error logs in the diag directory of the management instance and indicates the names of those logs. The next time you run modelApply, it will try again to complete any operations that failed previously, in addition to completing any new operations.

  • See Applying the Changes Made to the Model in Oracle TimesTen In-Memory Database Scaleout User's Guide for additional information.

Compare Models (modelCompare)

The modelCompare command compares two versions of the model and displays a summary of changes between them.

ttGridAdmin modelCompare -latest|-current|-version n
                         [-latest|-current|-version m]

Options

The modelCompare command has the options:

Option Description

-latest

Specifies that the latest version of the model—the model being modified and not yet applied to the grid—is one of the versions to compare.

If the command line specifies only one version, that version is compared against the latest version by default.

-current

Specifies that the current version of the model—the model most recently applied to the grid—is one of the versions to compare.

-version n

Specifies that model version n is one of the versions to compare.

-version m

Specifies that model version m is one of the versions to compare.

Examples

This example shows that the client/server connectable database1CS was added between the current model and the latest model. (Other differences shown are for meta data.)

% ttGridAdmin modelCompare -current -latest
4,5c4,5
<    "applied" : true,
<    "current" : true,
---
>    "applied" : false,
>    "current" : false,
94a95,107
>             },
>             {
>                "attrs" : {
>                   "CipherSuites" : "SSL_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
>                   "ConnectionCharacterSet" : "AL32UTF8",
>                   "Encryption" : "requested",
>                   "UID" : "terry",
>                   "Wallet" : "!!TIMESTEN_HOME!!/conf/wallets/clientWallet"
>                },
>                "clientServer" : true,
>                "guid" : "413F6633-B45B-4F47-A542-560C8519A058",
>                "name" : "database1CS",
>                "type" : "connectable"
433,435c446,447
<    "version" : 1,
<    "whenApplied" : "2021-08-12T14:48:14.000Z",
<    "whenCreated" : "2021-08-12T14:45:06.000Z"
---
>    "version" : 2,
>    "whenCreated" : "2021-08-12T14:46:25.000Z"

Note:

The summary of changes is displayed in UNIX diff format.

Export a Version of a Model (modelExport)

The modelExport command exports information about the grid for the specified version of the model in JSON format, typically to a specified file.

ttGridAdmin modelExport [-latest|-current|-version n] 
                        [filepath]

Within the grid, the hierarchy of the output includes the following:

SQLNet
TNSNames
DataSpaceGroups
Hosts
   Installations
      Instances
Databases
   Connectables

Options

The modelExport command has the options:

Option Description

-latest

Export the latest model—the model being modified and not yet applied to the grid. This is the default.

-current

Export the current model—the model most recently applied to the grid.

-version n

Lists database definition objects in the specified version number of the model.

filepath

Path and name of the file where the JSON representation of the model is written. If no file is specified, the export goes to stdout.

Examples

Export the current version (version 4) of the model. This is run from a management instance:

% pwd
/sw/tten/grid/ttinstances/gridmgmt1/bin
% ttGridAdmin modelExport -current /sw/tten/grid/models/model4export.json
Model version 4 exported to /sw/tten/grid/models/model4export.json

Export the latest version (version 5) of the model, which is the default version to export. This is run from a data instance:

% pwd
/sw/tten/grid/ttinstances/instance1/bin
% ttGridAdmin modelExport /sw/tten/grid/models/model5export.json
Model version 5 exported to /sw/tten/grid/models/model5export.json

Output files:

% pwd
/sw/tten/grid/models
% ls
model4export.json  model5export.json

Notes

  • Metrics and logs are not exported. They exist on the active management instance but are not part of the model.

  • You can run this command from a management instance or a data instance.

  • You can use modelExport to create a backup of the model.

Import a Version of the Model (modelImport)

The modelImport command imports a model from a JSON file (perhaps exported earlier using the modelExport command) to update the latest version of the model, or creates a script that you can use to update the model later.

ttGridAdmin modelImport [-script scriptpath] 
                        [filepath]

Options

The modelImport command has the options:

Option Description

-script scriptpath

Creates a script with the specified name and path. The model is not updated when you run modelImport. Instead, you can run the resulting script later to modify the latest version of the model to conform to the imported version. This allows you to review the changes beforehand.

Without -script, the latest model is updated immediately.

filepath

Path and name of the JSON file from which the representation of the model is read.

If filepath is not specified, input is read from stdin.

Examples

Consider a scenario where you exported the latest version (Version 5) of the model, subsequently made changes to the latest version of the model without applying them, then decided you do not want those changes after all. To undo the changes, import the file you previously exported:

% ttGridAdmin modelImport /sw/tten/grid/models/model5export.json
Model imported

Without the -script option, the model is imported immediately.

With the script option, a script is created that you can run later:

% ttGridAdmin modelImport /sw/tten/grid/models/model5export.json -script 
/sw/tten/grid/models/modelmodscript
Script /sw/tten/grid/models/modelmodscript created.

Here is an example of a resulting script:

% pwd
/sw/tten/grid/models
% more modelmodscript
#!/bin/sh
# Created by ttGridAdmin -modelImport
TIMESTEN_HOME=/sw/tten/grid/ttinstances/gridmgmt
if [ -e $TIMESTEN_HOME/bin/ttenv.sh ]; then
 . $TIMESTEN_HOME/bin/ttenv.sh >/dev/null 2>&1
fi
# TNSNames unchanged
#Host mysys5host...
ttGridAdmin -hostCreate  mysys5host -internalAddress mysys5.example.com -externalAddress mysys5.example.com
ttGridAdmin installationCreate mysys5host.installslc -location 
/sw/tten/grid/ttinstallations/installadc/
ttGridAdmin instanceCreate mysys5host.instance1 -installation installslc 
-location /sw/tten/grid/ttinstances/ -daemonPort 20000 -csPort 21000
#Host mysys3host...
#Host mysys1host...
#Host mysys2host...
#Host mysys4host...
#Dbdef database1
#Connectable unchanged!
#Connectable unchanged!
#DbDef unchanged!
#Dbdef TTGRIDADMIN
#Connectable unchanged!
#Connectable unchanged!
#DbDef unchanged!

Notes

  • The modelImport command compares the latest version of the model with the model being imported.

  • The changes to the latest version of the model are not done in an atomic transaction. Each change is done in a separate transaction, so any failure will result in complications.

List Model Versions (modelList)

The modelList command lists the versions of the model, indicating when each was defined, applied, and deleted, as applicable.

ttGridAdmin modelList

Examples

% ttGridAdmin modelList
Version Created             Applied             Deleted
------- ------------------- ------------------- -------------------
      1 2016-10-06 12:59:26 2016-10-14 13:45:24 N/A
      2 2016-10-14 13:44:45 2016-10-14 14:33:47 N/A
      3 2016-10-14 14:33:05 2016-10-14 14:46:33 N/A
      4 2016-10-14 14:46:20 N/A                 N/A