本文整理汇总了Python中java.net.URL.toString方法的典型用法代码示例。如果您正苦于以下问题:Python URL.toString方法的具体用法?Python URL.toString怎么用?Python URL.toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.net.URL
的用法示例。
在下文中一共展示了URL.toString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_map_file
# 需要导入模块: from java.net import URL [as 别名]
# 或者: from java.net.URL import toString [as 别名]
def _get_map_file(self):
map_param = self.getParameter('map')
map_url = URL(self.getDocumentBase(), map_param)
self.showStatus('Loading ' + map_url.toString())
map_is = map_url.openStream()
map_buf = ""
i = map_is.read()
while i != -1:
map_buf = map_buf + chr(i)
i = map_is.read()
return StringIO(map_buf)
示例2: fullStatus
# 需要导入模块: from java.net import URL [as 别名]
# 或者: from java.net.URL import toString [as 别名]
def fullStatus(islandID):
islandMgr = mc.getIslandManager()
island = islandMgr.getIsland(int(islandID))
print "INFO: island status for island", islandID
print "INFO: search URL", islandID, island.getSearchURL()
print "INFO: search Parmeters", islandID, island.getSearchParms()
print "INFO: cluster and shard status for island", islandID
clusterMgr = mc.getClusterManager()
clusters = clusterMgr.enumClusters(islandID)
masters = []
slaves = []
masterURLs = []
slaveURLs = []
for cluster in clusters:
print "INFO: cluster", cluster.getID(), "F:", cluster.isFeedEnabled(), "U:", cluster.isUpdateEnabled(), "P:", cluster.isPurgeEnabled()
locs = clusterMgr.enumClusterLocations(cluster.getID())
for loc in locs:
print "INFO: location", loc.getId(), "F:", loc.isFeedEnabled(), "U:", loc.isUpdateEnabled(), "P:", loc.isPurgeEnabled(), "M:", loc.isManagementEnabled()
slaveURL = URL(loc.getClusterLocationProperty(SolrClusterAdapter.SOLR_SLAVE_HOST_URL_PROP))
slaveHost = slaveURL.getHost()
slaves.append(slaveHost)
masterURL = URL(loc.getClusterLocationProperty(SolrClusterAdapter.SOLR_MASTER_HOST_URL_PROP))
masterHost = masterURL.getHost()
masters.append(masterHost)
masterURL = masterURL.toString() + "/admin/system"
masterURLs.append(masterURL)
slaveURL = slaveURL.toString() + "/admin/system"
slaveURLs.append(slaveURL)
print "INFO: Service Status for island", islandID
service = Service("ems-solr")
service.setThreadCount(1)
responses = service.invoke("status", masters)
for key in responses.keySet():
sr = responses.get(key)
print "INFO: Master", key, sr.getStdout()
responses = service.invoke("status", slaves)
for key in responses.keySet():
sr = responses.get(key)
print "INFO: Slave", key, sr.getStdout()
print "INFO: Version Info for island", islandID
for masterURL in masterURLs:
masterF = None
try:
masterF = urllib.urlopen(masterURL)
except:
print "WARN: Solr not running on", masterURL
continue
try:
masterData = masterF.read()
look = '<str name="solr-spec-version">'
idx = masterData.find(look)
idx = idx + len(look)
end = masterData.find("</str>", idx)
print "INFO:", masterURL, masterData[idx:end]
finally:
masterF.close()
for slaveURL in slaveURLs:
slaveF = None
try:
slaveF = urllib.urlopen(slaveURL)
except:
print "WARN: Solr not running on", slaveURL
continue
try:
slaveData = slaveF.read()
look = '<str name="solr-spec-version">'
idx = slaveData.find(look)
idx = idx + len(look)
end = slaveData.find("</str>", idx)
print "INFO:", slaveURL, slaveData[idx:end]
finally:
slaveF.close()
print "INFO: Upgrade activities"
ulog = "/tmp/.solr_upgrade_log_" + str(islandID)
if os.path.exists(ulog):
for line in open(ulog):
print "INFO:", line.strip()
else:
print "INFO: No activity log found:", ulog
示例3: upgradeSlave
# 需要导入模块: from java.net import URL [as 别名]
# 或者: from java.net.URL import toString [as 别名]
def upgradeSlave(islandID):
clusterMgr = mc.getClusterManager()
clusters = clusterMgr.enumClusters(islandID)
hosts = []
for cluster in clusters:
locs = clusterMgr.enumClusterLocations(cluster.getID())
for loc in locs:
slaveURL = URL(loc.getClusterLocationProperty(SolrClusterAdapter.SOLR_SLAVE_HOST_URL_PROP))
slaveHost = slaveURL.getHost()
masterURL = URL(loc.getClusterLocationProperty(SolrClusterAdapter.SOLR_MASTER_HOST_URL_PROP))
masterURL = masterURL.toString() + "/m1Monitor?command=register"
slaveURL = slaveURL.toString()
slaveURL = slaveURL + "/m1Monitor?command=shutdown"
try:
slaveF = urllib.urlopen(slaveURL)
except:
print "WARN: slave down, expected up", slaveURL
logOutput(slaveF)
slaveF.close()
try:
masterF = urllib.urlopen(masterURL)
except:
print "ERROR: master down, must be up", masterURL
return 1
logOutput(masterF)
masterF.close()
hosts.append(slaveHost)
islandMgr = mc.getIslandManager()
retries = 5
done = False
while not done and retries > 0:
done = True
island = islandMgr.getIsland(islandID)
parms = island.getSearchParms()
for cluster in clusters:
locs = clusterMgr.enumClusterLocations(cluster.getID())
for loc in locs:
slaveURL = URL(loc.getClusterLocationProperty(SolrClusterAdapter.SOLR_SLAVE_HOST_URL_PROP)).toString()
if slaveURL in parms:
print slaveURL, "still in search params, waiting for update"
done = False
retries = retries - 1
if not done and retries == 0:
print "Unable to start slave upgrade because search URL does not show masters handling all search requests"
return 1
print "Stopping Solr on slaves"
service = Service("ems-solr")
service.setThreadCount(1)
service.invoke("stop", hosts)
print "Removing Solr service from slaves to prepare for upgrade"
failures = runJob(["/usr/local/bin/ender", "remote-action", "upgrade-support", "remove-solr-service"], hosts)
if failures.isEmpty():
print "INFO: Search is now successfully running on masters, please use Extropy to upgrade slaves"
else:
print "WARN: check logs for errors before upgrading slaves. Host(s) reporting falilure:", failures
return 0