-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AddingChannelAcquisitionConext (#23464)
* add channel acquisition context Co-authored-by: annie-mac <[email protected]> Co-authored-by: Kushagra Thapar <[email protected]>
- Loading branch information
1 parent
4e3ea3e
commit bc2bdc4
Showing
20 changed files
with
489 additions
and
32 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
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
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
68 changes: 68 additions & 0 deletions
68
...om/azure/cosmos/implementation/directconnectivity/rntbd/RntbdChannelAcquisitionEvent.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,68 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.cosmos.implementation.directconnectivity.rntbd; | ||
|
||
import com.fasterxml.jackson.core.JsonGenerator; | ||
import com.fasterxml.jackson.databind.SerializerProvider; | ||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; | ||
|
||
import java.io.IOException; | ||
import java.time.Duration; | ||
import java.time.Instant; | ||
|
||
@JsonSerialize(using = RntbdChannelAcquisitionEvent.RntbdChannelAcquisitionEventJsonSerializer.class) | ||
public class RntbdChannelAcquisitionEvent { | ||
private final Instant createdTime; | ||
private final RntbdChannelAcquisitionEventType eventType; | ||
private volatile Instant completeTime; | ||
|
||
public RntbdChannelAcquisitionEvent(RntbdChannelAcquisitionEventType eventType, Instant createdTime) { | ||
this.eventType = eventType; | ||
this.createdTime = createdTime; | ||
} | ||
|
||
public Instant getCreatedTime() { | ||
return createdTime; | ||
} | ||
|
||
public RntbdChannelAcquisitionEventType getEventType() { | ||
return eventType; | ||
} | ||
|
||
public Instant getCompleteTime() { | ||
return completeTime; | ||
} | ||
|
||
public void setCompleteTime(Instant completeTime) { | ||
this.completeTime = completeTime; | ||
} | ||
|
||
public void complete(Instant completeTime) { | ||
this.completeTime = completeTime; | ||
} | ||
|
||
public void addDetail(Object detail) {} | ||
|
||
public static void addDetail(RntbdChannelAcquisitionEvent event, Object detail) { | ||
if (event != null) { | ||
event.addDetail(detail); | ||
} | ||
} | ||
|
||
public static class RntbdChannelAcquisitionEventJsonSerializer extends com.fasterxml.jackson.databind.JsonSerializer<RntbdChannelAcquisitionEvent> { | ||
@Override | ||
public void serialize(RntbdChannelAcquisitionEvent event, | ||
JsonGenerator writer, | ||
SerializerProvider serializerProvider) throws IOException { | ||
writer.writeStartObject(); | ||
|
||
writer.writeStringField(event.eventType.toString(), event.createdTime.toString()); | ||
if (event.completeTime != null) { | ||
writer.writeNumberField("durationInMicroSec",Duration.between(event.createdTime, event.completeTime).toNanos()/1000L); | ||
} | ||
|
||
writer.writeEndObject(); | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...zure/cosmos/implementation/directconnectivity/rntbd/RntbdChannelAcquisitionEventType.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,22 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.cosmos.implementation.directconnectivity.rntbd; | ||
|
||
public enum RntbdChannelAcquisitionEventType { | ||
ATTEMPT_TO_POLL_CHANNEL("poll"), | ||
ADD_TO_PENDING_QUEUE("pending"), | ||
PENDING_TIME_OUT("pendingTimeout"), | ||
ATTEMPT_TO_CREATE_NEW_CHANNEL("startNew"), | ||
ATTEMPT_TO_CREATE_NEW_CHANNEL_COMPLETE("completeNew"); | ||
|
||
private String name; | ||
RntbdChannelAcquisitionEventType(String name) { | ||
this.name = name; | ||
} | ||
|
||
@Override | ||
public String toString(){ | ||
return name; | ||
} | ||
} |
Oops, something went wrong.