Erlang and OTP in Action 1st Edition Martin Logan

gezimekhalou 8 views 47 slides Mar 17, 2025
Slide 1
Slide 1 of 47
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45
Slide 46
46
Slide 47
47

About This Presentation

Erlang and OTP in Action 1st Edition Martin Logan
Erlang and OTP in Action 1st Edition Martin Logan
Erlang and OTP in Action 1st Edition Martin Logan


Slide Content

Visit ebookfinal.com to download the full version and
explore more ebooks or textbooks
Erlang and OTP in Action 1st Edition Martin Logan
_____ Click the link below to download _____
https://ebookfinal.com/download/erlang-and-otp-in-
action-1st-edition-martin-logan/
Explore and download more ebooks or textbook at ebookfinal.com

Here are some recommended products that we believe you will be
interested in. You can click the link to download.
Processes of Community Change and Social Action 1st
Edition Allen Martin Omoto
https://ebookfinal.com/download/processes-of-community-change-and-
social-action-1st-edition-allen-martin-omoto/
The Affirmative Action Empire Nations and Nationalism in
the Soviet Union 1923 1939 1st Edition Terry Martin
https://ebookfinal.com/download/the-affirmative-action-empire-nations-
and-nationalism-in-the-soviet-union-1923-1939-1st-edition-terry-
martin/
IntelliJ IDEA in Action In Action series 1st Edition
Stephen Saunders
https://ebookfinal.com/download/intellij-idea-in-action-in-action-
series-1st-edition-stephen-saunders/
WebWork in Action In Action First Edition Patrick
Lightbody
https://ebookfinal.com/download/webwork-in-action-in-action-first-
edition-patrick-lightbody/

Microbial Fuel Cells 1st Edition Bruce E. Logan
https://ebookfinal.com/download/microbial-fuel-cells-1st-edition-
bruce-e-logan/
First Course in the Finite Element Method Fourth Edition
Daryl Logan
https://ebookfinal.com/download/first-course-in-the-finite-element-
method-fourth-edition-daryl-logan/
Women And Victimization Contributing Factors Interventions
And Implications 1st Edition Tk Logan
https://ebookfinal.com/download/women-and-victimization-contributing-
factors-interventions-and-implications-1st-edition-tk-logan/
Prototype and Scriptaculous in Action 1st Edition Dave
Crane
https://ebookfinal.com/download/prototype-and-scriptaculous-in-
action-1st-edition-dave-crane/
Democracy in Theory and Action 1st Edition Peter Herrmann
https://ebookfinal.com/download/democracy-in-theory-and-action-1st-
edition-peter-herrmann/

Erlang and OTP in Action 1st Edition Martin Logan
Digital Instant Download
Author(s): Martin Logan, Eric Merritt, Richard Carlsson
ISBN(s): 9781933988788, 1933988789
Edition: 1
File Details: PDF, 5.21 MB
Year: 2010
Language: english

MANNING
IN ACTION
Erlang
AND OTP
Martin Logan
Eric Merritt
Richard Carlsson
FOREWORD BY ULF WIGER

Erlang and OTP in Action

Erlang and
OTP in Action
MARTIN LOGAN
ERIC MERRITT
RICHARD CARLSSON
MANNING
Greenwich
(74° w. long.)

For online information and ordering of this and other Manning books, please visit
www.manning.com. The publisher offers discounts on this book when ordered in quantity.
For more information, please contact
Special Sales Department
Manning Publications Co.
180 Broad St.
Suite 1323
Stamford, CT 06901
Email: [email protected]
©2011 by Manning Publications Co. All rights reserved.
No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in
any form or by means electronic, mechanical, photocopying, or otherwise, without prior written
permission of the publisher.
Many of the designations used by manufacturers and sellers to distinguish their products are
claimed as trademarks. Where those designations appear in the book, and Manning
Publications was aware of a trademark claim, the designations have been printed in initial caps
or all caps.
Recognizing the importance of preserving what has been written, it is Manning’s policy to have
the books we publish printed on acid-free paper, and we exert our best efforts to that end.
Recognizing also our responsibility to conserve the resources of our planet, Manning books
are printed on paper that is at least 15 percent recycled and processed without the use of
elemental chlorine.
Manning Publications Co. Development editor: Cynthia Kane
180 Broad St. Copyeditor: Tiffany Taylor
Suite 1323 Proofreader: Katie Tennant
Stamford, CT 06901 Typesetter: Dennis Dalinnik
Cover designer: Marija Tudor
ISBN: 9781933988788
Printed in the United States of America
12345678910 –MAL–16151413121110

To all the great Erlangers,
many of whom we call friends, that we have met along the way.
May this book put an end to the long hard slog through
internet docs that we had to endure to learn OTP.

vii
brief contents
PART 1 GETTING PAST PURE ERLANG: THE OTP BASICS ............1
1■The Erlang/OTP platform 3
2■Erlang language essentials 22
3■Writing a TCP-based RPC service 94
4■OTP applications and supervision 119
5■Using the main graphical introspection tools 132
PART 2 BUILDING A PRODUCTION SYSTEM .............................147
6■Implementing a caching system 149
7■Logging and event handling
the Erlang/OTP way 170
8■Introducing distributed Erlang/OTP 190
9■Adding distribution to the cache with Mnesia 213
10■Packaging, services, and deployment 242

BRIEF CONTENTSviii
PART 3 INTEGRATING AND REFINING......................................259
11■Adding an HTTP interface to the cache 261
12■Integrating with foreign code using
ports and NIFs 291
13■Communication between Erlang and Java
via Jinterface 332
14■Optimization and performance 357
15■Installing Erlang 379
16■Lists and referential transparency 381

ix
contents
foreword xvii
preface xx
acknowledgments xxii
about this book xxiii
introduction xxviii
PART I GETTING PAST PURE ERLANG:
THE OTP BASICS ..............................................1
1
The Erlang/OTP platform 3
1.1 Concurrent programming with processes 5
Understanding concurrency 5
■Erlang’s process
model 6
■Four process communication paradigms 8
Programming with processes in Erlang 11
1.2 Erlang’s fault tolerance infrastructure 13
How process links work 13
■Supervision and
trapping of exit signals 14
■Layering processes for
fault tolerance 15
1.3 Distributed Erlang 16

CONTENTSx
1.4 The Erlang runtime system and virtual machine 17
The scheduler 18
■I/O and scheduling 19
Process isolation and the garbage collector 19
1.5 Functional programming: Erlang’s face to the world 20
1.6 Summary 21
2
Erlang language essentials 22
2.1 The Erlang shell 23
Starting the shell 24
■Entering expressions 24
Shell functions 26
■Escaping from the shell 26
Job-control basics 27
2.2 Data types in Erlang 29
Numbers and arithmetic 29
■Binaries and bitstrings 30
Atoms 31
■Tuples 32
■Lists 33
■Strings 34
Pids, ports, and references 35
■Functions as data: funs 36
Comparing terms 36
■Understanding lists 38
2.3 Modules and functions 39
Calling functions in other modules (remote calls) 40
Functions of different arity 40
■Built-in functions and
standard library modules 41
■Creating modules 42
Compiling and loading modules 43
■The stand-alone
compiler, erlc 44
■Compiled modules versus evaluation
in the shell 45
2.4 Variables and pattern matching 46
Variable syntax 46
■Single assignment 47
■Pattern
matching: assignment on steroids 49
■More about patterns 50
2.5 Functions and clauses 52
A function with side effects: printing text 52
■Multiple
clauses and pattern matching for choice 54
■Guards 55
Patterns, clauses, and variable scope 56
2.6 Case and if expressions 56
Boolean if-then-else switches in Erlang 57
■If expressions 58
2.7 Funs 58
Funs as aliases for existing functions 58
■Anonymous funs 59
2.8 Exceptions, try, and catch 61
Throwing (raising) exceptions 62
Using try...catch 62
■try...of...catch 63
■after 64
■Getting
a stack trace 64
■Rethrowing 64
■Plain old catch 65

CONTENTS xi
2.9 List comprehensions 65
List comprehension notation 66
■Mapping, filtering,
and pattern matching 66
2.10 Bit syntax and bitstring comprehensions 67
Building a bitstring 67
■Pattern matching with
bit syntax 68
■Bitstring comprehensions 69
2.11 Record syntax 69
Record declarations 70
■Creating records 70
■Record fields
and pattern matching 70
■Updating record fields 71
Where to put the record declarations 71
2.12 Preprocessing and include files 72
Defining and using macros 72
■Include files 73
Conditional compilation 74
2.13 Processes 74
Operating on processes 75
■Receiving messages,
selective receive 76
■Registered processes 77
■Delivery of
messages and signals 78
■The process dictionary 79
2.14 ETS tables 79
Why ETS tables work like they do 79
■Basics of
using ETS tables 80
2.15 Recursion: it’s how you loop 81
From iteration to recursion 81
■Understanding tail
recursion 84
■Accumulator parameters 85
■Some words
on efficiency 85
■Tips for writing recursive functions 86
2.16 Erlang programming resources 92
Books 92
■Online material 92
2.17 Summary 92
3
Writing a TCP-based RPC service 94
3.1 What you’re creating 95
A reminder of the fundamentals 96
■Behaviour basics 97
3.2 Implementing the RPC server 100
Canonical module layout for a behaviour implementation 100
The module header 101
■The API section 103
■The callback
function section 109
3.3Running the RPC server 116
3.4A few words on testing 117
3.5Summary 118

CONTENTSxii
4
OTP applications and supervision 119
4.1 OTP applications 120
The organization of an OTP application 120
■Adding the
application metadata 122
■The application behaviour 123
Application structure summary 125
4.2 Adding fault tolerance with supervisors 125
Implementing a supervisor 126
■The supervisor restart
strategy 127
■Writing the child specification 128
4.3Starting the application 129
4.4Generating documentation with EDoc 130
4.5Summary 131
5
Using the main graphical introspection tools 132
5.1 Appmon 132
The Appmon GUI 133
■The WebTool version of Appmon 136
5.2Pman 137
5.3Debugger 140
5.4TV, the Table Viewer 144
5.5Toolbar 146
5.6Summary 146
PART II BUILDING A PRODUCTION SYSTEM..................147
6
Implementing a caching system 149
6.1 The background story 149
6.2 The design of your cache 151
6.3 Creating the basic OTP application skeleton 153
Laying out the application directory structure 153
Creating the application metadata 154
■Implementing the
application behaviour 154
■Implementing the supervisor 155
6.4 From application skeleton to a working cache 157
Coding the sc_element processes 157
■Implementing the
sc_store module 162
■Rounding off with the application-level
API module 167
6.5 Summary 169

CONTENTS xiii
7
Logging and event handling the Erlang/OTP way 170
7.1 Logging in Erlang/OTP 171
Logging in general 171
■Erlang/OTP built-in logging
facilities 172
■The standard logging functions 173
SASL and crash reports 175
7.2 A custom event handler with gen_event 179
Introducing the gen_event behaviour 179
■Event handler
example 180
■Acting on error events 181
7.3 Adding a custom event stream to the Simple Cache 183
The event stream API 184
■Integrating the handler
with Simple Cache 185
■Subscribing to a custom
event stream 188
7.4 Summary 189
8
Introducing distributed Erlang/OTP 190
8.1 The fundamentals of Erlang distribution 190
Process communication by copying 191
Location transparency 192
8.2 Nodes and clustering 193
Starting a node 194
■Connecting nodes 195
■How Erlang
nodes find each other and communicate 197
■The magic
cookie security system 198
■Sending messages between
connected nodes 199
■Working with remote shells 201
8.3 The nuts and bolts of resource discovery 204
Terminology and taxonomy 204
■The algorithm 205
Implementing the resource discovery application 206
8.4 Summary 212
9
Adding distribution to the cache with Mnesia 213
9.1 Distributing the cache 214
Choosing a communication strategy 214
■Synchronous
versus asynchronous cache 216
■If you only had a
distributed table... 219
9.2 Distributed data storage with Mnesia 219
Creating a project database 220
■Initializing the database 221
Creating the tables 223
■Populating the tables 226
■Do some
basic queries on your data 228

CONTENTSxiv
9.3 Distributing the cache with Mnesia 230
Switching from ETS to Mnesia 230
■Making the cache aware of
other nodes 233
■Integrating resource discovery to find other
cache instances 236
■Bringing the Mnesia tables into
dynamic replication 238
9.4 Summary 241
10
Packaging, services, and deployment 242
10.1 Applications from a system viewpoint 243
Structure 243
■Metadata 243
■How the system
manages running applications 244
10.2 Making a release 245
Releases 246
■Preparing to release your code 247
The release metadata file 247
■The script and
boot files 249
■System configuration 250
■Starting a
target system 251
10.3 Release packaging 253
Creating a release package 253
■Release package
contents 254
■Customizing a release package 255
10.4 Installing a release 256
10.5 Summary 258
PART III INTEGRATING AND REFINING..........................259
11
Adding an HTTP interface to the cache 261
11.1 Implementing a TCP server 262
A pattern for efficient TCP servers 262
■Sketching the
tcp_interface application 263
■Fleshing out the TCP
server 264
■The simple text-based protocol 267
Text interface implementation 268
11.2 Building a web service from the ground up 270
A quick-and-dirty introduction to HTTP 271
■Implementing a
generic web server behaviour 274
■Getting REST 286
Implementing the RESTful protocol with gen_web_server 287
11.3 Summary 290

CONTENTS xv
12
Integrating with foreign code using ports and NIFs 291
12.1 Ports and NIFs 292
Plain ports 294
■Linked-in port drivers 295
Natively implemented functions (NIFs) 295
12.2 Integrating with the parser through a port 296
The Erlang side of the port 297
■The C side of the
port 300
■Compiling and running the code 312
12.3 Making a linked-in driver 313
Understanding linked-in drivers 313
■The C side of
the driver 315
■Compiling the driver code 320
The Erlang side of the driver 321
12.4 Implementing the parser as a NIF 322
The Erlang side of the NIF 322
■The C side of
the NIF 323
■Compiling and running the code 330
12.5 Summary 331
13
Communication between Erlang and Java via Jinterface 332
13.1 Integrating Erlang with Java using Jinterface 334
The OtpNode class 334
■The OtpMbox class 334
Mapping Erlang data structures onto Java 335
Message-handling example in Java 337
■Talking to
the Java node from Erlang 339
13.2 Installing and configuring HBase 340
Downloading and installing 340
■Configuring HBase 341
13.3 Building the bridge between Simple Cache
and HBase 342
The Erlang side: sc_hbase.erl 342
The HBaseConnector class 344
■Java message
handling 346
■The HBaseTask class 349
13.4 Integrating HBase with Simple Cache 351
Lookup 352
■Insert 352
■Delete 353
13.5 Running the integrated system 353
13.6 Summary 356

CONTENTSxvi
14
Optimization and performance 357
14.1 How to approach performance tuning 358
Determining your performance goals 358
■Establishing a
baseline 359
■Profiling the system 359
■Decide which
problems to attack 360
■Measure the results 360
14.2 Profiling Erlang code 360
Counting calls with cprof 361
■Profiling execution
time with fprof 363
14.3 Erlang programming language caveats 368
Performance aspects of the primitive data types 369
Performance of built-in functions and operators 373
Functions 374
■Processes 376
14.4Summary 378
appendix AInstalling Erlang 379
appendix BLists and referential transparency 381
index 383

xvii
foreword
For a long time, the world of Erlang programming had only one book—The Book,
1
released in 1993 and revised in 1996. Fanatics can still find it in print, at a price of
over $100. A decade or so after its publication, The Book was getting long in the
tooth, to say the least. The language had evolved to include several new and powerful
programming constructs. Higher-order functions, list comprehensions, and the bit
syntax are found everywhere in modern Erlang programs but weren’t described in
The Book. But the most notable omission was the Open Telecom Platform (OTP),
Erlang’s application development framework, which was first released in 1996. Erlang
was rather easy to learn; OTP wasn’t, and early adopters like Martin Logan, who
started using Erlang in 1999, pretty much had to learn it the hard way through trial
and error.
In the past few years, as an indication that Erlang had become interesting enough
to justify it, a number of books was released, and we were told that other books were
being written. Erlang and OTP in Action by Martin Logan, Eric Merritt, and Richard
Carlsson was the one most talked about. And now it is here.
I started programming Erlang in 1993, when I was designing disaster response sys-
tems in Anchorage, Alaska. I bought a precompiled version of Erlang for HP-UX, deliv-
ered on a magnetic QIC tape. The language was smaller back then, as were the
number of support libraries. I had to start designing my own data-access structures,
1
Robert Virding, Claes Wikstrom, and Mike Williams, Concurrent Programming in Erlang (Prentice Hall,
1993, 1996).

FOREWORDxviii
database managers, protocol parsers, and error-handling frameworks—but I enjoyed
myself thoroughly. After all, this was a different time: the web was emerging with the
release of the Mosaic browser that same year, and the term open source wouldn’t be
used for another five years; if you wanted a programming framework with support for
distributed computing and fault tolerance, you had to be prepared to pay dearly, both
in time and money. I had scoured the market for such tools and felt well-informed
about the commercial alternatives. Erlang was raw and unassuming, with a weird-
looking syntax and practically no documentation, but its core concepts felt right in a
way that no other tools had.
Three years later, I found myself in Sweden, working for Ericsson and chief
designer of the largest Erlang-based project to date. We would build what is known as
a telecom-class ATM switch using Erlang, as well as a new framework called the Open
Telecom Platform. The name was intended to make decision makers in the company
feel warm and fuzzy—Telecom was our core business, Open was the buzzword of the day,
and the prevailing wisdom was that if you wanted to build a robust complex product,
you had to have a Platform that provided things like redundancy, support for remote
configuration, live software upgrade, and real-time tracing and debugging.
Ericsson isn’t in the business of selling development tools, but it has designed pro-
gramming languages by necessity since the early 1970s. To its credit (but also to its
own benefit), Ericsson released Erlang/OTP as open source in 1998. Enthusiasts
across the world picked it up and used it, mainly in the telecom field at first, but later
also in other areas. We made several attempts in the ’90s to pitch Erlang to web devel-
opers, but the challenge facing web developers back then wasn’t how to make redun-
dant, scalable, and highly responsive e-commerce sites; the time for such systems
hadn’t yet come, nor had the time when concurrency would be a conversation topic
for mainstream programmers. Concurrency was hard—everyone knew that. Concur-
rency was something to be avoided. Why, then, choose a programming language
where you could hardly even write “hello world” without introducing concurrency?
The explosive growth of the web and the emergence of increasingly interactive
web applications eventually brought Erlang in from the cold. Unexpected help also
came from the laws of physics, which finally made it impossible to keep cranking up
the clock frequency on our CPUs to produce faster and faster single-core chips. The
message “The free lunch is over” from the hardware vendors, urging developers to
start learning how to make their programs scale across many weaker cores rather than
one very fast CPU, was wonderful news for Erlang. This meant many clever program-
mers would at least look at Erlang, to figure out what supposedly made it so special.
Many would simply look, and others would borrow concepts and implement them in
their favorite language. This was wonderful too, because it meant the market value of
knowing and loving Erlang and the principles behind it would increase rapidly.
OTP has by now been proven in several problem domains other than telecom and
is highly regarded by those who have learned to master it. Erlang/OTP is an amazingly
powerful platform, but it does take time to learn, not least when you try to apply it to a

FOREWORD xix
new niche. Interestingly, even programmers who have worked for years in OTP-based
projects may be fairly ignorant of how to build an OTP-based system from scratch,
because the application programmer is exposed only to a fairly small part of the total
framework. This is exactly what you want in a large project, but the entrepreneur in a
small startup can’t rely on someone else burning the midnight oil and figuring out the
subtleties of OTP release-handling and other dark corners without helpful examples
and tutorials.
A good book on OTP has been sorely needed, and it’s with great pleasure that we
welcome Erlang and OTP in Action. Martin Logan, Eric Merritt, and Richard Carlsson
represent an enormous amount of experience combined, and they have contributed
greatly to the Erlang community. I’m convinced that this book will help boost the
already impressive trend of Erlang adoption.
Enjoy!
ULF WIGER
CTO, ERLANG SOLUTIONS LTD

Discovering Diverse Content Through
Random Scribd Documents

The Project Gutenberg eBook of Voiton päivä;
Vala; Kotiin

This ebook is for the use of anyone anywhere in the United States
andmost other parts of the world at no cost and with almost no
restrictionswhatsoever . You may copy it, give it away or re-use it
under the termsof the Project Gutenberg License included with this
ebook or onlineat www.gutenberg.org. If you are not located in the
United States,you will have to check the laws of the country where
you are locatedbefore using this eBook.
Title: Voiton päivä; Vala; Kotiin
Historiallisia näytelmiä
Author: Kyösti Wilkuna
Release date: January 24, 2024 [eBook #72791]
Language: Finnish
Original publication: Helsinki: Kust.Oy Kirja, 1921
Credits: Tapio Riikonen
*** START OF THE PROJECT GUTENBERG EBOOK VOIT ON
PÄIVÄ; VALA; KOTIIN ***

VOITON PÄIVÄ; VALA; KOTIIN
Kolme istoriallistaa kuvaelmaa
Kirj.
KUSTAA WILKUNA
Helsingissä,Kustannusosakeyhtiö Otava,1921.
VOITON PÄIVÄ
Historiallinen kuvaelma
Esitetty Lapuan päivillä 14/VII 1921.

HENKILÖT:
ADLERCREUTZ, komentava kenraali Lapuan taistelussa.
RAMSAY |
JÄGERSKIÖLD | Luutnantteja.
WIRZÉN |
WANSÉN, Wirzénin sotilaspalvelija.
af BJERKÉN, ylilääkäri.
VÄLSKÄRI.
TORPAN MUORI.
SOTILAITA.
Tapahtuu 14 p. heinäk. 1808 Lapuan Ritamäellä.

NÄYTTÄMÖNÄ
taustalle kohoava mäenrinne. Oikealla torpantuvan matala seinä
pienine ikkunoineen ja ovineen. Vasemmalla, edellistä vastapäätä ja
enemmän etualalla, olkikattoisen ulkohuonerivin seinämä. Perällä
kaivo jasen takana louhuinen mäenrinne. V asemmalta, ulkohuoneen
ja taustana olevan metsän välitse johtaa pihaan tie. Keskellä pihaa
lattea kivi, jonka päällä ja vierustalla kaikenlaisia sitomavehkeitä ja
kirurgisia tarpeita. Kaivon luona vankkurit, joilla pienoinen
viinatynnyri, kirstuja y.m. Pihalla, kiven lähistöllä, myöskin avonainen
kirstu. —Varjossa ulkohuoneen seinustalla makaa tai istuu seinään
nojaten joukko sotilaita, joilla on side kenellä päässä, kenellä
kädessä tai jalassa.Seinän nojalla musketteja ja miekkoja.
Esiripun noustessa sitoo välskäri, joka on ylisillään ja hihat
käärittyinä, erään seinustalla olevan sotilaan päätä. Tohtori Bjerkén,
niinikään ylisillään ja hihat käärittyinä, istuu kivellä ja penkoo kirstua.
Taustalla näkyy puiden välissä kuhiloituja musketteja sekämuutamia
sotilaita, jotka tupakoivat ja istuskelevat varjossa.
Koko kuvaelman ajan kuuluu etäämpää vasemmalta katkeamaton
kiväärien jakanuunoin pauke.

SOTILAS 1 (Jonka päätä välskäri sitoo.)
En kuule mitään, huutakaa kovemmin!
VÄLSKÄRI (Kumartuen huutamaan miehen korvaan.)
Sitä vain, ettei tämä hengenvaarallinen ole. Parin kolmen viikon
päästä olet jo ennallasi.
SOTILAS 1.
Entä kuuloni?
VÄLSKÄRI
Ei korvissa ole mitään vikaa, ne ovat vain lumpeessa. Huomenna
on kuulojo ennallaan. Kivistääkö haavaa kovastikin?
SOTILAS 1
Ei, mutta muuten tuntuu pääni kuin savimöhkäleeltä. Sitokaa
lujaan,ettei se hajoa, kun minä lähden tästä uudestaan tappeluun.
BJERKÉN (Päätään nostaen.)
Sanokaa, että hänen on pysyttävä alallaan, muuten on henki
vaarassa.
VÄLSKÄRI
Arkkiaatteri kieltää liikkumasta, muuten on henki vaarassa.
SOTILAS 1

Vaarassa? Eikö se sitä ole ollut alunpitäen? — Kerkesin juuri
päästä parhaaseen tappelun makuun, kun tuli se pommi-piru!
Haluaisin mennätyötäni lopettamaan.
BJERKÉN
Kieltäkää häntä puhumasta. Se voi aiheuttaa verenvuodon
aivoihin.
VÄLSKÄRI
Sinun täytyy pysyä hiljaa, muuten olet mennyttä kalua. (Sitomisen
lopettaen.) Kas niin, laskeudu nyt pitkällesi ja pysy rauhassa.
SOTILAS 1
Kun saisin ensin vähän vettä.
VÄLSKÄRI
Heti paikalla! (Menee ja ottaa kaivonkannelta vesikipon, josta
tarjoaa juotavaa. Seuraavan kohtauksen aikana juottaa hän toisiakin
haavoittuneita, tunnustellen samalla heidän siteitään.)
TORPAN MUORI (Tulee tuvasta, kädessään kiulu; kun lähempää
vasemmalta samassa kuuluu karteshin räjähdys, nyykistyy hän
porraskivelle istumaanja painaa käsin sydänalaansa.)
Voi Herra Jeee-sus! Ihan maailmanloppu tulossa!
BJERKÉN (Joka välskärin ja joidenkin haavoittuneiden
naurahtaessakääntyy puolittain muoriin, kuivaten hikeä otsaltaan.)

Ei ihan vielä, muori! Jahka ryssät ensin ajetaan Suomesta pois.
MUORI. Sus siunatkoon tuota pauketta! Lähemmäshän ne vain
tulevat.
JÄGERSKIÖLD (Joka edellisen vuorosanan aikana astuu
sotatieltäpihalle.)
Ryssätkö lähemmäs? Ei niistä mitään! Kohtsillään on Lapuan
kirkonkylä meikäläisten vallassa. Porilaisten rynnäkköä ei pidätä
mikään. Mutta antakaahan, muori, se kipponne tänne, että saan
juoda. Kieleni onkuuma kuin silitysrauta.
(Muori menee kaivolle ja, siunaillen aina kanuunain paukahtaessa,
ottaavettä kiuluunsa ja tarjoaa Jägerskiöldille.)
BJERKÉN (Jägerskiöldille, joka juo ahneesti.)
Oletteko ollut taistelussa, luutnantti?
JÄGERSKIÖLD (Antaen kiulun muorille, joka mennä linkuttaa
sisälle.)
En, ikävä kyllä, sillä minun paikkani on tuolla (viittaa metsään)
reservissä. En kuitenkaan malttanut pysyä alallani, vaan kävin tuolla
ruisvainiolla tykkiemme luona.
BJERKÉN
Siellä on kuumat paikat? Siikajoella ei ammunta ollut läheskään
näintuimaa.
JÄGERSKIÖLD

Verta siellä vuotaa. Mutta jokaista meikäläistä kaatunutta kohti
kaatuu kaksi tai kolme ryssää. Kerrassaan suurenmoista oli läheltä
nähdä porilaisten hyökkäystä. Se oli kuin jäänlähtö suuressa
koskessa. Poisalta kaikki!
BJERKÉN (Siirtyen peremmäs, josta hän Jägerskiöldin kanssa
katsoovasemmalle.)
Taistelun menosta ei saa enää mitään käsitystä. Kaikki yhtenä
ainoana savupilvenä! Suurenmoinen ja kaamea näky! Mitä kaikkea
tuon pilvensisässä tapahtuneekaan?
JÄGERSKIÖLD (Haltioissaan.)
Siellä tapahtuu paljon, paljon! Ja yhdestä seikasta me ainakin
voimme olla varmat.
BJERKÉN.
Nimittäin?
JÄGERSKIÖLD
Nimittäin että ennen auringon laskua on ryssä ajettu tiehensä
tuosta uhkeasta laaksosta. Oh, kuuletteko, kuinka meikäläiset
haltioissaan hurraavat? Ja tuolla, kas, kasakat pakenevat täyttä
laukkaa!
BJERKÉN.
Ja haavoittuneita tuodaan tänne tien täydeltä.
JÄGERSKIÖLD

Oli hyvä, että lähetitte osan välskäreitä sinne, sillä useimpia ei
voida eikä ennätetä tänne kantaa.
BJERKÉN.
Onko kaatuneiden joukossa upseereita?
JÄGERSKIÖLD
On, Herra paratkoon! Juuri kun tulin tykkiemme luo, veti luutnantti
Gestrin viimeisen henkäyksensä. Kohtasin hänet tuolla metsässä,
tullessamme Kauhavalta tänne. Silmät loistaen marssi hän kuin
juhlaan. Laulaen oli hän hoitanut tykkipatteriaan, kunnes tuli
surmanluoti jalopetti nuoren elämän. Ja Maunu Blume — — —
BJERKÉN
Mitä, Blume, armeijan uljain kavaljeeri — hänkinkö kaatunut?
JÄGERSKIÖLD
Niin, Jumala nähköön! Hän oli kaikista ensimäisiä uhrejamme.
Tuolla tien vieressä pellon pientareella hän makaa kylmenneenä.
Peitin tullessani manttelilla hänen ruumiinsa. Ryssät ampuivat
piilosta ruispeltojen keskeltä ja kun Blume oli noussut aidalle
ottamaan selvää heidän asemastaan, sai hän kuulan rintaansa.
Qvantenin huhusivat myöskin saaneen surmansa lähempänä kylää.
Ja Herra ties kuinka monta muuta lisäksi siellä on mennyt ja
parhaillaan menee. Mutta kyllä heidät kostetaan. Kohta Blumen
kaaduttua vei Brakel komppaniansa ruispeltoihin ja niinkuin turilaita
surmasivat hänen porilaisensa laihon keskeen piiloutuneita ryssiä.
Muutamassa minuutissa oli tuo laaja vainio niistä puhtaana. Mutta

huomaatteko, kuinka savupilvi venyy tuonne Kuortaneen suunnalle.
Ryssä painuu omaa ilmansuuntaansa kohti.
BJERKÉN
Hyvä siitä lopultakin taitaa tulla. Mutta ketäs tuossa kannetaan?
Jokuupseeri, ellen erehdy.
JÄGERSKIÖLD (Hetkisen solalle tähystäen)
Luutnantti Wirzén, kadettitoverini! (Rientää vasemmalle, josta hän
hetken kuluttua palaa, astellen paarien rinnalla, joita kaksi sotilasta
kantaa; paareilla, jalka verisenä, makaa luutnantti Wirzén, nojaten
toiseen kyynärpäähänsä ja jutellen vilkkaasti Jägerskiöldille.)
WIRZÉN
… niin ettei muuta kuin sokeasti vain eteenpäin, talo talolta japiha
pihalta… Vaikka kuulia tuli kuin rakeita, niin ei muuta kuin pois alta
ryssät! (Sotilaat, joista toisen käsivarsi on verissä, laskevat paarit
pihan keskelle, jolloin Wirzén kääntyy Bjerkénin puoleen.) Hyvää
päivää, herra arkkiaatteri! Sain pienen läven koipeeni. Olkaapa sen
vuoksi ystävällinen ja laastaroikaa sitä hieman, että joudun sinne
takaisin ennenkuin ehtivät koko kylän puhdistaa. (Bjerkén ja välskäri
kumartuvat jalkaa tutkimaan; sill'aikaa menee toinen sotilaista
kaivolle juomaan, toisen sotilaan ja Jägerskiöldin jäädessä paarien
ääreen.)
JÄGERSKIÖLD (Sotilaalle.)
Kätesi on verissä?

SOTILAS 2 (Kättään katsoen.)
Niin, muuan partaniekka, johon ruispeltoa kahlatessani tulin pahki,
ehti sitä ennen viimeistä matkaansa hiukan pajunetillaan hotaista.
Sietäisisaada siihen hieman siteen tapaista.
VÄLSKÄRI (Kumartuessaan paarien ääreen.)
Heti paikalla, kun tämä luutnantin jalka on saatu hoidetuksi.
BJERKÉN (Suoraksi kohoten.)
Tjah! Luutnantti ei näytä vielä käsittävän, kuinka vakava paikka
tässä on. Suoraan sanoen: jalka on sahattava polven yläpuolelta,
muuten onhenkenne vaarassa.
WIRZÉN (Kaivolla olevalle sotilaalle.)
Wansén, missä miekkani?
WANSÉN (Juosten esiin ja ojentaen miekan, joka on paljaana
paarienpääpuolessa.)
Tässä, herra luutnantti.
WIRZÉN (Miekkaa pudistaen.)
Minun jalkaani ei katkaista niinkauan kuin minä tätä kykenen
heiluttamaan!
JÄGERSKIÖLD.
Oikein, veikko!

BJERKÉN.
Hulluko te olette?
WIRZÉN
Nähkääs, koko viime talven sain minä tällä jalallani juosta ryssän
edessä pohjaa kohti. Nytkö, kun on aljettu kulkea päinvastaisessa
järjestyksessä, minä antaisin jalkani sahata? Ei, herra arkkiaatteri!
Talvella en olisi sahoistanne suuriakaan piitannut, mutta nyt minä
tarvitsen itse jalkani.
BJERKÉN
Mutta sanoinhan, että henkenne on vaarassa. Mätä on jo alullaan.
WIRZÉN
Ei voiton makuun päässyt nuori mies niin vähästä kuole. Tällä
jalallani minä aion vielä tanssissakin pyörähtää, jahka ryssä on
maasta ajettu. Tiedättehän, suomalainen on sitkeä. Laittakaa siis
laastarit ja siteetvalmiiksi, enempää en salli teidän tehdä.
BJERKÉN (Hartioitaan kohauttaen.)
Kuten tahdotte. Mutta vastatkaa itse seurauksista! (Ryhtyy
välskärinkanssa sitomaan jalkaa.)
WANSÉN
Tarvitaanko minua enää täällä, luutnantti?
WIRZÉN

Ei tällä kertaa. Juokse takaisin kylään ja hakkaa minunkin
puolestani.
WANSÉN
Ja tämä poika kun se sitten hakkaakin! (Tekee kunniaa ja juoksee
vasemmalle.) Hurraa!
JÄGERSKIÖLD
Kas siinä soturi! Harmi, että minun täytyy pysyä täällä, vaikka maa
polttaa jalkojani.
WIRZÉN
Tee niinkuin vänrikki Fieandt. Hänkin oli reservissä, mutta
plutoonansa kera oli hän lähtenyt omin lupinsa liikkeelle. Minua
tänne tuotaessahänellä oli jo viitisenkymmentä ryssää vankina.
JÄGERSKIÖLD
Ei käy, Minä hoidan tänään prikaadin adjutantin virkaa, joten
minuntäytyy pysyä täällä, kunnes toisin määrätään.
BJERKÉN (Sitomisen lopettaen.)
Kas niin. Nostakaa nyt luutnantti tuonne varjoon. (Välskäri ja
sotilas 2 nostavat Wirzénin seinustalle, minkä jälkeen välskäri ryhtyy
sitomaan sotilas 2:n käsivartta; Bjerkén pesee käsiään vesisangossa
ja Jägerskiöld kävelee sotatielle tähystämään.)
JÄGERSKIÖLD

Taas tuodaan sieltä jotakin upseeria.
BJERKÉN (Käsiään kuivaten.)
Kylläpä tuoni nyt korjaa saalista. Ja ammunta jatkuu yhtä tuimana.
(Kaksi sotilasta tulee vasemmalta, kantaen paaria, joilla raukeana ja
verisenä makaa Ramsay; he laskevat paarit pihalle, menevät
kaivollejuomaan ja lähtevät sen jälkeen oitis vasemmalle.)
BJERKÉN ja JÄGERSKIÖLD (Lähestyen paareja, yhtaikaa.)
Ramsay!
BJERKÉN (Alas kumartuen.)
Oh, rinta läpi! Joutuin, välskäri! Tuokaa sidettä ja ooppiumipullo!
RAMSAY (Puhuen heikolla ja katkonaislla äänellä.)
Ne ovat tarpeettomia, tohtori. Hetkeni ovat luetut. Antakaa
mieluummintilkka vettä.
(Välskäri tarjoaa hänelle juotavaa.)
SOTILAS 2 (Joka käsivartensa tultua sidotuksi on mennyt
kaivonnurkalleistumaan.)
Kenraali ajaa tänne täyttä ravia.
(Nousee seisomaan; Jägerskiöld lähestyy katsomaan.)
ADLERCREUTZ (Tulee hengästyneenä ja kuohuksissaan
vasemmalta;
Jägerskiöld ja sotilas tekevät kunniaa.)

Mikä verinen päivä, Jägerskiöld! Gestrin, Blume ja Qvanten
makaavat kylmänä tuolla, jalka poikki ammuttuna voihkii kapteeni
Aminoff kylän laidassa ja nyt sanovat nuoren Ramsayn saaneen
surmanluodin. Niin monta nuorta ystävääni yhtenä päivänä! Mutta
missä on Ramsay, onkohänet tuotu tänne?
JÄGERSKIÖLD (Viitaten paareja, joilla makaava Ramsay on
jäänyt
Bjerkénin ja välskärin suojaan.)
Tuolla, herra kenraali!
ADLERCREUTZ (Lähestyen paareja, jolloin Bjerkén ja välskäri
antavathänelle tietä.)
Siis totta! Ramsay, Ramsay — kuuletko vielä minua? (Kumartuu
paarien yli.)
RAMSAY (Puhuen kaiken aikaa vaivaloisesti ja katkonaisesti.)
Tekö, herra kenraali? Mutta kuinka käy taistelun?
ADLERCREUTZ
Me voitamme. Mutta voittomme muuttuu tappioksi, ellei
arkkiaatterimme onnistu tehdä teitä terveeksi. Miten on, herra
arkkiaatteri?
BJERKÉN (Pudistaa päätään.)
RAMSAY

Hetkeni ovat luetut. Mutta ihanata on kuolla tällaisena voiton
päivänä. Herra kenraali, toimittakaa äidilleni viimeinen tervehdykseni
jasanokaa, että poikansa kuoli onnellisena keskellä voiton pauhinaa.
— Ja sitten… ottakaa, kenraali, minulta muistoksi ratsuni. Kun
taistelukentällä havahduin tainnoksista, seisoi se vieressäni. Tänne
tuotaessa asteli se yksinään paarien jäljessä.
ADLERCREUTZ (Liikutettuna.)
Tulen pitämään sen kalliina muistona teistä, rakas ystävä. Mutta
nyt täytyy minun rientää voittoamme täydentämään. Jumalan
haltuun!(Pudistaa Ramsayn käsiä.)
RAMSAY
Jumala kanssanne, kenraali! Pian erkaneva henkeni on seuraava
teitävoittoretkellänne.
ADLERCREUTZ (Lähtee nopeasti, mutta pysähtyy muutaman
askeleenotettuaan ja kääntyy Jägerskiöldiin.)
Jägerskiöld! Reservi tuleen, kostamaan nuorten sankariemme
kuolemaja täydentämään voittomme!
(Menee vasemmalle.)
JÄGERSKIÖLD (Joka edellisen kohtauksen aikana on jutellut
Wirzéninkanssa.)
Näkemiin, veikko!
WIRZÉN

Näkemiin! Ja teekin puhdasta jälkeä! Hitto soikoon, ettei tuo koipi
salli minun olla mukana!
JÄGERSKIÖLD (Poistuu nopeasti oikealle taka-alalle, josta kohta
alkaa kaikua komennushuutoja: "Kiväärit käteen!" — "Riviin!" —
"Asento!" — Perällä puiden välissä loikovat sotilaat hyökkäävät ylös,
hurraavatja ottavat kiväärinsä kuhilaalta.)
MUORI (Syöksyy tuvasta pihalle.)
Herra Jumala, kun Liuhtarinkylä palaa!
(Vasemmalta tuleva punerrus valaisee pihaa ja taustan puita;
Bjerkén, välskäri ja lievemmin haavoittuneet sotilaat kerääntyvät
kaivon luo vasemmalle tähystämään; vasemmalla kiihtyvää
ammuntaa ja tykkien jyskettä; metsästä kuuluu komento: "Eteenpäin
mars!" sekä sitten rummunpärrytystä; puiden välitse näkyy
vasemmalle syöksyviä sotilaita; muori porraskivelle lyyhistyneenä
siunailee ja voivottaa.)
WIRZÉN (Kavahtaa miekkaansa nojaten seisomaan, heiluttaa
hattuaan jaalkaa laulaa, johon metsästä yhtyy lukuisia ääniä.)
    Marssi päälle, pohjan poika
    vihollista varsin luo!
    Hakkaa päälle, pohjan poika,
    Luoja sulle voiton suo!
(Laulun aikana kavahtaa sotilas 1 seisaalleen, tempaa seinustalta
musketin ja syöksyy vasemmalle.)
BJERKÉN (Sotilas 1:n jälkeen.) Seis! Seis! Mitä tulimmaista!

Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
Let us accompany you on the journey of exploring knowledge and
personal growth!
ebookfinal.com