-
Notifications
You must be signed in to change notification settings - Fork 17
OperationalString
The OperationalString is the unit of deployment in Rio. It contains definitions that provide context on how to provision, manage, monitor and instantiate services through the network. An OperationalString is created through the use of a Groovy DSL. This section will walk you through the details of the OperationalString.
Why the name OperationalString? The name comes from creating a string (collection) of services that execute in an operational context. The OperationalString is sometimes referred to as an opstring as well.
he image below depicts the sections of an OperationalString. We will drill into each of these sections and explain the elements that make them up.
The OperationalString contains service declarations. Each enclosing service
declaration defines instantiation properties, associations (what other services this service is associated to), service SLA policies (scalability, etc ...), initialization parameters and configuration.
The spring
element is a way to easily declare the deployment and activation of a Spring application using Rio. Using the Spring bean, a Spring application can be dynamically deployed and managed using Rio.
The serviceExec
element provides the declarative support needed to encapsulate the control and monitoring of external services. Service control adapters represent applications/services, adding network wide visibility and control. Using this approach, we can attach monitoring, metering and SLA control to existing applications.
The OperationalString is also a reflexive entity. This means the OperationalString can include other OperationalStrings, creating a composite (nested) deployment. With this approach a single deployment can include multiple OperationalStrings.
What follows displays a context free grammar representation of the Rio DSL, using EBNF to document the Rio DSL syntax.
Notation:
Item | Description |
---|---|
Non-terminals | Are highlighted and displayed as plain text, as in service-header . |
Terminals | Are quoted and highlighted in green, for example deployment is a Rio DSL element. |
() | (parenthesis) are used to denote grouping. |
? | Denotes the optional appearance of a symbol or group of symbols. |
* | You can optionally append a list of one or more non-terminals. |
; | Is used to denote the end of each production. |
grammar rio_dsl;
opstring : 'deployment' '(' 'name:' name (',' 'debug:' (true | false) )? ')' '{'
opstring_body
'}' ;
opstring_body : codebase? groups? locators? (artifact | resources)? include? common? service* spring* service_exec* ;
include : 'include' identifier ;
groups : 'groups' name (',' name)* ;
locators : 'locators' (ip_address | host_name) (',' (ip_address | host_name))* ;
service : 'service' '(' service_header ')' '{'
instantiation_attrs
sla?
'}' ;
spring : 'spring' '(' service_header',' 'config:'name ')' '{'
instantiation_attrs
sla?
'}' ;
service_exec : 'serviceExec' '(' service_header ')' '{'
instantiation_attrs
sla?
execute
'}' ;
execute : 'execute' '(' 'command:' name (',' 'inDirectory:' name ')')? ('{'
'environment' '{' property '}'
'}')? ;
service_header : 'name:' name
(',' 'fork:' (yes | no ))?
(',' 'type:' (('fixed') | ('dynamic')) )?
(',' 'jvmArgs:' args )?
(',' 'environment:' args )? ;
artifact : 'artifact' (('id:' name) | ('ref:' name))? identifier? ;
resources : 'resources' (('id:' name) | ('ref:' name))? jar? (',' jar)* ;
codebase : 'codebase' identifier ;
instantiation_attrs : interfaces? implementation data?
common?
'maintain' digit
('comment' identifier)?
maxPerMachine? ;
implementation : 'implementation' '(' 'class:' class_name ')' '{'
(resources | artifact)
sharedComponent?
'}' ;
interfaces : 'interfaces' '{'
'classes' class_name (',' class_name)*
(resources | artifact)
'}' ;
common : logging? associations? association? parameters? configuration? system_requirements? cluster? ;
sharedComponent : 'sharedComponent' '(' 'class:' class_name ')' '{'
(resources | artifact)
'}' ;
associations : 'associations' '{' association (',' association )* '}' ;
association : 'association' '(' 'type:' (('uses') | ('requires') | ('colocated') | ('opposed') | ('isolated')) ','
'name:' name (',' 'serviceType:' class_name)? (',' 'property:' name)? ')' ( '{'
association_management
'}' )? ;
association_management : 'management' 'proxy:' class_name (',' proxyType)? (',' strategy)? (',' inject)? (',' filter)?
(',' serviceDiscoveryTimeout)? ;
proxyType : 'proxyType:' (('jdk')|('cglib')) ;
strategy : 'strategy:' class_name ;
inject : 'inject:' (('lazy') | ('eager')) ;
/* see AssociationMatchFilter javadoc */
filter : 'filter:' class_name ;
serviceDiscoveryTimeout: 'serviceDiscoveryTimeout:' digit ','
'units:' (('milliseconds') | ('seconds') | ('minutes') | ('hours') | ('days') );
sla : 'sla' '(' 'id:' identifier (',' 'low:' digit)? (',' 'high:' digit )? ')' '{'
sla_policy declarative_monitor?
'}' ;
sla_policy : 'policy' 'type:' (('scaling') | ('relocation') | ('notify')) (',' 'max:' digit)? ( ',' 'lowerDampener:' digit)? (',' 'upperDampener:' digit)?;
declarative_monitor : 'monitor' 'name:' name ',' 'property:' name ',' 'period:' digit ;
maxPerMachine : 'maxPerMachine' digit (',' 'type:' (('physical') | ('virtual')) )? ;
configuration : 'configuration' '(' ( 'file:' ('classpath:')? name | inline_configuration )? ')' ;
parameters : 'parameters' '{' parameter parameter* '}' ;
parameter : 'parameter' 'name:' identifier ',' 'value:' identifier ;
property : 'property' 'name:' identifier ',' 'value:' identifier ;
logging : 'logging' '{' logger '}' ;
logger : 'logger' class_or_package (',' handler_class_name)? ',' (('SEVERE') | ('WARNING') | ('INFO') | ('CONFIG') |
('FINE') | ('FINER') | ('FINEST') | ('ALL') | ('OFF')) ;
cluster : 'cluster' (host_name | wildcard_ip_address) (',' (host_name | wildcard_ip_address))* ;
platformRequirement : 'platformRequirement' '(' 'name:' name (',' 'type:' class_name)? (',' 'version:' identifier)? ')' ;
system_requirements : 'systemRequirements' ( 'ref:' name | ( ( '(' 'id:' name ')' )? '{'
software* platformRequirement* utilization* memory? diskspace? '}' ) )? ;
software : 'software' '(' 'name:' name (',' 'version:' name)? (',' 'removeOnDestroy:' (true | false) )? (',' 'classpathresource:' (true | false) )? ')' '{'
install postInstall?
'}' ;
install : 'install' 'source:' identifier ',' 'target:' identifier (',' 'unarchive:' (true | false) )? ;
postInstall : 'postInstall' '(' 'removeOnCompletion:' (true | false) ')' '{'
'execute' 'command:' identifier
'}';
utilization : 'utilization:' 'id:' (('CPU') | ('Memory' )) ',' 'high:' digit ( ',' 'low:'digit)? ;
diskspace : 'diskspace' ('available:' digit)? ( ','? 'capacity:' digit)? ;
memory : 'memory' ('available:' digit)? ( ','? 'capacity:' digit)? ;
data : 'data' 'source:' identifier ',' 'target:' identifier (',' 'unarchive:' (true | false) )? (',' 'perms:' identifier )? ;
host_name : string_literal | ('.' string_literal)* ;
ip_address : digit '.' digit '.' digit '.' digit ;
wildcard_ip_address : digit '.' ('*'|digit) ( ( '.' ( '*'| digit) )? ( '.'('*'| digit))?)? ;
handler_class_name : class_name;
class_name : class_or_package ;
class_or_package : ID;
inline_configuration : string_literal ;
args : string_literal ;
true : 'true';
false : 'false';
yes : 'yes' ;
no : 'no' ;
jar : name'.jar' ;
identifier : name ;
name : string_literal ;
string_literal : '"'ID'"';
digit : ('0'..'9')* ;
ID : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_')*;