mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-21 11:40:01 +00:00
working on bug 2408, adding an implementation that has the replica side of serializing an operation to the master through an HTTP request
This commit is contained in:
1 parent
47abca3054
commit
22d9ecdd3b
5 files changed
+50
-5
No files matched your search
+17
@@ -7,7 +7,9 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.ConnectException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.ArrayList;
|
||||
@@ -523,6 +525,21 @@ public class ReplicationServiceImpl implements ReplicationService {
|
||||
logger.info("Deleted queue " + queueName + " used for initial load: " + deleteOk.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendReplicaInitiatedOperationToMaster(Replicable<?, ?> replicable, OperationWithResult<?, ?> operation) throws IOException {
|
||||
ReplicationMasterDescriptor masterDescriptor = getReplicatingFromMaster();
|
||||
URL url = masterDescriptor.getSendReplicaInitiatedOperationToMasterURL(replicable.getId().toString());
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setDoOutput(true); // we want to post the serialized operation
|
||||
connection.setRequestMethod("POST");
|
||||
logger.info("Sending operation "+operation+" to master "+masterDescriptor+"'s replicable with ID "+replicable+" for initial execution and replication");
|
||||
connection.connect();
|
||||
OutputStream outputStream = connection.getOutputStream();
|
||||
replicable.writeOperation(operation, outputStream, /* closeStream */ true);
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
bufferedReader.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the UUID that the master generated for this client which is also entered into {@link #replicaUUIDs}
|
||||
|
||||
Reference in new issue
Block a user