• Aucun résultat trouvé

A framework for development of concurrency and I/O in servers

N/A
N/A
Protected

Academic year: 2021

Partager "A framework for development of concurrency and I/O in servers"

Copied!
2
0
0

Texte intégral

(1)

HAL Id: hal-00620056

https://hal-upec-upem.archives-ouvertes.fr/hal-00620056

Submitted on 7 Sep 2011

HAL is a multi-disciplinary open access archive for the deposit and dissemination of sci- entific research documents, whether they are pub- lished or not. The documents may come from teaching and research institutions in France or abroad, or from public or private research centers.

L’archive ouverte pluridisciplinaire HAL, est destinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des établissements d’enseignement et de recherche français ou étrangers, des laboratoires publics ou privés.

A framework for development of concurrency and I/O in servers

Gautier Loyauté

To cite this version:

Gautier Loyauté. A framework for development of concurrency and I/O in servers. 1st European

Conference on Systems (EuroSys 2006), Apr 2006, Belgium. 1pp., 2006. �hal-00620056�

(2)

A framework for development of concurrency and I/O in servers

Gautier Loyaut´e

Universit´e de Marne la Vall´ee

Laboratoire d’Informatique de l’Institut Gaspard-Monge UMR-CNRS 8049

F-77454 Marne la Vall´ee, Cedex 2, France e-mail: loyaute@univ-mlv.fr

Development of concurrency and I/O in servers and mid- dlewares becomes more and more complex:

minimization of latency ;

maximization of bandwidth ;

no consensus on the best concurrency model ; select the model best adapted to the hardware .

Applications are modeled by a directed graph , in which each stage (or vertex) corresponds to an atomic unit of treatment and edges correspond to channels (method calls, local queues or sockets) be- tween them.

We describe here the implementation of a simple “ Echo ” server which uses three stages. The directed graph models the interconnection of its stages:

accept read write

Specifications and code generation are 100% Java ! This ensures the portability of the applications de- veloped using our framework.

Development process

This table summarizes the development steps of our framework:

Input / Output interfaces specified in Java by user

Events generated from interfaces

Functionnal code of a stage specified in Java by user Technical code of a stage generated from concurrency Stage connection

specified by user Concurrency selection

Concurrency generated from concurrency

Event description

The developer has to define the interface for input and/or output events for each stage. These events allow the communication between stages.

Example:

For the initial stage, only an output interface is defined:

public interface OutputAcceptEvent {

public void setAcceptSaburoSocket(SaburoSocket s);

}

For a final stage only an input interface is defined:

public interface InputWriteEvent {

public SaburoSocket getAcceptSaburoSocket();

public ByteBuffer getReadByteBuffer();

}

For any other stage input and output interfaces should be defined:

public interface InputReadEvent {

public SaburoSocket getAcceptSaburoSocket();

}

public interface OutputReadEvent {

public void setReadByteBuffer(ByteBuffer b);

}

Stage description

The developer should implement the handle(. . . ) method which corresponds to the instructions car- ried out by a stage. Its parameters are the input and/or output events and the context.

The context is the way to reach successor(s) in the graph.

Example:

public class AcceptStage {

private final SaburoServerSocket server;

public void handle(StageContext ctx,

OutputAcceptEvent out) { SaburoSocket client = server.accept();

out.setAcceptSaburoSocket(client);

ctx.dispatchToSuccessor(out);

} }

public class ReadStage {

public void handle(StageContext ctx, InputReadEvent in,

OutputReadEvent out) {

SaburoSocket client = in.getAcceptSaburoSocket();

ByteBuffer buffer = null;

while((buffer = client.read()) != null) { buffer.flip();

out.setReadByteBuffer(buffer);

ctx.dispatchToSuccessor(out);

} } }

public class WriteStage {

public void handle(InputWriteEvent in) {

SaburoSocket client = in.getAcceptSaburoSocket();

client.write(in.getReadByteBuffer());

} }

The implementation is based on the Java NIO API which provides blocking and non blocking I/O. To avoid the complexity of this API, we provide encapsulation classes which simplifies implementation.

Stage connections

The connection of the stages has to be specified in Java by the developer.

Example:

StageManagerImpl manager = new StageManagerImpl();

manager.connect(AcceptStage.class, ReadStage.class);

manager.connect(ReadStage.class, WriteStage.class);

Concurrency selection

The concurrency model has to be selected in Java by the developer.

Example:

ModelExecutorImpl executor = new ModelExecutorImpl();

executor.run(configurator, stageManager, SEDA);

Currently, these two steps are hand-coded but could be generated automatically via an Eclipse plugin.

Communication generation

The interfaces previously defined of the input and/or output events which allow the communica- tion between stages are automatically generated . The implementation of the context is also auto- matically generated according to the concurrency model .

Context:

If there is only one process, the context is a function call.

In the case of several processes, we introduce queues to implement the context.

For distributed applications, the context establishes the connections between peers.

Concurrency generation

The last step consists in the automatic generation of the concurrency model .

Example: Iterative architecture

public class IterativeModel {

public void service() throws Exception { while(true)

acceptStageWrapper.handle();

} }

Example: S taged E vent- D riven A rchitecture

public class SedaModel

public void s e r v i c e ( ) throws Exception

new Thread ( new Runnable ( )

public void run ( )

while ( true )

w r i t e S e l e c t o r . doSelect ( ) ;

) . s t a r t ( ) ;

new Thread ( new Runnable ( )

public void run ( )

while ( true )

readSelector . doSelect ( ) ;

) . s t a r t ( ) ;

while ( true )

acceptSelector . doSelect ( ) ;

The bytecode is generated automatically using

ASM and all the code generators can be used at run-

time , even if they are usually used at compile time .

Références

Documents relatifs

Toute reproduction ou représentation intégrale ou partielle, par quelque procédé que ce so'it, des pages publiées dans la présente édition, faite sans l'autorisation de l'éditeur

Table 1 gives an overview of the resulting aspect ratios of drawn diagrams; it can be seen that for every class of graphs less than 50 % of the drawings have an acceptable

The Temporary Administration Measures for the Verifi cation and Approval of Overseas Investment Project provides that “overseas invest- ment” refers to investment

If the argument to evaluate is an ordi- nary value, evaluate just returns that value (EVAL1); if the value is an exceptional value, evaluate chooses an arbitrary member of the set

With a parallel printer port, three serial ports (one standard and two optional), and a game port, the Magic I/O packs more features and connectors on a true

Whereas ex- pression mechanisms of synaptic plasticity are well identified today and involve either presynaptic change in neurotransmitter release or post- synaptic change in

That is, the column j of the instruction matrix corresponding to a thread that is available but not fully executed, consists in a (possibly empty) sequence of decided cells,

The term procurement strategy means a set of planned amounts of procurement for the entire product line, including the selected prices and discounts from all potential suppliers;