diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-11-19 14:48:18 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-11-19 14:48:18 +0000 |
commit | b49684305e14208fa5bffb817a0677df33611878 (patch) | |
tree | bc3c83bb298edc39879d9a0c7bcc7cb761e25d66 /src/ats | |
parent | 77d5149378781178d0b216ef7898ff9ea562209e (diff) | |
download | gnunet-b49684305e14208fa5bffb817a0677df33611878.tar.gz gnunet-b49684305e14208fa5bffb817a0677df33611878.zip |
get normalized pref per client
Diffstat (limited to 'src/ats')
-rw-r--r-- | src/ats/gnunet-service-ats_addresses.c | 30 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_normalization.c | 26 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_normalization.h | 12 | ||||
-rw-r--r-- | src/ats/perf_ats_solver.c | 2 |
4 files changed, 64 insertions, 6 deletions
diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c index 7d0eb48ea..833a26c41 100644 --- a/src/ats/gnunet-service-ats_addresses.c +++ b/src/ats/gnunet-service-ats_addresses.c | |||
@@ -1460,6 +1460,10 @@ GAS_addresses_evaluate_assignment (struct GAS_Addresses_Handle *ah) | |||
1460 | struct SummaryContext sum; | 1460 | struct SummaryContext sum; |
1461 | int network_count; | 1461 | int network_count; |
1462 | 1462 | ||
1463 | /* Variables for preferences */ | ||
1464 | int prefs[GNUNET_ATS_PreferenceCount] = GNUNET_ATS_PreferenceType; | ||
1465 | double pref_val; | ||
1466 | |||
1463 | GNUNET_assert (NULL != ah); | 1467 | GNUNET_assert (NULL != ah); |
1464 | GNUNET_assert (NULL != ah->addresses); | 1468 | GNUNET_assert (NULL != ah->addresses); |
1465 | 1469 | ||
@@ -1530,12 +1534,32 @@ GAS_addresses_evaluate_assignment (struct GAS_Addresses_Handle *ah) | |||
1530 | 1534 | ||
1531 | /* 3) How well does selection match application requirements */ | 1535 | /* 3) How well does selection match application requirements */ |
1532 | include_requirements = GNUNET_NO; | 1536 | include_requirements = GNUNET_NO; |
1533 | for (pcur = ah->preference_clients_head; NULL != pcur; pcur = pcur->next) | 1537 | if (0 == ah->pref_clients) |
1534 | { | 1538 | { |
1535 | /* V metrics*/ | 1539 | include_requirements = GNUNET_NO; |
1540 | } | ||
1541 | else | ||
1542 | { | ||
1543 | for (pcur = ah->preference_clients_head; NULL != pcur; pcur = pcur->next) | ||
1536 | { | 1544 | { |
1537 | /* V peers */ | 1545 | /* V metrics*/ |
1546 | for (c = 0; c < GNUNET_ATS_PreferenceCount; c++) | ||
1547 | { | ||
1548 | |||
1549 | if (prefs[c] == GNUNET_ATS_PREFERENCE_END) | ||
1550 | continue; | ||
1551 | pref_val = -1.0; | ||
1552 | pref_val = GAS_normalization_get_preferences_by_client (pcur->client, prefs[c]); | ||
1553 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "normalized pref for client %p == %.3f\n", | ||
1554 | pcur->client, pref_val); | ||
1555 | if (-1.0 == pref_val) | ||
1556 | { | ||
1557 | GNUNET_break (0); | ||
1558 | continue; | ||
1559 | } | ||
1560 | } | ||
1538 | } | 1561 | } |
1562 | include_requirements = GNUNET_YES; | ||
1539 | } | 1563 | } |
1540 | /* GUQ */ | 1564 | /* GUQ */ |
1541 | 1565 | ||
diff --git a/src/ats/gnunet-service-ats_normalization.c b/src/ats/gnunet-service-ats_normalization.c index 96936332a..9a4e72665 100644 --- a/src/ats/gnunet-service-ats_normalization.c +++ b/src/ats/gnunet-service-ats_normalization.c | |||
@@ -519,6 +519,30 @@ GAS_normalization_get_preferences_by_peer (const struct GNUNET_PeerIdentity *id) | |||
519 | } | 519 | } |
520 | 520 | ||
521 | /** | 521 | /** |
522 | * Get the normalized preference values for a specific peer or | ||
523 | * the default values if | ||
524 | * | ||
525 | * @param id the peer | ||
526 | * @return pointer to the values, can be indexed with GNUNET_ATS_PreferenceKind, | ||
527 | * default preferences if peer does not exist | ||
528 | */ | ||
529 | const double | ||
530 | GAS_normalization_get_preferences_by_client (const void *client, enum GNUNET_ATS_PreferenceKind pref) | ||
531 | { | ||
532 | struct PreferenceClient *c_cur; | ||
533 | /* Find preference client */ | ||
534 | for (c_cur = pc_head; NULL != c_cur; c_cur = c_cur->next) | ||
535 | { | ||
536 | if (client == c_cur->client) | ||
537 | break; | ||
538 | } | ||
539 | if (NULL == c_cur) | ||
540 | return -1; | ||
541 | |||
542 | return 1.0; | ||
543 | } | ||
544 | |||
545 | /** | ||
522 | * Get the normalized properties values for a specific peer or | 546 | * Get the normalized properties values for a specific peer or |
523 | * the default values if | 547 | * the default values if |
524 | * | 548 | * |
@@ -922,8 +946,6 @@ GAS_normalization_stop () | |||
922 | { | 946 | { |
923 | struct PreferenceClient *pc; | 947 | struct PreferenceClient *pc; |
924 | struct PreferenceClient *next_pc; | 948 | struct PreferenceClient *next_pc; |
925 | struct PreferencePeer *p; | ||
926 | struct PreferencePeer *next_p; | ||
927 | 949 | ||
928 | if (GNUNET_SCHEDULER_NO_TASK != aging_task) | 950 | if (GNUNET_SCHEDULER_NO_TASK != aging_task) |
929 | { | 951 | { |
diff --git a/src/ats/gnunet-service-ats_normalization.h b/src/ats/gnunet-service-ats_normalization.h index 43b07910f..e1f5a5345 100644 --- a/src/ats/gnunet-service-ats_normalization.h +++ b/src/ats/gnunet-service-ats_normalization.h | |||
@@ -69,6 +69,18 @@ GAS_normalization_get_preferences_by_peer (const struct GNUNET_PeerIdentity *id) | |||
69 | const double * | 69 | const double * |
70 | GAS_normalization_get_properties (struct ATS_Address *address); | 70 | GAS_normalization_get_properties (struct ATS_Address *address); |
71 | 71 | ||
72 | |||
73 | /** | ||
74 | * Get the normalized preference values for a specific client | ||
75 | * | ||
76 | * @param client the client | ||
77 | * @param pref desired pref value | ||
78 | * @return normalized value | ||
79 | */ | ||
80 | const double | ||
81 | GAS_normalization_get_preferences_by_client (const void *client, | ||
82 | enum GNUNET_ATS_PreferenceKind pref); | ||
83 | |||
72 | /** | 84 | /** |
73 | * Normalize an updated preference value | 85 | * Normalize an updated preference value |
74 | * | 86 | * |
diff --git a/src/ats/perf_ats_solver.c b/src/ats/perf_ats_solver.c index d4723534d..7767e5496 100644 --- a/src/ats/perf_ats_solver.c +++ b/src/ats/perf_ats_solver.c | |||
@@ -313,7 +313,7 @@ bandwidth_changed_cb (void *cls, struct ATS_Address *address) | |||
313 | const double * | 313 | const double * |
314 | get_preferences_cb (void *cls, const struct GNUNET_PeerIdentity *id) | 314 | get_preferences_cb (void *cls, const struct GNUNET_PeerIdentity *id) |
315 | { | 315 | { |
316 | return GAS_normalization_get_preferences (id); | 316 | return GAS_normalization_get_preferences_by_peer (id); |
317 | } | 317 | } |
318 | 318 | ||
319 | 319 | ||