33

Getting Started Guide - hs-rm.de · 2008-04-22 · the example project. ouY can do that with the context menu in the pacagek explorer. In the dialog, select the Instrumentation Generation

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Getting Started Guide - hs-rm.de · 2008-04-22 · the example project. ouY can do that with the context menu in the pacagek explorer. In the dialog, select the Instrumentation Generation

Eclipse plug-ins for pattern-basedinstrumentation of applications

� Getting Started Guide �

Bernhard Jungk

Version: February 20, 2008

Page 2: Getting Started Guide - hs-rm.de · 2008-04-22 · the example project. ouY can do that with the context menu in the pacagek explorer. In the dialog, select the Instrumentation Generation

Contents

1 Introduction 3

1.1 General architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.2 Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.3 Log4J . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.4 ARM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2 Installation 6

2.1 Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62.2 Installation using the update site . . . . . . . . . . . . . . . . . . . . . . . . . . 62.3 Alternative installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

3 Importing the example project 11

4 Using the plug-ins 13

4.1 Add/Con�gure the instrumentation generation nature . . . . . . . . . . . . . . 134.2 Instrumenting with Log4J . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144.3 Instrumenting with ARM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194.4 Code generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274.5 Instrumentation Patterns View . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

4.5.1 Adding patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294.5.2 Deleting patterns and points . . . . . . . . . . . . . . . . . . . . . . . . 304.5.3 Moving and Copying patterns and points . . . . . . . . . . . . . . . . . 304.5.4 Changing the view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

2

Page 3: Getting Started Guide - hs-rm.de · 2008-04-22 · the example project. ouY can do that with the context menu in the pacagek explorer. In the dialog, select the Instrumentation Generation

1 Introduction

Instrumentation is essential for quality assurance during application development as well asfor production system monitoring. Especially for enterprise applications, a detailed analysisof internal processes is important. Depending on the required type of monitoring information,instrumentation can be achieved by inserting general purpose logging statements (e.g. com-plying to the Log4J [Gul03] speci�cation) or by using specialised performance measurementAPIs, e.g. Open Group Application Response Measurement [TOG04] (ARM).

The Eclipse plug-ins for model-based instrumentation of applications are a suite of easy to useplug-ins for instrumentation with Log4J and ARM. The tedious task of manual instrumenta-tion is supported by a GUI interface.

This guide shows how to instrument a small example application with the help of the instru-mentation suite. It starts with the plug-in installation and continues with a description of theinstrumentation process for the supplied example application with Log4J and ARM. The �nalstep is to generate the instrumentation code, which will be presented last.

Some basic knowledge of the architecture is important for a successful instrumentation. Thus,the following section discusses the general architecture of the plug-ins, the use of instrumen-tation patterns and what can be achieved with Log4J and ARM.

1.1 General architecture

The general architecture of the instrumentation suite consists of three types of Eclipse features(see �g. 1.1).

The Core feature acts as the central controller component for the instrumentation suite. TheUI uses the core to access the instrumentation model. Backends extend the core to providesupport for speci�c instrumentation APIs (e.g. ARM). Each Backend contains the ability togenerate code compatible with an instrumentation API. Furthermore, each Backend providesa number of instrumentation patterns that may be used in conjunction with the backend.

Figure 1.1: Eclipse features of the instrumentation suite suite

3

Page 4: Getting Started Guide - hs-rm.de · 2008-04-22 · the example project. ouY can do that with the context menu in the pacagek explorer. In the dialog, select the Instrumentation Generation

Figure 1.2: Selection of Instrumentation Patterns

1.2 Patterns

The Eclipse-based instrumentation suite provides a number of so called basic instrumentationpatterns (see �g. 1.2).

Basic patterns represent basic instrumentation entities that can be combined to form complexinstrumentation patterns: A single logging statement is seen as an Event, an ARM measure-ment with Start an Stop points is forms an Action. Each pattern has one or more roles. Eachrole de�nes the purpose of a point or basic pattern in greater detail. All possible roles andparticipating patterns have to be speci�ed by the Backend. For example, the RPC instru-mentation pattern combines a client side Action with a server side Action. The ARM backendrepresents this complex pattern using two correlated ARM measurements.

1.3 Log4J

Log4J is a widely used logging package. The Log4J Backend provides support for Event andAction patterns as shown in �g. 1.2. It does however not support the RPC pattern. Thegenerated code for the Event pattern is a simple logging statement:

1 Logger.getLogger($logger).$priority($message);

It may be parametrized by specifying a log message, a priority and a custom logger class. Thegenerated code for an Action pattern looks quite similar. The generated code only di�ers inthe generated log message. For an action, the Log4J Backend adds the action name to thebeginning and the role type (Start or Stop) to the end of the log message.

1.4 ARM

ARM is a much more sophisticated API than Log4J. ARM has been designed to measurethe performance of marked source code sections (units of work) within an application. TheARM Backend supports Action and RPC patterns. Event patterns are not supported by this

4

Page 5: Getting Started Guide - hs-rm.de · 2008-04-22 · the example project. ouY can do that with the context menu in the pacagek explorer. In the dialog, select the Instrumentation Generation

backend. The ARM Backend requires an additional Initalization pattern, which is used tomark the source code positions for ARM implementation initalization. The backend generatesa helper class (the ArmHelper class), which eases the generation of code inlined at the actualinstrumentation points.

The actual generated code for Action Start and Stop roles is

1 // start role

$exportCorrelator = ArmHelper.getInstance ().startTransaction("$id",

"$transactionName", new ArmHelper.ContextProperties($contextProperties),

$importCorrelator);

3

// stop role

5 ArmHelper.getInstance ().stopTransaction("$id");

The code for the Stop role is simpler. It does not require user speci�ed attributes, because theid is generated by the ARM Backend. The code for the Start role is much more interesting.It may be specialized with a transaction name and several user de�ned context properties.Furthermore, the user can specify import and export correlators, which are used by the cor-relation feature of ARM. The user still has the responsibility to manage the correlators in ameaningful way, e.g. transfer the correlator to the server side Action of an RPC pattern. TheRPC pattern does not have an e�ect on the code generation.

5

Page 6: Getting Started Guide - hs-rm.de · 2008-04-22 · the example project. ouY can do that with the context menu in the pacagek explorer. In the dialog, select the Instrumentation Generation

2 Installation

There are two ways to install the plug-ins. The preferred way is to use the Eclipse updatesite.

2.1 Prerequisites

The instrumentation suite has the following prerequisites:

• Java SE v5

• Eclipse v3.3 with JDT

• An ARM implementation (e.g. OpenGroup ARM1) to use the ARM Backend

The instrumentation suite may run on di�erent con�gurations as well, but they are unsup-ported.

2.2 Installation using the update site

Select Help -> Software Updates -> Find and Install in the menubar (see �g. 2.1).

Figure 2.1: Find and install menu

1http://www.opengroup.org/arm/

6

Page 7: Getting Started Guide - hs-rm.de · 2008-04-22 · the example project. ouY can do that with the context menu in the pacagek explorer. In the dialog, select the Instrumentation Generation

In the following dialog, choose Search for new features to install and click Next (see�g. 2.2).

Figure 2.2: Search for new features to install dialog

Click on New Remote Site (see �g. 2.3).

Figure 2.3: Update sites overview

7

Page 8: Getting Started Guide - hs-rm.de · 2008-04-22 · the example project. ouY can do that with the context menu in the pacagek explorer. In the dialog, select the Instrumentation Generation

Another dialog opens (see �g. 2.4). Choose a name for the update site (e.g. InstrumentationGeneration), enter the URLhttp://wwwvs.informatik.fh-wiesbaden.de/downloads/extern/oss/permanenta/update-site/

and click Ok.

Figure 2.4: New update site

Now select the entry with the name you have chosen and click on Finish. After a short whilea new dialog opens (see �g. 2.5).

Figure 2.5: Selection of features to install

You have to choose which features you want to install. Required are at least the Core, the UIand one of the ARM or Log4J features. To complete all parts of the guide, you have to installall available features. Click on Next, once you have selected the features to install. Acceptthe license and click Next.

8

Page 9: Getting Started Guide - hs-rm.de · 2008-04-22 · the example project. ouY can do that with the context menu in the pacagek explorer. In the dialog, select the Instrumentation Generation

The last dialog page lists the features you have selected to install (see �g. 2.6).

Figure 2.6: Con�rmation of features to install

Once Finish has been pressed, Eclipse will start to download the necessary �les from theupdate site. When the download has �nished, Eclipse will ask, if you really want to installthe selected features, because the digital signature can not be veri�ed (see �g. 2.7).

Figure 2.7: Veri�cation of the digitally signature failed.

Click on Install All. Usually Eclipse will ask you, if you want to restart Eclipse. If you donot need to save your work, you should choose Yes. When Eclipse has been restarted, youmay proceed with importing a small example project into your workspace.

9

Page 10: Getting Started Guide - hs-rm.de · 2008-04-22 · the example project. ouY can do that with the context menu in the pacagek explorer. In the dialog, select the Instrumentation Generation

2.3 Alternative installation

The alternative way is to download a tar-gz package (instrumentation-tools.tgz2) and extractthe content to the plugin directory of the local eclipse installation. The default location ofthe plugin directory is eclipse/plugins, where eclipse is the directory of your local Eclipseinstallation.

2http://wwwvs.informatik.fh-wiesbaden.de/downloads/extern/oss/permanenta/

instrumentation-tools.tgz

10

Page 11: Getting Started Guide - hs-rm.de · 2008-04-22 · the example project. ouY can do that with the context menu in the pacagek explorer. In the dialog, select the Instrumentation Generation

3 Importing the example project

The guide uses the example project to show how to use the instrumentation suite. The exampleproject is a small application with one or more client threads and a server thread. The clientssend messages to the server, which receives and prints the messages to standard out. Bothparties wait a small random period to simulate workload during each pass.

Download the project from the download location1 , extract and import it into your Eclipseworkspace. To do that, open the context menu in the package explorer and click on import(see �g. 3.1).

Figure 3.1: Project import with the Package Explorer

In the import dialog, select General -> Existing Projects into Workspace and click Next

(see �g. 3.2).

Figure 3.2: Import dialog

1http://wwwvs.informatik.fh-wiesbaden.de/downloads/extern/oss/permanenta/example-project.tgz

11

Page 12: Getting Started Guide - hs-rm.de · 2008-04-22 · the example project. ouY can do that with the context menu in the pacagek explorer. In the dialog, select the Instrumentation Generation

Press the Browse-Button on the right side of Select root directory (see �g. 3.3).

Figure 3.3: Import dialog

Browse to the directory where you have extracted the project. Once you have selected thedirectory, the getting_started project should show up in the import dialog. You may chooseto copy the project into your workspace, but this is not mandatory. Click on Finish. Now,you have successfully imported the example project.

12

Page 13: Getting Started Guide - hs-rm.de · 2008-04-22 · the example project. ouY can do that with the context menu in the pacagek explorer. In the dialog, select the Instrumentation Generation

4 Using the plug-ins

After the successful installation of the plug-ins and the import of the example project, youcan to start using the instrumentation suite. This guide will show you how to add the in-strumentation generation nature to your project, and how to instrument the example projectwith Log4J and ARM. This guide also shows how to generate instrumentation code for theinstrumentation points you have created in the instrumentation steps.

4.1 Add/Con�gure the instrumentation generation nature

First, you need to add the instrumentation generation nature to the example project. Se-lect the example project in the package explorer. Open the context menu and click onInstrumentation Generation -> Add Instrumentation Generation (see �g. 4.1).

Figure 4.1: Adding the instrumentation generation nature to a project.

Now you are asked where to store the repository. One repository is the central instrumentationmodel storage. For simplicity, choose the imported example project (see �g. 4.2).

Figure 4.2: Dialog for choosing the repository location.

The repository is used for all projects in the workspace. You can only have one repository perworkspace.

13

Page 14: Getting Started Guide - hs-rm.de · 2008-04-22 · the example project. ouY can do that with the context menu in the pacagek explorer. In the dialog, select the Instrumentation Generation

Workspace-wide settings like the repository location can be changed in the project settingsdialog of a project with instrumentation generation nature. Open the properties dialog forthe example project. You can do that with the context menu in the package explorer. In thedialog, select the Instrumentation Generation tab (see �g. 4.3).

Figure 4.3: Instrumentation Generation properties.

4.2 Instrumenting with Log4J

In order to use Log4J, the project needs to access a Log4J jar �le in the classpath. Theinstrumentation suite contains a suitable Log4J jar, which can be automatically copied to allprojects instrumented with Log4J.

Figure 4.4: Properties: copying the Log4J library to instrumented projects.

However, the suite does not copy the jar by default. You have to activate the copy option inthe project properties dialog (described in the previous section). In this dialog, you have toactivate the Add Log4J library to project checkbox (see �g. 4.4).

The Log4J Event pattern Now you can start to instrument the example application. Themost primitive pattern one can apply is an Event pattern. This will be the �rst pattern youcreate. Open the World.java �le in the example project. Change the cursor position to the�rst statement in the main method:

14

Page 15: Getting Started Guide - hs-rm.de · 2008-04-22 · the example project. ouY can do that with the context menu in the pacagek explorer. In the dialog, select the Instrumentation Generation

1 int numClients = 2;

Now right click to open the editor's context menu. Select Instrumentation Generation ->

Add Instrumentation Point (see �g. 4.5).

Figure 4.5: Adding an instrumentation point.

The Create new point dialog opened (see �g. 4.6).

Figure 4.6: The Create new point dialog.

In this dialog, you can create new instrumentation points and new basic patterns.

15

Page 16: Getting Started Guide - hs-rm.de · 2008-04-22 · the example project. ouY can do that with the context menu in the pacagek explorer. In the dialog, select the Instrumentation Generation

Create a new basic pattern, by pressing the New basic pattern button. Choose a name, e.g.Application startup (see �g. 4.7).

Figure 4.7: Choosing a pattern name.

Then you should select Event (Log4JBackend) and click OK (see �g. 4.8).

Figure 4.8: Choosing a pattern type.

Back in the Create new point dialog, you can see the newly created pattern. To �nallycreate an instrumentation point, you have to select the empty Source role in the pattern andclick OK (see �g. 4.9).

Figure 4.9: A new pattern.

16

Page 17: Getting Started Guide - hs-rm.de · 2008-04-22 · the example project. ouY can do that with the context menu in the pacagek explorer. In the dialog, select the Instrumentation Generation

You should see a blue L4 with a red cross (see �g. 4.10).

Figure 4.10: A new instrumentation point.

The red cross indicates that the pattern is deactivated. Each pattern is initially deactivatedto prevent the generation of incomplete code, in case required properties or related instru-mentation entities are missing.

The next step is to add a log message to the instrumentation point. Change the cursor positionback to the instrumentated statement. Open the context menu and select InstrumentationGeneration -> Properties (see �g. 4.11).

Figure 4.11: Opening the properties view for a point.

Eclipse will open the properties view. You can enter a log message in the log4j.message

property, e.g. Application startup successful. In the properties view, you may change theLog4J logger and the priority, too (see �g. 4.12).

Figure 4.12: Changing the Log4J log message.

The Log4J Action pattern Now continue with additional patterns. You can add two Actionpatterns, one for the lifetime of the client threads and one for the lifetime of the server thread.

Select the statement, where the client threads are started:

1 clients[i]. start();

Open the Create new point dialog again and add a Log4J action pattern. You can name itClient lifetime for example. The Action pattern for Log4J is Action (Log4JBackend).

You should now see your newly created action pattern in the Create new point dialog. Selectthe Start role and click OK.

17

Page 18: Getting Started Guide - hs-rm.de · 2008-04-22 · the example project. ouY can do that with the context menu in the pacagek explorer. In the dialog, select the Instrumentation Generation

The newly created instrumentation point should show up similar to the �rst instrumentationpoint. The next step is to create an instrumentation point for the Stop role. Change thecursor position in the editor to the join statement for clients:

1 clients[i].join();

Open up the Create new point dialog, select the Stop role and click OK (see �g. 4.13).

Figure 4.13: Adding the stop point.

The last step is to change the log messages for both points of the Action pattern. This worksexactly as described for the event pattern. The main di�erence is that the name of the Actionpattern is added to the beginning of the message, and the name of the role is added at theend. Therefore, you can choose for example Client as log message. This will be changed toClient lifetime: Client (Start) for the start role and Client lifetime: Client (Stop) for the stoprole.

This message is not very meaningful, yet. You may wish to add the Client thread id tothe log message. This is achieved by changing the log message to Client $clients[i].getId()$.Everything between the $-signs will be treated as code, which is concatenated to the messagestring at the position in the log message property.

You can now add another Action pattern for the server thread or go on with the next section.

18

Page 19: Getting Started Guide - hs-rm.de · 2008-04-22 · the example project. ouY can do that with the context menu in the pacagek explorer. In the dialog, select the Instrumentation Generation

4.3 Instrumenting with ARM

Instrumenting with ARM is similar to the Log4J case. In order use ARM, the project needsARM implementation libraries and the Open Group ARM interfaces in the classpath. TheARM interfaces are supplied with the instrumentation suite combined with the OpenGroupnull implementation. The null implementation makes sure you can run an ARM instrumentedapplication, but does not do anything further. There is a more functional implementationavailable at http://www.opengroup.org/arm/. If you have a di�eent ARM implementationavailable, you can use this one.

After you have decided which ARM implementation to use, you may open the project prop-erties as described in section 4.1.

Figure 4.14: Properties: adding the ARM null implementation to the project.

There you have to enter the name of the transaction factory corresponding to your ARMimplementation. If you have chosen to use the null implementation, you may additionally checkthe Add OpenGroup null implementation checkbox, as this implementation is packaged withthe instrumentation suite and can automatically be copied to the application classpath (see�g. 4.14).

The ARM Initalization pattern ARM needs some con�guration work to be done, before itcan be used. This is the task of the Initalization pattern. Open the World.java �le. There isno suitable statement to add the Initalization pattern to, so we will create one. Insert a single; somewhere before the following statement:

1 server.start();

This is necessary, because you cannot add an instrumentation point to an empty line. The ;is an empty statement, and therefore you can use it, to add an instrumentation point to anempty line.

19

Page 20: Getting Started Guide - hs-rm.de · 2008-04-22 · the example project. ouY can do that with the context menu in the pacagek explorer. In the dialog, select the Instrumentation Generation

Set the cursor at the ; statement. Open up the Create new point dialog as described in 4.2(see �g. 4.15).

Figure 4.15: The create new point dialog.

Create a new basic pattern, by pressing the New Basic Pattern button. Name the initaliza-tion pattern something like ARM initialization (see �g. 4.16).

Figure 4.16: Enter a name for the new pattern.

Next, you have to choose the Initalization (ArmBackend) pattern (see �g. 4.17).

Figure 4.17: Choose the initialization pattern.

20

Page 21: Getting Started Guide - hs-rm.de · 2008-04-22 · the example project. ouY can do that with the context menu in the pacagek explorer. In the dialog, select the Instrumentation Generation

Select the role of the initalization pattern and click OK in the Create new point dialog (see�g. 4.18).

Figure 4.18: The create new point dialog.

You should now see a yellow arrow on the left of the ;, which has a red cross painted over it.The red cross indicates, that the instrumenation point is deactivated (see �g. 4.19).

Figure 4.19: The deactivated initialization point.

After you have added the Initalization point, you have to edit the properties of the point.Open up the properties view for the instrumentation point, using the context menu of theeditor (Instrumentation Generation -> Properties) (see �g. 4.20).

Figure 4.20: The editor context menu to open the properties view.

21

Page 22: Getting Started Guide - hs-rm.de · 2008-04-22 · the example project. ouY can do that with the context menu in the pacagek explorer. In the dialog, select the Instrumentation Generation

In the properties view you have to enter an application name, e.g. Hello World! (see �g.4.21).

Figure 4.21: The properties view.

If you did not change the ARM transaction factory property to use the transaction factory ofyour ARM implementation, you can do that now.

The initialization point is now complete.

The ARM Action pattern You will now learn about another way to work with patterns.Note that to create basic patterns, it's possible to use two ways. In the Log4J chapter and forthe Initalization you learned how to create a basic pattern with the Create new point dialog.Now, you will learn how to create patterns with the Instrumentation Patterns view.

Open the Instrumentation Patterns view, by choosing Show View -> Others in the Windowmenu (see �g. 4.22).

Figure 4.22: Window menu and Show View sub menu.

In the Show View dialog, choose Instrumentation Generation -> Instrumentation Pat-

terns and click on OK.

Figure 4.23: The Show View dialog.

22

Page 23: Getting Started Guide - hs-rm.de · 2008-04-22 · the example project. ouY can do that with the context menu in the pacagek explorer. In the dialog, select the Instrumentation Generation

The Instrumentation Patterns view is now visible somewhere in your workbench. In thatview you see the patterns, you have created already (see �g. 4.24).

Figure 4.24: The Instrumentation patterns view.

Before you create the �rst pattern with this view, consider that the aim is to create an RPCpattern. An RPC pattern is created by combining two Action patterns. Therefore you shouldstart by creating two Action patterns. One pattern on the client side and another one on theserver side of the application.

To create a newAction pattern in the view, click on the little plus sign in the InstrumentationPatterns view's toolbar (see �g. 4.25).

Figure 4.25: The green plus sign to add patterns.

Choose a name for the client side Action pattern, e.g. Client action and click OK (see �g.4.26).

Figure 4.26: Choose a name for the pattern.

23

Page 24: Getting Started Guide - hs-rm.de · 2008-04-22 · the example project. ouY can do that with the context menu in the pacagek explorer. In the dialog, select the Instrumentation Generation

Then you have to select Action (ArmBackend) and click OK again (see �g. 4.27).

Figure 4.27: Choose a ARM Action pattern.

You will see the new pattern in the Instrumentation Patterns view. It will have two missingroles (see �g. 4.28).

Figure 4.28: Instrumentation Patterns view with the new pattern.

Create another pattern following the same instructions for the server Action pattern. Namethe server pattern Server action.

Open the Client.java �le now. Set the cursor position in the editor to the following statement:

1 message = new HashMap <String , byte []>();

Then open the editor context menu and choose Instrumentation Generation -> Add In-

strumentation Point. In the Create new point dialog, select the Start role of the Clientaction pattern and click OK.

There is no suitable statement for the Stop role but every instrumentation point is bound toa statement. You can create a empty statement with ;. Add an empty statement behind the�rst catch block and create an instrumentation point at this empty statement but select theStop role of the Client action in the Create new point dialog.

Continue with the Server.java �le. Use this statement as the Start role for the Server action:

1 System.out.println(message.keySet ().iterator ().next());

and create an empty statement after the catch block. Use this empty statement for the Stoprole.

24

Page 25: Getting Started Guide - hs-rm.de · 2008-04-22 · the example project. ouY can do that with the context menu in the pacagek explorer. In the dialog, select the Instrumentation Generation

The next step is to change the properties of each Start role to suitable values. Begin with theClient action. Open the Instrumentation Patterns view again. Scroll to the Start role ofthe Client action and double click on the role. The Properties View opens. The client sidedoes not have any import correlator. Instead it needs some export correlator, which has tobe transfered to the server side. The server uses this correlator as import correlator. Enter aname for the correlator, e.g. exportCorrelator (see �g. 4.29).

Figure 4.29: The ARM client Action properties.

The generated code uses a variable with this name to store the correlator. Therefore you haveto add the declaration of the exportCorrelator before the instrumented statement:

1 byte[] exportCorrelator = null;

3 message = new HashMap <String , byte []>();

The example is prepared to transfer the correlator with the message to the server. To do that,change this statement:

1 message.put("pid: " + mPid + ", iteration: " + i, new byte [0]);

to

1 message.put("pid: " + mPid + ", iteration: " + i, exportCorrelator);

The client side instrumentation is �nished now. Continue with the properties of the Startrole of the Server action. Open the Properties View for the Start role of the Server action.Change the import correlator to some name like importCorrelator (see �g. 4.30).

Figure 4.30: The ARM client Action properties.

The import correlator has to be extracted from the received message. To do so, insert thefollowing statement:

25

Page 26: Getting Started Guide - hs-rm.de · 2008-04-22 · the example project. ouY can do that with the context menu in the pacagek explorer. In the dialog, select the Instrumentation Generation

1 while (! message.containsKey("shutdown")) {

3 + byte[] importCorrelator = message.entrySet ().iterator ().next().getValue ();

5 // process the message

System.out.println(message.keySet ().iterator ().next());

The server side instrumentation is �nished now, too.

The ARM RPC pattern The next step is to combine both Action patterns to an RPCpattern. Open the Instrumentation Patterns view. Create a new pattern by clicking onthe green plus symbol in the view's toolbar. Enter a meaningful name, e.g. RPC. Choose theRPC (ArmBackend) pattern. The new RPC pattern should show up in the InstrumentationPatterns view (see �g. 4.31).

Figure 4.31: The new RPC pattern.

Unfold the RPC pattern and use drag and drop to move the Client and Server Action patterninto the RPC pattern. The Client pattern should be dropped at the ClientSide role, theServer pattern at the ServerSide role (see �g. 4.32).

Figure 4.32: The complete RPC pattern.

You �nished the creation of a RPC pattern.

26

Page 27: Getting Started Guide - hs-rm.de · 2008-04-22 · the example project. ouY can do that with the context menu in the pacagek explorer. In the dialog, select the Instrumentation Generation

4.4 Code generation

Pattern activation Code can only be generated for activated instrumentation points. Thedefault is to leave patterns deactivated after creation, until they are explicitly activate. There-fore, you have to activate all the patterns and instrumentation points you created earlier, be-fore you can generate code for them. There are several ways to activate the instrumentationpoints:

• At project, package and �le level

• At pattern level

• At point level

For activating all instrumentation points of a project, of a package or of a single �le, you haveto select the corresponding entity in the package explorer, open the context menu and chooseInstrumentation Generation -> Activate instrumentation points (see �g. 4.33).

Figure 4.33: Activation of instrumentation points with the package explorer.

For activating all instrumentation points belonging to a pattern, you have to open the InstrumentationPatterns view, select the desired pattern and use the context menu to activate that pattern(Activate/Deactivate, see �g. 4.34).

Figure 4.34: Activation of instrumentation points with the instrumentation patterns view.

27

Page 28: Getting Started Guide - hs-rm.de · 2008-04-22 · the example project. ouY can do that with the context menu in the pacagek explorer. In the dialog, select the Instrumentation Generation

For activating a single point, you can either use the Instrumentation Patterns view in thesame way as for patterns, but instead of a pattern you have to select an instrumentation point.Another way is to use the editor context menu (Instrumentation Generation -> Activate

instrumentation point, see �g. 4.35).

Figure 4.35: Activation of single instrumentation points with the editor context menu.

If a pattern is not complete, the user will be warned with a dialog message (see �g. 4.36).

Figure 4.36: Warning for activation of incomplete patterns.

The deactivation works very similar in all three cases, you just have to select Deactivate

instrumentation points instead of Activate instrumentation points.

Code generation and removal The code generation can be triggered in the same granularityas the activation and deactivation of patterns: at project, pattern or point level. You have tochoose Generate Instrumentation Code instead of Activate Pattern/Point in the contextmenus that also o�er the activation selection. The removal of generated code works accord-ingly, replacing Generate Instrumentation Code with Remove Instrumentation Code.

There are some things to note about the code generation and removal. Not all of the generatedcode will be removed. You have to do some manual work to remove all generated code forimports, the ArmHelper class and the libraries (ARM, Log4J) copied to the project.

If you deactivate a pattern, code that was generated for the patterns before gets removed.The code is rebuilt, if you activate the pattern again.

28

Page 29: Getting Started Guide - hs-rm.de · 2008-04-22 · the example project. ouY can do that with the context menu in the pacagek explorer. In the dialog, select the Instrumentation Generation

4.5 Instrumentation Patterns View

The Instrumentation Patterns view is one of the central places to do the instrumentationwork. Therefore, it is important to know the details of this view.

4.5.1 Adding patterns

Adding patterns is done in four simple steps:

• Click on the green plus symbol (see �g. 4.37)

Figure 4.37: The green plus sign, to add patterns.

• Choose a name (see �g. 4.38)

Figure 4.38: Choose a name for the pattern.

• Choose a pattern (see �g. 4.39)

Figure 4.39: Choose the desired pattern.

• Add patterns and points for the roles as required

The fourth step may require additional work in the editor context menu, because you can onlycreate new instrumentation points in the editor.

29

Page 30: Getting Started Guide - hs-rm.de · 2008-04-22 · the example project. ouY can do that with the context menu in the pacagek explorer. In the dialog, select the Instrumentation Generation

4.5.2 Deleting patterns and points

Deleting patterns is achieved using the context menu. Just select the pattern or point youwish to delete and choose Delete in the context menu. If you delete the last instrumentationpoint of a pattern, the whole pattern is deleted as well (see �g. 4.40).

Figure 4.40: Delete a pattern.

4.5.3 Moving and Copying patterns and points

Patterns and points can be moved and copied betwenn patterns. This is done by drag anddrop of patterns or points. They can only be moved or copied if they satisfy the requirementsof the new role (see �g. 4.41).

Figure 4.41: Moving a pattern with drag and drop.

If you want to perform a copy, you have to hold down the Ctrl key while dropping the patternor point.

30

Page 31: Getting Started Guide - hs-rm.de · 2008-04-22 · the example project. ouY can do that with the context menu in the pacagek explorer. In the dialog, select the Instrumentation Generation

4.5.4 Changing the view

The view can show the patterns in two di�erent organizations:

• Show all patterns or show patterns per project (see �g. 4.42 and 4.43)

Figure 4.42: The pattern view, showing all patterns.

Figure 4.43: The pattern view, showing patterns per project.

Additionally the view may be �ltered (see �g. 4.44):

• Hide empty patterns

• Show only complex patterns

• Hide basic patterns which are part of a complex pattern.

31

Page 32: Getting Started Guide - hs-rm.de · 2008-04-22 · the example project. ouY can do that with the context menu in the pacagek explorer. In the dialog, select the Instrumentation Generation

Figure 4.44: The pattern view, �ltering options.

32

Page 33: Getting Started Guide - hs-rm.de · 2008-04-22 · the example project. ouY can do that with the context menu in the pacagek explorer. In the dialog, select the Instrumentation Generation

Bibliography

[Gul03] Ceki Gulcu. The Complete Log4j Manual: The Reliable, Fast and Flexible LoggingFramework for Java. QOS.ch, Mai 2003.

[TOG04] The Open Group. Application Response Measurement (ARM) Issue 4.0 V2 - JavaBinding, December 2004. Catalog number C042.

33