-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9231 from mmedenjak/hot-backup
Implement cluster backup/snapshot of hot restart store
- Loading branch information
Showing
24 changed files
with
812 additions
and
118 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
31 changes: 31 additions & 0 deletions
31
hazelcast/src/main/java/com/hazelcast/hotrestart/BackupTaskState.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,31 @@ | ||
/* | ||
* Copyright (c) 2008-2016, Hazelcast, 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 | ||
* | ||
* http://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.hazelcast.hotrestart; | ||
|
||
/** | ||
* The state of the hot restart backup task | ||
*/ | ||
public enum BackupTaskState { | ||
/** The backup task has not yet started. */ | ||
NOT_STARTED, | ||
/** The backup task is currently in progress */ | ||
IN_PROGRESS, | ||
/** The backup task has failed */ | ||
FAILURE, | ||
/** The backup task completed successfully */ | ||
SUCCESS | ||
} |
71 changes: 71 additions & 0 deletions
71
hazelcast/src/main/java/com/hazelcast/hotrestart/BackupTaskStatus.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,71 @@ | ||
/* | ||
* Copyright (c) 2008-2016, Hazelcast, 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 | ||
* | ||
* http://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.hazelcast.hotrestart; | ||
|
||
/** | ||
* The status of the hot restart backup task, including progress and state. | ||
*/ | ||
public class BackupTaskStatus { | ||
private final BackupTaskState state; | ||
private final int completed; | ||
private final int total; | ||
|
||
public BackupTaskStatus(BackupTaskState state, int completed, int total) { | ||
this.state = state; | ||
this.completed = completed; | ||
this.total = total; | ||
} | ||
|
||
public BackupTaskState getState() { | ||
return state; | ||
} | ||
|
||
public int getCompleted() { | ||
return completed; | ||
} | ||
|
||
public int getTotal() { | ||
return total; | ||
} | ||
|
||
public float getProgress() { | ||
return total > 0 ? (float) completed / total : 0; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "BackupTaskStatus{state=" + state + ", completed=" + completed + ", total=" + total + '}'; | ||
} | ||
|
||
@Override | ||
@SuppressWarnings("checkstyle:innerassignment") | ||
public boolean equals(Object obj) { | ||
final BackupTaskStatus that; | ||
return obj instanceof BackupTaskStatus | ||
&& this.completed == (that = (BackupTaskStatus) obj).completed | ||
&& this.total == that.total | ||
&& this.state == that.state; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result = state != null ? state.hashCode() : 0; | ||
result = 31 * result + completed; | ||
result = 31 * result + total; | ||
return result; | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
hazelcast/src/main/java/com/hazelcast/hotrestart/HotRestartBackupService.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,63 @@ | ||
/* | ||
* Copyright (c) 2008-2016, Hazelcast, 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 | ||
* | ||
* http://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.hazelcast.hotrestart; | ||
|
||
/** | ||
* Service for starting cluster-wide hot restart data backups, determining the local backup state and interrupting a currently | ||
* running local hot restart backup. | ||
*/ | ||
public interface HotRestartBackupService { | ||
/** The prefix for each hot restart backup directory. The backup sequence is appended to this prefix. */ | ||
String BACKUP_DIR_PREFIX = "backup-"; | ||
|
||
/** | ||
* Attempts to perform a cluster hot restart data backup. Each node will create a directory under the defined backup dir | ||
* with the name {@link #BACKUP_DIR_PREFIX} followed by the cluster time defined by this node. | ||
* The backup request is performed transactionally. This method will throw an exception if an another request (transaction) | ||
* is already in progress. If a node is already performing a backup (there is a file indicating a backup is in progress), | ||
* the node will only log a warning and ignore the backup request. | ||
*/ | ||
void backup(); | ||
|
||
/** | ||
* Attempts to perform a cluster hot restart data backup. Each node will create a directory under the defined backup dir | ||
* with the name {@link #BACKUP_DIR_PREFIX} followed by the {@code backupSeq}. | ||
* The backup request is performed transactionally. This method will throw an exception if an another request (transaction) | ||
* is already in progress. If a node is already performing a backup (there is a file indicating a backup is in progress), | ||
* the node will only log a warning and ignore the backup request. | ||
* | ||
* @param backupSeq the suffix of the backup directory for this cluster hot restart backup | ||
*/ | ||
void backup(long backupSeq); | ||
|
||
/** | ||
* Returns the local hot restart backup task status (not the cluster backup status). | ||
*/ | ||
BackupTaskStatus getBackupTaskStatus(); | ||
|
||
/** | ||
* Interrupts the local backup task if one is currently running. The contents of the target backup directory will be left | ||
* as-is. | ||
*/ | ||
void interruptLocalBackupTask(); | ||
|
||
/** | ||
* Interrupts the backup tasks on each cluster member if one is currently running. The contents of the target backup | ||
* directories will be left as-is. | ||
*/ | ||
void interruptBackupTask(); | ||
} |
20 changes: 20 additions & 0 deletions
20
hazelcast/src/main/java/com/hazelcast/hotrestart/package-info.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,20 @@ | ||
/* | ||
* Copyright (c) 2008-2016, Hazelcast, 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 | ||
* | ||
* http://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. | ||
*/ | ||
|
||
/** | ||
* <p>This package contains Hot Restart classes needed for open source Hazelcast code<br/> | ||
*/ | ||
package com.hazelcast.hotrestart; |
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
Oops, something went wrong.