diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-03-31 15:35:00 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-03-31 15:35:00 +0000 |
commit | dfe8a19d9d0aebc8711992a99628732dbe674621 (patch) | |
tree | 12f188f126d79ac73f8d46f112b53e34c7e5e677 /src/fs | |
parent | b6f0365dd1cf3fbd6af64500cf9547583989e68b (diff) | |
download | gnunet-dfe8a19d9d0aebc8711992a99628732dbe674621.tar.gz gnunet-dfe8a19d9d0aebc8711992a99628732dbe674621.zip |
fix migration support
Diffstat (limited to 'src/fs')
-rw-r--r-- | src/fs/gnunet-service-fs_cp.c | 5 | ||||
-rw-r--r-- | src/fs/gnunet-service-fs_cp.h | 5 | ||||
-rw-r--r-- | src/fs/gnunet-service-fs_pr.c | 81 | ||||
-rw-r--r-- | src/fs/gnunet-service-fs_push.c | 8 |
4 files changed, 85 insertions, 14 deletions
diff --git a/src/fs/gnunet-service-fs_cp.c b/src/fs/gnunet-service-fs_cp.c index 3298a5216..702442bb2 100644 --- a/src/fs/gnunet-service-fs_cp.c +++ b/src/fs/gnunet-service-fs_cp.c | |||
@@ -509,6 +509,7 @@ revive_migration (void *cls, | |||
509 | * Get a handle for a connected peer. | 509 | * Get a handle for a connected peer. |
510 | * | 510 | * |
511 | * @param peer peer's identity | 511 | * @param peer peer's identity |
512 | * @return NULL if the peer is not currently connected | ||
512 | */ | 513 | */ |
513 | struct GSF_ConnectedPeer * | 514 | struct GSF_ConnectedPeer * |
514 | GSF_peer_get_ (const struct GNUNET_PeerIdentity *peer) | 515 | GSF_peer_get_ (const struct GNUNET_PeerIdentity *peer) |
@@ -548,6 +549,10 @@ GSF_handle_p2p_migration_stop_ (void *cls, | |||
548 | return GNUNET_OK; | 549 | return GNUNET_OK; |
549 | } | 550 | } |
550 | bt = GNUNET_TIME_relative_ntoh (msm->duration); | 551 | bt = GNUNET_TIME_relative_ntoh (msm->duration); |
552 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
553 | _("Migration of content to peer `%s' blocked for %llu ms\n"), | ||
554 | GNUNET_i2s (other), | ||
555 | (unsigned long long) bt.rel_value); | ||
551 | cp->ppd.migration_blocked_until = GNUNET_TIME_relative_to_absolute (bt); | 556 | cp->ppd.migration_blocked_until = GNUNET_TIME_relative_to_absolute (bt); |
552 | if (cp->mig_revive_task == GNUNET_SCHEDULER_NO_TASK) | 557 | if (cp->mig_revive_task == GNUNET_SCHEDULER_NO_TASK) |
553 | { | 558 | { |
diff --git a/src/fs/gnunet-service-fs_cp.h b/src/fs/gnunet-service-fs_cp.h index 7b8cf40ab..2925dd8ae 100644 --- a/src/fs/gnunet-service-fs_cp.h +++ b/src/fs/gnunet-service-fs_cp.h | |||
@@ -110,6 +110,10 @@ struct GSF_PeerPerformanceData | |||
110 | */ | 110 | */ |
111 | unsigned int pending_replies; | 111 | unsigned int pending_replies; |
112 | 112 | ||
113 | /** | ||
114 | * How many of the last blocks from migration were duplicates? | ||
115 | */ | ||
116 | unsigned int migration_duplication; | ||
113 | }; | 117 | }; |
114 | 118 | ||
115 | 119 | ||
@@ -175,6 +179,7 @@ GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer, | |||
175 | * Get a handle for a connected peer. | 179 | * Get a handle for a connected peer. |
176 | * | 180 | * |
177 | * @param peer peer's identity | 181 | * @param peer peer's identity |
182 | * @return NULL if this peer is not currently connected | ||
178 | */ | 183 | */ |
179 | struct GSF_ConnectedPeer * | 184 | struct GSF_ConnectedPeer * |
180 | GSF_peer_get_ (const struct GNUNET_PeerIdentity *peer); | 185 | GSF_peer_get_ (const struct GNUNET_PeerIdentity *peer); |
diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c index ed156daf5..f6b31c4e2 100644 --- a/src/fs/gnunet-service-fs_pr.c +++ b/src/fs/gnunet-service-fs_pr.c | |||
@@ -760,6 +760,30 @@ process_reply (void *cls, | |||
760 | 760 | ||
761 | 761 | ||
762 | /** | 762 | /** |
763 | * Context for the 'put_migration_continuation'. | ||
764 | */ | ||
765 | struct PutMigrationContext | ||
766 | { | ||
767 | |||
768 | /** | ||
769 | * Start time for the operation. | ||
770 | */ | ||
771 | struct GNUNET_TIME_Absolute start; | ||
772 | |||
773 | /** | ||
774 | * Request origin. | ||
775 | */ | ||
776 | struct GNUNET_PeerIdentity origin; | ||
777 | |||
778 | /** | ||
779 | * GNUNET_YES if we had a matching request for this block, | ||
780 | * GNUNET_NO if not. | ||
781 | */ | ||
782 | int requested; | ||
783 | }; | ||
784 | |||
785 | |||
786 | /** | ||
763 | * Continuation called to notify client about result of the | 787 | * Continuation called to notify client about result of the |
764 | * operation. | 788 | * operation. |
765 | * | 789 | * |
@@ -772,11 +796,37 @@ put_migration_continuation (void *cls, | |||
772 | int success, | 796 | int success, |
773 | const char *msg) | 797 | const char *msg) |
774 | { | 798 | { |
775 | struct GNUNET_TIME_Absolute *start = cls; | 799 | struct PutMigrationContext *pmc = cls; |
776 | struct GNUNET_TIME_Relative delay; | 800 | struct GNUNET_TIME_Relative delay; |
777 | 801 | struct GNUNET_TIME_Relative block_time; | |
778 | delay = GNUNET_TIME_absolute_get_duration (*start); | 802 | struct GSF_ConnectedPeer *cp; |
779 | GNUNET_free (start); | 803 | struct GSF_PeerPerformanceData *ppd; |
804 | |||
805 | delay = GNUNET_TIME_absolute_get_duration (pmc->start); | ||
806 | cp = GSF_peer_get_ (&pmc->origin); | ||
807 | if ( (GNUNET_OK != success) && | ||
808 | (GNUNET_NO == pmc->requested) ) | ||
809 | { | ||
810 | /* block migration for a bit... */ | ||
811 | if (NULL != cp) | ||
812 | { | ||
813 | ppd = GSF_get_peer_performance_data_ (cp); | ||
814 | ppd->migration_duplication++; | ||
815 | block_time = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | ||
816 | 5 * ppd->migration_duplication + | ||
817 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 5)); | ||
818 | GSF_block_peer_migration_ (cp, block_time); | ||
819 | } | ||
820 | } | ||
821 | else | ||
822 | { | ||
823 | if (NULL != cp) | ||
824 | { | ||
825 | ppd = GSF_get_peer_performance_data_ (cp); | ||
826 | ppd->migration_duplication = 0; /* reset counter */ | ||
827 | } | ||
828 | } | ||
829 | GNUNET_free (pmc); | ||
780 | /* FIXME: should we really update the load value on failure? */ | 830 | /* FIXME: should we really update the load value on failure? */ |
781 | GNUNET_LOAD_update (datastore_put_load, | 831 | GNUNET_LOAD_update (datastore_put_load, |
782 | delay.rel_value); | 832 | delay.rel_value); |
@@ -842,7 +892,7 @@ handle_dht_reply (void *cls, | |||
842 | { | 892 | { |
843 | struct GSF_PendingRequest *pr = cls; | 893 | struct GSF_PendingRequest *pr = cls; |
844 | struct ProcessReplyClosure prq; | 894 | struct ProcessReplyClosure prq; |
845 | struct GNUNET_TIME_Absolute *start; | 895 | struct PutMigrationContext *pmc; |
846 | 896 | ||
847 | memset (&prq, 0, sizeof (prq)); | 897 | memset (&prq, 0, sizeof (prq)); |
848 | prq.data = data; | 898 | prq.data = data; |
@@ -859,8 +909,9 @@ handle_dht_reply (void *cls, | |||
859 | GNUNET_h2s (key), | 909 | GNUNET_h2s (key), |
860 | prq.priority); | 910 | prq.priority); |
861 | #endif | 911 | #endif |
862 | start = GNUNET_malloc (sizeof (struct GNUNET_TIME_Absolute)); | 912 | pmc = GNUNET_malloc (sizeof (struct PutMigrationContext)); |
863 | *start = GNUNET_TIME_absolute_get (); | 913 | pmc->start = GNUNET_TIME_absolute_get (); |
914 | pmc->requested = GNUNET_YES; | ||
864 | GNUNET_DATASTORE_put (GSF_dsh, | 915 | GNUNET_DATASTORE_put (GSF_dsh, |
865 | 0, key, size, data, | 916 | 0, key, size, data, |
866 | type, prq.priority, 1 /* anonymity */, | 917 | type, prq.priority, 1 /* anonymity */, |
@@ -868,7 +919,7 @@ handle_dht_reply (void *cls, | |||
868 | 1 + prq.priority, MAX_DATASTORE_QUEUE, | 919 | 1 + prq.priority, MAX_DATASTORE_QUEUE, |
869 | GNUNET_CONSTANTS_SERVICE_TIMEOUT, | 920 | GNUNET_CONSTANTS_SERVICE_TIMEOUT, |
870 | &put_migration_continuation, | 921 | &put_migration_continuation, |
871 | start); | 922 | pmc); |
872 | } | 923 | } |
873 | } | 924 | } |
874 | 925 | ||
@@ -1124,7 +1175,7 @@ GSF_handle_p2p_content_ (struct GSF_ConnectedPeer *cp, | |||
1124 | struct ProcessReplyClosure prq; | 1175 | struct ProcessReplyClosure prq; |
1125 | struct GNUNET_TIME_Relative block_time; | 1176 | struct GNUNET_TIME_Relative block_time; |
1126 | double putl; | 1177 | double putl; |
1127 | struct GNUNET_TIME_Absolute *start; | 1178 | struct PutMigrationContext *pmc; |
1128 | 1179 | ||
1129 | msize = ntohs (message->size); | 1180 | msize = ntohs (message->size); |
1130 | if (msize < sizeof (struct PutMessage)) | 1181 | if (msize < sizeof (struct PutMessage)) |
@@ -1178,8 +1229,11 @@ GSF_handle_p2p_content_ (struct GSF_ConnectedPeer *cp, | |||
1178 | GNUNET_h2s (&query), | 1229 | GNUNET_h2s (&query), |
1179 | prq.priority); | 1230 | prq.priority); |
1180 | #endif | 1231 | #endif |
1181 | start = GNUNET_malloc (sizeof (struct GNUNET_TIME_Absolute)); | 1232 | pmc = GNUNET_malloc (sizeof (struct PutMigrationContext)); |
1182 | *start = GNUNET_TIME_absolute_get (); | 1233 | pmc->start = GNUNET_TIME_absolute_get (); |
1234 | pmc->requested = prq.request_found; | ||
1235 | GNUNET_PEER_resolve (GSF_get_peer_performance_data_ (cp)->pid, | ||
1236 | &pmc->origin); | ||
1183 | GNUNET_DATASTORE_put (GSF_dsh, | 1237 | GNUNET_DATASTORE_put (GSF_dsh, |
1184 | 0, &query, dsize, &put[1], | 1238 | 0, &query, dsize, &put[1], |
1185 | type, prq.priority, 1 /* anonymity */, | 1239 | type, prq.priority, 1 /* anonymity */, |
@@ -1187,7 +1241,7 @@ GSF_handle_p2p_content_ (struct GSF_ConnectedPeer *cp, | |||
1187 | 1 + prq.priority, MAX_DATASTORE_QUEUE, | 1241 | 1 + prq.priority, MAX_DATASTORE_QUEUE, |
1188 | GNUNET_CONSTANTS_SERVICE_TIMEOUT, | 1242 | GNUNET_CONSTANTS_SERVICE_TIMEOUT, |
1189 | &put_migration_continuation, | 1243 | &put_migration_continuation, |
1190 | start); | 1244 | pmc); |
1191 | } | 1245 | } |
1192 | else | 1246 | else |
1193 | { | 1247 | { |
@@ -1232,6 +1286,9 @@ GSF_pending_request_init_ () | |||
1232 | _("Configuration fails to specify `%s', assuming default value."), | 1286 | _("Configuration fails to specify `%s', assuming default value."), |
1233 | "MAX_PENDING_REQUESTS"); | 1287 | "MAX_PENDING_REQUESTS"); |
1234 | } | 1288 | } |
1289 | active_to_migration = GNUNET_CONFIGURATION_get_value_yesno (GSF_cfg, | ||
1290 | "FS", | ||
1291 | "CONTENT_CACHING"); | ||
1235 | datastore_put_load = GNUNET_LOAD_value_init (DATASTORE_LOAD_AUTODECLINE); | 1292 | datastore_put_load = GNUNET_LOAD_value_init (DATASTORE_LOAD_AUTODECLINE); |
1236 | pr_map = GNUNET_CONTAINER_multihashmap_create (32 * 1024); | 1293 | pr_map = GNUNET_CONTAINER_multihashmap_create (32 * 1024); |
1237 | requests_by_expiration_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); | 1294 | requests_by_expiration_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); |
diff --git a/src/fs/gnunet-service-fs_push.c b/src/fs/gnunet-service-fs_push.c index b96ee3d1c..38d916832 100644 --- a/src/fs/gnunet-service-fs_push.c +++ b/src/fs/gnunet-service-fs_push.c | |||
@@ -525,9 +525,11 @@ process_migration_content (void *cls, | |||
525 | } | 525 | } |
526 | #if DEBUG_FS | 526 | #if DEBUG_FS |
527 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 527 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
528 | "Retrieved block `%s' of type %u for migration\n", | 528 | "Retrieved block `%s' of type %u for migration (queue size: %u/%u)\n", |
529 | GNUNET_h2s (key), | 529 | GNUNET_h2s (key), |
530 | type); | 530 | type, |
531 | mig_size + 1, | ||
532 | MIGRATION_LIST_SIZE); | ||
531 | #endif | 533 | #endif |
532 | mb = GNUNET_malloc (sizeof (struct MigrationReadyBlock) + size); | 534 | mb = GNUNET_malloc (sizeof (struct MigrationReadyBlock) + size); |
533 | mb->query = *key; | 535 | mb->query = *key; |
@@ -570,6 +572,8 @@ gather_migration_blocks (void *cls, | |||
570 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 572 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
571 | { | 573 | { |
572 | mig_task = GNUNET_SCHEDULER_NO_TASK; | 574 | mig_task = GNUNET_SCHEDULER_NO_TASK; |
575 | if (mig_size >= MAX_MIGRATION_QUEUE) | ||
576 | return; | ||
573 | if (GSF_dsh != NULL) | 577 | if (GSF_dsh != NULL) |
574 | { | 578 | { |
575 | mig_qe = GNUNET_DATASTORE_get_random (GSF_dsh, | 579 | mig_qe = GNUNET_DATASTORE_get_random (GSF_dsh, |