mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-27 23:49:13 +00:00
MINOR: Some Cleanups in Snapshots (#37175)
* Removed pre v6 Bwc logic + comments * Removed some dead code
This commit is contained in:
parent
9040a96daf
commit
224475e6aa
@ -51,10 +51,6 @@ public class SnapshotException extends ElasticsearchException {
|
||||
}
|
||||
}
|
||||
|
||||
public SnapshotException(final String repositoryName, final SnapshotId snapshotId, final String msg) {
|
||||
this(repositoryName, snapshotId, msg, null);
|
||||
}
|
||||
|
||||
public SnapshotException(final String repositoryName, final SnapshotId snapshotId, final String msg, final Throwable cause) {
|
||||
super("[" + repositoryName + ":" + snapshotId + "] " + msg, cause);
|
||||
this.repositoryName = repositoryName;
|
||||
|
@ -131,25 +131,17 @@ public final class SnapshotId implements Comparable<SnapshotId>, Writeable, ToXC
|
||||
}
|
||||
|
||||
public static SnapshotId fromXContent(XContentParser parser) throws IOException {
|
||||
// the new format from 5.0 which contains the snapshot name and uuid
|
||||
if (parser.currentToken() == XContentParser.Token.START_OBJECT) {
|
||||
String name = null;
|
||||
String uuid = null;
|
||||
while (parser.nextToken() != XContentParser.Token.END_OBJECT) {
|
||||
String currentFieldName = parser.currentName();
|
||||
parser.nextToken();
|
||||
if (NAME.equals(currentFieldName)) {
|
||||
name = parser.text();
|
||||
} else if (UUID.equals(currentFieldName)) {
|
||||
uuid = parser.text();
|
||||
}
|
||||
String name = null;
|
||||
String uuid = null;
|
||||
while (parser.nextToken() != XContentParser.Token.END_OBJECT) {
|
||||
String currentFieldName = parser.currentName();
|
||||
parser.nextToken();
|
||||
if (NAME.equals(currentFieldName)) {
|
||||
name = parser.text();
|
||||
} else if (UUID.equals(currentFieldName)) {
|
||||
uuid = parser.text();
|
||||
}
|
||||
return new SnapshotId(name, uuid);
|
||||
} else {
|
||||
// the old format pre 5.0 that only contains the snapshot name, use the name as the uuid too
|
||||
final String name = parser.text();
|
||||
return new SnapshotId(name, name);
|
||||
}
|
||||
return new SnapshotId(name, uuid);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ import static org.elasticsearch.transport.EmptyTransportResponseHandler.INSTANCE
|
||||
public class SnapshotShardsService extends AbstractLifecycleComponent implements ClusterStateListener, IndexEventListener {
|
||||
private static final Logger logger = LogManager.getLogger(SnapshotShardsService.class);
|
||||
|
||||
public static final String UPDATE_SNAPSHOT_STATUS_ACTION_NAME = "internal:cluster/snapshot/update_snapshot_status";
|
||||
private static final String UPDATE_SNAPSHOT_STATUS_ACTION_NAME = "internal:cluster/snapshot/update_snapshot_status";
|
||||
|
||||
private final ClusterService clusterService;
|
||||
|
||||
|
@ -515,7 +515,7 @@ public class SnapshotsService extends AbstractLifecycleComponent implements Clus
|
||||
cleanupAfterError(e);
|
||||
}
|
||||
|
||||
public void onNoLongerMaster(String source) {
|
||||
public void onNoLongerMaster() {
|
||||
userCreateSnapshotListener.onFailure(e);
|
||||
}
|
||||
|
||||
@ -1073,7 +1073,7 @@ public class SnapshotsService extends AbstractLifecycleComponent implements Clus
|
||||
@Override
|
||||
public void onNoLongerMaster(String source) {
|
||||
if (listener != null) {
|
||||
listener.onNoLongerMaster(source);
|
||||
listener.onNoLongerMaster();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1423,8 +1423,6 @@ public class SnapshotsService extends AbstractLifecycleComponent implements Clus
|
||||
builder.put(shardId,
|
||||
new SnapshotsInProgress.ShardSnapshotStatus(null, State.MISSING, "primary shard is not allocated"));
|
||||
} else if (primary.relocating() || primary.initializing()) {
|
||||
// The WAITING state was introduced in V1.2.0 -
|
||||
// don't use it if there are nodes with older version in the cluster
|
||||
builder.put(shardId, new SnapshotsInProgress.ShardSnapshotStatus(primary.currentNodeId(), State.WAITING));
|
||||
} else if (!primary.started()) {
|
||||
builder.put(shardId,
|
||||
|
Loading…
x
Reference in New Issue
Block a user