Skip to content

Commit

Permalink
renaming sinks and sources api to be consistent with the rest of Pul…
Browse files Browse the repository at this point in the history
…sar (#4363)

* Rename sources and sinks CLI to be consistent with rest of Pulsar

* renaming sinks and sources api to be consistent with the rest of Pulsar

* use new interfaces in cmd
  • Loading branch information
jerrypeng committed May 27, 2019
1 parent e17506d commit aa40ad6
Show file tree
Hide file tree
Showing 32 changed files with 1,448 additions and 1,187 deletions.
4 changes: 2 additions & 2 deletions pulsar-broker/pom.xml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@
</apiSource> </apiSource>
<apiSource> <apiSource>
<springmvc>false</springmvc> <springmvc>false</springmvc>
<locations>org.apache.pulsar.broker.admin.v3.Source</locations> <locations>org.apache.pulsar.broker.admin.v3.Sources</locations>
<schemes>http,https</schemes> <schemes>http,https</schemes>
<basePath>/admin/v3</basePath> <basePath>/admin/v3</basePath>
<info> <info>
Expand All @@ -421,7 +421,7 @@
</apiSource> </apiSource>
<apiSource> <apiSource>
<springmvc>false</springmvc> <springmvc>false</springmvc>
<locations>org.apache.pulsar.broker.admin.v3.Sink</locations> <locations>org.apache.pulsar.broker.admin.v3.Sinks</locations>
<schemes>http,https</schemes> <schemes>http,https</schemes>
<basePath>/admin/v3</basePath> <basePath>/admin/v3</basePath>
<info> <info>
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.apache.pulsar.common.io.SinkConfig; import org.apache.pulsar.common.io.SinkConfig;
import org.apache.pulsar.common.policies.data.SinkStatus; import org.apache.pulsar.common.policies.data.SinkStatus;
import org.apache.pulsar.functions.worker.WorkerService; import org.apache.pulsar.functions.worker.WorkerService;
import org.apache.pulsar.functions.worker.rest.api.SinkImpl; import org.apache.pulsar.functions.worker.rest.api.SinksImpl;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition; import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataParam; import org.glassfish.jersey.media.multipart.FormDataParam;


Expand All @@ -47,12 +47,12 @@
import java.util.List; import java.util.List;
import java.util.function.Supplier; import java.util.function.Supplier;


public class SinkBase extends AdminResource implements Supplier<WorkerService> { public class SinksBase extends AdminResource implements Supplier<WorkerService> {


private final SinkImpl sink; private final SinksImpl sink;


public SinkBase() { public SinksBase() {
this.sink = new SinkImpl(this); this.sink = new SinksImpl(this);
} }


@Override @Override
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.apache.pulsar.common.io.SourceConfig; import org.apache.pulsar.common.io.SourceConfig;
import org.apache.pulsar.common.policies.data.SourceStatus; import org.apache.pulsar.common.policies.data.SourceStatus;
import org.apache.pulsar.functions.worker.WorkerService; import org.apache.pulsar.functions.worker.WorkerService;
import org.apache.pulsar.functions.worker.rest.api.SourceImpl; import org.apache.pulsar.functions.worker.rest.api.SourcesImpl;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition; import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataParam; import org.glassfish.jersey.media.multipart.FormDataParam;


Expand All @@ -47,12 +47,12 @@
import java.util.List; import java.util.List;
import java.util.function.Supplier; import java.util.function.Supplier;


public class SourceBase extends AdminResource implements Supplier<WorkerService> { public class SourcesBase extends AdminResource implements Supplier<WorkerService> {


private final SourceImpl source; private final SourcesImpl source;


public SourceBase() { public SourcesBase() {
this.source = new SourceImpl(this); this.source = new SourcesImpl(this);
} }


@Override @Override
Expand Down Expand Up @@ -188,6 +188,7 @@ public SourceStatus getSourceStatus(final @PathParam("tenant") String tenant,
@ApiResponse(code = 400, message = "Invalid request"), @ApiResponse(code = 400, message = "Invalid request"),
@ApiResponse(code = 403, message = "The requester doesn't have admin permissions") @ApiResponse(code = 403, message = "The requester doesn't have admin permissions")
}) })
@Consumes(MediaType.APPLICATION_JSON)
@Path("/{tenant}/{namespace}") @Path("/{tenant}/{namespace}")
public List<String> listSources(final @PathParam("tenant") String tenant, public List<String> listSources(final @PathParam("tenant") String tenant,
final @PathParam("namespace") String namespace) { final @PathParam("namespace") String namespace) {
Expand Down Expand Up @@ -291,6 +292,7 @@ public void startSource(final @PathParam("tenant") String tenant,
@ApiResponse(code = 400, message = "Invalid request"), @ApiResponse(code = 400, message = "Invalid request"),
@ApiResponse(code = 408, message = "Request timeout") @ApiResponse(code = 408, message = "Request timeout")
}) })
@Produces(MediaType.APPLICATION_JSON)
@Path("/builtinsources") @Path("/builtinsources")
public List<ConnectorDefinition> getSourceList() { public List<ConnectorDefinition> getSourceList() {
List<ConnectorDefinition> connectorDefinitions = source.getListOfConnectors(); List<ConnectorDefinition> connectorDefinitions = source.getListOfConnectors();
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package org.apache.pulsar.broker.admin.v3; package org.apache.pulsar.broker.admin.v3;


import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import org.apache.pulsar.broker.admin.impl.SinkBase; import org.apache.pulsar.broker.admin.impl.SinksBase;


import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
import javax.ws.rs.Path; import javax.ws.rs.Path;
Expand All @@ -30,5 +30,9 @@
@Api(value = "/sink", description = "Sink admin apis", tags = "sink") @Api(value = "/sink", description = "Sink admin apis", tags = "sink")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
public class Sink extends SinkBase { @Deprecated
/**
* @deprecated in favor of {@link Sinks}
*/
public class Sink extends SinksBase {
} }
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* 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.broker.admin.v3;

import io.swagger.annotations.Api;
import org.apache.pulsar.broker.admin.impl.SinksBase;

import javax.ws.rs.Consumes;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

@Path("/sinks")
@Api(value = "/sinks", description = "Sinks admin apis", tags = "sinks")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class Sinks extends SinksBase {
}
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package org.apache.pulsar.broker.admin.v3; package org.apache.pulsar.broker.admin.v3;


import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import org.apache.pulsar.broker.admin.impl.SourceBase; import org.apache.pulsar.broker.admin.impl.SourcesBase;


import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
import javax.ws.rs.Path; import javax.ws.rs.Path;
Expand All @@ -30,5 +30,9 @@
@Api(value = "/source", description = "Source admin apis", tags = "source") @Api(value = "/source", description = "Source admin apis", tags = "source")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
public class Source extends SourceBase { @Deprecated
/**
* @deprecated in favor of {@link Sources}
*/
public class Source extends SourcesBase {
} }
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* 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.broker.admin.v3;

import io.swagger.annotations.Api;
import org.apache.pulsar.broker.admin.impl.SourcesBase;

import javax.ws.rs.Consumes;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

@Path("/sources")
@Api(value = "/sources", description = "Sources admin apis", tags = "sources")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class Sources extends SourcesBase {
}
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
import org.apache.pulsar.client.admin.internal.PulsarAdminBuilderImpl; import org.apache.pulsar.client.admin.internal.PulsarAdminBuilderImpl;
import org.apache.pulsar.client.admin.internal.ResourceQuotasImpl; import org.apache.pulsar.client.admin.internal.ResourceQuotasImpl;
import org.apache.pulsar.client.admin.internal.SchemasImpl; import org.apache.pulsar.client.admin.internal.SchemasImpl;
import org.apache.pulsar.client.admin.internal.SinkImpl; import org.apache.pulsar.client.admin.internal.SinksImpl;
import org.apache.pulsar.client.admin.internal.SourceImpl; import org.apache.pulsar.client.admin.internal.SourcesImpl;
import org.apache.pulsar.client.admin.internal.TenantsImpl; import org.apache.pulsar.client.admin.internal.TenantsImpl;
import org.apache.pulsar.client.admin.internal.TopicsImpl; import org.apache.pulsar.client.admin.internal.TopicsImpl;
import org.apache.pulsar.client.admin.internal.WorkerImpl; import org.apache.pulsar.client.admin.internal.WorkerImpl;
Expand Down Expand Up @@ -87,8 +87,8 @@ public class PulsarAdmin implements Closeable {
private final String serviceUrl; private final String serviceUrl;
private final Lookup lookups; private final Lookup lookups;
private final Functions functions; private final Functions functions;
private final Source source; private final Sources sources;
private final Sink sink; private final Sinks sinks;
private final Worker worker; private final Worker worker;
private final Schemas schemas; private final Schemas schemas;
protected final WebTarget root; protected final WebTarget root;
Expand Down Expand Up @@ -193,8 +193,8 @@ public PulsarAdmin(String serviceUrl,
this.resourceQuotas = new ResourceQuotasImpl(root, auth); this.resourceQuotas = new ResourceQuotasImpl(root, auth);
this.lookups = new LookupImpl(root, auth, useTls); this.lookups = new LookupImpl(root, auth, useTls);
this.functions = new FunctionsImpl(root, auth, httpAsyncClient); this.functions = new FunctionsImpl(root, auth, httpAsyncClient);
this.source = new SourceImpl(root, auth, httpAsyncClient); this.sources = new SourcesImpl(root, auth, httpAsyncClient);
this.sink = new SinkImpl(root, auth, httpAsyncClient); this.sinks = new SinksImpl(root, auth, httpAsyncClient);
this.worker = new WorkerImpl(root, auth); this.worker = new WorkerImpl(root, auth);
this.schemas = new SchemasImpl(root, auth); this.schemas = new SchemasImpl(root, auth);
this.bookies = new BookiesImpl(root, auth); this.bookies = new BookiesImpl(root, auth);
Expand Down Expand Up @@ -340,23 +340,35 @@ public Functions functions() {
} }


/** /**
* * @return the sources management object
* @return the source management object * @deprecated in favor of {@link #sources()}
*/ */
@Deprecated
public Source source() { public Source source() {
return source; return (Source) sources;
}

public Sources sources() {
return sources;
} }


/** /**
* * @return the sinks management object
* @return the sink management object * @deprecated in favor of {@link #sinks}
*/ */
@Deprecated
public Sink sink() { public Sink sink() {
return sink; return (Sink) sinks;
}

/**
* @return the sinks management object
*/
public Sinks sinks() {
return sinks;
} }


/** /**
*
* @return the Worker stats * @return the Worker stats
*/ */
public Worker worker() { public Worker worker() {
Expand Down
Loading

0 comments on commit aa40ad6

Please sign in to comment.