Watcher: Remove watcherbuild info (elastic/elasticsearch#3792)

Watcher does not require any unique build info anymore, as all is put into
the MANIFEST.MF file during the build.

Also the xpack-properties is unused now and can be deleted.

Original commit: elastic/x-pack-elasticsearch@62f121c979
This commit is contained in:
Alexander Reelsen 2016-10-18 13:19:13 +02:00 committed by GitHub
parent 9c54173e74
commit 74334b3713
5 changed files with 1 additions and 137 deletions

View File

@ -1,112 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.watcher;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.joda.time.DateTimeZone;
import org.joda.time.format.ISODateTimeFormat;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class WatcherBuild {
public static final WatcherBuild CURRENT;
static {
String versionName = "NA";
String hash = "NA";
String hashShort = "NA";
String timestamp = "NA";
try (InputStream is = WatcherBuild.class.getResourceAsStream("/watcher-build.properties")) {
Properties props = new Properties();
props.load(is);
hash = props.getProperty("hash", hash);
if (!hash.equals("NA")) {
hashShort = hash.substring(0, 7);
}
String gitTimestampRaw = props.getProperty("timestamp");
if (gitTimestampRaw != null) {
timestamp = ISODateTimeFormat.dateTimeNoMillis().withZone(DateTimeZone.UTC).print(Long.parseLong(gitTimestampRaw));
}
versionName = props.getProperty("version", "NA");
} catch (Exception e) {
// just ignore...
}
CURRENT = new WatcherBuild(versionName, hash, hashShort, timestamp);
}
private final String versionName;
private final String hash;
private final String hashShort;
private final String timestamp;
WatcherBuild(String versionName, String hash, String hashShort, String timestamp) {
this.versionName = versionName;
this.hash = hash;
this.hashShort = hashShort;
this.timestamp = timestamp;
}
public String versionName() {
return versionName;
}
public String hash() {
return hash;
}
public String hashShort() {
return hashShort;
}
public String timestamp() {
return timestamp;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
WatcherBuild that = (WatcherBuild) o;
if (!hash.equals(that.hash)) return false;
if (!hashShort.equals(that.hashShort)) return false;
if (!timestamp.equals(that.timestamp)) return false;
if (!versionName.equals(that.versionName)) return false;
return true;
}
@Override
public int hashCode() {
int result = hash.hashCode();
result = 31 * result + hashShort.hashCode();
result = 31 * result + timestamp.hashCode();
result = 31 * result + versionName.hashCode();
return result;
}
public static WatcherBuild readBuild(StreamInput in) throws IOException {
String versionName = in.readString();
String hash = in.readString();
String hashShort = in.readString();
String timestamp = in.readString();
return new WatcherBuild(versionName, hash, hashShort, timestamp);
}
public static void writeBuild(WatcherBuild build, StreamOutput out) throws IOException {
out.writeString(build.versionName);
out.writeString(build.hash);
out.writeString(build.hashShort);
out.writeString(build.timestamp);
}
}

View File

@ -8,17 +8,16 @@ package org.elasticsearch.xpack.watcher.transport.actions.stats;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.block.ClusterBlockException;
import org.elasticsearch.cluster.block.ClusterBlockLevel;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.license.XPackLicenseState;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
import org.elasticsearch.xpack.watcher.WatcherBuild;
import org.elasticsearch.xpack.watcher.WatcherLifeCycleService;
import org.elasticsearch.xpack.watcher.WatcherService;
import org.elasticsearch.xpack.watcher.execution.ExecutionService;
@ -65,7 +64,6 @@ public class TransportWatcherStatsAction extends WatcherTransportAction<WatcherS
statsResponse.setThreadPoolQueueSize(executionService.executionThreadPoolQueueSize());
statsResponse.setWatchesCount(watcherService.watchesCount());
statsResponse.setThreadPoolMaxSize(executionService.executionThreadPoolMaxSize());
statsResponse.setBuild(WatcherBuild.CURRENT);
statsResponse.setWatcherMetaData(lifeCycleService.watcherMetaData());
if (request.includeCurrentWatches()) {
@ -82,6 +80,4 @@ public class TransportWatcherStatsAction extends WatcherTransportAction<WatcherS
protected ClusterBlockException checkBlock(WatcherStatsRequest request, ClusterState state) {
return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_READ);
}
}

View File

@ -11,7 +11,6 @@ import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.xpack.watcher.WatcherBuild;
import org.elasticsearch.xpack.watcher.WatcherMetaData;
import org.elasticsearch.xpack.watcher.WatcherState;
import org.elasticsearch.xpack.watcher.execution.QueuedWatch;
@ -24,7 +23,6 @@ import java.util.Locale;
public class WatcherStatsResponse extends ActionResponse implements ToXContent {
private WatcherBuild build;
private long watchesCount;
private WatcherState watcherState;
private long threadPoolQueueSize;
@ -81,17 +79,6 @@ public class WatcherStatsResponse extends ActionResponse implements ToXContent {
this.watcherState = watcherServiceState;
}
/**
* @return The watcher plugin build information.
*/
public WatcherBuild getBuild() {
return build;
}
void setBuild(WatcherBuild build) {
this.build = build;
}
@Nullable
public List<WatchExecutionSnapshot> getSnapshots() {
return snapshots;
@ -125,7 +112,6 @@ public class WatcherStatsResponse extends ActionResponse implements ToXContent {
threadPoolQueueSize = in.readLong();
threadPoolMaxSize = in.readLong();
watcherState = WatcherState.fromId(in.readByte());
build = WatcherBuild.readBuild(in);
if (in.readBoolean()) {
int size = in.readVInt();
@ -151,7 +137,6 @@ public class WatcherStatsResponse extends ActionResponse implements ToXContent {
out.writeLong(threadPoolQueueSize);
out.writeLong(threadPoolMaxSize);
out.writeByte(watcherState.getId());
WatcherBuild.writeBuild(build, out);
if (snapshots != null) {
out.writeBoolean(true);

View File

@ -1,3 +0,0 @@
version=${project.version}
hash=${buildNumber}
timestamp=${timestamp}

View File

@ -8,7 +8,6 @@ package org.elasticsearch.xpack.watcher.transport.action.stats;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.junit.annotations.TestLogging;
import org.elasticsearch.xpack.watcher.WatcherBuild;
import org.elasticsearch.xpack.watcher.WatcherState;
import org.elasticsearch.xpack.watcher.client.WatcherClient;
import org.elasticsearch.xpack.watcher.condition.compare.CompareCondition;
@ -43,7 +42,6 @@ public class WatcherStatsTests extends AbstractWatcherIntegrationTestCase {
assertThat(response.getThreadPoolQueueSize(), is(0L));
assertThat(response.getWatchesCount(), is(0L));
assertThat(response.getThreadPoolMaxSize(), is(timeWarped() ? 1L : 0L));
assertThat(response.getBuild(), is(WatcherBuild.CURRENT));
}
public void testWatchCountStats() throws Exception {