mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-28 07:59:10 +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) {
|
public SnapshotException(final String repositoryName, final SnapshotId snapshotId, final String msg, final Throwable cause) {
|
||||||
super("[" + repositoryName + ":" + snapshotId + "] " + msg, cause);
|
super("[" + repositoryName + ":" + snapshotId + "] " + msg, cause);
|
||||||
this.repositoryName = repositoryName;
|
this.repositoryName = repositoryName;
|
||||||
|
@ -131,25 +131,17 @@ public final class SnapshotId implements Comparable<SnapshotId>, Writeable, ToXC
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static SnapshotId fromXContent(XContentParser parser) throws IOException {
|
public static SnapshotId fromXContent(XContentParser parser) throws IOException {
|
||||||
// the new format from 5.0 which contains the snapshot name and uuid
|
String name = null;
|
||||||
if (parser.currentToken() == XContentParser.Token.START_OBJECT) {
|
String uuid = null;
|
||||||
String name = null;
|
while (parser.nextToken() != XContentParser.Token.END_OBJECT) {
|
||||||
String uuid = null;
|
String currentFieldName = parser.currentName();
|
||||||
while (parser.nextToken() != XContentParser.Token.END_OBJECT) {
|
parser.nextToken();
|
||||||
String currentFieldName = parser.currentName();
|
if (NAME.equals(currentFieldName)) {
|
||||||
parser.nextToken();
|
name = parser.text();
|
||||||
if (NAME.equals(currentFieldName)) {
|
} else if (UUID.equals(currentFieldName)) {
|
||||||
name = parser.text();
|
uuid = 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 {
|
public class SnapshotShardsService extends AbstractLifecycleComponent implements ClusterStateListener, IndexEventListener {
|
||||||
private static final Logger logger = LogManager.getLogger(SnapshotShardsService.class);
|
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;
|
private final ClusterService clusterService;
|
||||||
|
|
||||||
|
@ -515,7 +515,7 @@ public class SnapshotsService extends AbstractLifecycleComponent implements Clus
|
|||||||
cleanupAfterError(e);
|
cleanupAfterError(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onNoLongerMaster(String source) {
|
public void onNoLongerMaster() {
|
||||||
userCreateSnapshotListener.onFailure(e);
|
userCreateSnapshotListener.onFailure(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1073,7 +1073,7 @@ public class SnapshotsService extends AbstractLifecycleComponent implements Clus
|
|||||||
@Override
|
@Override
|
||||||
public void onNoLongerMaster(String source) {
|
public void onNoLongerMaster(String source) {
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
listener.onNoLongerMaster(source);
|
listener.onNoLongerMaster();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1423,8 +1423,6 @@ public class SnapshotsService extends AbstractLifecycleComponent implements Clus
|
|||||||
builder.put(shardId,
|
builder.put(shardId,
|
||||||
new SnapshotsInProgress.ShardSnapshotStatus(null, State.MISSING, "primary shard is not allocated"));
|
new SnapshotsInProgress.ShardSnapshotStatus(null, State.MISSING, "primary shard is not allocated"));
|
||||||
} else if (primary.relocating() || primary.initializing()) {
|
} 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));
|
builder.put(shardId, new SnapshotsInProgress.ShardSnapshotStatus(primary.currentNodeId(), State.WAITING));
|
||||||
} else if (!primary.started()) {
|
} else if (!primary.started()) {
|
||||||
builder.put(shardId,
|
builder.put(shardId,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user