2. What’s Wemlin?
Wemlin provides access to public transport information
– easy, fast and independent of time and place
iOS
Android
Windows Phone
Web
Netcetera | 2
4. Wemlin Hub – non-functional requirements
- Wemlin Hub shall be a high performance parallelized message processing system
-
low latency – good processing speed
throughput – number of messages we can process
available - zero downtime!
good disaster recovery
scalability (horizontal, vertical)
modular – component based
extensible – 80% usage pattern
flexible – adapt to any infrastructure with minimal effort
Netcetera | 4
8. Software Architecture is…
The decisions about software that are hard to change
E.g.
Use of Jodatime vs. java.util.Date
What kind of Database will you use
GWT vs. Angular JS
Encapsulation
Netcetera | 8
9. Wemin Hub Architecture
Model
Pure Java (no dependencies)
Well defined extensible classes
Immutable (like Jodatime, every
modification produces a new object)
Algebraic
Inverse References
Pipeline
Compositional (All components are
wired together using a fixed set of well
defined interfaces)
Filter (stateless, function)
Transformer (stateless, function)
Aggregator (stateful, function)
Sink (consumer)
Tap (producer)
Netcetera | 9
10. Pure Model
- no external dependency
- design not influenced by any technology e.g. Hibernate, RDBMS, MVC
Netcetera | 10
11. Algebraic, Immutable Model
- algebraic: each object identity is defined by it's contents.
- immutable: each object, once created, cannot be modified. Each part of the
pipeline must copy-and-modify each object to perform it’s processing. This
characteristic enables easier reasoning about concurrency.
- metadata: classes support arbitrary metadata expressed as key-value pairs.
Metadata does not take part in the definition of the object's identity. This allows
encoding of format specific information in the model, which can be used in the
pipeline.
Netcetera | 11
16. Memoization
Immutable Model: each object, once created, cannot be modified.
Problem: Big memory consumption, a lot of objects are created with the same
contents
Solution: Memoization
When a factory method is executed, for example:
Station.get("1", "St. Gallen, Bahnhof");
a global cache of objects in searched if a object with the specified data already exists.
If object exists, it is returned, if not, new object is created and stored into cache for
future use.
Netcetera | 16
17. Memoization (2)
Implementation:
Constructors are made private and replaced by annotated factory methods:
@DesignatedFactoryMethod
public static Station get(Map<String, ? extends Serializable> attributes,
String referenceId,
String name,
String localName,
String place,
GeoPoint location) {
return new Station(attributes, referenceId, name, localName, place, location);
}
Netcetera | 17
18. Memoization (3)
@Pointcut("execution(@com.wemlin.hub.memoization.annotations.DesignatedFactoryMeth
od * *(..))")
public void designatedFactoryMethodPointcut() {
}
@Around("designatedFactoryMethodPointcut()")
public Object handleMemoize(final ProceedingJoinPoint pjp) throws Exception {
// search for object with the specified factory parameters in cache
}}
Impact: 500 to 1000 times less objects created (depends on how much data is
processed)
Netcetera | 18
19. Modularization – components architectural constraints
- The following architectural constrains define a module in Wemlin Hub:
- it is a maven module, a jar or web fragment
- is not allowed to use spring annotations for injection, i.e. all injection is done
via constructors
- a module provides components, only a few (up to 4) and facades for the 80%
usage pattern
- each component is allowed to hook into the wemlin pipeline only through
the predefined pipeline interfaces Filter, Transformer, Aggregator, input
component, output component
- components are Spring independent, as far as it is possible. They may
implement some spring interfaces, but as few as possible, and provide means
to achieve the same functionality without Spring.
Netcetera | 19
20. Station resolver module (1)
-
The Wemlin Hub Station resolver module does station resolving with help of the reference
stations list
The reference station list contains all CH stations listed in the “Stationsnamen Fahrplan
und Antragsformular für Mutationen“
http://www.bav.admin.ch/dokumentation/publikationen/00475/01497/index.html
-
We use the reference station list primarily to match references to stations in incoming data
(HAFAS, VDV, GTFS) to known stations for which we fully control the names, have the
coordinates and other meta-data that can be associated with them.
- The list is well defined JSON file that lists
- attributes of the stations (full name, local name, place, coordinates, agency etc)
- their respective referenceId
- a set of rules that may be used to match the station in incoming data
- connection areas
Netcetera | 20
21. Station Resolver (2)
- I Every station is resolved by a set of rules:
-
General rules
Station specific rules
General rules
- station id (optimal)
- station similarity – we use Apache Lucene for search of name similarity in combination
with coordinates distance tolerance
-
Station specific rules
- matchByRegex – when the station has different id from the one we have, but also the
name we get is slightly different
Example: Bahnhof, Esslingen:
Esslingen Bhf, Esslingen Bhf., Esslingen etc
Netcetera | 21
22. Cache
-
we don’t use a DB:
- all data is time bounded i.e. all data we keep is temporary (daily)
-
our choice was an in-memory cache
- very simple java maps cache
- no third party cache libraries are involved
-
the cache is easy to browse via the cache browser component
- few implementations available:
-
-
standard cache browser
forwarding cache browser
lazy loading cache browser
all cache browsers can define filters
Netcetera | 22
23. REST
-
all data that is in the cache is available via the REST api
-
there are two versions of the api available:
- legacy api (V0): wemlin clients still operate with this one
- V2 api according to the new transport.opendata.ch specification – some of the
customers started using it
-
both apis support pretty much the same things:
- locations listings – cities, stations
- lines listing – all lines that operate within a network
- trips – for a given period of time
- departures – with realtime prognosis
Netcetera | 23
25. Wemlin Hub - Blue-Green deployment
- Requirement: ensure zero downtime of the system.
- Decision: blue-green deployment
- two identical production environments
- the reverse proxy before the machines resolves to one of them depending on
which one is configured active
- test on the “idle” server before go-live
- switch proxy to the tested instance – the other one is now “idle”
- Advantages:
- ensure zero downtime of the system
- easy rollback if anything goes wrong
Netcetera | 25
26. Wemlin Hub today
- currently 4 customers (all in Switzerland)
- they cover nearly 40% of the transport in all Switzerland including Liechtenstein
- 17 agencies, 14 with realtime data
- daily processing load
- around 33’000 trips, 571’000 stops
- 2’500 projections per second in peak hours (in the moment, not the actual
capacity of the system)
- offline transport data conversion - contract with Google for Switzerland
- we convert the Swiss yearly transport schedule (over 400 agencies, ~1GB data)
to GTFS (Google Transit Feed Specification) format for Google Maps usage
- conversion takes ~20min
Netcetera | 26
So What is Wemlin?According to our marketing, Wemlin is a Passenger Information System that provides access to public transport information – easy, fast and independent of time and place.The Wemlin Product family for the end user consists of mobile applications for iOS, Android, Windows Phone and Web application.All applications display the same data.Transport unitPlan data – schedules (yearly, daily) – which vehicle drives where?Stop – zastanuvanjeTrip – rutaGps – sends data to avms
Under the hood, Wemlin also has a Server part called Wemlin Hub whose main purpose is:to gather data from the transport agencies (using different protocols, like: VDV DFI, VDV AUS, GTFS, HAFAS)enrich the acquired data with its own reference data (why? – it’s third party data, often bad quality or not in desired format)serve that data to primarily to Wemlin mobile clients and also to 3-th party clients.convert data between various formats
Exstensible - Many clients with different requirements
Exstensible - Many clients with different requirements
Under the hood, Wemlin also has a Server part called Wemlin Hub whose main purpose is:to gather data from the transport agencies (using different protocols, like: VDV DFI, VDV AUS, GTFS, HAFAS)enrich the acquired data with its own reference data (why? – it’s third party data, often bad quality or not in desired format)serve that data to primarily to Wemlin mobile clients and also to 3-th party clients.convert data between various formats
Why microkernel?software systems that must be able to adapt to changing system requirementsit separates a minimal functional core from extended functionality and customer-specific partsmicrokernel also serves as a socket for plugging in these extensions and coordinating their collaborationsize of the microkernel should be kept to a minimum, therefore, only part of the core functionality can be included in itBenefits of the pattern:good portability, since only microkernel need to be modified when porting the system to a new environment.high flexibility and extensibility, as modifications or extensions can be done by modifying or extending internal servers.maintainability and changeability of the system.
You want to make your architecture as small as possible (the less things that are “hard to change” the better)Encapsulation: the more you are able t
Microkerncel.This is the architecture. Small, easy to remember.
- Log free
Explain input components responsibilityKeep connections openHandle specific protocolResolversStation resolver, line resolverWe translate data from the protocols to our model formatUniversal model for any protocolBidejkisekojakomponenta se pridrzuva do odredeninterfejs od pajplajnot, se dobivaparalelizacijazabezpari I bezmnogurazmisluvanjepriimplementacijataPrakanjenaporaki od edenna drug sistem: ova e moznobidejkiporakite se immutable Porakite ne moze da se smenat, mozesamo da zastarat
Memoization is a optimization technique used primarily to speed up computer programs by having function calls avoid repeating the calculation of results for previously processed inputs.Having immutable model in a system has it’s advantages when it comes to parallelization and concurrency, but also has it’s drawbacks which is big memory consumption, because for every modification of a single field in an object, you need to shallow copy the whole object and create a new one with the modified filed.Because many of the model objects in Wemlin will be recreated with the same data many times, it makes sense to check if we had previously created objects with the specified parameters and return the old object instead of creating a new one.
Memoization is a optimization technique used primarily to speed up computer programs by having function calls avoid repeating the calculation of results for previously processed inputs.
The pointcut selects all methods that are anotated with the @DesignatedFactoryMethod annotation.We use the Around advice on the selected join points.
Memoization is a optimization technique used primarily to speed up computer programs by having function calls avoid repeating the calculation of results for previously processed inputs.Having immutable model in a system has it’s advantages when it comes to parallelization and concurrency, but also has it’s drawbacks which is big memory consumption, because for every modification of a single field in an object, you need to shallow copy the whole object and create a new one with the modified filed.Because many of the model objects in Wemlin will be recreated with the same data many times, it makes sense to check if we had previously created objects with the specified parameters and return the old object instead of creating a new one.
forwarding cache browser - forwards all requests to a wrapped cache browser. useful for overriding some logic.lazy loading cache browser - lazy loads data from the cache, saves time for large schedules
forwarding cache browser - forwards all requests to a wrapped cache browser. useful for overriding some logic.lazy loading cache browser - lazy loads data from the cache, saves time for large schedules
Why microkernel?software systems that must be able to adapt to changing system requirementsit separates a minimal functional core from extended functionality and customer-specific partsmicrokernel also serves as a socket for plugging in these extensions and coordinating their collaborationsize of the microkernel should be kept to a minimum, therefore, only part of the core functionality can be included in itBenefits of the pattern:good portability, since only microkernel need to be modified when porting the system to a new environment.high flexibility and extensibility, as modifications or extensions can be done by modifying or extending internal servers.maintainability and changeability of the system.Apache httpd exampleKarakteristicno e stoparalelizirame