Search in sources :

Example 1 with ServerInfo

use of io.confluent.ksql.api.client.ServerInfo in project ksql by confluentinc.

the class ClientIntegrationTest method shouldExecutePlainHttpRequests.

@Test
public void shouldExecutePlainHttpRequests() throws Exception {
    final HttpResponse response = client.buildRequest("GET", "/info").send().get();
    assertThat(response.status(), is(200));
    final Map<String, Map<String, Object>> info = response.bodyAsMap();
    final ServerInfo serverInfo = client.serverInfo().get();
    final Map<String, Object> innerMap = info.get("KsqlServerInfo");
    assertThat(innerMap.get("version"), is(serverInfo.getServerVersion()));
    assertThat(innerMap.get("ksqlServiceId"), is(serverInfo.getKsqlServiceId()));
    assertThat(innerMap.get("kafkaClusterId"), is(serverInfo.getKafkaClusterId()));
    assertThat(innerMap.get("serverStatus"), is("RUNNING"));
}
Also used : ServerInfo(io.confluent.ksql.api.client.ServerInfo) HttpResponse(io.confluent.ksql.api.client.Client.HttpResponse) JsonObject(io.vertx.core.json.JsonObject) KsqlObject(io.confluent.ksql.api.client.KsqlObject) Matchers.containsString(org.hamcrest.Matchers.containsString) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.Test) IntegrationTest(io.confluent.common.utils.IntegrationTest)

Example 2 with ServerInfo

use of io.confluent.ksql.api.client.ServerInfo in project ksql by confluentinc.

the class MetadataUtil method serverSupportsMultiKeyPullQuery.

private static boolean serverSupportsMultiKeyPullQuery(final Client ksqlClient, final MigrationConfig config) {
    final String ksqlServerUrl = config.getString(MigrationConfig.KSQL_SERVER_URL);
    final ServerInfo serverInfo = getServerInfo(ksqlClient, ksqlServerUrl);
    return versionSupportsMultiKeyPullQuery(serverInfo.getServerVersion());
}
Also used : ServerInfo(io.confluent.ksql.api.client.ServerInfo) ServerVersionUtil.getServerInfo(io.confluent.ksql.tools.migrations.util.ServerVersionUtil.getServerInfo)

Example 3 with ServerInfo

use of io.confluent.ksql.api.client.ServerInfo in project ksql by confluentinc.

the class ClientImpl method serverInfo.

@Override
public CompletableFuture<ServerInfo> serverInfo() {
    final CompletableFuture<ServerInfo> cf = new CompletableFuture<>();
    makeGetRequest(INFO_ENDPOINT, new JsonObject(), cf, response -> handleObjectResponse(response, cf, AdminResponseHandlers::handleServerInfoResponse));
    return cf;
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) ServerInfo(io.confluent.ksql.api.client.ServerInfo) JsonObject(io.vertx.core.json.JsonObject)

Example 4 with ServerInfo

use of io.confluent.ksql.api.client.ServerInfo in project ksql by confluentinc.

the class ClientIntegrationTest method shouldGetServerInfo.

@Test
public void shouldGetServerInfo() throws Exception {
    // Given:
    final String expectedClusterId = REST_APP.getServiceContext().getAdminClient().describeCluster().clusterId().get();
    // When:
    final ServerInfo serverInfo = client.serverInfo().get();
    // Then:
    assertThat(serverInfo.getServerVersion(), is(AppInfo.getVersion()));
    assertThat(serverInfo.getKsqlServiceId(), is("default_"));
    assertThat(serverInfo.getKafkaClusterId(), is(expectedClusterId));
}
Also used : ServerInfo(io.confluent.ksql.api.client.ServerInfo) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test) IntegrationTest(io.confluent.common.utils.IntegrationTest)

Example 5 with ServerInfo

use of io.confluent.ksql.api.client.ServerInfo in project ksql by confluentinc.

the class ServerVersionUtil method serverVersionCompatible.

public static boolean serverVersionCompatible(final Client ksqlClient, final MigrationConfig config) {
    final String ksqlServerUrl = config.getString(MigrationConfig.KSQL_SERVER_URL);
    final ServerInfo serverInfo;
    try {
        serverInfo = getServerInfo(ksqlClient, ksqlServerUrl);
    } catch (MigrationException e) {
        LOGGER.error("Failed to get server info to verify version compatibility: {}", e.getMessage());
        return false;
    }
    final String serverVersion = serverInfo.getServerVersion();
    try {
        return isSupportedVersion(serverVersion);
    } catch (MigrationException e) {
        LOGGER.warn(e.getMessage() + ". Proceeding anyway.");
        return true;
    }
}
Also used : MigrationException(io.confluent.ksql.tools.migrations.MigrationException) ServerInfo(io.confluent.ksql.api.client.ServerInfo)

Aggregations

ServerInfo (io.confluent.ksql.api.client.ServerInfo)5 IntegrationTest (io.confluent.common.utils.IntegrationTest)2 JsonObject (io.vertx.core.json.JsonObject)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 Test (org.junit.Test)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 HttpResponse (io.confluent.ksql.api.client.Client.HttpResponse)1 KsqlObject (io.confluent.ksql.api.client.KsqlObject)1 MigrationException (io.confluent.ksql.tools.migrations.MigrationException)1 ServerVersionUtil.getServerInfo (io.confluent.ksql.tools.migrations.util.ServerVersionUtil.getServerInfo)1 Map (java.util.Map)1 CompletableFuture (java.util.concurrent.CompletableFuture)1