Class IsolatedIngestionUtils
java.lang.Object
com.linkedin.davinci.ingestion.utils.IsolatedIngestionUtils
This class contains methods used for communication between ingestion client and server.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
static io.netty.handler.codec.http.HttpResponse
buildHttpResponse
(io.netty.handler.codec.http.HttpResponseStatus status, byte[] content) static io.netty.handler.codec.http.HttpResponse
buildHttpResponse
(io.netty.handler.codec.http.HttpResponseStatus status, io.netty.buffer.ByteBuf contentBuf) static io.netty.handler.codec.http.HttpResponse
buildHttpResponse
(io.netty.handler.codec.http.HttpResponseStatus status, String msg) static IngestionTaskReport
static IngestionTaskReport
createIngestionTaskReport
(IngestionReportType ingestionReportType, String kafkaTopic, int partitionId, long offset, String message) static IngestionTaskReport
createIngestionTaskReport
(IngestionReportType ingestionReportType, String kafkaTopic, int partitionId, String message) static IngestionTaskReport
createIngestionTaskReport
(String kafkaTopic, int partitionId) static <T extends org.apache.avro.specific.SpecificRecordBase>
TdeserializeIngestionActionRequest
(IngestionAction action, byte[] content) static <T extends org.apache.avro.specific.SpecificRecordBase>
TdeserializeIngestionActionResponse
(IngestionAction action, byte[] content) static StoreVersionState
deserializeStoreVersionState
(String topicName, byte[] content) static void
destroyIsolatedIngestionProcess
(Process isolatedIngestionServiceProcess) static void
destroyIsolatedIngestionProcessByPid
(long pid) Kill isolated ingestion process by provided PID.static void
destroyLingeringIsolatedIngestionProcess
(VeniceConfigLoader configLoader) This method takes two steps to kill any lingering forked ingestion process previously created by the same user.static String
executeShellCommand
(String command) getAclHandler
(VeniceConfigLoader configLoader) static IngestionTaskCommand
static byte[]
static IngestionAction
getIngestionActionFromRequest
(io.netty.handler.codec.http.HttpRequest req) getLingeringIngestionProcessId
(int port) This method returns lingering forked ingestion process PID if it exists.static Optional<SSLFactory>
getSSLFactory
(VeniceConfigLoader configLoader) static Optional<SSLFactory>
getSSLFactoryForIngestion
(VeniceConfigLoader configLoader) Create SSLFactory for D2Client in ClientConfig, which will be used by different ingestion components.static boolean
isolatedIngestionServerAclEnabled
(VeniceConfigLoader configLoader) static boolean
isolatedIngestionServerSslEnabled
(VeniceConfigLoader configLoader) loadForkedIngestionKafkaClusterMapConfig
(String configBasePath) static VeniceProperties
loadVenicePropertiesFromFile
(String configPath) static VeniceProperties
loadVenicePropertiesFromFile
(String basePath, String fileName) static byte[]
readHttpRequestContent
(io.netty.handler.codec.http.FullHttpRequest response) static void
releaseTargetPortBinding
(int port) releaseTargetPortBinding aims to release the target port by killing lingering ingestion process bound to the port, which is created from previous deployment and was not killed due to unexpected failures.static void
saveForkedIngestionKafkaClusterMapConfig
(VeniceConfigLoader configLoader) static void
saveForkedIngestionProcessMetadata
(VeniceConfigLoader configLoader, ForkedJavaProcess forkedJavaProcess) static <T extends org.apache.avro.specific.SpecificRecordBase>
byte[]serializeIngestionActionRequest
(IngestionAction action, T param) static <T extends org.apache.avro.specific.SpecificRecordBase>
byte[]serializeIngestionActionResponse
(IngestionAction action, T param) static byte[]
serializeStoreVersionState
(String topicName, StoreVersionState storeVersionState) static boolean
sslEnabled
(VeniceConfigLoader configLoader) static void
waitPortBinding
(int port, int maxAttempt) waitPortBinding is used to test server port binding in other process.
-
Field Details
-
INGESTION_ISOLATION_CONFIG_PREFIX
- See Also:
-
ISOLATED_INGESTION_CONFIG_FILENAME
- See Also:
-
ISOLATED_INGESTION_KAFKA_CLUSTER_MAP_FILENAME
- See Also:
-
FORKED_PROCESS_METADATA_FILENAME
- See Also:
-
PID
- See Also:
-
-
Constructor Details
-
IsolatedIngestionUtils
public IsolatedIngestionUtils()
-
-
Method Details
-
serializeIngestionActionRequest
public static <T extends org.apache.avro.specific.SpecificRecordBase> byte[] serializeIngestionActionRequest(IngestionAction action, T param) -
deserializeIngestionActionRequest
public static <T extends org.apache.avro.specific.SpecificRecordBase> T deserializeIngestionActionRequest(IngestionAction action, byte[] content) -
serializeIngestionActionResponse
public static <T extends org.apache.avro.specific.SpecificRecordBase> byte[] serializeIngestionActionResponse(IngestionAction action, T param) -
deserializeIngestionActionResponse
public static <T extends org.apache.avro.specific.SpecificRecordBase> T deserializeIngestionActionResponse(IngestionAction action, byte[] content) -
getDummyCommand
-
getDummyContent
public static byte[] getDummyContent() -
serializeStoreVersionState
public static byte[] serializeStoreVersionState(String topicName, StoreVersionState storeVersionState) -
deserializeStoreVersionState
-
buildHttpResponse
public static io.netty.handler.codec.http.HttpResponse buildHttpResponse(io.netty.handler.codec.http.HttpResponseStatus status, String msg) -
buildHttpResponse
public static io.netty.handler.codec.http.HttpResponse buildHttpResponse(io.netty.handler.codec.http.HttpResponseStatus status, byte[] content) -
buildHttpResponse
public static io.netty.handler.codec.http.HttpResponse buildHttpResponse(io.netty.handler.codec.http.HttpResponseStatus status, io.netty.buffer.ByteBuf contentBuf) -
readHttpRequestContent
public static byte[] readHttpRequestContent(io.netty.handler.codec.http.FullHttpRequest response) -
getIngestionActionFromRequest
public static IngestionAction getIngestionActionFromRequest(io.netty.handler.codec.http.HttpRequest req) -
waitPortBinding
waitPortBinding is used to test server port binding in other process. Since we cannot control the connection setup on other process, we can only test by trying to establish a connection to the target port.- Parameters:
port
- Target port to test connection.maxAttempt
- Max number of connection retries before it announces fail to connect.- Throws:
Exception
-
releaseTargetPortBinding
public static void releaseTargetPortBinding(int port) releaseTargetPortBinding aims to release the target port by killing lingering ingestion process bound to the port, which is created from previous deployment and was not killed due to unexpected failures. -
getLingeringIngestionProcessId
This method returns lingering forked ingestion process PID if it exists. Since the lsof command will return all processes associated with the port number(including main process), we will need to iterate all PIDs and filter out ingestion process by name. -
executeShellCommand
-
createIngestionTaskReport
public static IngestionTaskReport createIngestionTaskReport(IngestionReportType ingestionReportType, String kafkaTopic, int partitionId, long offset, String message) -
createIngestionTaskReport
-
destroyIsolatedIngestionProcess
-
destroyIsolatedIngestionProcessByPid
public static void destroyIsolatedIngestionProcessByPid(long pid) Kill isolated ingestion process by provided PID. -
destroyLingeringIsolatedIngestionProcess
This method takes two steps to kill any lingering forked ingestion process previously created by the same user. It first tries to locate the PID of the lingering forked ingestion process stored in the metadata file. It then uses lsof command to locate isolated ingestion process binding to the same port and kill it. -
createIngestionTaskReport
-
createIngestionTaskReport
public static IngestionTaskReport createIngestionTaskReport(IngestionReportType ingestionReportType, String kafkaTopic, int partitionId, String message) -
buildAndSaveConfigsForForkedIngestionProcess
-
saveForkedIngestionKafkaClusterMapConfig
-
loadForkedIngestionKafkaClusterMapConfig
-
saveForkedIngestionProcessMetadata
public static void saveForkedIngestionProcessMetadata(VeniceConfigLoader configLoader, ForkedJavaProcess forkedJavaProcess) -
loadVenicePropertiesFromFile
public static VeniceProperties loadVenicePropertiesFromFile(String configPath) throws FileNotFoundException - Throws:
FileNotFoundException
-
loadVenicePropertiesFromFile
public static VeniceProperties loadVenicePropertiesFromFile(String basePath, String fileName) throws FileNotFoundException - Throws:
FileNotFoundException
-
getSSLFactory
-
getSSLFactoryForIngestion
Create SSLFactory for D2Client in ClientConfig, which will be used by different ingestion components. -
getAclHandler
public static Optional<IsolatedIngestionServerAclHandler> getAclHandler(VeniceConfigLoader configLoader) -
isolatedIngestionServerSslEnabled
-
isolatedIngestionServerAclEnabled
-
sslEnabled
-