update20140630

This commit is contained in:
stubbfel
2014-06-30 13:58:10 +02:00
parent 565970632e
commit 1e6cf42df3
877 changed files with 1146249 additions and 0 deletions

BIN
Bundeswehr/musterung.pdf Normal file

Binary file not shown.

View File

@@ -0,0 +1,55 @@
Kreiswehrersatzamt Neuruppin
Personenkennziffer
um: New -- 050187571637
Vorgangsnummer
Herrn 022-00970] h
Felix Axel Stubbe
Berliner Str. 131 B
16303 Schwedt/Oder Bearbeiter/in:FrauWi11e
i 03391/3569-330
Neuruppin, 27.1 1.2006
gegen Empfangsbekenntnis
Musterung
Sehr geehrter Herr Stubbe,
nach dem Ergebnis der Musterung am 27.11.2006 sind Sie nicht wehrdlenstffihlg. Eine Durchschrift des ärztlichen
Untersuchungsergebnisses/Verwendungsausweises ist beigefiigt.
Sie werden nicht zum Wehrdienst herangezogen.
Einer Entscheidung über Ihren Antrag auf Zurückstellung vorn 06.08.2004 bedarf es daher nicht.
Sie unterliegen nicht der Wehrüberwachung.
Angewandte Rechtsvorschriften: §§ Sa, 9, Z4 Abs.3 Wehrpflichtgesetz '
Rechtsbehelfsbelehrung
Gegen diesen Bescheid kann innerhalb von zwei Wochen nach Bekanntgabe Widerspruch erhoben werden. Der
Widerspruch ist beim Kreiswehrersatzamt Neuruppin, Eisenbahnen 23, 16816 Neuruppin schriftlich oder zur
Niederschrift einzulegen.
Mit freundlichen Grüßen
Im Auftrag
QMM
Wille
Das Schreiben enthält pensonenbezogene Daten (Schulzlzeietch 2 gem Dnnmhfixhmngsbeslilmnungen zu § 9 Bundesdatenschutzgesetz)
Auskunlts- und Eernmngszenlrum (A Hz): 03391/3569680 oder01s02/999640 ' 00011130 dc-
Sprecllzeilenz rommclmm Dienstgebäude: Telefon: 03391/35694)
Mo Du < 07-30-I6-O0,Di—l8 oo Uhr Postfinch 1351 Eisenbnlmstr 23 Telefax: 03391/3559-343
Fr: 07:30-I330 Uhr 15802 Neumppm 16816 Neuruppin
und nach Vereinbarung! eMnll: KWEANeuruppin@bund=swehr.urg

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,217 @@
Pe|S0n3lf|'a9eb09en für Sozialversicherungspflichtige
Persönliche Angaben Beschafugungen
Familienname S Fuk/w/
Vorname :4 ihr _
Straße und Hausnummer Ku */rr Ä“ 5/779
PLZ, Ort 46 75c a, 5214m fr
Geburtsdatum O5 Ü’. 74/ .477-
Sozialversicherungsnummer Q9 O 4J l S Q 7* k:
Geburtsname am M: i
Geburtsort „Qglxvwtjfl-
Geburtsland D eu b0: l am, d
Familienstand L 61%
Staatsangehörigkeit 02 q h; m I
Mitarbeitender Familienangehörige Elia Emein
Bankverbindung
Kontonummer
U iBAN 9:34 4 1-0 5 no 2 com; 36447
1:: BIC WfiLxfDfüfiu/Mtx
Bankleitzahl _
Bankbezeichnung 5fzM[/9197 IM-:7? 7:/,vw (In
Beschäftigung
Eintrittsdatum // f O i. Z 0 '70 g
Berufsbezeichnung Sc f/<4/a,~( em ht/I(I(’€ 7
ausgeübte Tätigkeit
Arbeitgeber C0 '0/\" W C k g M"; M
erstellt du roh:
EHL-HUBER-W RTH Se-nelvofl
Erfassungsbogen zum Tätigkeitsschlüssel
1 . Ausggübte Tätigkeit: Welche Tätigkeit übt der! die Beschäftigte im aktuellen
Beschäftigungsverhältnis aus?
Maßgebend ist alleine die derzeit ausgeübte Tätigkeit, NICHT der
erlernte Beruf.
&F*a/m at 1///a//(/5/ea
2, weichen allgemeinbildenden höchsten 3. Welchen höchsten ber fIi hen Ausbildun ahschluss
Schulggsghluss hat der! die Beschäftigte? hat deY/die Be5Ch3fTi997
__ Ohne Beruflichen Ausbildungsabschluss (l)
Ohne Schulabschluss (1) Anerkannte Berufsausbildung (2)
Haupt-/Volksschulc (2) Meister/Techniker glelchw, Fachschulabschluss (3)
Mittlere Reife oder gleichwerüg (3) Bachelor (4)
Abitur/Fachabitur (4) K Diplom/Magister/Master/Staatsexamen (5)
Promotion/Habilitation (6)
4. ist der/die Beschäftige in einem 5. -landelt es sich um 5- |$N-13$ Beschäfiigungs
Zeitarbeitsverhältnis beschäftigt? eine Vollzeit- oder Verhältnis b__efristet oder
Teilzeitbeschäftigung? Unbefristet
T Ne1n(smmmpers0na1) i1 Vollzeit Befristet
Ia (Zeitarbeit) Teilzeit Unbefristet
Anmerkungen:
erstellt durch:
Seite 2 von 4
EHL- Husex- WARTH & AMANN
v.
Urlaubsanspruch
"770 in?!
(pro Kalenderjahr)
Wöchentliche Arbeitszeit
LrOÖ/um/ev/i
Beginn der Ausbildung
Voraussichtl. Ende der Ausbildung
Befristung:
Das Arbeitsverhältnis ist befristet
(Wenn ja, bitte schriftlichen Arbeitsvertrag in Kopie beifügen)
Sozialversicherung:
nein
Krankenkasse
E111//75/)
-gesetzlich Krankenversichert
121a Ünein
—privat Krankenversichert
Eja Einein
Lohnsteuer:
Lohnsteuerklasse
/I
Kinderfreibetrag
Konfession
-__4
Steueridentifikations-Nr.
Vergütung:
904411 3 WM?
Stundenlohn
Ausbildungsvergütu ng
Gehalt
„Q O 00._'~4/)9 Mann/i
Zulagen
VL (Arbeitgeberzuschuss)
erstellt durch:
EHL - HUBER - WARTH a. AMANN
Seite 3 von 4
Betriebliche
Altersvorsorge
ja
nein
Wenn ia, Art: Direktversicherung
Pensionskasse
Pensionsfond
Unlerstüizungskasse
Direktzusage
Beizulegen sind:
(soweit zutreffend)
Lohnsteuerkartel Bescheinigung für den Lohnsteuerabzug
(des laufenden Kalenderjahres)
Mitgliedsbescheinigng der Krankenkasse
Kopie des Sozialversicherungsausweises
Kopie des Arbeitsvertrages/ Ausbildungsvertrag
Kopie des Vertrages über die betriebliche Altersvorsorge
Kopie des VL-Vertrages
Nachweis der Elterneigenschaft (z.B. Geburtsurkunde etc.)
bei Studenten: lmmatrikulaüonsbescheinigung
bei Prakükanten: Praktikumsbescheinigung der Universität
Bescheinigung über den Schulbesuch
Auszug aus Prüfungs-l Studienordnung
Sonstiges
EIIIKE—
Wir gmeg Sie ygi gag Iglgengm Umgrlyen neben 1g Bgnkvfllndung augh die IBAN und gig
Bl inzu ' hen:“ - Bankverbindung van „ VWL“
- Bankverbindung der „Betrieblichen Altersvorsorge“
- Bankverbindung bei „Pfändungen“
erstellt durch:
EHL - HUBER - WARTH s: AMANN
k i
Seite 4 von 4

Binary file not shown.

View File

@@ -0,0 +1,39 @@
3G BIKES
the art of motion
3G Bikes Deutschland GmbH ~ Fliegerstr 1 — 30179 Hannover
Herrn
Felix Stubbe K?""k“
Rudolf-Breitscheid Straße 19 ;')":g:"5_I;-"1.
uver
16303 s°“""e“ Telefon: 0511 /357 35s 4s
Fax: 0511 I 357 35s 49
E-Mail: info@3gbikes.de
Datum: 10.06.2014
Recnnungs«Nr ' 20140263
Kunden-Nr.: 20637
7 _ 7 Sachbearbeiler/»in: P_|flpp Vogelbein
Rechnung
Sehr geehrter Herr Stubbe,
wir erlauben uns, wie folgt Rechnung zu stellen:
Pos. Anzahl Einheit Artikelnr. Bezeichnung Einzelpreis Gesamtpreis
1 1 Stk. 36267 Satteldecke "Sunflower", 250 X 230mm, Nylon, mit 10 3.90 € 3,90 €
mm Schaumeinlage
2 1 Stk. 23045 Klingel Maxi ding dong Sunflower 15,98 € 15,98 €
3 1 Stk. Versand 5,25 € 5,25 €
Gesamtbetrag 25,13 €
enthaltene Mehnuertsteuer 19% auf 21,12 € netto 4,01 €
Bremer Landesbank Geschäftsführer: Jürgen Blaskuwitz
Konto—Nr.: 303 22 77 O03 Handelsregister: HRB 205585
BLZ: 290 500 OO Amtsgericht Hannover
iBAN: DE 31 2905 0000 3032 2770 D3 Steuernummer: 25/209/15808
SWIFF: ERLADE22

Binary file not shown.

View File

@@ -0,0 +1,62 @@
(3£1hLER|A
A1exanderp1atz
A1exanderp1atz 9
10176 Ber11n
Te1.: 030-24743-0
Mustang, Bermuda 34 59,95
234 04042779614220
T Shirt 1/2 S.011v XL 9,95
ii: I o t a 1
Anzah1 P05./Art. 2/2
EC—Cash EUR 69.90
~ Kundenbe1eg -
Kar1enzah1ung
girocard
Betrag: EUR 69,90
Datum: 14.06.14 Ze1t: 16:47
Term1na1-Nr: 67117171
Trace-Nr: 070083
Beleg: 2049
Karten-Nr: ###############14B0
Folge-Nr.: 0007
A10: 985674
Weitere Daten: 0000000000/EB00//
//440302//9012900002303000000000
00E80001
Zah1ung erfolgt
Uettowarenwert EUR 58,74
MwSt 19,00% EUR 11.15
Für diesen Einkauf hätten Sie mit der
PAVBACK Karte 10 Punkt(e) erha1ten1
(außer für Bücher
1111111111111 11|1I1|1111111111I111111111|11111111lI11
010/0210 14.06.14
Besuchen Sie unsere
Lego ~ SCHAU
in der 3.Eta9e
ha n für S1e geöffnet:
Mo — M1 9.30 — 20.00 Uhr
D0 Sa 9,30 - 22.00 Uhr
1tte den Kassenbon fur
Umtausch aufbewahrent
NEEE-Reg.-Nr. DEB0040693
UST-I0: DE 811142395
W1
m

BIN
bons/20140614-JackJones.pdf Normal file

Binary file not shown.

View File

@@ -0,0 +1,38 @@
J1-ICKE JONES
Vero Mada Jack E Jones
Bestseiier Retail Dtl. GmbH
Grunerstr. 20
10179 Berlin
Tei. 030 / 308744660
VERKAEUFER ohne Verkauf
5712063461593
ABSTRACT TEE S/S COR
5712410592055
CARSON TEE SS CREW N
PUSTEN
SUMME
girocard
MWST1
MWST Ü
2 .
6316 4479/001/001 14.06.2014 17:12 VA-00
\l1e1en Dank fur den Einkauf.
ao-Tege-Umtauschservi ce bundesweit. ab
Kaufdatum, gegen Vnriage des Kassenbons
oder des Umtauschetlketts und mit
Preisschild auf dem Artikei. Bei
Umtausch bitte den Kassenbon mitbringen.
Artikel können nur in der Originai-
Verpackung umgetauscht oder zurück-
gegeben warden, Bei Kundenrekiamarienen
bitte den Kassenbon mitbringen.

BIN
bons/20140614-SOliver.pdf Normal file

Binary file not shown.

View File

@@ -0,0 +1,54 @@
3.901101
5.01 Iver Bernd Freier GmbH E Co. KG
Store 2059 Beriin Mexa
Grunerstraise 20 - 10179 Berlin
Te! . - 030-84712298-0
.: DE811253614
Berater: 99. 999
Art/EAN 4054872079004
Bermuda 49,99 1
Große G4 Farbe SW8
Summe 49,99
Kartenzahiung EUR 49,99
s.0Hver Seriin Alexa
Gruruarstr. 20
10179 Ber] in
Kartenzahi ung
gi recard
Datum: 14.06.2014 Zeit: 17:21-46
Terminal -Nr. 1 54046040
Transaktv ons—Nr . z 129317
Beleg: 8490
Betrag: EUR 49,99
Kante-Nr. : mwmmummmnaao
KID: 810722
AID-Par : 0100000002
Zahlung erfoigt
Steuer mkiusiv: brutto MwSt netto
1 19,00 X von 49,99 7,98 42,01
Datum Uhrzeit i-iiiai Pas Bed Transak
1406.14_17:22 12069 1 DePo
Vielen Dank Fur Ihren Einkauf,
Umtausch innerhalb von 14 Tagen,
fur VIP Kunden 4 Wochen
nur mit Kassenbon und
Ware im Originalzustand.
l\|\\\\l\\\l\l\\|\ll|llll\lllllllllllllllllllllllllllllllllllfll
9000010000001 2 4
66000206 72014061417 1 2

BIN
perso/geburtsurkunde.pdf Normal file

Binary file not shown.

View File

@@ -0,0 +1,45 @@
DEUTSCHE DEMOKRATISCHE REPUBLIK
Geburtsurkunde
smdem,“ chwe d: (Ode r)
"Fe lix____Ax.e 1 S tubbe männliche n Ge s chle chts u
ist am
Schwe d1; (Ode
geboren.
s1x¢m:....S_G<%.§. He
_Axe l Stubbe .
Vermerke: keine -
?W@W—lE4 017 ä’ L1 ~13
lcneil-NLJOOIO VVSptemberg (37/11) mos A3310/87/DDRI615

Binary file not shown.

View File

Binary file not shown.

View File

@@ -0,0 +1,64 @@
m=_...8...m= E. §mm8_.-mn=&:E SSH
Genua? „.2. MN N N Q \\
\§\n
%.N\l.
mEn_¢=S=
§m=S_.>=
x.
<9m:Nm=n_m>. mam w:._E=mmm:mmn::$mm
Emäar 32.8!
fiat... T...» „i6: N Pam. m. $.:..m
H. mmBmm8n N mmammnmn w. mmammaw Kr mmEmm8., Eu
~A==.u_mx =<E..<E.z...»==n
zaroafia O_.==n=mmm= . mama» E5 mwmääm 53m
. Onzunmmmmn „.2
:o„...„2.=2.:2..=..„
<m..:m„...:mw...n::.:m„ . z„„.._..„._;=....„2„amsa . E9955: moan
%o==.=:.E.wm:.o=m. Ea zwang. . wzxm ...
.Hmn_..=o_o ä... . ..._..o..a=<„ Z£N~mnr=o_am.m
m . 23%
_€aaE=s:o=mmsaH
>33 .E_m:_m:_8.=Emxm N..<2.mm.w.a= E... manifim . monsam Etwa
_..mEm:o_2m=u. . . 9.3.? m: mämmcmzmß
. may . _=$m_..m:m Efimzis mfiaam
$52.: . 5335...... mazes.
mmn_=..__.~.,m25..=%u mE.=E= . waoamrnswammmfimun ma
.=„.=„n.„.„ä.„m.:.5 F. imam: mmfimflmu Po N
mmEmE
„An-Ein... :<_H.m=mäw=mmmn=:n
mmEEE. 2.2 Eaéea mozmmmnrlnmsmu. E.o_.m_:mm=:=m_. ma
Emraaa E/:Am Zmfiimaamfliwmou
mmnaumn 2.2 m_.mrEE:_
_Swm»m_.m_.um: 2%.. mo
:.E:mEm Bw:._EE

Binary file not shown.

View File

@@ -0,0 +1,74 @@
Brandenburglsche
. . . .. Verteuerz Bl 1 (wen's) zururk zum Prüfungsamt
Technische Umversltat aw 2 (gelb) verhlexbl bexm mm
Bl 3 (pm) vermelbt beim Prüfungsamt
COttbU S 5| 4 (blau) fur den Studenten
Studiengang:
PRÜ FUNGSMELDUNG Name Vumame
zur
Ü DipIom-Vorprüfung/Bachelor
Anschnfl {in Zustellung des Bescheides hex endgflmg mchtbeslandener Prüfung
Ü Diplomprüfung/Master
Ü Diplom/BacheIor/Masterarbeit 79%": Mar~NV- \
Erste Frewersuch zur Erste Zweite Prüfungsordnung
Prüfung Notenverbesserung Wiederhclungsprüfung Wredemolungspruiung vom
Für den Prüfungszeitraum
Fach
Prüfer/Betreuer
Je, Memung enlgegengenummen am:
Datum / Unterschrift des Sludenlen l der Studenhn Die Pruvungsvorausseczungen sind erfüllt.
Prüfungsergebnis
Pmlnkol! Uberdxe mündhchaschrwlfliche Prilfung/Verteldxgung der Dimom/Bachelor/Masterarbeu (Gegensmnde, Vsrlaul, Ergebmsse m Stichworten)
Damm: e Eegmn: e Uhr Ende. e Uhr Ausgabe des Themas:
Datum
Thema der Arbem- Abgabe der Arbeit:
Datum
engl. Uberselzung:
(bei Erlurdsrms Ruckseue verwenden)
Dipbm/BacheIor/Masterarbeit
Note.
Note: 1 Gutachten
Note. 2. Gutachten
y Pmler/Gulacmer:
Elnzemolen Lie: Verleldlgung > umerscnrxwnaxum
w 1,3 sehrgul „ x , y. '
„ 2., 23 w. Gesamnnwe Pmfe"Gma°h*er" -' r e. .
' ' u z h HID m
2,7 s,u 3,3 hemedwgend "am " a m
3J 49 ausrencherm Bg|§“Ze[_
5.0 mchl ausreichend 1
Unlerschrm/Da|um
Vmsnzenuer des Prfliurvgsausschusseslflalum
_„

View File

@@ -0,0 +1,341 @@
#include "BaseMoversight.h"
namespace ubeeme {
namespace moversight {
/**
* @brief Constructor
*/
BaseMoversight::BaseMoversight() : printDebugAC(true), printDebugUC(true), printDebugDIS(true), printDebugNFD(true), printDebugMT(true), printDebugMS(true), printDebugTC(true), printDebugAPP(true), printDebugMOB(true), printDebugST(true), printDebugCT(true), printDebugUT(true), printDebugVISU(true), printDebugES(true), enableNFD(true), enableRecordStats(true) {
}
/**
* @brief Destructor
*/
BaseMoversight::~BaseMoversight() {
}
/**
* @brief Determines, if the printing debug information within the dispatcher is enabled, or not.
* @return True, if the printing is enabled, false otherwise.
*/
bool
BaseMoversight::isPrintDebugDIS() {
return printDebugDIS;
}
/**
* @brief Enables or disables the printing of the debug information within the dispatcher.
* @param value True, to enable the printing, false to disable the printing.
*/
void
BaseMoversight::setPrintDebugDIS(bool value) {
printDebugDIS = value;
}
/**
* @brief Determines, if the printing debug information within the NFD enabled, or not.
* @return True, if the printing enabled, false otherwise.
*/
bool
BaseMoversight::isPrintDebugNFD() {
return printDebugNFD;
}
/**
* @brief Enables or disables the printing of the debug information within the NFD.
* @param value True, to enable the printing, false to disable the printing.
*/
void
BaseMoversight::setPrintDebugNFD(bool value) {
printDebugNFD = value;
}
/**
* @brief Determines, if the printing debug information within the MT enabled, or not.
* @return True, if the printing enabled, false otherwise.
*/
bool
BaseMoversight::isPrintDebugMT() {
return printDebugMT;
}
/**
* @brief Enables or disables the printing of the debug information within the MT.
* @param value True, to enable the printing, false to disable the printing.
*/
void
BaseMoversight::setPrintDebugMT(bool value) {
printDebugMT = value;
}
/**
* @brief Determines, if the printing debug information within the MS enabled, or not.
* @return True, if the printing enabled, false otherwise.
*/
bool
BaseMoversight::isPrintDebugMS() {
return printDebugMS;
}
/**
* @brief Enables or disables the printing of the debug information within the MS.
* @param value True, to enable the printing, false to disable the printing.
*/
void
BaseMoversight::setPrintDebugMS(bool value) {
printDebugMS = value;
}
/**
* @brief Determines, if the printing debug information within the TC enabled, or not.
* @return True, if the printing enabled, false otherwise.
*/
bool
BaseMoversight::isPrintDebugTC() {
return printDebugTC;
}
/**
* @brief Enables or disables the printing of the debug information within the TC.
* @param value True, to enable the printing, false to disable the printing.
*/
void
BaseMoversight::setPrintDebugTC(bool value) {
printDebugTC = value;
}
/**
* @brief Determines, if the printing debug information within the MOB enabled, or not.
* @return True, if the printing enabled, false otherwise.
*/
bool
BaseMoversight::isPrintDebugMOB() {
return printDebugMOB;
}
/**
* @brief Enables or disables the printing of the debug information within the MOB.
* @param value True, to enable the printing, false to disable the printing.
*/
void
BaseMoversight::setPrintDebugMOB(bool value) {
printDebugMOB = value;
}
/**
* @brief Determines, if the printing debug information within the ST enabled, or not.
* @return True, if the printing enabled, false otherwise.
*/
bool
BaseMoversight::isPrintDebugST() {
return printDebugST;
}
/**
* @brief Enables or disables the printing of the debug information within the ST.
* @param value True, to enable the printing, false to disable the printing.
*/
void
BaseMoversight::setPrintDebugST(bool value) {
printDebugST = value;
}
/**
* @brief Determines, if the printing debug information within the CT enabled, or not.
* @return True, if the printing enabled, false otherwise.
*/
bool
BaseMoversight::isPrintDebugCT() {
return printDebugCT;
}
/**
* @brief Enables or disables the printing of the debug information within the CT.
* @param value True, to enable the printing, false to disable the printing.
*/
void
BaseMoversight::setPrintDebugCT(bool value) {
printDebugCT = value;
}
/**
* @brief Determines, if the printing debug information within the UT enabled, or not.
* @return True, if the printing enabled, false otherwise.
*/
bool
BaseMoversight::isPrintDebugUT() {
return printDebugUT;
}
/**
* @brief Enables or disables the printing of the debug information within the UT.
* @param value True, to enable the printing, false to disable the printing.
*/
void
BaseMoversight::setPrintDebugUT(bool value) {
printDebugUT = value;
}
/**
* @brief Determines, if the printing debug information within the APP enabled, or not.
* @return True, if the printing enabled, false otherwise.
*/
bool
BaseMoversight::isPrintDebugAPP() {
return printDebugAPP;
}
/**
* @brief Enables or disables the printing of the debug information within the APP.
* @param value True, to enable the printing, false to disable the printing.
*/
void
BaseMoversight::setPrintDebugAPP(bool value) {
printDebugAPP = value;
}
/**
* @brief Determines, if printing debug information within the visualization module is enabled, or not.
* @return True, if printing is enabled, false otherwise.
*/
bool
BaseMoversight::isPrintDebugVISU() {
return printDebugVISU;
}
/**
* @brief Enables or disables printing of debug information within the visualization module.
* @param value True, to enable printing, false to disable printing.
*/
void
BaseMoversight::setPrintDebugVISU(bool value) {
printDebugVISU = value;
}
/**
* @brief Determines, if printing debug information within the event system is enabled, or not.
* @return True, if printing enabled, false otherwise.
*/
bool
BaseMoversight::isPrintDebugES() {
return printDebugES;
}
/**
* @brief Enables or disables printing of debug information within the event system.
* @param value True, to enable printing, false to disable printing.
*/
void
BaseMoversight::setPrintDebugES(bool value) {
printDebugES = value;
}
/**
* @brief Determines, if printing debug information within the UbeemeConnector is enabled, or not.
* @return True, if printing enabled, false otherwise.
*/
bool
BaseMoversight::isPrintDebugUC() {
return printDebugUC;
}
/**
* @brief Enables or disables printing of debug information within the UbeemeConnector.
* @param value True, to enable printing, false to disable printing.
*/
void
BaseMoversight::setPrintDebugUC( bool value) {
printDebugUC = value;
}
/**
* @brief Determines, if printing debug information within the ApplicationConnector is enabled, or not.
* @return True, if printing enabled, false otherwise.
*/
bool
BaseMoversight::isPrintDebugAC() {
return printDebugAC;
}
/**
* @brief Enables or disables printing of debug information within the ApplicationConnector.
* @param value True, to enable printing, false to disable printing.
*/
void
BaseMoversight::setPrintDebugAC( bool value) {
printDebugAC = value;
}
/**
* @brief Determines, if the NFD enabled, or not.
* @return True, if the NFD enabled, false otherwise.
*/
bool
BaseMoversight::isNFDEnabled() {
return enableNFD;
}
/**
* @brief Enables or disables the NFD.
* @param value True to enable, false to disable the service.
*/
void
BaseMoversight::setNFDEnabled(bool value) {
enableNFD = value;
}
/**
* @brief Determines, if the statistic recording is enabled.
* @return True, if the recording enabled, FALSE otherwise.
*/
bool
BaseMoversight::isRecordStats() const {
return enableRecordStats;
}
/**
* @brief Enables or disables the statistic recording.
* @param enableRecordStats True for enable, FALSE otherwise.
*/
void
BaseMoversight::setRecordStats(bool enableRecordStats) {
this->enableRecordStats = enableRecordStats;
}
/**
* @brief Assignment operator.
* @param other The instance to assign.
* @return A reference of the current object.
*/
BaseMoversight & BaseMoversight::operator =(BaseMoversight const & other) {
if (this == &other) {
return *this;
}
printDebugAC = other.printDebugAC;
printDebugUC = other.printDebugUC;
printDebugDIS = other.printDebugDIS;
printDebugNFD = other.printDebugNFD;
printDebugMT = other.printDebugMT;
printDebugMS = other.printDebugMS;
printDebugTC = other.printDebugTC;
printDebugAPP = other.printDebugAPP;
printDebugMOB = other.printDebugMOB;
printDebugST = other.printDebugST;
printDebugCT = other.printDebugCT;
printDebugUT = other.printDebugUT;
printDebugVISU = other.printDebugVISU;
printDebugES = other.printDebugES;
enableNFD = other.enableNFD;
enableRecordStats = other.enableRecordStats;
return *this;
}
}
}

View File

@@ -0,0 +1,109 @@
#pragma once
#ifndef BASEMOVERSIGHT_H
#define BASEMOVERSIGHT_H
#include "common/Defines.h"
#include "common/transport/TransportAddress.h"
#include "app/PeerDescription.h"
#if UBEEME
#include "core/network/network_message.h"
#endif
namespace ubeeme {
namespace moversight {
/**
* @defgroup Moversight Moversight
* @brief Defines the base interface for the Moversight protocol.
* @class BaseMoversight
* @author Jan Gäbler
*
* The Moversight group communication protocol.
*/
class BaseMoversight {
public:
virtual TransportAddress & getLocalAddress() = 0;
bool isPrintDebugDIS();
void setPrintDebugDIS(bool value);
bool isPrintDebugNFD();
void setPrintDebugNFD(bool value);
bool isPrintDebugMT();
void setPrintDebugMT(bool value);
bool isPrintDebugMS();
void setPrintDebugMS(bool value);
bool isPrintDebugTC();
void setPrintDebugTC(bool value);
bool isPrintDebugST();
void setPrintDebugST(bool value);
bool isPrintDebugMOB();
void setPrintDebugMOB(bool value);
bool isPrintDebugCT();
void setPrintDebugCT(bool value);
bool isPrintDebugUT();
void setPrintDebugUT(bool value);
bool isPrintDebugAPP();
void setPrintDebugAPP(bool value);
bool isPrintDebugVISU();
void setPrintDebugVISU(bool value);
bool isPrintDebugES();
void setPrintDebugES(bool value);
bool isPrintDebugUC();
void setPrintDebugUC(bool value);
bool isPrintDebugAC();
void setPrintDebugAC(bool value);
bool isNFDEnabled();
void setNFDEnabled(bool value);
bool isRecordStats() const;
void setRecordStats(bool enableRecordStats);
BaseMoversight & operator =(BaseMoversight const & other);
protected:
BaseMoversight();
virtual ~BaseMoversight();
private:
bool printDebugAC;
bool printDebugUC;
bool printDebugDIS;
bool printDebugNFD;
bool printDebugMT;
bool printDebugMS;
bool printDebugTC;
bool printDebugAPP;
bool printDebugMOB;
bool printDebugST;
bool printDebugCT;
bool printDebugUT;
bool printDebugVISU;
bool printDebugES;
bool enableNFD;
bool enableRecordStats;
};
}
}
#endif // BASEMOVERSIGHT_H

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,272 @@
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see http://www.gnu.org/licenses/.
//
/*
* File: Dispatcher.h
* Author: jgaebler
*
* Created on September 20, 2010, 1:30 PM
*/
#pragma once
#ifndef DISPATCHER_H
#define DISPATCHER_H
#include "ct/CausalTransfer.h"
#include "common/UbeemeConnector.h"
#include "common/transport/TransportAddress.h"
#include "common/transport/MoversightMessageQueue.h"
#include "common/validator/MessageValidatorType.h"
#include "event/EventService.h"
#include "event/ObjectListener.h"
#include "merge/MergeService.h"
#include "mob/MobilitySupport.h"
#include "mrs/MaintanceRoleService.h"
#include "mrs/metric/MaintanceMomentMetricTypes.h"
#include "mrs/sync/NextViewBuffer.h"
#include "ms/placingstrategy/PeerPlacingStrategyType.h"
#include "ms/MembershipService.h"
#include "ms/Invitation.h"
#include "mt/MessageTransfer.h"
#include "fd/FailureDetector.h"
#include "rvd/ResourceValueDistributor.h"
#include "simutils/logger/MemberRegisterLogger.h"
#include "split/SplitService.h"
#include "st/StreamTransfer.h"
#include "ts/TimeService.h"
#include "ut/UnicastTransfer.h"
#if UBEEME
#include "core/event/event_container.h"
#include "core/event/event_sender.h"
class GroupMessage;
#endif
namespace ubeeme {
namespace moversight {
class MessageValidator;
class Moversight;
class Application;
class Peer;
class PeerResources;
class Roster;
class NetworkFailureDetector;
/**
* @brief Implements the dispatcher of the Moversight protocol.
* @class Dispatcher
* @ingroup Moversight
* @author Jan Gäbler, Robert Noack
*/
#if OMNETPP
class Dispatcher : public ObjectListener {
#else
class Dispatcher : public EventSender {
#endif
public:
Dispatcher(Moversight & aModule, Application & app);
virtual ~Dispatcher();
virtual void initialise();
virtual void handleMessage(MoversightMessage *msg);
void handleSavedMessages();
// ----------------------------------------------------------------
// API Methods
// ----------------------------------------------------------------
void sendMessage(MulticastMessage& msg); // @NOTE used by several services.
void sendMessage(StreamMessage& msg);
void invitePeer(TransportAddress & ta, PeerDescription & pDesc);
void cancelInvitation(TransportAddress & ta, std::string reason);
void acceptInvitation(const Invitation & inv, const std::string & comment, const PeerDescription & pDesc, const PeerResources & resource);
void rejectInvitation(const Invitation & inv, const std::string & reason);
void leaveGroup();
void splitGroup(unsigned char options, PeerIDList splitPeers);
void mergeGroup(TransportAddress & destTa);
void acceptGroupMerge();
void rejectGroupMerge(std::string & reason);
Peer & getLocalPeer();
TransportAddress getLocalAddressFromPeer(PeerID pId);
const State & getLocalState() const;
const SubState & getLocalSubState() const;
const StateOperation & getLocalStateOperation() const;
void setLocalPeerResources(const PeerResources & pres);
const PeerResources & getLocalPeerResources() const;
ViewID getViewID() const;
// ----------------------------------------------------------------
// Object Delivery System
// ----------------------------------------------------------------
template<typename ObjType>
void subscribe(ObjectListener * ol);
template<typename ObjType>
void unsubscribe(ObjectListener * ol);
void unsubscribeAll(ObjectListener * ol);
void signal(DeliverableObject* e, ObjectListener* recipient = NULL);
// Event Handling
void handleEvent(const GroupClosedEvent & e);
void handleEvent(const FlushDoneEvent & e);
//-----------------------------------------------------------------
// Event signals from other Ubeeme components
//-----------------------------------------------------------------
void signalConnectionLost();
void signalConnectionReEstablished();
// ----------------------------------------------------------------
Application & getMoversightCallback();
const Application & getMoversightCallback() const;
Moversight & getMoversight();
const Moversight & getMoversight() const;
MembershipService & getMembershipService();
const MembershipService & getMembershipService() const;
EventService & getEventService();
const EventService & getEventService() const;
FailureDetector & getFailureDetector();
const FailureDetector & getFailureDetector() const;
NetworkFailureDetector & getNetworkFailureDetector();
const NetworkFailureDetector & getNetworkFailureDetector() const;
MobilitySupport & getMobilitySupport();
const MobilitySupport & getMobilitySupport() const;
TimeService & getTimeService();
const TimeService & getTimeService() const;
MergeService & getMergeService();
const MergeService & getMergeService() const;
SplitService & getSplitService();
const SplitService & getSplitService() const;
CausalTransfer & getCausalTransfer();
const CausalTransfer & getCausalTransfer() const;
StreamTransfer & getStreamTransfer();
const StreamTransfer & getStreamTransfer() const;
UnicastTransfer & getUnicastTransfer();
const UnicastTransfer & getUnicastTransfer() const;
MessageTransfer & getMessageTransfer();
const MessageTransfer & getMessageTransfer() const;
MaintenanceRoleService & getMaintenanceRoleService();
const MaintenanceRoleService & getMaintenanceRoleService() const;
ResourceValueDistributor & getResourceValueDistributor();
const ResourceValueDistributor & getResourceValueDistributor() const;
NextViewBuffer & getNextViewBuffer();
const NextViewBuffer & getNextViewBuffer() const;
size_t getGroupSize() const;
const PeerPlacingStrategyType & getPeerPlacingStrategyType() const;
const PeerPlacingStrategyMetricType & getPeerPlacingStrategyMetricType() const;
const MaintanceMomentMetricType & getMaintanceMomentMetricType() const;
void setStandardMessageValidator();
void setMessageValidator(MessageValidatorType type);
const MessageValidator * getMessageValidator() const;
void setupGroupFromRoster(Roster & roster, PeerID localPeerID);
Dispatcher & operator = (Dispatcher const & other);
private:
virtual void finalise();
Application & app;
Moversight & module;
MembershipService ms;
EventService es;
CausalTransfer ct;
StreamTransfer st;
UnicastTransfer ut;
MessageTransfer mt;
FailureDetector fd;
MobilitySupport mob;
MergeService merge;
SplitService split;
TimeService ts;
MaintenanceRoleService mrs;
ResourceValueDistributor rvd;
NextViewBuffer nvb;
UbeemeConnector uc;
MessageValidator * messageValidator;
// MoversightMessageQueue tempMessageQueue;
MemberRegisterLogger logMemberRegister;
};
/**
* @brief Subscribe for a certain type of object.
*
* This will add <ObjType> as a key value to <subscriptions>, if not
* already present. <ms> will be inserted in the object's subscriber list.
* To subscribe to multiple objects, you have to call <subscribe()>
* subsequently.
*
* @tparam ObjType Type of object to subscribe to.
* @param ms The Moversight service which is subscribing to the object.
*/
template<typename ObjType>
void
Dispatcher::subscribe(ObjectListener * ol) {
es.subscribe(ol, typeid(ObjType*).name());
}
/**
* @brief Unsubscribe from a certain type of object.
*
* The service will be removed from the object's list of subscribers.
* To unsubscribe from multiple objects you have to use subsequent calls
* to <unsubscribe()>.
*
* @tparam ObjType Type of object to unsubscribe from.
* @param ms The Moversight service to unsubscribe.
*/
template<typename ObjType>
void
Dispatcher::unsubscribe(ObjectListener * ol) {
es.unsubscribe(ol, typeid(ObjType*).name());
}
}
}
#endif /* DISPATCHER_H */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,766 @@
/*
* File: Moversight.cc
* Author: jgaebler
*
* Created on September 20, 2010, 1:30 PM
*/
#include "Moversight.h"
#include "Dispatcher.h"
#include "common/transport/MoversightMessageTypes.h"
#include "common/transport/TransportAddress.h"
#include "common/transport/msg/ExteriorMessage.h"
#include "common/validator/MessageValidator.h"
#include "ms/Peer.h"
#include "ms/msg/MSMessageFactory.h"
#include "mt/timer/MTTimer.h"
#include "mt/msg/MulticastMessage.h"
#include "fd/NetworkFailureDetectorType.h"
#if OMNETPP
#include "app/Application.h"
#include "app/ApplicationLevelMulticastTestApplication.h"
#include "app/MergeApplication.h"
#include "app/PeerplacingApplication.h"
#include "app/SplitApplication.h"
#include "app/TestApplication.h"
#include "app/PartitionApplication.h"
#include "app/PendingTestApplication.h"
#include "app/MaintanceApplication.h"
//omnet address related stuff
#include "IPvXAddressResolver.h"
#include "UDPControlInfo.h"
#include "InterfaceEntry.h"
#include "IInterfaceTable.h"
#include "IPvXAddress.h"
#include "IPv4InterfaceData.h"
#include "mobility/models/MovingMobilityBase.h"
#include "mobility/models/StationaryMobility.h"
#endif
namespace ubeeme {
namespace moversight {
#if OMNETPP
#define simulationTriggerTimeout 10
/**
* @brief Declares Moversight as omnetpp module.
*/
Define_Module(Moversight);
#else
Moversight::Moversight(MoversightCallback & callBack) : UDPNodeEventReceiver(0, false), infoObject(NULL), dispatcher(*this, callBack) {
#if 0
bool printDebugDIS;
bool printDebugNFD;
bool printDebugMT;
bool printDebugMS;
bool printDebugTC;
bool printDebugST;
bool printDebugCT;
bool printDebugAPP;
bool enableNFD;
bool enableMobilitySupport = default(true);
bool enableNetworkFailureDetector = default(true);
bool enableStreamTransfer = default(true);
#endif
setNFDEnabled(false);
initialize(0);
}
Moversight::~Moversight() {
}//End
#endif
/**
* @brief Returns the local address.
* @return The local address.
*/
TransportAddress &
Moversight::getLocalAddress() {
#if UBEEME
bool success = false;
if (infoObject.isNull()) {
success = initNetworkInfos();
}
if (success) {
PhysicalNetworkInterface::AddressEntryList addressList = infoObject->addressList;
PhysicalNetworkInterface::AddressEntryList::iterator it = addressList.begin();
if (it != addressList.end()) {
if (it->ip().protocol() == QAbstractSocket::IPv4Protocol) {
MOV_DEBUG << "Local: " << it->ip().toString();
localTA = TransportAddress(it->ip(), infoObject->boundPort);
}
}//End if
}
else {
localTA = TransportAddress();
}
#endif
return localTA;
}
#if OMNETPP
/**
* @brief Sets the local transport address of the current host
*/
void
Moversight::setLocalAddress() {
cModule *mod = getParentModule(); // get the MoversightPeer
IInterfaceTable* ift = IPvXAddressResolver().findInterfaceTableOf(mod);
//set the local address
if (ift && ift->getNumInterfaces() > 1) { //interface index 0 == loopback
InterfaceEntry *ie = ift->getInterface(1);
localTA = TransportAddress(ie->ipv4Data()->getIPAddress());
}
else {
localTA = TransportAddress();
}
//set the port
localTA.setPort(int(par("localPort")));
}
#endif
/**
* @brief Initialize the Moversight instance
*/
void
Moversight::initialize(int stage) {
#if OMNETPP
if (stage != 3) return;
setLocalAddress();
app = NULL;
visu = NULL;
dispatcher = NULL;
simulationTrigger = NULL;
//set Socket
socket.setOutputGate(gate("udpOut"));
socket.bind(localTA.getPort());
//read the simulation parameter and setup the module
peerPlacingStrategyType = PeerPlacingStrategyType(int (par("peerPlacingStrategy")));
peerPlacingStrategyMetricType = PeerPlacingStrategyMetricType(int (par("peerPlacingStrategyMetric")));
maintanceMomentMetricType = MaintanceMomentMetricType((int) (par("maintanceMomentMetricType")));
failureDetectorType = NetworkFailureDetectorType(int (par("failureDetectorType")));
peerResourcesValue = PeerResources(PeerResources::ResourceValue(par("peerResourceValue")));
//read max cluster
maxClusterCount = int(par("maxClusterCount"));
maxPeerCount = int(par("maxPeerCount"));
// // wireless Nodes register in category we want to listen with
// if (getParentModule()->getSubmodule("wlan", 0)) {
// notificationBoard = dynamic_cast<NotificationBoard *> (getParentModule()->getSubmodule("notificationBoard"));
// if (!notificationBoard)
// std::cerr << "Could not find NotificationBoard module with name 'notificationBoard' " << getParentModule() << endl;
// else {
// //categories we are interested in
// notificationBoard->subscribe(this, NF_L2_ASSOCIATED_NEWAP);
// notificationBoard->subscribe(this, NF_L2_BEACON_LOST);
// }
// }
app = NULL;
//load the proper test app
switch (int(par("testApp"))) {
case SPLIT_TEST_APPLICATION:
app = new SplitApplication(*this);
break;
case NFD_TEST_APPLICATION:
throw ParameterException("initialize - set up NFD_TEST_APPLICATION not implemented yet");
break;
case PEER_PLACING_TEST_APPLICATION:
app = new PeerplacingApplication(*this);
break;
case TEST_APPLICATION:
app = new TestApplication(*this);
break;
case MERGE_TEST_APPLICATION:
app = new MergeApplication(*this);
break;
case ALM_TEST_APPLICATION:
app = new ApplicationLevelMulticastTestApplication(*this);
break;
case PARTITION_APPLICATION:
app = new PartitionApplication(*this);
break;
case PENDING_TEST_APPLICATION:
app = new PendingTestApplication(*this);
break;
case MAINTANCE_APPLICATION:
app = new MaintanceApplication(*this);
break;
default:
throw ParameterException("initialize - no valid value for parameter \"application\" specified");
break;
}//end switch
enableRecordStats = par("recordStat").boolValue();
if(enableRecordStats){
numMessagesReceived = 0;
numMessagesSent = 0;;
}//end if
setNFDEnabled(par("enableNFD").boolValue());
//initialize print debug parameter
setPrintDebugAPP(par("printDebugAPP").boolValue());
setPrintDebugDIS(par("printDebugDIS").boolValue());
setPrintDebugNFD(par("printDebugNFD").boolValue());
setPrintDebugMT(par("printDebugMT").boolValue());
setPrintDebugMS(par("printDebugMS").boolValue());
setPrintDebugTC(par("printDebugTC").boolValue());
setPrintDebugST(par("printDebugST").boolValue());
setPrintDebugCT(par("printDebugCT").boolValue());
setPrintDebugUT(par("printDebugUT").boolValue());
setPrintDebugMOB(par("printDebugMOB").boolValue());
setPrintDebugVISU(par("printDebugVISU").boolValue());
setPrintDebugES(par("printDebugES").boolValue());
setPrintDebugUC(par("printDebugUC").boolValue());
setPrintDebugAC(par("printDebugAC").boolValue());
//start moversight
dispatcher = new Dispatcher(*this, *app);
//initialize the test application
app->setDispatcher(dispatcher);
app->initialise();
dispatcher->initialise();
simulationTrigger = new cMessage("simulationTrigger");
if (par("simulationTrigger").boolValue()) {
scheduleAt(simTime() + simulationTriggerTimeout, simulationTrigger);
}//End if
//start the visualization
visu = new MoversightSimulationPeerStateVisualization(*dispatcher);
visu->initialise();
updateSimUI();
#else
stage = stage;
//set up the peerplacing stuff
peerPlacingStrategyType = BALANCED_PEER_PLACING;
peerPlacingStrategyMetricType = OUCMETRIC_CLUSTERSIZE;
maintanceMomentMetricType = RESOURCEVALUEMOMENTMETRIC;
failureDetectorType = BERTIER_DETECTOR;
maxClusterCount = 12;
maxPeerCount = 6;
// setLocalAddress();
dispatcher.initialise();
#endif
}//End initialize
/**
* @brief Finish method. Is called during shutdown of moversight.
*/
void
Moversight::finish() {
#if OMNETPP
if(enableRecordStats){
recordScalar("messages_sent:count", numMessagesSent);
recordScalar("messages_received:count", numMessagesReceived);
}//End if
if (app != NULL) {
app->finalise();
delete app;
app = NULL;
}//End if
if (visu != NULL) {
delete visu;
visu = NULL;
}//End if
if (dispatcher != NULL) {
delete dispatcher;
dispatcher = NULL;
}//End if
if (simulationTrigger != NULL) {
cancelAndDelete(simulationTrigger);
simulationTrigger = NULL;
}//end if
#endif
}
#if OMNETPP
/**
* @brief Handles received messages (from the socket) and timers.
* @param msg The received message to handle.
*/
void
Moversight::handleMessage(cMessage *msg) {
// timer handling
if (msg->isSelfMessage()) {
cancelEvent(msg);
if (msg == simulationTrigger) {
handleSimulationTriggerTimer();
}//End if
else if (dynamic_cast<MoversightTimer *> (msg)) {
MoversightTimer* timer = dynamic_cast<MoversightTimer*> (msg);
timer->fire();
dispatcher->getEventService().process();
}//End else if
}//End if
// not a timer
else {
if(enableRecordStats) numMessagesReceived++;
MoversightMessage * mMsg = dynamic_cast<MoversightMessage *> (msg);
if (mMsg != NULL) {
GenericTime arrivalTime = GenericTime::currentTime();
mMsg->setArrivalTime(arrivalTime);
dispatcher->handleMessage(mMsg);
delete msg;
msg = NULL;
}
else {
MOV_DEBUG << "ERROR: handleMessage - unknown message type - drop message";
}
}//End else
}
/**
* @brief test code method
*/
void
Moversight::handleSimulationTriggerTimer() {
if (app != NULL) {
app->startTestCase(int(par("testCase")));
}
}
/**
* @brief This method updates the presentation of a peer within the omnett++ visualization. In particular, the
* icon of the peer is change depending on the role of the peer (master or slave).
*/
void
Moversight::updateSimUI() {
if (visu != NULL) {
visu->updateSimUI();
}
}
/**
* @brief Displays a message bubble at the omnet sim ui.
* @param msg
*/
void
Moversight::bubble(const char* msg) {
getParentModule()->bubble(msg);
}
/**
* @brief Schedules the simulation trigger timer.
* @param time The duration to the determined schedule.
*/
void
Moversight::scheduleTestCase(simtime_t time) {
cancelEvent(simulationTrigger);
scheduleAt((simTime() + time), simulationTrigger);
}
/**
* @brief receive notifications from notificationBoard
* @param category to identifiy the matter of changed Notification
*/
void
Moversight::receiveChangeNotification(int category, const cPolymorphic *details) {
switch (category) {
case NF_L2_ASSOCIATED_NEWAP:
std::cerr << dispatcher->getLocalPeer().getPeerID() << " Connection to an AP established " << endl;
//connectionEstablished();
break;
case NF_L2_BEACON_LOST:
std::cerr << dispatcher->getLocalPeer().getPeerID() << " Connection to an AP lost" << endl;
// dispatcher.signalConnectionLost();
break;
}
}
#endif
/**
* @brief Returns the user selected peer placing strategy type.
* @see PeerPlacingStrategy.h
* @return The selected strategy type.
*/
const PeerPlacingStrategyType &
Moversight::getPeerPlacingStrategyType() const {
return peerPlacingStrategyType;
}
const PeerPlacingStrategyMetricType &
Moversight::getPeerPlacingStrategyMetricType() const {
return peerPlacingStrategyMetricType;
}
const MaintanceMomentMetricType &
Moversight::getMaintanceMomentMetricType() const {
return maintanceMomentMetricType;
}
const PeerResources &
Moversight::getPeerResources() const {
return peerResourcesValue;
}
/**
* @brief Returns the user selected failure detector type.
* @see FailureDetectorType.h
* @return The selected failure detector type.
*/
const NetworkFailureDetectorType &
Moversight::getFailureDetectorType() const {
return failureDetectorType;
}
/**
* @brief Returns the maximal number of clusters
* @return number of clusters
*/
size_t
Moversight::getMaxClusterCount() {
return maxClusterCount;
}
/**
* @brief Returns the maximal number of peers in one cluster
* @return number of peers
*/
size_t
Moversight::getMaxPeerCount() {
return maxPeerCount;
}
/**
* @brief Sends a omnet message to a peer, identified by its transport address
* @param msg The message to send
* @param toPeerTA The destination address
*/
void
Moversight::sendToPeer( const MoversightMessage& msg, const TransportAddress & toPeerTA) {
#if OMNETPP
if(enableRecordStats) numMessagesSent++;
sendToUDP(msg, toPeerTA);
}
#else
void
Moversight::sendToPeer(MoversightMessage & msg, const TransportAddress & toPeerTA) {
delegateSend(msg, toPeerTA);
}
#endif
#if OMNETPP
/**
* @brief Sending the Message via UDP to the given TransportAddress
* @param packet The Message to send
* @param destAddr The destination transport address of the message
*/
void
Moversight::sendToUDP( const MoversightMessage& packet, const TransportAddress& destAddr) {
cPacket* msg = (cPacket *) packet.dup(); //without -> no local deletion of send message
// send message to UDP, with the appropriate control info attached
msg->setKind(UDP_C_DATA);
msg->setByteLength(sizeof packet);
socket.sendTo(msg, destAddr.getHostAddress(), destAddr.getPort());
}
#endif
/**
* @brief Assignment operator.
* @param other The instance to assign.
* @return A reference of the current object.
*/
Moversight & Moversight::operator =(Moversight const & other) {
if (this == &other) {
return *this;
}
BaseMoversight::operator=(other);
dispatcher = other.dispatcher;
#if OMNETPP
simulationTrigger = other.simulationTrigger;
app = other.app;
numMessagesReceived = other.numMessagesReceived;
numMessagesSent = other.numMessagesSent;
maxClusterCount = other.maxClusterCount;
maxPeerCount = other.maxPeerCount;
enableRecordStats = other.enableRecordStats;
socket = other.socket;
#endif
peerPlacingStrategyType = other.peerPlacingStrategyType;
peerPlacingStrategyMetricType = other.peerPlacingStrategyMetricType;
maintanceMomentMetricType = other.maintanceMomentMetricType;
failureDetectorType = other.failureDetectorType;
return *this;
}//End
#if UBEEME
/**
* @brief Delegates the data to the receiver
* @param buffer ByteArray of data
* @param from PeerID from the sender
*/
void
Moversight::delegateReceive(ByteArray const &buffer, PeerID const &from) {
DatagramInput<PeerID>::delegateReceive(buffer, from);
}
/**
* @brief Chains the given DatagramInput to this DatagramOutput. So it can be used for delegating.
* @param input Input to chain.
*/
void
Moversight::chainDown(DatagramInput<TransportAddress> *input) {
DatagramOutput<TransportAddress>::chainDown(input);
if (!initNetworkInfos()) {
MOV_DEBUG << "Cannot init network informations.";
}
dispatcher.initialise();
}
/**
* @brief Unchains the given input from this DatagramOutput.
* @param input Input to unchain.
*/
void
Moversight::unchainDown(DatagramInput<TransportAddress> *input) {
DatagramOutput<TransportAddress>::unchainDown(input);
infoObject.clear();
disconnectReceiver();
}
bool
Moversight::initNetworkInfos() {
DatagramInput<TransportAddress> *input = 0;
if (!inputList.empty()) {
input = inputList.front();
}
if (input && infoObject.isNull()) {
typedef std::list<QSharedPointer<UDPInfoObject> > UDPInfoObjectList;
UDPInfoObjectList objectList;
UDPInfoObjectList::iterator it;
UDPEndpoint *currentUDPEndpoint = 0;
InformationBroker::getInstance()->getInformationObjectList(objectList);
for (it = objectList.begin(); it != objectList.end(); ++it) {
currentUDPEndpoint = (*it)->getOwner();
if (input == currentUDPEndpoint || input->hasInputNodeInChain(currentUDPEndpoint)) {
infoObject = *it;
connectReceiver(currentUDPEndpoint);
connectAll();
return true;
}
}
}
return false;
}
/**
* @brief
* @param e The EventContainer
*/
void
Moversight::stateChanged(EventContainer e) {
UDPStateChangedEvent *changed = e.decapsulate<UDPStateChangedEvent > ();
if (changed) {
if (changed->getUDPState() == ubeeme::UDPEndpoint::UNCONNECTED_STATE) {
MOV_DEBUG << "UDP unconnected, delete information object.";
infoObject.clear();
disconnectReceiver();
initNetworkInfos();
}
dispatcher.initialise();
}
}
/**
* @brief Method checks whether the given DatagramInput is situated under the chain.
* Therefor bool NetworkOutput::hasNodeInChain(NETWORK_INPUT const *input) const is called.
* In case it's a DatagramOutput
*
* @param input searched DatagramInput
* @return if the DatagramInput searched for is below us
*/
bool
Moversight::hasInputNodeInChain(DatagramInput<PeerID> const * /*input*/) const {
return false;
}//End
/**
* @brief This is the callback, that gets called when the down linked node received data and forwards those to us.
* @param buffer all the received data
* @param from - sender of the data
* @param fromInput - reference to the linked node, from whom we got the data (can be ignored in most cases)
*/
void
Moversight::handleReceive(ByteArray const &buffer, TransportAddress const &from, DatagramInput<TransportAddress> const * /*fromInput*/) {
SharedPointer<NetworkMessage> received = factory.NetworkMessageFactory::createMessage(buffer, from);
if (!received.isNull()) {
dispatcher.handleMessage((MoversightMessage *) received.data());
}
}
/**
* @brief this is the callback, that gets called when the up linked node wants to send data to us
* @param buffer - the data to be send
* @param to - the receiver of the data
* @param fromOutput - reference to the linked node that wants to send the data to us (can be ignored in most cases)
* @return - true on successfull sending, otherwise false.
*/
bool
Moversight::handleSend(ByteArray const &buffer, PeerID const &/*to = 0*/, DatagramOutput<PeerID> const * /*fromOutput = 0 */) {
GroupData data; //("DT");
data.setData(buffer);
dispatcher.sendMessage(data);
return true;
}
/**
* @brief Invite a peer to the group
* @param destTa The transportAddress of the peer to invite
* @param pDesc the peerDescription
*/
void
Moversight::invitePeer(TransportAddress & destTa, PeerDescription & pDesc) {
dispatcher.invitePeer(destTa, pDesc);
}//End
/**
* @brief Cancel the invitation
* @param ta The transportAddress to send the cancellation
* @param reason Why the invitation is turned down
*/
void
Moversight::cancelInvitation(TransportAddress & ta, std::string reason) {
dispatcher.cancelInvitation(ta, reason);
}
/**
* @brief Accept the Invitation
* @param inv The invitation to accept
* @param comment A comment
* @param pDesc PeerDescription
*/
void
Moversight::acceptInvitation(Invitation & inv, std::string comment, PeerDescription & pDesc) {
dispatcher.acceptInvitation(inv, comment, pDesc);
}//End
/**
* @brief Reject the invitation
* @param inv The invitation to be rejected
* @param reason Why it's rejected
*/
void
Moversight::rejectInvitation(Invitation & inv, std::string reason) {
dispatcher.rejectInvitation(inv, reason);
}
/**
* @brief Leave the group
*/
void
Moversight::leaveGroup() {
dispatcher.leaveGroup();
}//End
/**
* @brief Start a split
* @param options The split options
* @param size The number of the splitting peers
* @param splitPeers PeerIDList of the splitting peers
*/
void
Moversight::splitGroup(unsigned char options, PeerIDList splitPeers) {
dispatcher.splitGroup(options, splitPeers);
}
/**
* @brief Start a group Merge
* @param destTa The other Mergedirector
*/
void
Moversight::mergeGroup(TransportAddress & destTa) {
dispatcher.mergeGroup(destTa);
}//End
/**
* @brief Accept the merge request
*/
void
Moversight::acceptGroupMerge() {
dispatcher.acceptGroupMerge();
}
/**
* @brief Reject the merge request
* @param reason Why it's rejected
*/
void
Moversight::rejectGroupMerge(std::string & reason) {
dispatcher.rejectGroupMerge(reason);
}
#endif
}
}

View File

@@ -0,0 +1,179 @@
#pragma once
#ifndef MOVERSIGHT_H
#define MOVERSIGHT_H
/*
* File: Moversight.h
* Author: jgaebler
*
* Created on September 20, 2010, 1:30 PM
*/
#include "BaseMoversight.h"
#include "mrs/metric/MaintanceMomentMetricTypes.h"
#include "ms/placingstrategy/PeerPlacingStrategyType.h"
#include "common/transport/msg/MoversightMessage.h"
#include "fd/NetworkFailureDetectorType.h"
#if UBEEME
#include "Dispatcher.h"
#include "mt/msg/GroupData.h"
#include "app/MoversightCallback.h"
#include "common/transport/MoversightMessageFactory.h"
#include "common/Defines.h"
#include "core/network/networking_nodes/datagram_input.h"
#include "core/network/networking_nodes/datagram_output.h"
#include "core/network/udp_endpoint.h"
#include "core/network/udp_node_event_receiver.h"
#include "core/network/udp_info_object.h"
#include "common/byte_array.h"
#include <QSharedPointer>
#else
#include "simutils/MoversightSimulationPeerStateVisualization.h"
//omnet
#include "UDPSocket.h"
#include "NotificationBoard.h"
#include "INotifiable.h"
#endif
namespace ubeeme {
namespace moversight {
class MulticastMessage;
class ExteriorMessage;
class Dispatcher;
class MoversightCallback;
class Application;
#if UBEEME
class MOV_EXPORT Moversight : public BaseMoversight, public DatagramInput<PeerID>, public DatagramOutput<TransportAddress>, public UDPNodeEventReceiver {
public:
Moversight(MoversightCallback & callBack);
~Moversight();
#else
/**
* @brief Base OMNeT++ Module for Moversight.
* @author Jan Gäbler
* @ingroup Moversight
* @class Moversight
*/
class Moversight : public BaseMoversight, public INotifiable, public cSimpleModule {
public:
void scheduleTestCase(simtime_t time);
void updateSimUI();
void bubble(const char* msg);
void receiveChangeNotification(int category, const cPolymorphic *details);
#endif
void sendToPeer( const MoversightMessage& msg, const TransportAddress& toPeerTA);
void connectionLost();
void connectionEstablished();
size_t getMaxClusterCount();
size_t getMaxPeerCount();
const PeerPlacingStrategyType & getPeerPlacingStrategyType() const;
const PeerPlacingStrategyMetricType & getPeerPlacingStrategyMetricType() const;
const MaintanceMomentMetricType & getMaintanceMomentMetricType() const;
const NetworkFailureDetectorType & getFailureDetectorType() const;
const PeerResources & getPeerResources() const;
Moversight & operator=(Moversight const & other);
virtual TransportAddress & getLocalAddress();
virtual void initialize(int stage);
#if UBEEME
//call backs
bool hasInputNodeInChain(DatagramInput<PeerID> const *input) const;
virtual void delegateReceive(ByteArray const &buffer, PeerID const &from);
/**
* @brief Chains the given DatagramInput to this DatagramOutput. So it can be used for delegating.
* @param input Input to chain.
*/
virtual void chainDown(DatagramInput<TransportAddress> *input);
/**
* @brief Unchains the given input from this DatagramOutput.
* @param input Input to unchain.
*/
virtual void unchainDown(DatagramInput<TransportAddress> *input);
virtual void stateChanged(EventContainer e);
bool handleSend(const ByteArray & buffer, PeerID const &to = 0, DatagramOutput<PeerID> const *fromOutput = 0);
void handleReceive(ByteArray const & buffer, TransportAddress const & from, DatagramInput<TransportAddress> const *fromInput);
void invitePeer(TransportAddress & ta, PeerDescription & pDesc);
void cancelInvitation(TransportAddress & ta, std::string reason);
void acceptInvitation(Invitation & inv, std::string comment, PeerDescription & pDesc);
void rejectInvitation(Invitation & inv, std::string reason);
void leaveGroup();
void splitGroup(unsigned char options, PeerIDList splitPeers);
void mergeGroup(TransportAddress & destTa);
void acceptGroupMerge();
void rejectGroupMerge(std::string & reason);
#endif
protected:
void sendToUDP( const MoversightMessage& msg, const TransportAddress & destAddr);
virtual int numInitStages() const { return 4; }
#if OMNETPP
virtual void handleMessage(cMessage *msg);
#endif
virtual void finish();
private:
void handleSimulationTriggerTimer();
void setLocalAddress();
PeerPlacingStrategyType peerPlacingStrategyType;
PeerPlacingStrategyMetricType peerPlacingStrategyMetricType;
PeerResources peerResourcesValue;
MaintanceMomentMetricType maintanceMomentMetricType;
NetworkFailureDetectorType failureDetectorType;
TransportAddress localTA;
#if UBEEME
bool initNetworkInfos();
MoversightMessageFactory factory;
QSharedPointer<UDPInfoObject> infoObject;
Dispatcher dispatcher;
#else
MoversightSimulationPeerStateVisualization * visu;
UDPSocket socket;
cMessage * simulationTrigger;
Application * app;
Dispatcher * dispatcher;
// NotificationBoard * notificationBoard;
size_t numMessagesReceived;
size_t numMessagesSent;
#endif
size_t maxClusterCount;
size_t maxPeerCount;
bool enableRecordStats;
}; //End class
}//End namespace
}//End namespace
#endif // MOVERSIGHT_H

View File

@@ -0,0 +1,50 @@
package ubeeme.moversight;
@namespace(ubeeme::moversight);
simple Moversight
{
parameters:
bool simulationTrigger = default(false);
//see ApplicationType in file Application.h
int testApp = default(0);
int testCase = default(0);
//see PeerPlacingStragyType in file PeerPlacingStrategy.h
int peerPlacingStrategy = default(0);
//see FailureDetectorType in file FailureDetectorType.h
int failureDetectorType = default(0);
bool enableNFD = default(false);
bool printDebugAC = default(true);
bool printDebugUC = default(true);
bool printDebugNFD = default(true);
bool printDebugDIS = default(true);
bool printDebugAPP = default(true);
bool printDebugMT = default(true);
bool printDebugMS = default(true);
bool printDebugTC = default(true);
bool printDebugST = default(true);
bool printDebugCT = default(true);
bool printDebugUT = default(true);
bool printDebugMOB = default(true);
bool printDebugVISU = default(true);
bool printDebugES = default(true);
bool recordStat = default(true);
int maxClusterCount = default(3);
int maxPeerCount = default(3);
int numberOfPeers = default(0);
int numberOfMobilePeers = default(0);
int localPort = default(100);
int destPort = default(100);
string destAddresses = default("");
gates:
output udpOut;
input udpIn;
}

View File

@@ -0,0 +1,80 @@
/*
* File: MoversightTimerTypes.h
* Author: jgaebler
*
* Created on February 14, 2011, 10:54 AM
*/
#pragma once
#ifndef MOVERSIGHTTIMERTYPES_H
#define MOVERSIGHTTIMERTYPES_H
#include "common/Defines.h"
namespace ubeeme {
namespace moversight {
/**
* @brief Define the general settings for a timer (number of retries and so on).
*/
enum MoversightTimerSettings {
//global setting
NUMBER_OF_MAX_RETRIES = 3,
MT_NUMBER_OF_MAX_RETRIES = NUMBER_OF_MAX_RETRIES,
FD_NUMBER_OF_MAX_RETRIES = NUMBER_OF_MAX_RETRIES,
MS_NUMBER_OF_MAX_RETRIES = NUMBER_OF_MAX_RETRIES,
PD_NUMBER_OF_MAX_RETRIES = NUMBER_OF_MAX_RETRIES,
MOB_NUMBER_OF_MAX_RETRIES = 1,
MERGE_NUMBER_OF_MAX_RETRIES = NUMBER_OF_MAX_RETRIES,
SPLIT_NUMBER_OF_MAX_RETRIES = NUMBER_OF_MAX_RETRIES
};
/**
* @brief Defines the timeout for the moversight timers.
*/
enum MoversightTimeout {
#if OMNETPP
AVERAGE_DELAY = 1,
#else
AVERAGE_DELAY = 6000,
#endif
//mt
LT_TIMEOUT = AVERAGE_DELAY,
GT_TIMEOUT = LT_TIMEOUT + (LT_TIMEOUT * MT_NUMBER_OF_MAX_RETRIES) + 1,
GT_AWAIT_TIMEOUT = GT_TIMEOUT + (GT_TIMEOUT * MT_NUMBER_OF_MAX_RETRIES) + 1,
GARBAGE_TIMEOUT = GT_AWAIT_TIMEOUT + (GT_AWAIT_TIMEOUT * MT_NUMBER_OF_MAX_RETRIES) + 1,
DT_DELIVERY_TIMEOUT = GT_AWAIT_TIMEOUT + 2,
//ms
JOIN_ABORT_TO_INVITEE_TIMEOUT = (5 * AVERAGE_DELAY),
JOIN_ANNOUNCE_TIMEOUT = DT_DELIVERY_TIMEOUT + (DT_DELIVERY_TIMEOUT * MS_NUMBER_OF_MAX_RETRIES) + 1,
JOIN_ABORT_TO_INVITER_TIMEOUT = (4 * AVERAGE_DELAY),
JOIN_ABORT_TO_INVITER_TIMEOUT_MISSING_ROSTER = JOIN_ANNOUNCE_TIMEOUT + (2 * AVERAGE_DELAY),
LEAVE_ANNOUNCE_TIMEOUT = JOIN_ANNOUNCE_TIMEOUT,
//tc
SPLIT_ABORT_TIMEOUT = DT_DELIVERY_TIMEOUT + (DT_DELIVERY_TIMEOUT * SPLIT_NUMBER_OF_MAX_RETRIES) + 1,
MERGE_REJECT_TO_INVITEE_TIMEOUT = (4 * AVERAGE_DELAY),
MERGE_ABORT_TO_INVITER_GROUP_TIMEOUT = (4 * AVERAGE_DELAY),
MERGE_ABORT_TO_INVITEE_GROUP_TIMEOUT = MERGE_ABORT_TO_INVITER_GROUP_TIMEOUT + (4 * AVERAGE_DELAY * MERGE_NUMBER_OF_MAX_RETRIES),
MERGE_ABORT_TIMEOUT = DT_DELIVERY_TIMEOUT + (DT_DELIVERY_TIMEOUT * MERGE_NUMBER_OF_MAX_RETRIES) + 1,
MERGE_ROLLBACK_TIMEOUT = MERGE_ABORT_TO_INVITER_GROUP_TIMEOUT + DT_DELIVERY_TIMEOUT + (DT_DELIVERY_TIMEOUT * MERGE_NUMBER_OF_MAX_RETRIES) + 1,
//MOB
GROUP_CLOSED_CAUSED_BY_CONNECTION_LOST_TIMEOUT = LEAVE_ANNOUNCE_TIMEOUT,
REJOIN_ROSTER_REQUEST_TIMEOUT = 1,
REJOIN_TIMEOUT = 20,
AR_TIMEOUT = 5,
//ut
UT_RETRANSMIT_TIMEOUT = DT_DELIVERY_TIMEOUT + (DT_DELIVERY_TIMEOUT * NUMBER_OF_MAX_RETRIES) + 1,
//nfd
DETECTION_TIMEOUT = 8 * AVERAGE_DELAY,
PARTITION_TIMEOUT = 2 * AVERAGE_DELAY,
ND_TIMEOUT = 2 * AVERAGE_DELAY,
//rvd
RESOURCE_VALUE_TIMEOUT = 1 * AVERAGE_DELAY
};
}
}
#endif /* MOVERSIGHTTIMERTYPES_H */

View File

@@ -0,0 +1,122 @@
/*
* File: Application.h
* Author: jgaebler
*
* Created on November 10, 2011, 03:37 PM
*/
#include "Application.h"
#include "Moversight.h"
#include "Dispatcher.h"
#include "PeerDescription.h"
namespace ubeeme {
namespace moversight {
#if OMNETPP
/**
* @brief Constructor
* @param m A reference to the moversight instance
*/
Application::Application(Moversight & m, std::string name) :
ObjectListener(name),
module(m),
dis(NULL),
candidatesIndex(0),
initApp(true) {
}
#else
Application::Application() : module(NULL), dis(NULL), candidatesIndex(0), initApp(true) {
}
#endif
/**
* @brief Destructor
*/
Application::~Application() {
}
/**
* @brief Assignment operator.
* @param Application to copy.
*/
Application &
Application::operator =(const Application& other) {
if (this != &other) {
setServiceName(other.getServiceName());
module = other.module;
dis = other.dis;
candidates = other.candidates;
candidatesIndex = other.candidatesIndex;
initApp = other.initApp;
}//End if
return *this;
}
/**
* @brief Sets the dispatcher call back to the test application.
*
* This method sets the dispatcher call back at the current test application instance.
* It is important to run this method before the testcase itself is executed.
* @param d The dispatcher to set.
*/
void
Application::setDispatcher(Dispatcher * d) {
dis = d;
}
void
Application::initialise() {
}
void
Application::finalise() {
}
#if UBEEME
void
Application::setMoversight(Moversight * m) {
module = m;
}
#endif
#if OMNETPP
/**
* @brief Callback method. This method is called by moversight to signal that the local peer have receive a group data message.
* @param data The received group data.
* @param sender The sending peer ID.
*/
void
Application::receiveGroupData(const GroupData & /* data */, const PeerID /* sender */) {
}
/**
* @brief Called, have the local peer received a stream data message.
* @param data The received message.
* @param sender The sender of the message.
*/
void
Application::receiveStreamMessage(const StreamMessage & /* data */, const PeerID /* sender */) {
}
/**
* @brief Called, have the local peer receive a stream data message.
* @param data The received message.
* @param sender The sender of the message.
*/
void
Application::receiveUnicastMessage(const UnicastMessage & /* data */, const PeerID /* sender */) {
}
#endif // #if OMNETPP
}
}

View File

@@ -0,0 +1,120 @@
/*
* File: Application.h
* Author: jgaebler
*
* Created on July 22, 2010, 10:56 AM
*/
#ifndef APPLICATION_H
#define APPLICATION_H
#include "common/Defines.h"
#include "common/transport/TransportAddress.h"
#include "common/transport/TransportAddressList.h"
#include "event/ObjectListener.h"
namespace ubeeme {
namespace moversight {
/**
* @brief Defines for each test application a value, configured within the omnet.ini files and moversight to
* select the test application to run.
*/
enum ApplicationType {
TEST_APPLICATION = 0,
SPLIT_TEST_APPLICATION,
NFD_TEST_APPLICATION,
PEER_PLACING_TEST_APPLICATION,
MERGE_TEST_APPLICATION,
ALM_TEST_APPLICATION, //5
PARTITION_APPLICATION,
PENDING_TEST_APPLICATION, //7
MAINTANCE_APPLICATION
};
class Moversight;
class Dispatcher;
class Invitation;
class PeerDescription;
class Peer;
class GroupData;
class StreamMessage;
class UnicastMessage;
/**
* @brief Defines a small test application interface to test the moversight protocol.
* @ingroup Moversight
* @class Application
* @author Jan G&auml;bler
* @author Rober Noack
*/
class Application : public ObjectListener {
public:
#if OMNETPP
Application(Moversight & m, std::string name);
#else
Application();
void setMoversight(Moversight * m);
#endif
Application& operator=(const Application & other);
virtual ~Application();
void setDispatcher(Dispatcher * d);
virtual void initialise();
virtual void finalise();
#if OMNETPP
/**
* @brief Starts the given test case.
* @param i The number of the test case to start.
*/
virtual void startTestCase(unsigned int i) = 0;
virtual void receiveGroupData(const GroupData & data, const PeerID sender);
virtual void receiveStreamMessage(const StreamMessage & data, const PeerID sender);
virtual void receiveUnicastMessage(const UnicastMessage & data, const PeerID sender);
#endif
protected:
/**
* @brief A reference to the moversight module, used to retrieve module information as the local transport address.
*/
#if OMNETPP
Moversight & module;
#else
Moversight * module;
#endif
/**
* @brief A reference to the moversight dispatcher, used to access all moversight methods and services.
*/
Dispatcher * dis;
/**
* @brief Stores the transport addresses of the peers to invite.
*/
TransportAddressList candidates;
/**
* @brief The points to the current peer to invite within the candidates list.
*/
size_t candidatesIndex;
/**
* @brief Signals, if the application is within its initialization phase. True, the app is within the initialise phase, false otherwise.
*/
bool initApp;
};
}
}
#endif /* APPLICATION_H */

View File

@@ -0,0 +1,217 @@
/*
* File: ApplicationLevelMulticastTestApplication.cc
* Author: jgaebler
*
* Created on February 17, 2012, 5:02 PM
*/
#include "ApplicationLevelMulticastTestApplication.h"
#include "../Moversight.h"
#include "../Dispatcher.h"
#include "../app/PeerDescription.h"
#include "../simutils/OmnetppIniUtils.h"
#include "StreamMessage.h"
#include "../simutils/statistics/VectorStatistic.h"
#include "ms/events/GroupClosedEvent.h"
#include "ms/events/GroupCreatedEvent.h"
#include "ms/events/JoinRequestEvent.h"
#undef DEBUG
#define DEBUG(msg) if (module.isPrintDebugAPP()) \
MOV_DEBUG << "APP@"<<(dis->getLocalState()==DISJOINED?"TA_":"");\
if(dis->getLocalState()==DISJOINED){MOV_DEBUG << module.getLocalAddress();}\
else{MOV_DEBUG<< dis->getMembershipService().getLocalID();}MOV_DEBUG<<" "<<msg<<std::endl;
namespace ubeeme {
namespace moversight {
/**
* @brief Constructor
* @param m A reference to the moversight instance
*/
ApplicationLevelMulticastTestApplication::ApplicationLevelMulticastTestApplication(Moversight & m) : Application(m, "ApplicationLevelMulticastTestApplication") {
}
/**
* @brief Destructor
*/
ApplicationLevelMulticastTestApplication::~ApplicationLevelMulticastTestApplication() {
}
void
ApplicationLevelMulticastTestApplication::initialise() {
dis->subscribe<GroupClosedEvent>(this);
dis->subscribe<GroupCreatedEvent>(this);
dis->subscribe<JoinRequestEvent>(this);
}
void
ApplicationLevelMulticastTestApplication::finalise() {
}
/**
* @brief Invites a peer to a the moversight group.
* @param ta The transport address of the peer to invite.
*/
void
ApplicationLevelMulticastTestApplication::invitePeer(TransportAddress & ta) {
std::stringstream buf;
buf << "invitePeer - invite peer at address " << ta;
DEBUG(buf.str().c_str());
PeerDescription pDesc;
dis->invitePeer(ta, pDesc);
}
/**
* @brief Sends dummy data to the group to simulate application traffic.
*/
void
ApplicationLevelMulticastTestApplication::sendData() {
DEBUG("sendData - stream dummy data to the group");
StreamMessage data;
dis->sendMessage(data);
VectorStatistic vs("sendStream");
vs.record(GenericTime::currentTime());
}//End
/**
* @brief Starts the given test case.
* @param i The number of the test case to start.
*/
void
ApplicationLevelMulticastTestApplication::startTestCase(unsigned int i) {
switch (i) {
case 0:
testCase00();
break;
case 1:
testCase01();
break;
default:
break;
}//End switch
}//End startTestCase
/**
* @brief Executes test case 00
*/
void
ApplicationLevelMulticastTestApplication::testCase00() {
int moduleIndex = module.getLocalAddress().getHostAddress().get4().getDByte(3);
if (initApp) {
candidates = OmnetppIniUtils::getDestinationAddressesFromOmnetppIni(module);
waitCounter = 5;
initApp = false;
if (moduleIndex == 1) {
module.scheduleTestCase(45);
}//End if
}//End if
//------------------------------------------------------------------
//run the app
//------------------------------------------------------------------
if (moduleIndex == 1) { // starts counting at 1
//we have more candidates?
if (candidatesIndex < candidates.size()) {
if (waitCounter > 0) {
waitCounter--;
}
else {
invitePeer(candidates.get(candidatesIndex++));
}
}
else {
sendData();
}
module.scheduleTestCase(45);
}//End if
}//End testCase00
/**
* @brief Executes test case 01.
*/
void
ApplicationLevelMulticastTestApplication::testCase01() {
std::cerr << "TC01 not implemented yet" << endl;
}
/**
* @brief Called, have the local peer received a stream data message.
* @param data The received message.
* @param sender The sender of the message.
*/
void
ApplicationLevelMulticastTestApplication::receiveStreamMessage(const StreamMessage & data, const PeerID sender) {
std::stringstream buf;
buf << "receiveStreamMessage - receive stream message from peer ID " << sender;
DEBUG(buf.str().c_str());
VectorStatistic vs("receiveStream");
vs.record(GenericTime::currentTime());
}
/**
* @brief Handle an incoming JoinRequestEvent.
* @param e The event.
*/
void
ApplicationLevelMulticastTestApplication::handleEvent(const JoinRequestEvent & e) {
DEBUG("invitationReceived - invitation received");
std::stringstream buf;
buf << "invitationReceived - invitationID: " << e.getInvitation().getInvitationID() << " inviterID: " << e.getInvitation().getInviterID();
DEBUG(buf.str().c_str());
// if(module.localAddress() == 1 || module.localAddress() == 3 ){
//
// MOV_DEBUG << "APP_invitationReceived@TA_" << module.localAddress() << " reject invitation" << endl;
// gc->rejectInvitaion(invitation, "peer placing strategy not supported");
//
// }//End if
// else{
DEBUG("invitationReceived - accept invitation");
PeerDescription pDesc;
PeerResources resources;
dis->acceptInvitation(e.getInvitation(), "accept invitation", pDesc, resources);
// }//End else
}
/**
* @brief Handle an incoming GroupCreatedEvent.
* @param e The event
*/
void
ApplicationLevelMulticastTestApplication::handleEvent(const GroupCreatedEvent & e) {
DEBUG("group created");
}
/**
* @brief Handle an incoming GroupClosedEvent.
* @param e The event.
*/
void
ApplicationLevelMulticastTestApplication::handleEvent(const GroupClosedEvent & e) {
DEBUG("group closed");
}
}
}

View File

@@ -0,0 +1,60 @@
/*
* File: ApplicationLevelMulticastTestApplication.h
* Author: jgaebler
*
* Created on February 17, 2012, 5:02 PM
*/
#ifndef APPLICATIONLEVELMULTICASTTESTAPPLICATION_H
#define APPLICATIONLEVELMULTICASTTESTAPPLICATION_H
#include "Application.h"
namespace ubeeme {
namespace moversight {
class Dispatcher;
class Moversight;
class Invitation;
/**
* @class ApplicationLevelMulticastTestApplication
* @brief Defines a small test application to test the stream transfer multicast service.
*
* @ingroup Moversight
* @author Jan G&auml;bler
*/
class ApplicationLevelMulticastTestApplication : public Application {
public:
ApplicationLevelMulticastTestApplication(Moversight & m);
virtual ~ApplicationLevelMulticastTestApplication();
virtual void initialise();
virtual void finalise();
void startTestCase(unsigned int i);
virtual void receiveStreamMessage(const StreamMessage & data, const PeerID sender);
// Event handling
virtual void handleEvent(const GroupCreatedEvent & e);
virtual void handleEvent(const GroupClosedEvent & e);
virtual void handleEvent(const JoinRequestEvent & e);
private:
void testCase00();
void testCase01();
void invitePeer(TransportAddress & ta);
void sendData();
size_t waitCounter;
};
}
}
#endif /* APPLICATIONLEVELMULTICASTTESTAPPLICATION_H */

View File

@@ -0,0 +1,36 @@
#pragma once
#ifndef EVENT_TYPES_H
#define EVENT_TYPES_H
namespace ubeeme {
namespace moversight {
class EventTypes {
public:
/**
* @brief Defines for each moversight event an identifier.
*/
enum Event {
/**
* PEER_JOINED_EVENT
*/
PEER_JOINED_EVENT = 1,
/**
*
* PEER_IS_PENDING_EVENT
*/
PEER_IS_PENDING_EVENT,
PEER_RECONNECTED_EVENT,
PEER_LEFT_EVENT,
LOCAL_PEER_UPDATE_EVENT,
GROUP_CREATED_EVENT,
GROUP_CLOSED_EVENT,
EVENT_TYPES_COUNT // has to be last
};
};
}
} // namespace ubeeme
#endif // EVENT_TYPES_H

View File

@@ -0,0 +1,594 @@
/*
* File: MaintanceApplication.cc
* Author: stubbfel
*
* Created on June 29, 2013
*/
#include "MaintanceApplication.h"
#include "Dispatcher.h"
#include "Moversight.h"
#include "ms/Invitation.h"
#include "common/transport/TransportAddress.h"
#include "simutils/OmnetppIniUtils.h"
#include "mt/msg/GroupData.h"
#include <fstream>
#include "ms/events/GroupClosedEvent.h"
#include "ms/events/JoinRequestEvent.h"
#include "ms/events/LocalPeerUpdatedEvent.h"
#include "ms/events/PeerJoinedEvent.h"
#include "ms/events/PeerLeftEvent.h"
#include "mt/events/MulticastMessageDroppedEvent.h"
#undef DEBUG
#define DEBUG(msg) if (module.isPrintDebugAPP()) \
MOV_DEBUG << "APP@"<<(dis->getLocalState()==DISJOINED?"TA_":"");\
if(dis->getLocalState()==DISJOINED){MOV_DEBUG << module.getLocalAddress();}\
else{MOV_DEBUG<< dis->getMembershipService().getLocalID();}MOV_DEBUG<<" "<<msg<<std::endl;
namespace ubeeme {
namespace moversight {
const unsigned int MaintanceApplication::INITIAL_FAKEID;
const unsigned int MaintanceApplication::MS_TO_INT_FACTOR;
/**
* @brief Constructor
* @param m A reference to the moversight instance
*/
MaintanceApplication::MaintanceApplication(Moversight & m) : Application(m, "MaintanceApplication"), RTTStat(m, "RTT") { /*, groupSizeStat(m, "groupSize"), groupSize(0) */
inGroup = false;
stopTest = false;
emptyCommandList = false;
nextCommand = true;
}
/**
* @brief Destructor
*/
MaintanceApplication::~MaintanceApplication() {
}
void
MaintanceApplication::initialise() {
dis->subscribe<GroupClosedEvent>(this);
dis->subscribe<PeerJoinedEvent>(this);
dis->subscribe<PeerLeftEvent>(this);
dis->subscribe<LocalPeerUpdatedEvent>(this);
dis->subscribe<JoinRequestEvent>(this);
dis->subscribe<MulticastMessageDroppedEvent>(this);
}
void
MaintanceApplication::finalise() {
dis->unsubscribeAll(this);
}
/**
* @brief Starts the given test case.
* @param i The number of the test case to start.
*/
void
MaintanceApplication::startTestCase(unsigned int i) {
if (stopTest) {
return;
}
switch (i) {
case 0:
testCase00();
break;
case 1:
testCase01();
break;
case 2:
testCase02();
break;
case 3:
testCase03();
break;
case 4:
testCase04();
break;
case 5:
testCase05();
break;
case 6:
testCase06();
break;
default:
throw NotImplementedYetException("not implemented");
break;
}
}//End startTestCase
/**
*@brief simple test run with random leaves and joins
*/
void
MaintanceApplication::testCase00() {
joinRate = 1;
leaveRate = 1;
defaultBehav();
}//End testCase00
/**
*@brief simple test run coordinatet leaves and joins
*/
void
MaintanceApplication::testCase01() {
joinRate = 1; // == 100%
leaveRate = 2; // == 50%
commandsFileName = "commands/comt01.txt";
coordinateBehav();
module.scheduleTestCase(1);
}//End testCase01
/**
*@brief testrun for simultaneously invataitons
*/
void
MaintanceApplication::testCase02() {
joinRate = 1; // == 100%
leaveRate = 1; // == 0%
defaultBehav2();
}//End testCase02
/**
*@brief coordiante testrun, if all commands are executed then moduel==1 start to send groupdatas
*/
void
MaintanceApplication::testCase03() {
commandsFileName = "commands/com.txt";
coordinateBehav();
if (moduleIndex == 1 && dis->getLocalState() == JOINED) {
// abuse sendMessage for transmitting first sending time of the messages
sendKickMessage(createFakeID(GenericTime::currentTime().dbl() * MS_TO_INT_FACTOR));
}//End if
module.scheduleTestCase(1);
}
/**
*@brief test run, for testing random forces role switch (module== ire sending RSA Messages)
*/
void
MaintanceApplication::testCase04() {
commandsFileName = "commands/comt04.txt";
module.scheduleTestCase(45);
coordinateBehav();
if (dis->getLocalState() == JOINED &&
commands.size() < 1 &&
moduleIndex == 1 &&
dis->getLocalSubState() != FLUSHING) {
PeerIDList masterIdList = dis->getMembershipService().getMasterPeerIDList();
PeerID switchMasterId = masterIdList.get(rand() % masterIdList.size());
dis->getMaintenanceRoleService().sendRSAMessage(switchMasterId);
}
module.scheduleTestCase(1);
}
/**
*@brief uncoordiante testrun, moduel==1 send groupdatas
*/
void
MaintanceApplication::testCase05() {
joinRate = 5;
leaveRate = 100;
defaultBehav();
if (moduleIndex == 1 && dis->getLocalState() == JOINED) {
// abuse sendMessage for sending "useless" messages
sendKickMessage(createFakeID(0));
}//End if
module.scheduleTestCase(1);
}
/**
*@brief coordiante testrun, if all commands are executed then moduel==1 start to send groupdatas (like testcase 3 but sending messages as a burst)
*/
void
MaintanceApplication::testCase06() {
commandsFileName = "commands/comt03.txt";
//module.scheduleTestCase(45);
coordinateBehav();
if (moduleIndex == 1 && dis->getLocalState() == JOINED && emptyCommandList) {
// send a the current time as fakeID
sendKickMessage(createFakeID(GenericTime::currentTime().dbl() * MS_TO_INT_FACTOR));
module.scheduleTestCase(0.001);
} else {
module.scheduleTestCase(1);
}
}
/**
* @brief excute the normal behaviour of the app, depends of the join- and
* leaverate, the module==1 will be insert peers. every Peer decided self,
* when they want to leave the group (Except module==1||2 )
*/
void
MaintanceApplication::defaultBehav() {
moduleIndex = module.getLocalAddress().getHostAddress().get4().getDByte(3);
if (initApp) {
candidates = OmnetppIniUtils::getDestinationAddressesFromOmnetppIni(module);
initApp = false;
}//End if
//------------------------------------------------------------------
//run the app
//------------------------------------------------------------------
if (moduleIndex == 1) { // starts counting at 1
//we have more candidates?
if (candidates.size() > 0) {
int join = rand() % joinRate;
if (join == 0) {
TransportAddress first = candidates.first();
candidates.remove(first);
invitePeer(first);
}
}
//module.scheduleTestCase(45);
} else {
if (dis->getLocalState() == JOINED) {
inGroup = true;
} else {
inGroup = false;
}
if (inGroup && dis->getGroupSize() > 2) {
int leave = rand() % leaveRate;
if (leave == 1) {
leaveGroup();
}
//module.scheduleTestCase(45);
}
}//End if
module.scheduleTestCase(45);
}
/**
* @brief excute the normal behaviour of the app, depends of the join- and
* leaverate, the module==1||2 will be insert peers. every Peer decided self,
* when they want to leave the group (Except module==1||2 )
*/
void
MaintanceApplication::defaultBehav2() {
moduleIndex = module.getLocalAddress().getHostAddress().get4().getDByte(3);
if (initApp) {
candidates = OmnetppIniUtils::getDestinationAddressesFromOmnetppIni(module);
initApp = false;
}//End if
//------------------------------------------------------------------
//run the app
//------------------------------------------------------------------
if (moduleIndex == 1) { // starts counting at 1
//we have more candidates?
if (candidates.size() > 0) {
int join = rand() % joinRate;
if (join == 0) {
TransportAddress first = candidates.first();
candidates.remove(first);
invitePeer(first);
}
}
//module.scheduleTestCase(45);
} else if (moduleIndex == 2) { // starts counting at 2
if (dis->getLocalState() == JOINED) {
inGroup = true;
} else {
inGroup = false;
}
//we have more candidates?
if (candidates.size() > 0 && inGroup) {
int join = rand() % joinRate;
if (join == 0) {
TransportAddress last = candidates.get(candidates.size() - 1);
candidates.remove(last);
invitePeer(last);
}
}
//module.scheduleTestCase(45);
} else {
if (dis->getLocalState() == JOINED) {
inGroup = true;
} else {
inGroup = false;
}
if (inGroup && dis->getGroupSize() > 2) {
int leave = rand() % leaveRate;
if (leave == 1) {
leaveGroup();
}
//module.scheduleTestCase(45);
}
}//End if
module.scheduleTestCase(45);
}
/**
* @brief excute the coordinated behaviour of the app, depends of the join- and
* leavecommands from a certean, the module==1 will be insert or remove peers
*/
void
MaintanceApplication::coordinateBehav() {
moduleIndex = module.getLocalAddress().getHostAddress().get4().getDByte(3);
if (initApp) {
candidates = OmnetppIniUtils::getDestinationAddressesFromOmnetppIni(module);
initApp = false;
if (moduleIndex == 1) {
std::ifstream commandFile(commandsFileName.c_str());
if (commandFile.is_open()) {
std::string command;
DEBUG("Load commands");
while (commandFile.good()) {
std::getline(commandFile, command);
DEBUG(command);
commands.add(command);
}
commandFile.close();
}
module.scheduleTestCase(45);
}//End if
}//End if
//------------------------------------------------------------------
//run the app
//------------------------------------------------------------------
if (moduleIndex == 1) { // starts counting at 1
//we have more candidates?
if (commands.size() > 0 && nextCommand == true) {
std::string command = commands.first();
commands.pop();
DEBUG("exec command " << command);
switch (command[0]) {
case 'J':
nextCommand = false;
if (candidates.size() > 0) {
TransportAddress firstAddr = candidates.first();
invitePeer(firstAddr);
candidates.pop();
}
break;
case 'L': {
nextCommand = false;
PeerID kickPeerID;
if (command.size() == 3) {
size_t firstNumber = (size_t)(command[1] - '0');
size_t secondNumber = (size_t)(command[2] - '0');
kickPeerID = firstNumber * 10 + secondNumber;
} else {
kickPeerID = (PeerID)(command[1] - '0');
}
sendKickMessage(kickPeerID);
}
break;
default:
break;
}
} else if (commands.size() == 0) {
emptyCommandList = true;
}
// module.scheduleTestCase(45);
}
}
void
MaintanceApplication::sendKickMessage(PeerID pId) {
DEBUG("sendData - stream dummy data to the group");
GroupData data;
data.setData(peerIDToByte(pId));
dis->sendMessage(data);
}
/**
* @brief convert a PeerID to a ByteArray
* @param id which has to been convert
*/
ByteArray
MaintanceApplication::peerIDToByte(PeerID pId) {
ByteArray array;
array.push_back(pId.getValue() & 0xff);
array.push_back(pId.getValue() >> 8 & 0xff);
array.push_back(pId.getValue() >> 16 & 0xff);
array.push_back(pId.getValue() >> 24 & 0xff);
return array;
}
/**
* @brief convert a ByteArray to a PeerId
* @param array which has to been convert
*/
PeerID
MaintanceApplication::byteToPeerID(ByteArray array) {
unsigned int intPid = 0;
char* chPID = (char*) &intPid;
*chPID = array[0];
chPID++;
*chPID = array[1];
chPID++;
*chPID = array[2];
chPID++;
*chPID = array[3];
return PeerID(intPid);
}
/**
* @brief Invites a peer to a the moversight group.
* @param ta The transport address of the peer to invite.
*/
void
MaintanceApplication::invitePeer(TransportAddress & ta) {
PeerDescription pDesc;
dis->invitePeer(ta, pDesc);
}
/**
* @brief Leaves the current group. The peer leafs the current group be
* emmiting a LeaveAnnounce within the current group.
*/
void
MaintanceApplication::leaveGroup() {
dis->leaveGroup();
}
/**
* @brief Handle an incoming JoinRequestEvent.
* @param e The event.
*/
void
MaintanceApplication::handleEvent(const JoinRequestEvent & e) {
PeerDescription desc;
PeerResources resource;
dis->acceptInvitation(e.getInvitation(), "accept invitation", desc, module.getPeerResources());
}
/**
* @brief Handle PeerJoinedEvent.
* @param e The event.
*/
void
MaintanceApplication::handleEvent(const PeerJoinedEvent & e) {
nextCommand = true;
}
/**
* @brief Handle an incoming PeerLeftEvent.
* @param e The event.
*/
void
MaintanceApplication::handleEvent(const PeerLeftEvent & e) {
if (moduleIndex == 1) {
if (!candidates.contains(e.getPeer().getLocalAddress())) {
candidates.add(e.getPeer().getLocalAddress());
}
}
nextCommand = true;
}
/**
* @brief Handle an incoming LocalPeerUpdatedEvent.
* @param e The event.
*/
void
MaintanceApplication::handleEvent(const LocalPeerUpdatedEvent & e) {
std::stringstream buf;
buf << "Peer-State - PID: " << e.getPeer().getPeerState();
DEBUG(buf.str().c_str());
}
/**
* @brief Handle an incoming GroupClosedEvent.
* @param e The event.
*/
void
MaintanceApplication::handleEvent(const GroupClosedEvent & e) {
if (moduleIndex == 1) {
stopTest = true;
}
}
/**
* @brief handler for incomming Group Data
* @param data, referennce of the new messages
* @param sender , id of the peer which sended this message
*/
void
MaintanceApplication::receiveGroupData(const GroupData & dat, const PeerID sender) {
ByteArray array = dat.getData();
PeerID pID = byteToPeerID(array);
std::stringstream buf;
buf << "receiveStreamMessage - kick Peer" << pID;
//std::cerr << "buf " << buf << "\n";
DEBUG(buf.str().c_str());
if (pID == dis->getLocalPeer().getPeerID()) {
leaveGroup();
}//End if
else if (pID > INITIAL_FAKEID) {
// is a fade id;
meassuringRTT(pID, dat);
}//end else if
}
/**
* @brief method extract from a abuse peerId the sending item and calculate the rtt of a messages
* @param peerId, is a faked id. its the sendingtime + 1000
* @param dat, referennce of the message
*/
void
MaintanceApplication::meassuringRTT(PeerID peerId, const GroupData & dat) {
int sendTime = peerId.getValue() - INITIAL_FAKEID;
int reciveTime = GenericTime::currentTime().dbl() * MS_TO_INT_FACTOR;
int rtt = reciveTime - sendTime;
RTTStat.record(rtt);
MessageReference msgref = dat.getMessageReference();
DEBUG("rtt of msg " << msgref << " = " << rtt << "ms");
}
/**
* @brief methed create a fakepid
* @param value, parameter wich has to bo corvert to peerID
*/
PeerID
MaintanceApplication::createFakeID(unsigned int value) {
return PeerID(INITIAL_FAKEID + value);
}
/**
* @brief Handle an incoming MulticastMessageDroppedEvent.
* @param e The event.
*/
void MaintanceApplication::handleEvent(const MulticastMessageDroppedEvent& e) {
const MulticastMessage & msg = e.getMessage();
DEBUG("message " << msg << "(MREF=" << msg.getMessageReference() << ") is dropped !!!");
}
}
}

View File

@@ -0,0 +1,90 @@
/*
* File: MaintanceApplication.h
* Author: stubbfel
*
* Created on June 29, 2013
*/
#ifndef MAINTANCEAPPLICATION_H
#define MAINTANCEAPPLICATION_H
#include "app/Application.h"
#include "StreamMessage.h"
#include "simutils/statistics/VectorStatisticRecorder.h"
namespace ubeeme {
namespace moversight {
class Dispatcher;
class Moversight;
class Invitation;
/**
* @class MaintanceApplication
* @brief test app for testing maintancement
* @ingroup Moversight
* @author stubbfel
*/
class MaintanceApplication : public Application {
public:
MaintanceApplication(Moversight & m);
virtual ~MaintanceApplication();
virtual void initialise();
virtual void finalise();
void startTestCase(unsigned int i);
void leaveGroup();
void receiveUnicastMessage(UnicastMessage & data, PeerID sender);
// Event handling
virtual void handleEvent(const JoinRequestEvent & e);
virtual void handleEvent(const PeerJoinedEvent & e);
virtual void handleEvent(const PeerLeftEvent & e);
virtual void handleEvent(const LocalPeerUpdatedEvent & e);
virtual void handleEvent(const GroupClosedEvent & e);
virtual void handleEvent(const MulticastMessageDroppedEvent & e);
void receiveGroupData(const GroupData & dat, const PeerID sender);
private:
void testCase00();
void testCase01();
void testCase02();
void testCase03();
void testCase04();
void testCase05();
void testCase06();
void invitePeer(TransportAddress & ta);
void defaultBehav();
void defaultBehav2();
void coordinateBehav();
void sendKickMessage(PeerID pId);
PeerID createFakeID(unsigned int value);
ByteArray peerIDToByte(PeerID pId);
PeerID byteToPeerID(ByteArray array);
void meassuringRTT(PeerID peerId, const GroupData & dat);
int moduleIndex;
bool inGroup;
bool emptyCommandList;
int joinRate;
int leaveRate;
std::string commandsFileName;
bool stopTest;
bool nextCommand;
List<std::string> commands;
VectorStatisticRecorder RTTStat;
static const unsigned int INITIAL_FAKEID = 1000;
static const unsigned int MS_TO_INT_FACTOR = 1000;
};
}
}
#endif /* MAINTANCEAPPLICATION_H*/

View File

@@ -0,0 +1,342 @@
/*
* File: MergeApplication.h
* Author: sgaebler
*
* Created on July 8, 2011, 03:37 PM
*/
#include "MergeApplication.h"
#include "Dispatcher.h"
#include "Moversight.h"
#include "app/Application.h"
#include "common/transport/TransportAddress.h"
#include "merge/events/MergeRequestEvent.h"
#include "merge/events/MergeDoneEvent.h"
#include "ms/Invitation.h"
#include "ms/PeerResources.h"
#include "mt/msg/GroupData.h"
#undef DEBUG
#define DEBUG(msg) if (module.isPrintDebugAPP()) \
MOV_DEBUG << "APP@"<<(dis->getLocalState()==DISJOINED?"TA_":"");\
if(dis->getLocalState()==DISJOINED){MOV_DEBUG << module.getLocalAddress();}\
else{MOV_DEBUG<< dis->getMembershipService().getLocalID();}MOV_DEBUG<<" "<<msg<<std::endl;
namespace ubeeme {
namespace moversight {
/**
* @brief c'tor
* @param m The moversight module
*/
MergeApplication::MergeApplication(Moversight & m) : Application(m, "MergeApplication") {
WATCH(state);
mergeOnce = false;
#if OMNETPP
mergeDuration.setName("mergeDuration");
mergeDuration.setUnit("s");
numberOfPeers = module.par("numberOfPeers");
clusterSize = numberOfPeers / module.getMaxPeerCount();
dt = 0.0;
#endif
}
/**
* @brief d'tor
*/
MergeApplication::~MergeApplication() {
}
void
MergeApplication::initialise() {
dis->subscribe<MergeDoneEvent>(this);
dis->subscribe<MergeRequestEvent>(this);
}
/**
* @brief Invites a peer
* @param ta The address to invite
*/
void
MergeApplication::invitePeer(TransportAddress & ta) {
std::stringstream buf;
buf << "invitePeer - invite peer at address " << ta;
DEBUG(buf.str().c_str());
PeerDescription pDesc;
dis->invitePeer(ta, pDesc);
}
/**
* @brief Leaves the group
*/
void
MergeApplication::leaveGroup() {
DEBUG("leaveGroup - peer leave the group");
dis->leaveGroup();
}
/**
* @brief Try to merge with second group
*/
void
MergeApplication::mergeRequest(TransportAddress & ta) {
DEBUG("mergeRequest - group wants to merge with other group");
dis->mergeGroup(ta);
}
/**
* @brief Sends dummy test data to the group
*/
void
MergeApplication::sendData() {
DEBUG("sendData - send 24 byte dummy data to the group");
GroupData data;
dis->sendMessage(data);
}
/**
* @brief Tries to start the given test case.
* @param i The test case to start
*/
void
MergeApplication::startTestCase(unsigned int i) {
switch (i) {
case 0:
testCase00();
break;
case 1:
testCase01();
break;
case 2:
testCase02();
break;
default:
break;
}//End switch
}
/**
* @brief Test case 0: Master-master
*/
void
MergeApplication::testCase00() {
state = dis->getLocalState();
// init app
if (initApp) {
//set up group for each peer
if (module.getLocalAddress().getHostAddress().get4().getDByte(3) < (numberOfPeers / 2 + 1)) {
createRoster(1);
}
else {
createRoster(2);
}
initApp = false;
dt = simTime();
}
// 1 is master
if (module.getLocalAddress().getHostAddress().get4().getDByte(3) == 1) {
if (dis->getLocalState() == JOINED) {
if (!mergeOnce) {
mergeOnce = true;
// defining the otherMergeDirector - here Master!
TransportAddress ta = getNewTransportAddress(numberOfPeers / 2 + 1);
ta.setPort(module.getLocalAddress().getPort());
mergeRequest(ta);
module.scheduleTestCase(45);
}//End if
}//End if
}
}
/**
* @brief Test case 1: master-slave
*/
void
MergeApplication::testCase01() {
state = dis->getLocalState();
// init app
if (initApp) {
//set up group for each peer
if (module.getLocalAddress().getHostAddress().get4().getDByte(3) < (numberOfPeers / 2 + 1)) {
createRoster(1);
}
else {
createRoster(2);
}
initApp = false;
dt = simTime();
}
// 1 is master
if (module.getLocalAddress().getHostAddress().get4().getDByte(3) == 1) {
if (dis->getLocalState() == JOINED) {
if (!mergeOnce) {
mergeOnce = true;
// defining the otherMergeDirector - here Slave!
TransportAddress ta = getNewTransportAddress(numberOfPeers / 2 + 2);
ta.setPort(module.getLocalAddress().getPort());
mergeRequest(ta);
module.scheduleTestCase(45);
}//End if
}//End if
}
}
/**
* @brief Test case 2: slave - slave
*/
void
MergeApplication::testCase02() {
state = dis->getLocalState();
// init app
if (initApp) {
//set up group for each peer
if (module.getLocalAddress().getHostAddress().get4().getDByte(3) < (numberOfPeers / 2 + 1)) {
createRoster(1);
}
else {
createRoster(2);
}
initApp = false;
dt = simTime();
}
// 2 is slave
if (module.getLocalAddress().getHostAddress().get4().getDByte(3) == 2) {
if (dis->getLocalState() == JOINED) {
if (!mergeOnce) {
mergeOnce = true;
// defining the otherMergeDirector - here Slave!
TransportAddress ta = getNewTransportAddress(numberOfPeers / 2 + 2);
ta.setPort(module.getLocalAddress().getPort());
mergeRequest(ta);
module.scheduleTestCase(45);
}//End if
}//End if
}
}
/**
* @brief Creating a new TransportAddress depending on the given parameter i.
* @param i - stands for the 3rd bytePosition
* @return the created ta
*/
TransportAddress
MergeApplication::getNewTransportAddress(int i) {
std::stringstream taStream;
taStream << "192.168.0." << i;
std::string s(taStream.str());
return TransportAddress(IPvXAddress(s.c_str()));
}
void
MergeApplication::receiveGroupData(const GroupData & data, const PeerID sender) {
std::stringstream buf;
buf << "receiveGroupData - receive group data from peer ID " << sender;
DEBUG(buf.str().c_str());
}
/**
* @brief Creates a new roster for the given group
* @param rosterNumber - if first or second roster to create
*/
void
MergeApplication::createRoster(int rosterNumber) {
Roster roster;
roster.setNextPeerID(numberOfPeers / 2 + 1);
roster.setViewID(numberOfPeers / 2 + 1);
PeerDescription dummyPDesc;
PeerResources dummyPRes;
ClusterID cID = 0;
if (clusterSize <= 1) {
// necessary to make sure if the numberOfPeers is equal or smaller than
// the maxPeerCount that only one cluster is created!
roster.setViewID(numberOfPeers + 1);
roster.setNextPeerID(numberOfPeers + 1);
}
if (rosterNumber == 1) {
for (int i = 1; i <= numberOfPeers / 2; i++) {
TransportAddress ta = getNewTransportAddress(i);
ta.setPort(module.getLocalAddress().getPort());
MemberDescription mDesc(i, ta, JOINED, cID, dummyPDesc, dummyPRes);
roster.addMemberDescription(mDesc);
if ((i % module.getMaxPeerCount()) == 0) {
cID++;
}//End if
}
dis->setupGroupFromRoster(roster, module.getLocalAddress().getHostAddress().get4().getDByte(3));
}
else {
for (int i = (numberOfPeers / 2 + 1); i <= numberOfPeers; i++) {
TransportAddress ta = getNewTransportAddress(i);
ta.setPort(module.getLocalAddress().getPort());
MemberDescription mDesc(i - (numberOfPeers / 2), ta, JOINED, cID, dummyPDesc, dummyPRes);
roster.addMemberDescription(mDesc);
if ((i % module.getMaxPeerCount()) == 0) {
cID++;
}//End if
}
dis->setupGroupFromRoster(roster, module.getLocalAddress().getHostAddress().get4().getDByte(3) - numberOfPeers / 2);
}
}
/**
* @brief Handle an incoming MergeRequestEvent
* @param e The event.
*/
void
MergeApplication::handleEvent(const MergeRequestEvent & e) {
dis->acceptGroupMerge();
}
/**
* @brief Handle an incoming MergeDoneEvent.
* @param e The event.
*/
void
MergeApplication::handleEvent(const MergeDoneEvent & e) {
#if OMNETPP
mergeDuration.recordWithTimestamp(simTime() - dt, numberOfPeers);
#endif
}
}//End namespace moversight
}//End namespace ubeeme

View File

@@ -0,0 +1,71 @@
/*
* File: MergeApplication.h
* Author: sgaebler
*
* Created on July 8, 2011, 03:37 PM
*/
#ifndef MERGEAPPLICATION_H
#define MERGEAPPLICATION_H
#include "Application.h"
#include "common/Defines.h"
#include "ms/PeerState.h"
namespace ubeeme {
namespace moversight {
class Dispatcher;
class Moversight;
class Invitation;
class MergeApplication : public Application {
public:
MergeApplication(Moversight & m);
virtual ~MergeApplication();
virtual void initialise();
void startTestCase(unsigned int i);
void receiveGroupData(const GroupData & data, const PeerID sender);
// Event handling
virtual void handleEvent(const MergeRequestEvent & e);
virtual void handleEvent(const MergeDoneEvent & e);
private:
void testCase00();
void testCase01();
void testCase02();
void invitePeer(TransportAddress & ta);
void leaveGroup();
void sendData();
void mergeRequest(TransportAddress & ta);
void mergeGroup();
void createRoster(int rosterNumber);
void createRoster2();
TransportAddress getNewTransportAddress(int i);
State state;
bool mergeOnce;
int waitCounter;
int mergeCase;
cOutVector mergeDuration;
simtime_t dt;
int numberOfPeers;
int clusterSize;
};
}
}
#endif /* MERGEAPPLICATION_H */

View File

@@ -0,0 +1,242 @@
/*
* File: NFDTestApplication.cc
* Author: jgaebler
*
* Created on April 20, 2011, 11:32 AM
*/
#include "NFDTestApplication.h"
#include "Dispatcher.h"
#include "Moversight.h"
#include "common/transport/TransportAddress.h"
#include "mt/msg/GroupData.h"
#include "ms/Invitation.h"
#include "ms/events/PeerJoinedEvent.h"
#include "fd/events/PeerReconnectedEvent.h"
#include "ms/events/LocalPeerUpdatedEvent.h"
#include "ms/events/JoinRequestEvent.h"
#include "ms/events/JoinConfirmEvent.h"
#include "ms/events/JoinRejectedEvent.h"
#include "ms/events/JoinAbortedEvent.h"
#include "mt/events/PendingPeersEvent.h"
#undef DEBUG
#define DEBUG(msg) if (module.isPrintDebugAPP()) \
MOV_DEBUG << "APP@"<<(dis->getLocalState()==DISJOINED?"TA_":"");\
if(dis->getLocalState()==DISJOINED){MOV_DEBUG << module.getLocalAddress();}\
else{MOV_DEBUG<< dis->getMembershipService().getLocalID();}MOV_DEBUG<<" "<<msg<<std::endl;
namespace ubeeme {
namespace moversight {
/**
* @brief Constructor
* @param m The moversight module
*/
NFDTestApplication::NFDTestApplication(Moversight & m) : Application(m, "NFDTestApplication") {
}
/**
* @brief Destructor
*/
NFDTestApplication::~NFDTestApplication() {
}
void
NFDTestApplication::initialise() {
dis->subscribe<PeerReconnectedEvent>(this);
dis->subscribe<PendingPeersEvent>(this);
dis->subscribe<JoinRequestEvent>(this);
dis->subscribe<JoinConfirmEvent>(this);
dis->subscribe<JoinRejectedEvent>(this);
dis->subscribe<PeerJoinedEvent>(this);
dis->subscribe<JoinAbortedEvent>(this);
}
void
NFDTestApplication::finalise() {
}
/**
* @brief Invites a peer to a the moversight group.
* @param ta The transport address of the peer to invite.
*/
void
NFDTestApplication::invitePeer(TransportAddress & ta) {
std::stringstream buf;
buf << "invitePeer - invite peer at address " << ta;
DEBUG(buf.str().c_str());
PeerDescription pDesc;
dis->invitePeer(ta, pDesc);
}
/**
* @brief Leaves the current group. The peer leafs the current group be
* emitting a LeaveAnnounce within the current group.
*/
void
NFDTestApplication::leaveGroup() {
DEBUG("leaveGroup - peer leave the group");
dis->leaveGroup();
}
/**
* @brief Sends dummy data to the group to simulate application traffic.
*/
void
NFDTestApplication::sendData() {
DEBUG("sendData - send 24 byte dummy data to the group");
GroupData data;
dis->sendMessage(data);
}//End
/**
* @brief Starts the given test case.
* @param i The number of the test case to start.
*/
void
NFDTestApplication::startTestCase(unsigned int i) {
}//End startTestCase
/**
* @brief Callback method. This method is called by moversight to signal that the local peer have receive a group data message.
* @param dat The received group data.
* @param sender The sending peer ID.
*/
void
NFDTestApplication::receiveGroupData(GroupData & dat, PeerID sender) {
std::stringstream buf;
buf << "receiveGroupData - receive group data from peer ID " << sender;
DEBUG(buf.str().c_str());
}
/**
* @brief Handle an incoming JoinRequestEvent
* @param e The event.
*
* The local instance has received an invitation.
*/
void
NFDTestApplication::handleEvent(const JoinRequestEvent & e) {
DEBUG("invitationReceived - invitation received");
std::stringstream buf;
buf << "invitationReceived - invitationID: " << e.getInvitation().getInvitationID() << " inviterID: " << e.getInvitation().getInviterID();
DEBUG(buf.str().c_str());
// if(module.localAddress() == 1 || module.localAddress() == 3 ){
//
// MOV_DEBUG << "APP_invitationReceived@TA_" << module.localAddress() << " reject invitation" << endl;
// gc->rejectInvitaion(invitation, "peer placing strategy not supported");
//
// }//End if
// else{
DEBUG("invitationReceived - accept invitation");
PeerDescription pDesc;
PeerResources resources;
dis->acceptInvitation(e.getInvitation(), "accept invitation", pDesc, resources);
// }//End else
}
/**
* @brief Handle an incoming JoinConfirmEvent
* @param e The event.
*
* The remote peer has accepted the invitation from the local peer.
*/
void
NFDTestApplication::handleEvent(const JoinConfirmEvent & e) {
std::stringstream buf;
buf << "receiveInvitationResponse - peer at TA: " << e.getInvitation().getInviteeAddress() << " accept invitation " << e.getInvitation().getInvitationID();
buf << " message: " << e.getMessage() << ", peer description: " << e.getDescription().getDescription();
DEBUG(buf.str().c_str());
}
/**
* @brief Handle an incoming JoinRejectedEvent.
* @param e The event.
*
* The remote peer has rejected the invitation from the local peer.
*/
void
NFDTestApplication::handleEvent(const JoinRejectedEvent & e) {
std::stringstream buf;
buf << "receiveInvitationResponse - peer at TA: " << e.getInvitation().getInviteeAddress() << " reject invitation " << e.getInvitation().getInvitationID();
buf << " reason: " << e.getReason();
DEBUG(buf.str().c_str());
}
/**
* @brief Handle an incoming JoinAbortedEvent.
* @param e The event.
*
* The invitation process was aborted.
*/
void
NFDTestApplication::handleEvent(const JoinAbortedEvent & e) {
std::stringstream buf;
buf << "invitationAborted - invitation to peer " << e.getTransportAddress() << " aborted";
buf << " reason: " << e.getReason();
DEBUG(buf.str().c_str());
}
/**
* @brief Handle an incoming PeerJoinedEvent.
* @param e The event.
*/
void
NFDTestApplication::handleEvent(const PeerJoinedEvent & e) {
std::stringstream buf;
buf << "peerJoined - peer " << e.getPeerID()
<< "@TA_" << e.getTransportAddress() << " joined group successfully ("
<< e.getDescription().getDescription() << ")";
DEBUG(buf.str().c_str());
}
/**
* @brief Handle an incoming PendingPeersEvent.
* @param e The event.
*
* Some peers are pending.
*/
void
NFDTestApplication::handleEvent(const PendingPeersEvent & e) {
std::stringstream buf;
buf << "peerIsPending - The following peers are pending: " << e.getPeerIDList();
DEBUG(buf.str().c_str());
}
/**
* @brief Handle an incoming PeerReconnectedEvent.
* @param e The event.
*
* A peer has reconnected.
*/
void
NFDTestApplication::handleEvent(const PeerReconnectedEvent & e) {
std::stringstream buf;
buf << "peerReconnected - peer " << e.getPeerID() << " has reconnected";
DEBUG(buf.str().c_str());
}
}
}

View File

@@ -0,0 +1,58 @@
/*
* File: NFDTestApplication.h
* Author: jgaebler
*
* Created on April 20, 2011, 11:32 AM
*/
#ifndef NFDTESTAPPLICATION_H
#define NFDTESTAPPLICATION_H
#include "Application.h"
#include "common/Defines.h"
#include "ms/PeerState.h"
namespace ubeeme {
namespace moversight {
class Dispatcher;
class Moversight;
class NFDTestApplication : public Application {
public:
NFDTestApplication(Moversight & m);
virtual ~NFDTestApplication();
virtual void initialise();
virtual void finalise();
void startTestCase(unsigned int i);
void receiveGroupData(GroupData & data, PeerID sender);
// Event handling
virtual void handleEvent(const PeerJoinedEvent & e);
virtual void handleEvent(const PeerReconnectedEvent & e);
virtual void handleEvent(const PendingPeersEvent & e);
virtual void handleEvent(const JoinRequestEvent & e);
virtual void handleEvent(const JoinConfirmEvent & e);
virtual void handleEvent(const JoinRejectedEvent & e);
virtual void handleEvent(const JoinAbortedEvent & e);
private:
void invitePeer(TransportAddress & ta);
void leaveGroup();
void sendData();
PeerState state;
};
}
}
#endif /* NFDTESTAPPLICATION_H */

View File

@@ -0,0 +1,411 @@
/*
* File: PartitionApplication.cc
* Author: gschneid
*
* Created on October 22, 2012, 11:09 AM
*/
#include "PartitionApplication.h"
#include "Dispatcher.h"
#include "Moversight.h"
#include "ms/PeerResources.h"
#include "common/transport/TransportAddress.h"
#include "mt/msg/GroupData.h"
#include "ms/Invitation.h"
#include "simutils/OmnetppIniUtils.h"
#include "StreamMessage.h"
#include "ms/events/GroupCreatedEvent.h"
#include "ms/events/GroupClosedEvent.h"
#include "ms/events/PeerJoinedEvent.h"
#include "ms/events/JoinRequestEvent.h"
#include "ms/events/JoinConfirmEvent.h"
#include "ms/events/JoinRejectedEvent.h"
#include "ms/events/JoinAbortedEvent.h"
#include "ms/events/RejoinDoneEvent.h"
#include "ms/events/RejoinFailedEvent.h"
#include "mt/events/PendingPeersEvent.h"
#include "ms/events/LocalPeerUpdatedEvent.h"
#include "ms/events/PeerLeftEvent.h"
#include "simutils/events/StartMeasuringEvent.h"
#include "simutils/events/StopMeasuringEvent.h"
#include "fd/events/PeerReconnectedEvent.h"
#undef DEBUG
#define DEBUG(msg) if (module.isPrintDebugAPP()) \
MOV_DEBUG << "APP@"<<(dis->getLocalState()==DISJOINED?"TA_":"");\
if(dis->getLocalState()==DISJOINED){MOV_DEBUG << module.getLocalAddress();}\
else{MOV_DEBUG<< dis->getMembershipService().getLocalID();}MOV_DEBUG<<" "<<msg<<std::endl;
namespace ubeeme {
namespace moversight {
/**
* @brief Constructor
* @param m A reference to the moversight instance
*/
PartitionApplication::PartitionApplication(Moversight & m) : Application(m, "PartitionApplication"), rejoinSucessDuration(m, "rejoinSuccess"), leaveDelay(m, "leaveDelay"), groupSize(0) {
numberOfPeers = module.par("numberOfPeers");
numberOfMobilePeers = module.par("numberOfMobilePeers");
clusterSize = (numberOfPeers + numberOfMobilePeers) / module.getMaxPeerCount();
if ((numberOfPeers + numberOfMobilePeers) % module.getMaxPeerCount() != 0) {
clusterSize++;
}
}
/**
* @brief Destructor
*/
PartitionApplication::~PartitionApplication() {
// joinDelayStat, leaveDelayStat, dtDelayStat,groupSizeStat removen?!
}
void
PartitionApplication::initialise() {
dis->subscribe<GroupCreatedEvent>(this);
dis->subscribe<PeerJoinedEvent>(this);
dis->subscribe<PendingPeersEvent>(this);
dis->subscribe<PeerReconnectedEvent>(this);
dis->subscribe<PeerLeftEvent>(this);
dis->subscribe<JoinRequestEvent>(this);
dis->subscribe<JoinConfirmEvent>(this);
dis->subscribe<JoinRejectedEvent>(this);
dis->subscribe<JoinAbortedEvent>(this);
dis->subscribe<RejoinDoneEvent>(this);
dis->subscribe<RejoinFailedEvent>(this);
// MeasurementEvent
dis->subscribe<StartMeasuringEvent>(this);
dis->subscribe<StopMeasuringEvent>(this);
}
void
PartitionApplication::finalise() {
}
/**
* @brief Invites a peer to a the moversight group.
* @param ta The transport address of the peer to invite.
*/
void
PartitionApplication::invitePeer(TransportAddress & ta) {
std::stringstream buf;
buf << "invitePeer - invite peer at address " << ta;
DEBUG(buf.str().c_str());
PeerDescription pDesc;
dis->invitePeer(ta, pDesc);
}
/**
* @brief Leaves the current group. The peer leafs the current group be
* emitting a LeaveAnnounce within the current group.
*/
void
PartitionApplication::leaveGroup() {
DEBUG("leaveGroup - peer leave the group");
dis->leaveGroup();
}
/**
* @brief Sends dummy data to the group to simulate application traffic.
*/
void
PartitionApplication::sendData() {
DEBUG("sendData - send 24 byte dummy data to the group");
GroupData data;
VectorStatistic vs("sendGroupData");
vs.record(GenericTime::currentTime());
dis->sendMessage(data);
}//End
/**
* @brief Starts the given test case.
* @param i The number of the test case to start.
*/
void
PartitionApplication::startTestCase(unsigned int i) {
switch (i) {
case 0:
testCase00();
break;
default:
break;
}//End switch
}
/**
* @brief Executes test case 01 - 6 peers, testcase1
*/
void
PartitionApplication::testCase00() {
DEBUG("partitionApplication tc00");
if (initApp) {
createRoster();
initApp = false;
module.scheduleTestCase(80);
}
}
/**
* @brief Method to create a roster from which the group is set up.
*/
void
PartitionApplication::createRoster() {
int numberOfAllPeers = numberOfPeers + numberOfMobilePeers;
Roster roster;
roster.setNextPeerID(numberOfAllPeers + 1);
roster.setViewID(numberOfAllPeers + 1);
PeerDescription dummyPDesc;
PeerResources dummyPRes;
ClusterID cID = 0;
if (clusterSize <= 1) {
// necessary to make sure if the numberOfPeers is equal or smaller than
// the maxPeerCount that only one cluster is created!
roster.setViewID(numberOfAllPeers + 1);
roster.setNextPeerID(numberOfAllPeers + 1);
}
for (int i = 1; i <= numberOfAllPeers; i++) {
TransportAddress ta = getNewTransportAddress(i);
ta.setPort(module.getLocalAddress().getPort());
MemberDescription mDesc(i, ta, JOINED, cID, dummyPDesc, dummyPRes);
roster.addMemberDescription(mDesc);
if ((i % module.getMaxPeerCount()) == 0) {
cID++;
}//End if
}
dis->setupGroupFromRoster(roster, module.getLocalAddress().getHostAddress().get4().getDByte(3));
}
/**
* @brief Getting a transportAddress for a given index.
* @param i The index of the peer a TA is searched for.
* @return The created TA.
*/
TransportAddress
PartitionApplication::getNewTransportAddress(int i) {
std::stringstream taStream;
taStream << "192.168.0." << i;
std::string s(taStream.str());
return TransportAddress(IPvXAddress(s.c_str()));
}
/**
* @brief Callback method. This method is called by moversight to signal that the local peer have receive a group data message.
* @param dat The received group data.
* @param sender The sending peer ID.
*/
void
PartitionApplication::receiveGroupData(const GroupData & dat, const PeerID sender) {
std::stringstream buf;
buf << "receiveGroupData - receive group data from peer ID " << sender;
DEBUG(buf.str().c_str());
VectorStatistic vs("receiveGroupData");
vs.record(GenericTime::currentTime());
}
/**
* @brief Handle an incoming JoinRequestEvent.
* @param e The event.
*
* The local instance has received an invitation.
*/
void
PartitionApplication::handleEvent(const JoinRequestEvent & e) {
DEBUG("invitationReceived - invitation received");
std::stringstream buf;
buf << "invitationReceived - invitationID: " << e.getInvitation().getInvitationID() << " inviterID: " << e.getInvitation().getInviterID();
DEBUG(buf.str().c_str());
DEBUG("invitationReceived - accept invitation");
PeerDescription pDesc;
PeerResources resources;
dis->acceptInvitation(e.getInvitation(), "accept invitation", pDesc, resources);
}
/**
* @brief Handle an incoming JonConfirmEvent.
* @param e The event.
*
* The remote peer has accepted the invitation from the local peer.
*/
void
PartitionApplication::handleEvent(const JoinConfirmEvent & e) {
std::stringstream buf;
buf << "receiveInvitationResponse - peer at TA: " << e.getInvitation().getInviteeAddress() << " accept invitation " << e.getInvitation().getInvitationID();
buf << " message: " << e.getMessage() << ", peer description: " << e.getDescription().getDescription();
DEBUG(buf.str().c_str());
}
/**
* @brief Handle an incoming JoinRejectedEvent.
* @param e The event.
*
* The invitation process was aborted.
*/
void
PartitionApplication::handleEvent(const JoinRejectedEvent & e) {
std::stringstream buf;
buf << "invitationAborted - invitation ID " << e.getInvitation().getInvitationID() << " aborted";
buf << " reason: " << e.getReason();
DEBUG(buf.str().c_str());
}
/**
* @brief Handle an incoming JoinAbortedEvent.
* @param e The event.
*
* The invitation process could not be executed.
*/
void
PartitionApplication::handleEvent(const JoinAbortedEvent & e) {
std::stringstream buf;
buf << "invitationAborted - invitation to peer " << e.getTransportAddress() << " aborted";
buf << " reason: " << e.getReason();
DEBUG(buf.str().c_str());
}
/**
* @brief Handle an incoming GroupCreatedEvent.
* @param e The event.
*/
void
PartitionApplication::handleEvent(const GroupCreatedEvent & e) {
groupSize = 1;
}
void
PartitionApplication::handleEvent(const PeerJoinedEvent & e) {
std::stringstream buf;
buf << "peerJoined - peer " << e.getPeerID()
<< "@TA_" << e.getTransportAddress() << " joined group successfully ("
<< e.getDescription().getDescription() << ")";
DEBUG(buf.str().c_str());
}
/**
* @brief Handle an incoming PendingPeersEvent.
* @param e The event.
*
* Some peers are pending.
*/
void
PartitionApplication::handleEvent(const PendingPeersEvent & e) {
std::stringstream buf;
buf << "peerIsPending - peer " << e.getPeerIDList() << " is pending";
DEBUG(buf.str().c_str());
}
/**
* @brief Handle an incoming PeerReconnectedEvent.
* @param e The event.
*
* A pending peers has reconnected.
*/
void
PartitionApplication::handleEvent(const PeerReconnectedEvent & e) {
std::stringstream buf;
buf << "peerReconnected - peer " << e.getPeerID() << " has reconnected";
DEBUG(buf.str().c_str());
}
/**
* @brief Handle an incoming PeerLeftEvent.
* @param e The event.
*
* A dedicated peer has left the group.
*/
void
PartitionApplication::handleEvent(const PeerLeftEvent & e) {
std::stringstream buf;
buf << "peerLeft - peer " << e.getPeer().getPeerID() << "@TA_" << e.getPeer().getLocalAddress() << " left the group";
DEBUG(buf.str().c_str());
}
/**
* @brief Handle an incoming RejoinDoneEvent.
* @param e The event.
*/
void
PartitionApplication::handleEvent(const RejoinDoneEvent & e) {
dis->signal(new StopMeasuringEvent("REJOIN"));
}
/**
* @brief Handle an incoming RejoinFailedEvent.
* @param e The event.
*/
void
PartitionApplication::handleEvent(const RejoinFailedEvent & e) {
}
/**
* @brief Handle an incoming StartMeasuringEvent.
* @param e The event.
*
* Starts the measuring of the given parameter.
*/
void
PartitionApplication::handleEvent(const StartMeasuringEvent & e) {
std::string startS = "start" + e.getMeasurement();
VectorStatistic vs(startS.c_str());
if (e.getMeasurement() == "REJOIN") {
vs.record(GenericTime::currentTime());
rejoinSucessDuration.startRecord();
}
if (e.getMeasurement() == "TG") {
vs.record(GenericTime::currentTime());
// leaveDelay.startRecord();
}
}
/**
* @brief Handle an incoming StopMeasuringEvent.
* @param e The event.
*
* Stops the measuring of the given parameter.
*/
void
PartitionApplication::handleEvent(const StopMeasuringEvent & e) {
std::string startS = "stop " + e.getMeasurement();
VectorStatistic vs(startS.c_str());
if (e.getMeasurement() == "REJOIN") {
vs.record(GenericTime::currentTime());
rejoinSucessDuration.startRecord();
}
if (e.getMeasurement() == "TG") {
vs.record(GenericTime::currentTime());
leaveDelay.stopRecord();
}
}
}//End namespace moversight
}//End namespace ubeeme

View File

@@ -0,0 +1,93 @@
/*
* File: PartitionApplication.h
* Author: gschneid
*
* Created on October 22, 2012, 11:09 AM
*/
#pragma once
#ifndef PARTITIONAPPLICATION_H
#define PARTITIONAPPLICATION_H
#include "Application.h"
#include "simutils/statistics/DurationStatisticRecorder.h"
#include "simutils/statistics/VectorStatisticRecorder.h"
#include "common/container/PeerIDList.h"
namespace ubeeme {
namespace moversight {
class Dispatcher;
class Moversight;
class Invitation;
/**
* @class PartitionApplication
* @brief Defines a small test application to test the moversight protocol.
*
* @ingroup Moversight
* @author Jan G&auml;bler
*/
class PartitionApplication : public Application {
public:
PartitionApplication(Moversight & m);
virtual ~PartitionApplication();
virtual void initialise();
virtual void finalise();
void startTestCase(unsigned int i);
void receiveGroupData(const GroupData & data, const PeerID sender);
// Event handling
virtual void handleEvent(const GroupCreatedEvent & e);
virtual void handleEvent(const JoinRequestEvent & e);
virtual void handleEvent(const JoinConfirmEvent & e);
virtual void handleEvent(const JoinRejectedEvent & e);
virtual void handleEvent(const JoinAbortedEvent & e);
virtual void handleEvent(const PeerJoinedEvent & e);
virtual void handleEvent(const PendingPeersEvent & e);
virtual void handleEvent(const PeerReconnectedEvent & e);
virtual void handleEvent(const PeerLeftEvent & e);
virtual void handleEvent(const RejoinDoneEvent & e);
virtual void handleEvent(const RejoinFailedEvent & e);
virtual void handleEvent(const StartMeasuringEvent & e);
virtual void handleEvent(const StopMeasuringEvent & e);
private:
void testCase00();
void invitePeer(TransportAddress & ta);
void leaveGroup();
void sendData();
void createRoster();
TransportAddress getNewTransportAddress(int i);
void setPendings(PeerIDList & pIdList);
DurationStatisticRecorder rejoinSucessDuration;
DurationStatisticRecorder leaveDelay;
size_t waitCounter;
size_t groupSize;
size_t lastGroupSize;
int numberOfPeers;
int clusterSize;
int numberOfMobilePeers;
};
}
}
#endif /* PARTITIONAPPLICATION_H */

View File

@@ -0,0 +1,86 @@
/*
* File: PeerDescription.cc
* Author: jgaebler
*
* Created on July 23, 2013, 4:00 PM
*/
#include "PeerDescription.h"
namespace ubeeme {
namespace moversight {
/**
* @brief Output operator
* @param s The stream to output
* @param pDesc The description to add to the output.
* @return The resulting output stream.
*/
std::ostream & operator<<(std::ostream & s, const PeerDescription & pDesc) {
s << pDesc.getDescription();
return s;
}
/**
* @brief Default Constructor
*/
PeerDescription::PeerDescription() : desc("dummy@moversight.org") {
}
/**
* @brief Constructor. Creates a new instance using the given string as description for the peer.
* @param d The string to use as peer description.
*/
PeerDescription::PeerDescription(const std::string & d) : desc(d) {
}
/**
* @brief Copy constructor
* @param other The instance to copy
*/
PeerDescription::PeerDescription(const PeerDescription & other) {
operator=(other);
}
/**
* @brief Destructor
*/
PeerDescription::~PeerDescription() {
}
/**
* @brief Returns a description of the given peer as string representation
* @returns A textual representation of the current peer description.
*/
std::string
PeerDescription::getDescription() const {
return desc;
}
/**
* @brief Serialization method
* @param archive the source and destination respectively of the serialization process.
*/
void
PeerDescription::set(Archive & archive) {
archive(desc);
}
/**
* @brief Assignment operator
* @param other The instance to assign
* @return A reference to the local object
*/
PeerDescription &
PeerDescription::operator=(const PeerDescription & other) {
if (this != &other) {
desc = other.desc;
}
return *this;
}
}
}

View File

@@ -0,0 +1,52 @@
// -*- C++ -*-
/*
* File: PeerDescription.h
* Author: jgaebler
*
* Created on September 28, 2010, 3:45 PM
*/
#pragma once
#ifndef PEERDESCRIPTION_H
#define PEERDESCRIPTION_H
#include "../core/serialization/serializable.h"
#include <string>
namespace ubeeme {
namespace moversight {
/**
* @class PeerDescription
* @author Jan G&auml;bler
* @ingroup Moversight
* @brief Provides a meta object which describe a peer within the moversight system, as the real name of a peer or this XMPP address.
*/
class PeerDescription : public Serializable {
public:
PeerDescription();
PeerDescription(const std::string & d);
PeerDescription(const PeerDescription & other);
virtual ~PeerDescription();
std::string getDescription() const;
virtual void set(Archive & archive);
PeerDescription & operator=(const PeerDescription & other);
protected:
/**
* The description of the peer, represented as string.
*/
std::string desc;
};
std::ostream & operator<<(std::ostream & s, const PeerDescription & pDesc);
}
}
#endif /* PEERDESCRIPTION_H */

View File

@@ -0,0 +1,366 @@
/*
* PeerplacingApplication.cc
*
* Created on: Apr 26, 2011
* Author: gschneid
*/
#include "PeerplacingApplication.h"
#include "Application.h"
#include "../Dispatcher.h"
#include "../Moversight.h"
#include "../common/transport/TransportAddress.h"
#include "../mt/msg/GroupData.h"
#include "../ms/Invitation.h"
#include "ms/events/JoinRequestEvent.h"
#include "ms/events/JoinConfirmEvent.h"
#include "ms/events/JoinRejectedEvent.h"
#include "ms/events/JoinAbortedEvent.h"
#include "ms/events/PeerJoinedEvent.h"
#include "ms/events/PeerLeftEvent.h"
#include "mt/events/PendingPeersEvent.h"
#include "fd/events/PeerReconnectedEvent.h"
#include "ms/events/PeerJoinedEvent.h"
#undef DEBUG
#define DEBUG(msg) if (module.isPrintDebugAPP()) \
MOV_DEBUG << "APP@"<<(dis->getLocalState()==DISJOINED?"TA_":"");\
if(dis->getLocalState()==DISJOINED){MOV_DEBUG << module.getLocalAddress();}\
else{MOV_DEBUG<< dis->getMembershipService().getLocalID();}MOV_DEBUG<<" "<<msg<<std::endl;
namespace ubeeme {
namespace moversight {
/**
* @brief Constructor
* @param m A reference to the moversight instance
*/
PeerplacingApplication::PeerplacingApplication(Moversight & m) : Application(m, "PeerPlacingApplication") {
WATCH(state);
}
/**
* @brief Destructor
*/
PeerplacingApplication::~PeerplacingApplication() {
}
void
PeerplacingApplication::initialise() {
dis->subscribe<PeerJoinedEvent>(this);
dis->subscribe<JoinRequestEvent>(this);
dis->subscribe<JoinConfirmEvent>(this);
dis->subscribe<JoinRejectedEvent>(this);
dis->subscribe<JoinAbortedEvent>(this);
dis->subscribe<PendingPeersEvent>(this);
dis->subscribe<PeerReconnectedEvent>(this);
dis->subscribe<PeerLeftEvent>(this);
}
void
PeerplacingApplication::finalise() {
}
/**
* @brief Invites a peer to a the moversight group.
* @param ta The transport address of the peer to invite.
*/
void
PeerplacingApplication::invitePeer(TransportAddress & ta) {
std::stringstream buf;
buf << "invitePeer - invite peer at address " << ta;
DEBUG(buf.str().c_str());
PeerDescription pDesc;
dis->invitePeer(ta, pDesc);
}
/**
* @brief Leaves the current group. The peer leafs the current group be
& emmiting a LeaveAnnounce within the current group.
*/
void
PeerplacingApplication::leaveGroup() {
DEBUG("leaveGroup - peer leave the group");
dis->leaveGroup();
}
/**
* @brief Sends dummy data to the group to simulate application traffic.
*/
void
PeerplacingApplication::sendData() {
DEBUG("sendData - send 24 byte dummy data to the group");
GroupData data;
dis->sendMessage(data);
}//End
/**
* @brief Starst the given test case.
* @param i The number of the test case to start.
*/
void
PeerplacingApplication::startTestCase(unsigned int i) {
switch (i) {
case 0:
testCase00();
break;
case 1:
testCase01();
break;
case 2:
testCase02();
break;
default:
break;
}//End switch
}//End startTestCase
/**
* @brief Executes test case 00
*/
void
PeerplacingApplication::testCase00() {
// state = dis->getLocalState();
// int moduleIndex = module.getLocalAddress().getHostAddress();
// if (initApp) {
//
// const char *candidateString = module.par("candidates");
// cStringTokenizer tokenizer(candidateString);
// while (tokenizer.hasMoreTokens()) {
// candidates.add(atoi(tokenizer.nextToken()));
// }//End while
// waitCounter = 5;
// initApp = false;
// count = 1;
//
// if (moduleIndex == 0) {
// count = 0;
// module.scheduleTestCase(45);
// }//End if
// }//End if
//
// //------------------------------------------------------------------
// //run the app
// //------------------------------------------------------------------
// if (moduleIndex == 0) {
// //do we have more candidates?
//
// if (waitCounter > 0) {
// waitCounter--;
// module.scheduleTestCase(45);
// }
// if (candidatesIndex < candidates.size()) {
// invitePeer(candidates.get(candidatesIndex++));
// if (candidatesIndex == candidates.size()) {
// module.scheduleTestCase(240);
// waitCounter = 50;
// }
// else {
// module.scheduleTestCase(45);
// }
// count = 1;
// }
// else {
// //Only leave if all the others are in their cluster
// if (waitCounter > 0) {
// waitCounter--;
// module.scheduleTestCase(90);
// }
// // else{
// // leaveGroup();
// // initApp = true;
// // module.scheduleTestCase(45);
// // waitCounter = 8;
// // }
// }//End else
// }//End if
// else if (moduleIndex > 0) {
// if (count == 1 && moduleIndex == 5) {
// waitCounter = 60;
// module.scheduleTestCase(250);
// count = 0;
// }
// else if (count == 1 && moduleIndex != 1) {
// waitCounter = (moduleIndex - 1) * 8;
// module.scheduleTestCase((moduleIndex - 1)*45);
// count = 0;
// }
// else {
// if (waitCounter > 0) {
// waitCounter--;
// module.scheduleTestCase(45);
// }
// else {
// //do we have more candidates?
// if (candidatesIndex < candidates.size()) {
// invitePeer(candidates.get(candidatesIndex++));
// count = 0;
// module.scheduleTestCase(45);
// if (module.getLocalAddress().getHostAddress() == 5) {
// waitCounter = 15;
// }
// }//End if
// }
// }
// }
}
/**
* @brief Executes test case 01.
*/
void
PeerplacingApplication::testCase01() {
throw NotImplementedYetException("run test case 01 not implemented ");
}
/**
* @brief Executes test case 02.
*/
void
PeerplacingApplication::testCase02() {
throw NotImplementedYetException("run test case 02 not implemented ");
}
/**
* @brief Callback method. This method is called by moversight to signal that the local peer have receive a group data message.
* @param dat The received group data.
* @param sender The sending peer ID.
*/
void
PeerplacingApplication::receiveGroupData(const GroupData & data, const PeerID sender) {
std::stringstream buf;
buf << "receiveGroupData - receive group data from peer ID " << sender;
DEBUG(buf.str().c_str());
}
/**
* @brief Handle an incoming JoinRequestEvent.
* @param e The event.
*
* The local instance has received an invitation.
*/
void
PeerplacingApplication::handleEvent(const JoinRequestEvent & e) {
DEBUG("invitationReceived - invitation received");
std::stringstream buf;
buf << "invitationReceived - invitationID: " << e.getInvitation().getInvitationID() << " inviterID: " << e.getInvitation().getInviterID();
DEBUG(buf.str().c_str());
DEBUG("invitationReceived - accept invitation");
PeerDescription pDesc;
PeerResources resources;
dis->acceptInvitation(e.getInvitation(), "accept invitation", pDesc, resources);
}
/**
* @brief Handle an incoming JoinConfirmEvent.
* @param e The event.
*
* The remote peer has accepted the invitation from the local peer.
*/
void
PeerplacingApplication::handleEvent(const JoinConfirmEvent & e) {
std::stringstream buf;
buf << "receiveInvitationResponse - peer at TA: " << e.getInvitation().getInviteeAddress() << " accept invitation " << e.getInvitation().getInvitationID();
buf << " message: " << e.getMessage() << ", peer description: " << e.getDescription().getDescription();
DEBUG(buf.str().c_str());
}
/**
* @brief Handle an incoming JoinRejectedEvent.
* @param e The event.
*
* The invitation was rejected by the remote peer.
*/
void
PeerplacingApplication::handleEvent(const JoinRejectedEvent & e) {
std::stringstream buf;
buf << "invitationAborted - invitation ID " << e.getInvitation().getInvitationID() << " aborted";
buf << " reason: " << e.getReason();
DEBUG(buf.str().c_str());
}
/**
* @brief Handle an incoming JoinAbortedEvent.
* @param e The event.
*
* The invitation process could not be executed.
*/
void
PeerplacingApplication::handleEvent(const JoinAbortedEvent & e) {
std::stringstream buf;
buf << "invitationAborted - invitation to peer " << e.getTransportAddress() << " aborted";
buf << " reason: " << e.getReason();
DEBUG(buf.str().c_str());
}
/**
* @brief Handle an incoming PeerJoinedEvent.
* @param e The event.
*
* A peer has joined the group.
*/
void
PeerplacingApplication::handleEvent(const PeerJoinedEvent & e) {
std::stringstream buf;
buf << "peerJoined - peer " << e.getPeerID() << "@TA_" << e.getTransportAddress() << " joined group successfully (" << e.getDescription().getDescription() << ")";
DEBUG(buf.str().c_str());
}
/**
* @brief Handle an incoming PendingPeersEvent.
* @param e The event.
*
* A list of peers is pending.
*/
void
PeerplacingApplication::handleEvent(const PendingPeersEvent & e) {
std::stringstream buf;
buf << "peerIsPending - peer " << e.getPeerIDList() << " is pending";
DEBUG(buf.str().c_str());
}
/**
* @brief Handle an incoming PeerReconnectedEvent.
* @param e The event.
*
* A pending peer has reconnected.
*/
void
PeerplacingApplication::handleEvent(const PeerReconnectedEvent & e) {
std::stringstream buf;
buf << "peerReconnected - peer " << e.getPeerID() << " is reconnected";
DEBUG(buf.str().c_str());
}
/**
* @brief Handle an incoming PeerLeftEvent.
* @param e The event.
*
* A dedicated peer has left the group.
*/
void
PeerplacingApplication::handleEvent(const PeerLeftEvent & e) {
std::stringstream buf;
buf << "peerLeft - peer " << e.getPeer().getPeerID() << "@TA_" << e.getPeer().getLocalAddress() << " left the group";
DEBUG(buf.str().c_str());
}
}//End namespace moversight
}//End namespace ubeeme

View File

@@ -0,0 +1,70 @@
/*
* PeerplacingApplication.h
*
* Created on: Apr 26, 2011
* Author: gschneid
*/
#ifndef PEERPLACINGAPPLICATION_H_
#define PEERPLACINGAPPLICATION_H_
#include "Application.h"
#include "common/Defines.h"
#include "ms/PeerState.h"
namespace ubeeme {
namespace moversight {
class Dispatcher;
class Moversight;
class Invitation;
/**
* @brief Defines a small test application to test the moversight protocoll.
* @ingroup Moversight
* @class TestApplication
* @author Grit Schneider
*/
class PeerplacingApplication : public Application {
public:
PeerplacingApplication(Moversight & m);
virtual ~PeerplacingApplication();
virtual void initialise();
virtual void finalise();
void startTestCase(unsigned int i);
void receiveGroupData(const GroupData & data, const PeerID sender);
// Event handling
virtual void handleEvent(const JoinRequestEvent & e);
virtual void handleEvent(const JoinConfirmEvent & e);
virtual void handleEvent(const JoinRejectedEvent & e);
virtual void handleEvent(const JoinAbortedEvent & e);
virtual void handleEvent(const PeerJoinedEvent & e);
virtual void handleEvent(const PendingPeersEvent & e);
virtual void handleEvent(const PeerReconnectedEvent & e);
virtual void handleEvent(const PeerLeftEvent & e);
private:
void testCase00();
void testCase01();
void testCase02();
void invitePeer(TransportAddress & ta);
void leaveGroup();
void sendData();
PeerState state;
int waitCounter;
int count;
};
}
}
#endif /* PEERPLACINGAPPLICATION_H_ */

View File

@@ -0,0 +1,200 @@
/*
* File: PendingTestApplication.cc
* Author: jgaebler
*
* Created on February 19, 2013, 5:01 PM
*/
#include "PendingTestApplication.h"
#include "Dispatcher.h"
#include "Moversight.h"
#include "common/transport/TransportAddress.h"
#include "mt/msg/GroupData.h"
#include "ms/Invitation.h"
#include "simutils/OmnetppIniUtils.h"
#include "ms/events/PeerLeftEvent.h"
#include "fd/events/PeerReconnectedEvent.h"
#include "mt/events/PendingPeersEvent.h"
#include "ms/events/JoinRequestEvent.h"
#include "ms/events/JoinConfirmEvent.h"
#include "ms/events/JoinRejectedEvent.h"
#include "ms/events/JoinAbortedEvent.h"
#undef DEBUG
#define DEBUG(msg) if (module.isPrintDebugAPP()) \
MOV_DEBUG << "APP@"<<(dis->getLocalState()==DISJOINED?"TA_":"");\
if(dis->getLocalState()==DISJOINED){MOV_DEBUG << module.getLocalAddress();}\
else{MOV_DEBUG<< dis->getMembershipService().getLocalID();}MOV_DEBUG<<" "<<msg<<std::endl;
namespace ubeeme {
namespace moversight {
PendingTestApplication::PendingTestApplication(Moversight & m) : Application(m, "PendingTestApplication") {
}
PendingTestApplication::~PendingTestApplication() {
}
void
PendingTestApplication::initialise() {
dis->subscribe<PeerLeftEvent>(this);
dis->subscribe<PeerReconnectedEvent>(this);
dis->subscribe<PendingPeersEvent>(this);
dis->subscribe<JoinRequestEvent>(this);
dis->subscribe<JoinConfirmEvent>(this);
dis->subscribe<JoinAbortedEvent>(this);
dis->subscribe<JoinRejectedEvent>(this);
}
void
PendingTestApplication::finalise() {
}
void
PendingTestApplication::startTestCase(unsigned int i) {
switch (i) {
case 0:
testCase00();
break;
default:
break;
}//End switch
}
void
PendingTestApplication::receiveGroupData(const GroupData & data, const PeerID sender) {
std::stringstream buf;
buf << "receiveGroupData - receive group data from peer ID " << sender;
DEBUG(buf.str().c_str());
}
void
PendingTestApplication::testCase00() {
int moduleIndex = module.getLocalAddress().getHostAddress().get4().getDByte(3);
if (initApp) {
candidates = OmnetppIniUtils::getDestinationAddressesFromOmnetppIni(module);
initApp = false;
if (moduleIndex == 1) {
module.scheduleTestCase(45);
}//End if
}//End if
//------------------------------------------------------------------
//run the app
//------------------------------------------------------------------
if (moduleIndex == 1) { // starts counting at 1
//we have more candidates?
if (candidates.size() > 0) {
invitePeer(candidates.first());
candidates.pop();
}
else {
sendData();
}
module.scheduleTestCase(45);
}//End if
}
void
PendingTestApplication::invitePeer(TransportAddress & ta) {
std::stringstream buf;
buf << "invitePeer - invite peer at address " << ta;
DEBUG(buf.str().c_str());
PeerDescription pDesc;
;
dis->invitePeer(ta, pDesc);
}
void
PendingTestApplication::leaveGroup() {
DEBUG("leaveGroup - peer leave the group");
dis->leaveGroup();
}
void
PendingTestApplication::sendData() {
DEBUG("sendData - send 24 byte dummy data to the group");
GroupData data;
dis->sendMessage(data);
}
void
PendingTestApplication::handleEvent(const JoinRequestEvent & e) {
DEBUG("JoinRequest - invitation received");
std::stringstream buf;
buf << "JoinRequest - invitationID: " << e.getInvitation().getInvitationID() << " inviterID: " << e.getInvitation().getInviterID();
DEBUG(buf.str().c_str());
DEBUG("JoinRequest - accept invitation");
PeerDescription pDesc;
PeerResources resources;
dis->acceptInvitation(e.getInvitation(), "accept invitation", pDesc, resources);
}
void
PendingTestApplication::handleEvent(const JoinConfirmEvent & e) {
std::stringstream buf;
buf << "JoinConfirm - peer at TA: " << e.getInvitation().getInviteeAddress() << " accept invitation " << e.getInvitation().getInvitationID();
buf << " message: " << e.getMessage() << ", peer description: " << e.getDescription().getDescription();
DEBUG(buf.str().c_str());
}
void
PendingTestApplication::handleEvent(const JoinRejectedEvent & e) {
std::stringstream buf;
buf << "JoinRejected - invitation ID " << e.getInvitation().getInvitationID() << " aborted";
buf << " reason: " << e.getReason();
DEBUG(buf.str().c_str());
}
void
PendingTestApplication::handleEvent(const JoinAbortedEvent & e) {
std::stringstream buf;
buf << "JoinNotExecutable - invitation to peer " << e.getTransportAddress() << " aborted";
buf << " reason: " << e.getReason();
DEBUG(buf.str().c_str());
}
void
PendingTestApplication::handleEvent(const PendingPeersEvent & e) {
std::stringstream buf;
buf << "PendingPeers - peers " << e.getPeerIDList() << " are pending";
DEBUG(buf.str().c_str());
}
void
PendingTestApplication::handleEvent(const PeerReconnectedEvent & e) {
std::stringstream buf;
buf << "PeerReconnect - peer " << e.getPeerID() << " is reconnected";
DEBUG(buf.str().c_str());
}
void
PendingTestApplication::handleEvent(const PeerLeftEvent & e) {
std::stringstream buf;
buf << "PeerLeft - peer " << e.getPeer().getPeerID() << "@TA_" << e.getPeer().getLocalAddress() << " left the group";
DEBUG(buf.str().c_str());
}
}
}

View File

@@ -0,0 +1,64 @@
/*
* File: PendingTestApplication.h
* Author: jgaebler
*
* Created on February 19, 2013, 5:01 PM
*/
#pragma once
#ifndef PENDINGTESTAPPLICATION_H
#define PENDINGTESTAPPLICATION_H
#include "Application.h"
namespace ubeeme {
namespace moversight {
class Dispatcher;
class Moversight;
class Invitation;
/**
* @class PendingTestApplication
* @author Jan G&auml;bler
* @brief An test application to test the protocol services related to
* pending peer issues.
* @ingroup Moversight
*/
class PendingTestApplication : public Application {
public:
PendingTestApplication(Moversight & m);
virtual ~PendingTestApplication();
virtual void initialise();
virtual void finalise();
void startTestCase(unsigned int inv);
void receiveGroupData(const GroupData & data, const PeerID sender);
// Event handling
virtual void handleEvent(const JoinRequestEvent & e);
virtual void handleEvent(const JoinConfirmEvent & e);
virtual void handleEvent(const JoinRejectedEvent & e);
virtual void handleEvent(const JoinAbortedEvent & e);
virtual void handleEvent(const PendingPeersEvent & e);
virtual void handleEvent(const PeerReconnectedEvent & e);
virtual void handleEvent(const PeerLeftEvent & e);
private:
void testCase00();
void invitePeer(TransportAddress & ta);
void leaveGroup();
void sendData();
};
}
}
#endif /* PENDINGTESTAPPLICATION_H */

View File

@@ -0,0 +1,688 @@
/*
* File: SplitApplication.h
* Author: sgaebler
*
* Created on April 12, 2011, 04:37 PM
*/
#include "SplitApplication.h"
#include "Dispatcher.h"
#include "Moversight.h"
#include "app/Application.h"
#include "common/transport/TransportAddress.h"
#include "merge/events/MergeRequestEvent.h"
#include "ms/Invitation.h"
#include "ms/PeerResources.h"
#include "ms/events/PeerJoinedEvent.h"
#include "ms/events/JoinConfirmEvent.h"
#include "ms/events/JoinRequestEvent.h"
#include "ms/events/JoinRejectedEvent.h"
#include "ms/events/JoinAbortedEvent.h"
#include "ms/events/PeerLeftEvent.h"
#include "mt/msg/GroupData.h"
#include "mt/events/PendingPeersEvent.h"
#include "fd/events/PeerReconnectedEvent.h"
#include "simutils/statistics/DurationStatisticRecorder.h"
#include "simutils/OmnetppIniUtils.h"
#include "split/events/SplitDoneEvent.h"
#undef DEBUG
#define DEBUG(msg) if (module.isPrintDebugAPP()) \
MOV_DEBUG << "APP@"<<(dis->getLocalState()==DISJOINED?"TA_":"");\
if(dis->getLocalState()==DISJOINED){MOV_DEBUG << module.getLocalAddress();}\
else{MOV_DEBUG<< dis->getMembershipService().getLocalID();}MOV_DEBUG<<" "<<msg<<std::endl;
//defines a test options parameter
//Bitlesrichtung-->
//bit 0: semantic flag
//bit 1: flush flag
//bit 2: reply flag
//bit 3-7: leer
#define TEST_OPTIONS 20 //0b00100000
namespace ubeeme {
namespace moversight {
/**
* @brief constructor
* @param m The moversight module
*/
SplitApplication::SplitApplication(Moversight & m) : Application(m, "SplitApplication"), joinDelayStat(m, "joinDelay") {
WATCH(state);
splitOnce = false;
splitDuration.setName("splitDuration");
splitDuration.setUnit("s");
numberOfPeers = module.par("numberOfPeers");
numberOfClusters = numberOfPeers / module.getMaxPeerCount();
dt = 0.0;
}
/**
* @brief destructor
*/
SplitApplication::~SplitApplication() {
}
void
SplitApplication::initialise() {
dis->subscribe<PeerJoinedEvent>(this);
dis->subscribe<JoinConfirmEvent>(this);
dis->subscribe<JoinRequestEvent>(this);
dis->subscribe<JoinRejectedEvent>(this);
dis->subscribe<JoinAbortedEvent>(this);
dis->subscribe<PeerLeftEvent>(this);
dis->subscribe<PeerReconnectedEvent>(this);
dis->subscribe<SplitDoneEvent>(this);
dis->subscribe<MergeRequestEvent>(this);
}
void
SplitApplication::finalise() {
}
/**
* @brief Invites a peer
* @param ta The address to invite
*/
void
SplitApplication::invitePeer(TransportAddress & ta) {
std::stringstream buf;
buf << "invitePeer - invite peer at address " << ta;
DEBUG(buf.str().c_str());
PeerDescription pDesc;
dis->invitePeer(ta, pDesc);
joinDelayStat.startRecord();
}
/**
* @brief Leaves the group
*/
void
SplitApplication::leaveGroup() {
DEBUG("leaveGroup - peer leave the group");
dis->leaveGroup();
}
/**
* @brief Sends dummy test data to the group
*/
void
SplitApplication::sendData() {
DEBUG("sendData - send 24 byte dummy data to the group");
GroupData data;
dis->sendMessage(data);
}//End
void
SplitApplication::splitGroup(unsigned char options, PeerIDList splitPeers) {
DEBUG("splitPeers - the group is splitting");
dis->splitGroup(options, splitPeers);
VectorStatistic vs("splitGroup");
vs.record(GenericTime::currentTime());
}//End
/**
* @brief Tries to start the given test case.
* @param i The test case to start
*/
void
SplitApplication::startTestCase(unsigned int i) {
switch (i) {
case 0:
testCase00();
break;
case 1:
testCase01();
break;
case 2:
testCase02();
break;
case 3:
testCase03();
break;
case 4:
testCase04();
break;
case 5:
testCase05(); // bis hier splitcases abgedeckt
break;
case 6:
testCase06();
break;
case 7:
testCase07();
break;
case 8:
testCase08();
break;
default:
break;
}//End switch
}
/**
* @brief Test case 0: complete Cluster
*/
void
SplitApplication::testCase00() {
// init app
if (initApp) {
createRoster(numberOfPeers + 1, numberOfClusters);
}
//------------------------------------------------------------------
//run the app
//------------------------------------------------------------------
if (module.getLocalAddress().getHostAddress().get4().getDByte(3) == 1) {
if (dis->getMembershipService().getLocalState() == JOINED) {
if (!splitOnce) {
splitOnce = true;
PeerList peerList = dis->getMembershipService().getPeerList();
PeerIDList pIdList;
for (size_t i = 0; i < peerList.size(); i++) {
if (peerList.get(i).getClusterID() == 0) {
pIdList.add(peerList.get(i).getPeerID());
}//End if
}//end for
splitGroup(TEST_OPTIONS, pIdList); //SPLITreq
module.scheduleTestCase(45);
}//End if
}//End if
}//End if
}
/**
* @brief Test case1: whole masters
*/
void
SplitApplication::testCase01() {
// init app
if (initApp) {
createRoster(numberOfPeers + 1, numberOfClusters);
}
//------------------------------------------------------------------
//run the app
//----------------------------------
if (module.getLocalAddress().getHostAddress().get4().getDByte(3) == 1) {
if (dis->getMembershipService().getLocalState() == JOINED) {
if (!splitOnce) {
splitOnce = true;
PeerIDList pidl;
pidl.add(dis->getMembershipService().getMasterPeerIDList());
splitGroup(TEST_OPTIONS, pidl); //SPLITreq
module.scheduleTestCase(45);
}//End if
}//End if
}//End if
}
/**
* @brief Test case2: <50% of slaves
*/
void
SplitApplication::testCase02() {
// init app
if (initApp) {
createRoster(numberOfPeers + 1, numberOfClusters);
}
//------------------------------------------------------------------
//run the app
//----------------------------------
if (module.getLocalAddress().getHostAddress().get4().getDByte(3) == 1) {
if (dis->getMembershipService().getLocalState() == JOINED) {
if (!splitOnce) {
splitOnce = true;
PeerIDList pidl;
int numberOfSlavesToAdd = (numberOfPeers - numberOfClusters) / 2 - 1;
PeerIDList peersToAdd = getSpecifiedNumberOfPeers(false, numberOfSlavesToAdd, numberOfClusters);
pidl.add(peersToAdd);
splitGroup(TEST_OPTIONS, pidl); //SPLITreq
module.scheduleTestCase(45);
}//End if
}//End if
}//End if
}
/**
* @brief Test case3: >= 50% of slaves
*/
void
SplitApplication::testCase03() {
// init app
if (initApp) {
createRoster(numberOfPeers + 1, numberOfClusters);
}
//------------------------------------------------------------------
//run the app
//----------------------------------
if (module.getLocalAddress().getHostAddress().get4().getDByte(3) == 1) {
if (dis->getMembershipService().getLocalState() == JOINED) {
if (!splitOnce) {
splitOnce = true;
PeerIDList pidl;
int numberOfSlavesToAdd = (numberOfPeers - numberOfClusters) / 2;
PeerIDList peersToAdd = getSpecifiedNumberOfPeers(false, numberOfSlavesToAdd, numberOfClusters);
pidl.add(peersToAdd);
splitGroup(TEST_OPTIONS, pidl); //SPLITreq
module.scheduleTestCase(45);
}//End if
}//End if
}//End if
}
/**
* @brief Test case4: <50% mixed
*/
void
SplitApplication::testCase04() {
// init app
if (initApp) {
createRoster(numberOfPeers + 1, numberOfClusters);
}
//------------------------------------------------------------------
//run the app
//----------------------------------
if (module.getLocalAddress().getHostAddress().get4().getDByte(3) == 1) {
if (dis->getMembershipService().getLocalState() == JOINED) {
if (!splitOnce) {
splitOnce = true;
PeerIDList pidl;
int numberOfSlavesToAdd = numberOfPeers / 2 - 1;
PeerIDList peersToAdd = getSpecifiedNumberOfPeers(true, numberOfSlavesToAdd, numberOfClusters);
pidl.add(peersToAdd);
splitGroup(TEST_OPTIONS, pidl); //SPLITreq
module.scheduleTestCase(45);
}//End if
}//End if
}//End if
}
/**
* @brief Test case5: >= 50% mixed
*/
void
SplitApplication::testCase05() {
// init app
if (initApp) {
createRoster(numberOfPeers + 1, numberOfClusters);
}
//------------------------------------------------------------------
//run the app
//----------------------------------
if (module.getLocalAddress().getHostAddress().get4().getDByte(3) == 1) {
if (dis->getMembershipService().getLocalState() == JOINED) {
if (!splitOnce) {
splitOnce = true;
PeerIDList pidl;
int numberOfSlavesToAdd = numberOfPeers / 2;
PeerIDList peersToAdd = getSpecifiedNumberOfPeers(true, numberOfSlavesToAdd, numberOfClusters);
pidl.add(peersToAdd);
splitGroup(TEST_OPTIONS, pidl); //SPLITreq
module.scheduleTestCase(45);
}//End if
}//End if
}//End if
}
/**
* @brief Test case 6: 6 peers cs 6 (Join - split)
*/
void
SplitApplication::testCase06() {
int moduleIndex = module.getLocalAddress().getHostAddress().get4().getDByte(3);
if (initApp) {
candidates = OmnetppIniUtils::getDestinationAddressesFromOmnetppIni(module);
waitCounter = 5;
initApp = false;
if (moduleIndex == 1) {
module.scheduleTestCase(45);
}//End if
}//End if
if (moduleIndex == 1) {
//we have more candidates?
if (candidates.size() > 0) {
if (waitCounter > 0) {
waitCounter--;
module.scheduleTestCase(45);
}
if (candidatesIndex < candidates.size()) {
invitePeer(candidates.get(candidatesIndex++));
module.scheduleTestCase(45);
}
else {
if (dis->getMembershipService().getLocalState() == JOINED) {
if (!splitOnce) {
splitOnce = true;
PeerIDList pidl;
int numberOfSlavesToAdd = 3;
PeerIDList peersToAdd = getSpecifiedNumberOfPeers(true, numberOfSlavesToAdd, 1);
pidl.add(peersToAdd);
splitGroup(TEST_OPTIONS, pidl); //SPLITreq
module.scheduleTestCase(45);
}
}
}
}
}
}
/**
* @brief Test case 7: 24 peers cs 6 (Join - split)
*/
void
SplitApplication::testCase07() {
int moduleIndex = module.getLocalAddress().getHostAddress().get4().getDByte(3);
if (initApp) {
candidates = OmnetppIniUtils::getDestinationAddressesFromOmnetppIni(module);
waitCounter = 5;
initApp = false;
if (moduleIndex == 1) {
module.scheduleTestCase(45);
}//End if
}//End if
if (moduleIndex == 1) {
//we have more candidates?
if (candidates.size() > 0) {
if (waitCounter > 0) {
waitCounter--;
module.scheduleTestCase(45);
}
if (candidatesIndex < candidates.size()) {
invitePeer(candidates.get(candidatesIndex++));
module.scheduleTestCase(45);
}
else {
if (dis->getMembershipService().getLocalState() == JOINED) {
if (!splitOnce) {
splitOnce = true;
PeerIDList pidl;
int numberOfSlavesToAdd = 12;
PeerIDList peersToAdd = getSpecifiedNumberOfPeers(true, numberOfSlavesToAdd, 4);
pidl.add(peersToAdd);
splitGroup(TEST_OPTIONS, pidl); //SPLITreq
module.scheduleTestCase(45);
}
}
}
}
}
}
/**
* @brief Test case 8: 96 peers cs 6 (Join - split)
*/
void
SplitApplication::testCase08() {
int moduleIndex = module.getLocalAddress().getHostAddress().get4().getDByte(3);
if (initApp) {
candidates = OmnetppIniUtils::getDestinationAddressesFromOmnetppIni(module);
waitCounter = 5;
initApp = false;
if (moduleIndex == 1) {
module.scheduleTestCase(45);
}//End if
}//End if
if (moduleIndex == 1) {
//we have more candidates?
if (candidates.size() > 0) {
if (waitCounter > 0) {
waitCounter--;
module.scheduleTestCase(45);
}
if (candidatesIndex < candidates.size()) {
invitePeer(candidates.get(candidatesIndex++));
module.scheduleTestCase(45);
}
else {
if (dis->getMembershipService().getLocalState() == JOINED) {
if (!splitOnce) {
splitOnce = true;
PeerIDList pidl;
int numberOfSlavesToAdd = 48;
PeerIDList peersToAdd = getSpecifiedNumberOfPeers(true, numberOfSlavesToAdd, 8);
pidl.add(peersToAdd);
splitGroup(TEST_OPTIONS, pidl); //SPLITreq
module.scheduleTestCase(45);
}
}
}
}
}
}
/**
* @brief Adding the specified number of peers to the peerIDList
* @param mixed - if true: master and slaves, if false: only slaves
* @param numberOfPeersToAdd - how many peers to add to the list
* @param numberOfClusters - number of clusters in the network
* @return PeerIDList with the peers to split
*/
PeerIDList
SplitApplication::getSpecifiedNumberOfPeers(bool mixed, int numberOfPeersToAdd, int numberOfClusters) {
PeerIDList peersToAdd;
for (int i = 0; i < numberOfClusters; i++) {
PeerIDList possiblePeers;
if (mixed) {
possiblePeers = dis->getMembershipService().getPeerIDList();
}
else {
possiblePeers = dis->getMembershipService().getClusterPeerIDListSlavesOnly(i);
}
for (unsigned int j = 0; j < possiblePeers.size(); j++) {
peersToAdd.add(possiblePeers.get(j));
if (peersToAdd.size() == (unsigned) numberOfPeersToAdd) {
break;
}
}
if (peersToAdd.size() == (unsigned) numberOfPeersToAdd) {
break;
}
}
return peersToAdd;
}
/**
* @brief Creates a new Roster for the given peers and clusters
* @param nextPeerId - the next peer id that can be used
* @param numberOfClusters - the number of clusters to create
*/
void
SplitApplication::createRoster(int nextPeerId, int numberOfClusters) {
Roster roster;
roster.setNextPeerID(nextPeerId);
roster.setViewID(nextPeerId);
PeerDescription dummyPDesc;
PeerResources dummyPRes;
ClusterID cID = 0;
for (unsigned int i = 1; i <= numberOfPeers; i++) {
TransportAddress ta = getNewTransportAddress(i);
ta.setPort(module.getLocalAddress().getPort());
MemberDescription mDesc(i, ta, JOINED, cID, dummyPDesc, dummyPRes);
roster.addMemberDescription(mDesc);
if ((i % module.getMaxPeerCount()) == 0) {
cID++;
}//End if
}//end for
//set up group for each peer
dis->setupGroupFromRoster(roster, module.getLocalAddress().getHostAddress().get4().getDByte(3));
dt = simTime();
}
/**
* @brief Create a new TransportAddress with the given index
* @param i - index to create the TransportAddress with
* @return the created transportaddress
*/
TransportAddress
SplitApplication::getNewTransportAddress(int i) {
std::stringstream taStream;
taStream << "192.168.0." << i;
std::string s(taStream.str());
return TransportAddress(IPvXAddress(s.c_str()));
}
void
SplitApplication::receiveGroupData(const GroupData & dat, const PeerID sender) {
std::stringstream buf;
buf << "receiveGroupData - receive group data from peer ID " << sender;
DEBUG(buf.str().c_str());
}
/**
* @brief Handle an incoming JoinRequestEvent.
* @param The event.
*
* Received an invitation from from a group
*/
void
SplitApplication::handleEvent(const JoinRequestEvent & e) {
DEBUG("invitationReceived - invitation received");
std::stringstream buf;
buf << "invitationReceived - invitationID: " << e.getInvitation().getInvitationID() << " inviterID: " << e.getInvitation().getInviterID();
DEBUG(buf.str().c_str());
DEBUG("invitationReceived - accept invitation");
PeerDescription pDesc;
PeerResources resources;
dis->acceptInvitation(e.getInvitation(), "accept invitation", pDesc, resources);
}
/**
* @brief Handle an incoming JoinConfirmEvent.
* @param The event.
*
* An invitation was accepted by the foreign host.
*/
void
SplitApplication::handleEvent(const JoinConfirmEvent & e) {
std::stringstream buf;
buf << "receiveInvitationResponse - peer at TA: " << e.getInvitation().getInviteeAddress() << " accept invitation " << e.getInvitation().getInvitationID();
buf << " message: " << e.getMessage() << ", peer description: " << e.getDescription().getDescription();
DEBUG(buf.str().c_str());
}
void
SplitApplication::handleEvent(const JoinRejectedEvent & e) {
std::stringstream buf;
buf << "invitationAborted - invitation ID " << e.getInvitation().getInvitationID() << " aborted";
buf << " reason: " << e.getReason();
DEBUG(buf.str().c_str());
}
void
SplitApplication::handleEvent(const JoinAbortedEvent & e) {
std::stringstream buf;
buf << "invitationAborted - invitation to peer " << e.getTransportAddress() << " aborted";
buf << " reason: " << e.getReason();
DEBUG(buf.str().c_str());
}
void
SplitApplication::handleEvent(const PeerJoinedEvent & e) {
std::stringstream buf;
buf << "peerJoined - peer " << e.getPeerID() << "@TA_" << e.getTransportAddress() << " joined group successfully (" << e.getDescription().getDescription() << ")";
DEBUG(buf.str().c_str());
}
void
SplitApplication::handleEvent(const PendingPeersEvent & e) {
std::stringstream buf;
buf << "peerIsPending - peer " << e.getPeerIDList() << " is pending";
DEBUG(buf.str().c_str());
}
void
SplitApplication::handleEvent(const PeerReconnectedEvent & e) {
std::stringstream buf;
buf << "peerReconnected - peer " << e.getPeerID() << " is reconnected";
DEBUG(buf.str().c_str());
}
/**
* @brief Signals, that a dedicated peer has left the group.
* @param peer The left peer.
*/
void
SplitApplication::handleEvent(const PeerLeftEvent & e) {
std::stringstream buf;
buf << "peerLeft - peer " << e.getPeer().getPeerID() << "@TA_" << e.getPeer().getLocalAddress() << " left the group";
DEBUG(buf.str().c_str());
}
/**
* @brief Signals that a split is done
*/
void
SplitApplication::handleEvent(const SplitDoneEvent & e) {
#if OMNETPP
splitDuration.recordWithTimestamp(simTime() - dt, numberOfPeers);
VectorStatistic vs("splitDone");
vs.record(GenericTime::currentTime());
if (module.getLocalAddress().getHostAddress().get4().getDByte(3) == 1) {
TransportAddress ta;
ta = getNewTransportAddress(3);
dis->mergeGroup(ta);
}
#endif
}
void
SplitApplication::handleEvent(const MergeRequestEvent & e) {
dis->acceptGroupMerge();
}
}//End namespace moversight
}//End namespace ubeeme

View File

@@ -0,0 +1,92 @@
/*
* File: SplitApplication.h
* Author: sgaebler
*
* Created on April 12, 2011, 04:37 PM
*/
#ifndef SPLITAPPLICATION_H
#define SPLITAPPLICATION_H
#include "Application.h"
#include "common/Defines.h"
#include "ms/PeerState.h"
#include "common/container/PeerIDList.h"
#include "simutils/statistics/DurationStatisticRecorder.h"
namespace ubeeme {
namespace moversight {
class Dispatcher;
class Moversight;
class Invitation;
class SplitApplication : public Application {
public:
SplitApplication(Moversight & m);
virtual ~SplitApplication();
virtual void initialise();
virtual void finalise();
void startTestCase(unsigned int i);
// Event handling
virtual void handleEvent(const JoinRequestEvent & e);
virtual void handleEvent(const PeerJoinedEvent & e);
virtual void handleEvent(const JoinConfirmEvent & e);
virtual void handleEvent(const JoinRejectedEvent & e);
virtual void handleEvent(const JoinAbortedEvent & e);
virtual void handleEvent(const SplitDoneEvent & e);
virtual void handleEvent(const MergeRequestEvent & e);
virtual void handleEvent(const PendingPeersEvent & e);
virtual void handleEvent(const PeerReconnectedEvent & e);
virtual void handleEvent(const PeerLeftEvent & e);
void receiveGroupData(const GroupData & data, const PeerID sender);
private:
void testCase00();
void testCase01();
void testCase02();
void testCase03();
void testCase04();
void testCase05();
void testCase06();
void testCase07();
void testCase08();
PeerIDList getSpecifiedNumberOfPeers(bool mixed, int numberOfPeersToAdd, int numberOfClusters);
void invitePeer(TransportAddress & ta);
void leaveGroup();
void sendData();
void splitGroup(unsigned char options, PeerIDList splitPeers);
TransportAddress getNewTransportAddress(int i);
void createRoster(int nextPeerId, int numberOfClusters);
PeerIDList addToPeerIdList(PeerIDList pidl, int peersToAdd[], int numberOfPeersToAdd);
PeerState state;
bool splitOnce;
int waitCounter;
int splitCase;
#if OMNETPP
cOutVector splitDuration;
DurationStatisticRecorder joinDelayStat;
simtime_t dt;
unsigned int numberOfPeers;
unsigned int numberOfClusters;
#endif
};
}
}
#endif /* SPLITAPPLICATION_H */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,115 @@
/*
* File: TestApplication.h
* Author: jgaebler
*
* Created on April 20, 2011, 11:33 AM
*/
#ifndef TESTAPPLICATION_H
#define TESTAPPLICATION_H
#include "Application.h"
#include "simutils/statistics/DurationStatisticRecorder.h"
#include "simutils/statistics/VectorStatisticRecorder.h"
namespace ubeeme {
namespace moversight {
class Dispatcher;
class Moversight;
class Invitation;
/**
* @class TestApplication
* @brief Defines a small test application to test the moversight protocol.
*
* @ingroup Moversight
* @author Jan G&auml;bler
*/
class TestApplication : public Application {
public:
TestApplication(Moversight & m);
virtual ~TestApplication();
virtual void initialise();
virtual void finalise();
void startTestCase(unsigned int i);
void receiveGroupData(const GroupData & data, const PeerID sender);
// Event handling
virtual void handleEvent(const JoinRequestEvent & e);
virtual void handleEvent(const JoinConfirmEvent & e);
virtual void handleEvent(const JoinRejectedEvent & e);
virtual void handleEvent(const JoinAbortedEvent & e);
virtual void handleEvent(const GroupCreatedEvent & e);
virtual void handleEvent(const GroupClosedEvent & e);
virtual void handleEvent(const PeerJoinedEvent & e);
virtual void handleEvent(const PendingPeersEvent & e);
virtual void handleEvent(const PeerReconnectedEvent & e);
virtual void handleEvent(const PeerLeftEvent & e);
virtual void handleEvent(const StartMeasuringEvent & e);
virtual void handleEvent(const StopMeasuringEvent & e);
private:
void testCase00();
void testCase01();
void testCase02();
void testCase03();
void testCase04();
void testCase05();
void testCase06();
void testCase07();
void testCase08();
void testCase09();
void testCase10();
void testCase11();
void testCase12();
void testCase13();
void testCase14();
void testCase15();
void testCase16();
void testCase17();
void testCase18();
void testCase19();
void testCase20();
void testCase21();
void testCase22();
/* void testCase23();
void testCase24();
void testCase25();
void testCase26();
void testCase27();
void testCase28();
*/
void invitePeer(TransportAddress & ta);
void leaveGroup();
void sendData();
void createRoster();
TransportAddress getNewTransportAddress(int i);
DurationStatisticRecorder joinDelayStat;
DurationStatisticRecorder dtDelayStat;
DurationStatisticRecorder leaveDelayStat;
DurationStatisticRecorder rejoinSuccessDuration;
VectorStatisticRecorder groupSizeStat;
size_t waitCounter;
size_t groupSize;
size_t lastGroupSize;
bool hasLeft;
int numberOfPeers;
int clusterSize;
int numberOfMobilePeers;
};
}
}
#endif /* TESTAPPLICATION_H */

View File

@@ -0,0 +1,30 @@
#include "ApplicationEventReceiver.h"
#include "GroupClosedEvent.h"
#include "JoinGroupDoneEvent.h"
#include "GroupCreatedEvent.h"
#include "PeerJoinedEvent.h"
#include "PeerIsPendingEvent.h"
#include "PeerReconnectedEvent.h"
#include "PeerLeftEvent.h"
#include "LocalPeerUpdateEvent.h"
namespace ubeeme {
namespace moversight {
ApplicationEventReceiver::ApplicationEventReceiver(EventSender *sender /*= 0*/) : EventReceiverTemplate<ApplicationEventReceiver>(GroupEvent<EventTypes>::getGroup(), sender) {
}
void ApplicationEventReceiver::connectAll(){
connectEvent(GroupCreatedEvent::getType(), &ApplicationEventReceiver::groupCreated);
connectEvent(JoinGroupDoneEvent::getType(), &ApplicationEventReceiver::joinGroupDone);
connectEvent(GroupClosedEvent::getType(), &ApplicationEventReceiver::groupClosed);
connectEvent(PeerJoinedEvent::getType(), &ApplicationEventReceiver::peerJoined);
connectEvent(PeerIsPendingEvent::getType(), &ApplicationEventReceiver::peerIsPending);
connectEvent(PeerReconnectedEvent::getType(), &ApplicationEventReceiver::peerReconnected);
connectEvent(PeerLeftEvent::getType(), &ApplicationEventReceiver::peerLeft);
connectEvent(LocalPeerUpdateEvent::getType(), &ApplicationEventReceiver::localPeerUpdate);
}
}
} // namespace ubeeme

View File

@@ -0,0 +1,64 @@
#pragma once
#ifndef APPLICATION_EVENT_RECEIVER_H
#define APPLICATION_EVENT_RECEIVER_H
#include <core/event/event_receiver_template.h>
#include <core/event/event.h>
#include <core/event/event_container.h>
#include "common/Defines.h"
namespace ubeeme {
namespace moversight {
class MOV_EXPORT ApplicationEventReceiver : public EventReceiverTemplate<ApplicationEventReceiver> {
public:
ApplicationEventReceiver(EventSender *sender = 0);
virtual ~ApplicationEventReceiver() {
}
void connectAll();
virtual void groupCreated(EventContainer /* e */) {
}
virtual void joinGroupDone(EventContainer /* e */) {
}
virtual void groupClosed(EventContainer /* e */) {
}
virtual void peerJoined(EventContainer /* e */) {
}
virtual void peerIsPending(EventContainer /* e */) {
}
virtual void peerReconnected(EventContainer /* e */) {
}
virtual void peerLeft(EventContainer /* e */) {
}
virtual void localPeerUpdate(EventContainer /* e */) {
}
virtual void mergeDone(EventContainer /* e */) {
}
virtual void mergeNotify(EventContainer /* e */) {
}
virtual void splitDone(EventContainer /* e */) {
}
virtual void splitNotify(EventContainer /* e */) {
}
};
}
} // namespace ubeeme
#endif // APPLICATION_EVENT_RECEIVER_H

View File

@@ -0,0 +1,32 @@
#pragma once
#ifndef EVENT_TYPES_H
#define EVENT_TYPES_H
namespace ubeeme {
namespace moversight {
class EventTypes {
public:
enum Event
{
PEER_JOINED_EVENT = 1,
PEER_IS_PENDING_EVENT,
PEER_RECONNECTED_EVENT,
PEER_LEFT_EVENT,
LOCAL_PEER_UPDATE_EVENT,
GROUP_CREATED_EVENT,
JOIN_GROUP_DONE_EVENT,
GROUP_CLOSED_EVENT,
SPLIT_NOTIFY_EVENT,
SPLIT_DONE_EVENT,
MERGE_DONE_EVENT,
MERGE_NOTIFY_EVENT,
REJOIN_DONE_EVENT,
EVENT_TYPES_COUNT // has to be last
};
};
}
} // namespace ubeeme
#endif // EVENT_TYPES_H

View File

@@ -0,0 +1,16 @@
#include "GroupClosedEvent.h"
namespace ubeeme {
namespace moversight {
GroupClosedEvent::GroupClosedEvent(): GroupEvent<EventTypes>(getType()){
}
GroupClosedEvent::~GroupClosedEvent(){
}
EventType GroupClosedEvent::getType(){
return EventType(getGroup(), EventTypes::GROUP_CLOSED_EVENT);
}
}
}

View File

@@ -0,0 +1,26 @@
#pragma once
#ifndef GROUPCLOSEDEVENT_H
#define GROUPCLOSEDEVENT_H
#include <core/event/group_event.h>
#include "EventTypes.h"
#include "common/Defines.h"
namespace ubeeme {
namespace moversight {
class MOV_EXPORT GroupClosedEvent: public GroupEvent<EventTypes> {
public:
GroupClosedEvent();
virtual ~GroupClosedEvent();
static EventType getType();
};
}
} // namespace ubeeme
#endif // GROUPCREATEDEVENT_H

View File

@@ -0,0 +1,25 @@
#include "GroupCreatedEvent.h"
namespace ubeeme {
namespace moversight {
GroupCreatedEvent::GroupCreatedEvent(Peer p): GroupEvent<EventTypes>(getType()), localPeer(p){
}
GroupCreatedEvent::~GroupCreatedEvent(){
}
EventType GroupCreatedEvent::getType(){
return EventType(getGroup(), EventTypes::GROUP_CREATED_EVENT);
}
Peer GroupCreatedEvent::getLocalPeer(){
return localPeer;
}
void GroupCreatedEvent::setLocalPeer(Peer p){
localPeer = p;
}
}
} // namespace ubeeme

View File

@@ -0,0 +1,32 @@
#pragma once
#ifndef GROUPCREATEDEVENT_H
#define GROUPCREATEDEVENT_H
#include <core/event/group_event.h>
#include "EventTypes.h"
#include "common/Peer.h"
#include "common/Defines.h"
namespace ubeeme {
namespace moversight {
class MOV_EXPORT GroupCreatedEvent: public GroupEvent<EventTypes> {
public:
GroupCreatedEvent(Peer p);
virtual ~GroupCreatedEvent();
static EventType getType();
Peer getLocalPeer();
void setLocalPeer(Peer p);
private:
Peer localPeer;
};
}
} // namespace ubeeme
#endif // GROUPCREATEDEVENT_H

View File

@@ -0,0 +1,39 @@
#pragma once
#ifndef GROUP_MESSAGE_H
#define GROUP_MESSAGE_H
#include <string>
#include <sstream>
#include <core/network/generic_message.h>
#include "common/Defines.h"
namespace ubeeme
{
namespace moversight
{
class MOV_EXPORT GroupMessage : public GenericMessage<moversight::PeerID>
{
public:
GroupMessage(int type, std::string tag = "") : GenericMessage<moversight::PeerID>(type, tag) {}
virtual ~GroupMessage() {}
inline virtual std::string toString() const;
};
std::string
GroupMessage::toString() const
{
std::ostringstream out;
out << "GroupMessage [" << header.getModuleTag() << "] from type: " << header.getMessageType();
return out.str();
}
}
}
#endif // GROUP_MESSAGE_H

View File

@@ -0,0 +1,30 @@
#include "GroupMessageFactory.h"
namespace ubeeme
{
namespace moversight
{
GroupMessageFactory::~GroupMessageFactory() {}
QSharedPointer<GroupMessage>
GroupMessageFactory::createMessage(ByteArray const &buffer, PeerID const &from)
{
char const *start = buffer.data();
int size = buffer.size();
int type = validateHeader(start, size);
if (type != MessageHeader<PeerID>::UNKNOWN_MESSAGE_TYPE) {
QSharedPointer<GroupMessage> message = internalCreateMessage(type, start, size);
if (!message.isNull()) {
message->setFrom(from);
}
return message;
}
return QSharedPointer<GroupMessage>();
}
}
}

View File

@@ -0,0 +1,44 @@
#pragma once
#ifndef GROUP_MESSAGE_FACTORY_H
#define GROUP_MESSAGE_FACTORY_H
#include "core/network/message_validator.h"
#include "common/Defines.h"
#include "GroupMessage.h"
namespace ubeeme
{
namespace moversight
{
class MOV_EXPORT GroupMessageFactory : public ubeeme::MessageValidator<PeerID>
{
public:
virtual ~GroupMessageFactory();
/**
* @brief Creates a message out of the given buffer and the PeerID the message was received from.
* @param buffer Buffer the message should created of.
* @param from PeerID the message was reiceved from.
* @returns The created message.
*/
QSharedPointer<GroupMessage> createMessage(ByteArray const &buffer, PeerID const &from);
protected:
/**
* @brief Creates the concrete message by given message type and buffer.
* @param messageType The type of message in the scope a module.
* @param buffer Buffer the message should created of.
* @param size Size of the buffer to use for deserialization.
* @returns The created message.
* @note Use the deserializePayload method of network message to deserialize the concreate message.
*/
virtual QSharedPointer<GroupMessage> internalCreateMessage(int messageType, char const *buffer, int size) = 0;
};
}
}
#endif // GROUP_MESSAGE_FACTORY_H

View File

@@ -0,0 +1,25 @@
#include "JoinGroupDoneEvent.h"
namespace ubeeme {
namespace moversight {
JoinGroupDoneEvent::JoinGroupDoneEvent(Peer const &p): GroupEvent<EventTypes>(getType()), localPeer(p) {
}
JoinGroupDoneEvent::~JoinGroupDoneEvent(){
}
EventType JoinGroupDoneEvent::getType(){
return EventType(getGroup(), EventTypes::JOIN_GROUP_DONE_EVENT);
}
Peer const & JoinGroupDoneEvent::getLocalPeer() const{
return localPeer;
}
void JoinGroupDoneEvent::setLocalPeer(Peer const &p){
localPeer = p;
}
}
} // namespace ubeeme

View File

@@ -0,0 +1,30 @@
#pragma once
#ifndef JOIN_GROUP_DONE_EVENT_H
#define JOIN_GROUP_DONE_EVENT_H
#include <core/event/group_event.h>
#include "EventTypes.h"
#include "common/Peer.h"
namespace ubeeme {
namespace moversight {
class MOV_EXPORT JoinGroupDoneEvent: public GroupEvent<EventTypes> {
public:
JoinGroupDoneEvent(Peer const &p);
virtual ~JoinGroupDoneEvent();
static EventType getType();
Peer const &getLocalPeer() const;
void setLocalPeer(Peer const &p);
private:
Peer localPeer;
};
}
} // namespace ubeeme
#endif // JOIN_GROUP_DONE_EVENT_H

View File

@@ -0,0 +1,25 @@
#include "LocalPeerUpdateEvent.h"
namespace ubeeme {
namespace moversight {
LocalPeerUpdateEvent::LocalPeerUpdateEvent(Peer const &p): GroupEvent<EventTypes>(getType()), localPeer(p) {
}
LocalPeerUpdateEvent::~LocalPeerUpdateEvent(){
}
EventType LocalPeerUpdateEvent::getType(){
return EventType(getGroup(), EventTypes::LOCAL_PEER_UPDATE_EVENT);
}
Peer const &LocalPeerUpdateEvent::getLocalPeer() const{
return localPeer;
}
void LocalPeerUpdateEvent::setLocalPeer(Peer const &p){
localPeer = p;
}
}
} // namespace ubeeme

View File

@@ -0,0 +1,30 @@
#pragma once
#ifndef LOCAL_PEER_UPDATE_EVENT_H
#define LOCAL_PEER_UPDATE_EVENT_H
#include <core/event/group_event.h>
#include "EventTypes.h"
#include "common/Peer.h"
namespace ubeeme {
namespace moversight {
class MOV_EXPORT LocalPeerUpdateEvent: public GroupEvent<EventTypes> {
public:
LocalPeerUpdateEvent(Peer const &p);
virtual ~LocalPeerUpdateEvent();
static EventType getType();
Peer const &getLocalPeer() const;
void setLocalPeer(Peer const &p);
private:
Peer localPeer;
};
}
} // namespace ubeeme
#endif // LOCAL_PEER_UPDATE_EVENT_H

View File

@@ -0,0 +1,16 @@
#include "MergeDoneEvent.h"
namespace ubeeme {
namespace moversight {
MergeDoneEvent::MergeDoneEvent() : GroupEvent<EventTypes>(getType()){
}
MergeDoneEvent::~MergeDoneEvent(){
}
EventType MergeDoneEvent::getType() {
return EventType(getGroup(), EventTypes::MERGE_DONE_EVENT);
}
}
}// namespace ubeeme

View File

@@ -0,0 +1,25 @@
#pragma once
#ifndef MERGE_DONE_EVENT_H
#define MERGE_DONE_EVENT_H
#include <core/event/group_event.h>
#include "EventTypes.h"
#include "common/Defines.h"
namespace ubeeme {
namespace moversight {
class MOV_EXPORT MergeDoneEvent: public GroupEvent<EventTypes> {
public:
MergeDoneEvent();
virtual ~MergeDoneEvent();
static EventType getType();
};
}
} // namespace ubeeme
#endif // MERGE_NOTIFY_EVENT_H

View File

@@ -0,0 +1,16 @@
#include "MergeNotifyEvent.h"
namespace ubeeme {
namespace moversight {
MergeNotifyEvent::MergeNotifyEvent() : GroupEvent<EventTypes>(getType()){
}
MergeNotifyEvent::~MergeNotifyEvent(){
}
EventType MergeNotifyEvent::getType() {
return EventType(getGroup(), EventTypes::MERGE_NOTIFY_EVENT);
}
}
}// namespace ubeeme

View File

@@ -0,0 +1,28 @@
#pragma once
#ifndef MERGE_NOTIFY_EVENT_H
#define MERGE_NOTIFY_EVENT_H
#include <core/event/group_event.h>
#include "EventTypes.h"
#include "common/Defines.h"
namespace ubeeme {
namespace moversight {
class MOV_EXPORT MergeNotifyEvent: public GroupEvent<EventTypes> {
public:
MergeNotifyEvent();
virtual ~MergeNotifyEvent();
static EventType getType();
private:
};
}
} // namespace ubeeme
#endif // MERGE_NOTIFY_EVENT_H

View File

@@ -0,0 +1,32 @@
#include "PeerIsPendingEvent.h"
namespace ubeeme {
namespace moversight {
PeerIsPendingEvent::PeerIsPendingEvent(PeerID const &pId, TransportAddress const &ta) : GroupEvent<EventTypes>(getType()), pendingPeerID(pId), pendingPeerTA(ta) {
}
PeerIsPendingEvent::~PeerIsPendingEvent(){
}
EventType PeerIsPendingEvent::getType() {
return EventType(getGroup(), EventTypes::PEER_IS_PENDING_EVENT);
}
PeerID const &PeerIsPendingEvent::getPendingPeerID() const{
return pendingPeerID;
}
void PeerIsPendingEvent::setPendingPeerID(PeerID const &pId){
pendingPeerID = pId;
}
TransportAddress const &PeerIsPendingEvent::getPendingPeerTA() const{
return pendingPeerTA;
}
void PeerIsPendingEvent::setPendingPeerTA(TransportAddress const &ta){
pendingPeerTA = ta;
}
}
} // namespace ubeeme

View File

@@ -0,0 +1,36 @@
#pragma once
#ifndef PEER_IS_PENDING_EVENT_H
#define PEER_IS_PENDING_EVENT_H
#include <core/event/group_event.h>
#include "EventTypes.h"
#include "common/Defines.h"
#include "common/transport/TransportAddress.h"
namespace ubeeme {
namespace moversight {
class MOV_EXPORT PeerIsPendingEvent: public GroupEvent<EventTypes> {
public:
PeerIsPendingEvent(PeerID const &pId, TransportAddress const &ta);
virtual ~PeerIsPendingEvent();
static EventType getType();
PeerID const &getPendingPeerID() const;
void setPendingPeerID(PeerID const &pId);
TransportAddress const &getPendingPeerTA() const;
void setPendingPeerTA(TransportAddress const &aTa);
private:
PeerID pendingPeerID;
TransportAddress pendingPeerTA;
};
}
} // namespace ubeeme
#endif // PEER_IS_PENDING_EVENT_H

View File

@@ -0,0 +1,40 @@
#include "PeerJoinedEvent.h"
namespace ubeeme {
namespace moversight {
PeerJoinedEvent::PeerJoinedEvent(PeerID const &pId, TransportAddress const &ta, PeerDescription const &pDesc) : GroupEvent<EventTypes>(getType()), joinedPeerID(pId), joinedPeerDesc(pDesc), joinedPeerTA(ta){
}
PeerJoinedEvent::~PeerJoinedEvent(){
}
EventType PeerJoinedEvent::getType(){
return EventType(getGroup(), EventTypes::PEER_JOINED_EVENT);
}
PeerID const &PeerJoinedEvent::getJoinedPeerID() const{
return joinedPeerID;
}
void PeerJoinedEvent::setJoinedPeerID(PeerID const &pId){
joinedPeerID = pId;
}
PeerDescription const &PeerJoinedEvent::getPeerDescription() const{
return joinedPeerDesc;
}
void PeerJoinedEvent::setPeerDescription(PeerDescription const &pDesc){
joinedPeerDesc = pDesc;
}
TransportAddress const &PeerJoinedEvent::getJoinedPeerTA() const{
return joinedPeerTA;
}
void PeerJoinedEvent::setJoinedPeerTA(TransportAddress const &ta){
joinedPeerTA = ta;
}
}
} // namespace ubeeme

View File

@@ -0,0 +1,44 @@
#pragma once
#ifndef PEER_JOINED_EVENT_H
#define PEER_JOINED_EVENT_H
#include "EventTypes.h"
#include "app/PeerDescription.h"
#include "common/Defines.h"
#include "common/transport/TransportAddress.h"
#include <core/event/group_event.h>
namespace ubeeme {
namespace moversight {
class MOV_EXPORT PeerJoinedEvent: public GroupEvent<EventTypes> {
public:
PeerJoinedEvent(PeerID const &pId, TransportAddress const &ta, PeerDescription const &pDesc);
virtual ~PeerJoinedEvent();
static EventType getType();
PeerID const &getJoinedPeerID() const;
void setJoinedPeerID(PeerID const &pId);
PeerDescription const &getPeerDescription() const;
void setPeerDescription(PeerDescription const & pDesc);
TransportAddress const &getJoinedPeerTA() const;
void setJoinedPeerTA(TransportAddress const & ta);
private:
PeerID joinedPeerID;
PeerDescription joinedPeerDesc;
TransportAddress joinedPeerTA;
};
}
} // namespace ubeeme
#endif // PEER_JOINED_EVENT_H

View File

@@ -0,0 +1,33 @@
#include "PeerLeftEvent.h"
namespace ubeeme {
namespace moversight {
PeerLeftEvent::PeerLeftEvent(PeerID const &pId, TransportAddress const &ta) : GroupEvent<EventTypes>(getType()), leftPeerID(pId), leftPeerTA(ta){
}
PeerLeftEvent::~PeerLeftEvent(){
}
EventType PeerLeftEvent::getType() {
return EventType(getGroup(), EventTypes::PEER_LEFT_EVENT);
}
PeerID const &PeerLeftEvent::getLeftPeerID() const{
return leftPeerID;
}
void PeerLeftEvent::setLeftPeerID(PeerID const &pId){
leftPeerID = pId;
}
TransportAddress const &PeerLeftEvent::getLeftPeerTA() const{
return leftPeerTA;
}
void PeerLeftEvent::setLeftPeerTA(TransportAddress const &ta){
leftPeerTA = ta;
}
}
}// namespace ubeeme

View File

@@ -0,0 +1,36 @@
#pragma once
#ifndef PEER_LEFT_EVENT_H
#define PEER_LEFT_EVENT_H
#include <core/event/group_event.h>
#include "EventTypes.h"
#include "common/Defines.h"
#include "common/transport/TransportAddress.h"
namespace ubeeme {
namespace moversight {
class MOV_EXPORT PeerLeftEvent: public GroupEvent<EventTypes> {
public:
PeerLeftEvent(PeerID const &pId, TransportAddress const &ta);
virtual ~PeerLeftEvent();
static EventType getType();
PeerID const &getLeftPeerID() const;
void setLeftPeerID(PeerID const &pId);
TransportAddress const &getLeftPeerTA() const;
void setLeftPeerTA(TransportAddress const &aTa);
private:
PeerID leftPeerID;
TransportAddress leftPeerTA;
};
}
} // namespace ubeeme
#endif // PEER_LEFT_EVENT_H

View File

@@ -0,0 +1,32 @@
#include "PeerReconnectedEvent.h"
namespace ubeeme {
namespace moversight {
PeerReconnectedEvent::PeerReconnectedEvent(PeerID const &pId, TransportAddress const &ta) : GroupEvent<EventTypes>(getType()), reconnectedPeerID(pId), reconnectedPeerTA(ta){
}
PeerReconnectedEvent::~PeerReconnectedEvent(){
}
EventType PeerReconnectedEvent::getType(){
return EventType(getGroup(), EventTypes::PEER_RECONNECTED_EVENT);
}
PeerID const &PeerReconnectedEvent::getReconnectedPeerID() const{
return reconnectedPeerID;
}
void PeerReconnectedEvent::setReconnectePeerID(PeerID const &pId){
reconnectedPeerID = pId;
}
TransportAddress const &PeerReconnectedEvent::getReconnectedPeerTA() const{
return reconnectedPeerTA;
}
void PeerReconnectedEvent::setReconnectePeerTA(TransportAddress const &ta){
reconnectedPeerTA = ta;
}
}
} // namespace ubeeme

View File

@@ -0,0 +1,35 @@
#pragma once
#ifndef PEER_RECONNECTED_EVENT_H
#define PEER_RECONNECTED_EVENT_H
#include <core/event/group_event.h>
#include "EventTypes.h"
#include "common/Defines.h"
#include "common/transport/TransportAddress.h"
namespace ubeeme {
namespace moversight {
class MOV_EXPORT PeerReconnectedEvent: public GroupEvent<EventTypes> {
public:
PeerReconnectedEvent(PeerID const &pId, TransportAddress const &ta);
virtual ~PeerReconnectedEvent();
static EventType getType();
PeerID const &getReconnectedPeerID() const;
void setReconnectePeerID(PeerID const &pId);
TransportAddress const &getReconnectedPeerTA() const;
void setReconnectePeerTA(TransportAddress const &aTa);
private:
PeerID reconnectedPeerID;
TransportAddress reconnectedPeerTA;
};
}
} // namespace ubeeme
#endif // PEER_RECONNECTED_EVENT_H

View File

@@ -0,0 +1,26 @@
#include "RejoinDoneEvent.h"
namespace ubeeme {
namespace moversight {
/**
* @brief Constructor
*/
RejoinDoneEvent::RejoinDoneEvent() : GroupEvent<EventTypes>(getType()){
}
/**
* @brief Destructor
*/
RejoinDoneEvent::~RejoinDoneEvent(){
}
/**
* @brief Get the EventType.
* @return The Eventtype - RejoinDoneEvent
*/
EventType RejoinDoneEvent::getType() {
return EventType(getGroup(), EventTypes::REJOIN_DONE_EVENT);
}
}
}// namespace ubeeme

View File

@@ -0,0 +1,28 @@
#pragma once
#ifndef SPLIT_DONE_EVENT_H
#define SPLIT_DONE_EVENT_H
#include <core/event/group_event.h>
#include "EventTypes.h"
#include "common/Defines.h"
namespace ubeeme {
namespace moversight {
class MOV_EXPORT RejoinDoneEvent: public GroupEvent<EventTypes> {
public:
RejoinDoneEvent();
virtual ~RejoinDoneEvent();
static EventType getType();
private:
};
}
} // namespace ubeeme
#endif // SPLIT_NOTIFY_EVENT_H

View File

@@ -0,0 +1,16 @@
#include "SplitDoneEvent.h"
namespace ubeeme {
namespace moversight {
SplitDoneEvent::SplitDoneEvent() : GroupEvent<EventTypes>(getType()){
}
SplitDoneEvent::~SplitDoneEvent(){
}
EventType SplitDoneEvent::getType() {
return EventType(getGroup(), EventTypes::SPLIT_DONE_EVENT);
}
}
}// namespace ubeeme

View File

@@ -0,0 +1,28 @@
#pragma once
#ifndef SPLIT_DONE_EVENT_H
#define SPLIT_DONE_EVENT_H
#include <core/event/group_event.h>
#include "EventTypes.h"
#include "common/Defines.h"
namespace ubeeme {
namespace moversight {
class MOV_EXPORT SplitDoneEvent: public GroupEvent<EventTypes> {
public:
SplitDoneEvent();
virtual ~SplitDoneEvent();
static EventType getType();
private:
};
}
} // namespace ubeeme
#endif // SPLIT_NOTIFY_EVENT_H

View File

@@ -0,0 +1,16 @@
#include "SplitNotifyEvent.h"
namespace ubeeme {
namespace moversight {
SplitNotifyEvent::SplitNotifyEvent() : GroupEvent<EventTypes>(getType()){
}
SplitNotifyEvent::~SplitNotifyEvent(){
}
EventType SplitNotifyEvent::getType() {
return EventType(getGroup(), EventTypes::SPLIT_NOTIFY_EVENT);
}
}
}// namespace ubeeme

View File

@@ -0,0 +1,28 @@
#pragma once
#ifndef SPLIT_NOTIFY_EVENT_H
#define SPLIT_NOTIFY_EVENT_H
#include <core/event/group_event.h>
#include "EventTypes.h"
#include "common/Defines.h"
namespace ubeeme {
namespace moversight {
class MOV_EXPORT SplitNotifyEvent: public GroupEvent<EventTypes> {
public:
SplitNotifyEvent();
virtual ~SplitNotifyEvent();
static EventType getType();
private:
};
}
} // namespace ubeeme
#endif // SPLIT_NOTIFY_EVENT_H

View File

@@ -0,0 +1,115 @@
/*
* File: Defines.h
* Author: jgaebler
*
* Created on June 28, 2010, 2:40 PM
*/
#pragma once
#ifndef DEFINES_H
#define DEFINES_H
#include "Platform.h"
#include "ms/PeerID.h"
#include "ms/InvitationID.h"
#include "ms/ViewID.h"
#include "ms/register/ClusterID.h"
//general includes
#include <cstddef>
#include <ostream>
#include <iostream>
#include <string>
#include <sstream>
#include <memory>
#include <vector>
#include <utility>
#include <functional>
#include <algorithm>
using ::std::size_t;
using ::std::cout;
using ::std::cerr;
using ::std::endl;
//fallback for environments, witch operates without the Netbeans environment
#ifndef CLOUD_SYNC_ENABLED
#define CLOUD_SYNC_ENABLED 0
//if the cloud storage disabled, we have to enable the p2p storage and vice versa
#define P2P_SYNC_ENABLED 1
#endif
//again, only one storing method can be used for resync a peer
#if CLOUD_SYNC_ENABLED
#define P2P_SYNC_ENABLED 0
#endif
#if OMNETPP
#include <stdint.h>
#include <omnetpp.h>
#include "IPvXAddress.h"
#define MOV_DEBUG EV
#define MOV_EXPORT
#else
#include "core/debugging/debug.h"
#include "common/utypes.h"
#include "core/network/host_address.h"
#include "common/ubeeme_global.h"
using ubeeme::uint16;
using ubeeme::uint32;
using ubeeme::HostAddress;
#define MOV_EXPORT UBEEME_EXPORT
#endif
namespace ubeeme {
namespace moversight {
/**
* @brief Defines the shifts for the option parameter within the SPA message.
*/
enum ShiftTypes {
SHIFT_SEMANTIC = 0x7, //0b00000111,
SHIFT_FLUSH = 0x6, //0b00000110,
SHIFT_REPLY = 0x5 //0b00000101
};
/**
* @brief Defines the test bit for each synchronisation
*/
enum SyncTypes {
FLUSH = 0x1, //0b00000001,
SEMANTIC = 0x1, //0b00000001
};
/**
* @brief Defines the bit masks for the reply parameter within the SPA message.
*/
enum ReplyTypes {
REPLY_ALL = 0x1, //0b00000001
};
#if OMNETPP
/**
* @brief Represents a host address within omnetpp
*/
typedef IPvXAddress HostAddress;
/**
* @brief Represents a port within omnetpp
*/
typedef uint16_t Port;
#else
typedef PortType Port;
#endif
}
}
#endif /* DEFINES_H */

View File

@@ -0,0 +1,369 @@
/*
* File: Exception.h
* Author: jgaebler
*
* Created on May 6, 2010, 9:44 AM
*/
#pragma once
#ifndef UBEEME_EXCEPTION_H
#define UBEEME_EXCEPTION_H
#include "common/Defines.h"
#include <exception>
namespace ubeeme {
namespace moversight {
/**
* @class Exception
* @brief Defines a set of exceptions, used within Moversight.
* @ingroup Moversight
* @author Jan G&auml;bler
*/
class Exception : public std::exception {
public:
/**
* @brief Constructor
* @param message the exception message - what has happened
*/
Exception(const char* message) {
m = message;
}
/**
* @brief Destructor
*/
virtual
~Exception() throw () {
};
/**
* @brief A Java style toString implementation. Returns, what has happened.
* @return What has happened.
*/
const char*
toString() {
return what();
}//End toString
/**
* @brief Overrides the standard what method and tells, what has happened.
* @return What has happened.
*/
virtual const char*
what() const throw () {
return m.c_str();
}
protected:
/**
* @brief Stores the exeption message.
*/
std::string m;
private:
Exception();
};
/**
* @brief Defines a null pointer expception. Used to signal a null pointer error during the execution.
* @author Jan G&auml;bler
* @ingroup Moversight
* @class NullPointerException
*/
class NullPointerException : public Exception {
public:
/**
* @brief Constructor
* @param message what has happened?
*/
NullPointerException(const char* message) : Exception(message) {
}
};
/**
* @brief Defines a logic expception. Used to signal a logical error during the execution.
* @author Jan G&auml;bler
* @ingroup Moversight
* @class LogicException
*/
class LogicException : public Exception {
public:
/**
* @brief Constructor
* @param message what has happened?
*/
LogicException(const char* message) : Exception(message) {
}
};
/**
* @brief Defines a not implemented yet expception. Used to signal not implemented methods.
* @author Jan G&auml;bler
* @ingroup Moversight
* @class NotImplementedYetException
*/
class NotImplementedYetException : public Exception {
public:
/**
* @brief Constructor
* @param message what has happened?
*/
NotImplementedYetException(const char* message) : Exception(message) {
}
};
/**
* @brief Defines an index out of bounce exception. Used to signal index errors.
* @author Jan G&auml;bler
* @ingroup Moversight
* @class IndexOutOfBounceException
*/
class IndexOutOfBounceException : public Exception {
public:
/**
* @brief Constructor
*
* @param message What has happened?
*/
IndexOutOfBounceException(const char* message) : Exception(message) {
}
};
/**
* @brief Defines an attribute not set exception. Used to signal the access of undefined references or values.
* @author Jan G&auml;bler
* @ingroup Moversight
* @class AttributeNotSetException
*/
class AttributeNotSetException : public Exception {
public:
/**
* @brief Constructor
* @param message What has happened?
*/
AttributeNotSetException(const char* message) : Exception(message) {
}
};
/**
* @brief Defines a peer not found exception. Used to signal the call for a peer, not stored or found within a list, a cluster et cetera.
* @author Jan G&auml;bler
* @ingroup Moversight
* @class PeerNotFoundException
*/
class PeerNotFoundException : public Exception {
public:
/**
* @brief Constructor
* @param message What has happened?
*/
PeerNotFoundException(const char* message) : Exception(message) {
}
};
/**
* @brief Defines a entry not found exception. Used to signal that a table or map lookup (or similar) has been failed, as the desired element was not found within the storage structure.
* @author Jan G&auml;bler
* @ingroup Moversight
* @class EntryNotFoundException
*/
class EntryNotFoundException : public Exception {
public:
/**
* @brief Constructor
* @param message What has happened?
*/
EntryNotFoundException(const char* message) : Exception(message) {
}
};
/**
* @brief Defines a cluster not found exception. Used to signal the call for a cluster, not stored or found within a list, a group et cetera.
* @author Jan G&auml;bler
* @ingroup Moversight
* @class ClusterNotFoundException
*/
class ClusterNotFoundException : public Exception {
public:
/**
* @brief Constructor
* @param message What has happened?
*/
ClusterNotFoundException(const char* message) : Exception(message) {
}
};
/**
* @brief Defines a peer place exception. Used to signal that an error have occur during placing a peer within the topology.
* @author Jan G&auml;bler
* @ingroup Moversight
* @class PeerPlaceException
*/
class PeerPlaceException : public Exception {
public:
/**
* @brief Constructor
* @param message What has happened?
*/
PeerPlaceException(const char* message) : Exception(message) {
}
};
/**
* @brief Defines cluster limit reached exception. Used to signal that no more clusters can be created within the acutal group setting.
* @author Jan G&auml;bler
* @ingroup Moversight
* @class ClusterLimitReachedException
*/
class ClusterLimitReachedException : public PeerPlaceException {
public:
/**
* @brief Constructor
* @param message What has happened?
*/
ClusterLimitReachedException(const char* message) : PeerPlaceException(message) {
}
};
/**
* @brief Defines a timer not found exception. Used to signal timer errors.
* @author Jan G&auml;bler
* @ingroup Moversight
* @class TimerNotFoundException
*/
class TimerNotFoundException : public Exception {
public:
/**
* @brief Constructor
*
* @param message What has happened?
*/
TimerNotFoundException(const char* message) : Exception(message) {
}
};
/**
* @brief Defines a invitation not found exception. Used to signal invitation missing errors.
* @author Jan G&auml;bler
* @ingroup Moversight
* @class InvitationNotFoundException
*/
class InvitationNotFoundException : public Exception {
public:
/**
* @brief Constructor
*
* @param message What has happened?
*/
InvitationNotFoundException(const char* message) : Exception(message) {
}
};
/**
* @brief Defines a parameter exception. Used to signal setup errors.
* @author Jan G&auml;bler
* @ingroup Moversight
* @class ParameterException
*/
class ParameterException : public Exception {
public:
/**
* @brief Constructor
*
* @param message What has happened?
*/
ParameterException(const char* message) : Exception(message) {
}
};
/**
* @brief Defines an illegal parameter exception. Used to signal that a given parameter is not valid within the current context.
* @author Jan G&auml;bler
* @ingroup Moversight
* @class IllegalParameterException
*/
class IllegalParameterException : public ParameterException {
public:
/**
* @brief Constructor
*
* @param message What has happened?
*/
IllegalParameterException(const char * message) : ParameterException(message) {
}
};
/**
* @brief Defines a flush in progress exception. Used to signal that a flush is in progress and no other split or merge is allowed.
* @author Silvio Gaebler
* @ingroup Moversight
* @class FlushModeException
*/
class FlushModeException : public Exception {
public:
/**
* @brief Constructor
*
* @param message What has happened?
*/
FlushModeException(const char * message) : Exception(message) {
}
};
/**
* @brief Defines a secondary group exception. Signals that the peer is not allowed to do an action because it's not in the primary group(ongoing partition).
* @author Grit Schneider
* @ingroup Moversight
* @class SecondaryGroupException
*/
class SecondaryGroupException : public Exception {
public:
/**
* @brief Constructor
*
* @param message What has happened?
*/
SecondaryGroupException(const char * message) : Exception(message) {
}
};
/**
* @brief Defines a rejoin lock exception. Signals that the peer is not allowed to do an action because it's actually locked due to a ongoing rejoin.
* @author Grit Schneider
* @ingroup Moversight
* @class RejoinLockException
*/
class RejoinLockException : public Exception {
public:
/**
* @brief Constructor
*
* @param message What has happened?
*/
RejoinLockException(const char * message) : Exception(message) {
}
};
}
}
#endif /* UBEEME_EXCEPTION_H */

View File

@@ -0,0 +1,456 @@
#include "MoversightService.h"
#include "Dispatcher.h"
#include "Moversight.h"
#include "common/transport/msg/ExteriorMessage.h"
#include "common/time/VirtualLogicalTime.h"
#include "mt/msg/MulticastMessage.h"
#include "ut/msg/UnicastMessage.h"
namespace ubeeme {
namespace moversight {
/**
* @brief Constructor
* @param d A reference to the moversight dispatcher
*/
MoversightService::MoversightService(Dispatcher & d, std::string name)
: ObjectListener(name),
dispatcher(d),
module(dispatcher.getMoversight()) {
}
/**
* @brief Copy constructor
* @param other The instance to copy.
*/
MoversightService::MoversightService(const MoversightService& other)
: ObjectListener(other.getServiceName()), dispatcher(other.dispatcher), module(other.module) {
}
/**
* @brief Destructor
*/
MoversightService::~MoversightService() {
}
/**
* @brief Returns the current view ID.
* @return The desired view ID.
*/
ViewID
MoversightService::getViewID() const {
return dispatcher.getMembershipService().getViewID();
}
/**
* @brief Returns the last view ID.
* @return The last view ID.
*/
ViewID
MoversightService::getLastViewID() const {
return dispatcher.getMembershipService().getLastViewID();
}
/**
* @brief Returns the master id list from the membership service.
* @return A list containing all master IDs.
*/
PeerIDList
MoversightService::getMasterIDList() {
return dispatcher.getMembershipService().getMasterPeerIDList();
}
/**
* @brief Permits access to the local moversight peer instance.
* @return The local peer instance.
*/
Peer &
MoversightService::getLocalPeer() {
return dispatcher.getMembershipService().getLocalPeer();
}
/**
* @brief Permits access to the local moversight peer instance.
* @return The local peer instance.
*/
const Peer &
MoversightService::getLocalPeer() const {
return dispatcher.getMembershipService().getLocalPeer();
}
/**
* @brief Returns the Peer ID of the local peer.
* @return The id of the local peer instance.
*/
PeerID
MoversightService::getLocalID() {
return getLocalPeer().getPeerID();
}
/**
* @brief Returns the transport address of the local peer.
* @return The transport address of the local peer.
*/
TransportAddress const &
MoversightService::getLocalAddress() {
return module.getLocalAddress();
}
/**
* @brief Returns true, if the local peer master.
* @return True, if the local peer master, false otherwise.
*/
bool
MoversightService::isLocalPeerMaster() {
return getLocalPeer().isMaster();
}
/**
* @brief Returns the peer ID of the master peer from the local peer.
* @return The ID of the master peer from the local peer.
*/
PeerID
MoversightService::getLocalMasterID() const {
return getLocalPeer().getMasterID();
}
/**
* @brief Returns the peer state of the local peer.
* @return The peer state of the local peer.
*/
PeerState &
MoversightService::getLocalPeerState() {
return getLocalPeer().getPeerState();
}
/**
* @brief Returns the peer state of the local peer.
* @return The peer state of the local peer.
*/
const PeerState &
MoversightService::getLocalPeerState() const {
return getLocalPeer().getPeerState();
}
/**
* @brief Returns the (main) state of the local peer.
* @return The (main) state of the local peer.
*/
const State &
MoversightService::getLocalState() const {
return getLocalPeer().getState();
}
/**
* @brief Sets the local (main) state of the peer.
* @param s The (main) state to set.
*/
void
MoversightService::setLocalState(const State & s) {
getLocalPeerState().setState(s);
}
/**
* @brief Returns the sub state of the local peer.
* @return The sub state of the local peer.
*/
const SubState &
MoversightService::getLocalSubState() const {
return getLocalPeer().getSubState();
}
/**
* @brief Sets the local sub state.
* @param sub The sub state to set.
*/
void
MoversightService::setLocalSubState(const SubState & sub) {
getLocalPeerState().setSubState(sub);
}
/**
* @brief Returns the state operation of the local peer.
* @return The state operation of the local peer.
*/
const StateOperation &
MoversightService::getLocalStateOperation() const {
return getLocalPeer().getStateOperation();
}
/**
* @brief Sets the state operation of the local peer.
* @param op The state operation to set.
*/
void
MoversightService::setLocalStateOperation(const StateOperation & op) {
getLocalPeerState().setStateOperation(op);
}
/**
* @brief Returns the peer state of the given peer.
* @param id The id of the peer to read.
* @return The peer state of the given peer.
*/
PeerState &
MoversightService::getPeerState(PeerID id) {
return dispatcher.getMembershipService().getPeer(id).getPeerState();
}
/**
* @brief Returns the peer state of the given peer.
* @param id The id of the peer to read.
* @return The peer state of the given peer.
*/
const PeerState &
MoversightService::getPeerState(PeerID id) const {
return dispatcher.getMembershipService().getPeer(id).getPeerState();
}
/**
* @brief Returns the state of the given peer.
* @param id The id of the peer to read.
* @return The state of the given peer.
*/
const State &
MoversightService::getState(PeerID id) const {
return getPeerState(id).getState();
}
/**
* @brief Sets the state of the given peer.
* @param id The id of the peer to set.
* @param s The state to set.
*/
void
MoversightService::setState(PeerID id, const State & s) {
getPeerState(id).setState(s);
}
/**
* @brief Returns the sub state of the given peer.
* @param id The id of the peer to read.
* @return The sub state of the given peer.
*/
const SubState &
MoversightService::getSubState(PeerID id) const {
return getPeerState(id).getSubState();
}
/**
* @brief Sets the sub state of the given peer.
* @param id The peer which sub state shall be set.
* @param sub The sub state to set.
*/
void
MoversightService::setSubState(PeerID id, const SubState & sub) {
getPeerState(id).setSubState(sub);
}
/**
* @brief Returns the state operation of the given peer.
* @param id The ID of the peer to read.
* @return The state operation of the local peer.
*/
const StateOperation &
MoversightService::getStateOperation(PeerID id) const {
return getPeerState(id).getStateOperation();
}
/**
* @brief Sets the state operation of the given peer.
* @param id The id of the peer to set.
* @param op The state operation to set.
*/
void
MoversightService::setStateOperation(PeerID id, const StateOperation & op) {
getPeerState(id).setStateOperation(op);
}
/* --------------------------------------------------------------------
* Common interface for PDU send operations
*/
/**
* @brief Send a message to a host identified by it's transport address.
* @param msg The message to send.
* @param dest The destination's transport address.
* @param reliable Whether to send the message reliable or not.
*/
void
MoversightService::sendTo(const MoversightMessage& msg, const TransportAddress& dest, const bool reliable /* = false */) {
if(getLocalAddress() != dest){
dispatcher.getUnicastTransfer().send(msg, dest, reliable);
}//End if
}
/**
* @brief Send a message to a host identified by it's peer ID.
* @param msg The message to send.
* @param dest The destination's peer ID.
* @param reliable Whether to send the message reliable or not.
*/
void
MoversightService::sendTo(const MoversightMessage& msg, const PeerID dest, const bool reliable /* = false */) {
TransportAddress ta;
if (getLocalSubState() == REJOIN_IN_PROGRESS) {
ta = dispatcher.getMembershipService().getLastMemberRegister().getPeer(dest).getLocalAddress();
}
else {
ta = dispatcher.getMembershipService().getPeer(dest).getLocalAddress();
}
sendTo(msg, ta, reliable);
}
/**
* @brief Send a message to a list of hosts identified by their transport addresses.
* @param msg The message to send.
* @param peers List of destination peer IDs.
* @param reliable Whether to send the message reliable or not.
*/
void
MoversightService::sendTo(const MoversightMessage& msg, const PeerIDList& peers, const bool reliable /* = false */) {
for (size_t i = 0; i < peers.size(); i++) {
sendTo(msg, peers.get(i), reliable);
}
}
/**
* @brief Send a message to all peers within this cluster.
* @param msg The message to send.
* @param reliable Whether to send the message reliable or not.
*/
void
MoversightService::sendToCluster(const MoversightMessage& msg, const bool reliable /* = false */) {
PeerIDList peers = dispatcher.getMembershipService().getClusterPeerIDList(getLocalID());
//remove the local peer as receiver of the message
peers.remove(getLocalID());
sendTo(msg, peers, reliable);
}
/**
* @brief Send a message to the master peer.
* @param msg The message to send.
* @param reliable Whether to send the message reliable or not.
*/
void
MoversightService::sendToMaster(const MoversightMessage& msg, const bool reliable /* = false */) {
PeerID pid = getLocalPeer().getMasterID();
if (getLocalID() != pid) {
sendTo(msg, pid, reliable);
}
}
/**
* @brief Send a message to all master peers.
* @param msg The message to send.
* @param reliable Whether to send the message reliable or not.
*/
void
MoversightService::sendToAllMasters(const MoversightMessage& msg, const bool reliable /* = false */) {
PeerIDList peers = dispatcher.getMembershipService().getMasterPeerIDList();
peers.remove(getLocalID());
sendTo(msg, peers, reliable);
}
/**
* @brief Send a message to a peer from the last view identified by it's peer ID.
* @param msg The message to send.
* @param dest The destination's peer ID.
* @param reliable Whether to send the message reliable or not.
*/
void
MoversightService::sendToLastView(const MoversightMessage& msg, const PeerID dest, const bool reliable /* = false */) {
TransportAddress ta = dispatcher.getMembershipService().getLastMemberRegister().getPeer(dest).getLocalAddress();
sendTo(msg, ta, reliable);
}
/**
* @brief Send a message to a list of peers from the last view identified by their peer ID.
* @param msg The message to send.
* @param peers List of destination peers.
* @param reliable Whether to send the message reliable or not.
*/
void
MoversightService::sendToLastView(const MoversightMessage& msg, const PeerIDList& peers, const bool reliable /* = false */) {
for (size_t i = 0; i < peers.size(); i++) {
sendToLastView(msg, peers.get(i), reliable);
}
}
/**
* @brief Creates a list of receiver peers.
*
* This method creates a list of receiver peers for example a multicast dissemination within the current cluster.
* The generated list contains all peers of the local cluster and all master, expect it self and the peer, which was the sender of the message.
* The sender of the message is given by the sourcePeerId attribute (in common stored in the last hop field of a peer message).
*
* @param sourcePeerID The sender of a message. Normally identified by the last hop / or sender field of a peer message.
* @return The created list.
*/
PeerIDList
MoversightService::createReceiverList(PeerID sourcePeerID) {
PeerIDList recList;
//sender is master
if (dispatcher.getMembershipService().getMasterPeerIDList().contains(sourcePeerID)) {
recList = dispatcher.getMembershipService().getClusterPeerIDList(getLocalID());
}
//sender is slave
else {
recList = dispatcher.getMembershipService().getClusterAndMasterPeerIDList(getLocalPeer());
recList.remove(sourcePeerID);
}
recList.remove(getLocalID());
return recList;
}
/**
* @brief Assignment operator
* @param other The instance to assign.
* @return A reference to the local instance.
*/
MoversightService &
MoversightService::operator=(const MoversightService & other) {
//prevent self assignment
if (this == &other) {
return *this;
}
dispatcher = other.dispatcher;
module = other.module;
return *this;
}
/**
* @brief Permits access to the current logical time.
* @return The current logical time.
*/
const VirtualLogicalTime &
MoversightService::getCurrentLogicalTime() const {
return dispatcher.getTimeService().getCurrentLogicalTime();
}
/**
* @brief Returns the last seen logical time for a delivered message.
* @return The last seen logical time of a delivered message
*/
const VirtualLogicalTime &
MoversightService::getLastSeenLogicalTime() const {
return dispatcher.getMessageTransfer().getLastSeenLogicalTime();
}
}
}

View File

@@ -0,0 +1,133 @@
/*
* File: MoversightService.h
* Author: jgaebler
*
* Created on May 27, 2011, 9:19 AM
*/
#pragma once
#ifndef MOVERSIGHTSERVICE_H
#define MOVERSIGHTSERVICE_H
#include "common/Defines.h"
#include "common/container/PeerList.h"
#include "common/container/PeerIDList.h"
#include "common/transport/TransportAddress.h"
#include "event/ObjectListener.h"
namespace ubeeme {
namespace moversight {
class Dispatcher;
class Moversight;
class MoversightMessage;
class NFDMessage;
class MoversightTimer;
class VirtualLogicalTime;
class ExteriorMessage;
class UnicastMessage;
class MulticastMessage;
class InteriorMessage;
/**
* @class MoversightService
* @author Jan Gäbler
* @ingroup Moversight
* @brief Defines a common interface for a moversight module.
*/
class MoversightService : public ObjectListener {
friend class MoversightTimer;
public:
MoversightService(Dispatcher & d, std::string name);
MoversightService(const MoversightService & other);
virtual ~MoversightService();
/**
* @brief Initialize the service. Called to setup the defined service.
*/
virtual void initialise() = 0;
/**
* @brief Finalize the module. Clean and stop the running module service.
*/
virtual void finalise() = 0;
MoversightService & operator=(const MoversightService & other);
virtual const PeerState & getLocalPeerState() const;
virtual const State & getLocalState() const;
virtual const SubState & getLocalSubState() const;
virtual const StateOperation & getLocalStateOperation() const;
virtual const State & getState(PeerID id) const;
virtual const SubState & getSubState(PeerID id) const;
virtual const StateOperation & getStateOperation(PeerID id) const;
virtual const VirtualLogicalTime & getCurrentLogicalTime() const;
virtual const VirtualLogicalTime & getLastSeenLogicalTime() const;
virtual ViewID getViewID() const;
virtual ViewID getLastViewID() const;
protected:
virtual PeerIDList getMasterIDList();
virtual Peer & getLocalPeer();
virtual const Peer & getLocalPeer() const;
virtual PeerID getLocalID();
virtual TransportAddress const & getLocalAddress();
virtual PeerID getLocalMasterID() const;
virtual bool isLocalPeerMaster();
virtual void setLocalState(const State & s);
virtual void setLocalSubState(const SubState & sub);
virtual void setLocalStateOperation(const StateOperation & op);
virtual void setState(PeerID id, const State & s);
virtual void setSubState(PeerID id, const SubState & sub);
virtual void setStateOperation(PeerID id, const StateOperation & op);
virtual PeerIDList createReceiverList(PeerID sourcePeerID);
/**
* Common interface for PDU send operations
*/
virtual void sendTo(const MoversightMessage& msg, const TransportAddress& dest, const bool reliable = false);
virtual void sendTo(const MoversightMessage& msg, const PeerID dest, const bool reliable = false);
virtual void sendTo(const MoversightMessage& msg, const PeerIDList& peers, const bool reliable = false);
virtual void sendToCluster(const MoversightMessage& msg, const bool reliable = false);
virtual void sendToMaster(const MoversightMessage& msg, const bool reliable = false);
virtual void sendToAllMasters(const MoversightMessage& msg, const bool reliable = false);
virtual void sendToLastView(const MoversightMessage& msg, const PeerID dest, const bool reliable = false);
virtual void sendToLastView(const MoversightMessage& msg, const PeerIDList& peers, const bool reliable = false);
protected:
/**
* @brief Reference to the moversight dispatcher.
*/
Dispatcher & dispatcher;
/**
* @brief Reference to the moversight module.
*/
Moversight & module;
private:
virtual PeerState & getLocalPeerState();
virtual PeerState & getPeerState(PeerID id);
virtual const PeerState & getPeerState(PeerID id) const;
};
}
}
#endif /* MOVERSIGHTSERVICE_H */

View File

@@ -0,0 +1,32 @@
// -*- C++ -*-
/*
* File: Platform.h
* Author: jgaebler
*
* Created on September 7, 2010, 3:03 PM
*/
#pragma once
#ifndef PLATFORM_H
#define PLATFORM_H
//check for ubeeme core settings
#ifdef UBEEME
//platform settings done in ubeeme/common/ubeeme_global.h
#define OMNETPP 0
#else
/**
* @brief Defines if the current platform is omnetpp or not
*/
#define OMNETPP 1
/**
* @breif Disables the ubeeme platform
*/
#define UBEEME 0
#endif
#endif /* PLATFORM_H */

View File

@@ -0,0 +1,294 @@
/*
* File: Reference.h
* Author: jgaebler
*
* Created on January 30, 2014, 7:39 PM
*/
#pragma once
#ifndef REFERENCE_H
#define REFERENCE_H
#include <serializable.h>
namespace ubeeme {
namespace moversight {
/**
* @brief Provides a basic reference implementation.
* @class Reference
* @ingroup Moversight
* @author Jan G&auml;bler
*/
template <typename T>
class Reference : public Serializable {
template <typename S>
friend std::ostream & operator<<(std::ostream & stream, const Reference<S> & ref);
public:
Reference();
Reference(const T & value);
Reference(const Reference<T> & orig);
virtual ~Reference();
Reference<T> & operator=(const Reference<T> & rhs);
Reference<T> operator+(const unsigned int & rhs);
Reference<T> operator+(const Reference<T> & rhs);
Reference<T> operator-(const Reference<T> & rhs);
Reference<T> operator*(const unsigned int & rhs);
bool operator==(const Reference<T> & rhs) const;
bool operator!=(const Reference<T> & rhs) const;
bool operator<(const Reference<T> & rhs) const;
bool operator>(const Reference<T> & rhs) const;
Reference<T> & operator++(); //++a
Reference<T> operator++(int); //a++
Reference<T> & operator--(); //--a
Reference<T> operator--(int); //a--
void set(Archive &archive);
virtual T getValue() const;
protected:
T value;
};
/**
* @brief Constructor
*/
template <typename T>
Reference<T>::Reference() : value(0) {
}
/**
* @brief Constructor
* @param aValue The initial reference value.
*/
template <typename T>
Reference<T>::Reference(const T & aValue) : value(aValue) {
}
/**
* @brief Constructor
* @param orig The instance to copy
*/
template <typename T>
Reference<T>::Reference(const Reference<T> & orig) : Serializable(orig) {
operator =(orig);
}
/**
* @brief Destructor
*/
template <typename T>
Reference<T>::~Reference() {
}
/**
* @brief Returns a integer representation of the current reference instance.
* @return A integer representation of the current reference instance.
*/
template <typename T>
T
Reference<T>::getValue() const {
return value;
}
/**
* @brief Archive method.
* @param archive The archive to which the attributes are to add.
*/
template <typename T>
void
Reference<T>::set(Archive &archive) {
archive(value);
}
/**
* @brief Addition operation.
* @param rhs the value to add
* @returns The result of the addition.
*/
template <typename T>
Reference<T>
Reference<T>::operator+(const unsigned int & rhs) {
return Reference<T>(value + rhs);
}
/**
* @brief Addition operation.
* @param rhs the value to add
* @returns The result of the addition.
*/
template <typename T>
Reference<T>
Reference<T>::operator+(const Reference<T> & rhs) {
return Reference<T>(value + rhs.value);
}
/**
* @brief Subtraction operation.
* @param rhs the value to add
* @returns The result of the subtraction.
*/
template <typename T>
Reference<T>
Reference<T>::operator-(const Reference<T> & rhs) {
return Reference<T>(value - rhs.value);
}
/**
* @brief Multiplication operation.
* @param rhs the factor to multiply with
* @returns The result of the multiplication.
*/
template <typename T>
Reference<T>
Reference<T>::operator*(const unsigned int & rhs) {
return Reference<T>(value * rhs);
}
/**
* @brief Assignment operator.
* @param rhs The right hand value.
* @return A reference to the new created object.
*/
template <typename T>
Reference<T> &
Reference<T>::operator=(const Reference<T> & rhs) {
if (this == &rhs) {
return *this;
}
Serializable::operator =(rhs);
value = rhs.value;
return *this;
}
/**
* @brief Less operator.
* @param rhs The value to compare.
* @return True, if the local value less than the given one, false otherwise.
*/
template <typename T>
bool
Reference<T>::operator<(const Reference<T> & rhs) const {
return value < rhs.value;
}
/**
* @brief Greater operator.
* @param rhs The value to compare.
* @return True, if the local value greater than the given one, false otherwise.
*/
template <typename T>
bool
Reference<T>::operator>(const Reference<T> & rhs) const {
return value > rhs.value;
}
/**
* @brief Equality operator.
* @param o The object to compare.
* @return True, if the given reference the same than the local, false otherwise.
*/
template <typename T>
bool
Reference<T>::operator==(const Reference<T> & o) const {
return value == o.value;
}
/**
* @brief Not equal operator.
* @param rhs The value to compare.
* @return True, if the local reference not equal to the given, false otherwise.
*/
template <typename T>
bool
Reference<T>::operator!=(const Reference<T> & rhs) const {
return value != rhs.value;
}
/**
* @brief Increments the reference (++a).
* @return A reference to the local instance.
*/
template <typename T>
Reference<T> &
Reference<T>::operator++() {
value++;
return *this;
}
/**
* @brief Increments the reference (a++).
* @return The result of the operation.
*/
template <typename T>
Reference<T>
Reference<T>::operator++(int) {
Reference<T> result(*this);
++(*this);
return result;
}
/**
* @brief Decrements the reference (--a).
* @return A reference to the local instance.
*/
template <typename T>
Reference<T> &
Reference<T>::operator--() {
value--;
return *this;
}
/**
* @brief Decrements the reference (a--).
* @return The result of the operation.
*/
template <typename T>
Reference<T>
Reference<T>::operator--(int) {
Reference<T> result(*this);
--(*this);
return result;
}
/**
* @brief Output operator. Prints a textual representation of the current reference.
* @param stream The output stream to print the textual representation.
* @param mRef The Reference to print.
*/
template <typename S>
std::ostream & operator<<(std::ostream& stream, const Reference<S> & ref) {
return stream << ref.value;
}
}
}
#endif /* REFERENCE_H */

View File

@@ -0,0 +1,338 @@
/*
* File: UbeemeConnector.cc
* Author: noackrob
*
* Created on August 12, 2013, 2:48 PM
*/
#include "common/UbeemeConnector.h"
#include "Moversight.h"
#include "Dispatcher.h"
/** @FIXME There will be a type interference if Ubeeme is enabled. */
#if UBEEME
#include "core/event/event_container.h"
#include "core/event/event_sender.h"
#include "app/events/GroupMessage.h"
#include "app/events/GroupCreatedEvent.h"
#include "app/events/GroupClosedEvent.h"
#include "app/events/JoinGroupDoneEvent.h"
#include "app/events/LocalPeerUpdateEvent.h"
#include "app/events/PeerIsPendingEvent.h"
#include "app/events/PeerJoinedEvent.h"
#include "app/events/PeerLeftEvent.h"
#include "app/events/PeerReconnectedEvent.h"
#include "app/events/SplitNotifyEvent.h"
#include "app/events/SplitDoneEvent.h"
#include "app/events/MergeNotifyEvent.h"
#include "app/events/MergeDoneEvent.h"
#include "debug.h"
#endif
#include "event/events/ConnectionLostEvent.h"
#include "event/events/ConnectionReEstablishedEvent.h"
#include "event/events/FlushStartEvent.h"
#include "merge/events/MergeRequestEvent.h"
#include "merge/events/MergeConfirmEvent.h"
#include "merge/events/MergeRejectedEvent.h"
#include "merge/events/MergeAbortEvent.h"
#include "merge/events/MergeDoneEvent.h"
#include "mob/events/UnableToReconnectToGroupEvent.h"
#include "ms/events/GroupCreatedEvent.h"
#include "ms/events/GroupClosedEvent.h"
#include "ms/events/PeerJoinedEvent.h"
#include "ms/events/PeerLeftEvent.h"
#include "ms/events/JoinGroupDoneEvent.h"
#include "ms/events/LocalPeerUpdatedEvent.h"
#include "ms/events/RejoinDoneEvent.h"
#include "ms/events/RejoinFailedEvent.h"
#include "mt/events/PendingPeersEvent.h"
#include "fd/events/PeerReconnectedEvent.h"
#include "split/events/SplitDoneEvent.h"
#include "split/events/SplitAbortEvent.h"
namespace ubeeme {
namespace moversight {
#undef DEBUG
#define DEBUG(msg) if (module.isPrintDebugUC()) MOV_DEBUG << "UC@" << dispatcher.getLocalPeer().getPeerID()<< " " << msg << endl;
/**
* @brief Constructor.
*/
UbeemeConnector::UbeemeConnector(Dispatcher & dis)
: MoversightService(dis, "UbeemeConnector") {
}
/**
* @brief Copy Constructor.
* @param other Service to copy.
*/
UbeemeConnector::UbeemeConnector(const UbeemeConnector & other)
: MoversightService(other) {
operator=(other);
}
/**
* @brief Assignment operator
* @param other The service to copy.
* @return This service with new values.
*/
UbeemeConnector &
UbeemeConnector::operator=(const UbeemeConnector & other) {
return *this;
}
/**
* @brief Destructor.
*/
UbeemeConnector::~UbeemeConnector() {
}
/**
* @brief Initialization.
*/
void
UbeemeConnector::initialise() {
dispatcher.subscribe<ConnectionLostEvent>(this);
dispatcher.subscribe<ConnectionReEstablishedEvent>(this);
dispatcher.subscribe<UnableToReconnectToGroupEvent>(this);
dispatcher.subscribe<GroupCreatedEvent>(this);
dispatcher.subscribe<GroupClosedEvent>(this);
dispatcher.subscribe<PeerJoinedEvent>(this);
dispatcher.subscribe<PeerLeftEvent>(this);
dispatcher.subscribe<PeerReconnectedEvent>(this);
dispatcher.subscribe<PendingPeersEvent>(this);
dispatcher.subscribe<LocalPeerUpdatedEvent>(this);
dispatcher.subscribe<JoinGroupDoneEvent>(this);
dispatcher.subscribe<RejoinDoneEvent>(this);
dispatcher.subscribe<RejoinFailedEvent>(this);
dispatcher.subscribe<FlushStartEvent>(this);
dispatcher.subscribe<SplitDoneEvent>(this);
dispatcher.subscribe<SplitAbortEvent>(this);
dispatcher.subscribe<MergeRequestEvent>(this);
dispatcher.subscribe<MergeConfirmEvent>(this);
dispatcher.subscribe<MergeRejectedEvent>(this);
dispatcher.subscribe<MergeAbortEvent>(this);
dispatcher.subscribe<MergeDoneEvent>(this);
}
/**
* @brief Cleanup.
*/
void
UbeemeConnector::finalise() {
dispatcher.unsubscribeAll(this);
}
/**
* @brief Handle ConnectionLostEvent.
* @param e The event.
*/
void
UbeemeConnector::handleEvent(const ConnectionLostEvent & e) {
#if UBEEME
#pragma message("SIGNAL CONNECTION LOST NOT IMPLEMENTED YET")
#endif
}
/**
* @brief Handle ConnectionReEstablishedEvent.
* @param e The event.
*/
void
UbeemeConnector::handleEvent(const ConnectionReEstablishedEvent & e) {
#if UBEEME
#pragma message("SIGNAL CONNECTION REESTABLISHED NOT IMPLEMENTED YET")
#endif
}
/**
* @brief Handle UnableToReconnectToGroupEvent.
* @param e The event.
*/
void
UbeemeConnector::handleEvent(const UnableToReconnectToGroupEvent & e) {
#if UBEEME
#pragma message("SIGNAL UNABLE TO RECONNECT TO GROUP NOT IMPLEMENTED YET")
#endif
}
/**
* @brief Handle GroupCreatedEvent.
* @param e The event.
*/
void
UbeemeConnector::handleEvent(const GroupCreatedEvent & e) {
#if UBEEME
EventContainer ev(new GroupCreatedEvent(getLocalPeer()));
sendEvent(ev);
#endif
}
/**
* @brief Handle GroupClosedEvent.
* @param e The event.
*/
void
UbeemeConnector::handleEvent(const GroupClosedEvent & e) {
#if UBEEME
EventContainer ev(new GroupClosedEvent(getLocalPeer()));
sendEvent(ev);
#endif
}
/**
* @brief Handle PeerJoinedEvent.
* @param e The event.
*/
void
UbeemeConnector::handleEvent(const PeerJoinedEvent & e) {
#if UBEEME
EventContainer ev(new PeerJoinedEvent(pId, ta, pDesc));
sendEvent(ev);
#endif
}
/**
* @brief Handle PeerLeftEvent.
* @param e The event.
*/
void
UbeemeConnector::handleEvent(const PeerLeftEvent & e) {
#if UBEEME
EventContainer ev(new PeerLeftEvent(e->getPeer()));
sendEvent(ev);
#endif
}
/**
* @brief Handle PeerReconnectedEvent.
* @param e The event.
*/
void
UbeemeConnector::handleEvent(const PeerReconnectedEvent & e) {
#if UBEEME
EventContainer ev(new PeerReconnectedEvent(e->getPeerID(), e->getTransportAddress()));
sendEvent(ev);
#endif
}
/**
* @brief Handle PendingPeersEvent.
* @param e The event.
*/
void
UbeemeConnector::handleEvent(const PendingPeersEvent & e) {
#if UBEEME
PeerIDList & pList = e->getPeerIDList();
for (size_t i = 0; i < pList.size(); i++) {
EventContainer ev(new PeerIsPendingEvent(pList.get(i), getLocalAddressFromPeer(pList.get(i))));
sendEvent(ev);
}
#endif
}
void
UbeemeConnector::handleEvent(const LocalPeerUpdatedEvent & e) {
#if UBEEME
EventContainer ev(new LocalPeerUpdateEvent(e->getPeer()));
sendEvent(ev);
#endif
}
void
UbeemeConnector::handleEvent(const JoinGroupDoneEvent & e) {
#if UBEEME
EventContainer ev(new JoinGroupDoneEvent(e->getPeer());
sendEvent(ev);
#endif
}
void
UbeemeConnector::handleEvent(const RejoinDoneEvent & e) {
#if UBEEME
EventContainer ev(new RejoinDoneEvent();
sendEvent(ev);
#endif
}
void
UbeemeConnector::handleEvent(const FlushStartEvent & e) {
#if UBEEME
EventContainer ev(new FlushStartEvent());
sendEvent(ev);
#endif
}
void
UbeemeConnector::handleEvent(const SplitDoneEvent & e) {
#if UBEEME
EventContainer ev(new SplitDoneEvent());
sendEvent(ev);
#endif
}
void
UbeemeConnector::handleEvent(const SplitAbortEvent & e) {
#if UBEEME
#pragma message ("SPLIT ABORT EVENT NOT IMPLEMENTED YET")
#endif
}
void
UbeemeConnector::handleEvent(const MergeRequestEvent & e) {
#if UBEEME
#pragma message ("MERGE REQUEST EVENT NOT IMPLEMENTED YET")
#endif
}
void
UbeemeConnector::handleEvent(const MergeConfirmEvent & e) {
#if UBEEME
#pragma message ("MERGE CONFIRM EVENT NOT IMPLEMENTED YET")
#endif
}
void
UbeemeConnector::handleEvent(const MergeRejectedEvent & e) {
#if UBEEME
#pragma message ("MERGE REJECT EVENT NOT IMPLEMENTED YET")
#endif
}
void
UbeemeConnector::handleEvent(const MergeAbortEvent & e) {
#if UBEEME
#pragma message ("MERGE ABORT EVENT NOT IMPLEMENTED YET")
#endif
}
void
UbeemeConnector::handleEvent(const MergeDoneEvent & e) {
#if UBEEME
EventContainer ev(new MergeDoneEvent());
sendEvent(ev);
#endif
}
void
UbeemeConnector::handleEvent(const RejoinFailedEvent & e) {
#if UBEEME
EventContainer ev(new RejoinFailedEvent());
sendEvent(ev);
#endif
}
}
}

View File

@@ -0,0 +1,76 @@
/*
* File: UbeemeConnector.h
* Author: noackrob
*
* Created on August 12, 2013, 2:48 PM
*/
#pragma once
#ifndef UBEEMECONNECTOR_H
#define UBEEMECONNECTOR_H
#include "common/MoversightService.h"
namespace ubeeme {
namespace moversight {
/**
* @brief Service to provide access to other ubeeme components via its own event system
*
* If ubeeme support is enabled, this service will receive every event generated
* by internal moversight modules and inform other components within the ubeeme
* system.
*
* @class UbeemeConnector
* @author Robert Noack
* @ingroup Moversight
*/
#if OMNETPP
class UbeemeConnector : public MoversightService {
#else
class UbeemeConnector : public MoversightService, public EventSender {
#endif
public:
UbeemeConnector(Dispatcher & dis);
UbeemeConnector(const UbeemeConnector& other);
UbeemeConnector& operator=(const UbeemeConnector& other);
virtual ~UbeemeConnector();
virtual void initialise();
virtual void finalise();
virtual void handleEvent(const ConnectionLostEvent& e);
virtual void handleEvent(const ConnectionReEstablishedEvent& e);
virtual void handleEvent(const UnableToReconnectToGroupEvent& e);
virtual void handleEvent(const GroupCreatedEvent& e);
virtual void handleEvent(const GroupClosedEvent& e);
virtual void handleEvent(const PeerJoinedEvent& e);
virtual void handleEvent(const PeerLeftEvent& e);
virtual void handleEvent(const PeerReconnectedEvent& e);
virtual void handleEvent(const PendingPeersEvent& e);
virtual void handleEvent(const LocalPeerUpdatedEvent& e);
virtual void handleEvent(const JoinGroupDoneEvent& e);
virtual void handleEvent(const RejoinDoneEvent& e);
virtual void handleEvent(const RejoinFailedEvent& e);
virtual void handleEvent(const FlushStartEvent& e);
virtual void handleEvent(const SplitDoneEvent& e);
virtual void handleEvent(const SplitAbortEvent& e);
virtual void handleEvent(const MergeRequestEvent& e);
virtual void handleEvent(const MergeConfirmEvent& e);
virtual void handleEvent(const MergeRejectedEvent& e);
virtual void handleEvent(const MergeAbortEvent& e);
virtual void handleEvent(const MergeDoneEvent& e);
};
}
}
#endif /* UBEEMECONNECTOR_H */

View File

@@ -0,0 +1,389 @@
/*
* File: CircularBuffer.h
* Author: jgaebler
*
* Created on October 26, 2012, 1:57 PM
*/
#pragma once
#ifndef CIRCULARBUFFER_H
#define CIRCULARBUFFER_H
#include <boost/circular_buffer.hpp>
namespace ubeeme {
namespace moversight {
/**
* @class CircularBuffer
* @brief Provides a circular buffer for objects.
*
* Provides a circular buffer for objects. The circular buffer
* should not be used for storing pointers to dynamically allocated objects.
* When a circular buffer becomes full, further insertion will overwrite
* the stored pointers - resulting in a memory leak. One recommend alternative
* is the use of smart pointers.
* @ingroup Moversight
* @author Jan G&auml;bler
*/
template <typename T>
class CircularBuffer {
public:
CircularBuffer(size_t size);
CircularBuffer(const CircularBuffer & orig);
virtual ~CircularBuffer();
void add(const T & t);
void clear();
size_t size() const;
size_t maxSize() const;
bool isEmpty() const;
bool isFull() const;
size_t getReserve() const;
void resetCapacity(size_t new_capacity);
size_t getCapacity() const;
void setCapacity(size_t new_capacity);
void resize(size_t new_size);
void pop();
T & get(size_t index);
T const & get(size_t index) const;
protected:
typedef boost::circular_buffer<T> CBuffer;
CBuffer buffer;
public:
typedef typename CBuffer::iterator iterator_type;
typedef typename CBuffer::const_iterator const_iterator_type;
iterator_type erase(iterator_type pos);
iterator_type erase(iterator_type first, iterator_type last);
iterator_type rerase(iterator_type pos);
iterator_type rerase(iterator_type first, iterator_type last);
iterator_type begin();
iterator_type end();
const_iterator_type begin() const;
const_iterator_type end() const;
};
template <typename T>
std::ostream operator<<(std::ostream & s, typename CircularBuffer<T>::iterator_type it){
return s<<*it;
}
/**
* @brief Constructor
* @param size the size of the circular buffer.
*/
template <typename T>
CircularBuffer<T>::CircularBuffer(size_t size) : buffer(size) {
}
/**
* @brief Copy constructor
* @param orig the list to copy
*/
template <typename T>
CircularBuffer<T>::CircularBuffer(const CircularBuffer & orig) : buffer(orig.buffer) {
}
/**
* @brief Destructor
*/
template <typename T>
CircularBuffer<T>::~CircularBuffer() {
}
/**
* @brief Clears the buffer
*/
template <typename T>
void
CircularBuffer<T>::clear() {
buffer.clear();
}
/**
* @brief Adds a object to the buffer
* @param t the object to add
* @return This list.
*/
template <typename T>
void
CircularBuffer<T>::add(const T & t) {
buffer.push_back(t);
}
/**
* @brief Get the number of elements currently stored in the circular buffer.
* @returns The number of elements currently stored in the buffer.
*/
template <typename T>
size_t
CircularBuffer<T>::size() const {
return buffer.size();
}
/**
* @brief Get the largest possible size or capacity of the circular buffer.
* @returns The largest possible size or capacity of the circular buffer.
*/
template <typename T>
size_t
CircularBuffer<T>::maxSize() const {
return buffer.max_size();
}
/**
* @brief Is the circular buffer empty?
* @returns True if there are no elements stored in the buffer; False otherwise.
*/
template <typename T>
bool
CircularBuffer<T>::isEmpty() const {
return buffer.empty();
}
/**
* @brief Is the circular buffer full?
* @returns True if the number of elements stored in the buffer equals the capacity of the buffer; false otherwise.
*/
template <typename T>
bool
CircularBuffer<T>::isFull() const {
return buffer.full();
}
/**
* @brief Get the maximum number of elements which can be inserted into
* the buffer without overwriting any of already stored elements.
* @returns getCapacity() - size()
*/
template <typename T>
size_t
CircularBuffer<T>::getReserve() const {
return buffer.reserve();
}
/**
* @brief Change the capacity of the buffer.
* Effect: getCapacity() == new_capacity && size() <= new_capacity
* If the current number of elements stored in the buffer is greater
* than the desired new capacity then number of [size() - new_capacity]
* first elements will be removed and the new size will be equal to new_capacity.
* @param new_capacity The new capacity.
* @throw An allocation error if memory is exhausted.
*/
template <typename T>
void
CircularBuffer<T>::resetCapacity(size_t new_capacity) {
buffer.rset_capacity(new_capacity);
}
/**
* @brief Get the capacity of the buffer.
* @returns The maximum number of elements which can be stored in the buffer.
*/
template <typename T>
size_t
CircularBuffer<T>::getCapacity() const {
return buffer.capacity();
}
/**
* @brief Change the capacity of the circular_buffer.
* Effect: getCapacity() == new_capacity && size() <= new_capacity
* If the current number of elements stored in the buffer is greater
* than the desired new capacity then number of [size() - new_capacity]
* last elements will be removed and the new size will be equal to new_capacity.
*
* @param new_capacity The new capacity.
* @throw An allocation error if memory is exhausted
*/
template <typename T>
void
CircularBuffer<T>::setCapacity(size_t new_capacity) {
buffer.set_capacity(new_capacity);
}
/**
* @brief Change the size of the buffer.
* Effect: size() == new_size && getCapacity() >= new_size
*
* If the new size is greater than the current size, copies of item will
* be inserted at the back of the of the buffer in order to
* achieve the desired size. In the case the resulting size exceeds the
* current capacity the capacity will be set to new_size.
*
* If the current number of elements stored in the buffer is greater
* than the desired new size then number of [size() - new_size] last
* elements will be removed. (The capacity will remain unchanged.)
*
* @param new_size The new size.
* @throw An allocation error if memory is exhausted.
**/
template <typename T>
void
CircularBuffer<T>::resize(size_t new_size) {
buffer.resize(new_size);
}
/**
* @brief Pops the first element from the buffer.
*/
template <typename T>
void
CircularBuffer<T>::pop() {
buffer.pop_front();
}
/**
* @brief Returns the object from the buffer, which is located at the given index.
* @throws IndexOutOfBounceException if the given index larger than the current size of the buffer
* @param index the index of the element to return
* @return the desired element
*/
template <typename T>
T &
CircularBuffer<T>::get(size_t index) {
if (index > buffer.size()) {
throw IndexOutOfBounceException("index out of bounce");
}//End if
return buffer[index];
}
/**
* @brief Returns the object from the buffer, which is located at the given index.
* @throws IndexOutOfBounceException if the given index larger than the current size of the buffer
* @param index the index of the element to return
* @return the desired element
*/
template <typename T>
T const &
CircularBuffer<T>::get(size_t index) const {
if (index > buffer.size()) {
throw IndexOutOfBounceException("index out of bounce");
}//End if
return buffer[index];
}
/**
* @brief Get the iterator pointing to the beginning of the buffer.
* @return A random access iterator pointing to the first element of the
* buffer. If the buffer is empty it returns an iterator equal to the
* one returned by end().
*/
template<typename T>
typename CircularBuffer<T>::iterator_type
CircularBuffer<T>::begin() {
return buffer.begin();
}
/**
* @brief Get the const iterator pointing to the beginning of the buffer.
* @return A const random access iterator pointing to the first element of the
* buffer. If the buffer is empty it returns an iterator equal to the
* one returned by end() const.
*/
template<typename T>
typename CircularBuffer<T>::const_iterator_type
CircularBuffer<T>::begin() const {
return buffer.begin();
}
/**
* @brief Get the iterator pointing to the end of the buffer.
* @return A random access iterator pointing to the element "one behind"
* the last element of the buffer. If the buffer is empty it returns an
* iterator equal to the one returned by begin().
*/
template<typename T>
typename CircularBuffer<T>::iterator_type
CircularBuffer<T>::end() {
return buffer.end();
}
/**
* @brief Get the const iterator pointing to the end of the buffer.
* @return A const random access iterator pointing to the element "one behind"
* the last element of the buffer. If the buffer is empty it returns an
* iterator equal to the one returned by begin() const.
*/
template<typename T>
typename CircularBuffer<T>::const_iterator_type
CircularBuffer<T>::end() const {
return buffer.end();
}
/**
* @brief Remove an element at the specified position. Precondition:
* pos is a valid iterator pointing to the buffer (but not an end()).
* @param pos An iterator pointing at the element to be removed.
* @return Iterator to the first element remaining beyond the removed
* element or end() if no such element exists.
*/
template<typename T>
typename CircularBuffer<T>::iterator_type
CircularBuffer<T>::erase(iterator_type pos){
return buffer.erase(pos);
}
/**
* @brief Erase the range [first, last). Precondition: Valid range [first, last).
* @param first The beginning of the range to be removed.
* @param last The end of the range to be removed.
* @return Iterator to the first element remaining beyond the removed
* elements or end() if no such element exists.
*/
template<typename T>
typename CircularBuffer<T>::iterator_type
CircularBuffer<T>::erase(iterator_type first, iterator_type last){
return buffer.erase(first, last);
}
/**
* @brief Remove an element at the specified position. Precondition:
* pos is a valid iterator pointing to the buffer (but not an end()).
* @param pos An iterator pointing at the element to be removed.
* @return Iterator to the first element remaining in front of the
* removed element or begin() if no such element exists.
*/
template<typename T>
typename CircularBuffer<T>::iterator_type
CircularBuffer<T>::rerase(iterator_type pos){
return buffer.rerase(pos);
}
/**
* @brief Erase the range [first, last). Precondition: Valid range [first, last).
* @param first The beginning of the range to be removed.
* @param last The end of the range to be removed.
* @return Iterator to the first element remaining in front of the
* removed elements or begin() if no such element exists.
*/
template<typename T>
typename CircularBuffer<T>::iterator_type
CircularBuffer<T>::rerase(iterator_type first, iterator_type last){
return buffer.rerase(first, last);
}
}
}
#endif /* CIRCULARBUFFER_H */

View File

@@ -0,0 +1,24 @@
#include <iostream>
#include "common/container/GroupList.h"
namespace ubeeme {
namespace moversight {
std::ostream&
operator<<( std::ostream & out, const GroupList l) {
out << "[";
if( !l.empty()) {
out << *(l.begin());
for( auto i = (++l.begin()); i != l.end(); i++) {
out << ", " << *i;
}
}
out << "]";
return out;
}
}
}

Some files were not shown because too many files have changed in this diff Show More