Embedded Atom Ant (EAA)€¦ · Atom Ant (EAA) Grupo 06 Introdu˘c~ao Trabalhos relacionados...

Post on 17-Aug-2020

5 views 0 download

Transcript of Embedded Atom Ant (EAA)€¦ · Atom Ant (EAA) Grupo 06 Introdu˘c~ao Trabalhos relacionados...

Embedded Atom Ant (EAA)

Grupo 06

July 6, 2009

EmbeddedAtom Ant

(EAA)

Grupo 06

Introducao

Trabalhosrelacionados

EAA-Core

EAA

Secao

1 Introducao

2 Trabalhos relacionados

3 EAA-Core

4 EAA

EmbeddedAtom Ant

(EAA)

Grupo 06

Introducao

Trabalhosrelacionados

EAA-Core

EAA

Objetivos

Persistencia semi-automatica de objetos de alto-nıvel

Voltado para sistemas embarcadosMetodologia simples para tratamento de heranca ecomposicaoPouca interferencia do programador

EmbeddedAtom Ant

(EAA)

Grupo 06

Introducao

Trabalhosrelacionados

EAA-Core

EAA

Caracterısticas necessarias

Persistencia de tabelasPersistencia de entradasUtilizacao mınima de recursos da maquina (memoria e cpu)Dados de armazenados como um conjunto de bytes

EmbeddedAtom Ant

(EAA)

Grupo 06

Introducao

Trabalhosrelacionados

EAA-Core

EAA

Secao

1 Introducao

2 Trabalhos relacionados

3 EAA-Core

4 EAA

EmbeddedAtom Ant

(EAA)

Grupo 06

Introducao

Trabalhosrelacionados

EAA-Core

EAA

Boost Serialization[1]

Serializacao semi-automaticaEscolha de variaveis serializadasSalvamento de ponteiros e arrays

EmbeddedAtom Ant

(EAA)

Grupo 06

Introducao

Trabalhosrelacionados

EAA-Core

EAA

BOOST Serialization - Exemplo

#inc l u d e <f s t r e a m >

// i n c l u d e h e a d e r s t h a t implement a a r c h i v e i n s i m p l e t e x t fo rmat#inc l u d e <b o o s t / a r c h i v e / t e x t o a r c h i v e . hpp>#inc l u d e <b o o s t / a r c h i v e / t e x t i a r c h i v e . hpp>

c l a s s g p s p o s i t i o n {p r i v a t e :

f r i e n d c l a s s b o o s t : : s e r i a l i z a t i o n : : a c c e s s ;/∗When th e c l a s s A r c h i v e c o r r e s p o n d s to an output a r c h i v e , t he

& o p e r a t o r i s d e f i n e d s i m i l a r to <<. L i k e w i s e , when th e c l a s s A r c h i v ei s a t y p e o f i n p u t a r c h i v e t he & o p e r a t o r i s d e f i n e d s i m i l a r to >>.∗/

template<c l a s s A r c h i v e >vo id s e r i a l i z e ( A r c h i v e & ar , const uns igned i n t v e r s i o n ) {

a r & d e g r e e s ;a r & minutes ;a r & s e c o n d s ;

}

i n t d e g r e e s ;i n t minutes ;f l o a t s e c o n d s ;

pub l i c :g p s p o s i t i o n ( ) {} ;g p s p o s i t i o n ( i n t d , i n t m, f l o a t s ) :

d e g r e e s ( d ) , minutes (m) , s e c o n d s ( s ) {}} ;

EmbeddedAtom Ant

(EAA)

Grupo 06

Introducao

Trabalhosrelacionados

EAA-Core

EAA

i n t main ( ) {// c r e a t e and open a c h a r a c t e r a r c h i v e f o r outputs t d : : o f s t r e a m o f s ( ”f i l e n a m e ”) ;

// c r e a t e c l a s s i n s t a n c econst g p s p o s i t i o n g ( 3 5 , 59 , 24 .567 f ) ;

// save data to a r c h i v e{

b o o s t : : a r c h i v e : : t e x t o a r c h i v e oa ( o f s ) ;// w r i t e c l a s s i n s t a n c e to a r c h i v eoa << g ;// a r c h i v e and st ream c l o s e d when d e s t r u c t o r s a r e c a l l e d

}

// . . . some t ime l a t e r r e s t o r e the c l a s s i n s t a n c e to i t s o r g i n a l s t a t eg p s p o s i t i o n newg ;{

// c r e a t e and open an a r c h i v e f o r i n pu ts t d : : i f s t r e a m i f s ( ”f i l e n a m e ”) ;b o o s t : : a r c h i v e : : t e x t i a r c h i v e i a ( i f s ) ;// read c l a s s s t a t e from a r c h i v ei a >> newg ;// a r c h i v e and st ream c l o s e d when d e s t r u c t o r s a r e c a l l e d

}r e t u r n 0 ;

}

EmbeddedAtom Ant

(EAA)

Grupo 06

Introducao

Trabalhosrelacionados

EAA-Core

EAA

JFFS (Journalling Flash File System)[2]

Voltado para flash

Escrita homogenea em toda flash

Trata flash como um vetor circularInodes novos sao sempre escritos no fim da fila

Nodos validos e obsoletos

Nova versao do arquivo -> velho obsoleto

EmbeddedAtom Ant

(EAA)

Grupo 06

Introducao

Trabalhosrelacionados

EAA-Core

EAA

Estrutura de inodos em memoria

varredura total de inodos na montagem

Dados estaticos sao tambem apagados (buffer circular)

Diminuicao da vida media das flashes

EmbeddedAtom Ant

(EAA)

Grupo 06

Introducao

Trabalhosrelacionados

EAA-Core

EAA

Secao

1 Introducao

2 Trabalhos relacionados

3 EAA-Core

4 EAA

EmbeddedAtom Ant

(EAA)

Grupo 06

Introducao

Trabalhosrelacionados

EAA-Core

EAA

Superbloco (24)

ID magico (4)Numero de blocos (4)Numero de descritores de tabela (4)Tamanho do discos (8)Tamanho dos blocos (4)

EmbeddedAtom Ant

(EAA)

Grupo 06

Introducao

Trabalhosrelacionados

EAA-Core

EAA

Descritores de tabela (20)

UTID -> Universal Table Identifier (8)Posicao do bloco inicial das entradas (4)Tamanho das entradas (4)Numero de entradas (4)

EmbeddedAtom Ant

(EAA)

Grupo 06

Introducao

Trabalhosrelacionados

EAA-Core

EAA

Descritor de Entrada (16)

Universal Entry Identifier (4)Indice de identidade (4)Tamanho da entrada (4)Posicao abosluta da entrada (4)

EmbeddedAtom Ant

(EAA)

Grupo 06

Introducao

Trabalhosrelacionados

EAA-Core

EAA

Interface

Metodos POSIX-like

open - cria/retorna descritor de entradaread - le uma entradawrite - escreve uma entradaclose - limpa os meta-dados da entrada e atualiza-a

EmbeddedAtom Ant

(EAA)

Grupo 06

Introducao

Trabalhosrelacionados

EAA-Core

EAA

Outras caracterısticas

estado dos blocos via bitmap“driver de emulacao” para POSIXinterface escrita em C++

EmbeddedAtom Ant

(EAA)

Grupo 06

Introducao

Trabalhosrelacionados

EAA-Core

EAA

Testes

BOOST AUTO TEST CASE( r e a d A n d W r i t e T e s t A t N o n Z e r o P o s i t i o n s ) {s t d : : t r 1 : : s h a r e d p t r <v s t o r a g e > s t o r a g e (new a r r a y s t o r a g e ( ”d i s k . img ”)

) ;

i n t dummy = 4 ;

s t o r a g e−>w r i t e B u f f e r (&dummy , dummy , s i z e o f ( i n t ) ) ;

i n t s t o r e d ;

s t o r a g e−>r e a d B u f f e r (& s t o r e d , dummy , s i z e o f ( i n t ) ) ;BOOST CHECK MESSAGE(dummy == s t o r e d , ”What you wrote i s what you

r e a d ”) ;

s t o r a g e−>r e a d B u f f e r (& readed , 0 , s i z e o f ( i n t ) ) ;BOOST CHECK MESSAGE(dummy != s t o r e d , ”What you wrote i s what you

r e a d ”) ;}

EmbeddedAtom Ant

(EAA)

Grupo 06

Introducao

Trabalhosrelacionados

EAA-Core

EAA

s t a t i c const uns igned i n t BLOCK SIZE = 6 4 ; // i n by t e s

BOOST AUTO TEST CASE( qu ickFormatTest ) {s t d : : t r 1 : : s h a r e d p t r <v s t o r a g e > s t o r a g e (new a r r a y s t o r a g e ( ”d i s k . img ”)

) ;

VERBOSE BLOCK {s t o r a g e f o r m a t t e r : : fo rmat (∗ s t o r a g e , BLOCK SIZE ,

f o r m a t p a t t e r n : : UPPER BITS HIGH PATTERN) ;}

s u p e r b l o c k d a t a sData = s t o r a g e−>getManager ( ) . g e t S u p e r b l o c k D a t a ( ) ;

BOOST CHECK MESSAGE( sData . b l o c k S i z e == BLOCK SIZE , ”Block s i z e v a l u emust remain unchanged ”) ;

BOOST CHECK MESSAGE( sData . mag ic Id == EAA MAGIC ID , ”The magic i dmust remain unchanged ”) ;

BOOST CHECK MESSAGE( sData . d i s k S i z e == s t o r a g e−>s t o r a g e S i z e ( ) , ”S t o r a g e s i z e s h o u l remain unchanged ”) ;

BOOST CHECK MESSAGE( sData . numberOfBlocks ==( ( sData . d i s k S i z e − s i z e o f ( s u p e r b l o c k d a t a ) ) / sData . b l o c k S i z e )

,”Number o f b l o c k s must be th e th e number o f f r e e b y t e s

d i v i d e d by th e BLOCK SIZE ”) ;

BOOST CHECK MESSAGE( sData . numberOfTables == 0x0 , ”There must be nonet a b l e t y p e i n f o s on system f o r m a t t i n g ”) ;

}

EmbeddedAtom Ant

(EAA)

Grupo 06

Introducao

Trabalhosrelacionados

EAA-Core

EAA

Secao

1 Introducao

2 Trabalhos relacionados

3 EAA-Core

4 EAA

EmbeddedAtom Ant

(EAA)

Grupo 06

Introducao

Trabalhosrelacionados

EAA-Core

EAA

Caracterısticas

Interfaces simples e direta para persistenciaPossibilidade de tratamento de heranca e composicao

EmbeddedAtom Ant

(EAA)

Grupo 06

Introducao

Trabalhosrelacionados

EAA-Core

EAA

Exemplo

c l a s s T e s t C l a s s F o o : pub l i c eaa : : P e r s i s t a b l e {pub l i c :

T e s t C l a s s F o o ( ) ;T e s t C l a s s F o o ( i n t a , f l o a t b , uns igned long i n t c ) ;

v i r t u a l vo id s e r i a l i z e ( eaa : : T a b l e F i e l d s & f i e l d s ) ;

boo l ope ra to r==(const T e s t C l a s s F o o & o t h e r ) const ;

p r i v a t e :i n t x ;f l o a t y ;uns igned long i n t z ;

} ;

EmbeddedAtom Ant

(EAA)

Grupo 06

Introducao

Trabalhosrelacionados

EAA-Core

EAA

vo id T e s t C l a s s F o o : : s e r i a l i z e ( eaa : : T a b l e F i e l d s & f i e l d s ) {f i e l d s . s a v e ( x ) ;f i e l d s . s a v e ( y ) ;f i e l d s . s a v e ( z ) ;

}

vo id P e r s i s t T e s t : : t e s t 1 ( ) {T e s t C l a s s F o o f o o ( 1 , 2 . 0 f , 3) ;f o o . s a v e ( ) ;i n t i d = f o o . g e t I d ( ) ;

T e s t C l a s s F o o bar ;bar . l o a d ( i d ) ;

CPPUNIT ASSERT( f o o == bar ) ;}

EmbeddedAtom Ant

(EAA)

Grupo 06

Introducao

Trabalhosrelacionados

EAA-Core

EAA

Faltou

Integracao total com o EPOS

EmbeddedAtom Ant

(EAA)

Grupo 06

Introducao

Trabalhosrelacionados

EAA-Core

EAA

Trabalhos futuros

Strings para identificacao de objetos - Hash

Timers - atualizacao de entradas

Interface metaprogramada

EmbeddedAtom Ant

(EAA)

Grupo 06

Introducao

Trabalhosrelacionados

EAA-Core

EAA

Conclusoes

Objetivos atingidos

Persistencia simples de objetosCodigo simples e pequeno

2410 linhas = 1605 linhas no Core e 845 nas interfaces

Test Driven Development

KISSValidacao

EmbeddedAtom Ant

(EAA)

Grupo 06

Introducao

Trabalhosrelacionados

EAA-Core

EAA

BOOST SERIALIZATION,http://www.boost.org/doc/libs/1_39_0/libs/serialization/doc/index.html

JFFS,http://en.wikipedia.org/wiki/JFFS

EAA,https://svn.inf.ufsc.br/fbafelipe/eaa/trunk

EAA-CORE,https://svn.inf.ufsc.br/dedefbs/so2/trunk/eaa_core

EXTremeDB,http://en.wikipedia.org/wiki/EXtremeDB

RDMEmbedded,http://en.wikipedia.org/wiki/RDM_Embedded