public class AttributeStringUtils
extends java.lang.Object
Attribute
s into strings. Spec is defined by Mesos documentation at:
http://mesos.apache.org/documentation/latest/attributes-resources/Modifier and Type | Class and Description |
---|---|
static class |
AttributeStringUtils.NameValue
A utility class which pairs an attribute name with an attribute value.
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
join(java.lang.String name,
java.lang.String value)
Converts the provided name + value strings to an attribute string.
|
static AttributeStringUtils.NameValue |
split(java.lang.String attribute)
Returns the name and value from the provided attribute string.
|
static java.lang.String |
toString(Attribute attribute)
Converts the provided attribute's name + value into a string which follows the format defined
by Mesos.
|
static java.lang.String |
toString(java.util.List<Attribute> attributes)
Converts the provided list of zero or more attributes into a string suitable for comparison.
|
static java.util.List<java.lang.String> |
toStringList(java.lang.String joinedAttributes) |
static java.lang.String |
valueString(Attribute attribute)
Converts the provided attribute's value into a string which follows the format defined by
Mesos:
attributes : attribute ( ";" attribute )*
attribute : text ":" ( scalar | range | text )
text : [a-zA-Z0-9_/.-]
scalar : floatValue
floatValue : ( intValue ( "." intValue )? ) | ... |
public static java.util.List<java.lang.String> toStringList(java.lang.String joinedAttributes)
public static java.lang.String toString(java.util.List<Attribute> attributes) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- if some part of the provided attributes couldn't be
serializedpublic static java.lang.String join(java.lang.String name, java.lang.String value)
which does the opposite
public static AttributeStringUtils.NameValue split(java.lang.String attribute)
which does the opposite
public static java.lang.String toString(Attribute attribute) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
valueString(Attribute)
public static java.lang.String valueString(Attribute attribute) throws java.lang.IllegalArgumentException
attributes : attribute ( ";" attribute )*
attribute : text ":" ( scalar | range | text )
text : [a-zA-Z0-9_/.-]
scalar : floatValue
floatValue : ( intValue ( "." intValue )? ) | ...
intValue : [0-9]+
range : "[" rangeValue ( "," rangeValue )* "]"
rangeValue : scalar "-" scalar
set : "{" text ( "," text )* "}"
NOTE that it is difficult if not impossible to consistently perform the inverse of this
operation. For example, how can you tell if something is supposed to be a SCALAR value or a
TEXT value? [0-9.]+ is valid in both cases! Your best hope is to consistently convert to
string, and then compare strings...java.lang.IllegalArgumentException
- if some part of the provided attributes couldn't be
serialized