public interface Maintenance extends CloseableClient
An etcd cluster needs periodic maintenance to remain reliable. Depending on an etcd application's needs, this maintenance can usually be automated and performed without downtime or significantly degraded performance.
All etcd maintenance manages storage resources consumed by the etcd keyspace. Failure to adequately control the keyspace size is guarded by storage space quotas; if an etcd member runs low on space, a quota will trigger cluster-wide alarms which will put the system into a limited-operation maintenance mode. To avoid running out of space for writes to the keyspace, the etcd keyspace history must be compacted. Storage space itself may be reclaimed by defragmenting etcd members. Finally, periodic snapshot backups of etcd member state makes it possible to recover any unintended logical data loss or corruption caused by operational error.
| Modifier and Type | Interface and Description |
|---|---|
static interface |
Maintenance.Snapshot |
| Modifier and Type | Method and Description |
|---|---|
CompletableFuture<AlarmResponse> |
alarmDisarm(AlarmMember member)
disarms a given alarm.
|
CompletableFuture<DefragmentResponse> |
defragmentMember(String endpoint)
defragment one member of the cluster by its endpoint.
|
CompletableFuture<AlarmResponse> |
listAlarms()
get all active keyspace alarm.
|
Maintenance.Snapshot |
snapshot()
retrieves backend snapshot.
|
CompletableFuture<StatusResponse> |
statusMember(String endpoint)
get the status of a member by its endpoint.
|
closeCompletableFuture<AlarmResponse> listAlarms()
CompletableFuture<AlarmResponse> alarmDisarm(AlarmMember member)
member - the alarmCompletableFuture<DefragmentResponse> defragmentMember(String endpoint)
After compacting the keyspace, the backend database may exhibit internal fragmentation. Any internal fragmentation is space that is free to use by the backend but still consumes storage space. The process of defragmentation releases this storage space back to the file system. Defragmentation is issued on a per-member so that cluster-wide latency spikes may be avoided.
Defragment is an expensive operation. User should avoid defragmenting multiple members at the same time. To defragment multiple members in the cluster, user need to call defragment multiple times with different endpoints.
CompletableFuture<StatusResponse> statusMember(String endpoint)
Maintenance.Snapshot snapshot()
-- ex: save backend snapshot to ./snapshot.db --
// create snapshot.db file current folder.
String dir = Paths.get("").toAbsolutePath().toString();
File snapfile = new File(dir, "snapshot.db");
// leverage try-with-resources
try (Snapshot snapshot = maintenance.snapshot();
FileOutputStream fop = newFileOutputStream(snapfile)) {
snapshot.write(fop);
} catch (Exception e) {
snapfile.delete();
}
Copyright © 2017. All rights reserved.