Commit f14c7fa5 authored by legoc's avatar legoc
Browse files

Some renamings

parent a463641b
......@@ -130,7 +130,7 @@ public:
void setPortUnavailable(int port) const;
void releasePort(int port) const;
json::Object request(const std::string& request, int overrideTimeout = -1) const;
json::Object requestJSON(const std::string& request, int overrideTimeout = -1) const;
std::unique_ptr<RequestSocketImpl> createRequestSocket(const std::string& endpoint) const;
std::unique_ptr<RequestSocketImpl> createRequestSocket(const std::string& endpoint, int timeout) const;
......@@ -252,7 +252,7 @@ public:
public:
std::string getKeyValue(const std::string& key) const;
json::Object request(const std::string& request, int overrideTimeout = -1) const;
json::Object requestJSON(const std::string& request, int overrideTimeout = -1) const;
std::string createJSONResponse(int value, const std::string& message) const;
......
......@@ -88,7 +88,7 @@ void This::Com::releasePort(int port) const {
m_server->releasePort(m_applicationId, port);
}
json::Object This::Com::request(const std::string& request, int overrideTimeout) const {
json::Object This::Com::requestJSON(const std::string& request, int overrideTimeout) const {
return m_server->requestJSON(request, overrideTimeout);
}
......@@ -454,7 +454,7 @@ std::string Instance::Com::getKeyValue(const std::string& key) const {
return m_server->getKeyValue(m_applicationId, key);
}
json::Object Instance::Com::request(const std::string& request, int overrideTimeout) const {
json::Object Instance::Com::requestJSON(const std::string& request, int overrideTimeout) const {
return m_server->requestJSON(request, overrideTimeout);
}
......
......@@ -42,7 +42,7 @@ Publisher::~Publisher() {
std::unique_ptr<Publisher> Publisher::create(const std::string& name, int numberOfSubscribers) {
json::Object response = application::This::getCom().request(createCreatePublisherRequest(application::This::m_instance.m_id, name, numberOfSubscribers));
json::Object response = application::This::getCom().requestJSON(createCreatePublisherRequest(application::This::m_instance.m_id, name, numberOfSubscribers));
int publisherPort = response[message::PublisherResponse::PUBLISHER_PORT].GetInt();
if (publisherPort == -1) {
......@@ -134,7 +134,7 @@ Subscriber::~Subscriber() {
std::unique_ptr<Subscriber> Subscriber::createSubscriber(application::Instance & instance, const std::string& publisherName, const std::string& instanceName) {
// Get the JSON response.
json::Object response = instance.getCom().request(createConnectPublisherRequest(instance.m_id, publisherName));
json::Object response = instance.getCom().requestJSON(createConnectPublisherRequest(instance.m_id, publisherName));
int publisherPort = response[message::PublisherResponse::PUBLISHER_PORT].GetInt();
if (publisherPort == -1) {
......
......@@ -121,7 +121,7 @@ Responder::~Responder() {
std::unique_ptr<Responder> Responder::create(const std::string& name) {
std::string portName = ResponderImpl::RESPONDER_PREFIX + name;
json::Object response = application::This::getCom().request(createRequestPortV0Request(application::This::m_instance.m_id, portName));
json::Object response = application::This::getCom().requestJSON(createRequestPortV0Request(application::This::m_instance.m_id, portName));
int responderPort = response[message::RequestResponse::VALUE].GetInt();
if (responderPort == -1) {
......@@ -174,7 +174,7 @@ std::unique_ptr<Requester> Requester::create(application::Instance & instance, c
std::string request = createConnectPortV0Request(responderId, responderPortName);
json::Object response = instance.getCom().request(request);
json::Object response = instance.getCom().requestJSON(request);
int responderPort = response[message::RequestResponse::VALUE].GetInt();
if (responderPort == -1) {
......@@ -182,7 +182,7 @@ std::unique_ptr<Requester> Requester::create(application::Instance & instance, c
instance.waitFor(responderPortName);
// Retry to connect.
response = instance.getCom().request(request);
response = instance.getCom().requestJSON(request);
responderPort = response[message::RequestResponse::VALUE].GetInt();
if (responderPort == -1) {
......@@ -191,7 +191,7 @@ std::unique_ptr<Requester> Requester::create(application::Instance & instance, c
}
// Request a requester port.
response = application::This::getCom().request(createRequestPortV0Request(application::This::m_instance.m_id, requesterPortName));
response = application::This::getCom().requestJSON(createRequestPortV0Request(application::This::m_instance.m_id, requesterPortName));
int requesterPort = response[message::RequestResponse::VALUE].GetInt();
if (requesterPort == -1) {
......
......@@ -180,7 +180,7 @@ void PublisherImpl::terminate() {
setEnd();
m_publisher.reset(nullptr);
json::Object response = application::This::getCom().request(createTerminatePublisherRequest(application::This::m_instance.m_id, m_name));
json::Object response = application::This::getCom().requestJSON(createTerminatePublisherRequest(application::This::m_instance.m_id, m_name));
int value = response[message::RequestResponse::VALUE].GetInt();
bool success = (value != -1);
......
......@@ -48,12 +48,10 @@ public class Application {
private ServerImpl server;
private int applicationId;
private ThisImpl thisImpl;
Com(ServerImpl server, int applicationId, ThisImpl thisImpl) {
Com(ServerImpl server, int applicationId) {
this.server = server;
this.applicationId = applicationId;
this.thisImpl = thisImpl;
}
public Context getContext() {
......@@ -116,8 +114,8 @@ public class Application {
}
}
public JSONObject request(JSONObject request) {
return thisImpl.request(request);
public JSONObject requestJSON(JSONObject request) {
return server.requestJSON(request);
}
public RequestSocket createRequestSocket(String endpoint) {
......@@ -175,7 +173,7 @@ public class Application {
if (impl.getStarterEndpoint() != null) {
starterServer = new Server(impl.getStarterEndpoint());
}
com = new Com(impl.getServer(), impl.getId(), impl);
com = new Com(impl.getServer(), impl.getId());
}
static public void init(String[] args) {
......@@ -453,7 +451,7 @@ public class Application {
return server.getKeyValue(applicationId, key);
}
public JSONObject request(JSONObject request) {
public JSONObject requestJSON(JSONObject request) {
return server.requestJSON(request);
}
......
......@@ -22,7 +22,7 @@ public class Publisher {
static PublisherImpl createPublisher(String name, int numberOfSubscribers) throws PublisherCreationException {
JSONObject request = Messages.createCreatePublisherRequest(This.getId(), name, numberOfSubscribers);
JSONObject response = This.getCom().request(request);
JSONObject response = This.getCom().requestJSON(request);
int publisherPort = JSON.getInt(response, Messages.PublisherResponse.PUBLISHER_PORT);
if (publisherPort == -1) {
......
......@@ -33,7 +33,7 @@ public class Requester {
// First connect to the responder.
JSONObject request = Messages.createConnectPortV0Request(responderId, responderPortName);
JSONObject response = application.getCom().request(request);
JSONObject response = application.getCom().requestJSON(request);
int responderPort = JSON.getInt(response, Messages.RequestResponse.VALUE);
if (responderPort == -1) {
......@@ -43,7 +43,7 @@ public class Requester {
// Retry to connect.
request = Messages.createConnectPortV0Request(responderId, responderPortName);
response = application.getCom().request(request);
response = application.getCom().requestJSON(request);
responderPort = JSON.getInt(response, Messages.RequestResponse.VALUE);
if (responderPort == -1) {
......@@ -54,7 +54,7 @@ public class Requester {
// Request a requester port.
request = Messages.createRequestPortV0Request(This.getId(), requesterPortName);
response = This.getCom().request(request);
response = This.getCom().requestJSON(request);
int requesterPort = JSON.getInt(response, Messages.RequestResponse.VALUE);
if (requesterPort == -1) {
......
......@@ -25,7 +25,7 @@ public class Responder {
String portName = ResponderImpl.RESPONDER_PREFIX + name;
JSONObject request = Messages.createRequestPortV0Request(This.getId(), portName);
JSONObject response = This.getCom().request(request);
JSONObject response = This.getCom().requestJSON(request);
int port = JSON.getInt(response, Messages.RequestResponse.VALUE);
if (port == -1) {
......
......@@ -24,7 +24,7 @@ public class Subscriber {
private static SubscriberImpl createSubscriber(String publisherName, Instance instance) throws SubscriberCreationException {
JSONObject request = Messages.createConnectPublisherRequest(instance.getId(), publisherName);
JSONObject response = instance.getCom().request(request);
JSONObject response = instance.getCom().requestJSON(request);
int publisherPort = JSON.getInt(response, Messages.PublisherResponse.PUBLISHER_PORT);
......
......@@ -192,7 +192,7 @@ public class PublisherImpl {
context.destroySocket(publisher);
JSONObject request = Messages.createTerminatePublisherRequest(This.getId(), name);
JSONObject response = This.getCom().request(request);
JSONObject response = This.getCom().requestJSON(request);
int value = JSON.getInt(response, Messages.RequestResponse.VALUE);
if (value == -1) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment