Я использую микросервис Spring Boot, интегрированный с apache ignite, для хранения ключа и некоторого значения для него в кеше.
В файле конфигурации воспламенения кеша я пытаюсь разделить кеш на 4 серверах с одним и тем же портом, т. Е. Я должен иметь возможность получить кеш, но не могу разделить кеш на 4, но он выбирает только 2 сервера для кластеризации. другие серверы, которые он запускает, кеш запускается как отдельный и не входит в кластер. Пожалуйста, помогите в этом.
Нужно ли вносить какие-либо другие изменения в конфигурацию серверов кластера 4.
Cacheconfig.xml
<property name="discoverySpi">
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<property name="ipFinder">
<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
<property name="addresses">
<list>
<!-- In distributed environment, replace with actual host IP address. -->
<!-- <value>127.0.0.1:47500..47509</value> -->
<value>158.xxx.xx.xxx</value><!--server1 ip-->
<value>158.xxx.xx.xxx</value><!--server2 ip-->
<value>158.xxx.xx.xxx</value><!--server3 ip-->
<value>4444</value><!--my port-->
</list>
</property>
</bean>
</property>
</bean>
</property>
Здесь я заменил IP-адрес по умолчанию на фактический требуемый IP-адрес сервера.
Но я мог видеть, когда я даю такой способ <value>158.xxx.xx.xxx:4444..158.xxx.xx.xxx:4444</value>
он работает для разделения между двумя серверами.
Это не будет работать, если к списку добавлено более двух IP-адресов серверов.
Пожалуйста, помогите в совместном использовании кэша для более чем 3 серверов.
Ниже приведен код, который я использую для запуска зажигания и активации кластера
import java.util.Enumeration;
import java.util.Properties;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteException;
import org.apache.ignite.Ignition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class IgniteCacheManager {
private static final Logger LOGGER = LoggerFactory.getLogger(IgniteCacheManager.class);
private Ignite ignite;
public Ignite getIgnite() {
return ignite;
}
@Autowired
private IgniteCacheManager(AppSpecificIgniteProperties igniteProperties) {
Properties p = System.getProperties();
Enumeration<Object> keys = p.keys();
LOGGER.debug("-----------------------------SYSTEM PROPERTIES Start--------------------------------------");
while (keys.hasMoreElements()) {
String key = (String) keys.nextElement();
String value = (String) p.get(key);
LOGGER.info(key);
LOGGER.info(value);
}
LOGGER.debug("-----------------------------SYSTEM PROPERTIES End--------------------------------------");
try {
// Ignite cache will start
ignite=Ignition.start(igniteProperties.getConfigFile());
//Cluster Activation
ignite.cluster().active(true);
LOGGER.info("IGNITE CACHE STARTED");
} catch (IgniteException e) {
LOGGER.error(e.getMessage(), e);
throw e;
}
}
public IgniteCache<String, Integer> getOrCreateCache(String name){
return ignite.getOrCreateCache(name);
}
}
Здесь igniteProperties.getproperties - это файл cacheconfig.xml, в котором находятся конфигурации истечения срока действия DiscoverySpi и кэша.
Чтобы добавить сервер в кластер, нужно ли мне вносить какие-либо другие изменения.
Пожалуйста, помогите в этом.
Ниже приведена конфигурация моего кеша, используемая при запуске воспламенения
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd">
<bean abstract="true" id="ignite.cfg"
class="org.apache.ignite.configuration.IgniteConfiguration">
<!-- Set to true to enable distributed class loading for examples, default
is false. -->
<!-- <property name="clientMode" value="true"/> -->
<property name="peerClassLoadingEnabled" value="true" />
<property name="cacheConfiguration">
<list>
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<property name="name" value="hcache" />
<property name="expiryPolicyFactory">
<!-- <bean id="expiryPolicy" class="javax.cache.expiry.CreatedExpiryPolicy"
factory-method="factoryOf"> -->
<bean id="expiryPolicy" class="javax.cache.expiry.CreatedExpiryPolicy"
factory-method="factoryOf">
<!-- CreatedExpiryPolicy is used to inform the cache provider to remove
the entry after a specified time since the entry’s addition to the cache. -->
<constructor-arg>
<bean class="javax.cache.expiry.Duration">
<constructor-arg value="HOURS" />
<constructor-arg value="1" />
</bean>
</constructor-arg>
</bean>
</property>
</bean>
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<property name="name" value="dcache" />
<property name="expiryPolicyFactory">
<bean id="expiryPolicy" class="javax.cache.expiry.CreatedExpiryPolicy"
factory-method="factoryOf">
<constructor-arg>
<bean class="javax.cache.expiry.Duration">
<constructor-arg value="HOURS" />
<constructor-arg value="24" />
</bean>
</constructor-arg>
</bean>
</property>
</bean>
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<property name="name" value="wcache" />
<property name="expiryPolicyFactory">
<bean id="expiryPolicy" class="javax.cache.expiry.CreatedExpiryPolicy"
factory-method="factoryOf">
<constructor-arg>
<bean class="javax.cache.expiry.Duration">
<constructor-arg value="DAYS" />
<constructor-arg value="7" />
</bean>
</constructor-arg>
</bean>
</property>
</bean>
</list>
</property>
<!-- Enable task execution events for examples. -->
<property name="includeEventTypes">
<list>
<!--Task execution events -->
<util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_STARTED" />
<util:constant
static-field="org.apache.ignite.events.EventType.EVT_TASK_FINISHED" />
<!-- This event is triggered every time a task finished with an exception -->
<util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FAILED" />
<util:constant
static-field="org.apache.ignite.events.EventType.EVT_TASK_TIMEDOUT" />
<util:constant
static-field="org.apache.ignite.events.EventType.EVT_TASK_SESSION_ATTR_SET" />
<util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_REDUCED" />
<!--Cache events -->
<util:constant
static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT" />
<util:constant
static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_READ" />
<util:constant
static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_REMOVED" />
</list>
</property>
<!-- <property name="eagerTtl" value="true" /> -->
<property name="dataStorageConfiguration">
<bean class="org.apache.ignite.configuration.DataStorageConfiguration">
<property name="defaultDataRegionConfiguration">
<bean class="org.apache.ignite.configuration.DataRegionConfiguration">
<property name="persistenceEnabled" value="true" />
</bean>
</property>
</bean>
</property>
<!-- Explicitly configure TCP discovery SPI to provide list of initial
nodes. -->
<property name="discoverySpi">
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<property name="ipFinder">
<!-- Ignite provides several options for automatic discovery that can
be used instead os static IP based discovery. For information on all options
refer to our documentation: http://apacheignite.readme.io/docs/cluster-config -->
<!-- Uncomment static IP finder to enable static-based discovery of
initial nodes. -->
<!--<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder"> -->
<bean
class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
<property name="addresses">
<list>
<!-- In distributed environment, replace with actual host IP address. -->
<!-- <value>127.0.0.1:47500..47509</value> -->
<value>server1</value>
<value>server2</value>
<value>server3</value>
<value>server4</value>
</list>
</property>
</bean>
</property>
</bean>
</property>
</bean>
</beans>