Commit 3e61810d authored by Dmitriy Novikov's avatar Dmitriy Novikov
Browse files

Updated atomics to read only

parent 5442903e
......@@ -26,7 +26,7 @@ public class AuditLogger {
private AuditEvents getAuditEvents() {
if (this.events == null) {
String user = Optional.ofNullable(headers.getUserEmail().get())
String user = Optional.ofNullable(headers.getUserEmailAtomic().get())
.orElse("storage-user-email");
this.events = new AuditEvents(user);
}
......
package org.opengroup.osdu.indexer.di;
import java.util.concurrent.atomic.AtomicReference;
import lombok.Data;
import lombok.Getter;
import org.springframework.stereotype.Component;
@Component
@Data
@Getter
public class ThreadLocalHeaders {
private AtomicReference<String> dataPartitionId = new AtomicReference<>();
private AtomicReference<String> authorization = new AtomicReference<>();
private AtomicReference<String> userEmail = new AtomicReference<>();
private AtomicReference<String> accountId = new AtomicReference<>();
private AtomicReference<String> correlationId = new AtomicReference<>();
private final AtomicReference<String> dataPartitionIdAtomic = new AtomicReference<>();
private final AtomicReference<String> authorizationAtomic = new AtomicReference<>();
private final AtomicReference<String> userEmailAtomic = new AtomicReference<>();
private final AtomicReference<String> accountIdAtomic = new AtomicReference<>();
private final AtomicReference<String> correlationIdAtomic = new AtomicReference<>();
}
......@@ -23,7 +23,6 @@ import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
......@@ -119,21 +118,21 @@ public class IndexerServiceImpl implements IndexerService {
}
private void putAtomicHeadersFromMessages(Map<String, String> attributes) {
headers.setDataPartitionId(new AtomicReference<>(attributes.get("data-partition-id")));
headers.setAuthorization(new AtomicReference<>(attributes.get("authorization")));
headers.setUserEmail(new AtomicReference<>(attributes.get("user")));
headers.setAccountId(new AtomicReference<>(attributes.get("account-id")));
headers.setCorrelationId(new AtomicReference<>(attributes.get("correlation-id")));
headers.getDataPartitionIdAtomic().set(attributes.get("data-partition-id"));
headers.getAuthorizationAtomic().set(attributes.get("authorization"));
headers.getUserEmailAtomic().set(attributes.get("user"));
headers.getAccountIdAtomic().set(attributes.get("account-id"));
headers.getCorrelationIdAtomic().set(attributes.get("correlation-id"));
}
@NotNull
private DpsHeaders convertAtomicToDpsHeaders() {
DpsHeaders dpsHeaders = new DpsHeaders();
dpsHeaders.put("data-partition-id", headers.getDataPartitionId().get());
dpsHeaders.put("authorization", headers.getAuthorization().get());
dpsHeaders.put("user", headers.getUserEmail().get());
dpsHeaders.put("account-id", headers.getAccountId().get());
dpsHeaders.put("correlation-id", headers.getCorrelationId().get());
dpsHeaders.put("data-partition-id", headers.getDataPartitionIdAtomic().get());
dpsHeaders.put("authorization", headers.getAuthorizationAtomic().get());
dpsHeaders.put("user", headers.getUserEmailAtomic().get());
dpsHeaders.put("account-id", headers.getAccountIdAtomic().get());
dpsHeaders.put("correlation-id", headers.getCorrelationIdAtomic().get());
return dpsHeaders;
}
......
Supports Markdown
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