Skip to content

Commit

Permalink
Fix grpc implementation
Browse files Browse the repository at this point in the history
Signed-off-by: Achal Shah <[email protected]>
  • Loading branch information
achals committed Dec 27, 2021
1 parent 8d621eb commit 7c81e4b
Show file tree
Hide file tree
Showing 11 changed files with 224 additions and 201 deletions.
4 changes: 4 additions & 0 deletions java/datatypes/java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
their interchanges. These are generated from Protocol Buffers and gRPC
definitions included in the package.
</description>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<artifactId>datatypes-java</artifactId>

<parent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public static void main(String[] args) throws InterruptedException, IOException
new ServingServiceConfigV2(),
new RegistryConfig(),
new InstrumentationConfig(),
new ServerModule(args));
new ServerModule(),
new ApplicationPropertiesModule(args));

Server server = i.getInstance(Server.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ public static class FeastProperties {
/* Feast Serving build version */
@NotBlank private String version = "unknown";

public void setRegistry(String registry) {
this.registry = registry;
}

public void setRegistryRefreshInterval(int registryRefreshInterval) {
this.registryRefreshInterval = registryRefreshInterval;
}

@NotBlank private String registry;

public String getRegistry() {
Expand Down Expand Up @@ -65,6 +73,10 @@ public Store getActiveStore() {
String.format("Active store is misconfigured. Could not find store: %s.", activeStore));
}

public void setActiveStore(String activeStore) {
this.activeStore = activeStore;
}

/** Name of the active store configuration (only one store can be active at a time). */
@NotBlank private String activeStore;

Expand All @@ -79,6 +91,10 @@ public Store getActiveStore() {
/* Feast Audit Logging properties */
@NotNull private LoggingProperties logging;

public void setStores(List<Store> stores) {
this.stores = stores;
}

/**
* Gets Serving store configuration as a list of {@link Store}.
*
Expand All @@ -97,6 +113,10 @@ public String getVersion() {
return version;
}

public void setTracing(TracingProperties tracing) {
this.tracing = tracing;
}

/**
* Gets tracing properties
*
Expand All @@ -118,6 +138,10 @@ public LoggingProperties getLogging() {

private FeastProperties feast;

public void setFeast(FeastProperties feast) {
this.feast = feast;
}

public FeastProperties getFeast() {
return feast;
}
Expand Down Expand Up @@ -149,6 +173,12 @@ public static class Store {

private Map<String, String> config = new HashMap<>();

public Store(String name, String type, Map<String, String> config) {
this.name = name;
this.type = type;
this.config = config;
}

/**
* Gets name of this store. This is unique to this specific instance.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright 2018-2021 The Feast 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
*
* https://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 feast.serving.config;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.google.inject.AbstractModule;
import com.google.inject.Provides;
import com.google.inject.Singleton;
import java.io.File;
import java.io.IOException;

public class ApplicationPropertiesModule extends AbstractModule {
private final String[] args;

public ApplicationPropertiesModule(String[] args) {
this.args = args;
}

@Provides
@Singleton
public ApplicationProperties provideApplicationProperties() throws IOException {
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
mapper.findAndRegisterModules();
ApplicationProperties properties =
mapper.readValue(new File(this.args[0]), ApplicationProperties.class);

return properties;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,21 @@
*/
package feast.serving.config;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.google.inject.AbstractModule;
import com.google.inject.Provides;
import com.google.inject.Singleton;
import feast.serving.grpc.OnlineServingGrpcServiceV2;
import io.grpc.Server;
import io.grpc.ServerBuilder;
import io.grpc.protobuf.services.ProtoReflectionService;
import io.opentracing.contrib.grpc.TracingServerInterceptor;
import java.io.File;
import java.io.IOException;

public class ServerModule extends AbstractModule {

private final String[] args;

public ServerModule(String[] args) {
this.args = args;
}

@Override
protected void configure() {
bind(OnlineServingGrpcServiceV2.class);
}

@Provides
// @Provides
public Server provideGrpcServer(
OnlineServingGrpcServiceV2 onlineServingGrpcServiceV2,
TracingServerInterceptor tracingServerInterceptor) {
Expand All @@ -54,15 +42,4 @@ public Server provideGrpcServer(

return serverBuilder.build();
}

@Provides
@Singleton
public ApplicationProperties provideApplicationProperties() throws IOException {
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
mapper.findAndRegisterModules();
ApplicationProperties properties =
mapper.readValue(new File(this.args[0]), ApplicationProperties.class);

return properties;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ public void getOnlineFeaturesV2(
StreamObserver<GetOnlineFeaturesResponse> responseObserver) {
try {
// authorize for the project in request object.
if (request.getProject() != null && !request.getProject().isEmpty()) {
request.getProject();
if (!request.getProject().isEmpty()) {
// update monitoring context
GrpcMonitoringContext.getInstance().setProject(request.getProject());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@
import feast.serving.service.ServingServiceV2;
import io.grpc.stub.StreamObserver;
import javax.inject.Inject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class OnlineServingGrpcServiceV2 extends ServingServiceGrpc.ServingServiceImplBase {
public static final Logger logger = LoggerFactory.getLogger(OnlineServingGrpcServiceV2.class);

private final ServingServiceV2 servingServiceV2;

Expand All @@ -36,12 +39,15 @@ public void getFeastServingInfo(
ServingAPIProto.GetFeastServingInfoRequest request,
StreamObserver<ServingAPIProto.GetFeastServingInfoResponse> responseObserver) {
responseObserver.onNext(this.servingServiceV2.getFeastServingInfo(request));
responseObserver.onCompleted();
}

@Override
public void getOnlineFeaturesV2(
ServingAPIProto.GetOnlineFeaturesRequestV2 request,
StreamObserver<ServingAPIProto.GetOnlineFeaturesResponse> responseObserver) {
logger.info("In the getOnlineFeaturesV2");
responseObserver.onNext(this.servingServiceV2.getOnlineFeatures(request));
responseObserver.onCompleted();
}
}

This file was deleted.

Loading

0 comments on commit 7c81e4b

Please sign in to comment.