bug4811: preparing for "remove application replica set" use case

This commit is contained in:
Axel Uhl committed 2021-03-11 23:43:59 +01:00
1 parent b868ad333f
commit fc53606424
5 files changed
+54 -2

No files matched your search

@@ -39,6 +39,7 @@ import com.sap.sse.gwt.client.ErrorReporter;
import com.sap.sse.gwt.client.Notification;
import com.sap.sse.gwt.client.Notification.NotificationType;
import com.sap.sse.gwt.client.celltable.ActionsColumn;
import com.sap.sse.gwt.client.celltable.EntityIdentityComparator;
import com.sap.sse.gwt.client.celltable.TableWrapperWithSingleSelectionAndFilter;
import com.sap.sse.gwt.client.controls.busyindicator.BusyIndicator;
import com.sap.sse.gwt.client.controls.busyindicator.SimpleBusyIndicator;
@@ -173,7 +174,20 @@ public class LandscapeManagementPanel extends SimplePanel {
// application replica sets:
applicationReplicaSetsTable = new TableWrapperWithSingleSelectionAndFilter<SailingApplicationReplicaSetDTO<String>, StringMessages, AdminConsoleTableResources>(
stringMessages, errorReporter, /* enablePager */ false,
/* entity identity comparator */ Optional.empty(), GWT.create(AdminConsoleTableResources.class),
/* entity identity comparator */ Optional.of(new EntityIdentityComparator<SailingApplicationReplicaSetDTO<String>>() {
@Override
public boolean representSameEntity(SailingApplicationReplicaSetDTO<String> dto1,
SailingApplicationReplicaSetDTO<String> dto2) {
// TODO Auto-generated method stub
return false;
}
@Override
public int hashCode(SailingApplicationReplicaSetDTO<String> t) {
// TODO Auto-generated method stub
return 0;
}
}), GWT.create(AdminConsoleTableResources.class),
/* checkbox filter function */ Optional.empty(), /* filter label */ Optional.empty(),
/* filter checkbox label */ null) {
@Override
@@ -350,7 +364,20 @@ public class LandscapeManagementPanel extends SimplePanel {
private void removeApplicationReplicaSet(StringMessages stringMessages, String regionId,
SailingApplicationReplicaSetDTO<String> applicationReplicaSetToRemove) {
if (Window.confirm(stringMessages.reallyRemoveApplicationReplicaSet(applicationReplicaSetToRemove.getName()))) {
// TODO implement LandscapeManagementPanel.removeApplicationReplicaSet
applicationReplicaSetsBusy.setBusy(true);
landscapeManagementService.removeApplicationReplicaSet(applicationReplicaSetToRemove, new AsyncCallback<Void>() {
@Override
public void onFailure(Throwable caught) {
applicationReplicaSetsBusy.setBusy(false);
errorReporter.reportError(caught.getMessage());
}
@Override
public void onSuccess(Void result) {
applicationReplicaSetsBusy.setBusy(false);
applicationReplicaSetsTable.getFilterPanel().remove(applicationReplicaSetToRemove);
}
});
}
}
@@ -71,4 +71,6 @@ public interface LandscapeManagementWriteService extends RemoteService {
String securityReplicationBearerToken, String optionalDomainName) throws Exception;
void defineDefaultRedirect(String regionId, String hostname, RedirectDTO redirect, String keyName, String passphraseForPrivateKeyDecryption);
void removeApplicationReplicaSet(SailingApplicationReplicaSetDTO<String> applicationReplicaSetToRemove);
}
@@ -94,4 +94,7 @@ public interface LandscapeManagementWriteServiceAsync {
void defineDefaultRedirect(String regionId, String hostname, RedirectDTO redirect, String keyName,
String passphraseForPrivateKeyDecryption, AsyncCallback<Void> asyncCallback);
void removeApplicationReplicaSet(SailingApplicationReplicaSetDTO<String> applicationReplicaSetToRemove,
AsyncCallback<Void> asyncCallback);
}
@@ -620,4 +620,23 @@ public class LandscapeManagementWriteServiceImpl extends ResultCachingProxiedRem
SailingApplicationReplicaSetDTO<String> sailingApplicationReplicationSetDTO) {
return null;
}
@Override
public void removeApplicationReplicaSet(SailingApplicationReplicaSetDTO<String> applicationReplicaSetToRemove) {
/*
* TODO implement removeApplicationReplicaSet; will probably need to enumerate things again, starting from the
* master and replica processes and their hosts where the DTO tells us the respective regions; we also know the
* hostname. So we can look for the load balancer rules having this hostname in their hostname header, and for
* any S3 records, and hopefully re-use some of the logic used in getApplicationReplicaSets. At least do the
* following:
*
* - remove the auto scaling group
* - remove the launch configuration used by the auto scaling group
* - terminate the instances
* - remove the load balancer rules
* - remove the target groups
* - remove the load balancer if it is a DNS-mapped one and there are no rules left other than the default rule
* - remove the DNS record if this replica set was a DNS-mapped one
*/
}
}
@@ -101,6 +101,7 @@ extends AbstractAwsProcedureImpl<ShardingKey> {
final ScheduledExecutorService executor = ThreadPoolUtil.INSTANCE.createBackgroundTaskThreadPoolExecutor(2, "MongoDB MD5 Hasher "+UUID.randomUUID());
final Future<String> sourceMd5 = executor.submit(()->sourceDatabase.getMD5Hash());
final Future<String> targetMd5 = executor.submit(()->targetDatabase.getMD5Hash());
executor.shutdown();
if (sourceMd5.get().equals(targetMd5.get())) {
logger.info("Databases "+sourceDatabase+" and "+targetDatabase+" have equal MD5 hash "+sourceMd5.get()+". Removing "+sourceDatabase+" and "+Util.joinStrings(", ", additionalDatabasesToDelete));
sourceDatabase.drop();