comparison Plugin/Plugin.cpp @ 10:c9e28e31262e

new option: MaxHttpRetries
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 04 Mar 2019 15:26:49 +0100
parents 7e207ade2f1a
children 34b1875c8e3a
comparison
equal deleted inserted replaced
9:7e207ade2f1a 10:c9e28e31262e
272 return; 272 return;
273 } 273 }
274 274
275 OrthancPlugins::TransferQuery query(body); 275 OrthancPlugins::TransferQuery query(body);
276 276
277 SubmitJob(output, new OrthancPlugins::PullJob( 277 SubmitJob(output, new OrthancPlugins::PullJob(query, context.GetThreadsCount(),
278 query, context.GetThreadsCount(), context.GetTargetBucketSize()), 278 context.GetTargetBucketSize(),
279 context.GetMaxHttpRetries()),
279 query.GetPriority()); 280 query.GetPriority());
280 } 281 }
281 282
282 283
283 284
450 451
451 Json::FastWriter writer; 452 Json::FastWriter writer;
452 std::string s = writer.write(lookup); 453 std::string s = writer.write(lookup);
453 454
454 Json::Value answer; 455 Json::Value answer;
455 if (peers.DoPost(answer, query.GetPeer(), URI_PULL, s) && 456 if (DoPostPeer(answer, peers, query.GetPeer(), URI_PULL, s, context.GetMaxHttpRetries()) &&
456 answer.type() == Json::objectValue && 457 answer.type() == Json::objectValue &&
457 answer.isMember(KEY_ID) && 458 answer.isMember(KEY_ID) &&
458 answer.isMember(KEY_PATH) && 459 answer.isMember(KEY_PATH) &&
459 answer[KEY_ID].type() == Json::stringValue && 460 answer[KEY_ID].type() == Json::stringValue &&
460 answer[KEY_PATH].type() == Json::stringValue) 461 answer[KEY_PATH].type() == Json::stringValue)
477 } 478 }
478 } 479 }
479 else 480 else
480 { 481 {
481 SubmitJob(output, new OrthancPlugins::PushJob(query, context.GetCache(), 482 SubmitJob(output, new OrthancPlugins::PushJob(query, context.GetCache(),
482 context.GetThreadsCount(), context.GetTargetBucketSize()), 483 context.GetThreadsCount(),
484 context.GetTargetBucketSize(),
485 context.GetMaxHttpRetries()),
483 query.GetPriority()); 486 query.GetPriority());
484 } 487 }
485 } 488 }
486 489
487 490
518 521
519 if (type == JOB_TYPE_PULL) 522 if (type == JOB_TYPE_PULL)
520 { 523 {
521 job.reset(new OrthancPlugins::PullJob(query, 524 job.reset(new OrthancPlugins::PullJob(query,
522 context.GetThreadsCount(), 525 context.GetThreadsCount(),
523 context.GetTargetBucketSize())); 526 context.GetTargetBucketSize(),
527 context.GetMaxHttpRetries()));
524 } 528 }
525 else if (type == JOB_TYPE_PUSH) 529 else if (type == JOB_TYPE_PUSH)
526 { 530 {
527 job.reset(new OrthancPlugins::PushJob(query, 531 job.reset(new OrthancPlugins::PushJob(query,
528 context.GetCache(), 532 context.GetCache(),
529 context.GetThreadsCount(), 533 context.GetThreadsCount(),
530 context.GetTargetBucketSize())); 534 context.GetTargetBucketSize(),
535 context.GetMaxHttpRetries()));
531 } 536 }
532 537
533 if (job.get() == NULL) 538 if (job.get() == NULL)
534 { 539 {
535 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); 540 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
635 { 640 {
636 size_t threadsCount = 4; 641 size_t threadsCount = 4;
637 size_t targetBucketSize = 4096; // In KB 642 size_t targetBucketSize = 4096; // In KB
638 size_t maxPushTransactions = 4; 643 size_t maxPushTransactions = 4;
639 size_t memoryCacheSize = 512; // In MB 644 size_t memoryCacheSize = 512; // In MB
645 unsigned int maxHttpRetries = 0;
640 std::map<std::string, std::string> bidirectionalPeers; 646 std::map<std::string, std::string> bidirectionalPeers;
641 647
642 { 648 {
643 OrthancPlugins::OrthancConfiguration config; 649 OrthancPlugins::OrthancConfiguration config;
644 650
648 config.GetSection(plugin, KEY_PLUGIN_CONFIGURATION); 654 config.GetSection(plugin, KEY_PLUGIN_CONFIGURATION);
649 655
650 threadsCount = plugin.GetUnsignedIntegerValue("Threads", threadsCount); 656 threadsCount = plugin.GetUnsignedIntegerValue("Threads", threadsCount);
651 targetBucketSize = plugin.GetUnsignedIntegerValue("BucketSize", targetBucketSize); 657 targetBucketSize = plugin.GetUnsignedIntegerValue("BucketSize", targetBucketSize);
652 memoryCacheSize = plugin.GetUnsignedIntegerValue("CacheSize", memoryCacheSize); 658 memoryCacheSize = plugin.GetUnsignedIntegerValue("CacheSize", memoryCacheSize);
653 maxPushTransactions = plugin.GetUnsignedIntegerValue 659 maxPushTransactions = plugin.GetUnsignedIntegerValue("MaxPushTransactions", maxPushTransactions);
654 ("MaxPushTransactions", maxPushTransactions); 660 maxHttpRetries = plugin.GetUnsignedIntegerValue("MaxHttpRetries", maxHttpRetries);
655 } 661 }
656 } 662 }
657 663
658 OrthancPlugins::PluginContext::Initialize 664 OrthancPlugins::PluginContext::Initialize(threadsCount, targetBucketSize * KB, maxPushTransactions,
659 (threadsCount, targetBucketSize * KB, maxPushTransactions, memoryCacheSize * MB); 665 memoryCacheSize * MB, maxHttpRetries);
660 666
661 OrthancPlugins::RegisterRestCallback<ServeChunks> 667 OrthancPlugins::RegisterRestCallback<ServeChunks>
662 (std::string(URI_CHUNKS) + "/([.0-9a-f-]+)", true); 668 (std::string(URI_CHUNKS) + "/([.0-9a-f-]+)", true);
663 669
664 OrthancPlugins::RegisterRestCallback<LookupInstances> 670 OrthancPlugins::RegisterRestCallback<LookupInstances>