October 5th, 2015
Alex
School, food, and video games as per the usual weekday.
Mindy
Today marked the first full week of school at Sophia University but I’ve already noticed some huge differences between my home university, Olin and Sophia. As I was warned, Japanese students are a lot more nonchalant when it comes to university. I was also told that Sophia University was one of the older centers for higher learning in Japan, but I was still struck by the strictness and old fashion methods of control here. Attendance matters far more than effort does and it’s apparent by the number of students who show up and never participate until prodded awake.
October 6th, 2015
Mindy
After my two classes (Japanese Language and Media Representation and Technology) and lunch with friends from my study abroad program, Kha and I headed over to Harajuku. It was much less crowded than when Alex and I went on a Sunday. We started out wandering through clothing stores on the main street with the explicit aim of finding more clothes. It turned out that there were a lot of deals to be had in the hidden stores and in the sales racks of the stores. Kha is a much better shopper than I but we both ended the journey with full bags. There was actually a point at which we decided to save our backs and drop everything into a locker while we wandered. At the end we got crepes and found a tacoyaki place called Koi-Taco that lets you write messages on the walls!
Alex with Mindy
Mindy and I met up just to hang out a bit near Ochanomizu station. We ended up going to get some food and spending the night inside.
October 7th, 2015
Mindy
Wednesdays are my longest days consisting of Japanese first period and my Venture Management course during third and fourth. Unfortunately, unlike the studio style courses I’ve become used to, the three hours consisted of pure lecture. It didn’t help that the professor is soft spoken and many of the students were blatantly disrespectful of the fact that they are in a class. Regardless, Kha and I made it through and I retreated back to dorms to plop.
October 8th, 2015
Mindy with Alex
Like most of my weekdays, I was free after second period. I met up with Alex just outside of Sophia’s front gate to head out to Butadon! The source of *~delicious~* pork and rice. Unfortunately, Alex wasn't feeling too good so we headed back to his dorms to chill for the rest of the day.
October 9th, 2015
Mindy
After my two classes, I was eating lunch with some friends in the CIEE break room waiting for Kha so we could go to Shibuya when she came in and told me that she was going to a nomikai and that I was coming with her. Since clubs were recruiting new students, many of them were hosting nomikais as a way of welcoming new members and showing what the club or circle culture was like. After wandering around Shibuya and buying some more socks, we headed back for the nomikai. The group members guided us to Shinjuku where we headed up to the rooftop floor and drank and ate for a few hours. It was Sophia Communications which connected Japanese students and foreign students to practice Japanese. However the number of foreign students greatly outnumbered the Japanese students and we wound up mostly speaking in broken English and playing Japanese and American drinking games.
October 10th, 2015
Alex with Mindy
Mindy and I met up in Shinjuku for her first trip to Asakusa. We went to get some sushi from a rotating sushi bar for lunch before walking around the small shopping district. Mindy bought some things and we made our way to the Senso-ji temple nearby. We looked around for a little bit and then headed out to make our way to Shibuya for our friend Alexa’s birthday party. We just went to an izakaya and spent a few hours there before heading out to do Alexa’s scavenger hunt around the district. It basically involved us finding distinct people like police officers and singers and taking pictures with them. Around midnight we all split up and went home.
October 11th, 2015
Alex with Mindy
After hiking plans were cancelled, we just decided to meet up and hang around for a sort of chill day. We decided to get dinner late-ish after a few hours together and then Mindy went home.


See: Description
| Class | Description |
|---|---|
| ConnectionMeterDataDto |
DTO class to carry information related to smart meter data on connection level (or per aggregator).
|
| ConnectionMeterEventDto |
DTO object for the ConnectionMeterEvent xml entity.
|
| FlexOfferDto |
Data Transfer Object for a FlexOffer.
|
| FlexOrderDto |
Data Transfer Object for a FlexOrder.
|
| FlexOrderSettlementDto |
DTO class for the settlement of one Flex Order.
|
| FlexRequestDto |
Data Transfer Object for a FlexRequest.
|
| MeterDataDto |
DTO class to carry information about smart meter data per period.
|
| MeterDataSetDto |
DTO class to carry information coming from the MDC participant.
|
| PrognosisDto |
DTO for the D-Prognosis Input Data.
|
| PtuFlexOfferDto |
Data Transfer Object conveying the PTU values for a
FlexOfferDto . |
| PtuFlexOrderDto |
Data Transfer Object to convey information related to the PTU of a
FlexOrderDto . |
| PtuFlexRequestDto |
Data Transfer Object conveying the PTU values for a FlexRequest.
|
| PtuMeterDataDto |
DTO class to carry information about smart meter data for 1 PTU.
|
| PtuPrognosisDto |
Data Transfer Object conveying the PTU values for a Prognosis.
|
| PtuSettlementDto |
DTO class containing the information of the settlement of a Flex Order for 1 PTU.
|
| SettlementDto |
DTO class which contains the list
FlexOrderSettlementDto for an given interval of time defined by two dates. |
| Enum | Description |
|---|---|
| AcknowledgementStatusDto |
Data Transfer Object for the AcknowledgementStatus.
|
| DispositionAcceptedDisputedDto |
DTO enumeration of the disposition accepted/disputed.
|
| DispositionTypeDto |
An enumeration to represent the disposition type.
|
| MeterDataQueryTypeDto |
DTO enumeration for the MeterDataQueryType.
|
| MeterEventTypeDto |
DTO enumeration for the MeterEventType.
|
| PrognosisTypeDto |
Enumeration of the different types of Prognosis in a Data Transfer Object.
|
| USEFRoleDto |
Enumeration of the different USEF roles in a Data Transfer Object.
|
Copyright © 2016. All rights reserved.


1 write to UseLocalScope
System.Management.Automation (1)
engine\lang\scriptblock.cs (1)
1432
UseLocalScope
= useLocalScope;
1 reference to UseLocalScope
System.Management.Automation (1)
engine\lang\scriptblock.cs (1)
1058
eventArgs.
UseLocalScope
,


165. Basketball
time limit per test: 0.3 sec.
memory limit per test: 1024
KB
input: standard
output: standard
A head of a rich company decided that the company needs to have
its own basketball team in the NBA. He thinks that a team will be successful
only if the heights of players don't differ from 2000 mm too much. He took on a
coach and this coach selected N players. The height of each player was in range
of 1950..2050 millimeters and their average height was exactly 2000 mm.
Moreover, the height of each player was integer number of micrometers
(micrometer is 1e-6 meters).
Now the head of that company wants to see his
new team. He wants to check, if his will is done, but he is going to check it in
quite a strange way. The players stands in a line in some order, then the head
selects two players and counts the summary height H of these two players and
players who are between them, and the number of these players K. If this sum H
differs from 2000*K mm more than on 10 cm, then he says that the team is bad. Of
course, the coach doesn't want his team to be named "bad", and he don't know,
what players will be selected by the head. So he asks you to help him.
Write
a program that will find the order of players in line, so that the head of a
company will not say the team is bad.
Input
On the first line of input there is one integer N
(1<=N<=6000) --- the number of players selected into a team (these are the
base players and substitutions and so on). Then N real numbers follow --- the
heights of the players in meters.
Output
If the solution exists, write on the first line of the output
one word "yes" (without quotes). On the second line write the order of players
in which they must stand in line. The players are numbered starting from 1 in
that order how their heights are written in input. If several solutions exist,
output any. If there exist no solution, write on the first line of output only
one word "no" (without quotes).
Sample test(s)
Input
6
1.95 1.95 1.96 2.04 2.05 2.05
Output
yes
1 6 2 5 3 4
| Author: |
Nizhny Novgorod city mathematic olympiad jury |
| Resource: |
Nizhny Novgorod city mathematic olympiad, 8th form |
| Date: |
21.12.2002
|
| Server time: 2004-01-13 20:38:48 |
Online Contester Team © 2002 - 2003. All
rights
reserved. | | |


Gibbon Tabs
Active Window
All Windows
Save
Cancel
Overwrite Snapshot
Overwrite contents of Snapshot "
" with tabs from:
Active Window
All Windows
Overwrite


Exchange those dolla's
We can show you just how much your dollars are worth in other countries.
How much u got??
Canidian dollar
Mexican Peso
British Sterling Pound
Euro
Albainian Lek
Show my results.


- DatabaseConfiguration - Class in pl.marczynski.seriesapp.config
-
- DatabaseConfiguration(Environment) - Constructor for class pl.marczynski.seriesapp.config.DatabaseConfiguration
-
- dataSource() - Method in class pl.marczynski.seriesapp.config.CloudDatabaseConfiguration
-
- DateTimeFormatConfiguration - Class in pl.marczynski.seriesapp.config
-
Configure the converters to use the ISO format for dates by default.
- DateTimeFormatConfiguration() - Constructor for class pl.marczynski.seriesapp.config.DateTimeFormatConfiguration
-
- DateTimeWrapper - Class in pl.marczynski.seriesapp.repository.timezone
-
- DateTimeWrapper() - Constructor for class pl.marczynski.seriesapp.repository.timezone.DateTimeWrapper
-
- DateTimeWrapperRepository - Interface in pl.marczynski.seriesapp.repository.timezone
-
Spring Data JPA repository for the DateTimeWrapper entity.
- DEFAULT_LANGUAGE - Static variable in class pl.marczynski.seriesapp.config.Constants
-
- DEFAULT_TYPE - Static variable in class pl.marczynski.seriesapp.web.rest.errors.ErrorConstants
-
- DefaultProfileUtil - Class in pl.marczynski.seriesapp.config
-
Utility class to load a Spring profile to be used as default
when there is no spring.profiles.active
set in the environment or as command line argument.
- deleteById(Long) - Method in interface pl.marczynski.seriesapp.service.EpisodeService
-
Delete Episode by id
- deleteById(Long) - Method in interface pl.marczynski.seriesapp.service.FollowedSeriesService
-
Delete FollowedSeries by id
- deleteById(Long) - Method in class pl.marczynski.seriesapp.service.impl.EpisodeServiceImpl
-
Delete Episode by id
- deleteById(Long) - Method in class pl.marczynski.seriesapp.service.impl.FollowedSeriesServiceImpl
-
Delete FollowedSeries by id
- deleteById(Long) - Method in class pl.marczynski.seriesapp.service.impl.SeasonServiceImpl
-
Delete Season by id
- deleteById(Long) - Method in class pl.marczynski.seriesapp.service.impl.SeriesServiceImpl
-
Delete Series by id
- deleteById(Long) - Method in class pl.marczynski.seriesapp.service.impl.WatchedEpisodeServiceImpl
-
Delete WatchedEpisode by id
- deleteById(Long) - Method in interface pl.marczynski.seriesapp.service.SeasonService
-
Delete Season by id
- deleteById(Long) - Method in interface pl.marczynski.seriesapp.service.SeriesService
-
Delete Series by id
- deleteById(Long) - Method in interface pl.marczynski.seriesapp.service.WatchedEpisodeService
-
Delete WatchedEpisode by id
- deleteEpisode(Long) - Method in class pl.marczynski.seriesapp.web.rest.EpisodeResource
-
DELETE /episodes/:id : delete episode by "id"
- deleteEpisode() - Method in class pl.marczynski.seriesapp.web.rest.EpisodeResourceIntTest
-
- deleteFollowedSeries(Long) - Method in class pl.marczynski.seriesapp.web.rest.FollowedSeriesResource
-
DELETE /followed-series/:id : delete the followedSeries by "id".
- deleteFollowedSeries() - Method in class pl.marczynski.seriesapp.web.rest.FollowedSeriesResourceIntTest
-
- deleteSeason(Long) - Method in class pl.marczynski.seriesapp.web.rest.SeasonResource
-
DELETE /seasons/:id : delete the season by "id".
- deleteSeason() - Method in class pl.marczynski.seriesapp.web.rest.SeasonResourceIntTest
-
- deleteSeries(Long) - Method in class pl.marczynski.seriesapp.web.rest.SeriesResource
-
DELETE /series/:id : delete the series by "id".
- deleteSeries() - Method in class pl.marczynski.seriesapp.web.rest.SeriesResourceIntTest
-
- deleteUser(String) - Method in class pl.marczynski.seriesapp.service.impl.UserServiceImpl
-
- deleteUser(String) - Method in interface pl.marczynski.seriesapp.service.UserService
-
- deleteUser(String) - Method in class pl.marczynski.seriesapp.web.rest.UserResource
-
DELETE /users/:login : delete the "login" User.
- deleteUser() - Method in class pl.marczynski.seriesapp.web.rest.UserResourceIntTest
-
- deleteWatchedEpisode(Long) - Method in class pl.marczynski.seriesapp.web.rest.WatchedEpisodeResource
-
DELETE /watched-episodes/:id : delete the watchedEpisode by "id".
- deleteWatchedEpisode() - Method in class pl.marczynski.seriesapp.web.rest.WatchedEpisodeResourceIntTest
-
- describeTo(Description) - Method in class pl.marczynski.seriesapp.web.rest.jhipster.TestUtil.ZonedDateTimeMatcher
-
- description(String) - Method in class pl.marczynski.seriesapp.domain.Season
-
- description(String) - Method in class pl.marczynski.seriesapp.domain.Series
-
- doFilter(ServletRequest, ServletResponse, FilterChain) - Method in class pl.marczynski.seriesapp.security.jwt.JWTFilter
-
- DomainUserDetailsService - Class in pl.marczynski.seriesapp.security
-
Authenticate a user from the database.
- DomainUserDetailsService(UserRepository) - Constructor for class pl.marczynski.seriesapp.security.DomainUserDetailsService
-
- DomainUserDetailsServiceIntTest - Class in pl.marczynski.seriesapp.security
-
Test class for DomainUserDetailsService.
- DomainUserDetailsServiceIntTest() - Constructor for class pl.marczynski.seriesapp.security.DomainUserDetailsServiceIntTest
-
- duration(Integer) - Method in class pl.marczynski.seriesapp.domain.Episode
-


parvovirus patients infection human {border-style px;} #ffffff;} viral PVB infected cell children disease rash respiratory Parvovirus acute fetal lung symptoms IgM cause px; seen {font-family DNA antibodies aplastic blood failure font-size immunocompromised infections pulmonary related transient â€" Massachusetts Medical associated cells damage double; erythroid illness immune inclusions infection. pneumonia virus Brown anemia bone border-color border-width cellular clinical diagnosis distress erythema especially persist persistent proteins red result solid; {font-style {font-weight Infect Lung Pathology, School, University [], al.Parvovirus aplasia bold courier; crisis days difficult disease, early em; factor fulminant grid..Department hydrops immunity injury marrow patient previous pt;} reported response serology similar tissues women


Input refresh rate in ms. This does not slow or speed up line generation
0 Bloons
0 Bloons per second
You have 0 Dart Monkeys
Pops 1 Bloon per second
You have 0 Tack Shooters
Pops 5 Bloons per second
You have 0 Sniper Monkeys
Pops 20 Bloons per second
You have 0 Boomerang Throwers
Pops 150 Bloons per second
You have 0 Bomb Towers
Pops 1000 Bloons per second
You have 0 Glue Gunners
Pops 8000 Bloons per second
You have 0 Ice Monkeys
Pops 80000 Bloons per second
You have 0 Ninja Monkeys
Pops 1000000 Bloons per second
You have 0 Monkey Apprentices
Pops 25000000 Bloons per second
You have 0 Monkey Buccaneers
Pops 400000000 Bloons per second
You have 0 Monkey Subs
Pops 6 billion Bloons per second
You have 0 Mortar Monkeys
Pops 120 billion Bloons per second
You have 0 Banana Farms
Pops 3.5 trillion Bloons per second
Get double clicks per upgrade for more bloons.
Dart Monkeys have more powerful darts and range. The production is doubled.
Dart Monkeys uses piercing darts for more pops. The production is doubled.
Dart Monkeys have triple darts for maximise bloon pops. The production is tripled.
Replaces all Dart Monkeys with a catapult that shoots a spiked ball. The production is tripled.
All Dart Monkeys darts are replaced by crossbow, which is known as archer and reach Bloons at long range. The production is quintupled.
Tack Shooters have more tacks and range. The production is doubled.
Tack Shooters have even more tacks and fire rate. The production is doubled.
Input refresh rate in ms. This does not slow or speed up line generation


{% extends "base.html" %}{% load i18n static %} {% block title %}About | Alex Khomenko{% endblock %} {% block header %} {% include "includes/navbar.html" with active='about' %} {% endblock %} {% block content %}
Based in Helsinki, Finland. Currently working as a web developer at Grafana Labs, the open source analytics and monitoring solution for every database.
I specialise in front end web development using modern tools, but also have experience with back end and devOps work. Technologies I have worked with include:
Recently I have been working mostly with Typescript, React, Redux, Emotion and Golang.
I am passionate about learning new things and applying my knowledge to build exciting stuff. Computers aside, I enjoy sports, listening to the music and reading books. One of the latest hobbies has been home brewing.
Certification:
{% endblocktrans %}


Manager
class Manager
This class manages the upload functionnalities of the program and the initialisation of more specialised classes for loading and rendering the articles.
-
The path to the folder containing the configuration file
Declaration
Swift
let rootPath : String
-
The configuration object for the current Manager instance
Declaration
Swift
let config : Config
-
The Loader object for the current instance, will load the articles from disk.
Declaration
Swift
var loader : Loader?
-
The Renderer for the current instance, will render the articles to disk.
Declaration
Swift
var renderer : Renderer?
-
The object managing the SFTP connection
Declaration
Swift
var ftpServer : NMSFTP?
-
A string representing the domain adress of the FTP
Declaration
Swift
let ftpAdress : String
-
A string representing the distant path to the destination folder on the FTP
Declaration
Swift
let ftpPath : String
-
Initalisation method
Declaration
Swift
init(rootPath : String, configuration : Config)
Parameters
rootPath
the path to the local directory containing the config file
configuration
a Configuration object for the current instance of the program
-
Initialises the Renderer for the current configuration and rootpath
Declaration
Swift
func initRenderer()
-
Initialises the SFTP session for the current configuration and rootpath
Declaration
Swift
func initSession() -> Bool
Return Value
a boolean denoting the success or failure of the connection
-
Calls the Renderer with the correct settings
Declaration
Swift
func generate(option : Int)
Parameters
option
the mode in which the Renderer should run
-
Regenerates the index page
Declaration
Swift
func index()
-
Regenerates the resources folder
Declaration
Swift
func resources()
-
Uploads the generated content to the SFTP server designated in the Configuration.
Declaration
Swift
func upload(option : Int = 0)
Parameters
option
the mode in which the upload should happen
-
Deletes the element passed as parameter if it exists on the server
Declaration
Swift
private func cleanElementAtPath(distantPath : String)
Parameters
distantPath
The path of the element to delete on the server
-
Uploads the file or folder stored at the given local path.
Declaration
Swift
private func uploadElementAtPath(path : String, force : Bool) -> Bool
Parameters
path
the local path pointing to the element to upload
force
indicates if an already existing element on the server should be replaced
Return Value
a boolean denoting the success of the whole operation
-
Tests the connection to the SFTP
Declaration
Swift
func runTest()
-
Creates a draft .md file
Declaration
Swift
func createDraft(title : String)
Parameters
title
the title of the draft file to create


This course provides students with a view into the job of a software engineer through hands-on interaction with course material. Topics covered include engineering processes and their application to the development of software; cost and effort estimation; software testing and test management; team structure, roles and composition; deployment and configuration management; and professional ethics.
This course is taught with a mandatory service learning component, during which you students work on a real software development project in a team context for a real client and reflect upon that experience. It is not possible to pass this course without taking part in this hands-on learning experience.
This course describes engineering processes and their application to the development of software.
One of:
To be successful in this course, students are expected to have practical experience building software, and in particular, should be comfortable working with data structures, designing classes, and writing software modules.
Students will experience the job of a software engineer through hands-on interaction with course material. The course will provide students with opportunities to experience: engineering processes and their application to the development of software; cost and effort estimation; software testing and test management; team structure, roles and composition; deployment and configuration management; and professional ethics.
Upon completion of this course, students should be able to:
Content Delivery. This course is taught in an experiential service learning format. Conceptual material is delivered in lecture and discussion format, and applied when possible through a service learning project experience.
Service Learning Project. A central focus of this course, the service learning project places students in the context of a software team working on a real piece of existing software for a real client. Projects are created by partners with a public benefit mission (usually non-profits or governmental organizations), and partners participate with the class during the course of the project as product owners for the software being built. Through the project, students gain real-life experience of what it’s like to work on a team as a professional software engineer.
Critical Reflection. With an experiential format, research has shown that students retain material better when they reflect critically on their learning. As such, students will be expected to write weekly reflection journal entries, as well as a short personal reflection essay at the end of the semester.
Exams. There are no exams in this course. However, students will be responsible for writing an analysis paper on a software ethics issue of their choice and presenting it in a mini-conference format at the end of the semester.
This course generally covers some combination of the following topics:


Inheritance vs. Composition
"Favor 'object composition' over 'class inheritance'" - Gang of Four, Design Patterns, 1995
CompositionComposition, in object oriented languages, involves moving features we want to share into their own class. (Ruby provides an additional method for achieving this - Modules.) While inheritance is a cool way to change behavior it is rife with potential error as subclasses can easily make assumptions about the context in which a method it overrides is being called.
InheritanceInheritance usually brings to mind the loss of someone and that person's bequest(s) to another. However in the world of programming it is a much more convoluted concept and one that seems to seldom lead to a big payout. If anything it would appear that relying on inheritance would be the programming equivalent of a reverse mortgage. It would allow you an easy answer today but would likely leave you well short in the not-too-distant future.
Black Box vs. White BoxWhile it seems like a comic strip from days gone by (MAD magazine anyone?) the idea of black box (where structure is strict but "unknown") vs. white box (where contents are completely visible and structure is loose) is a common one among programmers. It's not a language specific one - rather more of a design principle. Composition is black box reuse at its finest - it allows for flexibility and reuse opportunities for the smaller items that have been given power/behavior via delegation (rather than inheritance.)


http://www.reactivemanifesto.org/
Code for this talk under https://github.com/jlprat/reactive-jee
Database and remote server calls are typically synchronous. This means that every time one of those methods is called it takes some time to return, with a thread left waiting for the answer. Why not model it accordingly?
How a synchronous one looks like
@WebServlet(urlPatterns = "/servlet/users")
public class UserServlet extends HttpServlet {
...
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
final List<Author> authors = authorService.getAuthors();
final List<Reader> readers = readerService.getReaders();
final List<Person> users = new ArrayList<>(authors.size() + readers.size());
users.addAll(authors);
users.addAll(readers);
final ServletOutputStream out = resp.getOutputStream();
for (Person user : users) {
out.println(user.toString());
}
}
}
Making it asynchronous
@WebServlet(urlPatterns = "/servlet/users", asyncSuppported = true)
public class UserServlet extends HttpServlet {
...
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
final AsyncContext asyncCtx = req.startAsync();
asyncCtx.start(() -> {
final List<Author> authors = authorService.getAuthors();
final List<Reader> readers = readerService.getReaders();
final List<Person> users = mergeUsers(authors, readers);
printUsers(users, asyncCtx.getResponse().getOutputStream());
asyncCtx.complete();
});
}
}
How a synchronous one looks like
@Path("/users")
public class UserResource {
...
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getUsers() {
final List<Author> authors = authorService.getAuthors();
final List<Reader> readers = readerService.getReaders();
final List<Person> users = mergeUsers(authors, readers);
return Response.ok(users).build();
}
}
Making it asynchronous
@Stateless
@Path("/users")
public class UserResource {
...
@GET
@Produces(MediaType.APPLICATION_JSON)
@Asynchronous
public void getUsers(@Suspended AsyncResponse response) {
final List<Author> authors = authorService.getAuthors();
final List<Reader> readers = readerService.getReaders();
final List<Person> users = mergeUsers(authors, readers);
response.resume(Response.ok(users).build());
}
}
Never wait forever!
@Stateless
@Path("/users")
public class UserResource {
...
@GET
@Produces(MediaType.APPLICATION_JSON)
@Asynchronous
public void getUsers(@Suspended AsyncResponse response) {
response.setTimeout(2, TimeUnit.SECONDS);
response.setTimeoutHandler(resp ->
resp.resume(Response.status(Status.REQUEST_TIMEOUT).build()));
final List<Author> authors = authorService.getAuthors();
final List<Reader> readers = readerService.getReaders();
final List<Person> users = mergeUsers(authors, readers);
response.resume(Response.ok(users).build());
}
}
Request is accepted by a thread belonging to the http-thread-pool but the processing it is handled by a thread from the ejb-thread-pool. This way, the http-thread is free to accept new incoming request.
Last thing you want is waiting forever to complete a request from a client. Always specify timeouts when doing asynchronous tasks.
Use them when you have a combination of heavy and light loaded queries. You can get a higher throughput and your server can be better fine-tuned.
How a synchronous one looks like
@Stateless
public class AuthorService {
public Author createAuthor(final String name, final String surname) {
final Author author = new Author(UUID.randomUUID(), name, surname);
em.persist(author);
return author;
}
}
Making it asynchronous (I)
@Stateless
public class AuthorService {
@Asynchronous
public Future<Author> createAuthor(final String name, final String surname) {
final Author author = new Author(UUID.randomUUID(), name, surname);
em.persist(author);
return new AsyncResult<>(author);
}
}
The Client (I)
@Path("/users/authors")
public class AuthorResource {
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(MediaType.APPLICATION_JSON)
public Response createAuthor(@FormParam("name") final String name, @FormParam("surname") final String surname) {
final Future<Author> authorFuture =
authorService.createAuthor(name, surname);
try {
final Author author = authorFuture.get(2, TimeUnit.SECONDS);
return Response.ok(author).build();
} catch (InterruptedException | ExecutionException | TimeoutException e) {
return Response.serverError().build();
}
}
}
Making it asynchronous (II)
@Stateless
public class AuthorService {
@Asynchronous
public CompletableFuture<Author> createAuthor(final String name, final String surname) {
final Author author = new Author(UUID.randomUUID(), name, surname);
em.persist(author);
return CompletableFuture.completedFuture(author);
}
}
The Client (II)
@Stateless
@Path("/users/authors")
public class AuthorResource {
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(MediaType.APPLICATION_JSON)
@Asynchronous
public void createAuthor(@FormParam("name") final String name, @FormParam("surname") final String surname,
@Suspended AsyncResponse response) {
response.setTimeout(2, TimeUnit.SECONDS);
response.setTimeoutHandler(resp -> {
resp.resume(Response.status(Response.Status.REQUEST_TIMEOUT).build());
});
authorService.createAuthor(name, surname).thenApply(response::resume);
}
}
JEE specification doesn't allow this.
Async method exposed through no-interface view must have return type void or java.lang.concurrent.Future<V>
Making it asynchronous (III)
@Stateless
public class AuthorService {
@Asynchronous
public void createAuthor(final String name, final String surname,
final CompletableFuture<Author> promise) {
final Author author = new Author(UUID.randomUUID(), name, surname);
em.persist(author);
promise.complete(author);
}
}
The Client (III)
@Stateless
@Path("/users/authors")
public class AuthorResource {
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(MediaType.APPLICATION_JSON)
@Asynchronous
public void createAuthor(@FormParam("name") final String name, @FormParam("surname") final String surname,
@Suspended AsyncResponse response) {
CompletableFuture<Author> promise = new CompletableFuture<>();
authorService.createAuthor(name, surname, promise);
promise.thenApply(response::resume);
}
}
The Client (III bis)
@GET
@Produces(MediaType.APPLICATION_JSON)
@Asynchronous
public void getUsers(@Suspended AsyncResponse response) {
final CompletableFuture<List<Author>> authors = new CompletableFuture<>();
final CompletableFuture<List<Reader>> readers = new CompletableFuture<>();
authorService.getAuthors(authors);
readerService.getReaders(readers);
authors.thenCombine(readers, (a, r) -> {
final List<Person> list = new ArrayList<>(a.size() + r.size());
list.addAll(a);
list.addAll(r);
return list;
}).thenApply(response::resume);
}
Any time an asynchronous method is invoked, it is served by another thread-pool, freeing the caller one to continue with their tasks.
Use them when you can benefit of calling different Session Beans at the same time. Throughput can be incremented this way.
Futures are currently the main actor for Asynchronicity in JEE. However, they have some limitations as they can not compose and make use of the new lambdas like CompletableFuture does.
If things can go wrong, model failure in your API's. In the same way, do not expect users of your methods to check if your returned object is null.
Introduced in Java 8, its only purpose is to express that the return value of a method might not exist. It is not intended to be used in fields.
Example code
@Stateless
public class ReaderService {
public Optional<Reader> getReader(final String id) {
return Optional.ofNullable(em.find(Reader.class, id));
}
}
...
@Path("/users/readers")
public class ReaderResource {
public Response getReader(@PathParam("id") final String id) {
final Optional<Reader> reader = readerService.getReader(id);
return reader
.map(Response::ok)
.orElseGet(() -> Response.status(Response.Status.NOT_FOUND))
.build();
}
}
Optional is NOT serializable. It can not be used in remote Session Beans! Use it only on local methods.
This class doesn't exist in Java (currently). It can be found, for example, in the javaslang library. The Try object represents a computation that might complete or fail with an exception.
Possible Implementation
interface Try<T> {
//Consumes the throwable if this is a Failure.
Try<T> onFailure(Consumer<? super Throwable> action);
//Consumes the value if this is a Success.
Try<T> onSuccess(Consumer<? super T> action);
//Creates a Try of a supplier that might throw.
static <T> Try<T> of(Try.CheckedSupplier<? extends T> supplier)
}
Example code
Try<String> attempt = getURL("https://devnull-as-a-service.com/");
attempt.onFailure(e -> logger.log(Level.SEVERE, "Error occurred", e))
.onSuccess(logger::info);
Try<String> getURL(String url) {
return Try.of(() -> {
StringBuilder result = new StringBuilder();
HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
conn.setRequestMethod("GET");
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = rd.readLine()) != null) {
result.append(line);
}
rd.close();
return result.toString();
}):
}
Provide loosely coupled communication between services while keeping certain degree of guarantees of delivery and fault tolerance.
The oldest of the API's introduced in this talk (2001). It is loosely coupled, transactional and it can be durable, fault tolerant and clustered. Messages can be ObjectMessage, MapMessage, TextMessage, StreamMessage or BytesMessage.
Coupled code
public class LendingService {
public BookAvailability lendBook(final Book book, final Reader reader) {
final BookAvailability bookAvailability =
em.find(BookAvailability.class, book.getIsbn());
if (!bookAvailability.isAvailable()) {
throw new BookNotAvailableException();
} else {
reader.loanBook(book);
bookAvailability.lend();
em.merge(reader);
em.merge(bookAvailability);
return bookAvailability;
}
}
}
The Producer
public class LendingService {
@Inject JMSContext jmsContext;
@Resource(lookup = "jms/BookLendingQueue") Destination queue;
public BookAvailability lendBook(Book book, Reader reader) {
...
sendLoanBookJMS(reader, book);
bookAvailability.lend();
em.merge(bookAvailability);
...
}
private void sendLoanBookJMS(Reader reader, Book book) {
final Map<String, Object> message = new HashMap<>();
message.put("readerId", reader.getId());
message.put("bookIsbn", book.getIsbn());
jmsContext.createProducer().send(queue, message);
}
}
The Consumer
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType",
propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "destinationLookup",
propertyValue = "jms/BookLendingQueue")})
@Stateless
public class ReaderMDB implements MessageListener {
...
public void onMessage(Message message) {
MapMessage msg = (MapMessage) message;
Reader reader = em.find(Reader.class, msg.getString("readerId"));
Book book = em.find(Book.class, msg.getString("bookIsbn"));
reader.loanBook(book);
em.merge(reader);
}
}
Use JMS when you want to decouple services from each other. The processing of the message will be done in asynchronous fashion. You can add delivery guarantees, or even send messages to other machines. Also useful when you want to broadcast some information.
CDI events are around since JEE 6. They allow beans to communicate without any compile-time dependency. By default events are processed in a synchronous way.
Producer
public class LendingService {
@Inject @ReturnedBook Event<BookLoan> returnedBook;
public BookAvailability returnBook(final Book book, final Reader reader) {
...
if (reader.getBookShelf().contains(book)) {
bookAvailability.returned();
em.merge(bookAvailability);
returnedBook.fire(new BookLoan(book, reader));
return bookAvailability;
}
...
}
}
Qualifier
@Qualifier
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.PARAMETER})
public @interface ReturnedBook {
}
Consumer
@Stateless
public class ReaderService {
public void updateBookShelf(@Observes @ReturnedBook BookLoan bookLoan) {
bookLoan.reader.returnBook(bookLoan.book);
em.merge(bookLoan.reader);
}
}
Asynchronous Consumer
@Stateless
public class ReaderService {
@Asynchronous
public void updateBookShelf(@Observes @ReturnedBook BookLoan bookLoan) {
bookLoan.reader.returnBook(bookLoan.book);
em.merge(bookLoan.reader);
}
}
Producing and consuming CDI events is easier than the JMS way, but it comes with some limitations. If you need asynchronously process the events, it needs to be done manually and thread-safety needs to be taken into account.
Josep Prat - @jlprat - Berlin Expert Days - 16/09/2016


External Magnetic Field Namelist¶
The namelist &B_external
provides options for imposing an external magnetic field.
Externally imposed magnetic field¶
n_imp (default
n_imp = 0
) is an integer controling the type of external field applied.n_imp=0
No external magnetic field
n_imp=1
Follows idea of Uli Christensen of external field compensating internal field such that radial component of magnetic field vanishes at \(r/r_{cmb}=rrMP\) where
rrMP
is the ‘magnetopause radius’ input by the user (see below)n_imp=2
Uniform axisymmetric magnetic field of geometry given by
l_imp
(see below)n_imp=3
Uniform axisymmetric magnetic field which changes direction according to the direction of the axial dipole of the internal magnetic field
n_imp=4
Same as
n_imp=3
but the amplitude of the external field is scaled to the amplitude of the axial dipole of the internal fieldn_imp=7
External field depends on internal axial dipole through Special Heyner feedback functions
rrMP (default
rrMP = 0.0
) is a real which gives the value of ‘magnetopause radius’. In other words, it gives the radius (as a fraction ofr_cmb
) at which the radial component of the magnetic field vanishes due to cancelling out of external and internal magnetic field components. Used only whenn_imp = 1
.amp_imp (default
amp_imp = 0.0
) is a real which gives the amplitude of the external magnetic field.expo_imp (default
expo_imp = 0.0
) is a real which gives the exponent of dependence of external magnetic field on the axial dipole of the internal magnetic field. Used forn_imp=7
.bmax_imp (default
bmax_imp = 0.0
) is a real which gives the location of the maximum of the ratio of the poloidal potentials \(g_{ext}/g_{int}\).l_imp (default
l_imp = 1
) is an integer which gives the geometry (degree of spherical harmonic) of the external magnetic field. The external field is always axisymmetric, hencem = 0
always. This option is used whenn_imp = 2,3
or4
.
Current carrying loop¶
To simulate experiments, an external current carrying loop, concentric to the sphere and in the equatorial plane, has been implemented in the code. It’s radius is fixed at a distance \(a = r_{cmb}/0.8\) to match conditions of the Maryland 3 metre experiment.
l_curr (default
l_curr = .false.
) is a logical that controls switching on or off of the current carrying loop.amp_curr (default
amp_curr = 0.0
) is a real that gives the amplitude of magnetic field produced by the current carring loop.
Warning
Note that an external magnetic field is incompatible with a region of low conductivity inside the spherical shell (i.e, if r_LCR < r_cmb
). Thus, while imposing an external magnetic field, make sure r_LCR > r_cmb
(which is the default case). For details on r_LCR
, have a look at the section on electrical conductivity in the namelist for physical parameters.


--- layout: post title: Top topical ad date: '2017-08-25T11:30:27+02:00' categories: - Sketches picture_url: https://film-Storyboards.tumblr.com/post/164601055178/rough-Sketches-for-a-top-topical-ad ---
Rough Sketches for a top topical ad.