/** * Checks whether the service that is being deployed is already marked as a faulty service * * @param deploymentFileData DeploymentFileData instance corresponding to the service being * deployed. * @return Boolean representing the existence of the service as a faulty * service */ private boolean isFaultyService(DeploymentFileData deploymentFileData) { String faultyServiceFilePath = deploymentFileData.getFile().getAbsolutePath(); AxisService faultyService = CarbonUtils.getFaultyService(faultyServiceFilePath, this.configCtx); return faultyService != null; }
private void storeFaultyService(DeploymentFileData deploymentFileData, Throwable t) { StringWriter errorWriter = new StringWriter(); PrintWriter ptintWriter = new PrintWriter(errorWriter); t.printStackTrace(ptintWriter); String error = "Error:\n" + errorWriter.toString(); configCtx.getAxisConfiguration().getFaultyServices(). put(deploymentFileData.getFile().getAbsolutePath(), error); }
private void storeFaultyService(DeploymentFileData deploymentFileData, Throwable t) { StringWriter errorWriter = new StringWriter(); PrintWriter ptintWriter = new PrintWriter(errorWriter); t.printStackTrace(ptintWriter); String error = "Error:\n" + errorWriter.toString(); configCtx.getAxisConfiguration().getFaultyServices(). put(deploymentFileData.getFile().getAbsolutePath(), error); }
public void deploy(DeploymentFileData deploymentFileData) throws DeploymentException { log.info("Deploying HumanTask archive [ " + deploymentFileData.getName() + " ]"); try { humanTaskStore.deploy(deploymentFileData.getFile()); } catch (Exception e) { String errorMessage = "Error deploying HumanTask package : " + deploymentFileData.getName(); log.error(errorMessage, e); throw new DeploymentException(errorMessage, e); } }
/** * Removes a faulty service for a given module from the internal map. * * TODO: Doesn't this actually remove a faulty service *group*? And should this even be public? * * @param moduleName name of the module to look up * @param serviceGroupName name of the service group to remove */ public void removeFaultyServiceDuetoModule(String moduleName, String serviceGroupName) { synchronized (faultyServicesDueToModules) { Map<String, FaultyServiceData> faultyServicesDueToModule = faultyServicesDueToModules.get(moduleName); FaultyServiceData faultyServiceData = faultyServicesDueToModule.get(serviceGroupName); if (faultyServicesDueToModule != null) { faultyServicesDueToModule.remove(serviceGroupName); //Removing from the default faulty services map. String serviceLocation = null; if (faultyServiceData.getCurrentDeploymentFile() != null) { serviceLocation = faultyServiceData.getCurrentDeploymentFile().getFile().getAbsolutePath(); } if (serviceLocation == null) { serviceLocation = faultyServiceData.getServiceGroupName(); } faultyServices.remove(serviceLocation); if (faultyServicesDueToModule.isEmpty()) { faultyServicesDueToModules.remove(moduleName); } } } }
/** * Removes a faulty service for a given module from the internal map. * * TODO: Doesn't this actually remove a faulty service *group*? And should this even be public? * * @param moduleName name of the module to look up * @param serviceGroupName name of the service group to remove */ public void removeFaultyServiceDuetoModule(String moduleName, String serviceGroupName) { synchronized (faultyServicesDueToModules) { Map<String, FaultyServiceData> faultyServicesDueToModule = faultyServicesDueToModules.get(moduleName); FaultyServiceData faultyServiceData = faultyServicesDueToModule.get(serviceGroupName); if (faultyServicesDueToModule != null) { faultyServicesDueToModule.remove(serviceGroupName); //Removing from the default faulty services map. String serviceLocation = null; if (faultyServiceData.getCurrentDeploymentFile() != null) { serviceLocation = faultyServiceData.getCurrentDeploymentFile().getFile().getAbsolutePath(); } if (serviceLocation == null) { serviceLocation = faultyServiceData.getServiceGroupName(); } faultyServices.remove(serviceLocation); if (faultyServicesDueToModule.isEmpty()) { faultyServicesDueToModules.remove(moduleName); } } } }
/** * Updates the map that keeps track of faulty services due to modules * @param moduleName This service has become faulty due this module. * @param faultyServiceData Data that are required when recovering the faulty service. */ public void addFaultyServiceDuetoModule(String moduleName, FaultyServiceData faultyServiceData) { Map<String, FaultyServiceData> faultyServicesMap; synchronized (faultyServicesDueToModules) { if (faultyServicesDueToModules.containsKey(moduleName)) { faultyServicesMap = faultyServicesDueToModules.get(moduleName); faultyServicesMap.put(faultyServiceData.getServiceGroupName(), faultyServiceData); } else { faultyServicesMap = new HashMap<String, FaultyServiceData>(); faultyServicesMap.put(faultyServiceData.getServiceGroupName(), faultyServiceData); faultyServicesDueToModules.put(moduleName, faultyServicesMap); } //Adding the faulty service to default service map String serviceStatus = "Error:\n" + "Engaged module not found :" + moduleName; String serviceLocation = null; if(faultyServiceData.getCurrentDeploymentFile() != null){ serviceLocation = faultyServiceData.getCurrentDeploymentFile().getFile().getAbsolutePath(); } if(serviceLocation == null){ serviceLocation = faultyServiceData.getServiceGroupName(); } faultyServices.put(serviceLocation, serviceStatus); } }
/** * Updates the map that keeps track of faulty services due to modules * @param moduleName This service has become faulty due this module. * @param faultyServiceData Data that are required when recovering the faulty service. */ public void addFaultyServiceDuetoModule(String moduleName, FaultyServiceData faultyServiceData) { Map<String, FaultyServiceData> faultyServicesMap; synchronized (faultyServicesDueToModules) { if (faultyServicesDueToModules.containsKey(moduleName)) { faultyServicesMap = faultyServicesDueToModules.get(moduleName); faultyServicesMap.put(faultyServiceData.getServiceGroupName(), faultyServiceData); } else { faultyServicesMap = new HashMap<String, FaultyServiceData>(); faultyServicesMap.put(faultyServiceData.getServiceGroupName(), faultyServiceData); faultyServicesDueToModules.put(moduleName, faultyServicesMap); } //Adding the faulty service to default service map String serviceStatus = "Error:\n" + "Engaged module not found :" + moduleName; String serviceLocation = null; if(faultyServiceData.getCurrentDeploymentFile() != null){ serviceLocation = faultyServiceData.getCurrentDeploymentFile().getFile().getAbsolutePath(); } if(serviceLocation == null){ serviceLocation = faultyServiceData.getServiceGroupName(); } faultyServices.put(serviceLocation, serviceStatus); } }
/** * This method checks if the given data service has a corresponding "services.xml" is available, * if so, the AxisService representing the data service is applied the instructions from its * "services.xml". */ private AxisService handleTransports(DeploymentFileData file, AxisService axisService) throws DataServiceFault { try (FileInputStream fis = new FileInputStream(file.getFile().getAbsoluteFile())) { StAXOMBuilder builder = new StAXOMBuilder(fis); OMElement documentElement = builder.getDocumentElement(); OMAttribute transports = documentElement.getAttribute(new QName(DBSFields.TRANSPORTS)); if (transports != null) { String [] transportArr = transports.getAttributeValue().split(" "); axisService.setExposedTransports(Arrays.asList(transportArr)); } } catch (Exception e) { throw new DataServiceFault(e, "Error in processing transports info"); } return axisService; }
File directory = deploymentFileData.getFile(); classList = new ArrayList<String>(); for(Iterator<File> fileItr= FileUtils.iterateFiles(directory, new String[]{"class"}, true); fileItr.hasNext();){
File directory = deploymentFileData.getFile(); classList = new ArrayList<String>(); for(Iterator<File> fileItr= FileUtils.iterateFiles(directory, new String[]{"class"}, true); fileItr.hasNext();){
OMElement eventSink = builder.getDocumentElement(); String eventSinkName = FilenameUtils.getBaseName(deploymentFileData.getFile().getName()); EventSinkStore.getInstance().addEventSink(EventSink.createEventSink(eventSink, eventSinkName)); log.info("Deploying event sink: " + eventSinkName + " - file: " + deploymentFileData.getAbsolutePath());
public void deploy(DeploymentFileData deploymentFileData) throws DeploymentException { boolean isDirectory = deploymentFileData.getFile().isDirectory(); ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); try {
public void deploy(DeploymentFileData deploymentFileData) throws DeploymentException { boolean isDirectory = deploymentFileData.getFile().isDirectory(); ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); try {
PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(this.tenantId, true); deploymentFilePath = deploymentFileData.getFile().getAbsolutePath();
public static void addServiceGroup(AxisServiceGroup serviceGroup, ArrayList<AxisService> serviceList, URL serviceLocation, DeploymentFileData currentDeploymentFile, AxisConfiguration axisConfiguration) throws AxisFault { if (isServiceGroupReadyToDeploy(serviceGroup, serviceList, serviceLocation, currentDeploymentFile, axisConfiguration)) { fillServiceGroup(serviceGroup, serviceList, serviceLocation, axisConfiguration); axisConfiguration.addServiceGroup(serviceGroup); if (currentDeploymentFile != null) { addAsWebResources(currentDeploymentFile.getFile(), serviceGroup.getServiceGroupName(), serviceGroup); // let the system have hidden services if (!JavaUtils.isTrueExplicitly(serviceGroup.getParameterValue( Constants.HIDDEN_SERVICE_PARAM_NAME))) { log.info(Messages.getMessage(DeploymentErrorMsgs.DEPLOYING_WS, currentDeploymentFile.getName(), serviceLocation.toString())); } } else if (!JavaUtils.isTrueExplicitly(serviceGroup.getParameterValue( Constants.HIDDEN_SERVICE_PARAM_NAME))) { log.info(Messages.getMessage(DeploymentErrorMsgs.DEPLOYING_WS, serviceGroup.getServiceGroupName(), "")); } } }
public void deploy(DeploymentFileData deploymentFileData) throws DeploymentException { if (AnalyticsEventSinkServerStartupObserver.getInstance().isServerStarted()) { log.info("Deploying analytics event store: " + deploymentFileData.getName()); int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); try { AnalyticsEventStore eventStoreConfiguration = AnalyticsEventStoreManager.getInstance() .getAnalyticsEventStore(deploymentFileData.getFile()); if (AnalyticsEventSinkUtil.getAnalyticsEventStoreName(deploymentFileData.getName()). equalsIgnoreCase(eventStoreConfiguration.getName())) { addEventStore(tenantId, eventStoreConfiguration); } else { throw new AnalyticsEventStoreDeploymentException("Invalid configuration provided! File name: " + AnalyticsEventSinkUtil.getAnalyticsEventStoreName(deploymentFileData.getName() + " should be " + "matched with deduced table name: " + eventStoreConfiguration.getName() + " for the streams")); } } catch (AnalyticsEventStoreException e) { String errMsg = "Error while deploying file: " + deploymentFileData.getName() + " for tenant id: " + tenantId; log.error(errMsg, e); throw new AnalyticsEventStoreDeploymentException(errMsg, e); } catch (Exception e) { String errorMsg = "Unable to deploy the event store: " + deploymentFileData.getName() + ". " + e.getMessage(); log.error(errorMsg, e); throw new AnalyticsEventStoreDeploymentException(errorMsg, e); } log.info("Deployed successfully analytics event store: " + deploymentFileData.getName()); } else { pausedDeployments.add(deploymentFileData); } }
public static void addServiceGroup(AxisServiceGroup serviceGroup, ArrayList<AxisService> serviceList, URL serviceLocation, DeploymentFileData currentDeploymentFile, AxisConfiguration axisConfiguration) throws AxisFault { if (isServiceGroupReadyToDeploy(serviceGroup, serviceList, serviceLocation, currentDeploymentFile, axisConfiguration)) { fillServiceGroup(serviceGroup, serviceList, serviceLocation, axisConfiguration); axisConfiguration.addServiceGroup(serviceGroup); if (currentDeploymentFile != null) { addAsWebResources(currentDeploymentFile.getFile(), serviceGroup.getServiceGroupName(), serviceGroup); // let the system have hidden services if (!JavaUtils.isTrueExplicitly(serviceGroup.getParameterValue( Constants.HIDDEN_SERVICE_PARAM_NAME))) { log.info(Messages.getMessage(DeploymentErrorMsgs.DEPLOYING_WS, currentDeploymentFile.getName(), serviceLocation.toString())); } } else if (!JavaUtils.isTrueExplicitly(serviceGroup.getParameterValue( Constants.HIDDEN_SERVICE_PARAM_NAME))) { log.info(Messages.getMessage(DeploymentErrorMsgs.DEPLOYING_WS, serviceGroup.getServiceGroupName(), "")); } } }
File executionPlanFile = deploymentFileData.getFile(); boolean isEditable = !executionPlanFile.getAbsolutePath().contains(File.separator + "carbonapps" + File.separator); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();