转换地图服务器缓存存储格式 (Server)

许可等级:BasicStandardAdvanced

摘要

在松散格式和紧凑格式之间转换地图或影像服务缓存的存储。此工具可直接转换格式,这意味着它不会复制缓存的现有格式。而是在同一个缓存文件夹中创建新格式的缓存,并删除旧的格式。

如果您认为自己以后可能会返回到旧的格式,则请在运行此工具前对您的缓存进行备份。

用法

语法

ConvertMapServerCacheStorageFormat_server (input_service, {num_of_caching_service_instances})
参数说明数据类型
input_service

待转换缓存格式所属的地图或影像服务。

这是一个包含服务器和服务器信息的字符串。要查看构建此字符串的方法,请打开 ArcCatalog,选择“目录”树中的服务,并注意位置 工具条中的文本。然后将反斜线改为正斜线,例如,MYSERVER (admin)/USA.MapServer 上的 GIS Servers/arcgis

String
num_of_caching_service_instances
(可选)

专用于运行该工具的系统/缓存工具服务实例的总数。您可以通过与 ArcGIS Server 的管理连接,使用 服务编辑器 窗口,增加系统/缓存工具服务的每台计算机的最大实例数。确保您的服务器计算机可以支持所选数量的实例。

Long

代码实例

ConvertMapServerCacheStorageFormat 示例

转换某服务的缓存存储格式

# 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 "

环境

此工具不使用任何地理处理环境

相关主题

许可信息

ArcGIS for Desktop Basic:是
ArcGIS for Desktop Standard:是
ArcGIS for Desktop Advanced:是
9/15/2013