Search in sources :

Example 46 with Route

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));
}
Also used : Route(slash.navigation.base.RouteCharacteristics.Route) Route(slash.navigation.nmn.binding7.Route)

Example 47 with 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();
}
Also used : Response(okhttp3.Response) OkHttpClient(okhttp3.OkHttpClient) LogInterceptor(com.king.app.workhelper.okhttp.interceptor.LogInterceptor) File(java.io.File) Authenticator(okhttp3.Authenticator) Route(okhttp3.Route) Cache(okhttp3.Cache)

Example 48 with Route

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);
        }
    }
}
Also used : Route(okhttp3.Route) RouteGetter(com.navercorp.pinpoint.plugin.okhttp.v3.RouteGetter)

Example 49 with Route

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");
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) RouteBuilder(io.fabric8.knative.serving.v1.RouteBuilder) Endpoint(org.kie.kogito.addons.k8s.Endpoint) RouteStatus(io.fabric8.knative.serving.v1.RouteStatus) KnativeRouteEndpointDiscovery(org.kie.kogito.addons.k8s.KnativeRouteEndpointDiscovery) Route(io.fabric8.knative.serving.v1.Route) URL(java.net.URL) Test(org.junit.jupiter.api.Test)

Example 50 with Route

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());
}
Also used : RouteBuilder(io.fabric8.knative.serving.v1.RouteBuilder) Endpoint(org.kie.kogito.addons.k8s.Endpoint) KnativeRouteEndpointDiscovery(org.kie.kogito.addons.k8s.KnativeRouteEndpointDiscovery) Route(io.fabric8.knative.serving.v1.Route) Test(org.junit.jupiter.api.Test)

Aggregations

Route (okhttp3.Route)30 Response (okhttp3.Response)16 Authenticator (okhttp3.Authenticator)14 Request (okhttp3.Request)12 IOException (java.io.IOException)10 OkHttpClient (okhttp3.OkHttpClient)10 InetSocketAddress (java.net.InetSocketAddress)9 Route (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.Route)9 Proxy (java.net.Proxy)7 Route (io.fabric8.knative.serving.v1.Route)6 RouteBuilder (io.fabric8.knative.serving.v1.RouteBuilder)6 Test (org.junit.Test)6 Test (org.junit.jupiter.api.Test)6 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)6 KeyedInstanceIdentifier (org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier)6 Address (okhttp3.Address)5 Connection (okhttp3.Connection)5 RIBSupport (org.opendaylight.protocol.bgp.rib.spi.RIBSupport)5 Identifier (org.opendaylight.yangtools.yang.binding.Identifier)5 Builder (okhttp3.OkHttpClient.Builder)4