|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.lang.Thread | +--algod.SommetAbstract | +--algod.SommetIO | +--algod.SommetElection
Ajoute la capacité d'élection à un sommet. Election du sommet ayant le plus de voisin, en cas d'égalité, élection du plus gros identifiant.
Field Summary | |
protected AlgoDMessageFIFO |
algoDMessageFIFO
File d'attente des messages provenant d'autres sommets. |
(package private) int |
identElu
Identifiant du sommet élu. -1 si pas encore élu. |
protected int |
identifiant
Identifiant unique de ce sommet. |
private int |
maxIdent
Identifiant maximum des sommets candidats à l'élection |
private int |
maxNbVoisins
Nombre de sommets du meilleur candidat à l'élection |
(package private) static int |
nbMessagesElection
|
private IntVector |
nbRep
Tableau indiquant, pour les sommets supposés du graphe, le nombre de réponses attendues. |
private int |
nbSommetsPossibles
Nombre de sommets supposés dans le graphe. |
private BooleanVector |
participant
Tableau indiquant, parmis les sommets supposés du graphe, ceux qui participent. |
(package private) static int |
rndDelaiTransmission
|
(package private) IntVector |
route
Tableau indiquant, pour les sommets supposés du graphe, le voisin qui relaie la communication. |
static boolean |
verbose
Indique si un texte doit apparaître lors de certaines actions comme l'envoit de messages. |
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
SommetElection(int identifiant)
|
Method Summary | |
(package private) void |
acteCandidature()
Démarre un acte de candidature. |
(package private) void |
affiche(java.lang.String texte)
Affiche du texte sur la sortie standard. |
(package private) void |
afficheErreur(java.lang.String texte)
Affiche du texte sur la sortie standard. |
protected int |
ajoutVoisin(AlgoDMessageFIFO aAlgoDMessageFIFO,
int aIdentifiant)
Ajoute un voisin à ce sommet. |
protected int |
ajoutVoisin(SommetVoisin unSommet)
Ajoute un voisin à ce sommet. |
(package private) void |
attend(long millis)
Attend un certain nombre de millisecondes. |
protected void |
demarreElection()
|
void |
destroy()
Arrête le thread et nettoie ses structures et moyens de communication. |
(package private) void |
envoyerASommet(char typeMessage,
java.lang.String contenu,
int identSommetSource,
SommetVoisin sommetVoisin)
|
(package private) void |
envoyerASommet(char typeMessage,
java.lang.String contenu,
int identSommetSource,
SommetVoisin sommetVoisin,
int identSommetDestination)
|
protected void |
envoyerATousVoisins(char typeMessage,
java.lang.String contenu,
int identSommetSource)
Envoie un message à tous les voisins. |
protected void |
envoyerATousVoisinsSauf(char typeMessage,
java.lang.String contenu,
int identSommetSource,
int numVoisin)
Envoie un message à tous les voisins sauf un. |
protected void |
envoyerAVoisin(char typeMessage,
java.lang.String contenu,
int identSommetSource,
int numVoisin)
|
protected void |
envoyerAVoisin(char typeMessage,
java.lang.String contenu,
int identSommetSource,
int numVoisin,
int identSommetDestination)
Envoie un message de type typeMessage, provenant du sommet identSommetSource que l'on achemine par le voisin numVoisin pour le sommet identSommetDestination. |
protected void |
finElection()
Méthode invoquée lorsque l'algorithme d'élection est terminé. |
int |
getIdentifiant()
Accès à l'identifiant de ce sommet. |
SommetVoisin |
getVoisin(int ident)
|
SommetVoisin |
getVoisinAt(int num)
|
protected void |
initialisationElection(int nbSomm)
|
boolean |
isElu()
Retourne si ce sommet est l'élu de son groupe. |
boolean |
isFini()
Indique que le sommet n'a plus de message à traiter dans la file d'attente. |
private boolean |
isMeilleur(int nbDeVoisins,
int id)
|
boolean |
isVoisin(int ident)
Teste si un sommet est voisin de celui-ci. |
int |
nbVoisins()
|
int |
numOfVoisin(int ident)
|
private void |
receptionAccuse(int sommet_source,
int numVoisin,
boolean valeur)
Traitement d'un message d'accusé-réception. |
private void |
receptionElu(int sommet_source,
int numVoisin)
Réception d'un message contenant l'identifiant de l'élu. |
private void |
receptionIdentifiant(int sommet_source,
int nbDeVoisins,
int numVoisin)
Traitement d'un message de diffusion. |
void |
recevoir(AlgoDMessage adm)
Ajoute un message provenant d'un autre sommet à la file des messages. |
(package private) void |
sonnerie()
Fait un beep |
java.lang.String |
toString()
Informations sur ce sommet. |
protected void |
traiteReception(AlgoDMessage adm,
int numVoisin)
Appelle les méthodes appropriées en fonction du message à traiter aprés un parsage éventuel. |
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, yield |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
static int nbMessagesElection
private BooleanVector participant
private IntVector nbRep
IntVector route
private int nbSommetsPossibles
private int maxIdent
maxNbVoisins
,
identElu
private int maxNbVoisins
maxIdent
,
identElu
int identElu
maxIdent
,
maxNbVoisins
static int rndDelaiTransmission
protected AlgoDMessageFIFO algoDMessageFIFO
public static boolean verbose
protected final int identifiant
Constructor Detail |
public SommetElection(int identifiant)
Method Detail |
public void destroy()
SommetAbstract
destroy
in class SommetIO
protected void initialisationElection(int nbSomm)
protected int ajoutVoisin(SommetVoisin unSommet)
SommetAbstract
ajoutVoisin
in class SommetAbstract
public final boolean isElu()
protected void demarreElection()
protected void finElection()
final void acteCandidature()
protected void traiteReception(AlgoDMessage adm, int numVoisin)
SommetIO
traiteReception
in class SommetIO
private boolean isMeilleur(int nbDeVoisins, int id)
nbDeVoisins
- Nombre de voisins du candidat.id
- Identifiant du candidat (pour un ordre total en cas d'égalité sur le nombre de voisins).
private void receptionIdentifiant(int sommet_source, int nbDeVoisins, int numVoisin)
private void receptionAccuse(int sommet_source, int numVoisin, boolean valeur)
private void receptionElu(int sommet_source, int numVoisin)
public java.lang.String toString()
SommetAbstract
toString
in class SommetIO
final void envoyerASommet(char typeMessage, java.lang.String contenu, int identSommetSource, SommetVoisin sommetVoisin, int identSommetDestination)
final void envoyerASommet(char typeMessage, java.lang.String contenu, int identSommetSource, SommetVoisin sommetVoisin)
protected final void envoyerAVoisin(char typeMessage, java.lang.String contenu, int identSommetSource, int numVoisin, int identSommetDestination)
protected final void envoyerAVoisin(char typeMessage, java.lang.String contenu, int identSommetSource, int numVoisin)
protected final void envoyerATousVoisins(char typeMessage, java.lang.String contenu, int identSommetSource)
protected final void envoyerATousVoisinsSauf(char typeMessage, java.lang.String contenu, int identSommetSource, int numVoisin)
numVoisin
- le numéro du voisin à ignorer (pas son identifiant).public final boolean isFini()
public final void recevoir(AlgoDMessage adm)
SommetIO.algoDMessageFIFO
public final int getIdentifiant()
public final boolean isVoisin(int ident)
ident
- identifiant du sommet potentiellement voisin de celui-ci.
public final SommetVoisin getVoisinAt(int num)
num
- le numéro du voisin auquel on veut avoir accés.
public final SommetVoisin getVoisin(int ident)
ident
- l'identifiant du voisin auquel on veut avoir accés.
public final int numOfVoisin(int ident)
ident
- l'identifiant d'un sommet voisin de ce sommet.
public final int nbVoisins()
protected final int ajoutVoisin(AlgoDMessageFIFO aAlgoDMessageFIFO, int aIdentifiant)
void affiche(java.lang.String texte)
void afficheErreur(java.lang.String texte)
void sonnerie()
final void attend(long millis)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |