AppFabric 1.1 Caching Admin Tool BETA 1

Overview of the MDCAdminTool

 Jason Roth

 

Introduction

MDCAdminTool is a working sample of how to programmatically manage one or more on-premises AppFabric cache clusters in a single user interface. The tool does not need to be run on a cache node. In fact, part of the purpose of the tool is to allow administrators to manage their cache clusters outside of any cache node, which is currently not possible with PowerShell for certain commands such as Add-CacheHost, Remove-CacheHost, and Unregister-CacheHost. Running these commands requires three things:

  1. Elevated trust (which can be done by running as administrator)
  2. PowerShell remoting availability
  3. An authenticated user

The third requirement of having an authenticated user is the most difficult, because identity is lost after the PowerShell command is sent to a different machine in the network.

 

The fastest way to avoid this is to run the commands locally, but in a cluster with more than 20 hosts this becomes unfeasible. The situation is worse if you have several clusters. Even other commands that are specific to a cache host are impractical to run remotely across cache clusters of this size.

 

A simple sample on how wrap the PowerShell commands in C# can be found in this article. As guidance, this is a good method to use to programmatically centralize the use of the PowerShell commands. The Cache Admin Tool does this to wrap the AppFabric Caching PowerShell commands into a windows user-interface.

 

Breaking down the tool

Because this tool is offered as open source, this document attempts to explain the most vital parts of the tool in order to facilitate further development.

After opening the solution in Visual Studio (2010 was used to create the application), you will find the MDCAdminTool project, and this is what drives the tool; the other projects are mainly used for integration and unit testing, including the required peripheral libraries to execute them. As a windows application, the higher class is MainWindows.xaml.cs, and it controls the windows events. Through the Windows Presentation Foundation (WPF) Dispatcher object the CacheCluster class is invoked to ultimately run the PowerShell Commands. This class is found under the MDCAdminTool namespace (CacheCluster.cs); it inherits from the PowerShellBase class (PowerShell.cs) which handles logging the results from the PowerShell commands. It also inherits from the session class (session.cs) which does the actual invocation of the PowerShell commands to the cache node.

The tree view that is shown in the console requires a little more attention, so the CacheCluster class implements the MdcCache class (MdcCahe.cs) which also inherits from the PowerShellBase class (and hence the session class) and is used for the creation of the treeview as it implements a public property (Children) of the ObservableCollection object type.

Similar to the referenced PowerShell article, the Session class instantiates the Runsspace (to prepare to run PowerShell commands) in its constructor. In its private invokeInternal method it creates the Pipeline, which is used to send the actual command to the cache node. The same method also facilitates the receiving of an IDictionary object for taking in a command that requires several parameters. It returns a Collection which gathers the results of the command. This is the main class that runs all of the PowerShell commands required by the user.

Prerequisites

 

  1. The executable needs to be run in elevated privilege. Right-click and “Run as administrator”.

  2. In AppFabric setup, install the Cache Client feature and the Cache Administration feature. The Cache Client feature supports API calls to the cache cluster. The Cache Administration feature contains the actual PowerShell commands. Nothing else is required to run the tool. The screenshot below is from 1.0 but should be similar to 1.1.

 

 Feature Selection

 

 

 

  1. The tool should be able to add/remove remote cache nodes. If this functionality is needed, the following configuration is required. These additional steps are not required if you add/remove cache nodes outside of the tool.
    1. Follow the steps specified in this article to run th This will allow the creation of a listener via the Windows Remote Management service, which enables PowerShell sessions to receive instructions from a remote controller.

 

Note that the Enable-PSRemoting PowerShell command must be run with elevated permissions as an administrator. When prompted to confirm this setting, enter “y”.

 

  1. Enable delegation for the all the cache nodes in all the clusters that want to be administered, this is done via server manager against the Domain Active Directory. This allows delegation of user credentials in other machines.

 

From the server manager, open your Active Directory Domain Services and choose the domain, see screen below, where all the machines reside. And on the drop down click on “Computers” and find the appropriate machines, for each machine right click.

 Server Manager

 

Click Properties (see the follow screenshot), and then select the Delegation tab.

 

 

Select the “Trust this computer for delegation to any service” radio button, which means that this computer will allow delegation of a user's identity from any computer to this computer. This is the easiest way to allow the MDCAdminTool to administer this machine from multiple clients.

However, to improve security, it is recommended to instead select “Trust this computer for delegation to specified services only” (keep “Use Kerberos only” radio button selected). This is shown below. This enables you to specify the machines that are allowed to delegate to this server. In our case, it will be the machine(s) running the MDCAdminTool.

 

 

Use the Add button to select specific machines..

 

 

You might also be able to add the user for the administrator of the cache clusters, which is shown in the following window.

 

 

Note: the assumption is that your cache clusters and management nodes are all running inside a DMZ.

Configuration

Before running the tool you need to register your cache cluster(s) in the caching.config file. The tool supports arbitrary number of SQL-based or XML-based cache clusters. Refer to this example for configuration file format:

 

Sample:

<CachingConfig> 

<clusters> 

   <add name="Cluster 1" connectionString="\\NetworkShareName\Config" provider="XML"/>

   <add name="Cluster 2" connectionString="Data Source=SQLSERVERMACHINE\INSTANCE;Initial Catalog=databasename;Integrated Security=True" provider="System.Data.SqlClient"/>

</clusters> 

</CachingConfig> 

 

The app.config file also contains some tool settings, including pointing to the name of the caching.config file. It also contains the supported .NET version (note that only V4.0 has been tried)

 

Sample:

<?xml version="1.0"?>

<configuration> 

<configSections> 

   <section name="CachingConfig"

       type="MDCAdminTool.Configuration.CachingConfiguration, E4D.AppFabric.Entities"

       restartOnExternalChanges="false"

       requirePermission="false"/>

</configSections> 

  

<CachingConfig configSource="caching.config"/>

  

<startup>

   <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>

</startup>

 

</configuration>

 

Note that the version of this tool for AppFabric 1.1 has additional settings to locate the referenced AppFabric binaries. In AppFabric 1.1, these DLLs are not placed in the global assembly cache (GAC) automatically. If necessary, modify the runtime section in the app.config file to point to the correct path to these AppFabric binaries. Note that this section is not required for Windows Server AppFabric 1.0, because the 1.0 files are in the GAC.

 

<runtime>

   <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

     <dependentAssembly>

       <assemblyIdentity name="Microsoft.ApplicationServer.Caching.Management" publicKeyToken="31bf3856ad364e35"/>

       <codeBase version="1.0.0.0" href="FILE://C:/Program Files/AppFabric 1.1 for Windows Server/Microsoft.ApplicationServer.Caching.Management.dll"/>

     </dependentAssembly>

     <dependentAssembly>

       <assemblyIdentity name="Microsoft.ApplicationServer.Caching.Client" publicKeyToken="31bf3856ad364e35"/>

       <codeBase version="1.0.0.0" href="FILE://C:/Program Files/AppFabric 1.1 for Windows Server/Microsoft.ApplicationServer.Caching.Client.dll"/>

     </dependentAssembly>

     <dependentAssembly>

       <assemblyIdentity name="Microsoft.ApplicationServer.Caching.Configuration" publicKeyToken="31bf3856ad364e35"/>

       <codeBase version="1.0.0.0" href="FILE://C:/Program Files/AppFabric 1.1 for Windows Server/Microsoft.ApplicationServer.Caching.Configuration.dll"/>

     </dependentAssembly>

     <dependentAssembly>

       <assemblyIdentity name="Microsoft.ApplicationServer.Caching.Core" publicKeyToken="31bf3856ad364e35"/>

       <codeBase version="1.0.0.0" href="FILE://C:/Program Files/AppFabric 1.1 for Windows Server/Microsoft.ApplicationServer.Caching.Core.dll"/>

     </dependentAssembly>

     <dependentAssembly>

       <assemblyIdentity name="Microsoft.ApplicationServer.Caching.ManagementPS" publicKeyToken="31bf3856ad364e35"/>

       <codeBase version="1.0.0.0" href="FILE://C:/Program Files/AppFabric 1.1 for Windows Server/PowershellModules/DistributedCacheAdministration/Microsoft.ApplicationServer.Caching.ManagementPS.dll"/>

     </dependentAssembly>

     <dependentAssembly>

       <assemblyIdentity name="Microsoft.ApplicationServer.Caching.Configuration" publicKeyToken="31bf3856ad364e35"/>

       <codeBase version="1.0.0.0" href="FILE://C:/Program Files/AppFabric 1.1 for Windows Server/PowershellModules/DistributedCacheConfiguration/Microsoft.ApplicationServer.Caching.Configuration.dll"/>

     </dependentAssembly>

     <dependentAssembly>

       <assemblyIdentity name="Microsoft.ApplicationServer.Caching.SqlProvider" publicKeyToken="31bf3856ad364e35"/>

       <codeBase version="1.0.0.0" href="FILE://C:/Program Files/AppFabric 1.1 for Windows Server/Microsoft.ApplicationServer.Caching.SqlProvider.dll"/>

     </dependentAssembly>

     <dependentAssembly>

       <assemblyIdentity name="Microsoft.ApplicationServer.Caching.Configuration.resources" publicKeyToken="31bf3856ad364e35"/>

       <codeBase version="1.0.0.0" href="FILE://C:/Program Files/AppFabric 1.1 for Windows Server/Microsoft.ApplicationServer.Caching.Configuration.resources.dll"/>

     </dependentAssembly>

     <dependentAssembly>

       <assemblyIdentity name="Microsoft.ApplicationServer.Caching.EventDefinitions" publicKeyToken="31bf3856ad364e35"/>

       <codeBase version="1.0.0.0" href="FILE://C:/Program Files/AppFabric 1.1 for Windows Server/Microsoft.ApplicationServer.Caching.EventDefinitions.dll"/>

     </dependentAssembly>

     <dependentAssembly>

       <assemblyIdentity name="Microsoft.ApplicationServer.Caching.Server" publicKeyToken="31bf3856ad364e35"/>

       <codeBase version="1.0.0.0" href="FILE://C:/Program Files/AppFabric 1.1 for Windows Server/Microsoft.ApplicationServer.Caching.Server.dll"/>

     </dependentAssembly>

   </assemblyBinding>

</runtime>

 

Features

  1. Each level in the hierarchy allows right-click operations that will display all allowed actions under that given hierarchy-label. The same action is also shown on a menu with tabs.
  2. Edit your cluster name to a more user-friendly name in the UI (rename label).
  3. Icons on each cache cluster node indicate if a cluster is based on an XML or SQL Server configuration.
  4. View cache statistics with the Cache Stats feature to see the total cached data size and other metrics.

Consideration

The upper limit tested at 100 nodes, 10 clusters of 10 nodes each. However the interface does become rather slow at this point.

Last edited Apr 7, 2012 at 3:32 PM by Vardi, version 5

Comments

No comments yet.