@@ -171,6 +171,33 @@ public void createPartitionedTopic(
171
171
}
172
172
}
173
173
174
+ @ PUT
175
+ @ Path ("/{property}/{cluster}/{namespace}/{topic}/partitions/topicMetadata" )
176
+ @ ApiOperation (hidden = true , value = "Create a partitioned topic." ,
177
+ notes = "It needs to be called before creating a producer on a partitioned topic." )
178
+ @ ApiResponses (value = {
179
+ @ ApiResponse (code = 307 , message = "Current broker doesn't serve the namespace of this topic" ),
180
+ @ ApiResponse (code = 403 , message = "Don't have admin permission" ),
181
+ @ ApiResponse (code = 406 , message = "The number of partitions should be "
182
+ + "more than 0 and less than or equal to maxNumPartitionsPerPartitionedTopic" ),
183
+ @ ApiResponse (code = 409 , message = "Partitioned topic already exist" )})
184
+ public void createPartitionedTopic (
185
+ @ Suspended final AsyncResponse asyncResponse ,
186
+ @ PathParam ("property" ) String property ,
187
+ @ PathParam ("cluster" ) String cluster ,
188
+ @ PathParam ("namespace" ) String namespace ,
189
+ @ PathParam ("topic" ) @ Encoded String encodedTopic ,
190
+ @ QueryParam ("createLocalTopicOnly" ) @ DefaultValue ("false" ) boolean createLocalTopicOnly ,
191
+ PartitionedTopicMetadata metadata ) {
192
+ try {
193
+ validateTopicName (property , cluster , namespace , encodedTopic );
194
+ internalCreatePartitionedTopic (asyncResponse , metadata .partitions , createLocalTopicOnly , metadata .topicMetadata );
195
+ } catch (Exception e ) {
196
+ log .error ("[{}] Failed to create partitioned topic {}" , clientAppId (), topicName , e );
197
+ resumeAsyncResponseExceptionally (asyncResponse , e );
198
+ }
199
+ }
200
+
174
201
@ PUT
175
202
@ Path ("/{tenant}/{cluster}/{namespace}/{topic}" )
176
203
@ ApiOperation (value = "Create a non-partitioned topic." ,
@@ -196,10 +223,39 @@ public void createNonPartitionedTopic(
196
223
@ PathParam ("topic" ) @ Encoded String encodedTopic ,
197
224
@ ApiParam (value = "Is authentication required to perform this operation" )
198
225
@ QueryParam ("authoritative" ) @ DefaultValue ("false" ) boolean authoritative ) {
226
+ createNonPartitionedTopic (tenant , cluster , namespace , encodedTopic , authoritative , null );
227
+ }
228
+
229
+ @ PUT
230
+ @ Path ("/{tenant}/{cluster}/{namespace}/{topic}/topicMetadata" )
231
+ @ ApiOperation (value = "Create a non-partitioned topic." ,
232
+ notes = "This is the only REST endpoint from which non-partitioned topics could be created." )
233
+ @ ApiResponses (value = {
234
+ @ ApiResponse (code = 307 , message = "Current broker doesn't serve the namespace of this topic" ),
235
+ @ ApiResponse (code = 401 , message = "Don't have permission to administrate resources on this tenant" ),
236
+ @ ApiResponse (code = 403 , message = "Don't have admin permission" ),
237
+ @ ApiResponse (code = 409 , message = "Partitioned topic already exist" ),
238
+ @ ApiResponse (code = 412 ,
239
+ message = "Failed Reason : Name is invalid or Namespace does not have any clusters configured" ),
240
+ @ ApiResponse (code = 500 , message = "Internal server error" ),
241
+ @ ApiResponse (code = 503 , message = "Failed to validate global cluster configuration" )
242
+ })
243
+ public void createNonPartitionedTopic (
244
+ @ ApiParam (value = "Specify the tenant" , required = true )
245
+ @ PathParam ("tenant" ) String tenant ,
246
+ @ ApiParam (value = "Specify the cluster" , required = true )
247
+ @ PathParam ("cluster" ) String cluster ,
248
+ @ ApiParam (value = "Specify the namespace" , required = true )
249
+ @ PathParam ("namespace" ) String namespace ,
250
+ @ ApiParam (value = "Specify topic name" , required = true )
251
+ @ PathParam ("topic" ) @ Encoded String encodedTopic ,
252
+ @ ApiParam (value = "Is authentication required to perform this operation" )
253
+ @ QueryParam ("authoritative" ) @ DefaultValue ("false" ) boolean authoritative ,
254
+ @ ApiParam (value = "Key value pair properties for the topic metadata" ) Map <String , String > topicMetadata ) {
199
255
validateNamespaceName (tenant , cluster , namespace );
200
256
validateTopicName (tenant , cluster , namespace , encodedTopic );
201
257
validateGlobalNamespaceOwnership ();
202
- internalCreateNonPartitionedTopic (authoritative );
258
+ internalCreateNonPartitionedTopic (authoritative , topicMetadata );
203
259
}
204
260
205
261
/**
0 commit comments