Convert Map Server Cache Storage Format (Server)

Summary

Converts the storage of a map image layer or a map or image service cache between the exploded format and the compactV2 format.

Caution:

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 the cache before running this tool to revert to the old format if necessary.

Usage

  • In ArcGIS Enterprise, the Input Service parameter is a string containing the REST endpoint of the service. Ensure that your ArcGIS Enterprise portal is the active portal.

    In a stand-alone ArcGIS Server deployment, the Input Service parameter is a string containing both the server and the service information. To construct the string, add the full path to the ArcGIS Server connection file (.ags) with Publisher or Administrator credentials to the service name on the stand-alone server, for example: "C:\path_to_the connection_file_of_standAloneServer\arcgis on MyServer.com_6443.ags\ServiceName.MapServer". For more information, see Connect to a GIS server.

  • The current storage format of the input service is detected and used to set the target format to the opposite format. You can specify the number of service instances to dedicate to cache conversion using the Number of caching service instances parameter. The default value of -1 uses all the caching tool instances of the ArcGIS Enterprise setup. Use a lower value to use fewer caching tool instances. You can increase the Maximum number of instances per machine setting of the System/CachingTools service using the Service Editor window available through an administrative connection to ArcGIS Server. Ensure that the server machines can support the chosen number of instances. When connecting to a stand-alone server, the default number of instances is equal to the value of the Maximum number of instances setting of the caching tool service.

Parameters

LabelExplanationData Type
Input Service

The map or image service whose cache format will be converted. In ArcGIS Enterprise, this is a string containing the REST endpoint of the map image layer. In a stand-alone ArcGIS Server deployment, this is a string containing both the server and the service information.

Image Service; Map Server
Number of caching service instances
(Optional)

The total number of instances of the System/CachingTools service that will be dedicated to running this tool. When the default value of -1 is used, all the caching tool instances of the ArcGIS Enterprise setup will be used. Use a lower value to use fewer caching tool instances.

You can increase the Maximum number of instances per machine setting of the System/CachingTools service using the Service Editor window available through an administrative connection to ArcGIS Server. Ensure that the server machines can support the chosen number of instances.

When connecting to a stand-alone server, the default number of instances is equal to the value of the Maximum number of instances setting of the caching tool service.

Long

Derived Output

LabelExplanationData Type
Output Map Service URL

The output URL.

String

arcpy.management.ConvertMapServerCacheStorageFormat(input_service, {num_of_caching_service_instances})
NameExplanationData Type
input_service

The map or image service whose cache format will be converted. In ArcGIS Enterprise, this is a string containing the REST endpoint of the map image layer. In a stand-alone ArcGIS Server deployment, this is a string containing both the server and the service information.

Image Service; Map Server
num_of_caching_service_instances
(Optional)

The total number of instances of the System/CachingTools service that will be dedicated to running this tool. When the default value of -1 is used, all the caching tool instances of the ArcGIS Enterprise setup will be used. Use a lower value to use fewer caching tool instances.

You can increase the Maximum number of instances per machine setting of the System/CachingTools service using the Service Editor window available through an administrative connection to ArcGIS Server. Ensure that the server machines can support the chosen number of instances.

When connecting to a stand-alone server, the default number of instances is equal to the value of the Maximum number of instances setting of the caching tool service.

Long

Derived Output

NameExplanationData Type
out_job_url

The output URL.

String

Code sample

ConvertMapServerCacheStorageFormat example

Convert a map server cache storage format to the alternate storage format.

# Name: ConvertMapServerCacheStorageFormat.py
# Description: The following stand-alone script demonstrates how to convert map
#               server cache storage format to the alteranate storage format for
#               a weblayers/map or image service based on
#               ArcGIS Enterprise or a stand alone ArcGIS Server

import arcpy
import os

# Sign in to portal
myPortal= "https://www.myArcGISEnterprise.com/webadaptor"
arcpy.SignInToPortal(myPortal, "MyUserName", "MyPassword")
serviceName= "MyCounty"
serviceType= "MapServer"
myPortalServiceURL = (myPortal + "/" + "rest/services" +"/" + serviceName + "/" + serviceType)


# Stand alone ArcGIS Server
target_server_connection = r"C:\Project\gisserver.ags.esri.com (publisher).ags"
serviceName= "MyCounty"
serviceType= "MapServer"
myServerServiceURL= target_server_connection + "/" + serviceName + "." + serviceType

# Variables for reporting
currentTime = datetime.datetime.now()
arg1 = currentTime.strftime("%H-%M")
arg2 = currentTime.strftime("%Y-%m-%d %H:%M")
file = 'C:/results/report_%s.txt' % arg1

# Print results of the script to a report
report = open(file,'w')

try:
    #result = arcpy.server.ConvertMapServerCacheStorageFormat(myPortalServiceURL, -1)
    result = arcpy.server.ConvertMapServerCacheStorageFormat(myServerServiceURL, -1)
    while result.status < 4:
        time.sleep(0.2)
    resultValue = result.getMessages()
    report.write ("completed " + str(resultValue))
    
except Exception as e:
    
    # If an error occurred, print line number and error message
    import traceback, sys
    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 for " + serviceName)

Environments

This tool does not use any geoprocessing environments.