org.apache.gobblin.kafka.schemareg.LiKafkaSchemaRegistry Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gobblin-kafka-common Show documentation
Show all versions of gobblin-kafka-common Show documentation
A distributed data integration framework for streaming and batch data ecosystems.
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.gobblin.kafka.schemareg;
import java.io.IOException;
import java.util.Map;
import java.util.Properties;
import org.apache.avro.Schema;
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.pool2.impl.GenericObjectPool;
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import org.apache.gobblin.metrics.reporter.util.KafkaAvroReporterUtil;
import org.apache.gobblin.util.PropertiesUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import org.apache.gobblin.configuration.ConfigurationKeys;
import org.apache.gobblin.kafka.serialize.MD5Digest;
import org.apache.gobblin.util.AvroUtils;
/**
* Integration with LinkedIn's implementation of a schema registry that uses md5-hash for schema ids.
*/
public class LiKafkaSchemaRegistry implements KafkaSchemaRegistry {
private static final Logger LOG = LoggerFactory.getLogger(LiKafkaSchemaRegistry.class);
private static final String GET_RESOURCE_BY_ID = "/id=";
private static final String GET_RESOURCE_BY_TYPE = "/latest_with_type=";
private static final String SCHEMA_ID_HEADER_NAME = "Location";
private static final String SCHEMA_ID_HEADER_PREFIX = "/id=";
private final GenericObjectPool httpClientPool;
private final String url;
private final Optional
© 2015 - 2024 Weber Informatics LLC | Privacy Policy