-
Notifications
You must be signed in to change notification settings - Fork 0
Configuration
Hazelcast Locks Server je konfigurován výhradně pomocí proměnných prostředí.
Veškerá konfigurace je načítána ve třídě
org.ceskaexpedice.hazelcast.HazelcastServerNodeStarter.
Pokud není konkrétní proměnná nastavena, použije se její výchozí hodnota.
| Proměnná prostředí | Popis | Výchozí hodnota |
|---|---|---|
| HAZELCAST_CONFIG_FILE | Cesta ke konfiguračnímu XML souboru Hazelcastu | interní default-config.xml |
| HAZELCAST_INSTANCE | Název Hazelcast instance (cluster name) | akubrasync |
| HAZELCAST_USER | Logický identifikátor uživatele / prostředí | dev |
Určuje cestu ke konfiguračnímu souboru Hazelcastu ve formátu XML.
Pokud není proměnná nastavena, server:
- načte interní resource
default-config.xml - uloží ji do dočasného souboru
- použije tuto konfiguraci při startu
Tento mechanismus umožňuje:
- jednoduché lokální spuštění bez konfigurace
- přepsání konfigurace v Dockeru pomocí volume mountu
export HAZELCAST_CONFIG_FILE=/config/hazelcast.xml
Určuje název Hazelcast instance (cluster name).
Tato hodnota musí odpovídat konfiguraci klientů (např. Akubra), jinak se klient ke clusteru nepřipojí.
Výchozí hodnota akubrasync reflektuje primární použití v Akubře.
Doporučení
- lokální vývoj: akubrasync
- produkce: explicitně nastavit (např. kramerius-sync)
Logický identifikátor prostředí nebo uživatele.
Slouží k:
- oddělení prostředí (dev / test / prod)
- jednodušší identifikaci instance v logách a konfiguraci
Nemá bezpečnostní význam (nejde o autentizační mechanismus).
Při startu server:
- načte proměnné prostředí
- aplikuje výchozí hodnoty, pokud nejsou definovány
- vytvoří objekt HazelcastConfiguration
- zajistí existenci Hazelcast server node
Server běží až do obdržení signálu k ukončení procesu (SIGTERM, CTRL+C), na který reaguje korektním shutdownem Hazelcast instance.
Klientské aplikace (např. Akubra):
- načtou tyto proměnné
- musí mít kompatibilní Hazelcast konfiguraci zejména shodný název instance (HAZELCAST_INSTANCE)
Hazelcast Locks Server je z pohledu klientů externí infrastrukturní služba.
In order to use this module in your application you need to obtain a singleton object implementing AkubraRepository interface and provide all necessary configuration parameters. This object will then be shared accross your code and used for ingestion and querying data. Here is an example from Kramerius:
public class AkubraRepositoryProvider implements Provider<AkubraRepository> {
private static final java.util.logging.Logger LOGGER = java.util.logging.Logger.getLogger(AkubraRepositoryProvider.class.getName());
@Override
public AkubraRepository get() {
String objectPath = KConfiguration.getInstance().getProperty("objectStore.path");
String objectPattern = KConfiguration.getInstance().getProperty("objectStore.pattern");
String datastreamStorePath = KConfiguration.getInstance().getProperty("datastreamStore.path");
String datastreamStorePattern = KConfiguration.getInstance().getProperty("datastreamStore.pattern");
String solrProcessingHost = KConfiguration.getInstance().getSolrProcessingHost();
File hazelcastConfigFile = KConfiguration.getInstance().findConfigFile("hazelcast.clientconfig");
String hazelcastConfigFileS = (hazelcastConfigFile != null && hazelcastConfigFile.exists()) ? hazelcastConfigFile.getAbsolutePath() : null;
String hazelcastInstance = KConfiguration.getInstance().getConfiguration().getString("hazelcast.instance");
String hazelcastUser = KConfiguration.getInstance().getConfiguration().getString("hazelcast.user");
String waitTimeS = KConfiguration.getInstance().getConfiguration().getString("hazelcast.waitTime");
Long waitTime = waitTimeS != null ? Long.parseLong(waitTimeS) : null;
String leaseTimeS = KConfiguration.getInstance().getConfiguration().getString("hazelcast.leaseTime");
Long leaseTime = leaseTimeS != null ? Long.parseLong(leaseTimeS) : null;
// HAZELCAST SERVER ADDRESS
String env = System.getenv("HAZELCAST_SERVER_ADDRESSES");
List<String> envAddresses = env != null && !env.isEmpty()
? Arrays.asList(env.split(","))
: new ArrayList<>();
List<String> address = Lists.transform(KConfiguration.getInstance().getConfiguration().getList("hazelcast.server.addresses", new ArrayList<>()), Functions.toStringFunction());
HazelcastConfiguration hazelcastConfig = new HazelcastConfiguration.Builder()
.hazelcastClientConfigFile(hazelcastConfigFileS)
.hazelcastInstance(hazelcastInstance)
.setHazelcastServers( env != null && !env.isEmpty() ? envAddresses.toArray(new String[0]) : address.toArray(new String[0]))
.hazelcastUser(hazelcastUser)
.waitTimeSecs(waitTime) // default 120 sec
.leaseTimeSecs(leaseTime) // default 120 sec
.build();
RepositoryConfiguration config = new RepositoryConfiguration.Builder()
.processingIndexHost(solrProcessingHost)
.objectStorePath(objectPath)
.objectStorePattern(objectPattern)
.datastreamStorePath(datastreamStorePath)
.datastreamStorePattern(datastreamStorePattern)
.hazelcastConfiguration(hazelcastConfig)
.build();
AkubraRepository akubraRepository = AkubraRepositoryFactory.createRepository(config);
return akubraRepository;
}
}