-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Independent schema is set for each consumer generated by topic #6356
Merged
sijie
merged 21 commits into
apache:master
from
congbobo184:fix_schemaProvider_be_covered
Mar 6, 2020
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
cdf7735
no message
congbobo 145f97e
Revert "no message"
congbobo f27d415
Merge remote-tracking branch 'apache/master'
congbobo dc85737
Merge remote-tracking branch 'apache/master'
congbobo 65e6f83
Merge remote-tracking branch 'apache/master'
congbobo 260b137
Merge remote-tracking branch 'apache/master'
congbobo 09e1e40
Merge remote-tracking branch 'apache/master'
congbobo d8e1c03
Merge remote-tracking branch 'apache/master'
congbobo 605061b
Merge remote-tracking branch 'apache/master'
congbobo 3b39049
Merge remote-tracking branch 'apache/master'
congbobo 9c1e24b
Clone schema to different consumer
congbobo f18e248
Add the clone method for each schema
congbobo 4ef0e8d
Fix the clone schema method
congbobo a3285b7
Fix single topic consumer get clone schema
congbobo 2c580a1
fix the reader get schema
congbobo 91471ef
delete the unused imports
congbobo 266cc9e
Extend the Cloneable implementation and fix the AutoConsumeSchema
congbobo 1da1611
Merge remote-tracking branch 'apache/master' into fix_schemaProvider_…
congbobo 4e4192c
Add the kafkaSchema clone implementation
congbobo e97dece
Merge remote-tracking branch 'apache/master' into fix_schemaProvider_…
congbobo 54c6782
Add the jugement
congbobo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
136 changes: 136 additions & 0 deletions
136
pulsar-broker/src/test/java/org/apache/pulsar/schema/SchemaTest.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,136 @@ | ||
/** | ||
* 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.pulsar.schema; | ||
|
||
import com.google.common.collect.Sets; | ||
import org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest; | ||
import org.apache.pulsar.client.api.Consumer; | ||
import org.apache.pulsar.client.api.Producer; | ||
import org.apache.pulsar.client.api.Schema; | ||
import org.apache.pulsar.client.api.schema.SchemaDefinition; | ||
import org.apache.pulsar.common.naming.TopicDomain; | ||
import org.apache.pulsar.common.naming.TopicName; | ||
import org.apache.pulsar.common.policies.data.ClusterData; | ||
import org.apache.pulsar.common.policies.data.TenantInfo; | ||
import org.testng.annotations.AfterMethod; | ||
import org.testng.annotations.BeforeMethod; | ||
import org.testng.annotations.Test; | ||
|
||
import java.util.Collections; | ||
|
||
import static org.apache.pulsar.common.naming.TopicName.PUBLIC_TENANT; | ||
import static org.apache.pulsar.schema.compatibility.SchemaCompatibilityCheckTest.randomName; | ||
import static org.junit.Assert.assertEquals; | ||
|
||
public class SchemaTest extends MockedPulsarServiceBaseTest { | ||
|
||
private final static String CLUSTER_NAME = "test"; | ||
|
||
@BeforeMethod | ||
@Override | ||
public void setup() throws Exception { | ||
super.internalSetup(); | ||
|
||
// Setup namespaces | ||
admin.clusters().createCluster(CLUSTER_NAME, new ClusterData(pulsar.getBrokerServiceUrl())); | ||
TenantInfo tenantInfo = new TenantInfo(); | ||
tenantInfo.setAllowedClusters(Collections.singleton(CLUSTER_NAME)); | ||
admin.tenants().createTenant(PUBLIC_TENANT, tenantInfo); | ||
} | ||
|
||
@AfterMethod | ||
@Override | ||
public void cleanup() throws Exception { | ||
super.internalCleanup(); | ||
} | ||
|
||
@Test | ||
public void testMultiTopicSetSchemaProvider() throws Exception { | ||
final String tenant = PUBLIC_TENANT; | ||
final String namespace = "test-namespace-" + randomName(16); | ||
final String topicOne = "test-multi-version-schema-one"; | ||
final String topicTwo = "test-multi-version-schema-two"; | ||
final String fqtnOne = TopicName.get( | ||
TopicDomain.persistent.value(), | ||
tenant, | ||
namespace, | ||
topicOne | ||
).toString(); | ||
|
||
final String fqtnTwo = TopicName.get( | ||
TopicDomain.persistent.value(), | ||
tenant, | ||
namespace, | ||
topicTwo | ||
).toString(); | ||
|
||
|
||
admin.namespaces().createNamespace( | ||
tenant + "/" + namespace, | ||
Sets.newHashSet(CLUSTER_NAME) | ||
); | ||
|
||
admin.topics().createPartitionedTopic(fqtnOne, 3); | ||
admin.topics().createPartitionedTopic(fqtnTwo, 3); | ||
|
||
admin.schemas().createSchema(fqtnOne, Schema.AVRO( | ||
SchemaDefinition.<Schemas.PersonOne>builder().withAlwaysAllowNull | ||
(false).withSupportSchemaVersioning(true). | ||
withPojo(Schemas.PersonOne.class).build()).getSchemaInfo()); | ||
|
||
admin.schemas().createSchema(fqtnOne, Schema.AVRO( | ||
SchemaDefinition.<Schemas.PersonTwo>builder().withAlwaysAllowNull | ||
(false).withSupportSchemaVersioning(true). | ||
withPojo(Schemas.PersonTwo.class).build()).getSchemaInfo()); | ||
|
||
admin.schemas().createSchema(fqtnTwo, Schema.AVRO( | ||
SchemaDefinition.<Schemas.PersonTwo>builder().withAlwaysAllowNull | ||
(false).withSupportSchemaVersioning(true). | ||
withPojo(Schemas.PersonTwo.class).build()).getSchemaInfo()); | ||
|
||
Producer<Schemas.PersonTwo> producer = pulsarClient.newProducer(Schema.AVRO( | ||
SchemaDefinition.<Schemas.PersonTwo>builder().withAlwaysAllowNull | ||
(false).withSupportSchemaVersioning(true). | ||
withPojo(Schemas.PersonTwo.class).build())) | ||
.topic(fqtnOne) | ||
.create(); | ||
|
||
Schemas.PersonTwo personTwo = new Schemas.PersonTwo(); | ||
personTwo.setId(1); | ||
personTwo.setName("Tom"); | ||
|
||
|
||
Consumer<Schemas.PersonTwo> consumer = pulsarClient.newConsumer(Schema.AVRO( | ||
SchemaDefinition.<Schemas.PersonTwo>builder().withAlwaysAllowNull | ||
(false).withSupportSchemaVersioning(true). | ||
withPojo(Schemas.PersonTwo.class).build())) | ||
.subscriptionName("test") | ||
.topic(fqtnOne, fqtnTwo) | ||
.subscribe(); | ||
|
||
producer.send(personTwo); | ||
|
||
Schemas.PersonTwo personConsume = consumer.receive().getValue(); | ||
assertEquals("Tom", personConsume.getName()); | ||
assertEquals(1, personConsume.getId()); | ||
|
||
producer.close(); | ||
consumer.close(); | ||
} | ||
} |
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
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing license header