-
Notifications
You must be signed in to change notification settings - Fork 590
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/release-33.x' into develop
- Loading branch information
Showing
13 changed files
with
385 additions
and
36 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
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
63 changes: 63 additions & 0 deletions
63
...grpc/exporter/src/main/java/org/opennms/features/grpc/exporter/GrpcHeaderInterceptor.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,63 @@ | ||
/* | ||
* Licensed to The OpenNMS Group, Inc (TOG) under one or more | ||
* contributor license agreements. See the LICENSE.md file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. | ||
* | ||
* TOG licenses this file to You under the GNU Affero General | ||
* Public License Version 3 (the "License") or (at your option) | ||
* any later version. You may not use this file except in | ||
* compliance with the License. You may obtain a copy of the | ||
* License at: | ||
* | ||
* https://www.gnu.org/licenses/agpl-3.0.txt | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | ||
* either express or implied. See the License for the specific | ||
* language governing permissions and limitations under the | ||
* License. | ||
*/ | ||
|
||
package org.opennms.features.grpc.exporter; | ||
|
||
import io.grpc.CallOptions; | ||
import io.grpc.Channel; | ||
import io.grpc.ClientCall; | ||
import io.grpc.ClientInterceptor; | ||
import io.grpc.ForwardingClientCall; | ||
import io.grpc.Metadata; | ||
import io.grpc.MethodDescriptor; | ||
|
||
public class GrpcHeaderInterceptor implements ClientInterceptor { | ||
|
||
private final Metadata metadata; | ||
|
||
public GrpcHeaderInterceptor(String tenantId) { | ||
metadata = new Metadata(); | ||
metadata.put(Metadata.Key.of("tenant-id", Metadata.ASCII_STRING_MARSHALLER), tenantId); | ||
} | ||
|
||
@Override | ||
public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall( | ||
MethodDescriptor<ReqT, RespT> method, CallOptions callOptions, Channel next) { | ||
return new HeaderAttachingClientCall<>(next.newCall(method, callOptions), metadata); | ||
} | ||
|
||
private final static class HeaderAttachingClientCall<ReqT, RespT> | ||
extends ForwardingClientCall.SimpleForwardingClientCall<ReqT, RespT> { | ||
|
||
private final Metadata metadata; | ||
HeaderAttachingClientCall(ClientCall<ReqT, RespT> call, Metadata metadataToAttach) { | ||
super(call); | ||
this.metadata = metadataToAttach; | ||
} | ||
|
||
@Override | ||
public void start(Listener<RespT> responseListener, Metadata headers) { | ||
headers.merge(metadata); | ||
super.start(responseListener, headers); | ||
} | ||
} | ||
} |
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
62 changes: 62 additions & 0 deletions
62
features/poller/api/src/main/java/org/opennms/netmgt/poller/EscapeSequenceAdapter.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,62 @@ | ||
/******************************************************************************* | ||
* This file is part of OpenNMS(R). | ||
* | ||
* Copyright (C) 2025 The OpenNMS Group, Inc. | ||
* OpenNMS(R) is Copyright (C) 1999-2025 The OpenNMS Group, Inc. | ||
* | ||
* OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc. | ||
* | ||
* OpenNMS(R) is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, | ||
* or (at your option) any later version. | ||
* | ||
* OpenNMS(R) 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 | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with OpenNMS(R). If not, see: | ||
* http://www.gnu.org/licenses/ | ||
* | ||
* For more information contact: | ||
* OpenNMS(R) Licensing <[email protected]> | ||
* http://www.opennms.org/ | ||
* http://www.opennms.com/ | ||
*******************************************************************************/ | ||
|
||
package org.opennms.netmgt.poller; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import javax.xml.bind.annotation.adapters.XmlAdapter; | ||
|
||
public class EscapeSequenceAdapter extends XmlAdapter<String, String> { | ||
private static final Logger LOG = LoggerFactory.getLogger(EscapeSequenceAdapter.class); | ||
|
||
public EscapeSequenceAdapter() { | ||
|
||
} | ||
|
||
@Override | ||
public String unmarshal(String v) throws Exception { | ||
if (v != null) { | ||
v = v.replace("
", "\r") | ||
.replace("
", "\n"); | ||
} | ||
return v; | ||
|
||
} | ||
|
||
@Override | ||
public String marshal(String v) throws Exception { | ||
if (v != null) { | ||
v = v.replace("\r", "
") | ||
.replace("\n", "
"); | ||
} | ||
return v; | ||
|
||
} | ||
} |
Oops, something went wrong.