io.fabric8.kubernetes.client.dsl.base.BaseOperation Java Examples

The following examples show how to use io.fabric8.kubernetes.client.dsl.base.BaseOperation. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WatchConnectionManager.java    From kubernetes-client with Apache License 2.0 5 votes vote down vote up
public WatchConnectionManager(final OkHttpClient client, final BaseOperation<T, L, ?, ?> baseOperation, final ListOptions listOptions, final Watcher<T> watcher, final int reconnectInterval, final int reconnectLimit, long websocketTimeout, int maxIntervalExponent) throws MalformedURLException {
  this.listOptions = listOptions;
  this.resourceVersion = new AtomicReference<>(listOptions.getResourceVersion());
  this.baseOperation = baseOperation;
  this.watcher = watcher;
  this.reconnectInterval = reconnectInterval;
  this.reconnectLimit = reconnectLimit;
  this.websocketTimeout = websocketTimeout;
  this.maxIntervalExponent = maxIntervalExponent;

  this.clonedClient = client.newBuilder()
    .readTimeout(this.websocketTimeout, TimeUnit.MILLISECONDS)
    .build();

  // The URL is created, validated and saved once, so that reconnect attempts don't have to deal with
  // MalformedURLExceptions that would never occur

  requestUrl = baseOperation.getNamespacedUrl();
  //create after the call above where MalformedURLException can be raised
  //avoids having to call shutdown in case the exception is raised
  executor = Executors.newSingleThreadScheduledExecutor(r -> {
    Thread ret = new Thread(r, "Executor for Watch " + System.identityHashCode(WatchConnectionManager.this));
    ret.setDaemon(true);
    return ret;
  });
  runWatch();
}
 
Example #2
Source File: WatchHTTPManager.java    From kubernetes-client with Apache License 2.0 5 votes vote down vote up
public WatchHTTPManager(final OkHttpClient client,
                        final BaseOperation<T, L, ?, ?> baseOperation,
                        final ListOptions listOptions, final Watcher<T> watcher, final int reconnectInterval,
                        final int reconnectLimit, long connectTimeout)
  throws MalformedURLException {
  // Default max 32x slowdown from base interval
  this(client, baseOperation, listOptions, watcher, reconnectInterval, reconnectLimit, connectTimeout, 5);
}
 
Example #3
Source File: WatchHTTPManager.java    From kubernetes-client with Apache License 2.0 5 votes vote down vote up
public WatchHTTPManager(final OkHttpClient client,
                        final BaseOperation<T, L, ?, ?> baseOperation,
                        final ListOptions listOptions, final Watcher<T> watcher, final int reconnectInterval,
                        final int reconnectLimit, long connectTimeout, int maxIntervalExponent)
  throws MalformedURLException {

  this.resourceVersion = new AtomicReference<>(listOptions.getResourceVersion());
  this.listOptions = listOptions;
  this.baseOperation = baseOperation;
  this.watcher = watcher;
  this.reconnectInterval = reconnectInterval;
  this.reconnectLimit = reconnectLimit;
  this.maxIntervalExponent = maxIntervalExponent;

  OkHttpClient clonedClient = client.newBuilder()
    .connectTimeout(connectTimeout, TimeUnit.MILLISECONDS)
    .readTimeout(0, TimeUnit.MILLISECONDS)
    .cache(null)
    .build();

  // If we set the HttpLoggingInterceptor's logging level to Body (as it is by default), it does
  // not let us stream responses from the server.
  for (Interceptor i : clonedClient.networkInterceptors()) {
    if (i instanceof HttpLoggingInterceptor) {
      HttpLoggingInterceptor interceptor = (HttpLoggingInterceptor) i;
      interceptor.setLevel(HttpLoggingInterceptor.Level.BASIC);
    }
  }

  this.clonedClient = clonedClient;
  requestUrl = baseOperation.getNamespacedUrl();
  runWatch();
}
 
Example #4
Source File: BuildConfigOperationsImpl.java    From kubernetes-client with Apache License 2.0 5 votes vote down vote up
@Override
public Build instantiate(BuildRequest request) {
  try {
    updateApiVersion(request);
    URL instantiationUrl = new URL(URLUtils.join(getResourceUrl().toString(), "instantiate"));
    RequestBody requestBody = RequestBody.create(JSON, BaseOperation.JSON_MAPPER.writer().writeValueAsString(request));
    Request.Builder requestBuilder = new Request.Builder().post(requestBody).url(instantiationUrl);
    return handleResponse(requestBuilder, Build.class);
  } catch (Exception e) {
    throw KubernetesClientException.launderThrowable(e);
  }
}
 
Example #5
Source File: WatchConnectionManager.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
public WatchConnectionManager(final OkHttpClient client, final BaseOperation<T, L, ?, ?> baseOperation, final ListOptions listOptions, final Watcher<T> watcher, final int reconnectInterval, final int reconnectLimit, long websocketTimeout) throws MalformedURLException {
  // Default max 32x slowdown from base interval
  this(client, baseOperation, listOptions, watcher, reconnectInterval, reconnectLimit, websocketTimeout, 5);
}
 
Example #6
Source File: BaseClient.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
@Override
public RootPaths rootPaths() {
  return new BaseOperation(new OperationContext().withOkhttpClient(httpClient).withConfig(configuration)) {
  }.getRootPaths();
}
 
Example #7
Source File: ServiceBindingOperationsImpl.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
@Override
public BaseOperation<ServiceBinding, ServiceBindingList, DoneableServiceBinding, ServiceBindingResource> newInstance(OperationContext context) {
    return new ServiceBindingOperationsImpl(context);
}
 
Example #8
Source File: ServiceInstanceOperationsImpl.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
@Override
public BaseOperation<ServiceInstance, ServiceInstanceList, DoneableServiceInstance, ServiceInstanceResource> newInstance(OperationContext context) {
    return new ServiceInstanceOperationsImpl(context);
}
 
Example #9
Source File: ClusterServiceClassOperationsImpl.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
@Override
public BaseOperation<ClusterServiceClass, ClusterServiceClassList, DoneableClusterServiceClass, ClusterServiceClassResource> newInstance(OperationContext context) {
    return new ClusterServiceClassOperationsImpl(context);
}
 
Example #10
Source File: ClusterServicePlanOperationsImpl.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
@Override
public BaseOperation<ClusterServicePlan, ClusterServicePlanList, DoneableClusterServicePlan, ClusterServicePlanResource> newInstance(OperationContext context) {
    return new ClusterServicePlanOperationsImpl(context);
}
 
Example #11
Source File: ClusterServiceBrokerOperationsImpl.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
@Override
public BaseOperation<ClusterServiceBroker, ClusterServiceBrokerList, DoneableClusterServiceBroker, ClusterServiceBrokerResource> newInstance(OperationContext context) {
    return new ClusterServiceBrokerOperationsImpl(context);
}