Skip to content

Commit

Permalink
Merge branch 'master' into dedup-translog-merge
Browse files Browse the repository at this point in the history
# Conflicts:
#	core/src/test/java/org/elasticsearch/index/translog/TranslogTests.java
  • Loading branch information
dnhatn committed Nov 8, 2017
2 parents ebe92b6 + 6f04b8c commit def1d39
Show file tree
Hide file tree
Showing 151 changed files with 4,689 additions and 1,542 deletions.
4 changes: 2 additions & 2 deletions buildSrc/version.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ lucene = 7.1.0
# optional dependencies
spatial4j = 0.6
jts = 1.13
jackson = 2.8.6
snakeyaml = 1.15
jackson = 2.8.10
snakeyaml = 1.17
# when updating log4j, please update also docs/java-api/index.asciidoc
log4j = 2.9.1
slf4j = 1.6.2
Expand Down

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions client/sniffer/licenses/jackson-core-2.8.10.jar.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
eb21a035c66ad307e66ec8fce37f5d50fd62d039
1 change: 0 additions & 1 deletion client/sniffer/licenses/jackson-core-2.8.6.jar.sha1

This file was deleted.

1 change: 1 addition & 0 deletions core/licenses/jackson-core-2.8.10.jar.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
eb21a035c66ad307e66ec8fce37f5d50fd62d039
1 change: 0 additions & 1 deletion core/licenses/jackson-core-2.8.6.jar.sha1

This file was deleted.

1 change: 1 addition & 0 deletions core/licenses/jackson-dataformat-cbor-2.8.10.jar.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1c58cc9313ddf19f0900cd61ed044874278ce320
1 change: 0 additions & 1 deletion core/licenses/jackson-dataformat-cbor-2.8.6.jar.sha1

This file was deleted.

1 change: 1 addition & 0 deletions core/licenses/jackson-dataformat-smile-2.8.10.jar.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
e853081fadaad3e98ed801937acc3d8f77580686
1 change: 0 additions & 1 deletion core/licenses/jackson-dataformat-smile-2.8.6.jar.sha1

This file was deleted.

1 change: 1 addition & 0 deletions core/licenses/jackson-dataformat-yaml-2.8.10.jar.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1e08caf1d787c825307d8cc6362452086020d853
1 change: 0 additions & 1 deletion core/licenses/jackson-dataformat-yaml-2.8.6.jar.sha1

This file was deleted.

1 change: 0 additions & 1 deletion core/licenses/snakeyaml-1.15.jar.sha1

This file was deleted.

1 change: 1 addition & 0 deletions core/licenses/snakeyaml-1.17.jar.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7a27ea250c5130b2922b86dea63cbb1cc10a660c
4 changes: 4 additions & 0 deletions core/src/main/java/org/elasticsearch/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ public class Version implements Comparable<Version> {
public static final Version V_5_6_3 = new Version(V_5_6_3_ID, org.apache.lucene.util.Version.LUCENE_6_6_1);
public static final int V_5_6_4_ID = 5060499;
public static final Version V_5_6_4 = new Version(V_5_6_4_ID, org.apache.lucene.util.Version.LUCENE_6_6_1);
public static final int V_5_6_5_ID = 5060599;
public static final Version V_5_6_5 = new Version(V_5_6_5_ID, org.apache.lucene.util.Version.LUCENE_6_6_1);
public static final int V_6_0_0_alpha1_ID = 6000001;
public static final Version V_6_0_0_alpha1 =
new Version(V_6_0_0_alpha1_ID, org.apache.lucene.util.Version.LUCENE_7_0_0);
Expand Down Expand Up @@ -160,6 +162,8 @@ public static Version fromId(int id) {
return V_6_0_0_alpha2;
case V_6_0_0_alpha1_ID:
return V_6_0_0_alpha1;
case V_5_6_5_ID:
return V_5_6_5;
case V_5_6_4_ID:
return V_5_6_4;
case V_5_6_3_ID:
Expand Down
8 changes: 5 additions & 3 deletions core/src/main/java/org/elasticsearch/action/ActionModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@
import org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsAction;
import org.elasticsearch.action.admin.indices.shards.IndicesShardStoresAction;
import org.elasticsearch.action.admin.indices.shards.TransportIndicesShardStoresAction;
import org.elasticsearch.action.admin.indices.shrink.ResizeAction;
import org.elasticsearch.action.admin.indices.shrink.ShrinkAction;
import org.elasticsearch.action.admin.indices.shrink.TransportResizeAction;
import org.elasticsearch.action.admin.indices.shrink.TransportShrinkAction;
import org.elasticsearch.action.admin.indices.stats.IndicesStatsAction;
import org.elasticsearch.action.admin.indices.stats.TransportIndicesStatsAction;
Expand Down Expand Up @@ -181,7 +183,6 @@
import org.elasticsearch.action.search.TransportMultiSearchAction;
import org.elasticsearch.action.search.TransportSearchAction;
import org.elasticsearch.action.search.TransportSearchScrollAction;
import org.elasticsearch.action.support.ActionFilter;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.AutoCreateIndex;
import org.elasticsearch.action.support.DestructiveOperations;
Expand All @@ -199,7 +200,6 @@
import org.elasticsearch.common.NamedRegistry;
import org.elasticsearch.common.inject.AbstractModule;
import org.elasticsearch.common.inject.multibindings.MapBinder;
import org.elasticsearch.common.inject.multibindings.Multibinder;
import org.elasticsearch.common.logging.ESLoggerFactory;
import org.elasticsearch.common.settings.ClusterSettings;
import org.elasticsearch.common.settings.IndexScopedSettings;
Expand Down Expand Up @@ -271,6 +271,7 @@
import org.elasticsearch.rest.action.admin.indices.RestRefreshAction;
import org.elasticsearch.rest.action.admin.indices.RestRolloverIndexAction;
import org.elasticsearch.rest.action.admin.indices.RestShrinkIndexAction;
import org.elasticsearch.rest.action.admin.indices.RestSplitIndexAction;
import org.elasticsearch.rest.action.admin.indices.RestSyncedFlushAction;
import org.elasticsearch.rest.action.admin.indices.RestUpdateSettingsAction;
import org.elasticsearch.rest.action.admin.indices.RestUpgradeAction;
Expand Down Expand Up @@ -324,7 +325,6 @@
import java.util.function.UnaryOperator;
import java.util.stream.Collectors;

import static java.util.Collections.unmodifiableList;
import static java.util.Collections.unmodifiableMap;

/**
Expand Down Expand Up @@ -438,6 +438,7 @@ public <Request extends ActionRequest, Response extends ActionResponse> void reg
actions.register(IndicesShardStoresAction.INSTANCE, TransportIndicesShardStoresAction.class);
actions.register(CreateIndexAction.INSTANCE, TransportCreateIndexAction.class);
actions.register(ShrinkAction.INSTANCE, TransportShrinkAction.class);
actions.register(ResizeAction.INSTANCE, TransportResizeAction.class);
actions.register(RolloverAction.INSTANCE, TransportRolloverAction.class);
actions.register(DeleteIndexAction.INSTANCE, TransportDeleteIndexAction.class);
actions.register(GetIndexAction.INSTANCE, TransportGetIndexAction.class);
Expand Down Expand Up @@ -554,6 +555,7 @@ public void initRestHandlers(Supplier<DiscoveryNodes> nodesInCluster) {
registerHandler.accept(new RestIndicesAliasesAction(settings, restController));
registerHandler.accept(new RestCreateIndexAction(settings, restController));
registerHandler.accept(new RestShrinkIndexAction(settings, restController));
registerHandler.accept(new RestSplitIndexAction(settings, restController));
registerHandler.accept(new RestRolloverIndexAction(settings, restController));
registerHandler.accept(new RestDeleteIndexAction(settings, restController));
registerHandler.accept(new RestCloseIndexAction(settings, restController));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package org.elasticsearch.action.admin.indices.create;

import org.elasticsearch.action.admin.indices.alias.Alias;
import org.elasticsearch.action.admin.indices.shrink.ResizeType;
import org.elasticsearch.action.support.ActiveShardCount;
import org.elasticsearch.cluster.ack.ClusterStateUpdateRequest;
import org.elasticsearch.cluster.block.ClusterBlock;
Expand All @@ -43,7 +44,8 @@ public class CreateIndexClusterStateUpdateRequest extends ClusterStateUpdateRequ
private final String index;
private final String providedName;
private final boolean updateAllTypes;
private Index shrinkFrom;
private Index recoverFrom;
private ResizeType resizeType;

private IndexMetaData.State state = IndexMetaData.State.OPEN;

Expand All @@ -59,7 +61,6 @@ public class CreateIndexClusterStateUpdateRequest extends ClusterStateUpdateRequ

private ActiveShardCount waitForActiveShards = ActiveShardCount.DEFAULT;


public CreateIndexClusterStateUpdateRequest(TransportMessage originalMessage, String cause, String index, String providedName,
boolean updateAllTypes) {
this.originalMessage = originalMessage;
Expand Down Expand Up @@ -99,8 +100,8 @@ public CreateIndexClusterStateUpdateRequest state(IndexMetaData.State state) {
return this;
}

public CreateIndexClusterStateUpdateRequest shrinkFrom(Index shrinkFrom) {
this.shrinkFrom = shrinkFrom;
public CreateIndexClusterStateUpdateRequest recoverFrom(Index recoverFrom) {
this.recoverFrom = recoverFrom;
return this;
}

Expand All @@ -109,6 +110,11 @@ public CreateIndexClusterStateUpdateRequest waitForActiveShards(ActiveShardCount
return this;
}

public CreateIndexClusterStateUpdateRequest resizeType(ResizeType resizeType) {
this.resizeType = resizeType;
return this;
}

public TransportMessage originalMessage() {
return originalMessage;
}
Expand Down Expand Up @@ -145,8 +151,8 @@ public Set<ClusterBlock> blocks() {
return blocks;
}

public Index shrinkFrom() {
return shrinkFrom;
public Index recoverFrom() {
return recoverFrom;
}

/** True if all fields that span multiple types should be updated, false otherwise */
Expand All @@ -165,4 +171,11 @@ public String getProvidedName() {
public ActiveShardCount waitForActiveShards() {
return waitForActiveShards;
}

/**
* Returns the resize type or null if this is an ordinary create index request
*/
public ResizeType resizeType() {
return resizeType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@

package org.elasticsearch.action.admin.indices.rollover;

import org.elasticsearch.Version;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.io.stream.NamedWriteable;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.ObjectParser;

Expand All @@ -38,6 +40,9 @@ public abstract class Condition<T> implements NamedWriteable {
new ParseField(MaxAgeCondition.NAME));
PARSER.declareLong((conditions, value) ->
conditions.add(new MaxDocsCondition(value)), new ParseField(MaxDocsCondition.NAME));
PARSER.declareString((conditions, s) ->
conditions.add(new MaxSizeCondition(ByteSizeValue.parseBytesSizeValue(s, MaxSizeCondition.NAME))),
new ParseField(MaxSizeCondition.NAME));
}

protected T value;
Expand All @@ -49,6 +54,14 @@ protected Condition(String name) {

public abstract Result evaluate(Stats stats);

/**
* Checks if this condition is available in a specific version.
* This makes sure BWC when introducing a new condition which is not recognized by older versions.
*/
boolean includedInVersion(Version version) {
return true;
}

@Override
public final String toString() {
return "[" + name + ": " + value + "]";
Expand All @@ -60,10 +73,12 @@ public final String toString() {
public static class Stats {
public final long numDocs;
public final long indexCreated;
public final ByteSizeValue indexSize;

public Stats(long numDocs, long indexCreated) {
public Stats(long numDocs, long indexCreated, ByteSizeValue indexSize) {
this.numDocs = numDocs;
this.indexCreated = indexCreated;
this.indexSize = indexSize;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* 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.action.admin.indices.rollover;

import org.elasticsearch.Version;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.unit.ByteSizeUnit;
import org.elasticsearch.common.unit.ByteSizeValue;

import java.io.IOException;

/**
* A size-based condition for an index size.
* Evaluates to <code>true</code> if the index size is at least {@link #value}.
*/
public class MaxSizeCondition extends Condition<ByteSizeValue> {
public static final String NAME = "max_size";

public MaxSizeCondition(ByteSizeValue value) {
super(NAME);
this.value = value;
}

public MaxSizeCondition(StreamInput in) throws IOException {
super(NAME);
this.value = new ByteSizeValue(in.readVLong(), ByteSizeUnit.BYTES);
}

@Override
public Result evaluate(Stats stats) {
return new Result(this, stats.indexSize.getBytes() >= value.getBytes());
}

@Override
boolean includedInVersion(Version version) {
return version.onOrAfter(Version.V_6_1_0);
}

@Override
public String getWriteableName() {
return NAME;
}

@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeVLong(value.getBytes());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.ObjectParser;

Expand Down Expand Up @@ -106,7 +107,9 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeBoolean(dryRun);
out.writeVInt(conditions.size());
for (Condition condition : conditions) {
out.writeNamedWriteable(condition);
if (condition.includedInVersion(out.getVersion())) {
out.writeNamedWriteable(condition);
}
}
createIndexRequest.writeTo(out);
}
Expand Down Expand Up @@ -155,6 +158,13 @@ public void addMaxIndexDocsCondition(long numDocs) {
this.conditions.add(new MaxDocsCondition(numDocs));
}

/**
* Adds a size-based condition to check if the index size is at least <code>size</code>.
*/
public void addMaxIndexSizeCondition(ByteSizeValue size) {
this.conditions.add(new MaxSizeCondition(size));
}

/**
* Sets rollover index creation request to override index settings when
* the rolled over index has to be created
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.elasticsearch.action.support.master.MasterNodeOperationRequestBuilder;
import org.elasticsearch.client.ElasticsearchClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.unit.TimeValue;


Expand Down Expand Up @@ -52,6 +53,11 @@ public RolloverRequestBuilder addMaxIndexDocsCondition(long docs) {
return this;
}

public RolloverRequestBuilder addMaxIndexSizeCondition(ByteSizeValue size){
this.request.addMaxIndexSizeCondition(size);
return this;
}

public RolloverRequestBuilder dryRun(boolean dryRun) {
this.request.dryRun(dryRun);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.index.shard.DocsStats;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
Expand Down Expand Up @@ -195,7 +196,8 @@ static String generateRolloverIndexName(String sourceIndexName, IndexNameExpress
static Set<Condition.Result> evaluateConditions(final Set<Condition> conditions,
final DocsStats docsStats, final IndexMetaData metaData) {
final long numDocs = docsStats == null ? 0 : docsStats.getCount();
final Condition.Stats stats = new Condition.Stats(numDocs, metaData.getCreationDate());
final long indexSize = docsStats == null ? 0 : docsStats.getTotalSizeInBytes();
final Condition.Stats stats = new Condition.Stats(numDocs, metaData.getCreationDate(), new ByteSizeValue(indexSize));
return conditions.stream()
.map(condition -> condition.evaluate(stats))
.collect(Collectors.toSet());
Expand Down
Loading

0 comments on commit def1d39

Please sign in to comment.