Skip to content

Commit

Permalink
Expose the existing connection of the AxonServerConnectionManager
Browse files Browse the repository at this point in the history
Expose the connection of the AxonServerConnectionManager through the
ConnectionManager interface

#1964
  • Loading branch information
smcvb committed Feb 24, 2022
1 parent 6713e25 commit 498f660
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2020. Axon Framework
* Copyright (c) 2010-2022. Axon Framework
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -29,14 +29,15 @@
import org.axonframework.lifecycle.Lifecycle;
import org.axonframework.lifecycle.Phase;

import javax.net.ssl.SSLException;
import java.io.File;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;
import java.util.function.UnaryOperator;
import java.util.stream.Collectors;
import javax.net.ssl.SSLException;

import static org.axonframework.common.BuilderUtils.assertNonNull;

Expand All @@ -47,7 +48,7 @@
* @author Marc Gathier
* @since 4.0
*/
public class AxonServerConnectionManager implements Lifecycle {
public class AxonServerConnectionManager implements Lifecycle, ConnectionManager {

private final Map<String, AxonServerConnection> connections = new ConcurrentHashMap<>();
private final AxonServerConnectionFactory connectionFactory;
Expand Down Expand Up @@ -196,6 +197,13 @@ public Channel getChannel(String context) {
return ((ContextConnection) getConnection(context)).getManagedChannel();
}

@Override
public Map<String, Boolean> connections() {
return connections.entrySet()
.stream()
.collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().isConnected()));
}

/**
* Builder class to instantiate an {@link AxonServerConnectionManager}.
* <p>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2010-2022. Axon Framework
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.axonframework.axonserver.connector;

import java.util.Map;

/**
* Interface describing functionality for connection managers. A connection manager typically deals with a collection of
* connections per context the application is wired with.
*
* @author Steven van Beelen
* @author Milan Savic
* @author Sara Pelligrini
* @since 4.6.0
*/
public interface ConnectionManager {

/**
* Return the connections this instances manages. Consists of key-value pairs where the key resembles the context
* name and the value describes whether the connection is active at this moment.
*
* @return Return the connections this instances manages.
*/
Map<String, Boolean> connections();
}

0 comments on commit 498f660

Please sign in to comment.