-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'add-stream-category-filter' into add-stream-categories-…
…to-dashboard-widgets
- Loading branch information
Showing
40 changed files
with
598 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
type="c" | ||
message="Changed default setting for Kafka transports to non-legacy mode." | ||
|
||
issues=["19693"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
type = "f" | ||
message = "Add support for remote-reindex migration of closed indices" | ||
|
||
pulls = ["20081"] | ||
issues = ["20068"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
type = "a" | ||
message = "Added categories to Streams to allow Illuminate content to be scoped to multiple products." | ||
|
||
issues = ["graylog-plugin-enterprise#7945"] | ||
pulls = ["20110"] |
121 changes: 121 additions & 0 deletions
121
data-node/src/main/java/org/graylog/datanode/rest/IndexStateController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
/* | ||
* Copyright (C) 2020 Graylog, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the Server Side Public License, version 1, | ||
* as published by MongoDB, Inc. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* Server Side Public License for more details. | ||
* | ||
* You should have received a copy of the Server Side Public License | ||
* along with this program. If not, see | ||
* <http://www.mongodb.com/licensing/server-side-public-license>. | ||
*/ | ||
package org.graylog.datanode.rest; | ||
|
||
import jakarta.inject.Inject; | ||
import jakarta.ws.rs.POST; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.core.MediaType; | ||
import okhttp3.Credentials; | ||
import okhttp3.OkHttpClient; | ||
import okhttp3.Request; | ||
import okhttp3.RequestBody; | ||
import org.graylog.datanode.configuration.DatanodeTrustManagerProvider; | ||
import org.graylog.storage.opensearch2.IndexState; | ||
import org.graylog.storage.opensearch2.IndexStateChangeRequest; | ||
|
||
import javax.net.ssl.SSLContext; | ||
import javax.net.ssl.TrustManager; | ||
import javax.net.ssl.X509TrustManager; | ||
import java.io.IOException; | ||
import java.security.KeyManagementException; | ||
import java.security.NoSuchAlgorithmException; | ||
import java.security.SecureRandom; | ||
import java.util.Locale; | ||
import java.util.Objects; | ||
|
||
import static org.graylog.datanode.rest.OpensearchConnectionCheckController.CONNECT_TIMEOUT; | ||
import static org.graylog.datanode.rest.OpensearchConnectionCheckController.READ_TIMEOUT; | ||
import static org.graylog.datanode.rest.OpensearchConnectionCheckController.WRITE_TIMEOUT; | ||
|
||
@Path("/index-state") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public class IndexStateController { | ||
|
||
private final DatanodeTrustManagerProvider datanodeTrustManagerProvider; | ||
private final OkHttpClient httpClient; | ||
|
||
@Inject | ||
public IndexStateController(DatanodeTrustManagerProvider datanodeTrustManagerProvider) { | ||
this.datanodeTrustManagerProvider = datanodeTrustManagerProvider; | ||
this.httpClient = new OkHttpClient.Builder() | ||
.retryOnConnectionFailure(true) | ||
.connectTimeout(CONNECT_TIMEOUT) | ||
.writeTimeout(WRITE_TIMEOUT) | ||
.readTimeout(READ_TIMEOUT) | ||
.build(); | ||
} | ||
|
||
@POST | ||
@Path("/get") | ||
public IndexState get(IndexStateChangeRequest indexStateChangeRequest) { | ||
final String host = indexStateChangeRequest.host().endsWith("/") ? indexStateChangeRequest.host() : indexStateChangeRequest.host() + "/"; | ||
final Request.Builder request = new Request.Builder() | ||
.url(host + "_cat/indices/" + indexStateChangeRequest.indexName() + "/?h=status"); | ||
if (Objects.nonNull(indexStateChangeRequest.username()) && Objects.nonNull(indexStateChangeRequest.password())) { | ||
request.header("Authorization", Credentials.basic(indexStateChangeRequest.username(), indexStateChangeRequest.password())); | ||
} | ||
try (var response = getClient().newCall(request.build()).execute()) { | ||
if (response.isSuccessful() && response.body() != null) { | ||
final String state = response.body().string().trim().toUpperCase(Locale.ROOT); | ||
return IndexState.valueOf(state); | ||
} else { | ||
throw new RuntimeException("Failed to detect open/close index status " + indexStateChangeRequest.indexName() + ". Code: " + response.code() + "; message=" + response.message()); | ||
} | ||
} catch (IOException e) { | ||
throw new RuntimeException("Failed to open/close index" + indexStateChangeRequest.indexName(), e); | ||
} | ||
} | ||
|
||
@POST | ||
@Path("/set") | ||
public IndexState change(IndexStateChangeRequest indexStateChangeRequest) { | ||
return performAction(indexStateChangeRequest); | ||
} | ||
|
||
private IndexState performAction(IndexStateChangeRequest indexStateChangeRequest) { | ||
final String host = indexStateChangeRequest.host().endsWith("/") ? indexStateChangeRequest.host() : indexStateChangeRequest.host() + "/"; | ||
final Request.Builder request = new Request.Builder() | ||
.post(RequestBody.create("", okhttp3.MediaType.parse(MediaType.APPLICATION_JSON))) | ||
.url(host + indexStateChangeRequest.indexName() + "/" + (indexStateChangeRequest.action() == IndexState.OPEN ? "_open" : "_close")); | ||
if (Objects.nonNull(indexStateChangeRequest.username()) && Objects.nonNull(indexStateChangeRequest.password())) { | ||
request.header("Authorization", Credentials.basic(indexStateChangeRequest.username(), indexStateChangeRequest.password())); | ||
} | ||
try (var response = getClient().newCall(request.build()).execute()) { | ||
if (response.isSuccessful()) { | ||
return indexStateChangeRequest.action(); | ||
} else { | ||
throw new RuntimeException("Failed to open/close index " + indexStateChangeRequest.indexName() + ". Code: " + response.code() + "; message=" + response.message()); | ||
} | ||
} catch (IOException e) { | ||
throw new RuntimeException("Failed to open/close index" + indexStateChangeRequest.indexName(), e); | ||
} | ||
} | ||
|
||
private OkHttpClient getClient() { | ||
try { | ||
final SSLContext ctx = SSLContext.getInstance("TLS"); | ||
final X509TrustManager trustManager = datanodeTrustManagerProvider.get(); | ||
ctx.init(null, new TrustManager[]{trustManager}, new SecureRandom()); | ||
return httpClient.newBuilder().sslSocketFactory(ctx.getSocketFactory(), trustManager).build(); | ||
} catch (NoSuchAlgorithmException | KeyManagementException e) { | ||
throw new RuntimeException(e); | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...orage-opensearch2/src/main/java/org/graylog/storage/opensearch2/ConnectionCheckIndex.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright (C) 2020 Graylog, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the Server Side Public License, version 1, | ||
* as published by MongoDB, Inc. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* Server Side Public License for more details. | ||
* | ||
* You should have received a copy of the Server Side Public License | ||
* along with this program. If not, see | ||
* <http://www.mongodb.com/licensing/server-side-public-license>. | ||
*/ | ||
package org.graylog.storage.opensearch2; | ||
|
||
public record ConnectionCheckIndex(String name, boolean closed) { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.