[.net programming language only]

Configuring WebSphere eXtreme Scale Client for .NET programmatically

You can override client-side settings programmatically. Create an ObjectGridConfiguration object that is similar in structure to the server-side ObjectGrid instance.

About this task

The following code example creates the same overrides that are described in WebSphere eXtreme Scale Client for .NET overrides.

Procedure

The following code creates a client-side ObjectGrid instance.
IGridManager gm = GridManagerFactory.GetGridManager();
ICatalogDomainInfo cdi = gm.CatalogDomainManager.CreateCatalogDomainInfo("localhost:2809");
ctx = gm.Connect(cdi, "Sample.Client.Net.properties");
IGrid grid = gm.GetGrid( ctx, "Grid");

//Overriding grid’s txTimeout value
grid.TransactionTimeout = new TimeSpan(0, 0, 30);

IGridMapPessimisticTxObject, Object gridMap;
gridMap = grid.GetGridMapPessimisticTx<Object, Object>("Map1");

//Overriding timeToLive value
gridMap.TimeToLive = new TimeSpan(0, 0, 50);

//Overriding lockTimeout value
gridMap.LockTimeout = new TimeSpan(0, 0, 20);

//Overriding txTimeout value
gridMap.Transaction.TransactionTimeout = new TimeSpan(0, 0, 40);

//Overriding txIsolation value
gridMap.Transaction.TransactionIsolationLevel = TxnIsolationLevel.ReadUncommitted;

//Calling ResetToDefaults(), resets the value of timeToLive, lockTimeout,
//txTimeout, txIsolation back to values when .NET client initialized the grid.

gridMap.ResetToDefaults();

Before overriding the timeToLive value programmatically, set the ttlEvictorType value to LAST_ACCESS_TIME or LAST_UPDATE_TIME in the objectgrid.xml file. If WebSphere eXtreme Scale Client for .NET tries to programmatically override timeToLive without setting the ttlEvictorType value, an exception its thrown. The txTimeout value set to TimeSpan.Zero indicates an unlimited timeout.