Skip to content

Commit e6af262

Browse files
committed
Revert "[CB-18319] skip Hive database backup on upgrade"
This reverts commit 049b94b.
1 parent 6b03a05 commit e6af262

File tree

31 files changed

+103
-223
lines changed

31 files changed

+103
-223
lines changed

core-api/src/main/java/com/sequenceiq/cloudbreak/api/endpoint/v4/stacks/StackV4Endpoint.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,6 @@ FlowIdentifier updateSaltByName(@PathParam("workspaceId") Long workspaceId, @Pat
522522
@ApiOperation(value = DATABASE_BACKUP, nickname = "databaseBackup")
523523
BackupV4Response backupDatabaseByName(@PathParam("workspaceId") Long workspaceId, @PathParam("name") String name,
524524
@QueryParam("backupLocation") String backupLocation, @QueryParam("backupId") String backupId,
525-
@QueryParam("skipDatabaseNames") List<String> skipDatabaseNames,
526525
@AccountId @QueryParam("accountId") String accountId);
527526

528527
@POST
@@ -531,8 +530,7 @@ BackupV4Response backupDatabaseByName(@PathParam("workspaceId") Long workspaceId
531530
@ApiOperation(value = DATABASE_BACKUP_INTERNAL, nickname = "databaseBackupInternal")
532531
BackupV4Response backupDatabaseByNameInternal(@PathParam("workspaceId") Long workspaceId, @PathParam("name") String name,
533532
@QueryParam("backupId") String backupId, @QueryParam("backupLocation") String backupLocation,
534-
@QueryParam("closeConnections") boolean closeConnections,
535-
@QueryParam("skipDatabaseNames") List<String> skipDatabaseNames, @QueryParam("initiatorUserCrn") String initiatorUserCrn);
533+
@QueryParam("closeConnections") boolean closeConnections, @QueryParam("initiatorUserCrn") String initiatorUserCrn);
536534

537535
@POST
538536
@Path("{name}/database_restore")

core/src/main/java/com/sequenceiq/cloudbreak/controller/v4/StackV4Controller.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -439,19 +439,19 @@ public FlowIdentifier updatePillarConfigurationByCrn(Long workspaceId, @TenantAw
439439

440440
@Override
441441
@CheckPermissionByAccount(action = AuthorizationResourceAction.POWERUSER_ONLY)
442-
public BackupV4Response backupDatabaseByName(Long workspaceId, String name, String backupLocation, String backupId, List<String> skipDatabaseNames,
442+
public BackupV4Response backupDatabaseByName(Long workspaceId, String name, String backupLocation, String backupId,
443443
@AccountId String accountId) {
444444
FlowIdentifier flowIdentifier = stackOperations.backupClusterDatabase(NameOrCrn.ofName(name),
445-
restRequestThreadLocalService.getRequestedWorkspaceId(), backupLocation, backupId, true, skipDatabaseNames);
445+
restRequestThreadLocalService.getRequestedWorkspaceId(), backupLocation, backupId, true);
446446
return new BackupV4Response(flowIdentifier);
447447
}
448448

449449
@Override
450450
@InternalOnly
451451
public BackupV4Response backupDatabaseByNameInternal(Long workspaceId, String name, String backupId, String backupLocation,
452-
boolean closeConnections, List<String> skipDatabaseNames, @InitiatorUserCrn String initiatorUserCrn) {
452+
boolean closeConnections, @InitiatorUserCrn String initiatorUserCrn) {
453453
FlowIdentifier flowIdentifier = stackOperations.backupClusterDatabase(NameOrCrn.ofName(name),
454-
restRequestThreadLocalService.getRequestedWorkspaceId(), backupLocation, backupId, closeConnections, skipDatabaseNames);
454+
restRequestThreadLocalService.getRequestedWorkspaceId(), backupLocation, backupId, closeConnections);
455455
return new BackupV4Response(flowIdentifier);
456456
}
457457

core/src/main/java/com/sequenceiq/cloudbreak/core/flow2/chain/BackupDatalakeDatabaseFlowEventChainFactory.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public FlowTriggerEventQueue createFlowTriggerEventQueue(DatabaseBackupTriggerEv
2626
Queue<Selectable> flowEventChain = new ConcurrentLinkedQueue<>();
2727
flowEventChain.add(new StackEvent(SaltUpdateEvent.SALT_UPDATE_EVENT.event(), event.getResourceId(), event.accepted()));
2828
flowEventChain.add(new DatabaseBackupTriggerEvent(DATABASE_BACKUP_EVENT.event(), event.getResourceId(),
29-
event.getBackupLocation(), event.getBackupId(), event.isCloseConnections(), event.getSkipDatabaseNames()));
29+
event.getBackupLocation(), event.getBackupId(), event.isCloseConnections()));
3030
return new FlowTriggerEventQueue(getName(), event, flowEventChain);
3131
}
3232
}

core/src/main/java/com/sequenceiq/cloudbreak/core/flow2/cluster/datalake/dr/AbstractBackupRestoreActions.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ protected AbstractBackupRestoreActions(Class<P> payloadClass) {
2121
@Override
2222
protected BackupRestoreContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext,
2323
P payload) {
24-
return BackupRestoreContext.from(flowParameters, payload, payload.getBackupLocation(), payload.getBackupId(),
25-
payload.isCloseConnections(), payload.getSkipDatabaseNames());
24+
return BackupRestoreContext.from(flowParameters, payload, payload.getBackupLocation(), payload.getBackupId(), payload.isCloseConnections());
2625
}
2726

2827
@Override

core/src/main/java/com/sequenceiq/cloudbreak/core/flow2/cluster/datalake/dr/BackupRestoreContext.java

+11-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.dr;
22

3-
import java.util.List;
4-
53
import com.sequenceiq.cloudbreak.reactor.api.event.StackEvent;
64
import com.sequenceiq.flow.core.CommonContext;
75
import com.sequenceiq.flow.core.FlowParameters;
@@ -16,21 +14,24 @@ public class BackupRestoreContext extends CommonContext {
1614

1715
private final boolean closeConnections;
1816

19-
private final List<String> skipDatabaseNames;
20-
21-
public BackupRestoreContext(FlowParameters flowParameters, StackEvent event, String backupLocation, String backupId,
22-
boolean closeConnections, List<String> skipDatabaseNames) {
17+
public BackupRestoreContext(FlowParameters flowParameters, StackEvent event, String backupLocation, String backupId, boolean closeConnections) {
2318
super(flowParameters);
2419
this.stackId = event.getResourceId();
2520
this.backupLocation = backupLocation;
2621
this.backupId = backupId;
2722
this.closeConnections = closeConnections;
28-
this.skipDatabaseNames = skipDatabaseNames;
2923
}
3024

31-
public static BackupRestoreContext from(FlowParameters flowParameters, StackEvent event, String backupLocation, String backupId,
32-
boolean closeConnections, List<String> skipDatabaseNames) {
33-
return new BackupRestoreContext(flowParameters, event, backupLocation, backupId, closeConnections, skipDatabaseNames);
25+
public BackupRestoreContext(FlowParameters flowParameters, Long stackId, String backupLocation, String backupId) {
26+
super(flowParameters);
27+
this.stackId = stackId;
28+
this.backupLocation = backupLocation;
29+
this.backupId = backupId;
30+
this.closeConnections = true;
31+
}
32+
33+
public static BackupRestoreContext from(FlowParameters flowParameters, StackEvent event, String backupLocation, String backupId, boolean closeConnections) {
34+
return new BackupRestoreContext(flowParameters, event, backupLocation, backupId, closeConnections);
3435
}
3536

3637
public Long getStackId() {
@@ -48,8 +49,4 @@ public String getBackupId() {
4849
public boolean getCloseConnections() {
4950
return closeConnections;
5051
}
51-
52-
public List<String> getSkipDatabaseNames() {
53-
return skipDatabaseNames;
54-
}
5552
}

core/src/main/java/com/sequenceiq/cloudbreak/core/flow2/cluster/datalake/dr/backup/DatabaseBackupActions.java

+12-13
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,6 @@
22

33
import static com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.dr.backup.DatabaseBackupEvent.DATABASE_BACKUP_FAIL_HANDLED_EVENT;
44

5-
import java.util.Map;
6-
import java.util.Optional;
7-
8-
import javax.inject.Inject;
9-
10-
import org.springframework.context.annotation.Bean;
11-
import org.springframework.context.annotation.Configuration;
12-
import org.springframework.statemachine.StateContext;
13-
import org.springframework.statemachine.action.Action;
14-
155
import com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus;
166
import com.sequenceiq.cloudbreak.common.event.Selectable;
177
import com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.dr.AbstractBackupRestoreActions;
@@ -27,6 +17,16 @@
2717
import com.sequenceiq.flow.core.FlowParameters;
2818
import com.sequenceiq.flow.core.FlowState;
2919

20+
import java.util.Map;
21+
import java.util.Optional;
22+
23+
import javax.inject.Inject;
24+
25+
import org.springframework.context.annotation.Bean;
26+
import org.springframework.context.annotation.Configuration;
27+
import org.springframework.statemachine.StateContext;
28+
import org.springframework.statemachine.action.Action;
29+
3030
@Configuration
3131
public class DatabaseBackupActions {
3232

@@ -45,8 +45,7 @@ protected void doExecute(BackupRestoreContext context, DatabaseBackupTriggerEven
4545

4646
@Override
4747
protected Selectable createRequest(BackupRestoreContext context) {
48-
return new DatabaseBackupRequest(context.getStackId(), context.getBackupLocation(), context.getBackupId(),
49-
context.getCloseConnections(), context.getSkipDatabaseNames());
48+
return new DatabaseBackupRequest(context.getStackId(), context.getBackupLocation(), context.getBackupId(), context.getCloseConnections());
5049
}
5150

5251
@Override
@@ -82,7 +81,7 @@ protected BackupRestoreContext createFlowContext(FlowParameters flowParameters,
8281
DatabaseBackupFailedEvent payload) {
8382
Flow flow = getFlow(flowParameters.getFlowId());
8483
flow.setFlowFailed(payload.getException());
85-
return BackupRestoreContext.from(flowParameters, payload, null, null, true, payload.getSkipDatabaseNames());
84+
return BackupRestoreContext.from(flowParameters, payload, null, null, true);
8685
}
8786

8887
@Override

core/src/main/java/com/sequenceiq/cloudbreak/core/flow2/cluster/datalake/dr/restore/DatabaseRestoreActions.java

+11-11
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,6 @@
22

33
import static com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.dr.restore.DatabaseRestoreEvent.DATABASE_RESTORE_FAIL_HANDLED_EVENT;
44

5-
import java.util.Map;
6-
import java.util.Optional;
7-
8-
import javax.inject.Inject;
9-
10-
import org.springframework.context.annotation.Bean;
11-
import org.springframework.context.annotation.Configuration;
12-
import org.springframework.statemachine.StateContext;
13-
import org.springframework.statemachine.action.Action;
14-
155
import com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus;
166
import com.sequenceiq.cloudbreak.common.event.Selectable;
177
import com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.dr.AbstractBackupRestoreActions;
@@ -27,6 +17,16 @@
2717
import com.sequenceiq.flow.core.FlowParameters;
2818
import com.sequenceiq.flow.core.FlowState;
2919

20+
import java.util.Map;
21+
import java.util.Optional;
22+
23+
import javax.inject.Inject;
24+
25+
import org.springframework.context.annotation.Bean;
26+
import org.springframework.context.annotation.Configuration;
27+
import org.springframework.statemachine.StateContext;
28+
import org.springframework.statemachine.action.Action;
29+
3030
@Configuration
3131
public class DatabaseRestoreActions {
3232

@@ -81,7 +81,7 @@ protected BackupRestoreContext createFlowContext(FlowParameters flowParameters,
8181
DatabaseRestoreFailedEvent payload) {
8282
Flow flow = getFlow(flowParameters.getFlowId());
8383
flow.setFlowFailed(payload.getException());
84-
return BackupRestoreContext.from(flowParameters, payload, null, null, true, payload.getSkipDatabaseNames());
84+
return BackupRestoreContext.from(flowParameters, payload, null, null, true);
8585
}
8686

8787
@Override

core/src/main/java/com/sequenceiq/cloudbreak/core/flow2/event/DatabaseBackupTriggerEvent.java

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.sequenceiq.cloudbreak.core.flow2.event;
22

3-
import java.util.List;
43
import java.util.Objects;
54

65
import com.fasterxml.jackson.annotation.JsonCreator;
@@ -14,9 +13,12 @@
1413

1514
public class DatabaseBackupTriggerEvent extends BackupRestoreEvent {
1615

17-
public DatabaseBackupTriggerEvent(String selector, Long stackId, String backupLocation, String backupId,
18-
boolean closeConnections, List<String> skipDatabaseNames) {
19-
super(selector, stackId, backupLocation, backupId, closeConnections, skipDatabaseNames);
16+
public DatabaseBackupTriggerEvent(String selector, Long stackId, String backupLocation, String backupId, boolean closeConnections) {
17+
super(selector, stackId, backupLocation, backupId, closeConnections);
18+
}
19+
20+
public DatabaseBackupTriggerEvent(String selector, Long stackId, String backupLocation, String backupId) {
21+
super(selector, stackId, backupLocation, backupId);
2022
}
2123

2224
@JsonCreator
@@ -26,9 +28,8 @@ public DatabaseBackupTriggerEvent(
2628
@JsonIgnoreDeserialization @JsonProperty("accepted") Promise<AcceptResult> accepted,
2729
@JsonProperty("backupLocation") String backupLocation,
2830
@JsonProperty("backupId") String backupId,
29-
@JsonProperty("closeConnections") boolean closeConnections,
30-
@JsonProperty("skipDatabaseNames") List<String> skipDatabaseNames) {
31-
super(event, resourceId, accepted, backupLocation, backupId, closeConnections, skipDatabaseNames);
31+
@JsonProperty("closeConnections") boolean closeConnections) {
32+
super(event, resourceId, accepted, backupLocation, backupId, closeConnections);
3233
}
3334

3435
@Override

core/src/main/java/com/sequenceiq/cloudbreak/core/flow2/event/DatabaseRestoreTriggerEvent.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public DatabaseRestoreTriggerEvent(
2424
@JsonIgnoreDeserialization @JsonProperty("accepted") Promise<AcceptResult> accepted,
2525
@JsonProperty("backupLocation") String backupLocation,
2626
@JsonProperty("backupId") String backupId) {
27-
super(event, resourceId, accepted, backupLocation, backupId, true);
27+
super(event, resourceId, accepted, backupLocation, backupId);
2828
}
2929

3030
@Override

core/src/main/java/com/sequenceiq/cloudbreak/core/flow2/service/ReactorFlowManager.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -396,11 +396,9 @@ public FlowIdentifier triggerPillarConfigurationUpdate(Long stackId) {
396396
return reactorNotifier.notify(stackId, selector, new StackEvent(selector, stackId));
397397
}
398398

399-
public FlowIdentifier triggerDatalakeDatabaseBackup(Long stackId, String location, String backupId,
400-
boolean closeConnections, List<String> skipDatabaseNames) {
399+
public FlowIdentifier triggerDatalakeDatabaseBackup(Long stackId, String location, String backupId, boolean closeConnections) {
401400
String selector = FlowChainTriggers.DATALAKE_DATABASE_BACKUP_CHAIN_TRIGGER_EVENT;
402-
return reactorNotifier.notify(stackId, selector, new DatabaseBackupTriggerEvent(selector, stackId,
403-
location, backupId, closeConnections, skipDatabaseNames));
401+
return reactorNotifier.notify(stackId, selector, new DatabaseBackupTriggerEvent(selector, stackId, location, backupId, closeConnections));
404402
}
405403

406404
public FlowIdentifier triggerDatalakeDatabaseRestore(Long stackId, String location, String backupId) {
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package com.sequenceiq.cloudbreak.reactor.api.event.cluster.dr;
22

3-
import java.util.Collections;
4-
import java.util.List;
5-
63
import com.fasterxml.jackson.annotation.JsonCreator;
74
import com.fasterxml.jackson.annotation.JsonProperty;
85
import com.sequenceiq.cloudbreak.common.event.AcceptResult;
@@ -19,34 +16,33 @@ public class BackupRestoreEvent extends StackEvent {
1916

2017
private final boolean closeConnections;
2118

22-
private final List<String> skipDatabaseNames;
23-
2419
public BackupRestoreEvent(Long stackId, String backupLocation, String backupId) {
2520
this (null, stackId, backupLocation, backupId);
2621
}
2722

23+
public BackupRestoreEvent(Long stackId, String backupLocation, String backupId, boolean closeConnections) {
24+
this(null, stackId, backupLocation, backupId, closeConnections);
25+
}
26+
2827
public BackupRestoreEvent(String selector, Long stackId, String backupLocation, String backupId) {
2928
super(selector, stackId);
3029
this.backupLocation = backupLocation;
3130
this.backupId = backupId;
3231
this.closeConnections = true;
33-
this.skipDatabaseNames = Collections.emptyList();
3432
}
3533

36-
public BackupRestoreEvent(String selector, Long stackId, String backupLocation, String backupId, boolean closeConnections, List<String> skipDatabaseNames) {
34+
public BackupRestoreEvent(String selector, Long stackId, String backupLocation, String backupId, boolean closeConnections) {
3735
super(selector, stackId);
3836
this.backupLocation = backupLocation;
3937
this.backupId = backupId;
4038
this.closeConnections = closeConnections;
41-
this.skipDatabaseNames = skipDatabaseNames;
4239
}
4340

44-
public BackupRestoreEvent(String selector, Long stackId, Promise<AcceptResult> accepted, String backupLocation, String backupId, boolean closeConnections) {
41+
public BackupRestoreEvent(String selector, Long stackId, Promise<AcceptResult> accepted, String backupLocation, String backupId) {
4542
super(selector, stackId, accepted);
4643
this.backupLocation = backupLocation;
4744
this.backupId = backupId;
48-
this.closeConnections = closeConnections;
49-
this.skipDatabaseNames = Collections.emptyList();
45+
this.closeConnections = true;
5046
}
5147

5248
@JsonCreator
@@ -56,13 +52,11 @@ public BackupRestoreEvent(
5652
@JsonIgnoreDeserialization @JsonProperty("accepted") Promise<AcceptResult> accepted,
5753
@JsonProperty("backupLocation") String backupLocation,
5854
@JsonProperty("backupId") String backupId,
59-
@JsonProperty("closeConnections") boolean closeConnections,
60-
@JsonProperty("skipDatabaseNames") List<String> skipDatabaseNames) {
55+
@JsonProperty("closeConnections") boolean closeConnections) {
6156
super(selector, stackId, accepted);
6257
this.backupLocation = backupLocation;
6358
this.backupId = backupId;
6459
this.closeConnections = closeConnections;
65-
this.skipDatabaseNames = skipDatabaseNames;
6660
}
6761

6862
public String getBackupLocation() {
@@ -76,8 +70,4 @@ public String getBackupId() {
7670
public boolean isCloseConnections() {
7771
return closeConnections;
7872
}
79-
80-
public List<String> getSkipDatabaseNames() {
81-
return skipDatabaseNames;
82-
}
8373
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package com.sequenceiq.cloudbreak.reactor.api.event.cluster.dr.backup;
22

3-
import java.util.List;
4-
53
import com.fasterxml.jackson.annotation.JsonCreator;
64
import com.fasterxml.jackson.annotation.JsonProperty;
75
import com.sequenceiq.cloudbreak.reactor.api.event.cluster.dr.BackupRestoreEvent;
@@ -13,8 +11,7 @@ public DatabaseBackupRequest(
1311
@JsonProperty("resourceId") Long stackId,
1412
@JsonProperty("backupLocation") String backupLocation,
1513
@JsonProperty("backupId") String backupId,
16-
@JsonProperty("closeConnections") boolean closeConnections,
17-
@JsonProperty("skipDatabaseNames") List<String> skipDatabaseNames) {
18-
super(null, stackId, backupLocation, backupId, closeConnections, skipDatabaseNames);
14+
@JsonProperty("closeConnections") boolean closeConnections) {
15+
super(stackId, backupLocation, backupId, closeConnections);
1916
}
2017
}

0 commit comments

Comments
 (0)