Skip to content
Snippets Groups Projects
Commit 0dfe648a authored by Simon Spinner's avatar Simon Spinner
Browse files

Support removal of Containers in Wildfly Agent.

parent d3710861
No related branches found
No related tags found
No related merge requests found
......@@ -238,6 +238,11 @@ public class ModelExtractionService extends AgentController implements Service<M
if (instance instanceof RuntimeEnvironment) {
addNewRuntimeEnvironment((RuntimeEnvironment) instance);
}
} else if (event.getNotificationType().equals(ModelNotification.REMOVED_NOTIFICATION)) {
EObject instance = event.getInstance();
if (instance instanceof RuntimeEnvironment) {
removeRuntimeEnvironment((RuntimeEnvironment) instance);
}
}
}
});
......@@ -251,10 +256,26 @@ public class ModelExtractionService extends AgentController implements Service<M
}
}
public void removeRuntimeEnvironment(RuntimeEnvironment env) {
if (env.getOfClass() == RuntimeEnvironmentClasses.OPERATING_SYSTEM
&& env.getName().equalsIgnoreCase(getLocalHost().getHostName())) {
synchronized (skeleton) {
// Remove all obsolete deployment contexts
skeleton.getContainers().remove(wildFlyContainer);
skeleton.getDeployment().getDeploymentContexts().clear();
apply(skeleton);
wildFlyContainer = null;
}
}
}
public void addNewRuntimeEnvironment(RuntimeEnvironment env) {
if (env.getOfClass() == RuntimeEnvironmentClasses.OPERATING_SYSTEM
&& env.getName().equalsIgnoreCase(getLocalHost().getHostName())) {
wildFlyContainer = ModelSkeletonUtil.adopt(ModelExtractionService.this, env);
synchronized (skeleton) {
wildFlyContainer = ModelSkeletonUtil.adopt(ModelExtractionService.this, env);
skeleton.getContainers().add(wildFlyContainer);
}
}
}
......@@ -292,27 +313,29 @@ public class ModelExtractionService extends AgentController implements Service<M
boolean changed = false;
while ((current = updates.poll()) != null) {
if (current instanceof InvocationRecord) {
handleInvocation((InvocationRecord) current);
changed = true;
synchronized (skeleton) {
while ((current = updates.poll()) != null) {
if (current instanceof InvocationRecord) {
handleInvocation((InvocationRecord) current);
changed = true;
}
}
}
if (wildFlyContainer != null) {
for (AssemblyContext curContext : undeployedAssemblyContexts) {
DeploymentContext curDeployment = DeploymentFactory.eINSTANCE.createDeploymentContext();
curDeployment.setName(toName(curContext.getName() + "@" + wildFlyContainer.getName()));
curDeployment.setAssemblyContext(curContext);
curDeployment.setResourceContainer(wildFlyContainer);
ModelSkeletonUtil.insert(skeleton.getDeployment().getDeploymentContexts(), curDeployment);
changed = true;
if (wildFlyContainer != null) {
for (AssemblyContext curContext : undeployedAssemblyContexts) {
DeploymentContext curDeployment = DeploymentFactory.eINSTANCE.createDeploymentContext();
curDeployment.setName(toName(curContext.getName() + "@" + wildFlyContainer.getName()));
curDeployment.setAssemblyContext(curContext);
curDeployment.setResourceContainer(wildFlyContainer);
ModelSkeletonUtil.insert(skeleton.getDeployment().getDeploymentContexts(), curDeployment);
changed = true;
}
undeployedAssemblyContexts.clear();
}
undeployedAssemblyContexts.clear();
}
if (changed) {
apply(skeleton);
if (changed) {
apply(skeleton);
}
}
} catch (Throwable ex) {
log.error("Error updating skeleton.", ex);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment