javax.ws.rs.Encoded Java Examples

The following examples show how to use javax.ws.rs.Encoded. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PersistentTopics.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@GET
@Path("/{property}/{cluster}/{namespace}/{topic}/ledger/{ledgerId}/entry/{entryId}")
@ApiOperation(hidden = true, value = "Get message by its messageId.")
@ApiResponses(value = {
        @ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
        @ApiResponse(code = 403, message = "Don't java admin permission"),
        @ApiResponse(code = 404, message = "Topic, subscription or the messageId does not exist")
})
public void getMessageByID(@Suspended final AsyncResponse asyncResponse, @PathParam("property") String property,
            @PathParam("cluster") String cluster, @PathParam("namespace") String namespace,
            @PathParam("topic") @Encoded String encodedTopic, @PathParam("ledgerId") Long ledgerId,
            @PathParam("entryId") Long entryId, @QueryParam("authoritative") @DefaultValue("false") boolean authoritative) {
    try {
        validateTopicName(property, cluster, namespace, encodedTopic);
        internalGetMessageById(asyncResponse, ledgerId, entryId, authoritative);
    } catch (WebApplicationException wae) {
        asyncResponse.resume(wae);
    } catch (Exception e) {
        asyncResponse.resume(new RestException(e));
    }
}
 
Example #2
Source File: NonPersistentTopics.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@PUT
@Path("/{property}/{cluster}/{namespace}/{topic}/partitions")
@ApiOperation(hidden = true, value = "Create a partitioned topic.", notes = "It needs to be called before creating a producer on a partitioned topic.")
@ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission"),
        @ApiResponse(code = 406, message = "The number of partitions should be more than 0 and less than or equal to maxNumPartitionsPerPartitionedTopic"),
        @ApiResponse(code = 409, message = "Partitioned topic already exist") })
public void createPartitionedTopic(@Suspended final AsyncResponse asyncResponse, @PathParam("property") String property, @PathParam("cluster") String cluster,
        @PathParam("namespace") String namespace, @PathParam("topic") @Encoded String encodedTopic,
        int numPartitions) {
    try {
        validateTopicName(property, cluster, namespace, encodedTopic);
        internalCreatePartitionedTopic(asyncResponse, numPartitions);
    } catch (Exception e) {
        log.error("[{}] Failed to create partitioned topic {}", clientAppId(), topicName, e);
        resumeAsyncResponseExceptionally(asyncResponse, e);
    }
}
 
Example #3
Source File: PersistentTopics.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@POST
@Path("/{tenant}/{namespace}/{topic}/terminate")
@ApiOperation(value = "Terminate a topic. A topic that is terminated will not accept any more "
        + "messages to be published and will let consumer to drain existing messages in backlog")
@ApiResponses(value = {
        @ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
        @ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant or" +
                "subscriber is not authorized to access this operation"),
        @ApiResponse(code = 403, message = "Don't have admin permission"),
        @ApiResponse(code = 404, message = "Topic does not exist"),
        @ApiResponse(code = 405, message = "Termination of a partitioned topic is not allowed"),
        @ApiResponse(code = 412, message = "Topic name is not valid"),
        @ApiResponse(code = 500, message = "Internal server error"),
        @ApiResponse(code = 503, message = "Failed to validate global cluster configuration") })
public MessageId terminate(
        @ApiParam(value = "Specify the tenant", required = true)
        @PathParam("tenant") String tenant,
        @ApiParam(value = "Specify the namespace", required = true)
        @PathParam("namespace") String namespace,
        @ApiParam(value = "Specify topic name", required = true)
        @PathParam("topic") @Encoded String encodedTopic,
        @ApiParam(value = "Is authentication required to perform this operation")
        @QueryParam("authoritative") @DefaultValue("false") boolean authoritative) {
    validateTopicName(tenant, namespace, encodedTopic);
    return internalTerminate(authoritative);
}
 
Example #4
Source File: PersistentTopics.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@PUT
@Path("/{property}/{cluster}/{namespace}/{topic}/partitions")
@ApiOperation(hidden = true, value = "Create a partitioned topic.", notes = "It needs to be called before creating a producer on a partitioned topic.")
@ApiResponses(value = {
        @ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
        @ApiResponse(code = 403, message = "Don't have admin permission"),
        @ApiResponse(code = 406, message = "The number of partitions should be more than 0 and less than or equal to maxNumPartitionsPerPartitionedTopic"),
        @ApiResponse(code = 409, message = "Partitioned topic already exist") })
public void createPartitionedTopic(@Suspended final AsyncResponse asyncResponse, @PathParam("property") String property, @PathParam("cluster") String cluster,
        @PathParam("namespace") String namespace, @PathParam("topic") @Encoded String encodedTopic,
        int numPartitions) {
    try {
        validateTopicName(property, cluster, namespace, encodedTopic);
        internalCreatePartitionedTopic(asyncResponse, numPartitions);
    } catch (Exception e) {
        log.error("[{}] Failed to create partitioned topic {}", clientAppId(), topicName, e);
        resumeAsyncResponseExceptionally(asyncResponse, e);
    }
}
 
Example #5
Source File: PersistentTopics.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@GET
@Path("{property}/{cluster}/{namespace}/{topic}/partitioned-stats")
@ApiOperation(hidden = true, value = "Get the stats for the partitioned topic.")
@ApiResponses(value = {
        @ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
        @ApiResponse(code = 403, message = "Don't have admin permission"),
        @ApiResponse(code = 404, message = "Topic does not exist") })
public void getPartitionedStats(@Suspended final AsyncResponse asyncResponse,
        @PathParam("property") String property,
        @PathParam("cluster") String cluster, @PathParam("namespace") String namespace,
        @PathParam("topic") @Encoded String encodedTopic,
        @QueryParam("perPartition") @DefaultValue("true") boolean perPartition,
        @QueryParam("authoritative") @DefaultValue("false") boolean authoritative) {
    try {
        validateTopicName(property, cluster, namespace, encodedTopic);
        internalGetPartitionedStats(asyncResponse, authoritative, perPartition, false);
    } catch (WebApplicationException wae) {
        asyncResponse.resume(wae);
    } catch (Exception e) {
        asyncResponse.resume(new RestException(e));
    }
}
 
Example #6
Source File: PersistentTopics.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@DELETE
@Path("/{property}/{cluster}/{namespace}/{topic}/partitions")
@ApiOperation(hidden = true, value = "Delete a partitioned topic.", notes = "It will also delete all the partitions of the topic if it exists.")
@ApiResponses(value = {
        @ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
        @ApiResponse(code = 403, message = "Don't have admin permission"),
        @ApiResponse(code = 404, message = "Partitioned topic does not exist") })
public void deletePartitionedTopic(@Suspended final AsyncResponse asyncResponse,
        @PathParam("property") String property, @PathParam("cluster") String cluster,
        @PathParam("namespace") String namespace, @PathParam("topic") @Encoded String encodedTopic,
        @QueryParam("force") @DefaultValue("false") boolean force,
        @QueryParam("authoritative") @DefaultValue("false") boolean authoritative) {
    try {
        validateTopicName(property, cluster, namespace, encodedTopic);
        internalDeletePartitionedTopic(asyncResponse, authoritative, force);
    } catch (WebApplicationException wae) {
        asyncResponse.resume(wae);
    } catch (Exception e) {
        asyncResponse.resume(new RestException(e));
    }
}
 
Example #7
Source File: PersistentTopics.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@POST
@Path("/{tenant}/{namespace}/{topic}/terminate/partitions")
@ApiOperation(value = "Terminate all partitioned topic. A topic that is terminated will not accept any more "
        + "messages to be published and will let consumer to drain existing messages in backlog")
@ApiResponses(value = {
        @ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant or" +
                "subscriber is not authorized to access this operation"),
        @ApiResponse(code = 403, message = "Don't have admin permission"),
        @ApiResponse(code = 404, message = "Topic does not exist"),
        @ApiResponse(code = 405, message = "Termination of a partitioned topic is not allowed"),
        @ApiResponse(code = 412, message = "Topic name is not valid"),
        @ApiResponse(code = 500, message = "Internal server error"),
        @ApiResponse(code = 503, message = "Failed to validate global cluster configuration") })
public void terminatePartitionedTopic( @Suspended final AsyncResponse asyncResponse,
        @ApiParam(value = "Specify the tenant", required = true)
        @PathParam("tenant") String tenant,
        @ApiParam(value = "Specify the namespace", required = true)
        @PathParam("namespace") String namespace,
        @ApiParam(value = "Specify topic name", required = true)
        @PathParam("topic") @Encoded String encodedTopic,
        @ApiParam(value = "Is authentication required to perform this operation")
        @QueryParam("authoritative") @DefaultValue("false") boolean authoritative) {
    validateTopicName(tenant, namespace, encodedTopic);
    internalTerminatePartitionedTopic(asyncResponse, authoritative);
}
 
Example #8
Source File: PersistentTopics.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@GET
@Path("/{tenant}/{namespace}/{topic}/compaction")
@ApiOperation(value = "Get the status of a compaction operation for a topic.")
@ApiResponses(value = {
        @ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
        @ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant or" +
                "subscriber is not authorized to access this operation"),
        @ApiResponse(code = 403, message = "Don't have admin permission"),
        @ApiResponse(code = 404, message = "Topic does not exist, or compaction hasn't run"),
        @ApiResponse(code = 405, message = "Operation is not allowed on the persistent topic"),
        @ApiResponse(code = 412, message = "Topic name is not valid"),
        @ApiResponse(code = 500, message = "Internal server error"),
        @ApiResponse(code = 503, message = "Failed to validate global cluster configuration") })
public LongRunningProcessStatus compactionStatus(
        @ApiParam(value = "Specify the tenant", required = true)
        @PathParam("tenant") String tenant,
        @ApiParam(value = "Specify the namespace", required = true)
        @PathParam("namespace") String namespace,
        @ApiParam(value = "Specify topic name", required = true)
        @PathParam("topic") @Encoded String encodedTopic,
        @ApiParam(value = "Is authentication required to perform this operation")
        @QueryParam("authoritative") @DefaultValue("false") boolean authoritative) {
    validateTopicName(tenant, namespace, encodedTopic);
    return internalCompactionStatus(authoritative);
}
 
Example #9
Source File: PersistentTopics.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@GET
@Path("{tenant}/{namespace}/{topic}/backlog")
@ApiOperation(value = "Get estimated backlog for offline topic.")
@ApiResponses(value = {
        @ApiResponse(code = 404, message = "Namespace does not exist"),
        @ApiResponse(code = 412, message = "Topic name is not valid"),
        @ApiResponse(code = 503, message = "Failed to validate global cluster configuration") })
public PersistentOfflineTopicStats getBacklog(
        @ApiParam(value = "Specify the tenant", required = true)
        @PathParam("tenant") String tenant,
        @ApiParam(value = "Specify the namespace", required = true)
        @PathParam("namespace") String namespace,
        @ApiParam(value = "Specify topic name", required = true)
        @PathParam("topic") @Encoded String encodedTopic,
        @ApiParam(value = "Is authentication required to perform this operation")
        @QueryParam("authoritative") @DefaultValue("false") boolean authoritative) {
    validateTopicName(tenant, namespace, encodedTopic);
    return internalGetBacklog(authoritative);
}
 
Example #10
Source File: PersistentTopics.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@GET
@Path("{property}/{cluster}/{namespace}/{topic}/partitioned-internalStats")
@ApiOperation(hidden = true, value = "Get the stats-internal for the partitioned topic.")
@ApiResponses(value = {
        @ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
        @ApiResponse(code = 403, message = "Don't have admin permission"),
        @ApiResponse(code = 404, message = "Topic does not exist") })
public void getPartitionedStatsInternal(
        @Suspended final AsyncResponse asyncResponse,
        @PathParam("property") String property,
        @PathParam("cluster") String cluster, @PathParam("namespace") String namespace,
        @PathParam("topic") @Encoded String encodedTopic,
        @QueryParam("authoritative") @DefaultValue("false") boolean authoritative) {
    try {
        validateTopicName(property, cluster, namespace, encodedTopic);
        internalGetPartitionedStatsInternal(asyncResponse, authoritative);
    } catch (WebApplicationException wae) {
        asyncResponse.resume(wae);
    } catch (Exception e) {
        asyncResponse.resume(new RestException(e));
    }
}
 
Example #11
Source File: PersistentTopics.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@DELETE
@Path("/{property}/{cluster}/{namespace}/{topic}/subscription/{subName}")
@ApiOperation(hidden = true, value = "Delete a subscription.", notes = "The subscription cannot be deleted if delete is not forcefully and there are any active consumers attached to it. "
        + "Force delete ignores connected consumers and deletes subscription by explicitly closing them.")
@ApiResponses(value = {
        @ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
        @ApiResponse(code = 403, message = "Don't have admin permission"),
        @ApiResponse(code = 404, message = "Topic does not exist"),
        @ApiResponse(code = 412, message = "Subscription has active consumers") })
public void deleteSubscription(@Suspended final AsyncResponse asyncResponse, @PathParam("property") String property,
        @PathParam("cluster") String cluster, @PathParam("namespace") String namespace,
        @PathParam("topic") @Encoded String encodedTopic, @PathParam("subName") String encodedSubName,
        @QueryParam("force") @DefaultValue("false") boolean force,
        @QueryParam("authoritative") @DefaultValue("false") boolean authoritative) {
    try {
        validateTopicName(property, cluster, namespace, encodedTopic);
        internalDeleteSubscription(asyncResponse, decode(encodedSubName), authoritative, force);
    } catch (WebApplicationException wae) {
        asyncResponse.resume(wae);
    } catch (Exception e) {
        asyncResponse.resume(new RestException(e));
    }
}
 
Example #12
Source File: PersistentTopics.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@POST
@Path("/{property}/{cluster}/{namespace}/{topic}/subscription/{subName}/skip_all")
@ApiOperation(hidden = true, value = "Skip all messages on a topic subscription.", notes = "Completely clears the backlog on the subscription.")
@ApiResponses(value = {
        @ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
        @ApiResponse(code = 403, message = "Don't have admin permission"),
        @ApiResponse(code = 405, message = "Operation not allowed on non-persistent topic"),
        @ApiResponse(code = 404, message = "Topic or subscription does not exist") })
public void skipAllMessages(@Suspended final AsyncResponse asyncResponse, @PathParam("property") String property,
        @PathParam("cluster") String cluster, @PathParam("namespace") String namespace,
        @PathParam("topic") @Encoded String encodedTopic, @PathParam("subName") String encodedSubName,
        @QueryParam("authoritative") @DefaultValue("false") boolean authoritative) {
    try {
        validateTopicName(property, cluster, namespace, encodedTopic);
        internalSkipAllMessages(asyncResponse, decode(encodedSubName), authoritative);
    } catch (WebApplicationException wae) {
        asyncResponse.resume(wae);
    } catch (Exception e) {
        asyncResponse.resume(new RestException(e));
    }
}
 
Example #13
Source File: PersistentTopics.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@POST
@Path("/{property}/{cluster}/{namespace}/{topic}/all_subscription/expireMessages/{expireTimeInSeconds}")
@ApiOperation(hidden = true, value = "Expire messages on all subscriptions of topic.")
@ApiResponses(value = {
        @ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
        @ApiResponse(code = 403, message = "Don't have admin permission"),
        @ApiResponse(code = 404, message = "Topic or subscription does not exist") })
public void expireMessagesForAllSubscriptions(@Suspended final AsyncResponse asyncResponse,
        @PathParam("property") String property, @PathParam("cluster") String cluster,
        @PathParam("namespace") String namespace, @PathParam("topic") @Encoded String encodedTopic,
        @PathParam("expireTimeInSeconds") int expireTimeInSeconds,
        @QueryParam("authoritative") @DefaultValue("false") boolean authoritative) {
    try {
        validateTopicName(property, cluster, namespace, encodedTopic);
        internalExpireMessagesForAllSubscriptions(asyncResponse, expireTimeInSeconds, authoritative);
    } catch (WebApplicationException wae) {
        asyncResponse.resume(wae);
    } catch (Exception e) {
        asyncResponse.resume(new RestException(e));
    }
}
 
Example #14
Source File: PersistentTopics.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@POST
@Path("/{property}/{cluster}/{namespace}/{topic}/subscription/{subName}/resetcursor/{timestamp}")
@ApiOperation(hidden = true, value = "Reset subscription to message position closest to absolute timestamp (in ms).", notes = "It fence cursor and disconnects all active consumers before reseting cursor.")
@ApiResponses(value = {
        @ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
        @ApiResponse(code = 403, message = "Don't have admin permission"),
        @ApiResponse(code = 404, message = "Topic/Subscription does not exist") })
public void resetCursor(@Suspended final AsyncResponse asyncResponse, @PathParam("property") String property,
        @PathParam("cluster") String cluster, @PathParam("namespace") String namespace,
        @PathParam("topic") @Encoded String encodedTopic, @PathParam("subName") String encodedSubName,
        @PathParam("timestamp") long timestamp,
        @QueryParam("authoritative") @DefaultValue("false") boolean authoritative) {
    try {
        validateTopicName(property, cluster, namespace, encodedTopic);
        internalResetCursor(asyncResponse, decode(encodedSubName), timestamp, authoritative);
    } catch (WebApplicationException wae) {
        asyncResponse.resume(wae);
    } catch (Exception e) {
        asyncResponse.resume(new RestException(e));
    }
}
 
Example #15
Source File: PersistentTopics.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@PUT
@Path("/{property}/{cluster}/{namespace}/{topic}/subscription/{subscriptionName}")
@ApiOperation(value = "Create a subscription on the topic.", notes = "Creates a subscription on the topic at the specified message id")
@ApiResponses(value = {
        @ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
        @ApiResponse(code = 403, message = "Don't have admin permission"),
        @ApiResponse(code = 404, message = "Topic/Subscription does not exist"),
        @ApiResponse(code = 405, message = "Not supported for partitioned topics") })
public void createSubscription(@Suspended final AsyncResponse asyncResponse, @PathParam("property") String property,
        @PathParam("cluster") String cluster, @PathParam("namespace") String namespace,
        @PathParam("topic") @Encoded String topic, @PathParam("subscriptionName") String encodedSubName,
        @QueryParam("authoritative") @DefaultValue("false") boolean authoritative, MessageIdImpl messageId,
        @QueryParam("replicated") boolean replicated) {
    try {
        validateTopicName(property, cluster, namespace, topic);
        internalCreateSubscription(asyncResponse, decode(encodedSubName), messageId, authoritative, replicated);
    } catch (WebApplicationException wae) {
        asyncResponse.resume(wae);
    } catch (Exception e) {
        asyncResponse.resume(new RestException(e));
    }
}
 
Example #16
Source File: PersistentTopics.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@POST
@Path("/{property}/{cluster}/{namespace}/{topic}/subscription/{subName}/expireMessages/{expireTimeInSeconds}")
@ApiOperation(hidden = true, value = "Expire messages on a topic subscription.")
@ApiResponses(value = {
        @ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
        @ApiResponse(code = 403, message = "Don't have admin permission"),
        @ApiResponse(code = 404, message = "Topic or subscription does not exist") })
public void expireTopicMessages(@Suspended final AsyncResponse asyncResponse,
        @PathParam("property") String property, @PathParam("cluster") String cluster,
        @PathParam("namespace") String namespace, @PathParam("topic") @Encoded String encodedTopic,
        @PathParam("subName") String encodedSubName, @PathParam("expireTimeInSeconds") int expireTimeInSeconds,
        @QueryParam("authoritative") @DefaultValue("false") boolean authoritative) {
    try {
        validateTopicName(property, cluster, namespace, encodedTopic);
        internalExpireMessages(asyncResponse, decode(encodedSubName), expireTimeInSeconds, authoritative);
    } catch (WebApplicationException wae) {
        asyncResponse.resume(wae);
    } catch (Exception e) {
        asyncResponse.resume(new RestException(e));
    }
}
 
Example #17
Source File: PersistentTopics.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@PUT
@Path("/{property}/{cluster}/{namespace}/{topic}/compaction")
@ApiOperation(value = "Trigger a compaction operation on a topic.")
@ApiResponses(value = {
        @ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
        @ApiResponse(code = 403, message = "Don't have admin permission"),
        @ApiResponse(code = 405, message = "Operation not allowed on persistent topic"),
        @ApiResponse(code = 404, message = "Topic does not exist"),
        @ApiResponse(code = 409, message = "Compaction already running")})
public void compact(@Suspended final AsyncResponse asyncResponse,
                    @PathParam("property") String property, @PathParam("cluster") String cluster,
                    @PathParam("namespace") String namespace, @PathParam("topic") @Encoded String encodedTopic,
                    @QueryParam("authoritative") @DefaultValue("false") boolean authoritative) {
    try {
        validateTopicName(property, cluster, namespace, encodedTopic);
        internalTriggerCompaction(asyncResponse, authoritative);
    } catch (WebApplicationException wae) {
        asyncResponse.resume(wae);
    } catch (Exception e) {
        asyncResponse.resume(new RestException(e));
    }
}
 
Example #18
Source File: PersistentTopics.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@PUT
@Path("/{tenant}/{cluster}/{namespace}/{topic}/offload")
@ApiOperation(value = "Offload a prefix of a topic to long term storage")
@ApiResponses(value = {
        @ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
        @ApiResponse(code = 403, message = "Don't have admin permission"),
        @ApiResponse(code = 405, message = "Operation not allowed on persistent topic"),
        @ApiResponse(code = 404, message = "Topic does not exist"),
        @ApiResponse(code = 409, message = "Offload already running")})
public void triggerOffload(@PathParam("tenant") String tenant,
                           @PathParam("cluster") String cluster,
                           @PathParam("namespace") String namespace,
                           @PathParam("topic") @Encoded String encodedTopic,
                           @QueryParam("authoritative") @DefaultValue("false") boolean authoritative,
                           MessageIdImpl messageId) {
    validateTopicName(tenant, cluster, namespace, encodedTopic);
    internalTriggerOffload(authoritative, messageId);
}
 
Example #19
Source File: PersistentTopics.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@GET
@Path("/{tenant}/{cluster}/{namespace}/{topic}/offload")
@ApiOperation(value = "Offload a prefix of a topic to long term storage")
@ApiResponses(value = {
        @ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
        @ApiResponse(code = 403, message = "Don't have admin permission"),
        @ApiResponse(code = 405, message = "Operation not allowed on persistent topic"),
        @ApiResponse(code = 404, message = "Topic does not exist")})
public OffloadProcessStatus offloadStatus(@PathParam("tenant") String tenant,
                                          @PathParam("cluster") String cluster,
                                          @PathParam("namespace") String namespace,
                                          @PathParam("topic") @Encoded String encodedTopic,
                                          @QueryParam("authoritative") @DefaultValue("false") boolean authoritative) {
    validateTopicName(tenant, cluster, namespace, encodedTopic);
    return internalOffloadStatus(authoritative);
}
 
Example #20
Source File: NonPersistentTopics.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@GET
@Path("/{tenant}/{namespace}/{topic}/partitions")
@ApiOperation(value = "Get partitioned topic metadata.")
@ApiResponses(value = {
        @ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
        @ApiResponse(code = 401, message = "Don't have permission to manage resources on this tenant"),
        @ApiResponse(code = 403, message = "Don't have admin permission"),
        @ApiResponse(code = 404, message = "The tenant/namespace/topic does not exist"),
        @ApiResponse(code = 412, message = "Topic name is not valid"),
        @ApiResponse(code = 500, message = "Internal server error"),
        @ApiResponse(code = 503, message = "Failed to validate cluster configuration")
})
public PartitionedTopicMetadata getPartitionedMetadata(
        @ApiParam(value = "Specify the tenant", required = true)
        @PathParam("tenant") String tenant,
        @ApiParam(value = "Specify the namespace", required = true)
        @PathParam("namespace") String namespace,
        @ApiParam(value = "Specify topic name", required = true)
        @PathParam("topic") @Encoded String encodedTopic,
        @ApiParam(value = "Is authentication required to perform this operation")
        @QueryParam("authoritative") @DefaultValue("false") boolean authoritative,
        @ApiParam(value = "Is check configuration required to automatically create topic")
        @QueryParam("checkAllowAutoCreation") @DefaultValue("false") boolean checkAllowAutoCreation) {
    validateTopicName(tenant, namespace, encodedTopic);
    return getPartitionedTopicMetadata(topicName, authoritative, checkAllowAutoCreation);
}
 
Example #21
Source File: PersistentTopics.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@GET
@Path("{tenant}/{namespace}/{topic}/internal-info")
@ApiOperation(value = "Get the stored topic metadata.")
@ApiResponses(value = {
        @ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant"),
        @ApiResponse(code = 403, message = "Don't have admin permission"),
        @ApiResponse(code = 404, message = "Topic does not exist"),
        @ApiResponse(code = 412, message = "Topic name is not valid"),
        @ApiResponse(code = 500, message = "Internal server error"),
        @ApiResponse(code = 503, message = "Failed to validate global cluster configuration") })
public void getManagedLedgerInfo(
        @ApiParam(value = "Specify the tenant", required = true)
        @PathParam("tenant") String tenant,
        @ApiParam(value = "Specify the namespace", required = true)
        @PathParam("namespace") String namespace,
        @ApiParam(value = "Is authentication required to perform this operation")
        @QueryParam("authoritative") @DefaultValue("false") boolean authoritative,
        @ApiParam(value = "Specify topic name", required = true)
        @PathParam("topic")
        @Encoded String encodedTopic,@Suspended AsyncResponse asyncResponse) {
    validateTopicName(tenant, namespace, encodedTopic);
    internalGetManagedLedgerInfo(asyncResponse, authoritative);
}
 
Example #22
Source File: NonPersistentTopics.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@GET
@Path("{tenant}/{namespace}/{topic}/internalStats")
@ApiOperation(value = "Get the internal stats for the topic.")
@ApiResponses(value = {
        @ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
        @ApiResponse(code = 401, message = "Don't have permission to manage resources on this tenant"),
        @ApiResponse(code = 403, message = "Don't have admin permission"),
        @ApiResponse(code = 404, message = "The tenant/namespace/topic does not exist"),
        @ApiResponse(code = 412, message = "Topic name is not valid"),
        @ApiResponse(code = 500, message = "Internal server error"),
})
public PersistentTopicInternalStats getInternalStats(
        @ApiParam(value = "Specify the tenant", required = true)
        @PathParam("tenant") String tenant,
        @ApiParam(value = "Specify the namespace", required = true)
        @PathParam("namespace") String namespace,
        @ApiParam(value = "Specify topic name", required = true)
        @PathParam("topic") @Encoded String encodedTopic,
        @ApiParam(value = "Is authentication required to perform this operation")
        @QueryParam("authoritative") @DefaultValue("false") boolean authoritative) {
    validateTopicName(tenant, namespace, encodedTopic);
    validateAdminOperationOnTopic(topicName, authoritative);
    Topic topic = getTopicReference(topicName);
    return topic.getInternalStats();
}
 
Example #23
Source File: PersistentTopics.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@GET
@Path("{tenant}/{namespace}/{topic}/internalStats")
@ApiOperation(value = "Get the internal stats for the topic.")
@ApiResponses(value = {
        @ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
        @ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant"),
        @ApiResponse(code = 403, message = "Don't have admin permission"),
        @ApiResponse(code = 404, message = "Topic does not exist"),
        @ApiResponse(code = 412, message = "Topic name is not valid"),
        @ApiResponse(code = 500, message = "Internal server error"),
        @ApiResponse(code = 503, message = "Failed to validate global cluster configuration") })
public PersistentTopicInternalStats getInternalStats(
        @ApiParam(value = "Specify the tenant", required = true)
        @PathParam("tenant") String tenant,
        @ApiParam(value = "Specify the namespace", required = true)
        @PathParam("namespace") String namespace,
        @ApiParam(value = "Specify topic name", required = true)
        @PathParam("topic") @Encoded String encodedTopic,
        @ApiParam(value = "Is authentication required to perform this operation")
        @QueryParam("authoritative") @DefaultValue("false") boolean authoritative) {
    validateTopicName(tenant, namespace, encodedTopic);
    return internalGetInternalStats(authoritative);
}
 
Example #24
Source File: PersistentTopics.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@GET
@Path("{tenant}/{namespace}/{topic}/stats")
@ApiOperation(value = "Get the stats for the topic.")
@ApiResponses(value = {
        @ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
        @ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant"),
        @ApiResponse(code = 403, message = "Don't have admin permission"),
        @ApiResponse(code = 404, message = "Topic does not exist"),
        @ApiResponse(code = 412, message = "Topic name is not valid"),
        @ApiResponse(code = 500, message = "Internal server error"),
        @ApiResponse(code = 503, message = "Failed to validate global cluster configuration") })
public TopicStats getStats(
        @ApiParam(value = "Specify the tenant", required = true)
        @PathParam("tenant") String tenant,
        @ApiParam(value = "Specify the namespace", required = true)
        @PathParam("namespace") String namespace,
        @ApiParam(value = "Specify topic name", required = true)
        @PathParam("topic") @Encoded String encodedTopic,
        @ApiParam(value = "Is authentication required to perform this operation")
        @QueryParam("authoritative") @DefaultValue("false") boolean authoritative,
        @ApiParam(value = "Is return precise backlog or imprecise backlog")
        @QueryParam("getPreciseBacklog") @DefaultValue("false") boolean getPreciseBacklog) {
    validateTopicName(tenant, namespace, encodedTopic);
    return internalGetStats(authoritative, getPreciseBacklog);
}
 
Example #25
Source File: PersistentTopics.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@GET
@Path("/{tenant}/{namespace}/{topic}/permissions")
@ApiOperation(value = "Get permissions on a topic.", notes = "Retrieve the effective permissions for a topic. These permissions are defined by the permissions set at the"
        + "namespace level combined (union) with any eventual specific permission set on the topic.")
@ApiResponses(value = {
        @ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant"),
        @ApiResponse(code = 403, message = "Don't have admin permission"),
        @ApiResponse(code = 404, message = "tenant/namespace/topic doesn't exit"),
        @ApiResponse(code = 412, message = "Topic name is not valid"),
        @ApiResponse(code = 500, message = "Internal server error") })
public Map<String, Set<AuthAction>> getPermissionsOnTopic(
        @ApiParam(value = "Specify the tenant", required = true)
        @PathParam("tenant") String tenant,
        @ApiParam(value = "Specify the namespace", required = true)
        @PathParam("namespace") String namespace,
        @ApiParam(value = "Specify topic name", required = true)
        @PathParam("topic") @Encoded String encodedTopic) {
    validateTopicName(tenant, namespace, encodedTopic);
    return internalGetPermissionsOnTopic();
}
 
Example #26
Source File: PersistentTopics.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@POST
@Path("/{tenant}/{namespace}/{topic}/permissions/{role}")
@ApiOperation(value = "Grant a new permission to a role on a single topic.")
@ApiResponses(value = {
        @ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
        @ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant"),
        @ApiResponse(code = 403, message = "Don't have admin permission"),
        @ApiResponse(code = 404, message = "tenant/namespace/topic doesn't exit"),
        @ApiResponse(code = 409, message = "Concurrent modification"),
        @ApiResponse(code = 412, message = "Topic name is not valid"),
        @ApiResponse(code = 500, message = "Internal server error") })
public void grantPermissionsOnTopic(
        @ApiParam(value = "Specify the tenant", required = true)
        @PathParam("tenant") String tenant,
        @ApiParam(value = "Specify the namespace", required = true)
        @PathParam("namespace") String namespace,
        @ApiParam(value = "Specify topic name", required = true)
        @PathParam("topic") @Encoded String encodedTopic,
        @ApiParam(value = "Client role to which grant permissions", required = true)
        @PathParam("role") String role,
        @ApiParam(value = "Actions to be granted (produce,functions,consume)", allowableValues = "produce,functions,consume")
        Set<AuthAction> actions) {
    validateTopicName(tenant, namespace, encodedTopic);
    internalGrantPermissionsOnTopic(role, actions);
}
 
Example #27
Source File: PersistentTopics.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@DELETE
@Path("/{tenant}/{namespace}/{topic}/permissions/{role}")
@ApiOperation(value = "Revoke permissions on a topic.", notes = "Revoke permissions to a role on a single topic. If the permission was not set at the topic"
        + "level, but rather at the namespace level, this operation will return an error (HTTP status code 412).")
@ApiResponses(value = {
        @ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
        @ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant"),
        @ApiResponse(code = 403, message = "Don't have admin permission"),
        @ApiResponse(code = 404, message = "tenant/namespace/topic doesn't exit"),
        @ApiResponse(code = 412, message = "Permissions are not set at the topic level"),
        @ApiResponse(code = 500, message = "Internal server error") })
public void revokePermissionsOnTopic(
        @ApiParam(value = "Specify the tenant", required = true)
        @PathParam("tenant") String tenant,
        @ApiParam(value = "Specify the namespace", required = true)
        @PathParam("namespace") String namespace,
        @ApiParam(value = "Specify topic name", required = true)
        @PathParam("topic") @Encoded String encodedTopic,
        @ApiParam(value = "Client role to which grant permissions", required = true)
        @PathParam("role") String role) {
    validateTopicName(tenant, namespace, encodedTopic);
    internalRevokePermissionsOnTopic(role);
}
 
Example #28
Source File: PersistentTopics.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@PUT
@Path("/{tenant}/{namespace}/{topic}")
@ApiOperation(value="Create a non-partitioned topic.", notes = "This is the only REST endpoint from which non-partitioned topics could be created.")
@ApiResponses(value = {
        @ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
        @ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant"),
        @ApiResponse(code = 403, message = "Don't have admin permission"),
        @ApiResponse(code = 409, message = "Partitioned topic already exist"),
        @ApiResponse(code = 412, message = "Failed Reason : Name is invalid or Namespace does not have any clusters configured"),
        @ApiResponse(code = 500, message = "Internal server error"),
        @ApiResponse(code = 503, message = "Failed to validate global cluster configuration")
})
public void createNonPartitionedTopic(
        @ApiParam(value = "Specify the tenant", required = true)
        @PathParam("tenant") String tenant,
        @ApiParam(value = "Specify the namespace", required = true)
        @PathParam("namespace") String namespace,
        @ApiParam(value = "Specify topic name", required = true)
        @PathParam("topic") @Encoded String encodedTopic,
        @ApiParam(value = "Is authentication required to perform this operation")
        @QueryParam("authoritative") @DefaultValue("false") boolean authoritative) {
    validateGlobalNamespaceOwnership(tenant,namespace);
    validateTopicName(tenant, namespace, encodedTopic);
    internalCreateNonPartitionedTopic(authoritative);
}
 
Example #29
Source File: PersistentTopics.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@DELETE
@Path("/{tenant}/{namespace}/{topic}")
@ApiOperation(value = "Delete a topic.", notes = "The topic cannot be deleted if delete is not forcefully and there's any active "
        + "subscription or producer connected to the it. Force delete ignores connected clients and deletes topic by explicitly closing them.")
@ApiResponses(value = {
        @ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
        @ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant"),
        @ApiResponse(code = 403, message = "Don't have admin permission"),
        @ApiResponse(code = 404, message = "Topic does not exist"),
        @ApiResponse(code = 412, message = "Topic has active producers/subscriptions"),
        @ApiResponse(code = 500, message = "Internal server error") })
public void deleteTopic(
        @ApiParam(value = "Specify the tenant", required = true)
        @PathParam("tenant") String tenant,
        @ApiParam(value = "Specify the namespace", required = true)
        @PathParam("namespace") String namespace,
        @ApiParam(value = "Specify topic name", required = true)
        @PathParam("topic") @Encoded String encodedTopic,
        @ApiParam(value = "Stop all producer/consumer/replicator and delete topic forcefully", defaultValue = "false", type = "boolean")
        @QueryParam("force") @DefaultValue("false") boolean force,
        @ApiParam(value = "Is authentication required to perform this operation")
        @QueryParam("authoritative") @DefaultValue("false") boolean authoritative) {
    validateTopicName(tenant, namespace, encodedTopic);
    internalDeleteTopic(authoritative, force);
}
 
Example #30
Source File: PersistentTopics.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@GET
@Path("/{tenant}/{namespace}/{topic}/partitions")
@ApiOperation(value = "Get partitioned topic metadata.")
@ApiResponses(value = {
        @ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
        @ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant"),
        @ApiResponse(code = 403, message = "Don't have admin permission"),
        @ApiResponse(code = 404, message = "Tenant does not exist"),
        @ApiResponse(code = 409, message = "Concurrent modification"),
        @ApiResponse(code = 412, message = "Partitioned topic name is invalid"),
        @ApiResponse(code = 500, message = "Internal server error")
})
public PartitionedTopicMetadata getPartitionedMetadata(
        @ApiParam(value = "Specify the tenant", required = true)
        @PathParam("tenant") String tenant,
        @ApiParam(value = "Specify the namespace", required = true)
        @PathParam("namespace") String namespace,
        @ApiParam(value = "Specify topic name", required = true)
        @PathParam("topic") @Encoded String encodedTopic,
        @ApiParam(value = "Is authentication required to perform this operation")
        @QueryParam("authoritative") @DefaultValue("false") boolean authoritative,
        @ApiParam(value = "Is check configuration required to automatically create topic")
        @QueryParam("checkAllowAutoCreation") @DefaultValue("false") boolean checkAllowAutoCreation) {
    validateTopicName(tenant, namespace, encodedTopic);
    return internalGetPartitionedMetadata(authoritative, checkAllowAutoCreation);
}