use of com.intellij.remoteServer.impl.runtime.deployment.DeploymentImpl in project intellij-community by JetBrains.
the class ServerConnectionImpl method getDeployments.
@NotNull
@Override
public Collection<Deployment> getDeployments() {
Set<Deployment> result = new LinkedHashSet<>();
Map<Deployment, DeploymentImpl> orderedDeployments = new TreeMap<>(getServer().getType().getDeploymentComparator());
synchronized (myLocalDeployments) {
synchronized (myRemoteDeployments) {
for (LocalDeploymentImpl localDeployment : myLocalDeployments.values()) {
localDeployment.setRemoteDeployment(null);
orderedDeployments.put(localDeployment, localDeployment);
}
result.addAll(orderedDeployments.keySet());
for (DeploymentImpl remoteDeployment : myRemoteDeployments.values()) {
DeploymentImpl deployment = orderedDeployments.get(remoteDeployment);
if (deployment != null) {
if (deployment instanceof LocalDeploymentImpl) {
((LocalDeploymentImpl) deployment).setRemoteDeployment(remoteDeployment);
}
} else {
orderedDeployments.put(remoteDeployment, remoteDeployment);
}
}
result.addAll(orderedDeployments.keySet());
}
}
return result;
}
use of com.intellij.remoteServer.impl.runtime.deployment.DeploymentImpl 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