/** * Tests whether or not the custom should be serialized. The criteria are: * <ul> * <li>the output stream must be at least the minimum supported version of the custom</li> * <li>the output stream must have the feature required by the custom (if any) or not be a transport client</li> * </ul> * <p> * That is, we only serialize customs to clients than can understand the custom based on the version of the client and the features * that the client has. For transport clients we can be lenient in requiring a feature in which case we do not send the custom but * for connected nodes we always require that the node has the required feature. * * @param out the output stream * @param custom the custom to serialize * @param <T> the type of the custom * @return true if the custom should be serialized and false otherwise */ static <T extends VersionedNamedWriteable & FeatureAware> boolean shouldSerialize(final StreamOutput out, final T custom) { if (out.getVersion().before(custom.getMinimalSupportedVersion())) { return false; } if (custom.getRequiredFeature().isPresent()) { final String requiredFeature = custom.getRequiredFeature().get(); // if it is a transport client we are lenient yet for a connected node it must have the required feature return out.hasFeature(requiredFeature) || out.hasFeature(TransportClient.TRANSPORT_CLIENT_FEATURE) == false; } return true; }
/** * Tests whether or not the custom should be serialized. The criteria are: * <ul> * <li>the output stream must be at least the minimum supported version of the custom</li> * <li>the output stream must have the feature required by the custom (if any) or not be a transport client</li> * </ul> * <p> * That is, we only serialize customs to clients than can understand the custom based on the version of the client and the features * that the client has. For transport clients we can be lenient in requiring a feature in which case we do not send the custom but * for connected nodes we always require that the node has the required feature. * * @param out the output stream * @param custom the custom to serialize * @param <T> the type of the custom * @return true if the custom should be serialized and false otherwise */ static <T extends VersionedNamedWriteable & FeatureAware> boolean shouldSerialize(final StreamOutput out, final T custom) { if (out.getVersion().before(custom.getMinimalSupportedVersion())) { return false; } if (custom.getRequiredFeature().isPresent()) { final String requiredFeature = custom.getRequiredFeature().get(); // if it is a transport client we are lenient yet for a connected node it must have the required feature return out.hasFeature(requiredFeature) || out.hasFeature(TransportClient.TRANSPORT_CLIENT_FEATURE) == false; } return true; }
/** * Tests whether or not the custom should be serialized. The criteria are: * <ul> * <li>the output stream must be at least the minimum supported version of the custom</li> * <li>the output stream must have the feature required by the custom (if any) or not be a transport client</li> * </ul> * <p> * That is, we only serialize customs to clients than can understand the custom based on the version of the client and the features * that the client has. For transport clients we can be lenient in requiring a feature in which case we do not send the custom but * for connected nodes we always require that the node has the required feature. * * @param out the output stream * @param custom the custom to serialize * @param <T> the type of the custom * @return true if the custom should be serialized and false otherwise */ static <T extends VersionedNamedWriteable & FeatureAware> boolean shouldSerialize(final StreamOutput out, final T custom) { if (out.getVersion().before(custom.getMinimalSupportedVersion())) { return false; } if (custom.getRequiredFeature().isPresent()) { final String requiredFeature = custom.getRequiredFeature().get(); // if it is a transport client we are lenient yet for a connected node it must have the required feature return out.hasFeature(requiredFeature) || out.hasFeature(TransportClient.TRANSPORT_CLIENT_FEATURE) == false; } return true; }