Skip to content

Commit f3b0073

Browse files
authored
Increasing frame size used by thrift (#99)
* Thrift frame size adjustment
1 parent 08ff5d8 commit f3b0073

File tree

3 files changed

+30
-5
lines changed

3 files changed

+30
-5
lines changed

src/proxyfmu/client/proxy_slave.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ namespace proxyfmu::client
4545

4646
const int max_retries = 600;
4747
const int retry_interval = 500;
48+
const int MAX_FRAME_SIZE = 50 * 1024 * 1024;
4849

4950
proxy_slave::proxy_slave(const filesystem::path& fmuPath, const std::string& instanceName, fmi::model_description modelDescription, const std::optional<remote_info>& remote)
5051
: modelDescription_(std::move(modelDescription))
@@ -62,7 +63,9 @@ proxy_slave::proxy_slave(const filesystem::path& fmuPath, const std::string& ins
6263
} else {
6364
host = remote->host();
6465
std::shared_ptr<TTransport> socket(new TSocket(host, remote->port()));
65-
auto transport = std::make_shared<TFramedTransport>(socket);
66+
auto t_config = std::make_shared<TConfiguration>();
67+
t_config->setMaxFrameSize(MAX_FRAME_SIZE);
68+
auto transport = std::make_shared<TFramedTransport>(socket, t_config);
6669
std::shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
6770
auto client = std::make_shared<BootServiceClient>(protocol);
6871

@@ -94,7 +97,9 @@ proxy_slave::proxy_slave(const filesystem::path& fmuPath, const std::string& ins
9497
}
9598

9699
std::shared_ptr<TTransport> socket(new TSocket(host, port));
97-
transport_ = std::make_shared<TFramedTransport>(socket);
100+
auto t_config = std::make_shared<TConfiguration>();
101+
t_config->setMaxFrameSize(MAX_FRAME_SIZE);
102+
transport_ = std::make_shared<TFramedTransport>(socket, t_config);
98103
std::shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport_));
99104
client_ = std::make_shared<FmuServiceClient>(protocol);
100105
transport_->open();

tool/proxyfmu.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,28 @@ class ServerReadyEventHandler : public TServerEventHandler
4242
}
4343
};
4444

45+
class ProxyFMUFramedTransportFactory : public TTransportFactory
46+
{
47+
public:
48+
explicit ProxyFMUFramedTransportFactory(uint32_t maxFrameSize)
49+
: maxFrameSize_(maxFrameSize)
50+
{ }
51+
52+
std::shared_ptr<TTransport> getTransport(std::shared_ptr<TTransport> trans) override
53+
{
54+
auto t_config = std::make_shared<TConfiguration>();
55+
t_config->setMaxFrameSize(maxFrameSize_);
56+
return std::shared_ptr<TTransport>(new TFramedTransport(trans, t_config));
57+
}
58+
59+
private:
60+
uint32_t maxFrameSize_;
61+
};
62+
4563
const int port_range_min = 49152;
4664
const int port_range_max = 65535;
65+
const int MAX_FRAME_SIZE = 50 * 1024 * 1024;
66+
4767

4868
const int max_port_retries = 10;
4969

@@ -68,7 +88,7 @@ int run_booter_application(const int port)
6888
std::shared_ptr<boot_service_handler> handler(new boot_service_handler());
6989
std::shared_ptr<TProcessor> processor(new BootServiceProcessor(handler));
7090

71-
std::shared_ptr<TTransportFactory> transportFactory(new TFramedTransportFactory());
91+
std::shared_ptr<TTransportFactory> transportFactory(new ProxyFMUFramedTransportFactory(MAX_FRAME_SIZE));
7292
std::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
7393

7494
std::shared_ptr<TServerTransport> serverTransport(new TServerSocket(port));
@@ -93,7 +113,7 @@ int run_application(const std::string& fmu, const std::string& instanceName)
93113
std::shared_ptr<fmu_service_handler> handler(new fmu_service_handler(fmu, instanceName, stop));
94114
std::shared_ptr<TProcessor> processor(new FmuServiceProcessor(handler));
95115

96-
std::shared_ptr<TTransportFactory> transportFactory(new TFramedTransportFactory());
116+
std::shared_ptr<TTransportFactory> transportFactory(new ProxyFMUFramedTransportFactory(MAX_FRAME_SIZE));
97117
std::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
98118

99119
proxyfmu::fixed_range_random_generator rng(port_range_min, port_range_max);

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.4.0
1+
0.4.1

0 commit comments

Comments
 (0)