Skip to content

Commit a79c2c1

Browse files
committed
Merge branch 'master' into compile-with-jdk-9
* master: Set watermarks in single-node test cases Add the ability to bundle multiple plugins into a meta plugin (elastic#28022) Declare empty package dirs as output dirs Consistent updates of IndexShardSnapshotStatus (elastic#28130)
2 parents 6ca2834 + 2c24ac7 commit a79c2c1

File tree

40 files changed

+1625
-519
lines changed

40 files changed

+1625
-519
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Elasticsearch meta plugin descriptor file
2+
# This file must exist as 'meta-plugin-descriptor.properties' in a folder named `elasticsearch`.
3+
#
4+
### example meta plugin for "meta-foo"
5+
#
6+
# meta-foo.zip <-- zip file for the meta plugin, with this structure:
7+
#|____elasticsearch/
8+
#| |____ <bundled_plugin_1> <-- The plugin files for bundled_plugin_1 (the content of the elastisearch directory)
9+
#| |____ <bundled_plugin_2> <-- The plugin files for bundled_plugin_2
10+
#| |____ meta-plugin-descriptor.properties <-- example contents below:
11+
#
12+
# description=My meta plugin
13+
# name=meta-foo
14+
#
15+
### mandatory elements for all meta plugins:
16+
#
17+
# 'description': simple summary of the meta plugin
18+
description=${description}
19+
#
20+
# 'name': the meta plugin name
21+
name=${name}

core/src/main/java/org/elasticsearch/action/admin/cluster/node/info/PluginsAndModules.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.io.IOException;
3131
import java.util.ArrayList;
3232
import java.util.Collections;
33+
import java.util.Comparator;
3334
import java.util.List;
3435

3536
/**
@@ -60,23 +61,23 @@ public void writeTo(StreamOutput out) throws IOException {
6061
*/
6162
public List<PluginInfo> getPluginInfos() {
6263
List<PluginInfo> plugins = new ArrayList<>(this.plugins);
63-
Collections.sort(plugins, (p1, p2) -> p1.getName().compareTo(p2.getName()));
64+
Collections.sort(plugins, Comparator.comparing(PluginInfo::getName));
6465
return plugins;
6566
}
66-
67+
6768
/**
6869
* Returns an ordered list based on modules name
6970
*/
7071
public List<PluginInfo> getModuleInfos() {
7172
List<PluginInfo> modules = new ArrayList<>(this.modules);
72-
Collections.sort(modules, (p1, p2) -> p1.getName().compareTo(p2.getName()));
73+
Collections.sort(modules, Comparator.comparing(PluginInfo::getName));
7374
return modules;
7475
}
7576

7677
public void addPlugin(PluginInfo info) {
7778
plugins.add(info);
7879
}
79-
80+
8081
public void addModule(PluginInfo info) {
8182
modules.add(info);
8283
}

core/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/SnapshotIndexShardStatus.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import org.elasticsearch.action.support.broadcast.BroadcastShardResponse;
2323
import org.elasticsearch.common.io.stream.StreamInput;
2424
import org.elasticsearch.common.io.stream.StreamOutput;
25-
import org.elasticsearch.common.xcontent.ToXContent.Params;
2625
import org.elasticsearch.common.xcontent.ToXContentFragment;
2726
import org.elasticsearch.common.xcontent.XContentBuilder;
2827
import org.elasticsearch.index.shard.ShardId;
@@ -49,13 +48,13 @@ private SnapshotIndexShardStatus() {
4948
this.stats = new SnapshotStats();
5049
}
5150

52-
SnapshotIndexShardStatus(ShardId shardId, IndexShardSnapshotStatus indexShardStatus) {
51+
SnapshotIndexShardStatus(ShardId shardId, IndexShardSnapshotStatus.Copy indexShardStatus) {
5352
this(shardId, indexShardStatus, null);
5453
}
5554

56-
SnapshotIndexShardStatus(ShardId shardId, IndexShardSnapshotStatus indexShardStatus, String nodeId) {
55+
SnapshotIndexShardStatus(ShardId shardId, IndexShardSnapshotStatus.Copy indexShardStatus, String nodeId) {
5756
super(shardId);
58-
switch (indexShardStatus.stage()) {
57+
switch (indexShardStatus.getStage()) {
5958
case INIT:
6059
stage = SnapshotIndexShardStage.INIT;
6160
break;
@@ -72,10 +71,12 @@ private SnapshotIndexShardStatus() {
7271
stage = SnapshotIndexShardStage.FAILURE;
7372
break;
7473
default:
75-
throw new IllegalArgumentException("Unknown stage type " + indexShardStatus.stage());
74+
throw new IllegalArgumentException("Unknown stage type " + indexShardStatus.getStage());
7675
}
77-
stats = new SnapshotStats(indexShardStatus);
78-
failure = indexShardStatus.failure();
76+
this.stats = new SnapshotStats(indexShardStatus.getStartTime(), indexShardStatus.getTotalTime(),
77+
indexShardStatus.getNumberOfFiles(), indexShardStatus.getProcessedFiles(),
78+
indexShardStatus.getTotalSize(), indexShardStatus.getProcessedSize());
79+
this.failure = indexShardStatus.getFailure();
7980
this.nodeId = nodeId;
8081
}
8182

core/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/SnapshotStats.java

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,33 +25,28 @@
2525
import org.elasticsearch.common.xcontent.ToXContent;
2626
import org.elasticsearch.common.xcontent.ToXContentFragment;
2727
import org.elasticsearch.common.xcontent.XContentBuilder;
28-
import org.elasticsearch.index.snapshots.IndexShardSnapshotStatus;
2928

3029
import java.io.IOException;
3130

3231
public class SnapshotStats implements Streamable, ToXContentFragment {
33-
private long startTime;
3432

33+
private long startTime;
3534
private long time;
36-
3735
private int numberOfFiles;
38-
3936
private int processedFiles;
40-
4137
private long totalSize;
42-
4338
private long processedSize;
4439

4540
SnapshotStats() {
4641
}
4742

48-
SnapshotStats(IndexShardSnapshotStatus indexShardStatus) {
49-
startTime = indexShardStatus.startTime();
50-
time = indexShardStatus.time();
51-
numberOfFiles = indexShardStatus.numberOfFiles();
52-
processedFiles = indexShardStatus.processedFiles();
53-
totalSize = indexShardStatus.totalSize();
54-
processedSize = indexShardStatus.processedSize();
43+
SnapshotStats(long startTime, long time, int numberOfFiles, int processedFiles, long totalSize, long processedSize) {
44+
this.startTime = startTime;
45+
this.time = time;
46+
this.numberOfFiles = numberOfFiles;
47+
this.processedFiles = processedFiles;
48+
this.totalSize = totalSize;
49+
this.processedSize = processedSize;
5550
}
5651

5752
/**

core/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/TransportNodesSnapshotsStatus.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,23 +96,25 @@ protected NodesSnapshotStatus newResponse(Request request, List<NodeSnapshotStat
9696
protected NodeSnapshotStatus nodeOperation(NodeRequest request) {
9797
Map<Snapshot, Map<ShardId, SnapshotIndexShardStatus>> snapshotMapBuilder = new HashMap<>();
9898
try {
99-
String nodeId = clusterService.localNode().getId();
99+
final String nodeId = clusterService.localNode().getId();
100100
for (Snapshot snapshot : request.snapshots) {
101101
Map<ShardId, IndexShardSnapshotStatus> shardsStatus = snapshotShardsService.currentSnapshotShards(snapshot);
102102
if (shardsStatus == null) {
103103
continue;
104104
}
105105
Map<ShardId, SnapshotIndexShardStatus> shardMapBuilder = new HashMap<>();
106106
for (Map.Entry<ShardId, IndexShardSnapshotStatus> shardEntry : shardsStatus.entrySet()) {
107-
SnapshotIndexShardStatus shardStatus;
108-
IndexShardSnapshotStatus.Stage stage = shardEntry.getValue().stage();
107+
final ShardId shardId = shardEntry.getKey();
108+
109+
final IndexShardSnapshotStatus.Copy lastSnapshotStatus = shardEntry.getValue().asCopy();
110+
final IndexShardSnapshotStatus.Stage stage = lastSnapshotStatus.getStage();
111+
112+
String shardNodeId = null;
109113
if (stage != IndexShardSnapshotStatus.Stage.DONE && stage != IndexShardSnapshotStatus.Stage.FAILURE) {
110114
// Store node id for the snapshots that are currently running.
111-
shardStatus = new SnapshotIndexShardStatus(shardEntry.getKey(), shardEntry.getValue(), nodeId);
112-
} else {
113-
shardStatus = new SnapshotIndexShardStatus(shardEntry.getKey(), shardEntry.getValue());
115+
shardNodeId = nodeId;
114116
}
115-
shardMapBuilder.put(shardEntry.getKey(), shardStatus);
117+
shardMapBuilder.put(shardEntry.getKey(), new SnapshotIndexShardStatus(shardId, lastSnapshotStatus, shardNodeId));
116118
}
117119
snapshotMapBuilder.put(snapshot, unmodifiableMap(shardMapBuilder));
118120
}

core/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/TransportSnapshotsStatusAction.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,8 @@ private SnapshotsStatusResponse buildResponse(SnapshotsStatusRequest request, Li
233233
Map<ShardId, IndexShardSnapshotStatus> shardStatues =
234234
snapshotsService.snapshotShards(request.repository(), snapshotInfo);
235235
for (Map.Entry<ShardId, IndexShardSnapshotStatus> shardStatus : shardStatues.entrySet()) {
236-
shardStatusBuilder.add(new SnapshotIndexShardStatus(shardStatus.getKey(), shardStatus.getValue()));
236+
IndexShardSnapshotStatus.Copy lastSnapshotStatus = shardStatus.getValue().asCopy();
237+
shardStatusBuilder.add(new SnapshotIndexShardStatus(shardStatus.getKey(), lastSnapshotStatus));
237238
}
238239
final SnapshotsInProgress.State state;
239240
switch (snapshotInfo.state()) {

core/src/main/java/org/elasticsearch/bootstrap/Security.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -163,16 +163,8 @@ static Map<String, URL> getCodebaseJarMap(Set<URL> urls) {
163163
static Map<String,Policy> getPluginPermissions(Environment environment) throws IOException, NoSuchAlgorithmException {
164164
Map<String,Policy> map = new HashMap<>();
165165
// collect up set of plugins and modules by listing directories.
166-
Set<Path> pluginsAndModules = new LinkedHashSet<>(); // order is already lost, but some filesystems have it
167-
if (Files.exists(environment.pluginsFile())) {
168-
try (DirectoryStream<Path> stream = Files.newDirectoryStream(environment.pluginsFile())) {
169-
for (Path plugin : stream) {
170-
if (pluginsAndModules.add(plugin) == false) {
171-
throw new IllegalStateException("duplicate plugin: " + plugin);
172-
}
173-
}
174-
}
175-
}
166+
Set<Path> pluginsAndModules = new LinkedHashSet<>(PluginInfo.extractAllPlugins(environment.pluginsFile()));
167+
176168
if (Files.exists(environment.modulesFile())) {
177169
try (DirectoryStream<Path> stream = Files.newDirectoryStream(environment.modulesFile())) {
178170
for (Path module : stream) {

core/src/main/java/org/elasticsearch/bootstrap/Spawner.java

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,12 @@
2121

2222
import org.apache.lucene.util.Constants;
2323
import org.apache.lucene.util.IOUtils;
24-
import org.elasticsearch.common.io.FileSystemUtils;
2524
import org.elasticsearch.env.Environment;
2625
import org.elasticsearch.plugins.Platforms;
2726
import org.elasticsearch.plugins.PluginInfo;
2827

2928
import java.io.Closeable;
3029
import java.io.IOException;
31-
import java.nio.file.DirectoryStream;
3230
import java.nio.file.Files;
3331
import java.nio.file.Path;
3432
import java.util.ArrayList;
@@ -72,27 +70,23 @@ void spawnNativePluginControllers(final Environment environment) throws IOExcept
7270
* For each plugin, attempt to spawn the controller daemon. Silently ignore any plugin that
7371
* don't include a controller for the correct platform.
7472
*/
75-
try (DirectoryStream<Path> stream = Files.newDirectoryStream(pluginsFile)) {
76-
for (final Path plugin : stream) {
77-
if (FileSystemUtils.isDesktopServicesStore(plugin)) {
78-
continue;
79-
}
80-
final PluginInfo info = PluginInfo.readFromProperties(plugin);
81-
final Path spawnPath = Platforms.nativeControllerPath(plugin);
82-
if (!Files.isRegularFile(spawnPath)) {
83-
continue;
84-
}
85-
if (!info.hasNativeController()) {
86-
final String message = String.format(
87-
Locale.ROOT,
88-
"plugin [%s] does not have permission to fork native controller",
89-
plugin.getFileName());
90-
throw new IllegalArgumentException(message);
91-
}
92-
final Process process =
93-
spawnNativePluginController(spawnPath, environment.tmpFile());
94-
processes.add(process);
73+
List<Path> paths = PluginInfo.extractAllPlugins(pluginsFile);
74+
for (Path plugin : paths) {
75+
final PluginInfo info = PluginInfo.readFromProperties(plugin);
76+
final Path spawnPath = Platforms.nativeControllerPath(plugin);
77+
if (!Files.isRegularFile(spawnPath)) {
78+
continue;
9579
}
80+
if (!info.hasNativeController()) {
81+
final String message = String.format(
82+
Locale.ROOT,
83+
"plugin [%s] does not have permission to fork native controller",
84+
plugin.getFileName());
85+
throw new IllegalArgumentException(message);
86+
}
87+
final Process process =
88+
spawnNativePluginController(spawnPath, environment.tmpFile());
89+
processes.add(process);
9690
}
9791
}
9892

0 commit comments

Comments
 (0)