/** * Returns a set of custom meta data types when any custom metadata for the cluster has changed * between the previous cluster state and the new cluster state. custom meta data types are * returned iff they have been added, updated or removed between the previous and the current state */ public Set<String> changedCustomMetaDataSet() { Set<String> result = new HashSet<>(); ImmutableOpenMap<String, MetaData.Custom> currentCustoms = state.metaData().customs(); ImmutableOpenMap<String, MetaData.Custom> previousCustoms = previousState.metaData().customs(); if (currentCustoms.equals(previousCustoms) == false) { for (ObjectObjectCursor<String, MetaData.Custom> currentCustomMetaData : currentCustoms) { // new custom md added or existing custom md changed if (previousCustoms.containsKey(currentCustomMetaData.key) == false || currentCustomMetaData.value.equals(previousCustoms.get(currentCustomMetaData.key)) == false) { result.add(currentCustomMetaData.key); } } // existing custom md deleted for (ObjectObjectCursor<String, MetaData.Custom> previousCustomMetaData : previousCustoms) { if (currentCustoms.containsKey(previousCustomMetaData.key) == false) { result.add(previousCustomMetaData.key); } } } return result; }
/** * For interoperability with transport clients older than 6.3, we need to strip customs * from the cluster state that the client might not be able to deserialize * * @param clusterState the cluster state to filter the customs from * @return the adapted cluster state */ public static ClusterState filterCustomsForPre63Clients(ClusterState clusterState) { final ClusterState.Builder builder = ClusterState.builder(clusterState); clusterState.customs().keysIt().forEachRemaining(name -> { if (PRE_6_3_CLUSTER_CUSTOMS_WHITE_LIST.contains(name) == false) { builder.removeCustom(name); } }); final MetaData.Builder metaBuilder = MetaData.builder(clusterState.metaData()); clusterState.metaData().customs().keysIt().forEachRemaining(name -> { if (PRE_6_3_METADATA_CUSTOMS_WHITE_LIST.contains(name) == false) { metaBuilder.removeCustom(name); } }); return builder.metaData(metaBuilder).build(); }
for (ObjectObjectCursor<String, Custom> cursor : metaData.customs()) { if (cursor.value.context().contains(context)) { builder.startObject(cursor.key);
for (ObjectObjectCursor<String, MetaData.Custom> cursor : metaData.customs()) { builder.startObject(cursor.key); cursor.value.toXContent(builder, params);
/** * Returns a set of custom meta data types when any custom metadata for the cluster has changed * between the previous cluster state and the new cluster state. custom meta data types are * returned iff they have been added, updated or removed between the previous and the current state */ public Set<String> changedCustomMetaDataSet() { Set<String> result = new HashSet<>(); ImmutableOpenMap<String, MetaData.Custom> currentCustoms = state.metaData().customs(); ImmutableOpenMap<String, MetaData.Custom> previousCustoms = previousState.metaData().customs(); if (currentCustoms.equals(previousCustoms) == false) { for (ObjectObjectCursor<String, MetaData.Custom> currentCustomMetaData : currentCustoms) { // new custom md added or existing custom md changed if (previousCustoms.containsKey(currentCustomMetaData.key) == false || currentCustomMetaData.value.equals(previousCustoms.get(currentCustomMetaData.key)) == false) { result.add(currentCustomMetaData.key); } } // existing custom md deleted for (ObjectObjectCursor<String, MetaData.Custom> previousCustomMetaData : previousCustoms) { if (currentCustoms.containsKey(previousCustomMetaData.key) == false) { result.add(previousCustomMetaData.key); } } } return result; }
/** * Returns a set of custom meta data types when any custom metadata for the cluster has changed * between the previous cluster state and the new cluster state. custom meta data types are * returned iff they have been added, updated or removed between the previous and the current state */ public Set<String> changedCustomMetaDataSet() { Set<String> result = new HashSet<>(); ImmutableOpenMap<String, MetaData.Custom> currentCustoms = state.metaData().customs(); ImmutableOpenMap<String, MetaData.Custom> previousCustoms = previousState.metaData().customs(); if (currentCustoms.equals(previousCustoms) == false) { for (ObjectObjectCursor<String, MetaData.Custom> currentCustomMetaData : currentCustoms) { // new custom md added or existing custom md changed if (previousCustoms.containsKey(currentCustomMetaData.key) == false || currentCustomMetaData.value.equals(previousCustoms.get(currentCustomMetaData.key)) == false) { result.add(currentCustomMetaData.key); } } // existing custom md deleted for (ObjectObjectCursor<String, MetaData.Custom> previousCustomMetaData : previousCustoms) { if (currentCustoms.containsKey(previousCustomMetaData.key) == false) { result.add(previousCustomMetaData.key); } } } return result; }
/** * Returns a set of custom meta data types when any custom metadata for the cluster has changed * between the previous cluster state and the new cluster state. custom meta data types are * returned iff they have been added, updated or removed between the previous and the current state */ public Set<String> changedCustomMetaDataSet() { Set<String> result = new HashSet<>(); ImmutableOpenMap<String, MetaData.Custom> currentCustoms = state.metaData().customs(); ImmutableOpenMap<String, MetaData.Custom> previousCustoms = previousState.metaData().customs(); if (currentCustoms.equals(previousCustoms) == false) { for (ObjectObjectCursor<String, MetaData.Custom> currentCustomMetaData : currentCustoms) { // new custom md added or existing custom md changed if (previousCustoms.containsKey(currentCustomMetaData.key) == false || currentCustomMetaData.value.equals(previousCustoms.get(currentCustomMetaData.key)) == false) { result.add(currentCustomMetaData.key); } } // existing custom md deleted for (ObjectObjectCursor<String, MetaData.Custom> previousCustomMetaData : previousCustoms) { if (currentCustoms.containsKey(previousCustomMetaData.key) == false) { result.add(previousCustomMetaData.key); } } } return result; }
for (ObjectObjectCursor<String, Custom> custom : currentState.metaData().customs()) { if (custom.value.context().contains(MetaData.XContentContext.API) == false) { mdBuilder.removeCustom(custom.key);
for (ObjectObjectCursor<String, Custom> cursor : metaData.customs()) { Custom proto = lookupPrototypeSafe(cursor.key); if (proto.context().contains(context)) {
for (ObjectObjectCursor<String, Custom> cursor : metaData.customs()) { if (cursor.value.context().contains(context)) { builder.startObject(cursor.key);
/** * For interoperability with transport clients older than 6.3, we need to strip customs * from the cluster state that the client might not be able to deserialize * * @param clusterState the cluster state to filter the customs from * @return the adapted cluster state */ public static ClusterState filterCustomsForPre63Clients(ClusterState clusterState) { final ClusterState.Builder builder = ClusterState.builder(clusterState); clusterState.customs().keysIt().forEachRemaining(name -> { if (PRE_6_3_CLUSTER_CUSTOMS_WHITE_LIST.contains(name) == false) { builder.removeCustom(name); } }); final MetaData.Builder metaBuilder = MetaData.builder(clusterState.metaData()); clusterState.metaData().customs().keysIt().forEachRemaining(name -> { if (PRE_6_3_METADATA_CUSTOMS_WHITE_LIST.contains(name) == false) { metaBuilder.removeCustom(name); } }); return builder.metaData(metaBuilder).build(); }
for (ObjectObjectCursor<String, Custom> cursor : metaData.customs()) { if (cursor.value.context().contains(context)) { builder.startObject(cursor.key);
/** * For interoperability with transport clients older than 6.3, we need to strip customs * from the cluster state that the client might not be able to deserialize * * @param clusterState the cluster state to filter the customs from * @return the adapted cluster state */ public static ClusterState filterCustomsForPre63Clients(ClusterState clusterState) { final ClusterState.Builder builder = ClusterState.builder(clusterState); clusterState.customs().keysIt().forEachRemaining(name -> { if (PRE_6_3_CLUSTER_CUSTOMS_WHITE_LIST.contains(name) == false) { builder.removeCustom(name); } }); final MetaData.Builder metaBuilder = MetaData.builder(clusterState.metaData()); clusterState.metaData().customs().keysIt().forEachRemaining(name -> { if (PRE_6_3_METADATA_CUSTOMS_WHITE_LIST.contains(name) == false) { metaBuilder.removeCustom(name); } }); return builder.metaData(metaBuilder).build(); }
private void restoreGlobalStateIfRequested(MetaData.Builder mdBuilder) { if (request.includeGlobalState()) { if (metaData.persistentSettings() != null) { Settings settings = metaData.persistentSettings(); clusterSettings.validateUpdate(settings); mdBuilder.persistentSettings(settings); } if (metaData.templates() != null) { // TODO: Should all existing templates be deleted first? for (ObjectCursor<IndexTemplateMetaData> cursor : metaData.templates().values()) { mdBuilder.put(cursor.value); } } if (metaData.customs() != null) { for (ObjectObjectCursor<String, MetaData.Custom> cursor : metaData.customs()) { if (!RepositoriesMetaData.TYPE.equals(cursor.key)) { // Don't restore repositories while we are working with them // TODO: Should we restore them at the end? mdBuilder.putCustom(cursor.key, cursor.value); } } } } }
for(ObjectObjectCursor<String, Custom> custom : currentState.metaData().customs()) { if(!custom.value.context().contains(MetaData.XContentContext.API)) { mdBuilder.removeCustom(custom.key);