-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
168 additions
and
48 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
27 changes: 27 additions & 0 deletions
27
.../main/java/org/apache/flink/protobuf/registry/confluent/SchemaRegistryClientProvider.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,27 @@ | ||
/* | ||
* 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.flink.protobuf.registry.confluent; | ||
|
||
import io.confluent.kafka.schemaregistry.client.SchemaRegistryClient; | ||
|
||
import java.io.Serializable; | ||
|
||
public interface SchemaRegistryClientProvider extends Serializable { | ||
SchemaRegistryClient createSchemaRegistryClient(); | ||
} |
69 changes: 69 additions & 0 deletions
69
...main/java/org/apache/flink/protobuf/registry/confluent/SchemaRegistryClientProviders.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,69 @@ | ||
/* | ||
* 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.flink.protobuf.registry.confluent; | ||
|
||
import org.apache.flink.annotation.VisibleForTesting; | ||
|
||
import io.confluent.kafka.schemaregistry.SchemaProvider; | ||
import io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient; | ||
import io.confluent.kafka.schemaregistry.client.MockSchemaRegistryClient; | ||
import io.confluent.kafka.schemaregistry.client.SchemaRegistryClient; | ||
import io.confluent.kafka.schemaregistry.protobuf.ProtobufSchemaProvider; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** Providers for {@link SchemaRegistryClient}. */ | ||
public class SchemaRegistryClientProviders { | ||
public static class CachedSchemaRegistryClientProvider implements SchemaRegistryClientProvider { | ||
|
||
private final String url; | ||
private final int identityMapCapacity; | ||
private final Map<String, String> properties; | ||
|
||
public CachedSchemaRegistryClientProvider( | ||
String url, int identityMapCapacity, Map<String, String> properties) { | ||
this.url = url; | ||
this.identityMapCapacity = identityMapCapacity; | ||
this.properties = properties; | ||
} | ||
|
||
@Override | ||
public SchemaRegistryClient createSchemaRegistryClient() { | ||
List<SchemaProvider> providers = new ArrayList<>(); | ||
providers.add(new ProtobufSchemaProvider()); | ||
return new CachedSchemaRegistryClient(url, identityMapCapacity, providers, properties); | ||
} | ||
} | ||
|
||
@VisibleForTesting | ||
public static class MockSchemaRegistryClientProvider implements SchemaRegistryClientProvider { | ||
private final MockSchemaRegistryClient client; | ||
|
||
public MockSchemaRegistryClientProvider(MockSchemaRegistryClient client) { | ||
this.client = client; | ||
} | ||
|
||
@Override | ||
public SchemaRegistryClient createSchemaRegistryClient() { | ||
return client; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.