-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Motivation This patch is the continuation of https://rb.dcache.org/r/10691/. It aims to embed KafkaProducer so that dCache, if required, may publish DoorRequestInfoMessage info to Kafka. Modification Add KafkaTemplate and kafkaProducer to 'nfs41-common.xml'. Target: master Require-book: no Require-notes: no Patch: https://rb.dcache.org/r/10771/ Acked-by:Tigran Mkrtchyan
- Loading branch information
1 parent
eefb964
commit 5f97c5a
Showing
6 changed files
with
149 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
modules/dcache/src/main/java/org/dcache/notification/DoorRequestMessageSerializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package org.dcache.notification; | ||
|
||
import org.apache.kafka.common.serialization.Serializer; | ||
import org.json.JSONArray; | ||
import org.json.JSONObject; | ||
|
||
import java.util.Date; | ||
import java.util.Map; | ||
|
||
import diskCacheV111.vehicles.DoorRequestInfoMessage; | ||
|
||
import static java.nio.charset.StandardCharsets.UTF_8; | ||
|
||
public class DoorRequestMessageSerializer implements Serializer<DoorRequestInfoMessage> { | ||
|
||
@Override | ||
public byte[] serialize(String topic, DoorRequestInfoMessage data) { | ||
|
||
JSONObject o = new JSONObject(); | ||
o.put("VERSION", "1.0"); | ||
o.put("msgType", data.getMessageType()); | ||
o.put("date", new Date(data.getTimestamp())); | ||
o.put("queuingTime", data.getTimeQueued()); | ||
o.put("cellName", data.getCellAddress().getCellName()); | ||
o.put("cellType", data.getCellType()); | ||
o.put("cellDomain", data.getCellAddress().getCellDomainName()); | ||
|
||
JSONObject status = new JSONObject(); | ||
status.put("code", data.getResultCode()); | ||
status.put("msg", data.getMessage()); | ||
o.put("status", status); | ||
|
||
o.put("session", data.getTransaction()); | ||
o.put("sessionDuration", data.getTransactionDuration()); | ||
o.put("transferPath", data.getTransferPath()); | ||
|
||
JSONArray subject = new JSONArray(); | ||
data.getSubject().getPrincipals().forEach(s -> subject.put(s)); | ||
o.put("subject", subject); | ||
o.put("client", data.getClient()); | ||
o.put("clientChain", data.getClientChain()); | ||
o.put("mappedUID", data.getUid()); | ||
o.put("mappedGID", data.getGid()); | ||
o.put("owner", data.getOwner()); | ||
o.put("pnfsid", data.getPnfsId()); | ||
o.put("billingPath", data.getBillingPath()); | ||
o.put("fileSize", data.getFileSize()); | ||
o.put("storageInfo", data.getStorageInfo()); | ||
return o.toString().getBytes(UTF_8); | ||
|
||
} | ||
|
||
@Override | ||
public void configure(Map<String, ?> configs, boolean isKey) { | ||
} | ||
|
||
@Override | ||
public void close() { | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters