update comments for AdsService and AdsServiceClient

This commit is contained in:
rahulpa 2018-08-15 15:06:00 -07:00
parent 2d03430bec
commit 786949ab2e
2 changed files with 6 additions and 22 deletions

View file

@ -41,7 +41,7 @@ public class AdsService {
private void start() throws IOException { private void start() throws IOException {
int port = Integer.parseInt(System.getenv("PORT")); int port = Integer.parseInt(System.getenv("PORT"));
server = ServerBuilder.forPort(port).addService(new AdsServiceImpl()).build().start(); server = ServerBuilder.forPort(port).addService(new AdsServiceImpl()).build().start();
logger.info("Server started, listening on " + port); logger.info("Ads Service started, listening on " + port);
Runtime.getRuntime() Runtime.getRuntime()
.addShutdownHook( .addShutdownHook(
new Thread() { new Thread() {
@ -138,7 +138,6 @@ public class AdsService {
} }
static void initializeAds() { static void initializeAds() {
// TODO: Replace localhost with
String adsUrl = System.getenv("ADS_URL"); String adsUrl = System.getenv("ADS_URL");
cacheMap.put("camera", Ads.newBuilder().setRedirectUrl(adsUrl + "/camera") cacheMap.put("camera", Ads.newBuilder().setRedirectUrl(adsUrl + "/camera")
.setText("MyPro camera for sale. 50% off.").build()); .setText("MyPro camera for sale. 50% off.").build());

View file

@ -1,18 +1,3 @@
/*
* Copyright 2018, OpenCensus Authors
*
* Licensed 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 hipstershop; package hipstershop;
@ -49,7 +34,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.annotation.Nullable; import javax.annotation.Nullable;
/** A simple client that requests a greeting from the {@link AdsServiceClient}. */ /** A simple client that requests ads from the Ads Service. */
public class AdsServiceClient { public class AdsServiceClient {
private static final Logger logger = Logger.getLogger(AdsServiceClient.class.getName()); private static final Logger logger = Logger.getLogger(AdsServiceClient.class.getName());
@ -58,7 +43,7 @@ public class AdsServiceClient {
private final ManagedChannel channel; private final ManagedChannel channel;
private final hipstershop.AdsServiceGrpc.AdsServiceBlockingStub blockingStub; private final hipstershop.AdsServiceGrpc.AdsServiceBlockingStub blockingStub;
/** Construct client connecting to HelloWorld server at {@code host:port}. */ /** Construct client connecting to Ad Service at {@code host:port}. */
public AdsServiceClient(String host, int port) { public AdsServiceClient(String host, int port) {
this( this(
ManagedChannelBuilder.forAddress(host, port) ManagedChannelBuilder.forAddress(host, port)
@ -78,7 +63,7 @@ public class AdsServiceClient {
channel.shutdown().awaitTermination(5, TimeUnit.SECONDS); channel.shutdown().awaitTermination(5, TimeUnit.SECONDS);
} }
/** Say hello to server. */ /** Get Ads from Server. */
public void getAds(String contextKey) { public void getAds(String contextKey) {
logger.info("Get Ads with context " + contextKey + " ..."); logger.info("Get Ads with context " + contextKey + " ...");
AdsRequest request = AdsRequest.newBuilder().addContextKeys(contextKey).build(); AdsRequest request = AdsRequest.newBuilder().addContextKeys(contextKey).build();
@ -129,8 +114,8 @@ public class AdsServiceClient {
} }
/** /**
* Greet server. If provided, the first element of {@code args} is the name to use in the * Ads Service Client main. If provided, the first element of {@code args} is the context key to
* greeting. * get the ads from the Ads Service
*/ */
public static void main(String[] args) throws IOException, InterruptedException { public static void main(String[] args) throws IOException, InterruptedException {
// Add final keyword to pass checkStyle. // Add final keyword to pass checkStyle.