@SuppressWarnings("unchecked") private void checkForTimedOutResourceConfigurationUpdateRequests() { try { // TODO (ips): Optimize this so the query actually does the timeout check too, // i.e. "WHERE cu.createdtime > :maxCreatedTime". Query query = entityManager.createNamedQuery(ResourceConfigurationUpdate.QUERY_FIND_ALL_IN_STATUS); query.setParameter("status", ConfigurationUpdateStatus.INPROGRESS); List<ResourceConfigurationUpdate> requests = query.getResultList(); for (ResourceConfigurationUpdate request : requests) { // TODO [mazz]: should we make this configurable? long timeout = 1000L * 60 * 10; // 10 minutes - should be more than enough time long duration = request.getDuration(); if (duration > timeout) { LOG.info("Resource configuration update request seems to have been orphaned - timing it out: " + request); request.setErrorMessage("Timed out - did not complete after " + duration + " ms" + " (the timeout period was " + timeout + " ms)"); request.setStatus(ConfigurationUpdateStatus.FAILURE); // If it's part of a group update, check if all member updates of the group update have completed, // and, if so, update the group update's status. checkForCompletedGroupResourceConfigurationUpdate(request.getId()); } } } catch (Throwable t) { LOG.error("Failed to check for timed out Resource configuration update requests. Cause: " + t); } }
update.setStatus(response.getStatus()); update.setErrorMessage(response.getErrorMessage());
newUpdateRequest.setStatus(newStatus);
invalidConfig, subject.getName()); resourceConfigurationUpdate.setErrorMessage("resource.validation.failed"); resourceConfigurationUpdate.setStatus(ConfigurationUpdateStatus.FAILURE); newConfiguration, subject.getName()); resourceConfigurationUpdate.setErrorMessage(e.getMessage()); resourceConfigurationUpdate.setStatus(ConfigurationUpdateStatus.FAILURE); return resourceConfigurationUpdate;
/** * Tells the Agent to asynchronously update a managed resource's configuration as per the specified * <code>ResourceConfigurationUpdate</code>. */ private void executeResourceConfigurationUpdate(ResourceConfigurationUpdate update) { try { AgentClient agentClient = agentManager.getAgentClient(update.getResource().getAgent()); ConfigurationUpdateRequest request = new ConfigurationUpdateRequest(update.getId(), update.getConfiguration(), update.getResource().getId()); agentClient.getConfigurationAgentService().updateResourceConfiguration(request); } catch (RuntimeException e) { // Any exception means the remote call itself failed - make sure to change the status on the update to FAILURE // and set its error message field. if (null != update) { update.setStatus(ConfigurationUpdateStatus.FAILURE); update.setErrorMessage(ThrowableUtil.getStackAsString(e)); // Here we call ourselves, but we do so via the EJB interface so we pick up the REQUIRES_NEW semantics. this.configurationManager.mergeConfigurationUpdate(update); checkForCompletedGroupResourceConfigurationUpdate(update.getId()); } } }