Search in sources :

Example 16 with Start

use of org.infinispan.factories.annotations.Start in project infinispan by infinispan.

the class GlobalConfigurationManagerImpl method start.

@Start
void start() {
    switch(configurationManager.getGlobalConfiguration().globalState().configurationStorage()) {
        case IMMUTABLE:
            this.localConfigurationManager = new ImmutableLocalConfigurationStorage();
            break;
        case VOLATILE:
            this.localConfigurationManager = new VolatileLocalConfigurationStorage();
            break;
        case OVERLAY:
            this.localConfigurationManager = new OverlayLocalConfigurationStorage();
            break;
        default:
            this.localConfigurationManager = configurationManager.getGlobalConfiguration().globalState().configurationStorageClass().get();
            break;
    }
    internalCacheRegistry.registerInternalCache(CONFIG_STATE_CACHE_NAME, new ConfigurationBuilder().build(), EnumSet.of(InternalCacheRegistry.Flag.GLOBAL));
    parserRegistry = new ParserRegistry();
    // Start the static caches first
    Set<String> staticCacheNames = new HashSet<>(configurationManager.getDefinedCaches());
    log.debugf("Starting statically defined caches: %s", staticCacheNames);
    for (String cacheName : configurationManager.getDefinedCaches()) {
        SecurityActions.getCache(cacheManager, cacheName);
    }
    localConfigurationManager.initialize(cacheManager, configurationManager, blockingManager);
    // Install the global state listener
    GlobalConfigurationStateListener stateCacheListener = new GlobalConfigurationStateListener(this);
    getStateCache().addListener(stateCacheListener);
    Map<String, Configuration> persistedCaches = localConfigurationManager.loadAllCaches();
    Map<String, Configuration> persistedTemplates = localConfigurationManager.loadAllTemplates();
    getStateCache().forEach((key, v) -> {
        String scope = key.getScope();
        if (isKnownScope(scope)) {
            String name = key.getName();
            CacheState state = (CacheState) v;
            boolean cacheScope = CACHE_SCOPE.equals(scope);
            Map<String, Configuration> map = cacheScope ? persistedCaches : persistedTemplates;
            ensureClusterCompatibility(name, state, map);
            CompletionStage<Void> future = cacheScope ? createCacheLocally(name, state) : createTemplateLocally(name, state);
            CompletionStages.join(future);
        }
    });
    EnumSet<CacheContainerAdmin.AdminFlag> adminFlags = EnumSet.noneOf(CacheContainerAdmin.AdminFlag.class);
    persistedCaches.forEach((name, configuration) -> {
        ensurePersistenceCompatibility(name, configuration);
        // First create the cache locally to ensure that it's available on startup
        createCacheLocally(name, null, configuration, adminFlags);
        // The cache configuration was permanent, it still needs to be
        CompletionStages.join(getOrCreateCache(name, configuration, adminFlags));
    });
    persistedTemplates.forEach((name, configuration) -> {
        ensurePersistenceCompatibility(name, configuration);
        // First create the cache locally to ensure that it's available on startup
        createTemplateLocally(name, configuration, adminFlags);
        // The template was permanent, it still needs to be
        CompletionStages.join(getOrCreateTemplate(name, configuration, adminFlags));
    });
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) Configuration(org.infinispan.configuration.cache.Configuration) ParserRegistry(org.infinispan.configuration.parsing.ParserRegistry) CacheContainerAdmin(org.infinispan.commons.api.CacheContainerAdmin) HashSet(java.util.HashSet) Start(org.infinispan.factories.annotations.Start)

Example 17 with Start

use of org.infinispan.factories.annotations.Start in project infinispan by infinispan.

the class BackupSenderImpl method start.

@Start
public void start() {
    Transport transport = rpcManager.getTransport();
    transport.checkCrossSiteAvailable();
    this.cacheName = cache.wired().getName();
    this.localSiteName = transport.localSiteName();
    config.sites().syncBackupsStream().filter(bc -> bc.backupFailurePolicy() == BackupFailurePolicy.CUSTOM).forEach(bc -> {
        String backupPolicy = bc.failurePolicyClass();
        if (backupPolicy == null) {
            throw new IllegalStateException("Backup policy class missing for custom failure policy!");
        }
        CustomFailurePolicy<Object, Object> instance = Util.getInstance(backupPolicy, globalConfig.classLoader());
        instance.init(cache.wired());
        siteFailurePolicy.put(bc.site(), instance);
    });
}
Also used : WriteCommand(org.infinispan.commands.write.WriteCommand) XSiteResponse(org.infinispan.remoting.transport.XSiteResponse) Arrays(java.util.Arrays) ListIterator(java.util.ListIterator) LogFactory(org.infinispan.util.logging.LogFactory) ReplaceCommand(org.infinispan.commands.write.ReplaceCommand) SimpleAsyncInvocationStage(org.infinispan.interceptors.impl.SimpleAsyncInvocationStage) GlobalConfiguration(org.infinispan.configuration.global.GlobalConfiguration) Cache(org.infinispan.Cache) SiteState(org.infinispan.xsite.status.SiteState) CustomFailurePolicy(org.infinispan.configuration.cache.CustomFailurePolicy) Scopes(org.infinispan.factories.scopes.Scopes) InvocationContext(org.infinispan.context.InvocationContext) ComponentRef(org.infinispan.factories.impl.ComponentRef) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TxInvocationContext(org.infinispan.context.impl.TxInvocationContext) Map(java.util.Map) Scope(org.infinispan.factories.scopes.Scope) Transaction(javax.transaction.Transaction) PrepareCommand(org.infinispan.commands.tx.PrepareCommand) RemoveCommand(org.infinispan.commands.write.RemoveCommand) CommandsFactory(org.infinispan.commands.CommandsFactory) Collection(java.util.Collection) ReadWriteManyEntriesCommand(org.infinispan.commands.functional.ReadWriteManyEntriesCommand) ReadWriteKeyValueCommand(org.infinispan.commands.functional.ReadWriteKeyValueCommand) Set(java.util.Set) AbstractCacheTransaction(org.infinispan.transaction.impl.AbstractCacheTransaction) List(java.util.List) LocalTransaction(org.infinispan.transaction.impl.LocalTransaction) PutKeyValueCommand(org.infinispan.commands.write.PutKeyValueCommand) GuardedBy(net.jcip.annotations.GuardedBy) InvocationStage(org.infinispan.interceptors.InvocationStage) AbstractVisitor(org.infinispan.commands.AbstractVisitor) ComputeCommand(org.infinispan.commands.write.ComputeCommand) BackupConfiguration(org.infinispan.configuration.cache.BackupConfiguration) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) ArrayList(java.util.ArrayList) WriteOnlyManyEntriesCommand(org.infinispan.commands.functional.WriteOnlyManyEntriesCommand) Start(org.infinispan.factories.annotations.Start) HashSet(java.util.HashSet) FlagBitSets(org.infinispan.context.impl.FlagBitSets) BackupFailurePolicy(org.infinispan.configuration.cache.BackupFailurePolicy) KeyPartitioner(org.infinispan.distribution.ch.KeyPartitioner) IracPutKeyValueCommand(org.infinispan.commands.write.IracPutKeyValueCommand) Log(org.infinispan.util.logging.Log) TakeOfflineManager(org.infinispan.xsite.status.TakeOfflineManager) SyncInvocationStage(org.infinispan.interceptors.SyncInvocationStage) ClearCommand(org.infinispan.commands.write.ClearCommand) Transport(org.infinispan.remoting.transport.Transport) Iterator(java.util.Iterator) CacheEntry(org.infinispan.container.entries.CacheEntry) EventLogManager(org.infinispan.util.logging.events.EventLogManager) WriteOnlyKeyValueCommand(org.infinispan.commands.functional.WriteOnlyKeyValueCommand) RollbackCommand(org.infinispan.commands.tx.RollbackCommand) WriteOnlyManyCommand(org.infinispan.commands.functional.WriteOnlyManyCommand) Util(org.infinispan.commons.util.Util) RpcManager(org.infinispan.remoting.rpc.RpcManager) PutMapCommand(org.infinispan.commands.write.PutMapCommand) CommitCommand(org.infinispan.commands.tx.CommitCommand) Inject(org.infinispan.factories.annotations.Inject) ReadWriteKeyCommand(org.infinispan.commands.functional.ReadWriteKeyCommand) ComputeIfAbsentCommand(org.infinispan.commands.write.ComputeIfAbsentCommand) Configuration(org.infinispan.configuration.cache.Configuration) WriteOnlyKeyCommand(org.infinispan.commands.functional.WriteOnlyKeyCommand) VisitableCommand(org.infinispan.commands.VisitableCommand) ReadWriteManyCommand(org.infinispan.commands.functional.ReadWriteManyCommand) Collections(java.util.Collections) TransactionTable(org.infinispan.transaction.impl.TransactionTable) TimeService(org.infinispan.commons.time.TimeService) Transport(org.infinispan.remoting.transport.Transport) Start(org.infinispan.factories.annotations.Start)

Example 18 with Start

use of org.infinispan.factories.annotations.Start in project infinispan by infinispan.

the class ClusteredCacheBackupReceiver method start.

@Start
public void start() {
    // it would be nice if we could inject bootstrap component
    // this feels kind hacky but saves 3 fields in this class
    ComponentRegistry cr = cache.getAdvancedCache().getComponentRegistry();
    TransactionHandler txHandler = new TransactionHandler(cache, cr.getTransactionTable());
    defaultHandler = new DefaultHandler(txHandler, cr.getComponent(BlockingManager.class));
}
Also used : ComponentRegistry(org.infinispan.factories.ComponentRegistry) Start(org.infinispan.factories.annotations.Start)

Example 19 with Start

use of org.infinispan.factories.annotations.Start in project infinispan by infinispan.

the class DefaultIracManager method start.

@Start
public void start() {
    Transport transport = rpcManager.getTransport();
    transport.checkCrossSiteAvailable();
    String localSiteName = transport.localSiteName();
    asyncBackups.removeIf(xSiteBackup -> localSiteName.equals(xSiteBackup.getSiteName()));
    if (log.isTraceEnabled()) {
        String b = asyncBackups.stream().map(XSiteBackup::getSiteName).collect(Collectors.joining(", "));
        log.tracef("Async remote sites found: %s", b);
    }
    hasClear = false;
}
Also used : Transport(org.infinispan.remoting.transport.Transport) Start(org.infinispan.factories.annotations.Start)

Example 20 with Start

use of org.infinispan.factories.annotations.Start in project infinispan by infinispan.

the class DefaultTakeOfflineManager method start.

@Start
public void start() {
    String localSiteName = rpcManager.getTransport().localSiteName();
    config.sites().allBackupsStream().filter(bc -> !localSiteName.equals(bc.site())).forEach(bc -> {
        String siteName = bc.site();
        OfflineStatus offline = new OfflineStatus(bc.takeOffline(), timeService, new Listener(siteName));
        offlineStatus.put(siteName, offline);
    });
}
Also used : XSiteResponse(org.infinispan.remoting.transport.XSiteResponse) LogFactory(org.infinispan.util.logging.LogFactory) SiteStatusListener(org.infinispan.xsite.notification.SiteStatusListener) TakeOfflineConfiguration(org.infinispan.configuration.cache.TakeOfflineConfiguration) TimeoutException(java.util.concurrent.TimeoutException) MBeanMetadata(org.infinispan.factories.impl.MBeanMetadata) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Start(org.infinispan.factories.annotations.Start) Scopes(org.infinispan.factories.scopes.Scopes) EventLogCategory(org.infinispan.util.logging.events.EventLogCategory) Map(java.util.Map) Log(org.infinispan.util.logging.Log) Scope(org.infinispan.factories.scopes.Scope) CacheUnreachableException(org.infinispan.remoting.CacheUnreachableException) XSiteBackup(org.infinispan.xsite.XSiteBackup) EventLogger(org.infinispan.util.logging.events.EventLogger) InternalDataContainer(org.infinispan.container.impl.InternalDataContainer) EventLogManager(org.infinispan.util.logging.events.EventLogManager) CacheConfigurationException(org.infinispan.commons.CacheConfigurationException) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) RpcManager(org.infinispan.remoting.rpc.RpcManager) MESSAGES(org.infinispan.util.logging.events.Messages.MESSAGES) Inject(org.infinispan.factories.annotations.Inject) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) MetricUtils(org.infinispan.metrics.impl.MetricUtils) Configuration(org.infinispan.configuration.cache.Configuration) OfflineStatus(org.infinispan.xsite.OfflineStatus) Optional(java.util.Optional) RemoteException(org.infinispan.remoting.RemoteException) UnreachableException(org.jgroups.UnreachableException) TimeService(org.infinispan.commons.time.TimeService) SuspectException(org.infinispan.remoting.transport.jgroups.SuspectException) SiteStatusListener(org.infinispan.xsite.notification.SiteStatusListener) OfflineStatus(org.infinispan.xsite.OfflineStatus) Start(org.infinispan.factories.annotations.Start)

Aggregations

Start (org.infinispan.factories.annotations.Start)31 Configuration (org.infinispan.configuration.cache.Configuration)7 Inject (org.infinispan.factories.annotations.Inject)7 Scope (org.infinispan.factories.scopes.Scope)7 Scopes (org.infinispan.factories.scopes.Scopes)7 Log (org.infinispan.util.logging.Log)7 LogFactory (org.infinispan.util.logging.LogFactory)7 CompletionStage (java.util.concurrent.CompletionStage)6 TimeService (org.infinispan.commons.time.TimeService)6 HashSet (java.util.HashSet)5 List (java.util.List)5 Transaction (javax.transaction.Transaction)5 CommandsFactory (org.infinispan.commands.CommandsFactory)5 PutKeyValueCommand (org.infinispan.commands.write.PutKeyValueCommand)5 GlobalConfiguration (org.infinispan.configuration.global.GlobalConfiguration)5 InvocationContext (org.infinispan.context.InvocationContext)5 FlagBitSets (org.infinispan.context.impl.FlagBitSets)5 KeyPartitioner (org.infinispan.distribution.ch.KeyPartitioner)5 ComponentRef (org.infinispan.factories.impl.ComponentRef)5 Transport (org.infinispan.remoting.transport.Transport)5