use of com.google.cloud.compute.v1.Route in project RouteConverter by cpesch.
the class Nmn7Format method read.
public void read(InputStream source, ParserContext<NmnRoute> context) throws IOException {
Route route = unmarshal(source);
context.appendRoute(process(route));
}
use of com.google.cloud.compute.v1.Route in project WorkHelperApp by hubme.
the class OkHttpProvider method initOkHttp.
private void initOkHttp() {
// 自动刷新 token
Authenticator mAuthenticator = new Authenticator() {
@Override
public Request authenticate(Route route, Response response) {
Logger.i("自动刷新 token 开始");
String accessToken = "";
/*TokenService tokenService = mRetrofit.create(TokenService.class);
try {
if (null != mCacheUtil.getToken()) {
Call<Token> call = tokenService.refreshToken(OAuth.client_id,
OAuth.client_secret, OAuth.GRANT_TYPE_REFRESH,
mCacheUtil.getToken().getRefresh_token());
retrofit2.Response<Token> tokenResponse = call.execute();
Token token = tokenResponse.body();
if (null != token) {
mCacheUtil.saveToken(token);
accessToken = token.getAccess_token();
}
}
} catch (Exception e) {
e.printStackTrace();
}*/
Logger.i("自动刷新 token 结束:" + accessToken);
return response.request().newBuilder().addHeader("KEY_TOKEN", accessToken).build();
}
};
OkHttpClient.Builder builder = new OkHttpClient.Builder().cache(new Cache(new File(Environment.getExternalStorageDirectory().getPath() + "/000test/cache"), 5 * 1024 * 1024L)).connectTimeout(DEFAULT_CONNECT_TIMEOUT, TimeUnit.SECONDS).readTimeout(DEFAULT_READ_TIMEOUT, TimeUnit.SECONDS).writeTimeout(DEFAULT_WRITE_TIMEOUT, TimeUnit.SECONDS).retryOnConnectionFailure(true).authenticator(mAuthenticator);
if (BuildConfig.LOG_DEBUG) {
builder.addInterceptor(new LogInterceptor());
}
mOkHttpClient = builder.build();
}
use of com.google.cloud.compute.v1.Route in project pinpoint by naver.
the class RealConnectionConnectMethodInterceptor method doInAfterTrace.
@Override
protected void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] args, Object result, Throwable throwable) {
recorder.recordApi(methodDescriptor);
recorder.recordServiceType(OkHttpConstants.OK_HTTP_CLIENT_INTERNAL);
recorder.recordException(throwable);
if (target instanceof RouteGetter) {
final Route route = ((RouteGetter) target)._$PINPOINT$_getRoute();
if (route != null) {
final String hostAndPort = getHostAndPort(route);
recorder.recordAttribute(AnnotationKey.HTTP_INTERNAL_DISPLAY, hostAndPort);
}
}
}
use of com.google.cloud.compute.v1.Route in project kogito-runtimes by kiegroup.
the class KnativeRouteEndpointDiscoveryTest method testQueryByLabels.
@Test
public void testQueryByLabels() {
final KnativeRouteEndpointDiscovery endpointDiscovery = new KnativeRouteEndpointDiscovery(null);
endpointDiscovery.setKnativeClient(knativeClient);
final Map<String, String> labels = Collections.singletonMap("app", "serverlessapp");
// configure mock
final RouteStatus status = new RouteStatus();
status.setUrl("http://192.168.2.32");
final Route route = new RouteBuilder().withNewMetadata().withLabels(labels).withName("ksvc2").withNamespace("test").and().withStatus(status).build();
knativeClient.routes().create(route);
final List<Endpoint> endpoint = endpointDiscovery.findEndpoint("test", labels);
assertFalse(endpoint.isEmpty());
try {
new URL(endpoint.get(0).getUrl());
} catch (MalformedURLException e) {
// verbose
fail("The generated URL " + endpoint.get(0).getUrl() + " is invalid");
}
}
use of com.google.cloud.compute.v1.Route in project kogito-runtimes by kiegroup.
the class KnativeRouteEndpointDiscoveryTest method testRouteWithoutStatus.
@Test
public void testRouteWithoutStatus() {
final KnativeRouteEndpointDiscovery endpointDiscovery = new KnativeRouteEndpointDiscovery(null);
endpointDiscovery.setKnativeClient(knativeClient);
// configure mock
final Route route = new RouteBuilder().withNewMetadata().withName("ksvc3").withNamespace("test").and().build();
knativeClient.routes().create(route);
final Optional<Endpoint> endpoint = endpointDiscovery.findEndpoint("test", "ksvc3");
assertTrue(endpoint.isEmpty());
}
Aggregations