Skip to content

Commit

Permalink
Created Super and Sub routing procedures for multi clustering feature
Browse files Browse the repository at this point in the history
- Super procedure simply returns a list of the router capable hosts in a
cluster, split by database name.

- Sub procedure is similar, though takes a database name as a parameter
and only returns those router capable hosts which contain that database.
  • Loading branch information
hugofirth committed Mar 20, 2018
1 parent 2aabc7b commit d09e708
Show file tree
Hide file tree
Showing 63 changed files with 768 additions and 170 deletions.
Expand Up @@ -23,7 +23,7 @@
import java.util.Map; import java.util.Map;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;


import org.neo4j.causalclustering.load_balancing.LoadBalancingPluginLoader; import org.neo4j.causalclustering.routing.load_balancing.LoadBalancingPluginLoader;
import org.neo4j.graphdb.config.InvalidSettingException; import org.neo4j.graphdb.config.InvalidSettingException;
import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.configuration.Config;
import org.neo4j.kernel.configuration.ConfigurationValidator; import org.neo4j.kernel.configuration.ConfigurationValidator;
Expand Down
Expand Up @@ -54,11 +54,11 @@
import org.neo4j.causalclustering.handlers.PipelineWrapper; import org.neo4j.causalclustering.handlers.PipelineWrapper;
import org.neo4j.causalclustering.handlers.VoidPipelineWrapperFactory; import org.neo4j.causalclustering.handlers.VoidPipelineWrapperFactory;
import org.neo4j.causalclustering.identity.MemberId; import org.neo4j.causalclustering.identity.MemberId;
import org.neo4j.causalclustering.load_balancing.LoadBalancingPluginLoader; import org.neo4j.causalclustering.routing.load_balancing.LoadBalancingPluginLoader;
import org.neo4j.causalclustering.load_balancing.LoadBalancingProcessor; import org.neo4j.causalclustering.routing.load_balancing.LoadBalancingProcessor;
import org.neo4j.causalclustering.load_balancing.procedure.GetServersProcedureForMultiDC; import org.neo4j.causalclustering.routing.load_balancing.procedure.GetServersProcedureForMultiDC;
import org.neo4j.causalclustering.load_balancing.procedure.GetServersProcedureForSingleDC; import org.neo4j.causalclustering.routing.load_balancing.procedure.GetServersProcedureForSingleDC;
import org.neo4j.causalclustering.load_balancing.procedure.LegacyGetServersProcedure; import org.neo4j.causalclustering.routing.load_balancing.procedure.LegacyGetServersProcedure;
import org.neo4j.causalclustering.logging.BetterMessageLogger; import org.neo4j.causalclustering.logging.BetterMessageLogger;
import org.neo4j.causalclustering.logging.MessageLogger; import org.neo4j.causalclustering.logging.MessageLogger;
import org.neo4j.causalclustering.logging.NullMessageLogger; import org.neo4j.causalclustering.logging.NullMessageLogger;
Expand All @@ -78,6 +78,8 @@
import org.neo4j.causalclustering.protocol.handshake.ModifierProtocolRepository; import org.neo4j.causalclustering.protocol.handshake.ModifierProtocolRepository;
import org.neo4j.causalclustering.protocol.handshake.ModifierSupportedProtocols; import org.neo4j.causalclustering.protocol.handshake.ModifierSupportedProtocols;
import org.neo4j.causalclustering.protocol.handshake.ProtocolStack; import org.neo4j.causalclustering.protocol.handshake.ProtocolStack;
import org.neo4j.causalclustering.routing.multi_cluster.procedure.GetSubClusterRoutersProcedure;
import org.neo4j.causalclustering.routing.multi_cluster.procedure.GetSuperClusterRoutersProcedure;
import org.neo4j.com.storecopy.StoreUtil; import org.neo4j.com.storecopy.StoreUtil;
import org.neo4j.function.Predicates; import org.neo4j.function.Predicates;
import org.neo4j.graphdb.DependencyResolver; import org.neo4j.graphdb.DependencyResolver;
Expand Down Expand Up @@ -177,6 +179,8 @@ public void registerEditionSpecificProcedures( Procedures procedures ) throws Ke
config, logProvider ) ); config, logProvider ) );
} }


procedures.register( new GetSuperClusterRoutersProcedure( topologyService, config ) );
procedures.register( new GetSubClusterRoutersProcedure( topologyService, config ) );
procedures.register( new ClusterOverviewProcedure( topologyService, logProvider ) ); procedures.register( new ClusterOverviewProcedure( topologyService, logProvider ) );
procedures.register( new CoreRoleProcedure( consensusModule.raftMachine() ) ); procedures.register( new CoreRoleProcedure( consensusModule.raftMachine() ) );
procedures.register( new InstalledProtocolsProcedure( clientInstalledProtocols, serverInstalledProtocols ) ); procedures.register( new InstalledProtocolsProcedure( clientInstalledProtocols, serverInstalledProtocols ) );
Expand Down
Expand Up @@ -30,10 +30,10 @@
import org.neo4j.causalclustering.discovery.DiscoveryServerInfo; import org.neo4j.causalclustering.discovery.DiscoveryServerInfo;
import org.neo4j.causalclustering.discovery.Topology; import org.neo4j.causalclustering.discovery.Topology;
import org.neo4j.causalclustering.identity.MemberId; import org.neo4j.causalclustering.identity.MemberId;
import org.neo4j.causalclustering.load_balancing.filters.Filter; import org.neo4j.causalclustering.routing.load_balancing.filters.Filter;
import org.neo4j.causalclustering.load_balancing.plugins.server_policies.FilterConfigParser; import org.neo4j.causalclustering.routing.load_balancing.plugins.server_policies.FilterConfigParser;
import org.neo4j.causalclustering.load_balancing.plugins.server_policies.InvalidFilterSpecification; import org.neo4j.causalclustering.routing.load_balancing.plugins.server_policies.InvalidFilterSpecification;
import org.neo4j.causalclustering.load_balancing.plugins.server_policies.ServerInfo; import org.neo4j.causalclustering.routing.load_balancing.plugins.server_policies.ServerInfo;
import org.neo4j.helpers.Service; import org.neo4j.helpers.Service;


@Service.Implementation( UpstreamDatabaseSelectionStrategy.class ) @Service.Implementation( UpstreamDatabaseSelectionStrategy.class )
Expand Down
Expand Up @@ -17,9 +17,10 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.neo4j.causalclustering.load_balancing; package org.neo4j.causalclustering.routing;


import java.util.Objects; import java.util.Objects;
import java.util.Optional;


import org.neo4j.helpers.AdvertisedSocketAddress; import org.neo4j.helpers.AdvertisedSocketAddress;


Expand All @@ -38,6 +39,12 @@ public Endpoint( AdvertisedSocketAddress address, Role role )
this.role = role; this.role = role;
} }


public Endpoint( AdvertisedSocketAddress address, Role role, String dbName )
{
this.address = address;
this.role = role;
}

public AdvertisedSocketAddress address() public AdvertisedSocketAddress address()
{ {
return address; return address;
Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.neo4j.causalclustering.load_balancing; package org.neo4j.causalclustering.routing;


/** /**
* Defines a capability of an endpoint. * Defines a capability of an endpoint.
Expand Down
@@ -0,0 +1,29 @@
/*
* Copyright (c) 2002-2018 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Neo4j 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.
*
* 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
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.causalclustering.routing;


public interface RoutingResult
{
/**
* @return The time-to-live of the returned result.
*/
long ttlMillis();
}
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.neo4j.causalclustering.load_balancing; package org.neo4j.causalclustering.routing;


import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.neo4j.causalclustering.load_balancing; package org.neo4j.causalclustering.routing.load_balancing;


import org.neo4j.causalclustering.core.consensus.LeaderLocator; import org.neo4j.causalclustering.core.consensus.LeaderLocator;
import org.neo4j.causalclustering.discovery.TopologyService; import org.neo4j.causalclustering.discovery.TopologyService;
Expand Down
Expand Up @@ -17,15 +17,15 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.neo4j.causalclustering.load_balancing; package org.neo4j.causalclustering.routing.load_balancing;


import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;


import org.neo4j.causalclustering.core.CausalClusteringSettings; import org.neo4j.causalclustering.core.CausalClusteringSettings;
import org.neo4j.causalclustering.core.consensus.LeaderLocator; import org.neo4j.causalclustering.core.consensus.LeaderLocator;
import org.neo4j.causalclustering.discovery.TopologyService; import org.neo4j.causalclustering.discovery.TopologyService;
import org.neo4j.causalclustering.load_balancing.plugins.ServerShufflingProcessor; import org.neo4j.causalclustering.routing.load_balancing.plugins.ServerShufflingProcessor;
import org.neo4j.graphdb.config.InvalidSettingException; import org.neo4j.graphdb.config.InvalidSettingException;
import org.neo4j.helpers.Service; import org.neo4j.helpers.Service;
import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.configuration.Config;
Expand Down
Expand Up @@ -17,11 +17,13 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.neo4j.causalclustering.load_balancing; package org.neo4j.causalclustering.routing.load_balancing;


import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;


import org.neo4j.causalclustering.routing.Endpoint;
import org.neo4j.causalclustering.routing.RoutingResult;
import org.neo4j.internal.kernel.api.exceptions.ProcedureException; import org.neo4j.internal.kernel.api.exceptions.ProcedureException;


public interface LoadBalancingProcessor public interface LoadBalancingProcessor
Expand All @@ -35,13 +37,8 @@ public interface LoadBalancingProcessor
*/ */
Result run( Map<String,String> context ) throws ProcedureException; Result run( Map<String,String> context ) throws ProcedureException;


interface Result interface Result extends RoutingResult
{ {
/**
* @return The time-to-live of the returned result.
*/
long getTimeToLiveMillis();

/** /**
* @return List of ROUTE-capable endpoints. * @return List of ROUTE-capable endpoints.
*/ */
Expand Down
Expand Up @@ -17,11 +17,13 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.neo4j.causalclustering.load_balancing; package org.neo4j.causalclustering.routing.load_balancing;


import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;


import org.neo4j.causalclustering.routing.Endpoint;

/** /**
* The outcome of applying a load balancing plugin, which will be used by client * The outcome of applying a load balancing plugin, which will be used by client
* software for scheduling work at the endpoints. * software for scheduling work at the endpoints.
Expand All @@ -43,7 +45,7 @@ public LoadBalancingResult( List<Endpoint> routeEndpoints, List<Endpoint> writeE
} }


@Override @Override
public long getTimeToLiveMillis() public long ttlMillis()
{ {
return timeToLiveMillis; return timeToLiveMillis;
} }
Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.neo4j.causalclustering.load_balancing.filters; package org.neo4j.causalclustering.routing.load_balancing.filters;


import java.util.Set; import java.util.Set;


Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.neo4j.causalclustering.load_balancing.filters; package org.neo4j.causalclustering.routing.load_balancing.filters;


import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.neo4j.causalclustering.load_balancing.filters; package org.neo4j.causalclustering.routing.load_balancing.filters;


import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.neo4j.causalclustering.load_balancing.filters; package org.neo4j.causalclustering.routing.load_balancing.filters;


import java.util.Set; import java.util.Set;


Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.neo4j.causalclustering.load_balancing.filters; package org.neo4j.causalclustering.routing.load_balancing.filters;


import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
Expand Down
Expand Up @@ -17,12 +17,12 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.neo4j.causalclustering.load_balancing.plugins; package org.neo4j.causalclustering.routing.load_balancing.plugins;


import java.util.Collections; import java.util.Collections;
import java.util.Map; import java.util.Map;


import org.neo4j.causalclustering.load_balancing.LoadBalancingProcessor; import org.neo4j.causalclustering.routing.load_balancing.LoadBalancingProcessor;
import org.neo4j.internal.kernel.api.exceptions.ProcedureException; import org.neo4j.internal.kernel.api.exceptions.ProcedureException;


/** /**
Expand Down
Expand Up @@ -17,14 +17,14 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.neo4j.causalclustering.load_balancing.plugins.server_policies; package org.neo4j.causalclustering.routing.load_balancing.plugins.server_policies;


import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.stream.Collectors; import java.util.stream.Collectors;


import org.neo4j.causalclustering.load_balancing.filters.Filter; import org.neo4j.causalclustering.routing.load_balancing.filters.Filter;


import static org.neo4j.helpers.collection.Iterators.asSet; import static org.neo4j.helpers.collection.Iterators.asSet;


Expand Down
Expand Up @@ -17,18 +17,18 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.neo4j.causalclustering.load_balancing.plugins.server_policies; package org.neo4j.causalclustering.routing.load_balancing.plugins.server_policies;


import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;


import org.neo4j.causalclustering.load_balancing.filters.Filter; import org.neo4j.causalclustering.routing.load_balancing.filters.Filter;
import org.neo4j.causalclustering.load_balancing.filters.FilterChain; import org.neo4j.causalclustering.routing.load_balancing.filters.FilterChain;
import org.neo4j.causalclustering.load_balancing.filters.FirstValidRule; import org.neo4j.causalclustering.routing.load_balancing.filters.FirstValidRule;
import org.neo4j.causalclustering.load_balancing.filters.IdentityFilter; import org.neo4j.causalclustering.routing.load_balancing.filters.IdentityFilter;
import org.neo4j.causalclustering.load_balancing.filters.MinimumCountFilter; import org.neo4j.causalclustering.routing.load_balancing.filters.MinimumCountFilter;


import static java.lang.String.format; import static java.lang.String.format;
import static java.util.Collections.singletonList; import static java.util.Collections.singletonList;
Expand Down
Expand Up @@ -17,12 +17,12 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.neo4j.causalclustering.load_balancing.plugins.server_policies; package org.neo4j.causalclustering.routing.load_balancing.plugins.server_policies;


import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;


import org.neo4j.causalclustering.load_balancing.filters.Filter; import org.neo4j.causalclustering.routing.load_balancing.filters.Filter;


public class FilteringPolicy implements Policy public class FilteringPolicy implements Policy
{ {
Expand Down
Expand Up @@ -17,13 +17,13 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.neo4j.causalclustering.load_balancing.plugins.server_policies; package org.neo4j.causalclustering.routing.load_balancing.plugins.server_policies;


import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;


import org.neo4j.causalclustering.load_balancing.filters.Filter; import org.neo4j.causalclustering.routing.load_balancing.filters.Filter;
import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.configuration.Config;
import org.neo4j.logging.Log; import org.neo4j.logging.Log;


Expand Down
Expand Up @@ -17,11 +17,11 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.neo4j.causalclustering.load_balancing.plugins.server_policies; package org.neo4j.causalclustering.routing.load_balancing.plugins.server_policies;


import java.util.Set; import java.util.Set;


import org.neo4j.causalclustering.load_balancing.filters.Filter; import org.neo4j.causalclustering.routing.load_balancing.filters.Filter;


/** /**
* This filter is not meant for actual use. No more filters nor * This filter is not meant for actual use. No more filters nor
Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.neo4j.causalclustering.load_balancing.plugins.server_policies; package org.neo4j.causalclustering.routing.load_balancing.plugins.server_policies;


public class InvalidFilterSpecification extends Exception public class InvalidFilterSpecification extends Exception
{ {
Expand Down
Expand Up @@ -17,12 +17,12 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.neo4j.causalclustering.load_balancing.plugins.server_policies; package org.neo4j.causalclustering.routing.load_balancing.plugins.server_policies;


import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;


import org.neo4j.causalclustering.load_balancing.filters.IdentityFilter; import org.neo4j.causalclustering.routing.load_balancing.filters.IdentityFilter;
import org.neo4j.internal.kernel.api.exceptions.ProcedureException; import org.neo4j.internal.kernel.api.exceptions.ProcedureException;
import org.neo4j.kernel.api.exceptions.Status; import org.neo4j.kernel.api.exceptions.Status;
import org.neo4j.logging.Log; import org.neo4j.logging.Log;
Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.neo4j.causalclustering.load_balancing.plugins.server_policies; package org.neo4j.causalclustering.routing.load_balancing.plugins.server_policies;


import java.util.Set; import java.util.Set;


Expand Down

0 comments on commit d09e708

Please sign in to comment.