-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] Support Cluster Snapshot Backup: checkpoint and image backu…
…p (part3) (#54695) Signed-off-by: srlch <[email protected]> (cherry picked from commit e332116) # Conflicts: # fe/fe-core/src/main/java/com/starrocks/fs/hdfs/HdfsFsManager.java # fe/fe-core/src/test/java/com/starrocks/lake/ClusterSnapshotTest.java
- Loading branch information
1 parent
0a074ee
commit b4ba25c
Showing
22 changed files
with
929 additions
and
53 deletions.
There are no files selected for viewing
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
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
117 changes: 117 additions & 0 deletions
117
fe/fe-core/src/main/java/com/starrocks/lake/snapshot/ClusterSnapshot.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,117 @@ | ||
// Copyright 2021-present StarRocks, Inc. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package com.starrocks.lake.snapshot; | ||
|
||
import com.google.gson.annotations.SerializedName; | ||
import com.starrocks.server.GlobalStateMgr; | ||
import com.starrocks.server.StorageVolumeMgr; | ||
import com.starrocks.storagevolume.StorageVolume; | ||
import com.starrocks.thrift.TClusterSnapshotsItem; | ||
|
||
public class ClusterSnapshot { | ||
public enum ClusterSnapshotType { AUTOMATED, MANUAL, INCREMENTAL } | ||
|
||
@SerializedName(value = "id") | ||
private long id; | ||
@SerializedName(value = "snapshotName") | ||
private String snapshotName; | ||
@SerializedName(value = "type") | ||
private ClusterSnapshotType type; | ||
@SerializedName(value = "storageVolumeName") | ||
private String storageVolumeName; | ||
@SerializedName(value = "createdTime") | ||
private long createdTime; | ||
@SerializedName(value = "finishedTime") | ||
private long finishedTime; | ||
@SerializedName(value = "feJournalId") | ||
private long feJournalId; | ||
@SerializedName(value = "starMgrJournal") | ||
private long starMgrJournalId; | ||
|
||
public ClusterSnapshot() {} | ||
|
||
public ClusterSnapshot(long id, String snapshotName, String storageVolumeName, long createdTime, | ||
long finishedTime, long feJournalId, long starMgrJournalId) { | ||
this.id = id; | ||
this.snapshotName = snapshotName; | ||
this.type = ClusterSnapshotType.AUTOMATED; | ||
this.storageVolumeName = storageVolumeName; | ||
this.createdTime = createdTime; | ||
this.finishedTime = finishedTime; | ||
this.feJournalId = feJournalId; | ||
this.starMgrJournalId = starMgrJournalId; | ||
} | ||
|
||
public void setJournalIds(long feJournalId, long starMgrJournalId) { | ||
this.feJournalId = feJournalId; | ||
this.starMgrJournalId = starMgrJournalId; | ||
} | ||
|
||
public void setFinishedTime(long finishedTime) { | ||
this.finishedTime = finishedTime; | ||
} | ||
|
||
public String getSnapshotName() { | ||
return snapshotName; | ||
} | ||
|
||
public String getStorageVolumeName() { | ||
return storageVolumeName; | ||
} | ||
|
||
public long getCreatedTime() { | ||
return createdTime; | ||
} | ||
|
||
public long getFinishedTime() { | ||
return finishedTime; | ||
} | ||
|
||
public long getFeJournalId() { | ||
return feJournalId; | ||
} | ||
|
||
public long getStarMgrJournalId() { | ||
return starMgrJournalId; | ||
} | ||
|
||
public long getId() { | ||
return id; | ||
} | ||
|
||
public TClusterSnapshotsItem getInfo() { | ||
TClusterSnapshotsItem item = new TClusterSnapshotsItem(); | ||
item.setSnapshot_name(snapshotName); | ||
item.setSnapshot_type(type.name()); | ||
item.setCreated_time(createdTime / 1000); | ||
item.setFinished_time(finishedTime / 1000); | ||
item.setFe_jouranl_id(feJournalId); | ||
item.setStarmgr_jouranl_id(starMgrJournalId); | ||
item.setProperties(""); | ||
item.setStorage_volume(storageVolumeName); | ||
|
||
StorageVolumeMgr storageVolumeMgr = GlobalStateMgr.getCurrentState().getStorageVolumeMgr(); | ||
try { | ||
StorageVolume sv = storageVolumeMgr.getStorageVolumeByName(storageVolumeName); | ||
if (sv == null) { | ||
throw new Exception("Unknown storage volume: " + storageVolumeName); | ||
} | ||
item.setStorage_path(ClusterSnapshotUtils.getSnapshotImagePath(sv, snapshotName)); | ||
} catch (Exception e) { | ||
item.setStorage_path(""); | ||
} | ||
return item; | ||
} | ||
} |
Oops, something went wrong.