use of com.intellij.remoteServer.impl.runtime.log.LoggingHandlerImpl in project intellij-community by JetBrains.
the class ServerConnectionImpl method undeploy.
@Override
public void undeploy(@NotNull Deployment deployment, @NotNull final DeploymentRuntime runtime) {
final String deploymentName = deployment.getName();
final DeploymentImpl deploymentImpl;
final Map<String, ? extends DeploymentImpl> deploymentsMap;
synchronized (myLocalDeployments) {
synchronized (myRemoteDeployments) {
DeploymentImpl localDeployment = myLocalDeployments.get(deploymentName);
if (localDeployment != null) {
deploymentImpl = localDeployment;
deploymentsMap = myLocalDeployments;
} else {
DeploymentImpl remoteDeployment = myRemoteDeployments.get(deploymentName);
if (remoteDeployment != null) {
deploymentImpl = remoteDeployment;
deploymentsMap = myRemoteDeployments;
} else {
deploymentImpl = null;
deploymentsMap = null;
}
}
if (deploymentImpl != null) {
deploymentImpl.changeState(DeploymentStatus.DEPLOYED, DeploymentStatus.UNDEPLOYING, null, null);
}
}
}
myEventDispatcher.queueDeploymentsChanged(this);
DeploymentLogManagerImpl logManager = myLogManagers.get(deploymentName);
final LoggingHandlerImpl loggingHandler = logManager == null ? null : logManager.getMainLoggingHandler();
final Consumer<String> logConsumer = message -> {
if (loggingHandler == null) {
LOG.info(message);
} else {
loggingHandler.printlnSystemMessage(message);
}
};
logConsumer.consume("Undeploying '" + deploymentName + "'...");
runtime.undeploy(new DeploymentRuntime.UndeploymentTaskCallback() {
@Override
public void succeeded() {
logConsumer.consume("'" + deploymentName + "' has been undeployed successfully.");
if (deploymentImpl != null) {
synchronized (deploymentsMap) {
if (deploymentImpl.changeState(DeploymentStatus.UNDEPLOYING, DeploymentStatus.NOT_DEPLOYED, null, null)) {
deploymentsMap.remove(deploymentName);
}
}
}
DeploymentLogManagerImpl logManager = myLogManagers.remove(deploymentName);
if (logManager != null) {
logManager.disposeLogs();
}
myEventDispatcher.queueDeploymentsChanged(ServerConnectionImpl.this);
computeDeployments(myRuntimeInstance, EmptyRunnable.INSTANCE);
}
@Override
public void errorOccurred(@NotNull String errorMessage) {
logConsumer.consume("Failed to undeploy '" + deploymentName + "': " + errorMessage);
if (deploymentImpl != null) {
synchronized (deploymentsMap) {
deploymentImpl.changeState(DeploymentStatus.UNDEPLOYING, DeploymentStatus.DEPLOYED, errorMessage, runtime);
}
}
myEventDispatcher.queueDeploymentsChanged(ServerConnectionImpl.this);
}
});
}
Aggregations