mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-14 22:43:57 +00:00
bug5627: copying tags to new target groups; various smaller fixes
This commit is contained in:
1 parent
f8b7bae7d6
commit
fcc5f71695
10 files changed
+84
-81
No files matched your search
+1
-5
@@ -312,7 +312,6 @@ public class LandscapeManagementPanel extends SimplePanel {
|
||||
return new LinkBuilder().setReplicaSet(replicaSet).setRegion(regionsTable.getSelectionModel().getSelectedObject()).setPathMode(LinkBuilder.pathModes.AmiSearch).build();
|
||||
}
|
||||
};
|
||||
|
||||
applicationReplicaSetsTable.addColumn(autoScalingGroupAmiIdColumn, stringMessages.machineImageId(), (rs1, rs2)->new NaturalComparator().compare(rs1.getAutoScalingGroupAmiId(), rs2.getAutoScalingGroupAmiId()));
|
||||
final ActionsColumn<SailingApplicationReplicaSetDTO<String>, ApplicationReplicaSetsImagesBarCell> applicationReplicaSetsActionColumn = new ActionsColumn<SailingApplicationReplicaSetDTO<String>, ApplicationReplicaSetsImagesBarCell>(
|
||||
new ApplicationReplicaSetsImagesBarCell(userService, stringMessages), /* permission checker */ (applicationReplicaSet, action)->true);
|
||||
@@ -350,10 +349,7 @@ public class LandscapeManagementPanel extends SimplePanel {
|
||||
regionsTable.getSelectionModel().getSelectedObject(),
|
||||
Collections.singleton(applicationReplicaSetToUpgrade)));
|
||||
applicationReplicaSetsActionColumn.addAction(ApplicationReplicaSetsImagesBarCell.ACTION_OPEN_SHARD_MANAGEMENT,
|
||||
selected -> {
|
||||
openShardManagementPanel(stringMessages, regionsTable.getSelectionModel().getSelectedObject(),
|
||||
selected);
|
||||
});
|
||||
selectedReplicaSet -> openShardManagementPanel(stringMessages, regionsTable.getSelectionModel().getSelectedObject(), selectedReplicaSet));
|
||||
// see below for the finalization o the applicationRelicaSetsActionColumn; we need to have the machineImagesTable ready for the last action...
|
||||
final CaptionPanel applicationReplicaSetsCaptionPanel = new CaptionPanel(stringMessages.applicationReplicaSets());
|
||||
final VerticalPanel applicationReplicaSetsVerticalPanel = new VerticalPanel();
|
||||
|
||||
+2
-2
@@ -154,7 +154,7 @@ public interface LandscapeManagementWriteService extends RemoteService {
|
||||
|
||||
public void removeShard(AwsShardDTO shard, SailingApplicationReplicaSetDTO<String> replicaset, String region, byte[] passphrase) throws Exception;
|
||||
|
||||
void appendShardingKeysToShard(Iterable<LeaderboardNameDTO> selectedLeaderBoardNames, String region, String shardName, SailingApplicationReplicaSetDTO<String> replicaset, String bearertoken, byte[] passphraseForPrivateKeyDecryption) throws Exception;
|
||||
void appendShardingKeysToShard(Iterable<LeaderboardNameDTO> shardingKeysToAppend, String region, String shardName, SailingApplicationReplicaSetDTO<String> replicaSet, String bearerToken, byte[] passphraseForPrivateKeyDecryption) throws Exception;
|
||||
|
||||
void removeShardingKeysToShard(Iterable<LeaderboardNameDTO> selectedShardingKeys, String region, String shardName, SailingApplicationReplicaSetDTO<String> replicaset, String bearertoken, byte[] passphraseForPrivateKeyDecryption) throws Exception;
|
||||
void removeShardingKeysFromShard(Iterable<LeaderboardNameDTO> shardingKeysToRemove, String region, String shardName, SailingApplicationReplicaSetDTO<String> replicaSet, String bearerToken, byte[] passphraseForPrivateKeyDecryption) throws Exception;
|
||||
}
|
||||
+3
-3
@@ -197,11 +197,11 @@ public interface LandscapeManagementWriteServiceAsync {
|
||||
String instanceTypeName, String optionalKeyName, byte[] privateKeyEncryptionPassphrase,
|
||||
AsyncCallback<SailingApplicationReplicaSetDTO<String>> callback);
|
||||
|
||||
void getLeaderboardNames(SailingApplicationReplicaSetDTO<String> replicaset, String bearertoken,
|
||||
void getLeaderboardNames(SailingApplicationReplicaSetDTO<String> replicaSet, String bearerToken,
|
||||
AsyncCallback<ArrayList<LeaderboardNameDTO>> names);
|
||||
|
||||
void addShard(String shardName, ArrayList<LeaderboardNameDTO> selectedLeaderBoards,
|
||||
SailingApplicationReplicaSetDTO<String> replicaset, String bearertoken, String region,
|
||||
SailingApplicationReplicaSetDTO<String> replicaSet, String bearerToken, String region,
|
||||
byte[] passphraseForPrivateKeyDecryption, AsyncCallback<Void> callback);
|
||||
|
||||
void getShards(SailingApplicationReplicaSetDTO<String> replicaset, String region, String bearertoken,
|
||||
@@ -267,7 +267,7 @@ public interface LandscapeManagementWriteServiceAsync {
|
||||
* @param passphraseForPrivateKeyDecryption
|
||||
* @param callback
|
||||
*/
|
||||
void removeShardingKeysToShard(Iterable<LeaderboardNameDTO> selectedLeaderBoards, String region, String shardName,
|
||||
void removeShardingKeysFromShard(Iterable<LeaderboardNameDTO> selectedLeaderBoards, String region, String shardName,
|
||||
SailingApplicationReplicaSetDTO<String> replicaset, String bearertoken,
|
||||
byte[] passphraseForPrivateKeyDecryption, AsyncCallback<Void> callback);
|
||||
}
|
||||
+20
-20
@@ -41,7 +41,7 @@ public class ShardManagementPanel extends SimplePanel {
|
||||
private final TableWrapperWithMultiSelectionAndFilter<LeaderboardNameDTO, StringMessages, AdminConsoleTableResources> regattasTable;
|
||||
private final TableWrapperWithMultiSelectionAndFilter<AwsShardDTO, StringMessages, AdminConsoleTableResources> shardTable;
|
||||
private final TableWrapperWithMultiSelectionAndFilter<LeaderboardNameDTO, StringMessages, AdminConsoleTableResources> selectedKeysTable;
|
||||
private final TextBox baerertokenText;
|
||||
private final TextBox bearertokenText;
|
||||
private SailingApplicationReplicaSetDTO<String> replicaSet;
|
||||
private final BusyIndicator shardBusy;
|
||||
private final BusyIndicator leaderboardsBusy;
|
||||
@@ -106,11 +106,11 @@ public class ShardManagementPanel extends SimplePanel {
|
||||
actionPanel.add(removeShardButton);
|
||||
mainPanel.add(actionPanel);
|
||||
final HorizontalPanel usercredentials = new HorizontalPanel();
|
||||
baerertokenText = new TextBox();
|
||||
bearertokenText = new TextBox();
|
||||
final Label brearerhinttext = new Label(stringMessages.bearerTokenOrNullForApplicationReplicaSetToArchive(""));
|
||||
brearerhinttext.getElement().getStyle().setFontSize(15, Unit.PX);
|
||||
usercredentials.add(brearerhinttext);
|
||||
usercredentials.add(baerertokenText);
|
||||
usercredentials.add(bearertokenText);
|
||||
mainPanel.add(usercredentials);
|
||||
shardsCaption = new CaptionPanel(StringMessages.INSTANCE.shard());
|
||||
shardTable.addColumn(t -> t.getName(), StringMessages.INSTANCE.shardname());
|
||||
@@ -269,9 +269,8 @@ public class ShardManagementPanel extends SimplePanel {
|
||||
|
||||
private void getLeaderboards() {
|
||||
setLeaderboardBusy(true);
|
||||
landscapeManagementService.getLeaderboardNames(replicaSet, baerertokenText.getValue(),
|
||||
landscapeManagementService.getLeaderboardNames(replicaSet, getBearerToken(),
|
||||
new AsyncCallback<ArrayList<LeaderboardNameDTO>>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(ArrayList<LeaderboardNameDTO> result) {
|
||||
leaderboards = result;
|
||||
@@ -282,15 +281,19 @@ public class ShardManagementPanel extends SimplePanel {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
errorReporter.reportError("Error while retriving regattas.");
|
||||
|
||||
setLeaderboardBusy(false);
|
||||
setShardTableBusy(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void getShards() {
|
||||
landscapeManagementService.getShards(replicaSet, region, baerertokenText.getValue(),
|
||||
new AsyncCallback<Map<AwsShardDTO, Iterable<LeaderboardNameDTO>>>() {
|
||||
private String getBearerToken() {
|
||||
return Util.hasLength(bearertokenText.getValue()) ? bearertokenText.getValue(): null;
|
||||
}
|
||||
|
||||
private void getShards() {
|
||||
landscapeManagementService.getShards(replicaSet, region, getBearerToken(),
|
||||
new AsyncCallback<Map<AwsShardDTO, Iterable<LeaderboardNameDTO>>>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
errorReporter.reportError(caught.getMessage());
|
||||
@@ -302,16 +305,11 @@ public class ShardManagementPanel extends SimplePanel {
|
||||
shards = result;
|
||||
setShardTableBusy(false);
|
||||
display();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void addShardButtonPress() {
|
||||
if (baerertokenText.getValue() == null || baerertokenText.getValue() == "") {
|
||||
errorReporter.reportError("Please enter a bearertoken");
|
||||
return;
|
||||
}
|
||||
Set<LeaderboardNameDTO> selectedLeaderboards = regattasTable.getSelectionModel().getSelectedSet();
|
||||
if (!selectedLeaderboards.isEmpty() && replicaSet != null) {
|
||||
DialogBox nameRequest = new DialogBox(false);
|
||||
@@ -336,8 +334,7 @@ public class ShardManagementPanel extends SimplePanel {
|
||||
ArrayList<LeaderboardNameDTO> l = new ArrayList<>();
|
||||
l.addAll(selectedLeaderboards);
|
||||
landscapeManagementService.addShard(nameText.getValue(), l, replicaSet,
|
||||
baerertokenText.getValue(), region, passphrase.getBytes(), new AsyncCallback<Void>() {
|
||||
|
||||
getBearerToken(), region, passphrase.getBytes(), new AsyncCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void result) {
|
||||
Notification.notify("Created succesfully", NotificationType.SUCCESS);
|
||||
@@ -362,7 +359,6 @@ public class ShardManagementPanel extends SimplePanel {
|
||||
for (AwsShardDTO selection : shardTable.getSelectionModel().getSelectedSet()) {
|
||||
landscapeManagementService.removeShard(selection, replicaSet, region, passphrase.getBytes(),
|
||||
new AsyncCallback<Void>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
errorReporter.reportError(caught.getMessage());
|
||||
@@ -386,14 +382,16 @@ public class ShardManagementPanel extends SimplePanel {
|
||||
final Iterable<LeaderboardNameDTO> selectedLeaderboards = regattasTable.getSelectionModel().getSelectedSet();
|
||||
final AwsShardDTO shard = shardTable.getSelectionModel().getSelectedSet().iterator().next();
|
||||
landscapeManagementService.appendShardingKeysToShard(selectedLeaderboards, region, shard.getName(),
|
||||
replicaSet, baerertokenText.getValue(), passphrase.getBytes(), new AsyncCallback<Void>() {
|
||||
replicaSet, getBearerToken(), passphrase.getBytes(), new AsyncCallback<Void>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
setLeaderboardBusy(false);
|
||||
errorReporter.reportError(caught.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Void result) {
|
||||
setLeaderboardBusy(false);
|
||||
appendMessage(stringMessages.successfullyAppendedShardingKeysToShard(Util.join(", ", selectedLeaderboards), shard.getName()));
|
||||
refresh();
|
||||
}
|
||||
@@ -408,15 +406,17 @@ public class ShardManagementPanel extends SimplePanel {
|
||||
&& shardTable.getSelectionModel().getSelectedSet().size() == 1) {
|
||||
final Iterable<LeaderboardNameDTO> selectedLeaderboards = selectedKeysTable.getSelectionModel().getSelectedSet();
|
||||
final AwsShardDTO shard = shardTable.getSelectionModel().getSelectedSet().iterator().next();
|
||||
landscapeManagementService.removeShardingKeysToShard(selectedLeaderboards, region, shard.getName(),
|
||||
replicaSet, baerertokenText.getValue(), passphrase.getBytes(), new AsyncCallback<Void>() {
|
||||
landscapeManagementService.removeShardingKeysFromShard(selectedLeaderboards, region, shard.getName(),
|
||||
replicaSet, getBearerToken(), passphrase.getBytes(), new AsyncCallback<Void>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
setLeaderboardBusy(false);
|
||||
errorReporter.reportError(caught.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Void result) {
|
||||
setLeaderboardBusy(false);
|
||||
appendMessage(stringMessages.successfullyRemovedLeaderboardsFromShard(Util.join(", ", selectedLeaderboards), shard.getName()));
|
||||
refresh();
|
||||
}
|
||||
|
||||
+18
-20
@@ -876,16 +876,15 @@ public class LandscapeManagementWriteServiceImpl extends ResultCachingProxiedRem
|
||||
|
||||
@Override
|
||||
public Map<AwsShardDTO, Iterable<LeaderboardNameDTO>> getShards(SailingApplicationReplicaSetDTO<String> replicaSetDTO,
|
||||
String region, String bearertoken) throws Exception {
|
||||
String region, String bearerToken) throws Exception {
|
||||
checkLandscapeManageAwsPermission();
|
||||
final AwsRegion awsRegion = new AwsRegion(replicaSetDTO.getMaster().getHost().getRegion(), getLandscape());
|
||||
final Map<AwsShardDTO, Iterable<String>> shardsDTO = new HashMap<>();
|
||||
SailingServer server = getLandscapeService().getSailingServer(replicaSetDTO.getHostname(), bearertoken,
|
||||
final SailingServer server = getLandscapeService().getSailingServer(replicaSetDTO.getHostname(), bearerToken,
|
||||
Optional.empty());
|
||||
final AwsApplicationReplicaSet<String, SailingAnalyticsMetrics, SailingAnalyticsProcess<String>> applicationServerReplicaSet = convertFromApplicationReplicaSetDTO(
|
||||
awsRegion, replicaSetDTO);
|
||||
|
||||
Map<String, String> mapping = new HashMap<>();
|
||||
final Map<String, String> mapping = new HashMap<>();
|
||||
for (String leaderboard : server.getLeaderboardNames()) {
|
||||
mapping.put(server.getLeaderboardShardingKey(leaderboard), leaderboard);
|
||||
}
|
||||
@@ -893,7 +892,7 @@ public class LandscapeManagementWriteServiceImpl extends ResultCachingProxiedRem
|
||||
shardsDTO.put(createAwsShardDTO(entry.getKey(), applicationServerReplicaSet.getName(), server, mapping),
|
||||
entry.getValue());
|
||||
}
|
||||
Map<AwsShardDTO, Iterable<LeaderboardNameDTO>> res = new HashMap<>();
|
||||
final Map<AwsShardDTO, Iterable<LeaderboardNameDTO>> res = new HashMap<>();
|
||||
for (Entry<AwsShardDTO, Iterable<String>> entry : shardsDTO.entrySet()) {
|
||||
res.put(entry.getKey(), Util.asList(Util.map(entry.getValue(), LeaderboardNameDTO::new)));
|
||||
}
|
||||
@@ -911,33 +910,32 @@ public class LandscapeManagementWriteServiceImpl extends ResultCachingProxiedRem
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendShardingKeysToShard(Iterable<LeaderboardNameDTO> selectedLeaderBoardnames, String region,
|
||||
String shardName, SailingApplicationReplicaSetDTO<String> replicaSetDTO, String bearertoken,
|
||||
public void appendShardingKeysToShard(Iterable<LeaderboardNameDTO> sharindKeysToAppend, String region,
|
||||
String shardName, SailingApplicationReplicaSetDTO<String> replicaSet, String bearerToken,
|
||||
byte[] passphraseForPrivateKeyDecryption) throws Exception {
|
||||
checkLandscapeManageAwsPermission();
|
||||
final AwsRegion awsRegion = new AwsRegion(replicaSetDTO.getMaster().getHost().getRegion(), getLandscape());
|
||||
final AwsApplicationReplicaSet<String, SailingAnalyticsMetrics, SailingAnalyticsProcess<String>> replicaSet = convertFromApplicationReplicaSetDTO(
|
||||
awsRegion, replicaSetDTO);
|
||||
final AwsRegion awsRegion = new AwsRegion(replicaSet.getMaster().getHost().getRegion(), getLandscape());
|
||||
final AwsApplicationReplicaSet<String, SailingAnalyticsMetrics, SailingAnalyticsProcess<String>> rs = convertFromApplicationReplicaSetDTO(
|
||||
awsRegion, replicaSet);
|
||||
final AwsApplicationReplicaSet<String, SailingAnalyticsMetrics, SailingAnalyticsProcess<String>> applicationReplicaSet = getLandscape()
|
||||
.getApplicationReplicaSet(awsRegion, replicaSet.getServerName(), replicaSet.getMaster(),
|
||||
replicaSet.getReplicas());
|
||||
getLandscapeService().appendShardingKeysToShard(Util.map(selectedLeaderBoardnames, t -> t.getName()),
|
||||
applicationReplicaSet, passphraseForPrivateKeyDecryption, awsRegion, shardName, bearertoken);
|
||||
.getApplicationReplicaSet(awsRegion, rs.getServerName(), rs.getMaster(), rs.getReplicas());
|
||||
getLandscapeService().appendShardingKeysToShard(Util.map(sharindKeysToAppend, t -> t.getName()),
|
||||
applicationReplicaSet, passphraseForPrivateKeyDecryption, awsRegion, shardName, bearerToken);
|
||||
}
|
||||
|
||||
public void removeShardingKeysToShard(Iterable<LeaderboardNameDTO> selectedShardingKeys, String region,
|
||||
String shardName, SailingApplicationReplicaSetDTO<String> replicaset, String bearertoken,
|
||||
public void removeShardingKeysFromShard(Iterable<LeaderboardNameDTO> selectedShardingKeys, String region,
|
||||
String shardName, SailingApplicationReplicaSetDTO<String> replicaSet, String bearerToken,
|
||||
byte[] passphraseForPrivateKeyDecryption) throws Exception {
|
||||
checkLandscapeManageAwsPermission();
|
||||
final AwsRegion awsRegion = new AwsRegion(region, getLandscape());
|
||||
final AwsApplicationReplicaSet<String, SailingAnalyticsMetrics, SailingAnalyticsProcess<String>> replicaSet = convertFromApplicationReplicaSetDTO(
|
||||
awsRegion, replicaset);
|
||||
final AwsApplicationReplicaSet<String, SailingAnalyticsMetrics, SailingAnalyticsProcess<String>> rs = convertFromApplicationReplicaSetDTO(
|
||||
awsRegion, replicaSet);
|
||||
getLandscapeService().removeShardingKeysFromShard(Util.asList(Util.map(selectedShardingKeys, t -> t.getName())),
|
||||
replicaSet, passphraseForPrivateKeyDecryption, awsRegion, shardName, bearertoken);
|
||||
rs, passphraseForPrivateKeyDecryption, awsRegion, shardName, bearerToken);
|
||||
}
|
||||
|
||||
public AwsShardDTO createAwsShardDTO(AwsShard<String> shard, String replicaSetName, SailingServer server, Map<String, String> leaderboardMapping) throws Exception {
|
||||
return new AwsShardDTO(Util.map(shard.getKeys(), t -> leaderboardMapping.get(t)),
|
||||
return new AwsShardDTO(Util.filter(Util.map(shard.getKeys(), t -> leaderboardMapping.get(t)), leaderboardName->leaderboardName!=null),
|
||||
shard.getTargetGroup().getTargetGroupArn(), shard.getTargetGroup().getName(),
|
||||
shard.getAutoScalingGroup().getAutoScalingGroup().autoScalingGroupARN(),
|
||||
shard.getTargetGroup().getLoadBalancerArn(), shard.getAutoScalingGroup().getName(),
|
||||
|
||||
+11
-9
@@ -1593,11 +1593,11 @@ public class LandscapeServiceImpl implements LandscapeService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SailingServer getSailingServer(String hostname, String bearertoken, Optional<Integer> port)
|
||||
public SailingServer getSailingServer(String hostname, String bearerToken, Optional<Integer> port)
|
||||
throws MalformedURLException {
|
||||
final SailingServerFactory fac = sailingServerFactoryTracker.getService();
|
||||
return fac.getSailingServer(RemoteServerUtil.getBaseServerUrl(hostname,
|
||||
port.isPresent() ? port.get() : /* defaults to HTTPS */ 443), bearertoken);
|
||||
port.orElse(443 /* defaults to HTTPS */)), bearerToken);
|
||||
}
|
||||
|
||||
private <BuilderT extends ShardProcedure.Builder<BuilderT, CreateShard<String, SailingAnalyticsMetrics, SailingAnalyticsProcess<String>>, String, SailingAnalyticsMetrics, SailingAnalyticsProcess<String>>> com.sap.sse.landscape.aws.orchestration.ShardProcedure.Builder<BuilderT, CreateShard<String, SailingAnalyticsMetrics, SailingAnalyticsProcess<String>>, String, SailingAnalyticsMetrics, SailingAnalyticsProcess<String>> createShardBuilder() {
|
||||
@@ -1617,11 +1617,10 @@ public class LandscapeServiceImpl implements LandscapeService {
|
||||
@Override
|
||||
public void removeShardingKeysFromShard(Iterable<String> selectedleaderboards,
|
||||
AwsApplicationReplicaSet<String, SailingAnalyticsMetrics, SailingAnalyticsProcess<String>> applicationReplicaSet,
|
||||
byte[] passphraseForPrivateKeyDecription, AwsRegion region, String shardName, String bearertoken)
|
||||
byte[] passphraseForPrivateKeyDecription, AwsRegion region, String shardName, String bearerToken)
|
||||
throws Exception {
|
||||
final SailingServer server = getSailingServer(applicationReplicaSet.getHostname(), bearertoken,
|
||||
final SailingServer server = getSailingServer(applicationReplicaSet.getHostname(), bearerToken,
|
||||
/* HTTPS port */ Optional.of(443));
|
||||
|
||||
Set<String> shardingKeys = new HashSet<>();
|
||||
for (String leaderboardName : selectedleaderboards) {
|
||||
shardingKeys.add(server.getLeaderboardShardingKey(leaderboardName));
|
||||
@@ -1631,11 +1630,12 @@ public class LandscapeServiceImpl implements LandscapeService {
|
||||
.setPassphrase(passphraseForPrivateKeyDecription).build().run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendShardingKeysToShard(Iterable<String> selectedLeaderboards,
|
||||
AwsApplicationReplicaSet<String, SailingAnalyticsMetrics, SailingAnalyticsProcess<String>> applicationReplicaSet,
|
||||
byte[] passphraseForPrivateKeyDecription, AwsRegion region, String shardName, String bearertoken)
|
||||
byte[] passphraseForPrivateKeyDecription, AwsRegion region, String shardName, String bearerToken)
|
||||
throws Exception {
|
||||
final SailingServer server = getSailingServer(applicationReplicaSet.getHostname(), bearertoken,
|
||||
final SailingServer server = getSailingServer(applicationReplicaSet.getHostname(), bearerToken,
|
||||
/* HTTPS port */ Optional.of(443));
|
||||
final Set<String> shardingkeys = new HashSet<String>();
|
||||
for (String s : selectedLeaderboards) {
|
||||
@@ -1646,6 +1646,7 @@ public class LandscapeServiceImpl implements LandscapeService {
|
||||
.setPassphrase(passphraseForPrivateKeyDecription).build().run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeShard(
|
||||
AwsApplicationReplicaSet<String, SailingAnalyticsMetrics, SailingAnalyticsProcess<String>> applicationReplicaSet,
|
||||
String shardTargetGroupArn) throws Exception {
|
||||
@@ -1657,11 +1658,12 @@ public class LandscapeServiceImpl implements LandscapeService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addShard(Iterable<String> selectedLeaderboardNames,
|
||||
AwsApplicationReplicaSet<String, SailingAnalyticsMetrics, SailingAnalyticsProcess<String>> applicationReplicaSet,
|
||||
AwsRegion region, String bearertoken, byte[] passphraseForPrivateKeyDecription, String shardName)
|
||||
AwsRegion region, String bearerToken, byte[] passphraseForPrivateKeyDecription, String shardName)
|
||||
throws Exception {
|
||||
final SailingServer server = getSailingServer(applicationReplicaSet.getHostname(), bearertoken,
|
||||
final SailingServer server = getSailingServer(applicationReplicaSet.getHostname(), bearerToken,
|
||||
Optional.of(443));
|
||||
final Set<String> shardingkeys = new HashSet<String>();
|
||||
for (final String s : selectedLeaderboardNames) {
|
||||
|
||||
+5
-1
@@ -69,7 +69,11 @@ public class SailingServerImpl extends SecuredServerImpl implements SailingServe
|
||||
public Iterable<String> getLeaderboardNames() throws Exception {
|
||||
final URL leaderboardsUrl = new URL(getBaseUrl(), GATEWAY_URL_PREFIX+LeaderboardsResource.V1_LEADERBOARDS);
|
||||
final HttpGet getLeaderboards = new HttpGet(leaderboardsUrl.toString());
|
||||
final JSONArray jsonResponse = (JSONArray) getJsonParsedResponse(getLeaderboards).getA();
|
||||
final Pair<Object, Integer> jsonParsedResponse = getJsonParsedResponse(getLeaderboards);
|
||||
final JSONArray jsonResponse = (JSONArray) jsonParsedResponse.getA();
|
||||
if (jsonResponse == null) {
|
||||
throw new IllegalAccessError("Error accessing leaderboard names; response status "+jsonParsedResponse.getB());
|
||||
}
|
||||
return Util.map(jsonResponse, o->o.toString());
|
||||
}
|
||||
|
||||
|
||||
+5
-1
@@ -2036,8 +2036,12 @@ public class AwsLandscapeImpl<ShardingKey> implements AwsLandscape<ShardingKey>
|
||||
.availabilityZones(availabilityZones)
|
||||
.targetGroupARNs(targetgroup.getTargetGroupArn())
|
||||
.launchConfigurationName(launchConfigurationName);
|
||||
final List<software.amazon.awssdk.services.autoscaling.model.Tag> awsTags = new ArrayList<>();
|
||||
final List<software.amazon.awssdk.services.autoscaling.model.TagDescription> parentTags = autoscalingParent.getAutoScalingGroup().tags();
|
||||
for (final software.amazon.awssdk.services.autoscaling.model.TagDescription parentTag : parentTags) {
|
||||
awsTags.add(software.amazon.awssdk.services.autoscaling.model.Tag.builder().key(parentTag.key()).value(parentTag.value()).build());
|
||||
}
|
||||
tags.ifPresent(t->{
|
||||
final List<software.amazon.awssdk.services.autoscaling.model.Tag> awsTags = new ArrayList<>();
|
||||
for (final Entry<String, String> tag : t) {
|
||||
awsTags.add(software.amazon.awssdk.services.autoscaling.model.Tag.builder().key(tag.getKey()).value(tag.getValue()).build());
|
||||
}
|
||||
|
||||
+16
-19
@@ -2,13 +2,13 @@ package com.sap.sse.landscape.aws.orchestration;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.sap.sse.common.Duration;
|
||||
import com.sap.sse.common.HttpRequestHeaderConstants;
|
||||
import com.sap.sse.common.Util;
|
||||
import com.sap.sse.landscape.Landscape;
|
||||
import com.sap.sse.landscape.application.ApplicationProcess;
|
||||
import com.sap.sse.landscape.application.ApplicationProcessMetrics;
|
||||
import com.sap.sse.landscape.aws.ApplicationLoadBalancer;
|
||||
@@ -43,6 +43,7 @@ public class CreateShard<ShardingKey, MetricsT extends ApplicationProcessMetrics
|
||||
|
||||
private static int DEFAULT_INSTANCE_STARTUP_TIME = 180;
|
||||
private static final Logger logger = Logger.getLogger(ShardProcedure.class.getName());
|
||||
private static final String PATH_UNUSED_BY_ANY_APPLICATION = "lauycaluy3cla3yrclaurlIYQL8";
|
||||
|
||||
public CreateShard(BuilderImpl<?, ShardingKey, MetricsT, ProcessT> builder) throws Exception {
|
||||
super(builder);
|
||||
@@ -51,7 +52,6 @@ public class CreateShard<ShardingKey, MetricsT extends ApplicationProcessMetrics
|
||||
static class BuilderImpl<BuilderT extends Builder<BuilderT, CreateShard<ShardingKey, MetricsT, ProcessT>, ShardingKey, MetricsT, ProcessT>, ShardingKey, MetricsT extends ApplicationProcessMetrics, ProcessT extends ApplicationProcess<ShardingKey, MetricsT, ProcessT>>
|
||||
extends
|
||||
ShardProcedure.BuilderImpl<BuilderT, CreateShard<ShardingKey, MetricsT, ProcessT>, ShardingKey, MetricsT, ProcessT> {
|
||||
|
||||
@Override
|
||||
public CreateShard<ShardingKey, MetricsT, ProcessT> build() throws Exception {
|
||||
assert shardingKeys != null;
|
||||
@@ -100,7 +100,7 @@ public class CreateShard<ShardingKey, MetricsT extends ApplicationProcessMetrics
|
||||
.getB()))
|
||||
.build(),
|
||||
RuleCondition.builder().field("path-pattern")
|
||||
.pathPatternConfig(ppc -> ppc.values(/* just any path */"/temp/")).build())
|
||||
.pathPatternConfig(ppc -> ppc.values(PATH_UNUSED_BY_ANY_APPLICATION)).build())
|
||||
.actions(Action.builder()
|
||||
.forwardConfig(ForwardActionConfig.builder()
|
||||
.targetGroups(TargetGroupTuple.builder()
|
||||
@@ -112,25 +112,22 @@ public class CreateShard<ShardingKey, MetricsT extends ApplicationProcessMetrics
|
||||
getLandscape().putScalingPolicy(DEFAULT_INSTANCE_STARTUP_TIME, getLandscape().getAutoScalingGroupName(shardName), targetgroup,
|
||||
AwsAutoScalingGroup.DEFAULT_MAX_REQUESTS_PER_TARGET, region);
|
||||
// wait until instances are running
|
||||
Wait.wait(new Callable<Boolean>() {
|
||||
public Boolean call() {
|
||||
boolean ret = true;
|
||||
final Map<AwsInstance<ShardingKey>, TargetHealth> healths = getLandscape()
|
||||
.getTargetHealthDescriptions(targetgroup);
|
||||
if (healths.isEmpty()) {
|
||||
ret = false; // if there is no Aws in target
|
||||
} else {
|
||||
for (Map.Entry<AwsInstance<ShardingKey>, TargetHealth> instance : healths.entrySet()) {
|
||||
if (instance.getValue().state() != TargetHealthStateEnum.HEALTHY) {
|
||||
ret = false; // if this instance is unhealthy
|
||||
break;
|
||||
}
|
||||
Wait.wait(()->{
|
||||
boolean ret = true;
|
||||
final Map<AwsInstance<ShardingKey>, TargetHealth> healths = getLandscape()
|
||||
.getTargetHealthDescriptions(targetgroup);
|
||||
if (healths.isEmpty()) {
|
||||
ret = false; // if there is no Aws in target
|
||||
} else {
|
||||
for (Map.Entry<AwsInstance<ShardingKey>, TargetHealth> instance : healths.entrySet()) {
|
||||
if (instance.getValue().state() != TargetHealthStateEnum.HEALTHY) {
|
||||
ret = false; // if this instance is unhealthy
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}, Optional.of(Duration.ONE_MINUTE.times(10)), Duration.ONE_SECOND.times(5), Level.INFO,
|
||||
"Instances not yet healty");
|
||||
return ret;
|
||||
}, Landscape.WAIT_FOR_HOST_TIMEOUT, Duration.ONE_SECOND.times(30), Level.INFO, "Instances not yet healty");
|
||||
// remove dummy-rule
|
||||
for (Rule r : newRuleSet) {
|
||||
loadBalancer.deleteRules(r);
|
||||
|
||||
@@ -12,6 +12,7 @@ import java.util.UUID;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.Status.Family;
|
||||
|
||||
import org.apache.http.HttpRequest;
|
||||
import org.apache.http.HttpResponse;
|
||||
@@ -75,7 +76,8 @@ public class SecuredServerImpl implements SecuredServer {
|
||||
final HttpResponse response = client.execute(request);
|
||||
final int statusCode = response.getStatusLine().getStatusCode();
|
||||
Object jsonParseResult;
|
||||
if (statusCode == Response.Status.NO_CONTENT.getStatusCode()) {
|
||||
if (statusCode == Response.Status.NO_CONTENT.getStatusCode()
|
||||
|| Response.Status.fromStatusCode(statusCode).getFamily() != Family.SUCCESSFUL) {
|
||||
jsonParseResult = null;
|
||||
} else {
|
||||
response.getEntity().writeTo(bos);
|
||||
|
||||
Reference in new issue
Block a user