Remove AlreadyExpiredException (#24857)
This is a relict from the TTL functionality that has been removed in #21670
This commit is contained in:
parent
6bc5b1dbcd
commit
b5adb3cce9
|
@ -877,8 +877,7 @@ public class ElasticsearchException extends RuntimeException implements ToXConte
|
|||
org.elasticsearch.transport.ReceiveTimeoutTransportException::new, 83, UNKNOWN_VERSION_ADDED),
|
||||
NODE_DISCONNECTED_EXCEPTION(org.elasticsearch.transport.NodeDisconnectedException.class,
|
||||
org.elasticsearch.transport.NodeDisconnectedException::new, 84, UNKNOWN_VERSION_ADDED),
|
||||
ALREADY_EXPIRED_EXCEPTION(org.elasticsearch.index.AlreadyExpiredException.class,
|
||||
org.elasticsearch.index.AlreadyExpiredException::new, 85, UNKNOWN_VERSION_ADDED),
|
||||
// 85 used to be for AlreadyExpiredException
|
||||
AGGREGATION_EXECUTION_EXCEPTION(org.elasticsearch.search.aggregations.AggregationExecutionException.class,
|
||||
org.elasticsearch.search.aggregations.AggregationExecutionException::new, 86, UNKNOWN_VERSION_ADDED),
|
||||
// 87 used to be for MergeMappingException
|
||||
|
|
|
@ -1,91 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you 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 org.elasticsearch.index;
|
||||
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.index.engine.IgnoreOnRecoveryEngineException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class AlreadyExpiredException extends ElasticsearchException implements IgnoreOnRecoveryEngineException {
|
||||
private String index;
|
||||
private String type;
|
||||
private String id;
|
||||
private final long timestamp;
|
||||
private final long ttl;
|
||||
private final long now;
|
||||
|
||||
public AlreadyExpiredException(String index, String type, String id, long timestamp, long ttl, long now) {
|
||||
super("already expired [" + index + "]/[" + type + "]/[" + id + "] due to expire at [" + (timestamp + ttl) + "] and was processed at [" + now + "]");
|
||||
this.setIndex(index);
|
||||
this.type = type;
|
||||
this.id = id;
|
||||
this.timestamp = timestamp;
|
||||
this.ttl = ttl;
|
||||
this.now = now;
|
||||
}
|
||||
|
||||
public String index() {
|
||||
return index;
|
||||
}
|
||||
|
||||
public String type() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public String id() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public long timestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public long ttl() {
|
||||
return ttl;
|
||||
}
|
||||
|
||||
public long now() {
|
||||
return now;
|
||||
}
|
||||
|
||||
public AlreadyExpiredException(StreamInput in) throws IOException{
|
||||
super(in);
|
||||
index = in.readOptionalString();
|
||||
type = in.readOptionalString();
|
||||
id = in.readOptionalString();
|
||||
timestamp = in.readLong();
|
||||
ttl = in.readLong();
|
||||
now = in.readLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeOptionalString(index);
|
||||
out.writeOptionalString(type);
|
||||
out.writeOptionalString(id);
|
||||
out.writeLong(timestamp);
|
||||
out.writeLong(ttl);
|
||||
out.writeLong(now);
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you 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 org.elasticsearch.index.engine;
|
||||
|
||||
/**
|
||||
* Exceptions implementing this interface will be ignored during recovery.
|
||||
*/
|
||||
public interface IgnoreOnRecoveryEngineException {
|
||||
}
|
|
@ -24,12 +24,10 @@ import org.elasticsearch.common.io.stream.StreamInput;
|
|||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.index.engine.Engine;
|
||||
import org.elasticsearch.index.engine.IgnoreOnRecoveryEngineException;
|
||||
import org.elasticsearch.index.mapper.DocumentMapperForType;
|
||||
import org.elasticsearch.index.mapper.MapperException;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.index.mapper.Mapping;
|
||||
import org.elasticsearch.index.mapper.Uid;
|
||||
import org.elasticsearch.index.translog.Translog;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
|
||||
|
@ -149,8 +147,6 @@ public class TranslogRecoveryPerformer {
|
|||
* is encountered.
|
||||
*/
|
||||
private void performRecoveryOperation(Engine engine, Translog.Operation operation, boolean allowMappingUpdates, Engine.Operation.Origin origin) throws IOException {
|
||||
|
||||
try {
|
||||
switch (operation.opType()) {
|
||||
case INDEX:
|
||||
Translog.Index index = (Translog.Index) operation;
|
||||
|
@ -185,24 +181,6 @@ public class TranslogRecoveryPerformer {
|
|||
default:
|
||||
throw new IllegalStateException("No operation defined for [" + operation + "]");
|
||||
}
|
||||
} catch (ElasticsearchException e) {
|
||||
boolean hasIgnoreOnRecoveryException = false;
|
||||
ElasticsearchException current = e;
|
||||
while (true) {
|
||||
if (current instanceof IgnoreOnRecoveryEngineException) {
|
||||
hasIgnoreOnRecoveryException = true;
|
||||
break;
|
||||
}
|
||||
if (current.getCause() instanceof ElasticsearchException) {
|
||||
current = (ElasticsearchException) current.getCause();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasIgnoreOnRecoveryException) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
operationProcessed();
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,6 @@ import org.elasticsearch.common.util.set.Sets;
|
|||
import org.elasticsearch.common.xcontent.XContentLocation;
|
||||
import org.elasticsearch.discovery.DiscoverySettings;
|
||||
import org.elasticsearch.env.ShardLockObtainFailedException;
|
||||
import org.elasticsearch.index.AlreadyExpiredException;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.engine.RecoveryEngineException;
|
||||
import org.elasticsearch.index.query.QueryShardException;
|
||||
|
@ -296,24 +295,6 @@ public class ExceptionSerializationTests extends ESTestCase {
|
|||
assertTrue(ex.getCause() instanceof NullPointerException);
|
||||
}
|
||||
|
||||
public void testAlreadyExpiredException() throws IOException {
|
||||
AlreadyExpiredException alreadyExpiredException = serialize(new AlreadyExpiredException("index", "type", "id", 1, 2, 3));
|
||||
assertEquals("index", alreadyExpiredException.getIndex().getName());
|
||||
assertEquals("type", alreadyExpiredException.type());
|
||||
assertEquals("id", alreadyExpiredException.id());
|
||||
assertEquals(2, alreadyExpiredException.ttl());
|
||||
assertEquals(1, alreadyExpiredException.timestamp());
|
||||
assertEquals(3, alreadyExpiredException.now());
|
||||
|
||||
alreadyExpiredException = serialize(new AlreadyExpiredException(null, null, null, -1, -2, -3));
|
||||
assertNull(alreadyExpiredException.getIndex());
|
||||
assertNull(alreadyExpiredException.type());
|
||||
assertNull(alreadyExpiredException.id());
|
||||
assertEquals(-2, alreadyExpiredException.ttl());
|
||||
assertEquals(-1, alreadyExpiredException.timestamp());
|
||||
assertEquals(-3, alreadyExpiredException.now());
|
||||
}
|
||||
|
||||
public void testActionNotFoundTransportException() throws IOException {
|
||||
ActionNotFoundTransportException ex = serialize(new ActionNotFoundTransportException("AACCCTION"));
|
||||
assertEquals("AACCCTION", ex.action());
|
||||
|
@ -780,7 +761,7 @@ public class ExceptionSerializationTests extends ESTestCase {
|
|||
ids.put(82, org.elasticsearch.repositories.RepositoryException.class);
|
||||
ids.put(83, org.elasticsearch.transport.ReceiveTimeoutTransportException.class);
|
||||
ids.put(84, org.elasticsearch.transport.NodeDisconnectedException.class);
|
||||
ids.put(85, org.elasticsearch.index.AlreadyExpiredException.class);
|
||||
ids.put(85, null);
|
||||
ids.put(86, org.elasticsearch.search.aggregations.AggregationExecutionException.class);
|
||||
ids.put(88, org.elasticsearch.indices.InvalidIndexTemplateException.class);
|
||||
ids.put(90, org.elasticsearch.index.engine.RefreshFailedEngineException.class);
|
||||
|
|
Loading…
Reference in New Issue