Title: Beanbag: A Framework for OnSite Synchronization
1Beanbag A Framework for On-Site Synchronization
- Yingfei Xiong (speaker), University of Tokyo
- Zhenjiang Hu, National Institute of Informatics /
University of Tokyo - Song Hui, Peking University
- Masato Takeichi, University of Tokyo
- Haiyan Zhao, Peking University
- Hong Mei, Peking University
2Example An EJB Modeling Tool(Enterprise
JavaBeans)
User
SignModule
SignModule
User
SignModule
3On-Site Synchronization
- We call such synchronization On-Site
Synchronization. - Characteristics
- Synchronization need to be completed in a short
time constraint - No predefined synchronization direction
4Existing Approaches onOff-Site Synchronization
- Synchronizing between applications
- Manipulating data on external copies
5Not Enough for On-Site Synchronization
- Importing and exporting degrades system
performance - No clear separation of data
6No clear separation of data
User
User
7Our Contribution Beanbag
- Beanbag is a framework for supporting on-site
synchronization.
- Beanbag(???,??) is also a traditional Asian game
for keeping several beanbags consistent - The actor must response in a short time or the
bag will fall to the ground - The bags can be thrown in any directions
The picture is obtained from www.city.kodaira.tok
yo.jp
8An Overview of Beanbag
Users
Updates
------------ ------------ ------------ -----------
-
On-Site Synchronizer
Compile
Application Data
Beanbag Program
Updates
9Beanbag Program for the EJB
- main(ejbs, modules, entitybeans)
- containmentRefsltattr"Module"gt(ejbs, modules)
- for ejb, entitybean in ejbs, entitybeans
- persistent(ejb, entitybean, modules)
- nonPersistent(ejb, entitybean)
- ejb null entitybean null
-
10Beanbag Program for the EJB
- persistent(ejb, entitybean, modules)
- var moduleRef, moduleName
- ejb."Persistent" true
- entitybean."EJBName" ejb."Name"
- moduleRef ejb."Module"
- !modules.moduleRef module
- entitybean."ModuleName" module.Name
-
- nonPersistent(ejb, entitybean)
- ejb."Persistent" false
- entitybean null
11Describing Updates
Assign a unique id for each object
4
5
1
6
2
3
12Describing Updates
Describing attribute modification
4
5
1
User
6
2
3
ejbs 2-gtName-gt!User module
s void entityBeans void
13Describing Updates
Describing deletion
4
5
1
6
2
3
ejbs void modules
4-gt!null entityBeans void
14Describing Updates
Describing Insertion
4
5
1
6
2
3
ejbs 7-gtName-gt!AccessRight,
Persistent-gt!true modules
void entityBeans void
15An Update Propagation of EJB Tool
ejbs 2-gtName-gt!User module
s void entityBeans void
EJB Program
------------ ------------ ------------ -----------
-
User
Compile
Synchronizer
User
ejbs 2-gtName-gt!User module
s void entityBeans 5-gtName-gt!User
16How we compile a Beanbag program
- Consider an example
- var c
- ca.Name
- cb.Name
-
17ca.Name
a Name-gt!X c nomod
ca.Name
a Name-gt!X c !X
18ca.Name
a Persistent-gt!true c !X
ca.Name
a Persistent-gt!true, Name-gt!X c !X
19ca.Name
a Name-gt!Y c !X
ca.Name
Failure!
20Conjunction
a nomod b name-gt!x
b name-gt!x c nomod
a nomod c !x
var c ca.name cb.name
cb.name
ca.name
a name-gt!x b name-gt!x
b name-gt!xc !x
a name-gt!xc !x
21Primitive Relations and Combinators in BeanBag
- In Beanbag, we define six types of primitive
relations - ab
- ax
- a.Namec
- !a.bc
- ab
- altgtb
- three gluing constructs
- conjuction
- disjunction
- the for statement
- and some other constructs defined as syntax sugar
of the above
Refer to our paper and the website for more
details
22Implementation
- We have implemented Beanbag in Java
- The implementation is published under MIT license
Url http//code.google.com/p/synclib/
23Conclusion
- We have proposed a synchronization language,
Beanbag, for users to describe consistency
relations over data - We have given execution semantics for Beanbag to
turn a program into a synchronizer. The main
input and output of the synchronizer are updates - We have implemented Beanbag and tested its
practicability by applying it to several
applications
24Old and New Version of Beanbag
25Appendix Index
- Semantics Details
- data type and updates
- ab, ax, !d.kv
- disjunction, for
- State of Synchronizer
- Comparison with constraint solvers
26Constraint Solvers
- Constraint solvers try to find a set of values
satisfying a logic expression - Beanbag is not as declarative as constraint
solvers, - but every construct declared in Beanbag has a
clear execution semantics, which - ensures a short synchronization time
- provide precise control over behavior
back
27State of Synchronizer
- Synchronizers are stateful. Some synchronizers
need to store some information in their states. - !a.bc need to store the current values of a, b
- disjunction needs to store the index of the last
succeeded inner synchronizer - Every synchronizer contains to procedures
- initialize to provide some initial values to
initialize the state - synchronize to synchronize the updates we have
seen
back
28Primitives Update
- An update is a function mapping from some data
from other data - An update on primitives is just a replacing of
the old value with the new value - !c(a)c
29Dictionaries
- Real world data is more complex than primitive
values - Beanbag uses dictionaries to describe complex
data structures - A dictionary maps keys to values
- 1-gta, 2-gtb, 3-gtc
- Many data structures can be mapped to dictionaries
30Describe data using dictionaries
- 1-gtName-gt"SignOnEJB",
- Persistent-gtfalse,
- Module-gt4,
- 2-gtName-gt"UserEJB",
- Persistent-gttrue,
- Module-gt4,
- 3-gtName-gt"DepartmentEJB",
- Persistent-gttrue,
- Module-gt4
- ,
- 4-gtName-gt"SignOn",
- Description-gt"This module is for
authenticating users" -
31Updates on Dictionary
- An update on dictionary is also a dictionary
mapping from keys to updates
,4-gty
x
1-gta, 2-gtb, 3-gtc
1-gt!x, 2-gt!null, 4-gt!y
32Nested Updates
1-gtName-gt"SignOnEJB", Persistent-gtfalse
, Module-gt1, 2-gtName-gt"UserEJB",
Persistent-gttrue, Module-gt1,
3-gtName-gt"DepartmentEJB",
Persistent-gttrue, Module-gt1
User
2-gtName-gt!User
back
33Equal
- A basic synchronizer a b
- Keeps two variables equal
a !3b nomod
3
a2
ab
3
b2
a !3 b !3
34Equal
- A basic synchronizer a b
- Keeps two variables equal
a nomodb !3
3
a2
ab
3
b2
a !3 b !3
35Equal
- A basic synchronizer a b
- Keeps two variables equal
a nomodb nomod
a2
ab
b2
a nomod b nomod
36Equal
- A basic synchronizer a b
- Keeps two variables equal
a !3b !3
3
a2
ab
3
b2
a !3 b !3
37Equal
- A basic synchronizer a b
- Keeps two variables equal
a !3b !4
3
a2
ab
4
b2
Failure!
38Equal on Dictionaries
a 1-gt!ab 2-gt!b
ab
a 1-gt!a, 2-gt!b b 1-gt!a, 2-gt!b
39Equal on Dictionaries
a 1-gt!ab 1-gt!b
ab
Failure!
back
40ax
a !x
a !y
ax
ax
a !x
Failure!
back
41ab
a !x b !x
a !y b !x
ax
ax
a !x b !x
Failure!
back
42d.kv
d k-gt!4 v nomod
4
di-gt1, j-gt5, k-gt3
equal
d.kv
v3
4
d k-!4 v !4
43d.kv
d i-gt!3 v !4
4
3
di-gt1, j-gt5, k-gt3
equal
d.kv
v3
4
d i-gt3, k-!4 v !4
back
44!d.kv
Current values d k x v
null Current values are stored in the state of
the synchronizer.
d i-gt!3 v !4
!d.kv
d i-gt3, x-!4 v !4
back
45Disjunction
a !y
a !y
a !y
ax ay
ax
ay
a !y
Failure!
a !y
back
46The for Statement
dictA 1-gt!x dictB 2-gt!y
a !x b nomod
a nomod b !y
for a, b in dictA, dictB a b
ab
ab
dictA 1-gt!x, 2-gt!y dictB 1-gt!x,
2-gt!y
a !x b !x
a !y b !y
for key 2
for key 1
back
47Program for the EJB
- main(ejbs, modules, entitybeans)
- containmentRefMaintainerltattr"Module"gt(ejbs,
modules) - for ejb, entitybean in ltejbs, entitybeansgt (
- persistent(ejb, entitybean, modules)
- nonPersistent(ejb, entitybean)
- ejb null entitybean null)
48Program for the EJB
- persistent(ejb, entitybean, modules)
- var moduleRef, moduleName
- ejb."Persistent" true
- entitybean."EJBName" ejb."Name"
- entitybean."ModuleName" moduleName
- moduleRef ejb."Module"
- findByltattr"Name"gt(modules, moduleName,
moduleRef) -
- nonPersistent(ejb, entitybean)
- ejb."Persistent" false
- entitybean null