Marvel: Use cluster UUID in hash function

Original commit: elastic/x-pack-elasticsearch@919f7928f0
This commit is contained in:
Tanguy Leroux 2015-08-20 09:54:47 +02:00
parent 392398c7aa
commit f08b53eb2d
2 changed files with 5 additions and 5 deletions

View File

@ -44,8 +44,9 @@ public class LicensesRenderer extends AbstractRenderer<LicensesMarvelDoc> {
builder.field(Fields.MAX_NODES, license.maxNodes());
builder.field(Fields.ISSUED_TO, license.issuedTo());
builder.field(Fields.ISSUER, license.issuer());
builder.field(Fields.HKEY, hash(license, marvelDoc.getClusterName()));
builder.field(Fields.HKEY, hash(license, marvelDoc.clusterUUID()));
builder.endObject();
}
}
builder.endArray();
@ -67,8 +68,8 @@ public class LicensesRenderer extends AbstractRenderer<LicensesMarvelDoc> {
return hash(status(license), license.uid(), license.type(), String.valueOf(license.expiryDate()), clusterName);
}
public static String hash(String licenseStatus, String licenseUid, String licenseType, String licenseExpiryDate, String clusterName) {
String toHash = licenseStatus + licenseUid + licenseType + licenseExpiryDate + clusterName;
public static String hash(String licenseStatus, String licenseUid, String licenseType, String licenseExpiryDate, String clusterUUID) {
String toHash = licenseStatus + licenseUid + licenseType + licenseExpiryDate + clusterUUID;
return Hashing.sha256().hashString(toHash, Charsets.UTF_8).toString();
}

View File

@ -11,7 +11,6 @@ import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.license.core.License;
import org.elasticsearch.license.plugin.LicensePlugin;
import org.elasticsearch.marvel.MarvelPlugin;
import org.elasticsearch.marvel.agent.collector.licenses.LicensesCollector;
@ -94,7 +93,7 @@ public class LicensesRendererIT extends ESIntegTestCase {
// We basically recompute the hash here
String hkey = (String) ((Map) license).get(LicensesRenderer.Fields.HKEY.underscore().toString());
String recalculated = LicensesRenderer.hash(status, uid, type, String.valueOf(expiryDate), cluster().getClusterName());
String recalculated = LicensesRenderer.hash(status, uid, type, String.valueOf(expiryDate), clusterUUID);
assertThat(hkey, equalTo(recalculated));
assertThat((String) ((Map) license).get(LicensesRenderer.Fields.FEATURE.underscore().toString()), not(isEmptyOrNullString()));