How to: Set Log Sink Levels (Code) (Velocity)
On the server side, log sinks can only be configured in the cache host configuration file. For more information about these settings, see Log Sink Settings (Velocity).
To programmatically enable log sinks on the cache client, use the DataCacheFactory class static methods CreateLogSinks or EnableAllAvailableSinks. To disable log sinks programmatically, use the DisableLogSinks static method. For more information about log sink settings, see Log Sink Settings (Velocity).
Note
These procedures assume that you have already prepared your development environment and set references to the "Velocity" assemblies, and so on. For more information, see How to: Prepare the Development Environment (Velocity)
To create log sinks programmatically on the cache client
Create a list of type DataCacheLogSink to contain the log sinks you want to enable.
Create a DataCacheLogSink object for each log sink you want to enable.
Specify the type of log sink you want by using the DataCacheSinkType enumeration in the sinkType parameter of the DataCacheLogSink constructor.
Specify the trace level of the log sink by using the System.Diagnostics.TraceLevel enumeration in the logLevel parameter of the DataCacheLogSink constructor.
(optional) If you are creating a file-based log sink, and you want to change the log file naming convention and storage location, define the log file naming convention with the sinkParam parameter of the DataCacheLogSink constructor. For more information about the file naming convention, see Log Sink Settings (Velocity).
Add each log sink that you created to the list you created in the first step.
Pass the list of log sinks to the sinkList parameter of the CreateLogSinks method to enable the log sinks on your cache client.
To enable all available log sinks programmatically on the cache client
Call the EnableAllAvailableSinks static method to enable the log sinks on your cache client.
To disable all log sinks programmatically on the cache client
Call the DisableLogSinks static method to enable the log sinks on your cache client.
How to: Enable Local Cache (Code) (Velocity)
To programmatically enable local cache when creating your cache client, you must make sure the localCache parameter in the DataCacheFactory class constructor is equal to true. For more information about the application configuration settings, see Application Configuration Settings (Velocity).
Note
These procedures assume that you have already prepared your development environment and set references to the "Velocity" assemblies, and so on. For more information, see How to: Prepare the Development Environment (Velocity)
To create a cache client that has local cache enabled
Create an array of DataCacheServerEndPoint objects to specify the cache hosts for the client.
Configure your cache hosts by assigning the cache host array from the previous step to the servers parameter of the DataCacheFactory constructor. Note: For performance reasons, we recommend that you minimize the number of DataCacheFactory objects created in a cache-enabled application. Store the DataCacheFactory object in a variable available to all parts of the application that use cache clients.
Configure your cache client type by assigning a true or false value to the routingClient parameter of the DataCacheFactory constructor. Use the true value for a routing client, or a false value for a simple client.
Enable local cache by assigning a true value to the localCache parameter of the DataCacheFactory constructor.
(optional) Configure your cache client for cache notifications by using the DataCacheFactory constructor with the following additional parameters.
syncPolicy: Use the DataCacheLocalCacheSyncPolicy enumeration to choose how locally cached objects are invalidated. Use TimeoutBased to indicate that a time-out value should be used or NotificationBased to indicate that cache notifications will be used. For more information, see Cache Clients and Local Cache (Velocity).
localCacheTimeout: Use this parameter to specify the number of seconds that an object will remain in local cache before it is invalidated. This parameter is ignored if syncPolicy is set to NotificationBased.
pollInterval: Use this parameter to specify the interval of frequency, in seconds, that the cache client will check with the cache cluster for cache notifications. The default value is 300 seconds. Note: Local cache is not required for cache notifications. For more information, see Cache Notifications (Velocity).
Use the GetCache method to obtain an instance of the routing client.
Posted in: .Net Programming| Tags: .net 4.0 parameter Application Configuration CTP CTP 3 Microsoft Velocity cache code enable client local localcacheImportant Considerations of Velocity (Powershell Command)
When using the PowerShell commands described in this topic, it is important to consider the following points:
-
The security identity of the person using these PowerShell commands must have administrator privileges on all cache servers in the cache cluster.
-
Parameter values for the commands are case sensitive. For example, if you create a cache called
NamedCache1, the commandGet-CacheConfig -CacheName namedcache1will not work. You must match the case, as inGet-CacheConfig -CacheName NamedCache1. -
When making XML-based cluster configuration changes with the
Export-CacheClusterConfigandImport-CacheClusterConfigcommands, you can change cluster configuration settings (XML attributes) in the XML file, but adding or removing named caches and cache hosts by inserting or removing XML elements is not supported. -
Start-CacheCluster,Stop-CacheCluster, andRestart-CacheClustercache cluster commands involve coordinating the state of the cache host Windows service on all cache servers in the cluster. These commands may take longer when lead hosts perform the cluster management role; there must be a majority of lead host running while the rest of the cache hosts stop and start. -
Stop-CacheClusterorRestart-CacheClustercache cluster commands cause all data to be flushed from the memory of all cache hosts in the cluster. -
Set-CacheConfigandImport-CacheClusterConfigcommands require you to restart the cache cluster with Restart-CacheCluster in order for changes to take effect. -
Remove-CacheandNew-Cachecommands can be used to change a named cache configuration without impacting other named caches in the cluster.
How to uninstall a cache server and remove it from the cache cluster
-
Open the PowerShell-based cache administration tool from the shortcut that was installed on the desktop of the cache server. Note: On Microsoft Windows Vista and Microsoft Windows Server 2008 operating systems, you will have to right-click the "Velocity" PowerShell shortcut and select Run as administrator for the cache administration tool to work correctly.
-
Before the cache host service can be uninstalled on the cache server, use the PowerShell-based cache administration tool to stop the service with the
Stop-CacheHostcommand. For example, if you want to uninstall the cache host service on a computer namedCacheServer1, and it was installed with the default values for the TCP/IP port numbers, you would use the following command to stop the server's cache host service:Stop-CacheHost -HostName CacheServer1 -CachePort 22233. For more information about the cache administration commands available, see Cache Administration with PowerShell (Velocity). -
If the
Stop-CacheHostcommand was not successful and returns the errorERRCAdmin013, "Cluster Quorum would be disturbed…", stop the cache cluster using the commandStop-CacheCluster. This error is returned because there must always be a majority of cache hosts designated as lead hosts available for the cache cluster to remain running. This error also suggests that (after you uninstall this cache host) you will need to designate another cache host as a lead host before you can start the cache cluster. For more information about how to do that, see How to: Set the Cluster Management Role and Lead Host Designations (Velocity). -
Perform the cache host service uninstallation. This can be done manually with the Windows operating system program removal console or by using command-line parameters to automate a "silent" uninstallation.
-
Windows uninstallation: Use the operating system's Add or Remove Programs or Programs and Feature console to remove the program titled Microsoft project code named "Velocity" CTP3.
-
Automated installation: To perform an automated uninstallation, open the CMD.exe command-line tool and navigate to the folder you saved the installation program. Then, execute the installation program using the automated uninstallation parameters. For more information, see Automated Cache Server Installation (Velocity).
-
-
(optional) Depending on the options you selected for the uninstallation, you may need to re-apply the corporate standard firewall configuration settings.