Try OpenEdge Now
skip to main content
Programming Interfaces
Database Administration Entity Interface Reference : ITenant interface : ITenant examples : Managing partitions for a tenant
 
Managing partitions for a tenant
Tenant partitioning is managed by various default settings on the tenant. The partitions for a tenant can be accessed through the Partitions property collection on the ITenant interface.
Setting DefaultAllocation to "Immediate" causes the partitioning to take place in the same transaction as the tenant creation using the default areas defined for the tenant. Setting the property to "Delayed" or "None" postpones the allocation and allows the area to be edited before the allocation.
The "Delayed" setting allows the partitions to be allocated in one operation by invoking the Allocate( ) method on ITenant, which sets the AllocationState property for every tenant partition (IPartition) to "Allocated". However, the IsAllocated property on ITenant returns FALSE when any individual partition has an AllocationState setting of "Delayed". The "None" setting is considered a permanent setting, and partitions that have an AllocationState setting of "None" do not affect a tenant's IsAllocated property setting. Also, allocating individual partitions do not affect the tenant's IsAllocated property setting. So, while changing the AllocationState setting of a partition from "None" to "Delayed" sets the tenant's IsAllocated property to FALSE, changing the AllocationState setting of a partition to "Allocated" does not set the tenant's IsAllocated property to TRUE.
Note: The IsAllocated property on ITenant does not necessarily reflect the state of all the tenant partitions. While it is always FALSE if one of the tenant partitions has an AllocationState setting of "Delayed", IsAllocated can be set to TRUE only by invoking the Allocate( ) method on ITenant. It cannot be set to TRUE by invoking the Allocate( ) method on the Partitions property (an IPartitionMap) of ITenant or on any individual partition (IPartition). In other words, for IsAllocated to be TRUE for a tenant, the Allocate( ) method must be invoked on the tenant itself, not on any one or more of the partitions (in a collection) owned by the tenant.
The following example creates the tenant with a delayed default allocation and changes the area on two partitions before the allocation is done:
define variable tenant   as ITenant no-undo.
define variable tbl       as ITable no-undo.
define variable partition as IPartition no-undo.

assign
  tenant = service:NewTenant("ABC")
  tenant:DefaultDataArea = service:GetArea("FirstClassDataArea")
  tenant:DefaultIndexArea = service:GetArea("FirstClassIndexArea")
  tenant:DefaultLobArea = service:GetArea("GeneralLobArea").
  tenant:DefaultAllocation = "Delayed".

service:CreateTenant(tenant).

assign
  tbl = service:GetTable("Customer")
  partition = tenant:Partitions:Get(tbl)
  partition:Area = service:GetArea("CustomerArea")
  partition = tenant:Partitions:Get(tbl:Indexes:Find("CustIdx"))
  partition:Area = service:GetArea("CustIndexArea").

tenant:Allocate().
Service:UpdateTenant(tenant).
See also:
*IArea interface
*IDataAdminElement interface
*IDomain interface
*IDomainSet interface
*IPartition interface
*IPartitionMap interface
*ISequence interface
*ISequenceValue interface
*ISequenceValueMap interface
*ITenantGroup interface
*ITenantGroupSet interface
*ITenantSet interface
*IUser interface
*IUserSet interface