|
28 | 28 | import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
29 | 29 | import org.elasticsearch.cluster.service.ClusterService;
|
30 | 30 | import org.elasticsearch.common.inject.Inject;
|
31 |
| -import org.elasticsearch.snapshots.Snapshot; |
32 |
| -import org.elasticsearch.snapshots.SnapshotInfo; |
33 | 31 | import org.elasticsearch.snapshots.SnapshotsService;
|
34 | 32 | import org.elasticsearch.threadpool.ThreadPool;
|
35 | 33 | import org.elasticsearch.transport.TransportService;
|
@@ -72,37 +70,13 @@ protected ClusterBlockException checkBlock(CreateSnapshotRequest request, Cluste
|
72 | 70 |
|
73 | 71 | @Override
|
74 | 72 | protected void masterOperation(final CreateSnapshotRequest request, ClusterState state,
|
75 |
| - final ActionListener<CreateSnapshotResponse> listener) { |
76 |
| - snapshotsService.createSnapshot(request, new SnapshotsService.CreateSnapshotListener() { |
77 |
| - @Override |
78 |
| - public void onResponse(Snapshot snapshotCreated) { |
79 |
| - if (request.waitForCompletion()) { |
80 |
| - snapshotsService.addListener(new SnapshotsService.SnapshotCompletionListener() { |
81 |
| - @Override |
82 |
| - public void onSnapshotCompletion(Snapshot snapshot, SnapshotInfo snapshotInfo) { |
83 |
| - if (snapshotCreated.equals(snapshot)) { |
84 |
| - listener.onResponse(new CreateSnapshotResponse(snapshotInfo)); |
85 |
| - snapshotsService.removeListener(this); |
86 |
| - } |
87 |
| - } |
88 |
| - |
89 |
| - @Override |
90 |
| - public void onSnapshotFailure(Snapshot snapshot, Exception e) { |
91 |
| - if (snapshotCreated.equals(snapshot)) { |
92 |
| - listener.onFailure(e); |
93 |
| - snapshotsService.removeListener(this); |
94 |
| - } |
95 |
| - } |
96 |
| - }); |
97 |
| - } else { |
98 |
| - listener.onResponse(new CreateSnapshotResponse()); |
99 |
| - } |
100 |
| - } |
101 |
| - |
102 |
| - @Override |
103 |
| - public void onFailure(Exception e) { |
104 |
| - listener.onFailure(e); |
105 |
| - } |
106 |
| - }); |
| 73 | + final ActionListener<CreateSnapshotResponse> listener) { |
| 74 | + if (request.waitForCompletion()) { |
| 75 | + snapshotsService.executeSnapshot(request, |
| 76 | + ActionListener.wrap(snapshotInfo-> listener.onResponse(new CreateSnapshotResponse(snapshotInfo)), listener::onFailure)); |
| 77 | + } else { |
| 78 | + snapshotsService.createSnapshot(request, |
| 79 | + ActionListener.wrap(snapshot -> listener.onResponse(new CreateSnapshotResponse()), listener::onFailure)); |
| 80 | + } |
107 | 81 | }
|
108 | 82 | }
|
0 commit comments