io.hekate.core.HekateBootstrap Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hekate-all Show documentation
Show all versions of hekate-all Show documentation
Java library for cluster communications and computing.
/*
* Copyright 2020 The Hekate Project
*
* The Hekate Project licenses this file to you 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 io.hekate.core;
import io.hekate.cluster.ClusterNode;
import io.hekate.cluster.ClusterNodeFilter;
import io.hekate.cluster.ClusterTopology;
import io.hekate.cluster.ClusterView;
import io.hekate.codec.AutoSelectCodecFactory;
import io.hekate.codec.Codec;
import io.hekate.codec.CodecFactory;
import io.hekate.codec.CodecService;
import io.hekate.core.internal.HekateNodeFactory;
import io.hekate.core.internal.util.ConfigCheck;
import io.hekate.core.plugin.Plugin;
import io.hekate.core.service.Service;
import io.hekate.core.service.ServiceFactory;
import io.hekate.util.format.ToString;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Consumer;
import static io.hekate.core.internal.util.StreamUtils.nullSafe;
/**
* Main configuration and factory for {@link Hekate} instances.
*
*
* This class provides bean-style properties with getters/setters (to be used in the Spring Framework XML files) as well as fluent-style API for programmatic configuration from within the Java code.
*
*
*
* Configuration options are:
*
*
* - {@link #setClusterName(String) Cluster name}
* - {@link #setNodeName(String) Node name}
* - {@link #setProperties(Map) Node properties}
* - {@link #setRoles(List) Node roles}
* - {@link #setDefaultCodec(CodecFactory) Data serialization codec}
* - {@link #setServices(List) Services} to be provided by the node
* - {@link #setPlugins(List) Plugins} that should run within the node
*
*
*
* Once configured, the {@link #join()} method must be called in order to construct a new {@link Hekate} instance and join the cluster.
*
*
*
* For more details about the lifecycle and available services please see the documentation of {@link Hekate} interface.
*
*/
public class HekateBootstrap {
/** Default value (={@value}) for {@link #setClusterName(String)}. */
public static final String DEFAULT_CLUSTER_NAME = "default";
/** See {@link #setNodeName(String)}. */
private String nodeName;
/** See {@link #setClusterName(String)}. */
private String clusterName = DEFAULT_CLUSTER_NAME;
/** See {@link #setRoles(List)}. */
private List roles;
/** See {@link #setProperties(Map)}. */
private Map properties;
/** See {@link #setPropertyProviders(List)}. */
private List propertyProviders;
/** See {@link #setServices(List)}. */
private List> services;
/** See {@link #setDefaultCodec(CodecFactory)}. */
private CodecFactory