Search in sources :

Example 11 with Start

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

the class LocalPublisherManagerImpl method start.

@Start
public void start() {
    // We need to unwrap the cache as a local stream should only deal with BOXED values
    // Any mappings will be provided by the originator node in their intermediate operation stack in the operation itself.
    this.remoteCache = AbstractDelegatingCache.unwrapCache(cacheComponentRef.running()).getAdvancedCache();
    // The iteration caches should only deal with local entries.
    this.cache = remoteCache.withFlags(Flag.CACHE_MODE_LOCAL);
    ClusteringConfiguration clusteringConfiguration = cache.getCacheConfiguration().clustering();
    this.maxSegment = clusteringConfiguration.hash().numSegments();
    updateStrategy(configuration.persistence().usingSegmentedStore());
    persistenceManager.addStoreListener(storeChangeListener);
}
Also used : ClusteringConfiguration(org.infinispan.configuration.cache.ClusteringConfiguration) Start(org.infinispan.factories.annotations.Start)

Example 12 with Start

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

the class DistributionManagerImpl method start.

// Start before RpcManagerImpl
@Start(priority = 8)
@SuppressWarnings("unused")
void start() throws Exception {
    if (log.isTraceEnabled())
        log.tracef("starting distribution manager on %s", getAddress());
    cacheMode = configuration.clustering().cacheMode();
    // We need an extended topology for preload, before the start of StateTransferManagerImpl
    Address localAddress = transport == null ? LocalModeAddress.INSTANCE : transport.getAddress();
    extendedTopology = makeSingletonTopology(cacheMode, keyPartitioner, configuration.clustering().hash().numSegments(), localAddress);
}
Also used : Address(org.infinispan.remoting.transport.Address) LocalModeAddress(org.infinispan.remoting.transport.LocalModeAddress) Start(org.infinispan.factories.annotations.Start)

Example 13 with Start

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

the class CacheNotifierImpl method start.

@Start(priority = 9)
public void start() {
    if (!config.simpleCache()) {
        clusterExecutor = SecurityActions.getClusterExecutor(cache.wired());
    }
    Collection<FilterIndexingServiceProvider> providers = ServiceFinder.load(FilterIndexingServiceProvider.class);
    filterIndexingServiceProviders = new ArrayList<>(providers.size());
    for (FilterIndexingServiceProvider provider : providers) {
        componentRegistry.wireDependencies(provider, false);
        provider.start();
        filterIndexingServiceProviders.add(provider);
    }
}
Also used : FilterIndexingServiceProvider(org.infinispan.notifications.cachelistener.filter.FilterIndexingServiceProvider) Start(org.infinispan.factories.annotations.Start)

Example 14 with Start

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

the class MetricsCollector method start.

@Start
protected void start() {
    baseRegistry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
    baseRegistry.config().meterFilter(new BaseFilter());
    new BaseAdditionalMetrics().bindTo(baseRegistry);
    vendorRegistry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
    vendorRegistry.config().meterFilter(new VendorFilter());
    new VendorAdditionalMetrics().bindTo(vendorRegistry);
    Transport transport = transportRef.running();
    String nodeName = transport != null ? transport.getAddress().toString() : globalConfig.transport().nodeName();
    if (nodeName == null) {
        // TODO [anistor] Maybe we should just ensure a unique node name was set in all tests and also in real life usage, even for local cache managers
        nodeName = generateRandomName();
    // throw new CacheConfigurationException("Node name must always be specified in configuration if metrics are enabled.");
    }
    nodeTag = Tag.of(NODE_TAG_NAME, nodeName);
    if (globalConfig.metrics().namesAsTags()) {
        cacheManagerTag = Tag.of(CACHE_MANAGER_TAG_NAME, globalConfig.cacheManagerName());
    }
}
Also used : PrometheusMeterRegistry(io.micrometer.prometheus.PrometheusMeterRegistry) Transport(org.infinispan.remoting.transport.Transport) Start(org.infinispan.factories.annotations.Start)

Example 15 with Start

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

the class LocalCacheStatus method doHandleTopologyUpdate.

/**
 * Update the cache topology in the LocalCacheStatus and pass it to the CacheTopologyHandler.
 *
 * @return {@code true} if the topology was applied, {@code false} if it was ignored.
 */
private CompletionStage<Boolean> doHandleTopologyUpdate(String cacheName, CacheTopology cacheTopology, AvailabilityMode availabilityMode, int viewId, Address sender, LocalCacheStatus cacheStatus) {
    CacheTopology existingTopology;
    synchronized (cacheStatus) {
        if (cacheTopology == null) {
            // Still, return true because we don't want to re-send the join request.
            return CompletableFutures.completedTrue();
        }
        // Register all persistent UUIDs locally
        registerPersistentUUID(cacheTopology);
        existingTopology = cacheStatus.getCurrentTopology();
        if (existingTopology != null && cacheTopology.getTopologyId() <= existingTopology.getTopologyId()) {
            log.debugf("Ignoring late consistent hash update for cache %s, current topology is %s: %s", cacheName, existingTopology.getTopologyId(), cacheTopology);
            return CompletableFutures.completedFalse();
        }
        if (!updateCacheTopology(cacheName, cacheTopology, viewId, sender, cacheStatus))
            return CompletableFutures.completedFalse();
    }
    CacheTopologyHandler handler = cacheStatus.getHandler();
    ConsistentHash currentCH = cacheTopology.getCurrentCH();
    ConsistentHash pendingCH = cacheTopology.getPendingCH();
    ConsistentHash unionCH;
    if (pendingCH != null) {
        ConsistentHashFactory chf = cacheStatus.getJoinInfo().getConsistentHashFactory();
        switch(cacheTopology.getPhase()) {
            case READ_NEW_WRITE_ALL:
                // When removing members from topology, we have to make sure that the unionCH has
                // owners from pendingCH (which is used as the readCH in this phase) before
                // owners from currentCH, as primary owners must match in readCH and writeCH.
                unionCH = chf.union(pendingCH, currentCH);
                break;
            default:
                unionCH = chf.union(currentCH, pendingCH);
        }
    } else {
        unionCH = null;
    }
    List<PersistentUUID> persistentUUIDs = persistentUUIDManager.mapAddresses(cacheTopology.getActualMembers());
    CacheTopology unionTopology = new CacheTopology(cacheTopology.getTopologyId(), cacheTopology.getRebalanceId(), currentCH, pendingCH, unionCH, cacheTopology.getPhase(), cacheTopology.getActualMembers(), persistentUUIDs);
    boolean updateAvailabilityModeFirst = availabilityMode != AvailabilityMode.AVAILABLE;
    CompletionStage<Void> stage = resetLocalTopologyBeforeRebalance(cacheName, cacheTopology, existingTopology, handler);
    stage = stage.thenCompose(ignored -> {
        unionTopology.logRoutingTableInformation(cacheName);
        if (updateAvailabilityModeFirst && availabilityMode != null) {
            return cacheStatus.getPartitionHandlingManager().setAvailabilityMode(availabilityMode);
        }
        return CompletableFutures.completedNull();
    });
    stage = stage.thenCompose(ignored -> {
        boolean startConflictResolution = cacheTopology.getPhase() == CacheTopology.Phase.CONFLICT_RESOLUTION;
        if (!startConflictResolution && unionCH != null && (existingTopology == null || existingTopology.getRebalanceId() != cacheTopology.getRebalanceId())) {
            // This CH_UPDATE command was sent after a REBALANCE_START command, but arrived first.
            // We will start the rebalance now and ignore the REBALANCE_START command when it arrives.
            log.tracef("This topology update has a pending CH, starting the rebalance now");
            return handler.rebalance(unionTopology);
        } else {
            return handler.updateConsistentHash(unionTopology);
        }
    });
    if (!updateAvailabilityModeFirst) {
        stage = stage.thenCompose(ignored -> cacheStatus.getPartitionHandlingManager().setAvailabilityMode(availabilityMode));
    }
    return stage.thenApply(ignored -> true);
}
Also used : GlobalStateManager(org.infinispan.globalstate.GlobalStateManager) ScheduledFuture(java.util.concurrent.ScheduledFuture) ComponentName(org.infinispan.factories.annotations.ComponentName) LogFactory(org.infinispan.util.logging.LogFactory) CONFIG(org.infinispan.util.logging.Log.CONFIG) Stop(org.infinispan.factories.annotations.Stop) Scopes(org.infinispan.factories.scopes.Scopes) RebalancePhaseConfirmCommand(org.infinispan.commands.topology.RebalancePhaseConfirmCommand) ActionSequencer(org.infinispan.util.concurrent.ActionSequencer) GlobalStateProvider(org.infinispan.globalstate.GlobalStateProvider) MBean(org.infinispan.jmx.annotations.MBean) CompletableFutures(org.infinispan.util.concurrent.CompletableFutures) Map(java.util.Map) Scope(org.infinispan.factories.scopes.Scope) CacheShutdownRequestCommand(org.infinispan.commands.topology.CacheShutdownRequestCommand) ConsistentHash(org.infinispan.distribution.ch.ConsistentHash) CompletionStages.handleAndCompose(org.infinispan.util.concurrent.CompletionStages.handleAndCompose) GlobalComponentRegistry(org.infinispan.factories.GlobalComponentRegistry) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) GlobalStateManagerImpl(org.infinispan.globalstate.impl.GlobalStateManagerImpl) ConsistentHashFactory(org.infinispan.distribution.ch.ConsistentHashFactory) List(java.util.List) CompletionStage(java.util.concurrent.CompletionStage) CLUSTER(org.infinispan.util.logging.Log.CLUSTER) GuardedBy(net.jcip.annotations.GuardedBy) PartitionHandlingManager(org.infinispan.partitionhandling.impl.PartitionHandlingManager) RebalanceStatusRequestCommand(org.infinispan.commands.topology.RebalanceStatusRequestCommand) AvailabilityMode(org.infinispan.partitionhandling.AvailabilityMode) TimeoutException(org.infinispan.util.concurrent.TimeoutException) TIMEOUT_SCHEDULE_EXECUTOR(org.infinispan.factories.KnownComponentNames.TIMEOUT_SCHEDULE_EXECUTOR) CompletableFutures.completedNull(org.infinispan.util.concurrent.CompletableFutures.completedNull) HashMap(java.util.HashMap) Callable(java.util.concurrent.Callable) CompletableFuture(java.util.concurrent.CompletableFuture) CompletionStages(org.infinispan.util.concurrent.CompletionStages) DataType(org.infinispan.jmx.annotations.DataType) Start(org.infinispan.factories.annotations.Start) Version(org.infinispan.commons.util.Version) Log(org.infinispan.util.logging.Log) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) VoidResponseCollector(org.infinispan.remoting.transport.impl.VoidResponseCollector) ExecutorService(java.util.concurrent.ExecutorService) Address(org.infinispan.remoting.transport.Address) ReplicableCommand(org.infinispan.commands.ReplicableCommand) Transport(org.infinispan.remoting.transport.Transport) ScopedPersistentState(org.infinispan.globalstate.ScopedPersistentState) NON_BLOCKING_EXECUTOR(org.infinispan.factories.KnownComponentNames.NON_BLOCKING_EXECUTOR) CacheJoinCommand(org.infinispan.commands.topology.CacheJoinCommand) Inject(org.infinispan.factories.annotations.Inject) TimeUnit(java.util.concurrent.TimeUnit) RebalancePolicyUpdateCommand(org.infinispan.commands.topology.RebalancePolicyUpdateCommand) IllegalLifecycleStateException(org.infinispan.commons.IllegalLifecycleStateException) ManagedAttribute(org.infinispan.jmx.annotations.ManagedAttribute) CacheAvailabilityUpdateCommand(org.infinispan.commands.topology.CacheAvailabilityUpdateCommand) ScopedPersistentStateImpl(org.infinispan.globalstate.impl.ScopedPersistentStateImpl) BlockingManager(org.infinispan.util.concurrent.BlockingManager) Collections(java.util.Collections) TimeService(org.infinispan.commons.time.TimeService) CacheLeaveCommand(org.infinispan.commands.topology.CacheLeaveCommand) SuspectException(org.infinispan.remoting.transport.jgroups.SuspectException) ConsistentHash(org.infinispan.distribution.ch.ConsistentHash) ConsistentHashFactory(org.infinispan.distribution.ch.ConsistentHashFactory)

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