All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sap.hana.datalake.files.utils.http.DefaultTimeConnectionKeepAliveStrategy Maven / Gradle / Ivy

Go to download

An implementation of org.apache.hadoop.fs.FileSystem targeting SAP HANA Data Lake Files.

There is a newer version: 3.0.27
Show newest version
// © 2023-2024 SAP SE or an SAP affiliate company. All rights reserved.
package com.sap.hana.datalake.files.utils.http;

import com.sap.hana.datalake.files.classification.InterfaceAudience;
import org.apache.http.HttpResponse;
import org.apache.http.impl.client.DefaultConnectionKeepAliveStrategy;
import org.apache.http.protocol.HttpContext;

@InterfaceAudience.Private
public class DefaultTimeConnectionKeepAliveStrategy extends DefaultConnectionKeepAliveStrategy {

  private final long defaultKeepAliveTimeMs;

  public DefaultTimeConnectionKeepAliveStrategy(final long defaultKeepAliveTimeSecs) {
    this.defaultKeepAliveTimeMs = defaultKeepAliveTimeSecs * 1_000L;
  }

  @Override
  public long getKeepAliveDuration(final HttpResponse response, final HttpContext context) {
    final long keepAliveFromServer = super.getKeepAliveDuration(response, context);

    return keepAliveFromServer > 0 ? keepAliveFromServer : this.defaultKeepAliveTimeMs;
  }
}

// © 2023-2024 SAP SE or an SAP affiliate company. All rights reserved.




© 2015 - 2025 Weber Informatics LLC | Privacy Policy