Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YOML = YAML object mapping language [BIG!] #363

Open
wants to merge 93 commits into
base: master
Choose a base branch
from

Conversation

ahgittin
Copy link
Contributor

As discussed on mailing list...

I've been spiking a new approach to our YAML modelling for java objects.

The root problem I want to solve is to that it's tedious, inconsistent, and poorly documented how YAML should map on to the Java items. Every new place we want to do this we use ad hoc code. This is an obstacle to writing new java items which can easily be configured in YAML by any Brooklyn user.

The idea of the solution is to have a schema for mapping Java <-> YAML so you can simply annotate the Java classes and the job's done. You get a working schema for reading from YAML without having to think about it. The thinking is that this lets us make many more things expressible in YAML, including:

I've built a prototype called "YOML" (YAML Object Mapping Language) and opened a PR for it [2].

As it stands it supports reading and writing (so we could improve our persistence model and be able to output reusable plans from the current state of the world -- though I've not worked on those), and it's designed to be very flexible, optimizing for the experience of the human reading and writing it.

It also has hooks for reflecting about itself -- meaning we could generate documentation and code completion proposals with explanations for everything that is YOML'd (though again not implemented).

It's integrated with the new BrooklynTypeRegistry (code which replaces the old fixed-type-category catalog, allowing arbitrary types and aliases; it's used currently, but not persisted, and we're not taking advantage of it yet; we could also use this to restrict who can use which types) and has a TypePlanTransformer so we can use it in specific places. You can use anywhere the YAML DSL is supported by saying $brooklyn:object-yoml: ..., and it's hooked in specially in one place, under brooklyn.initializers if you supply a map (previously only a list was allowed), with some sensor/effector tests at [3], in short allowing:

  • type: org.apache.brooklyn.entity.software.base.EmptySoftwareProcess
    brooklyn.initializers:
    echo-hi-name-from-config:
    type: ssh-effector
    command: echo hi ${NAME}
    env:
    NAME: $brooklyn:config("name")
    date:
    type: ssh-sensor
    command: date
    period: 100ms
    brooklyn.config:
    name: bob

A detailed write-up is at [4].

I could do an online brown-bag session next week if folks are interested.

[1] #282
2
[3] https://github.com/ahgittin/brooklyn-server/blob/yoml/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/yoml/YomlTypeRegistryEntityInitializersTest.java
[4] https://github.com/ahgittin/brooklyn-server/blob/yoml/utils/common/src/main/java/org/apache/brooklyn/util/yoml/sketch.md

ahgittin and others added 27 commits November 7, 2016 12:01
note core and client are no longer kept in sync; latest version of each has been taken
using serializers on the blackboard
and more refactor using now an internal package
and cleaning up sketch
fleshing out how explicit fields will handle defaults/aliases,
with tests,
and fixing a bug in primitive handling
also supporting multiple supertypes in the tests
mainly around findMethod
also failing test for map/list generics which i'm about to fix
tests demonstrate adding types and resolving them through the brooklyn type creation api
better handling for serializer collection and supertypes/java-type in underlying yoml and brooklyn registry integration
and error reporting
Alex Heneveld and others added 3 commits December 6, 2016 16:29
DslYomlObject.toString changed, as there is better toString support throughout
@ahgittin
Copy link
Contributor Author

test failures unrelated, described in #560

one small conflict:  `params` field added to AddSensor in master
This reverts commit 1108d8f.

Does not belong in this PR.  Included in apache#547 .
(imports conflicts in SshCommandSensor)
@ahgittin
Copy link
Contributor Author

More goddamn merge conflicts. Any objections to commit-then-review on this one?

@aledsage
Copy link
Contributor

aledsage commented May 2, 2017

@ahgittin with such a huge pull request, I think we should definitely stick with review before merging. We are hopefully going to find time next week to review this properly, with a concrete plan for how more members of the community would become familiar with this large code base, to build on and maintain it long term.

Mainly minor import/code conflicts. However one significant change, regarding persistence of AddSensor and subtypes. More care is taken here to ensure ability to rebind to previous state.
Conflicts: utils/common/src/test/java/org/apache/brooklyn/util/javalang/ReflectionsTest.java = both added tests
Fix conflicts - use stronger type token in refactored <Structured>ConfigKey classes
@ahgittin
Copy link
Contributor Author

Any update @aledsage ? Was it was reviewed the second week of May as planned and there were no comments? ;)

I'd like to use this for the catalog.bom syntax. Instead I'm having to write new ad-hoc parsing in order to support OSGi auto-wrapping. Please a high-level review.

@ahgittin
Copy link
Contributor Author

Updated for merge conflicts. Fixes access to AddSensor.params. Also incorporates latest OSGi works (#799 - not yet merged but including a fix to an issue this PR tested for but others didn't, recursive references being treated as templates).

Conflicts:
	core/src/main/java/org/apache/brooklyn/core/sensor/ssh/SshCommandSensor.java - imports
	utils/common/src/main/java/org/apache/brooklyn/util/collections/MutableSet.java - new methods added
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants