diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/ClustersBase.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/ClustersBase.java index 7797f5dcaacf1..597e191f11cf3 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/ClustersBase.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/ClustersBase.java @@ -146,11 +146,12 @@ public void createCluster( examples = @Example( value = @ExampleProperty( mediaType = MediaType.APPLICATION_JSON, - value = - "{\n" - + " 'serviceUrl': 'http://pulsar.example.com:8080',\n" - + " 'brokerServiceUrl': 'pulsar://pulsar.example.com:6651',\n" - + "}" + value = """ + { + "serviceUrl": "http://pulsar.example.com:8080", + "brokerServiceUrl": "pulsar://pulsar.example.com:6651", + } + """ ) ) ) ClusterDataImpl clusterData) { @@ -201,11 +202,12 @@ public void updateCluster( examples = @Example( value = @ExampleProperty( mediaType = MediaType.APPLICATION_JSON, - value = - "{\n" - + " 'serviceUrl': 'http://pulsar.example.com:8080',\n" - + " 'brokerServiceUrl': 'pulsar://pulsar.example.com:6651'\n" - + "}" + value = """ + { + "serviceUrl": "http://pulsar.example.com:8080", + "brokerServiceUrl": "pulsar://pulsar.example.com:6651" + } + """ ) ) ) ClusterDataImpl clusterData) { @@ -247,10 +249,11 @@ public void setPeerClusterNames(@Suspended AsyncResponse asyncResponse, required = true, examples = @Example( value = @ExampleProperty(mediaType = MediaType.APPLICATION_JSON, - value = "[\n" - + " 'cluster-a',\n" - + " 'cluster-b'\n" - + "]"))) + value = """ + [ + "cluster-a", + "cluster-b" + ]"""))) LinkedHashSet peerClusterNames) { validateSuperUserAccessAsync() .thenCompose(__ -> validatePoliciesReadOnlyAccessAsync()) diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/FunctionsBase.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/FunctionsBase.java index be9dc8c7b714c..81d90b84c8fd1 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/FunctionsBase.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/FunctionsBase.java @@ -173,26 +173,21 @@ public void registerFunction( value = { @ExampleProperty( mediaType = MediaType.TEXT_PLAIN, - value = " Example \n" - + "\n" - + " 1. Create a JSON object. \n" - + "\n" - + "{\n" - + "\t\"inputs\": \"persistent://public/default/input-topic\",\n" - + "\t\"parallelism\": \"4\",\n" - + "\t\"output\": \"persistent://public/default/output-topic\",\n" - + "\t\"log-topic\": \"persistent://public/default/log-topic\",\n" - + "\t\"classname\": \"org.example.test.ExclamationFunction\",\n" - + "\t\"jar\": \"java-function-1.0-SNAPSHOT.jar\"\n" - + "}\n" - + "\n" - + "\n" - + "2. Encapsulate the JSON object to a multipart object (in Python). \n" - + "\n" - + "from requests_toolbelt.multipart.encoder import MultipartEncoder \n" - + "mp_encoder = MultipartEncoder( \n" - + "\t[('functionConfig', " - + "(None, json.dumps(config), 'application/json'))])\n" + value = """ + Examples + 1. Create a JSON object + { + "inputs": "persistent://public/default/input-topic", + "parallelism": "4", + "output": "persistent://public/default/output-topic", + "log-topic": "persistent://public/default/log-topic", + "classname": "org.example.test.ExclamationFunction", + "jar": "java-function-1.0-SNAPSHOT.jar" + } + 2. Encapsulate the JSON object to a multipart object (in Python) + from requests_toolbelt.multipart.encoder import MultipartEncoders + mp_encoder = MultipartEncoder([('functionConfig',(None, json.dumps(config),\ + 'application/json'))])""" ) } ) @@ -309,14 +304,16 @@ public void updateFunction( examples = @Example( value = @ExampleProperty( mediaType = MediaType.APPLICATION_JSON, - value = "{\n" - + " \"inputs\": persistent://public/default/input-topic,\n" - + " \"parallelism\": 4\n" - + " \"output\": persistent://public/default/output-topic\n" - + " \"log-topic\": persistent://public/default/log-topic\n" - + " \"classname\": org.example.test.ExclamationFunction\n" - + " \"jar\": java-function-1.0-SNAPSHOT.jar\n" - + "}\n" + value = """ + { + "inputs": "persistent://public/default/input-topic", + "parallelism": 4, + "output": "persistent://public/default/output-topic", + "log-topic": "persistent://public/default/log-topic", + "classname": "org.example.test.ExclamationFunction", + "jar": "java-function-1.0-SNAPSHOT.jar" + } + """ ) ) ) diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/SinksBase.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/SinksBase.java index d45016454f559..26186fe17ab6c 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/SinksBase.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/SinksBase.java @@ -145,27 +145,23 @@ public void registerSink(@ApiParam(value = "The tenant of a Pulsar Sink") final value = { @ExampleProperty( mediaType = MediaType.TEXT_PLAIN, - value = "Example \n" - + "\n" - + " 1. Create a JSON object. \n" - + "\n" - + "{\n" - + "\t\"classname\": \"org.example.MySinkTest\",\n" - + "\t\"inputs\": [" - + "\"persistent://public/default/sink-input\"],\n" - + "\t\"processingGuarantees\": \"EFFECTIVELY_ONCE\",\n" - + "\t\"parallelism\": \"10\"\n" - + "}\n" - + "\n" - + "\n" - + "2. Encapsulate the JSON object to a multipart object " - + "(in Python).\n" - + "\n" - + "from requests_toolbelt.multipart.encoder import " - + "MultipartEncoder \n" - + "mp_encoder = MultipartEncoder( \n" - + "\t[('sinkConfig', " - + "(None, json.dumps(config), 'application/json'))])\n" + value = """ + Example + 1. Create a JSON object. + { + "classname": "org.example.MySinkTest", + "inputs": ["persistent://public/default/sink-input"], + "processingGuarantees": "EFFECTIVELY_ONCE", + "parallelism": "10" + } + 2. Encapsulate the JSON object to a multipart object \ + (in Python). + from requests_toolbelt.multipart.encoder import \ + MultipartEncoder + mp_encoder = MultipartEncoder(\ + [('sinkConfig',\ + (None, json.dumps(config), 'application/json'))]) + """ ) } ) @@ -260,13 +256,14 @@ public void updateSink(@ApiParam(value = "The tenant of a Pulsar Sink") final @P examples = @Example( value = @ExampleProperty( mediaType = MediaType.APPLICATION_JSON, - value = "{\n" - + "\t\"classname\": \"org.example.SinkStressTest\",\n" - + "\t\"inputs\": [" - + "\"persistent://public/default/sink-input\"],\n" - + "\t\"processingGuarantees\": \"EFFECTIVELY_ONCE\",\n" - + "\t\"parallelism\": 5\n" - + "}" + value = """ + { + "classname": "org.example.SinkStressTest", + "inputs": ["persistent://public/default/sink-input"], + "processingGuarantees": "EFFECTIVELY_ONCE", + "parallelism": 5 + } + """ ) ) ) diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/SourcesBase.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/SourcesBase.java index b4ba332c312af..4a5efdad80cb8 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/SourcesBase.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/SourcesBase.java @@ -119,28 +119,24 @@ public void registerSource( examples = @Example( value = @ExampleProperty( mediaType = MediaType.TEXT_PLAIN, - value = " Example \n" - + "\n" - + "1. Create a JSON object. \n" - + "\n" - + "{\n" - + "\t\"tenant\": \"public\",\n" - + "\t\"namespace\": \"default\",\n" - + "\t\"name\": \"pulsar-io-mysql\",\n" - + "\t\"className\": \"TestSourceMysql\",\n" - + "\t\"topicName\": \"pulsar-io-mysql\",\n" - + "\t\"parallelism\": \"1\",\n" - + "\t\"archive\": \"/connectors/pulsar-io-mysql-0.0.1.nar\",\n" - + "\t\"schemaType\": \"avro\"\n" - + "}\n" - + "\n" - + "\n" - + "2. Encapsulate the JSON object to a multipart object (in Python). \n" - + "\n" - + "from requests_toolbelt.multipart.encoder import MultipartEncoder \n" - + "mp_encoder = MultipartEncoder( \n" - + "\t[('sourceConfig', " - + "(None, json.dumps(config), 'application/json'))])\n" + value = """ + Example + 1. Create a JSON object. + { + "tenant": "public", + "namespace": "default", + "name": "pulsar-io-mysql", + "className": "TestSourceMysql", + "topicName": "pulsar-io-mysql", + "parallelism": "1", + "archive": "/connectors/pulsar-io-mysql-0.0.1.nar", + "schemaType": "avro" + } + 2. Encapsulate the JSON object to a multipart object (in Python). + from requests_toolbelt.multipart.encoder import MultipartEncoder + mp_encoder = MultipartEncoder([('sourceConfig', \ + (None, json.dumps(config), 'application/json'))]) + """ ) ) ) @@ -212,16 +208,18 @@ public void updateSource( examples = @Example( value = @ExampleProperty( mediaType = MediaType.APPLICATION_JSON, - value = "{\n" - + " \"tenant\": public\n" - + " \"namespace\": default\n" - + " \"name\": pulsar-io-mysql\n" - + " \"className\": TestSourceMysql\n" - + " \"topicName\": pulsar-io-mysql\n" - + " \"parallelism\": 1\n" - + " \"archive\": /connectors/pulsar-io-mysql-0.0.1.nar\n" - + " \"schemaType\": avro\n" - + "}\n" + value = """ + { + "tenant": "public", + "namespace": "default", + "name": "pulsar-io-mysql", + "className": "TestSourceMysql", + "topicName": "pulsar-io-mysql", + "parallelism": 1, + "archive": "/connectors/pulsar-io-mysql-0.0.1.nar", + "schemaType": "avro" + } + """ ) ) ) diff --git a/pulsar-io/batch-data-generator/src/main/java/org/apache/pulsar/io/batchdatagenerator/Person.java b/pulsar-io/batch-data-generator/src/main/java/org/apache/pulsar/io/batchdatagenerator/Person.java index 0015dabea7b2b..f112b111a741b 100644 --- a/pulsar-io/batch-data-generator/src/main/java/org/apache/pulsar/io/batchdatagenerator/Person.java +++ b/pulsar-io/batch-data-generator/src/main/java/org/apache/pulsar/io/batchdatagenerator/Person.java @@ -40,7 +40,8 @@ public class Person { private String password; private Sex sex; private String telephoneNumber; - @org.apache.avro.reflect.AvroSchema("{ \"type\": \"long\", \"logicalType\": \"timestamp-millis\" }") + @org.apache.avro.reflect.AvroSchema(""" + { "type": "long", "logicalType": "timestamp-millis" }""") private long dateOfBirth; private Integer age; private Company company;