-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(restore-indices): add additional step to also clear system metad…
…ata service
- Loading branch information
1 parent
6fdf2f7
commit bfac935
Showing
9 changed files
with
120 additions
and
28 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
...c/main/java/com/linkedin/datahub/upgrade/common/steps/ClearSystemMetadataServiceStep.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.linkedin.datahub.upgrade.common.steps; | ||
|
||
import com.linkedin.datahub.upgrade.UpgradeContext; | ||
import com.linkedin.datahub.upgrade.UpgradeStep; | ||
import com.linkedin.datahub.upgrade.UpgradeStepResult; | ||
import com.linkedin.datahub.upgrade.impl.DefaultUpgradeStepResult; | ||
import com.linkedin.datahub.upgrade.nocode.NoCodeUpgrade; | ||
import com.linkedin.metadata.systemmetadata.SystemMetadataService; | ||
import java.util.function.Function; | ||
|
||
public class ClearSystemMetadataServiceStep implements UpgradeStep { | ||
|
||
private final SystemMetadataService _systemMetadataService; | ||
private final boolean _alwaysRun; | ||
|
||
public ClearSystemMetadataServiceStep( | ||
final SystemMetadataService systemMetadataService, final boolean alwaysRun) { | ||
_systemMetadataService = systemMetadataService; | ||
_alwaysRun = alwaysRun; | ||
} | ||
|
||
@Override | ||
public String id() { | ||
return "ClearSystemMetadataServiceStep"; | ||
} | ||
|
||
@Override | ||
public boolean skip(UpgradeContext context) { | ||
if (_alwaysRun) { | ||
return false; | ||
} | ||
if (context.parsedArgs().containsKey(NoCodeUpgrade.CLEAN_ARG_NAME)) { | ||
return false; | ||
} | ||
context.report().addLine("Cleanup has not been requested."); | ||
return true; | ||
} | ||
|
||
@Override | ||
public int retryCount() { | ||
return 1; | ||
} | ||
|
||
@Override | ||
public Function<UpgradeContext, UpgradeStepResult> executable() { | ||
return (context) -> { | ||
try { | ||
_systemMetadataService.clear(); | ||
} catch (Exception e) { | ||
context.report().addLine("Failed to clear system metadata service", e); | ||
return new DefaultUpgradeStepResult(id(), UpgradeStepResult.Result.FAILED); | ||
} | ||
return new DefaultUpgradeStepResult(id(), UpgradeStepResult.Result.SUCCEEDED); | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters