Skip to content

Commit

Permalink
Merge pull request #8457 from mandy-chessell/oak2024
Browse files Browse the repository at this point in the history
Add refresh ALL governance engine
  • Loading branch information
mandy-chessell authored Oct 22, 2024
2 parents 9338793 + 0e5aaf0 commit 7cf47f0
Show file tree
Hide file tree
Showing 12 changed files with 320 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1296,6 +1296,28 @@ public void refreshEngineConfig(String governanceEngineName) throws InvalidPara
engineHostClient.refreshConfig(clientUserId, governanceEngineName);
}




/**
* Request that all governance engines refresh their configuration by calling the metadata server.
* This request is useful if the metadata server has an outage, particularly while the
* governance server is initializing. This request just ensures that the latest configuration
* is in use.
*
* @throws InvalidParameterException one of the parameters is null or invalid.
* @throws UserNotAuthorizedException user not authorized to issue this request.
* @throws PropertyServerException there was a problem detected by the governance engine.
*/
public void refreshEngineConfig() throws InvalidParameterException,
UserNotAuthorizedException,
PropertyServerException
{
assert engineHostClient != null;
engineHostClient.refreshConfig(clientUserId);
}


/*
* ========================================================================================
* Metadata Access Server specific services
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,22 @@ public void refreshEngineConfig(String governanceEngineName) throws InvalidPara
{
extractor.refreshEngineConfig(governanceEngineName);
}


/**
* Request that all governance engines refresh their configuration by calling the metadata server.
* This request is useful if the metadata server has an outage, particularly while the
* governance server is initializing. This request just ensures that the latest configuration
* is in use.
*
* @throws InvalidParameterException one of the parameters is null or invalid.
* @throws UserNotAuthorizedException user not authorized to issue this request.
* @throws PropertyServerException there was a problem detected by the governance engine.
*/
public void refreshEngineConfig() throws InvalidParameterException,
UserNotAuthorizedException,
PropertyServerException
{
extractor.refreshEngineConfig();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,13 @@ GET {{baseURL}}/servers/{{server}}/open-metadata/engine-host/users/{{user}}/engi
# Further Information: https://egeria-project.org/concepts/governance-engine-definition/
GET {{baseURL}}/servers/{{server}}/open-metadata/engine-host/users/{{user}}/governance-engines/{{governanceEngineName}}/refresh-config


###
# @name refreshConfig (ALL)
# Request that all governance engines refresh their configuration by calling the metadata server.
# This request is useful if the metadata server has an outage, particularly while the
# governance server is initializing. This request just ensures that the latest configuration is in use.
# Further Information: https://egeria-project.org/concepts/governance-engine-definition/
GET {{baseURL}}/servers/{{server}}/open-metadata/engine-host/users/{{user}}/governance-engines/refresh-config

###
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,26 @@ public enum EngineHostServicesAuditCode implements AuditLogMessageSet
"The server is not able to run any requests since this has not engines. It fails to start.",
"Add the qualified name for at least one engine to the engine service in this server's configuration document."),

/**
* ENGINE-HOST-SERVICES-0153 - Refreshing governance engine {0}
*/
CLEARING_ALL_GOVERNANCE_ENGINE_CONFIG("ENGINE-HOST-SERVICES-0153",
AuditLogRecordSeverityLevel.INFO,
"Refreshing governance engine {0}",
"The engine host services will call the Governance Engine OMAS in the metadata server to " +
"retrieve details of this governance engine.",
"Monitor the engine host services for errors."),

/**
* ENGINE-HOST-SERVICES-0154 - Refreshing of governance engine {0} is complete
*/
FINISHED_ALL_GOVERNANCE_ENGINE_CONFIG("ENGINE-HOST-SERVICES-0154",
AuditLogRecordSeverityLevel.INFO,
"Refreshing of governance engine {0} is complete",
"This governance engine is ready to receive governance requests for all successfully loaded " +
"governance services.",
"No action is required as long as there are no errors reported."),

/**
* ENGINE-HOST-SERVICES-2000 - {0} caught an exception {1} while processing governance action {2}; the error message was {3}
*/
Expand Down Expand Up @@ -501,6 +521,7 @@ public enum EngineHostServicesAuditCode implements AuditLogMessageSet
"The server is not able to complete the restart processing.",
"Follow the instructions for the message associated with the exception to resolve the error. You may need to restart the engine host."),


;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,32 @@ public void refreshConfig(String userId,
userId,
governanceEngineName);
}


/**
* Request that all governance engines refresh their configuration by calling the metadata server.
* This request is useful if the metadata server has an outage, particularly while the
* governance server is initializing. This request just ensures that the latest configuration
* is in use.
*
* @param userId identifier of calling user
*
* @throws InvalidParameterException one of the parameters is null or invalid.
* @throws UserNotAuthorizedException user not authorized to issue this request.
* @throws PropertyServerException there was a problem detected by the governance engine.
*/
public void refreshConfig(String userId) throws InvalidParameterException,
UserNotAuthorizedException,
PropertyServerException
{
final String methodName = "refreshConfig";
final String urlTemplate = "/servers/{0}/open-metadata/engine-host/users/{1}/governance-engines/refresh-config";

invalidParameterHandler.validateUserId(userId, methodName);

restClient.callVoidGetRESTCall(methodName,
serverPlatformRootURL + urlTemplate,
serverName,
userId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ public class GovernanceEngineMap
* @param auditLog logging destination
* @param maxPageSize maximum number of results that can be returned in a single request
*/
public GovernanceEngineMap(String localServerName,
String localServerUserId,
String localServerPassword,
public GovernanceEngineMap(String localServerName,
String localServerUserId,
String localServerPassword,
GovernanceConfigurationClient configurationClient,
GovernanceContextClient engineActionClient,
AuditLog auditLog,
int maxPageSize)
GovernanceContextClient engineActionClient,
AuditLog auditLog,
int maxPageSize)
{
governanceEngineHandlerFactoryMap = OMAGEngineServiceRegistration.getGovernanceEngineHandlerFactoryMap();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException;
import org.odpi.openmetadata.governanceservers.enginehostservices.admin.GovernanceEngineHandler;
import org.odpi.openmetadata.governanceservers.enginehostservices.enginemap.GovernanceEngineMap;
import org.odpi.openmetadata.governanceservers.enginehostservices.ffdc.EngineHostServicesAuditCode;
import org.odpi.openmetadata.governanceservers.enginehostservices.ffdc.EngineHostServicesErrorCode;
import org.odpi.openmetadata.governanceservers.enginehostservices.properties.GovernanceEngineStatus;
import org.odpi.openmetadata.governanceservers.enginehostservices.properties.GovernanceEngineSummary;
Expand Down Expand Up @@ -73,26 +74,53 @@ void refreshConfig(String governanceEngineName,
{
final String governanceEngineParameterName = "governanceEngineName";

invalidParameterHandler.validateName(governanceEngineName, governanceEngineParameterName, serviceOperationName);

if (governanceEngineHandlers == null)
{
throw new PropertyServerException(EngineHostServicesErrorCode.NO_GOVERNANCE_ENGINES.getMessageDefinition(serverName),
this.getClass().getName(),
serviceOperationName);
}

GovernanceEngineHandler handler = governanceEngineHandlers.getGovernanceEngineHandler(governanceEngineName);

if (handler == null)
if (governanceEngineName == null)
{
throw new InvalidParameterException(EngineHostServicesErrorCode.UNKNOWN_ENGINE_NAME.getMessageDefinition(governanceEngineName, serverName),
this.getClass().getName(),
serviceOperationName,
governanceEngineParameterName);
List<String> governanceEngineNames = new ArrayList<>(governanceEngineHandlers.getGovernanceEngineNames());
for (String engineName : governanceEngineNames)
{
auditLog.logMessage(serviceOperationName,
EngineHostServicesAuditCode.CLEARING_ALL_GOVERNANCE_ENGINE_CONFIG.getMessageDefinition(engineName));

GovernanceEngineHandler governanceEngineHandler = governanceEngineHandlers.getGovernanceEngineHandler(engineName);

if (governanceEngineHandler != null)
{
governanceEngineHandler.refreshConfig();
}

auditLog.logMessage(serviceOperationName,
EngineHostServicesAuditCode.FINISHED_ALL_GOVERNANCE_ENGINE_CONFIG.getMessageDefinition(engineName));
}
}
else
{
GovernanceEngineHandler governanceEngineHandler = governanceEngineHandlers.getGovernanceEngineHandler(governanceEngineName);

if (governanceEngineHandler == null)
{
throw new InvalidParameterException(EngineHostServicesErrorCode.UNKNOWN_ENGINE_NAME.getMessageDefinition(governanceEngineName, serverName),
this.getClass().getName(),
serviceOperationName,
governanceEngineParameterName);
}

auditLog.logMessage(serviceOperationName,
EngineHostServicesAuditCode.CLEARING_ALL_GOVERNANCE_ENGINE_CONFIG.getMessageDefinition(governanceEngineName));

handler.refreshConfig();
governanceEngineHandler.refreshConfig();

auditLog.logMessage(serviceOperationName,
EngineHostServicesAuditCode.FINISHED_ALL_GOVERNANCE_ENGINE_CONFIG.getMessageDefinition(governanceEngineName));

}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,49 @@ public VoidResponse refreshConfig(String serverName,
}



/**
* Request that all governance engines refresh their configuration by calling the metadata server.
* This request is useful if the metadata server has an outage, particularly while the
* governance server is initializing. This request just ensures that the latest configuration
* is in use.
*
* @param serverName name of the governance server.
* @param userId identifier of calling user
*
* @return void or
* InvalidParameterException one of the parameters is null or invalid or
* UserNotAuthorizedException user not authorized to issue this request or
* GovernanceEngineException there was a problem detected by the governance engine.
*/
public VoidResponse refreshConfig(String serverName,
String userId)
{
final String methodName = "refreshConfig";

RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName);

VoidResponse response = new VoidResponse();
AuditLog auditLog = null;

try
{
auditLog = instanceHandler.getAuditLog(userId, serverName, methodName);

instanceHandler.refreshConfig(userId, serverName, null, methodName);
}
catch (Exception error)
{
restExceptionHandler.captureExceptions(response, error, methodName, auditLog);
}

restCallLogger.logRESTCallReturn(token, response.toString());

return response;
}



/**
* Return a summary of the requested engine's status.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,35 @@ public VoidResponse refreshConfig(@PathVariable String se
{
return restAPI.refreshConfig(serverName, userId, governanceEngineName);
}


/**
* Request that all governance engines refresh their configuration by calling the metadata server.
* This request is useful if the metadata server has an outage, particularly while the
* governance server is initializing. This request just ensures that the latest configuration
* is in use.
*
* @param serverName name of the governance server.
* @param userId identifier of calling user
*
* @return void or
* InvalidParameterException one of the parameters is null or invalid or
* UserNotAuthorizedException user not authorized to issue this request or
* GovernanceEngineException there was a problem detected by the governance engine.
*/
@GetMapping(path = "/governance-engines/refresh-config")

@Operation(summary="refreshConfig",
description="Request that all governance engines refresh their configuration by calling the metadata server. " +
"This request is useful if the metadata server has an outage, particularly while the " +
"governance server is initializing. This request just ensures that the latest configuration " +
"is in use.",
externalDocs=@ExternalDocumentation(description="Further Information",
url="https://egeria-project.org/concepts/governance-engine-definition/"))

public VoidResponse refreshConfig(@PathVariable String serverName,
@PathVariable String userId)
{
return restAPI.refreshConfig(serverName, userId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,16 @@ Content-Type: application/json
GET {{baseURL}}/servers/{{viewServer}}/api/open-metadata/runtime-manager/engine-hosts/{{serverGUID}}/governance-engines/{{governanceEngineName}}/refresh-config
Authorization: Bearer {{token}}


###
# @name refreshConfig
# Request that all governance engines refresh their configuration by calling the metadata server.
# This request is useful if the metadata server has an outage, particularly while the
# governance server is initializing. This request just ensures that the latest configuration
# is in use. See https://egeria-project.org/concepts/governance-engine-definition/
GET {{baseURL}}/servers/{{viewServer}}/api/open-metadata/runtime-manager/engine-hosts/{{serverGUID}}/governance-engines/refresh-config
Authorization: Bearer {{token}}

###
# ========================================================================================
# Metadata Access Servers
Expand Down
Loading

0 comments on commit 7cf47f0

Please sign in to comment.