org.infinispan.Cache.getCacheManager()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(9.3k)|赞(0)|评价(0)|浏览(148)

本文整理了Java中org.infinispan.Cache.getCacheManager()方法的一些代码示例,展示了Cache.getCacheManager()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cache.getCacheManager()方法的具体详情如下:
包路径:org.infinispan.Cache
类名称:Cache
方法名:getCacheManager

Cache.getCacheManager介绍

暂无

代码示例

代码示例来源:origin: wildfly/wildfly

public AffinityIdentifierFactory(IdentifierFactory<K> factory, Cache<Key<K>, ?> cache, KeyAffinityServiceFactory affinityFactory) {
  this.factory = factory;
  this.affinity = affinityFactory.createService(cache, this);
  this.manager = cache.getCacheManager();
}

代码示例来源:origin: wildfly/wildfly

@Override
public boolean isSingleton() {
  return this.cache.getCacheManager().getTransport() == null;
}

代码示例来源:origin: wildfly/wildfly

@Override
public void close() {
  this.cache.removeListener(this);
  this.cache.getCacheManager().removeListener(this);
  // Cleanup any unregistered listeners
  for (ExecutorService executor : this.listeners.values()) {
    PrivilegedAction<List<Runnable>> action = () -> executor.shutdownNow();
    WildFlySecurityManager.doUnchecked(action);
  }
  this.listeners.clear();
}

代码示例来源:origin: wildfly/wildfly

@Override
public Node getLocalMember() {
  return this.createNode(this.cache.getCacheManager().getAddress());
}

代码示例来源:origin: wildfly/wildfly

@Override
public int hashCode() {
  return this.cache.getCacheManager().getCacheManagerConfiguration().globalJmxStatistics().cacheManagerName().hashCode() ^ this.cache.getName().hashCode();
}

代码示例来源:origin: wildfly/wildfly

@Override
public boolean equals(Object object) {
  if ((object == null) || !(object instanceof InfinispanXAResourceRecovery)) return false;
  InfinispanXAResourceRecovery recovery = (InfinispanXAResourceRecovery) object;
  return this.cache.getCacheManager().getCacheManagerConfiguration().globalJmxStatistics().cacheManagerName().equals(recovery.cache.getCacheManager().getCacheManagerConfiguration().globalJmxStatistics().cacheManagerName()) && this.cache.getName().equals(recovery.cache.getName());
}

代码示例来源:origin: wildfly/wildfly

public CacheGroup(CacheGroupConfiguration config) {
  this.cache = config.getCache();
  this.nodeFactory = config.getMemberFactory();
  this.cache.getCacheManager().addListener(this);
  this.cache.addListener(this);
}

代码示例来源:origin: wildfly/wildfly

@TopologyChanged
public void topologyChanged(TopologyChangedEvent<?, ?> event) {
  if (event.isPre()) return;
  int viewId = event.getCache().getCacheManager().getTransport().getViewId();
  if (!this.listeners.isEmpty()) {
    Address localAddress = event.getCache().getCacheManager().getAddress();
    Membership previousMembership = new CacheMembership(localAddress, event.getWriteConsistentHashAtStart(), this);
    Membership membership = new CacheMembership(localAddress, event.getWriteConsistentHashAtEnd(), this);
    Boolean status = this.views.get(viewId);
    boolean merged = (status != null) ? status.booleanValue() : false;
    for (Map.Entry<GroupListener, ExecutorService> entry : this.listeners.entrySet()) {
      GroupListener listener = entry.getKey();
      ExecutorService executor = entry.getValue();
      try {
        executor.submit(() -> {
          try {
            listener.membershipChanged(previousMembership, membership, merged);
          } catch (Throwable e) {
            ClusteringServerLogger.ROOT_LOGGER.warn(e.getLocalizedMessage(), e);
          }
        });
      } catch (RejectedExecutionException e) {
        // Listener was unregistered
      }
    }
  }
  // Purge obsolete views
  this.views.headMap(viewId).clear();
}

代码示例来源:origin: wildfly/wildfly

@Override
  public String toString() {
    return this.cache.getCacheManager().getCacheManagerConfiguration().globalJmxStatistics().cacheManagerName() + "." + this.cache.getName();
  }
}

代码示例来源:origin: wildfly/wildfly

ClusteringServerLogger.ROOT_LOGGER.registryListenerFailed(e, this.cache.getCacheManager().getCacheManagerConfiguration().globalJmxStatistics().cacheManagerName(), this.cache.getName(), type, entries);

代码示例来源:origin: wildfly/wildfly

@Override
  public <K> KeyAffinityService<K> createService(Cache<K, ?> cache, KeyGenerator<K> generator) {
    CacheMode mode = cache.getCacheConfiguration().clustering().cacheMode();
    return mode.isDistributed() || mode.isReplicated() ? new KeyAffinityServiceImpl<>(executor, cache, generator, bufferSize, Collections.singleton(cache.getCacheManager().getAddress()), false) : new SimpleKeyAffinityService<>(generator);
  }
};

代码示例来源:origin: wildfly/wildfly

ClusteringServerLogger.ROOT_LOGGER.registryPurgeFailed(e, this.cache.getCacheManager().toString(), this.cache.getName(), leftMembers);
ClusteringServerLogger.ROOT_LOGGER.failedToRestoreLocalRegistryEntry(e, this.cache.getCacheManager().toString(), this.cache.getName());

代码示例来源:origin: wildfly/wildfly

@CacheEntryCreated
  @CacheEntryModified
  public void modified(CacheEntryEvent<T, Set<Address>> event) {
    if (event.isPre()) return;
    Map.Entry<Listener, ExecutorService> entry = this.listeners.get(event.getKey());
    if (entry != null) {
      Listener listener = entry.getKey();
      if (listener != null) {
        ExecutorService executor = entry.getValue();
        Set<Node> members = new TreeSet<>();
        for (Address address : event.getValue()) {
          members.add(this.group.createNode(address));
        }
        try {
          executor.submit(() -> {
            try {
              listener.providersChanged(members);
            } catch (Throwable e) {
              ClusteringServerLogger.ROOT_LOGGER.serviceProviderRegistrationListenerFailed(e, this.cache.getCacheManager().getCacheManagerConfiguration().globalJmxStatistics().cacheManagerName(), this.cache.getName(), members);
            }
          });
        } catch (RejectedExecutionException e) {
          // Executor was shutdown
        }
      }
    }
  }
}

代码示例来源:origin: wildfly/wildfly

@Override
public String getName() {
  GlobalConfiguration global = this.cache.getCacheManager().getCacheManagerConfiguration();
  TransportConfiguration transport = global.transport();
  return transport.transport() != null ? transport.clusterName() : global.globalJmxStatistics().cacheManagerName();
}

代码示例来源:origin: wildfly/wildfly

public ConsistentHashLocality(Cache<?, ?> cache, ConsistentHash hash) {
  this.topology = new LocalizedCacheTopology(cache.getCacheConfiguration().clustering().cacheMode(), new CacheTopology(0, 0, hash, null, CacheTopology.Phase.NO_REBALANCE, Collections.emptyList(), Collections.emptyList()), cache.getCacheConfiguration().clustering().hash().keyPartitioner(), cache.getCacheManager().getAddress(), true);
}

代码示例来源:origin: wildfly/wildfly

@Override
public Membership getMembership() {
  if (this.isSingleton()) {
    return new SingletonMembership(this.getLocalMember());
  }
  Transport transport = this.cache.getCacheManager().getTransport();
  DistributionManager dist = this.cache.getAdvancedCache().getDistributionManager();
  return (dist != null) ? new CacheMembership(transport.getAddress(), dist.getCacheTopology(), this) : new CacheMembership(transport, this);
}

代码示例来源:origin: wildfly/wildfly

@Override
  public String locate(String sessionId) {
    DistributionManager dist = this.cache.getAdvancedCache().getDistributionManager();
    Address address = (dist != null) && !this.cache.getCacheConfiguration().clustering().cacheMode().isScattered() ? dist.getCacheTopology().getDistribution(new Key<>(sessionId)).primary() : this.cache.getCacheManager().getAddress();
    Node node = (address != null) ? this.factory.createNode(address) : null;
    Map.Entry<String, Void> entry = (node != null) ? this.registry.getEntry(node) : null;
    if (entry == null) {
      entry = this.registry.getEntry(this.registry.getGroup().getLocalMember());
    }
    return (entry != null) ? entry.getKey() : null;
  }
}

代码示例来源:origin: wildfly/wildfly

public InfinispanBeanManager(InfinispanBeanManagerConfiguration<I, T> configuration, IdentifierFactory<I> identifierFactory, Configuration<BeanKey<I>, BeanEntry<I>, BeanFactory<I, T>> beanConfiguration, Configuration<BeanGroupKey<I>, BeanGroupEntry<I, T>, BeanGroupFactory<I, T>> groupConfiguration) {
  this.filter = configuration.getBeanFilter();
  this.groupFactory = groupConfiguration.getFactory();
  this.beanFactory = beanConfiguration.getFactory();
  this.cache = beanConfiguration.getCache();
  this.properties = configuration.getProperties();
  this.batcher = new InfinispanBatcher(this.cache);
  Address address = this.cache.getCacheManager().getAddress();
  KeyAffinityServiceFactory affinityFactory = configuration.getAffinityFactory();
  KeyGenerator<BeanKey<I>> beanKeyGenerator = () -> beanConfiguration.getFactory().createKey(identifierFactory.createIdentifier());
  this.affinity = affinityFactory.createService(this.cache, beanKeyGenerator);
  this.identifierFactory = () -> this.affinity.getKeyForAddress(address).getId();
  this.registry = configuration.getRegistry();
  this.nodeFactory = configuration.getNodeFactory();
  this.dispatcherFactory = configuration.getCommandDispatcherFactory();
  this.expiration = configuration.getExpirationConfiguration();
  this.passivation = configuration.getPassivationConfiguration();
}

代码示例来源:origin: org.infinispan/infinispan-core

private static NodeController setNodeControllerIn(Cache<Object, Object> cache) {
 NodeController nodeController = new NodeController();
 nodeController.interceptor = new ControlledCommandInterceptor(cache);
 nodeController.topologyManager = BlockingLocalTopologyManager.replaceTopologyManagerDefaultCache(
   cache.getCacheManager());
 return nodeController;
}

代码示例来源:origin: org.infinispan/infinispan-core

private void installNewView(Cache installing, Cache... cachesInView) {
 JGroupsTransport transport = (JGroupsTransport) installing.getCacheManager().getTransport();
 JChannel channel = transport.getChannel();
 org.jgroups.Address[] members = Stream.of(cachesInView)
                    .map(c -> ((JGroupsAddress) address(c)).getJGroupsAddress())
                    .toArray(org.jgroups.Address[]::new);
 View view = View.create(members[0], transport.getViewId() + 1, members);
 ((GMS) channel.getProtocolStack().findProtocol(GMS.class)).installView(view);
}

相关文章