Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Further Java updates #983

Merged
merged 6 commits into from
Oct 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.8.RELEASE</version>
<version>2.2.0.RELEASE</version>
</parent>
<groupId>io.seldon.engine</groupId>
<artifactId>seldon-engine</artifactId>
Expand All @@ -18,14 +18,14 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs
<project.build.sourceEncoding>
UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<grpc.version>1.23.0</grpc.version>
<grpc.version>1.24.0</grpc.version>
<pb.version>3.9.2</pb.version>
<micrometer.version>1.1.7</micrometer.version>
<micrometer.version>1.3.0</micrometer.version>
<start-class>io.seldon.engine.App</start-class>
<jaeger.version>1.0.0</jaeger.version>
<opentracing.version>0.33.0</opentracing.version>
<curator.version>4.2.0</curator.version>
<jackson.version>2.9.10</jackson.version>
<jackson.version>2.10.0</jackson.version>
<kubernetes.version>6.0.1</kubernetes.version>
</properties>
<build>
Expand Down Expand Up @@ -267,11 +267,6 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs
<artifactId>opentracing-api</artifactId>
<version>${opentracing.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-properties-migrator</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
Expand Down
19 changes: 0 additions & 19 deletions engine/src/license/THIRD-PARTY.properties

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ public class GrpcChannelHandler {
@Autowired TracingProvider tracingProvider;

public Channel get(Endpoint endpoint) {
if (store.containsKey(endpoint)) return store.get(endpoint);
else {
if (store.containsKey(endpoint)) {
return store.get(endpoint);
} else {
ManagedChannel channel =
ManagedChannelBuilder.forAddress(endpoint.getServiceHost(), endpoint.getServicePort())
.usePlaintext(true)
.usePlaintext()
.build();

if (tracingProvider != null && tracingProvider.isActive()) {
Expand All @@ -32,7 +33,9 @@ public Channel get(Endpoint endpoint) {
.withTracer(this.tracingProvider.getTracer())
.build();
store.putIfAbsent(endpoint, tracingInterceptor.intercept(channel));
} else store.putIfAbsent(endpoint, channel);
} else {
store.putIfAbsent(endpoint, channel);
}
return store.get(endpoint);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public SeldonGrpcServer(
try {
maxMessageSize = Integer.parseInt(annotations.get(ANNOTATION_MAX_MESSAGE_SIZE));
logger.info("Setting max message to {}", maxMessageSize);
builder.maxMessageSize(maxMessageSize);
builder.maxInboundMessageSize(maxMessageSize);
} catch (NumberFormatException e) {
logger.warn(
"Failed to parse {} with value {}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
*/
package io.seldon.engine.predictors;

import static org.ojalgo.function.PrimitiveFunction.*;
// import static org.ojalgo.function.PrimitiveFunction.*;
import static org.ojalgo.function.constant.PrimitiveMath.DIVIDE;

import io.seldon.engine.exception.APIException;
import io.seldon.protos.PredictionProtos.DefaultData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.time.Duration;
import java.util.Collections;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -138,8 +139,8 @@ public InternalPredictionService(
logger.info("REST read timeout set to {}", readTimeout);
this.restTemplate =
restTemplateBuilder
.setConnectTimeout(connectionTimeout)
.setReadTimeout(readTimeout)
.setConnectTimeout(Duration.ofMillis(connectionTimeout))
.setReadTimeout(Duration.ofMillis(readTimeout))
.build();
if (tracingProvider.isActive()) {
restTemplate.setInterceptors(
Expand Down Expand Up @@ -370,7 +371,9 @@ public SeldonMessage aggregate(List<SeldonMessage> outputs, PredictiveUnitState
}

private boolean isDefaultData(SeldonMessage message) {
if (message.getDataOneofCase() == DataOneofCase.DATA) return true;
if (message.getDataOneofCase() == DataOneofCase.DATA) {
return true;
}
return false;
}

Expand All @@ -393,8 +396,9 @@ private SeldonMessage queryREST(
URI uri;
try {
final String uriKey = getUriKey(endpoint, path);
if (uriCache.containsKey(uriKey)) uri = uriCache.get(uriKey);
else {
if (uriCache.containsKey(uriKey)) {
uri = uriCache.get(uriKey);
} else {
URIBuilder builder =
new URIBuilder()
.setScheme("http")
Expand All @@ -413,8 +417,9 @@ private SeldonMessage queryREST(
for (int i = 0; i < restRetries; i++) {
try {
HttpHeaders headers;
if (headersCache.containsKey(state.name)) headers = headersCache.get(state.name);
else {
if (headersCache.containsKey(state.name)) {
headers = headersCache.get(state.name);
} else {
headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
headers.add(MODEL_NAME_HEADER, state.name);
Expand All @@ -430,7 +435,9 @@ private SeldonMessage queryREST(
HttpEntity<MultiValueMap<String, String>> request =
new HttpEntity<MultiValueMap<String, String>>(map, headers);

if (logger.isDebugEnabled()) logger.debug("Requesting {}", uri.toString());
if (logger.isDebugEnabled()) {
logger.debug("Requesting {}", uri.toString());
}
ResponseEntity<String> httpResponse =
restTemplate.postForEntity(uri, request, String.class);
try {
Expand All @@ -449,9 +456,10 @@ private SeldonMessage queryREST(
String.format("Bad return code %d", httpResponse.getStatusCode()));
}
} finally {
if (logger.isDebugEnabled())
if (logger.isDebugEnabled()) {
logger.debug(
"External prediction server took " + (System.currentTimeMillis() - timeNow) + "ms");
}
}
} catch (ResourceAccessException e) {
logger.warn("Caught resource access exception ", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.test.web.servlet.MockMvc;
Expand All @@ -41,10 +40,6 @@
@ActiveProfiles("test")
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@AutoConfigureMockMvc
@TestPropertySource(
properties = {
"management.security.enabled=false",
})
public class TestRandomABTest {

@Autowired private WebApplicationContext context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.test.web.servlet.MockMvc;
Expand All @@ -43,10 +42,6 @@
@ActiveProfiles("test")
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@AutoConfigureMockMvc
@TestPropertySource(
properties = {
"management.security.enabled=false",
})
public class TestRestClientControllerExternalGraphs {

@Autowired private WebApplicationContext context;
Expand Down
7 changes: 4 additions & 3 deletions engine/src/test/java/io/seldon/engine/config/TestConfig.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package io.seldon.engine.config;

import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import io.seldon.engine.grpc.GrpcChannelHandler;
import io.seldon.engine.service.InternalPredictionService;
import io.seldon.engine.tracing.TracingProvider;
import java.io.IOException;
import java.time.Duration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
Expand All @@ -33,8 +34,8 @@ public RestTemplateBuilder restTemplateBuilder() {
RestTemplateBuilder rtb = mock(RestTemplateBuilder.class);
RestTemplate restTemplate = mock(RestTemplate.class);
ClientHttpRequestFactory requestFactory = mock(ClientHttpRequestFactory.class);
when(rtb.setConnectTimeout(anyInt())).thenReturn(rtb);
when(rtb.setReadTimeout(anyInt())).thenReturn(rtb);
when(rtb.setConnectTimeout(any(Duration.class))).thenReturn(rtb);
when(rtb.setReadTimeout(any(Duration.class))).thenReturn(rtb);
when(rtb.build()).thenReturn(restTemplate);
when(restTemplate.getRequestFactory()).thenReturn(requestFactory);

Expand Down