Summary
Converts the storage of a map or image service cache between the exploded format and the compact format. The tool converts the format in place, meaning it does not make a copy of the existing format of the cache. Instead, it creates the new format of the cache in the same cache folder and deletes the old format.
Make a backup of your cache before running this tool if you think you might want to go back to the old format.
Usage
To use this tool, specify the map or image service whose cache you want to convert. The tool detects the current storage format and uses that information to automatically set the target format to the opposite format. You can choose how many service instances to dedicate to cache conversion by specifing a value in the Number of caching service instances (num_of_caching_service_instances in Python) parameter.
Syntax
ConvertMapServerCacheStorageFormat(input_service, {num_of_caching_service_instances})
Parameter | Explanation | Data Type |
input_service | The map or image service whose cache format you want to convert. This is a string containing both the server and service information. To see how to construct this string, open ArcCatalog, select your service in the Catalog tree, and note the text in the Location toolbar. Change the backslashes to forward slashes, for example, GIS Servers/arcgis on MYSERVER (admin)/USA.MapServer. | String |
num_of_caching_service_instances (Optional) |
The total number of instances of the System/CachingTools service that you want to dedicate toward running this tool. You can increase the maximum number of instances per machine of the System/CachingTools service using the Service Editor window available through an administrative connection to ArcGIS Server. Ensure your server machines can support the chosen number of instances. | Long |
Code sample
ConvertMapServerCacheStorageFormat exampleConverts the cache storage format of a service
# Name: ConvertMapServerCacheStorageFormat.py
# Description: The following stand-alone script demonstrates how to convert map
# server cache storage format to the alteranate storage format
# Requirements: os, sys, time, traceback modules
# Any line that begins with a pound sign is a comment and will not be executed
# Empty quotes take the default value.
# To accept arguments from the command line replace values of variables to
# "sys.argv[]"
# Import system modules
import arcpy
from arcpy import env
import os, sys, time, string, datetime, traceback
# Set environment settings
env.workspace = "C:/data"
# Set local variables for mapservice properties
connectionFile = r"C:\Users\<username>\AppData\Roaming\ESRI\Desktop10.1\ArcCatalog"
server = "arcgis on MyServer_6080 (publisher)"
serviceName = "Rainfall.MapServer"
inputService = connectionFile + "\\" + server + "\\" + serviceName
numOfCachingServiceInstances = "2"
currentTime = datetime.datetime.now()
arg1 = currentTime.strftime("%H-%M")
arg2 = currentTime.strftime("%Y-%m-%d %H:%M")
file = 'C:/data/report_%s.txt' % arg1
# print results of the script to a report
report = open(file,'w')
# One can leave the variable for storage format marked "COMPACT" to "" (default)
# Execute ConvertMapServerCacheFormat
try:
starttime = time.clock()
result = arcpy.ConvertMapServerCacheStorageFormat_server(inputService,
numOfCachingServiceInstances)
finishtime = time.clock()
elapsedtime = finishtime - starttime
#print messages to a file
while result.status < 4:
time.sleep(0.2)
resultValue = result.getMessages()
report.write ("completed " + str(resultValue))
print "Converted Map Server Cache Storage format for " + serviceName + " in "
str(elapsedtime) + " sec \n on" + arg2
except Exception, e:
# If an error occurred, print line number and error message
tb = sys.exc_info()[2]
report.write("Failed at step 1 \n" "Line %i" % tb.tb_lineno)
report.write(e.message)
report.close()
print "Converted Map Server Cache Storage format "
Environments
This tool does not use any geoprocessing environments.
Licensing information
- Basic: Yes
- Standard: Yes
- Advanced: Yes