...
Excerpt |
---|
A goal of the platform is to make working with messages and state as simple as working with plain old java objects. The X Platform's Application Data Modeler (ADM) allows modeling of messages and state entities in XML and provides utilities to generate source code that is instrumented to transparently handle encoding, serialization and transactional functionality that underpin the platform. This section and its subsections will familiarize you with theses modeling constructs and code generation tools. |
- Entity:
- Entities are used to model application state. In Talon, an application exposes its state to the platform by providing it with a single root object that references the rest of the application state. The single root forms an object graph that is held fully in memory, supports transactional semantics, and is replicated asynchronously to backup instances in a delta based pipelined fashion as application code modifies it in the course of processing.
- Message:
- A message can be thought of as a special type of entity that is enhanced to allow transport over the platform's Simple Message Abstract (SMA) layer. A message can't reference other entities because it is serialized as an independently transportable unit.
Embedded Entity:Anchor EmbeddedEntity EmbeddedEntity - An embedded entity models a collection of fields of primitive types or other embedded entities. An embedded entity can be embedded into a Message, Entity or other Embedded entity as a field, and become part of that type's serializable unit, e.g. not another node from the standpoint of ROG, and a transported part of a message from the standpoint of SMA.
As a convenience, there is also:
- Inlined Entity:
- An embedded entity can be "inlined" into another type such that it inherits the embedded entity's fields.
An application's state is formed by a collection of entities held entirely in memory and is rooted by a single node.
Messages are independently serializable units made up of primitive and embedded entities.
...
ADM Types
Primitive/Built-In Types:
...
Align | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||
Table 3: Collection Types
|
Restrictions on Collections
- Array types are limited to primitive, built-in, and embedded entity types. They are intended to allow embedded values that are transported along with a message or entity, and consequently:
- Queue, Set and Map types can only be used with non-embedded entities and may only use other non embedded entities as their values.
...
Note | ||||||
---|---|---|---|---|---|---|
| ||||||
Types from a model imported must be generated with the same encoding type as the model importing them. It is not possible to mix and match different encoding types within a message or entity. So if MessageA is generated with Xbuf and embedded EntityB is generated with Protobuf, Message cannot use EntityB as a field.
When generating code and copying model to output, encoding information is written to target model XML as a directive. If model for which code is generated and any of its imports have encoding mismatch, code generator will raise model validation error. For imported models that do not have encoding info (resolved directly to OS path or packaged to jar with earlier versions of ADM), this validation is not enforced. |
See also Imported Model Resolution
...
For UUID and XString types, additional zero garbage accessors to the underlying raw type which is backed by the message buffer are additionally generated (though only zero garbage when used in conjunction with Xbuf with pooling enabled). For these types, some additional accessors are also generated to allow copying the value into and out of the message in an efficient zero garbage fashion:
Code Block | ||||
---|---|---|---|---|
| ||||
@Generated(value="com.neeve.adm.AdmGenerator", date="Fri Jan 23 02:03:22 PST 2015") public interface IMyMessage extends extends IRogNode, IRogMessage { //Standard accessors: public void setMyStringField(final String val); public String getMyStringField(); //Copying accessors: public void setMyStringFieldFrom(final XString val); public void getMyStringFieldTo(final XString val); public T getMyStringFieldTo(XString.Factory<T> factory); //Unsafe accessor: public XString getMyStringFieldUnsafe(); } |
...
To avoid garbage for embedded messages entities when using Xbuf encoding, while still providing a mechanism for applications to hold such fields in state beyond the lifespan of the message from whence they came, additional take/lend accessors are generated for embedded entity fields. Considerations for using embedded entity fields in the context of message pooling are discussed in detail in the knowledge base article at: http://docs.neeveresearch.com/display/KB/Zero+Garbage+Nested+Entities
Code Block | ||||
---|---|---|---|---|
| ||||
@Generated(value="com.neeve.adm.AdmGenerator", date="Fri Jan 23 02:03:22 PST 2015") public interface IMyMessage extends extends IRogNode, IRogMessage { final public void setChildField(final Child2 val); final public Child2 getChildField(); final public void lendChildField(final Child2 val); final public Child2 takeChildField();} |
...
Code Block | ||
---|---|---|
| ||
public interface IEmployeeSalarayUpdateMessage extends IRogNode, IRogMessage { /** * Sets the value of this field to the provided SocialSecurityNumber value. */ public void setSsn(final String val); /** * Gets the value of 'ssn' * * @return The value of 'ssn' */ public String getSsn(); /** * Sets the value of 'salary' * <p> * <h2>Field Semantics</h2> * <p> * Represents a salary in US dollars. * * @param val The value to set. */ public void setSalary(final float val); /** * Gets the value of 'salary' * <p> * <h2>Field Semantics</h2> * <p> * Represents a salary in US dollars. * * @return The value of 'salary' */ public float getSalary(); } /** * <p> * Represents a social security number in the format xxx-xx-xxxx. * <p> * Detailed information about social security numbers can be found at the <a href="http://www.ssa.gov/">Social Security Website</a>. */ public class SocialSecurityNumber extends XString {...} |
Poolable String Types
The X Platform provides an XString implementation that allows zero garbage manipulation of Strings. Low latency applications should use XStrings instead of Java Strings in domain state This allows for zero garbage copy of fields to and from outbound and inbound messages and zero garbage manipulation of fields by domain logic. Although the use of XStrings will eliminate garbage, it will not eliminate object promotion across heap generations which can be an expensive operation. To avoid promotions, low latency applications also need the ability to pool and pre-allocate such fields. To make working with such types easier, the ADM model provides support for creating sub types of XString that are poolable. For String fields that are declared as poolable, the ADM code generator will generate code implementing a new type for the field that is a subtype of XString and the associated classes that allow for the pooling and pre-allocation of fields of this type. All of the methods currently available on XStrings will be available to the subtype. The XString documentation can be found at: http://build.neeveresearch.com/core/javadoc/LATEST/com/neeve/lang/XString.html
...
Code Block | ||||
---|---|---|---|---|
| ||||
@Generated(value="com.neeve.adm.AdmGenerator", date="Fri Jan 23 02:03:22 PST 2015") public interface IChildLongMap extends IRogLongMap<Child1>, Map<Long, Child1> {} @Generated(value="com.neeve.adm.AdmXbufGenerator", date="Fri Jan 23 02:03:22 PST 2015") final public class ChildLongMap extends RogLongMap<Child1> implements IChildLongMapRogLongMap<Child1> implements IChildLongMap, IXbufDesyncer, IRogJsonizable {...} |
...