mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-20 04:35:32 +00:00
Bug 4963: Fixed sending operations from a replica to the master
This commit is contained in:
+6
-4
@@ -5,12 +5,11 @@ import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.sap.sse.common.WithID;
|
||||
import com.sap.sse.util.HttpUrlConnectionHelper;
|
||||
|
||||
public interface OperationsToMasterSender<S, O extends OperationWithResult<S, ?>> extends OperationsToMasterSendingQueue, WithID {
|
||||
final Logger logger = Logger.getLogger(OperationsToMasterSender.class.getName());
|
||||
@@ -46,8 +45,11 @@ public interface OperationsToMasterSender<S, O extends OperationWithResult<S, ?>
|
||||
// TODO bug4018: if sending the operation fails, e.g., because of an HTTP response code != 2xx, enqueue the operation for retry
|
||||
addOperationSentToMasterForReplication(operationWithResultWithIdWrapper);
|
||||
URL url = masterDescriptor.getSendReplicaInitiatedOperationToMasterURL(this.getId().toString());
|
||||
final URLConnection connection = HttpUrlConnectionHelper.redirectConnectionWithBearerToken(url,
|
||||
masterDescriptor.getBearerToken());
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
String optionalBearerToken = masterDescriptor.getBearerToken();
|
||||
if (optionalBearerToken != null && !optionalBearerToken.isEmpty()) {
|
||||
connection.setRequestProperty("Authorization", "Bearer " + optionalBearerToken);
|
||||
}
|
||||
connection.setDoOutput(true); // we want to post the serialized operation
|
||||
logger.info("Sending operation "+operation+" to master "+masterDescriptor+"'s replicable with ID "+this+" for initial execution and replication");
|
||||
connection.connect();
|
||||
|
||||
Reference in New Issue
Block a user