Skip to content
Draft
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
32 changes: 31 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,34 @@ The `cf-java-client` project is a Java language binding for interacting with a C
* `cloudfoundry-operations` – An API and implementation that corresponds to the [Cloud Foundry CLI][c] operations. This project builds on the `cloudfoundry-client` and therefore has a single implementation.

## Versions
The Cloud Foundry Java Client has two active versions. The `5.x` line is compatible with Spring Boot `2.4.x - 2.6.x` just to manage its dependencies, while the `4.x` line uses Spring Boot `2.3.x`.
The Cloud Foundry Java Client has two active versions. The `6.x` line includes breaking changes (see below), while the `5.x` line maintains backward compatibility.

## Breaking Changes (6.x)

### `DopplerClient.recentLogs()` — Removed

The `DopplerClient.recentLogs()` endpoint (and the `RecentLogsRequest` type) have been **removed**.
This API relied on the [Loggregator][loggregator] Doppler/Traffic Controller endpoint `/apps/{id}/recentlogs`, which was removed in **Loggregator >= 107.0** (CF Deployment >= 24.3, TAS >= 4.0).

**Migration:** Replace calls to `DopplerClient.recentLogs()` with [`LogCacheClient.read()`][log-cache-api]:

```java
logCacheClient.read(ReadRequest.builder()
.sourceId(appId)
.envelopeTypes(EnvelopeType.LOG)
.build());
```

**Operations API users:** Use `Applications.logs(ApplicationLogsRequest)` instead of the removed `Applications.logs(LogsRequest)`.

### `Applications.logs(LogsRequest)` — Removed

The `Applications.logs(LogsRequest)` method (and the `LogsRequest` type) have been **removed**.

**Migration:** Use `Applications.logs(ApplicationLogsRequest)` instead. For recent logs, set `recent(true)` (the default). For streaming, set `recent(false)`.

[loggregator]: https://github.com/cloudfoundry/loggregator
[log-cache-api]: https://github.com/cloudfoundry/log-cache

## Dependencies
Most projects will need two dependencies; the Operations API and an implementation of the Client API. For Maven, the dependencies would be defined like this:
Expand Down Expand Up @@ -76,6 +103,9 @@ Both the `cloudfoundry-operations` and `cloudfoundry-client` projects follow a [

### `CloudFoundryClient`, `DopplerClient`, `UaaClient` Builders

> [!NOTE]
> **`DopplerClient` — partial deprecation:** The `recentLogs()` method on `DopplerClient` is deprecated and only works against Loggregator \< 107.0 (CFD \< 24.3 / TAS \< 4.0). See the [Deprecations](#deprecations) section above for the migration path to `LogCacheClient`.

The lowest-level building blocks of the API are `ConnectionContext` and `TokenProvider`. These types are intended to be shared between instances of the clients, and come with out of the box implementations. To instantiate them, you configure them with builders:

```java
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.cloudfoundry.doppler.ContainerMetricsRequest;
import org.cloudfoundry.doppler.Envelope;
import org.cloudfoundry.doppler.FirehoseRequest;
import org.cloudfoundry.doppler.RecentLogsRequest;
import org.cloudfoundry.doppler.StreamRequest;
import org.cloudfoundry.reactor.ConnectionContext;
import org.cloudfoundry.reactor.TokenProvider;
Expand Down Expand Up @@ -57,17 +56,6 @@ Flux<Envelope> firehose(FirehoseRequest request) {
.checkpoint();
}

Flux<Envelope> recentLogs(RecentLogsRequest request) {
return get(
builder ->
builder.pathSegment(
"apps", request.getApplicationId(), "recentlogs"),
MultipartCodec::createDecoder,
MultipartCodec::decode)
.map(ReactorDopplerEndpoints::toEnvelope)
.checkpoint();
}

Flux<Envelope> stream(StreamRequest request) {
return ws(builder -> builder.pathSegment("apps", request.getApplicationId(), "stream"))
.map(ReactorDopplerEndpoints::toEnvelope)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.cloudfoundry.doppler.DopplerClient;
import org.cloudfoundry.doppler.Envelope;
import org.cloudfoundry.doppler.FirehoseRequest;
import org.cloudfoundry.doppler.RecentLogsRequest;

import org.cloudfoundry.doppler.StreamRequest;
import org.cloudfoundry.reactor.ConnectionContext;
import org.cloudfoundry.reactor.TokenProvider;
Expand All @@ -47,11 +47,6 @@ public Flux<Envelope> firehose(FirehoseRequest request) {
return getDopplerEndpoints().firehose(request);
}

@Override
public Flux<Envelope> recentLogs(RecentLogsRequest request) {
return getDopplerEndpoints().recentLogs(request);
}

@Override
public Flux<Envelope> stream(StreamRequest request) {
return getDopplerEndpoints().stream(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
import org.cloudfoundry.doppler.ContainerMetricsRequest;
import org.cloudfoundry.doppler.Envelope;
import org.cloudfoundry.doppler.EventType;
import org.cloudfoundry.doppler.LogMessage;
import org.cloudfoundry.doppler.MessageType;
import org.cloudfoundry.doppler.RecentLogsRequest;
import org.cloudfoundry.reactor.InteractionContext;
import org.cloudfoundry.reactor.TestRequest;
import org.cloudfoundry.reactor.TestResponse;
Expand Down Expand Up @@ -137,108 +134,4 @@ void containerMetricsLarge() {
.expectComplete()
.verify(Duration.ofSeconds(5));
}

@Test
void recentLogs() {
mockRequest(
InteractionContext.builder()
.request(
TestRequest.builder()
.method(GET)
.path("/apps/test-application-id/recentlogs")
.build())
.response(
TestResponse.builder()
.status(OK)
.contentType(
"multipart/x-protobuf;"
+ " boundary=92d42123ec83c0af6a27ba0de34528b702a53e2e67ba99636286b6a4cafb")
.payload(
"fixtures/doppler/apps/GET_{id}_recentlogs_response.bin")
.build())
.build());

this.dopplerEndpoints
.recentLogs(
RecentLogsRequest.builder().applicationId("test-application-id").build())
.as(StepVerifier::create)
.expectNext(
Envelope.builder()
.deployment("cf-cfapps-io2-diego")
.eventType(EventType.LOG_MESSAGE)
.index("33")
.ip("10.10.115.68")
.job("cell_z2")
.logMessage(
LogMessage.builder()
.applicationId(
"1a95eadc-95c6-4675-aa07-8c02f80ea8a4")
.message(
"2016-04-21 22:36:28.035 INFO 24 --- [ "
+ " main]"
+ " o.s.j.e.a.AnnotationMBeanExporter "
+ " : Located managed bean"
+ " 'rabbitConnectionFactory':"
+ " registering with JMX server as"
+ " MBean"
+ " [org.springframework.amqp.rabbit.connection:name=rabbitConnectionFactory,type=CachingConnectionFactory]")
.messageType(MessageType.OUT)
.sourceInstance("0")
.sourceType("APP")
.timestamp(1461278188035928339L)
.build())
.origin("rep")
.timestamp(1461278188035930425L)
.build(),
Envelope.builder()
.deployment("cf-cfapps-io2-diego")
.eventType(EventType.LOG_MESSAGE)
.index("33")
.ip("10.10.115.68")
.job("cell_z2")
.logMessage(
LogMessage.builder()
.applicationId(
"1a95eadc-95c6-4675-aa07-8c02f80ea8a4")
.message("Container became healthy")
.messageType(MessageType.OUT)
.sourceInstance("0")
.sourceType("CELL")
.timestamp(1461278188715651492L)
.build())
.origin("rep")
.timestamp(1461278188715653514L)
.build())
.expectComplete()
.verify(Duration.ofSeconds(5));
}

@Test
void recentLogsLarge() {
mockRequest(
InteractionContext.builder()
.request(
TestRequest.builder()
.method(GET)
.path("/apps/test-application-id/recentlogs")
.build())
.response(
TestResponse.builder()
.status(OK)
.contentType(
"multipart/x-protobuf;"
+ " boundary=74684f6bed3ee99aa98a13c609c354cd849b01a6e6051226906140ad31b2")
.payload(
"fixtures/doppler/apps/GET_{id}_recentlogs_response-large.bin")
.build())
.build());

this.dopplerEndpoints
.recentLogs(
RecentLogsRequest.builder().applicationId("test-application-id").build())
.as(StepVerifier::create)
.expectNextCount(3093)
.expectComplete()
.verify(Duration.ofSeconds(5));
}
}
Loading
Loading