TFS Source Control administration web service
Have you ever wondered how many files are in your server? Or workspaces? Have you wanted to stop a request that was being processed? Using the administration web service and matching web page for TFS Source Control, you can do exactly that.
For a beta 2 server, bring up http://localhost:8080/scc/application/admin.asmx in Internet Explorer (either run IE on the application tier or replace localhost with the name of the server). For the upcoming mid-July CTP server, bring up http://localhost:8080/SourceControl/Application/Administration.asmx (yep, longer name and more capital letters).
Since we’re close to the upcoming mid-July CTP, I’m going use it in the examples.
When you bring up the web page, you’ll see links for the web methods that are available. You can run these in Internet Explorer, or you can write code in VS 2005 to call the web service methods from an application. Here is what you’ll see.
Team Foundation VersionControl Admin web service
The following operations are supported. For a formal definition, please review the Service Description.
If you click on QueryRepositoryInformation and then click the Invoke button, you’ll see how many files, workspaces, and so forth that are on the server. For my current development server, I see the following.
<?xml version=”1.0″ encoding=”utf-8″ ?>
<AdminRepositoryInfo xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance“ xmlns:xsd=”http://www.w3.org/2001/XMLSchema“ UserCount=”1“ GroupCount=”6“ WorkspaceCount=”2“ ShelvesetCount=”1“ FileCount=”2487“ FolderCount=”27“ MaxChangesetID=”3“ PendingChangeCount=”12“ xmlns=”http://schemas.microsoft.com/TeamFoundation/2005/06/VersionControl/Admin/02“ />
From this you can see that I’m the only user (UserCount = 1). There are six groups defined (GroupCount = 6). I have created two workspaces (WorkspaceCount = 2) and one shevleset (ShelvesetCount = 1). On a beta 2 server, the workspace and shelveset counts are lumped together in the workspace count. There are currently 2487 files in 27 directories checked into the server (FileCount = 2487 and FolderCount = 27). I’ve only checked in twice since the server was created (MaxChangesetID = 3, and the first changeset is always the creation of $/ when the server is installed).
The last number is the number of pending changes. It says that there are 12 pending changes on the server (PendingChangeCount = 12). However, six of those pending changes are in one of my workspaces, and the other six are in the one shelveset I’ve created. So, as your users make use of shelving, you’ll see your pending change count climb quite a bit.
You can create a quick shortcut to the repository info page by using the URL you see in IE when you are looking at the XML data. In this case, it’s http://localhost:8080/SourceControl/Application/Administration.asmx/QueryRepositoryInformation. That gets you the result of clicking the Invoke button without having to click it.
Clicking on QueryServerInformation will tell you how long your server has been running, the unique ID of the server, and a few other details.
The ChangeServerState operation allows you to pause or stop the server. When you click on it, you’ll see a newServerState parameter and a comment parameter. The newServerState values are shown in the SOAP detail below the parameter boxes. The following lines from that description show what you can enter.
<newServerState>Stopped or Starting or Running or Paused or Unknown</newServerState>
So, if you enter Paused (be sure to type it with the exact casing you see, or you’ll get an error about the value being unknown) for newServerState and type in some text for a comment, the server will be Paused when you click Invoke. If it succeeds, you’ll see a blank window in IE, since we’re just using the feature of ASP.NET that allows you to interactively run the web methods, so it doesn’t give you anything back since the web method has no response, unlike QueryServerInformation.
When I paused my server, I put in a comment of “For this demo.” Now, if you’ll go back to QueryServerInformation, you’ll see that your server is indeed paused (ServerState = Paused and Comment is whatever you typed).
<?xml version=”1.0″ encoding=”utf-8″ ?><AdminServerInfo xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance“ xmlns:xsd=”http://www.w3.org/2001/XMLSchema“ StartTime=”2005-06-29T20:38:33.0581917Z“ Uptime=”06:49:58.2633623“ ServerState=”Paused“ Comment=”For this demo.“ DateLastStateChange=”2005-06-30T03:22:18.3Z“ ServerLogState=”None“ LogComment=”Administrative logging not enabled“ LogDateLastStateChange=”2005-06-29T20:34:06.053Z“ RepositoryName=”buckhHatteras“ RepositoryId=”97732cf6-ff08-455c-b0e5-b77ae02844fa“ xmlns=”http://schemas.microsoft.com/TeamFoundation/2005/06/VersionControl/Admin/02“ />
If you paused your server, now’s a good time to go back to ChangeServerState and set newServerState to Running.
The QueryServerRequests page will show you the currently active server requests. When I invoke QueryServerRequests, I see the following.
<?xml version=”1.0″ encoding=”utf-8″ ?>
<ArrayOfAnyType xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance“ xmlns:xsd=”http://www.w3.org/2001/XMLSchema“ xmlns=”http://schemas.microsoft.com/TeamFoundation/2005/06/VersionControl/Admin/02“><anyType xsi:type=”AdminServerRequest“ User=”NORTHAMERICAbuckh“ ServerProcessID=”5978“ StartTime=”2005-06-30T03:36:11.5461948Z“ StopTime=”0001-01-01T00:00:00“ InProgress=”true“ ExecutionTime=”00:00:00.7343844“ WebMethod=”Get“ RemoteComputerName=”192.168.20.105“ RemoteComputer=”192.168.120.105“ RemotePort=”2519“ /><anyType xsi:type=”AdminServerRequest“ User=”NORTHAMERICAbuckh“ ServerProcessID=”5979“ StartTime=”2005-06-30T03:36:12.264954Z“ StopTime=”0001-01-01T00:00:00“ InProgress=”true“ ExecutionTime=”00:00:00.0156252“ WebMethod=”QueryServerRequests“ RemoteComputerName=”127.0.0.1“ RemoteComputer=”127.0.0.1“ RemotePort=”2464“ /></ArrayOfAnyType>
I ran “h get” from a command prompt immediately before running QueryServerRequests. So, there are two requests active. The second one, WebMethod = QueryServerRequests, is my own requests to see the other requests. You’ll always see at least this entry. The first one is the result of my execution of “h get” from the command prompt. The client has called the Get web service on the server to get the latest files into my workspace.
Earlier I mentioned being able to stop active server requests. The data returned by QueryServerRequests includes a ServerProcessID. In the data above, you can see that my Get web service request has ServerProcessID = 5978.
If you go back to the main Admin web page and click on KillProcess, you can use this ServerProcessID you obtained from QueryServerRequests. KillProcess takes two parameters, serverProcessID and comment. For the serverProcessID, enter the ServerProcessID from the QueryServerRequests page for the request you want to stop. You can also enter a comment to describe why you are doing it. When you execute the method, the specified request will immediately be stopped, and an error will be returned to the caller.
The OptimizeDatabase operation removes unreferenced content from the server. Unreferenced content is data that was uploaded to the server but is not referenced by any shelved change or committed file version. You don’t need to run this, as it’s run periodically (once per week, by default I believe).
With QueryServerInformation and the other methods, you have more information about what’s going on with your server and the ability to change it.