forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Rishabh Maurya <[email protected]>
- Loading branch information
1 parent
d1f14e3
commit dffb8e6
Showing
15 changed files
with
154 additions
and
73 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
35 changes: 35 additions & 0 deletions
35
libs/arrow-spi/src/main/java/org/opensearch/arrow/spi/StreamTicketFactory.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,35 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.arrow.spi; | ||
|
||
import org.opensearch.common.annotation.ExperimentalApi; | ||
|
||
/** | ||
* Factory interface for creating and managing StreamTicket instances. | ||
* This factory provides methods to create and deserialize StreamTickets, | ||
* ensuring consistent ticket creation. | ||
*/ | ||
@ExperimentalApi | ||
public interface StreamTicketFactory { | ||
/** | ||
* Generates a new StreamTicket | ||
* | ||
* @return A new StreamTicket instance | ||
*/ | ||
StreamTicket generateTicket(); | ||
|
||
/** | ||
* Deserializes a StreamTicket from its byte representation. | ||
* | ||
* @param bytes The byte array containing the serialized ticket data | ||
* @return A StreamTicket instance reconstructed from the byte array | ||
* @throws IllegalArgumentException if bytes is null or invalid | ||
*/ | ||
StreamTicket fromBytes(byte[] bytes); | ||
} |
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
60 changes: 60 additions & 0 deletions
60
...flight-rpc/src/main/java/org/opensearch/arrow/flight/core/DefaultStreamTicketFactory.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,60 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.arrow.flight.core; | ||
|
||
import org.opensearch.arrow.spi.StreamTicket; | ||
import org.opensearch.arrow.spi.StreamTicketFactory; | ||
import org.opensearch.common.annotation.ExperimentalApi; | ||
|
||
import java.util.UUID; | ||
import java.util.function.Supplier; | ||
|
||
/** | ||
* Default implementation of StreamTicketFactory | ||
*/ | ||
@ExperimentalApi | ||
public class DefaultStreamTicketFactory implements StreamTicketFactory { | ||
|
||
private final Supplier<String> nodeId; | ||
|
||
/** | ||
* Constructs a new DefaultStreamTicketFactory instance. | ||
* | ||
* @param nodeId A Supplier that provides the node ID for the StreamTicket | ||
*/ | ||
public DefaultStreamTicketFactory(Supplier<String> nodeId) { | ||
this.nodeId = nodeId; | ||
} | ||
|
||
/** | ||
* Generates a new StreamTicket with a unique ticket ID. | ||
* | ||
* @return A new StreamTicket instance | ||
*/ | ||
@Override | ||
public StreamTicket generateTicket() { | ||
return new FlightStreamTicket(generateUniqueTicket(), nodeId.get()); | ||
} | ||
|
||
/** | ||
* Deserializes a StreamTicket from its byte representation. | ||
* | ||
* @param bytes The byte array containing the serialized ticket data | ||
* @return A StreamTicket instance reconstructed from the byte array | ||
* @throws IllegalArgumentException if bytes is null or invalid | ||
*/ | ||
@Override | ||
public StreamTicket fromBytes(byte[] bytes) { | ||
return FlightStreamTicket.fromBytes(bytes); | ||
} | ||
|
||
private String generateUniqueTicket() { | ||
return UUID.randomUUID().toString(); | ||
} | ||
} |
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
33 changes: 0 additions & 33 deletions
33
.../arrow-flight-rpc/src/main/java/org/opensearch/arrow/flight/core/StreamTicketFactory.java
This file was deleted.
Oops, something went wrong.
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