First part: Actor Architecture
Akka version 2.5.8Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Akka provides you with some basic functionality for creating an actor system, and has implemented the underlying code necessary to control basic behavior. To understand this, let's take a look at the relationship between the actor role you created and
Actor Model AKKA
Actor Model
Actor Model in AKKA
application of Akka in Pea pod
Actor Model
The Actor model is a different way of modeling concurrent processes. actor is a free-running activity that can receive messages, process messages, and send responsesdesigned primarily to support asynchronous and efficient messaging mechanisms
1.OOP: is a variable dri
includes Spark, Mesos, Akka, Cassandra, and Kafka, with the following features:
Contains lightweight toolkits that are widely used in big data processing scenarios
Powerful community support with open source software that is well-tested and widely used
Ensures scalability and data backup at low latency.
A unified cluster management platform to manage diverse, different load applications.
When deploying specific applications,
Route is the core part of Akka-http routing DSL, which makes it easy for users to filter http-request from Http-server, perform server operations, and build replies Http-response. The main purpose of the so-called screening http-request is to allow request to enter the next inner route, or to reject reject request. For example, this ~ symbol: it connects up and down two separate route. If the route above rejects a request, the following route will the
The following procedure demonstrates a simple example of Akka. Create an actor to process a command that interacts with the message delivery.
I use the Akka version and the associated jar package see the Pom file:
1. Creating Event Events
Import java.io.Serializable;
public class Event implements Serializable {
private String data;
Private String uuid;
Public Event (String data) {
Echoserver
In the previous article, we used akka to write a simpleHelloworldFor exampleActorMode) has a preliminary understanding. This article uses akka to writeEchoserverTo see how to use actor in the worldTCP protocol.
GitHub Project
As usual, the echoserver code is put on GitHub. Echoserver is a little more complex than helloworld. There are three classes, as shown in:
Main
Start with the main
Introduction Akka Before you need to say a little bit scala,scala claims to be the next generation JVM language,
The integration of the object-oriented Java, as well as functional programming in one, unusually powerful, but also complex, this article is not controversial, let's briefly introduce.
The Akka framework is based on Scala and a small amount of Java code, and Scala replaces its own underlying act
includes Spark, Mesos, Akka, Cassandra, and Kafka, with the following features:
Contains lightweight toolkits that are widely used in big data processing scenarios
Powerful community support with open source software that is well-tested and widely used
Ensures scalability and data backup at low latency.
A unified cluster management platform to manage diverse, different load applications.
When deploying specific applications,
Akka send a message to the actor in the following way! Tell means "Fire-and-forget", that is, asynchronously sending a message without waiting for the result to be returned
? Ask asynchronously sends a message and returns a future that represents a possible reply.
Messages are ordered on a per-sender basis. MailBox
The Akka mailbox contains messages destined for the actor. Usually each actor has its own mai
Because of the recent work relationship, you want to split the asynchronous task from the application server into a dedicated asynchronous processing server.Programme Iis to use MQ to send a task message to the server for processing, as shown in:This scheme uses MQ as the intermediate medium, using the thread pool asynchronous processing task on the server side, after processing completes sends the result to the MQ, the client listens the way obtains the result to continue processing.
T
1. Test Objective: verify that Akka ensures that each instance of the actor runs in its own lightweight thread and has its own queue, guaranteeing FIFO processing of each message. 2, Akka actor is both a transmitter and receiver, send messages and receive messages must pass their own OnReceive method. 3. If you use the same instance test obtained from spring, the result is that each actor instance is self-
Akka-persistence-hbase-master is the component responsible for Akka persistence, using the Async method to manipulate HBase, Akka logs persisted into hbase.Akka-persistence-hbase-master to create a journal table before persisting, the configuration of the table is stored in the application.conf file.The Akka.persistence.hbase.journal.HBaseJournalInit object is re
Title, to test the Akka Actor model remote transmission restrictions, the results have really found a point.The design test cases are as follows:Client side:1 Packagecn.wanda.local2 3 ImportAkka.actor.Actor4 Importmodule. {ListType, Jsontype, Seqtype}5 6 Importjava.util.ArrayList7 /**8 * Created by Administrator on 2014/11/17.9 */Ten classLocalactorextendsActor { One AVal remote = context.actorselection ("Akka.tcp://[email protected]:8000/user/remo
Main content:1. Typed actor Definition2. Typed actor Created3. Message sent 1. Typed actor Definition
The typed actor in Akka is the implementation of the active objects design pattern, and the active objects mode will decouple the execution of the method and the invocation of the method, thus introducing concurrency into the program. The Typed actor is composed of a common interface and a corresponding implementation, and its underlying implementatio
What should I do if I want to fault tolerance?
The parent actor first needs to know the failure status of the sub-actor, and then determine what to do. What to do is called supervisorstrategy ".
// Restart the storage child when storageexception is thrown.
// After 3 restarts within 5 seconds it will be stopped.
Override Val supervisorstrategy = oneforonestrategy (maxnrofretries = 3,
Withintimerange = 5 seconds ){
Case _: storage. storageexception => restart
}
What does supervisorstrategy do?An
Spark is a distributed computing framework, and there must be communication between multiple machines. Spark was implemented in earlier versions using Akka. A rpcenv is now abstracted from the upper Akka. The rpcenv is responsible for managing communication between machines.The RPCENV consists of three main cores:
Rpcendpoint the message loop body, which is responsible for receiving and processing
. The good news is that akka's actor, in terms of concept, contains a lightweight thread of its own, which is completely separated from other parts of the system. This means that you do not need to consider synchronization locks.In the background, akka runs multiple actor objects on a physical thread. Generally, several actors share a physical thread, the subsequent calls of an actor may use different physical threads, but these implementation details
Official Document: Http://developer.lightbend.com/guides/akka-quickstart-java/?_ga= 2.177525157.1012573474.1504767665-546319647.1504766934I. AKKA Hello World Example:1. First you need to create a actorsystem, which is the container for all actors to run.2. Next create the Greeter actor and the printer actor.3. Send the message to the Greeter actor instance, which stores the message internally first.4. The i
dispatcher relies on the execcutor of the thread pool
# is optimized for blocking operations 1.2.3 Balancingdispatcher
He can reassign work from the more busy actor to the more idle actor, the reallocation of tasks is premised on the premise that all actors must be of the same type.
Characteristics:
# only one mailbox
# The dispatcher is shared by all actors of the same type
# The dispatcher relies on a thread pool or fork join pool
1.2.4 Callingthreaddispatcher
He just runs the task on the sa
The Akka provides scalable, real-time transaction processing capabilities.The Akka is based on actor and provides location transparency.The 1GB heap can have 2.5 million actors.Horizontal expansion, vertical expansion, fault tolerance 3 ways to solve.The actor of the tree structure, each actor has state and behavior.DT Big Data Dream Factory public account: Dt_spark.DT Big Data Dream Factory's public number
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.