protected void deleteAllocatedRoutes(HistoryService historyService, String processInstanceId) { HistoricVariableInstance allocatedPortsInstance = getHistoricVarInstanceValue(historyService, processInstanceId, Constants.VAR_ALLOCATED_PORTS); if (allocatedPortsInstance == null) { return; } CloudControllerClient client = getCloudFoundryClient(historyService, processInstanceId); String defaultDomain = client.getDefaultDomain() != null ? client.getDefaultDomain() .getName() : null; if (defaultDomain == null) { LOGGER.warn(Messages.COULD_NOT_COMPUTE_DEFAULT_DOMAIN); return; } Integer[] allocatedPorts = JsonUtil.fromBinaryJson((byte[]) allocatedPortsInstance.getValue(), Integer[].class); for (Integer port : allocatedPorts) { try { client.deleteRoute(port.toString(), defaultDomain); } catch (CloudOperationException e) { LOGGER.warn(format(Messages.COULD_NOT_DELETE_ROUTE_FOR_PORT, port.toString())); } } }
protected void deleteAllocatedRoutes(HistoryService historyService, String processInstanceId) { HistoricVariableInstance allocatedPortsInstance = getHistoricVarInstanceValue(historyService, processInstanceId, Constants.VAR_ALLOCATED_PORTS); if (allocatedPortsInstance == null) { return; } CloudControllerClient client = getCloudFoundryClient(historyService, processInstanceId); String defaultDomain = client.getDefaultDomain() != null ? client.getDefaultDomain() .getName() : null; if (defaultDomain == null) { LOGGER.warn(Messages.COULD_NOT_COMPUTE_DEFAULT_DOMAIN); return; } Integer[] allocatedPorts = JsonUtil.fromBinaryJson((byte[]) allocatedPortsInstance.getValue(), Integer[].class); for (Integer port : allocatedPorts) { try { client.deleteRoute(port.toString(), defaultDomain); } catch (CloudOperationException e) { LOGGER.warn(format(Messages.COULD_NOT_DELETE_ROUTE_FOR_PORT, port.toString())); } } }
public void deleteRoute(String uri, boolean portBasedRouting) { if (!portBasedRouting) { uri = UriUtil.removePort(uri); } Pair<String, String> hostAndDomain = UriUtil.getHostAndDomain(uri); if (client instanceof XsCloudControllerClient) { XsCloudControllerClient xsClient = (XsCloudControllerClient) client; xsClient.deleteRoute(hostAndDomain._1, hostAndDomain._2, UriUtil.getPath(uri)); } else { client.deleteRoute(hostAndDomain._1, hostAndDomain._2); } }