当前位置: 首页>>代码示例>>Java>>正文


Java Cluster类代码示例

本文整理汇总了Java中org.axonframework.eventhandling.Cluster的典型用法代码示例。如果您正苦于以下问题:Java Cluster类的具体用法?Java Cluster怎么用?Java Cluster使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Cluster类属于org.axonframework.eventhandling包,在下文中一共展示了Cluster类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doSelectCluster

import org.axonframework.eventhandling.Cluster; //导入依赖的package包/类
@Override
protected Cluster doSelectCluster(EventListener eventListener, Class<?> listenerType) {
    final String packageName = listenerType.getPackage().getName();
    final Matcher matcher = pattern.matcher(packageName);
    final String group;

    if ( ! matcher.matches()) {
        group = "default";
        LOGGER.error("No cluster name matched from package '{}' using regex '{}'. Using '{}' as default cluster name",
                packageName, pattern, group);
    } else {
        group = matcher.group(1);
    }

    Cluster cluster = cache.get(group);

    if (null == cluster) {
        cluster = clusterFactory.create(group);
        cache.put(group, cluster);
    }

    return cluster;
}
 
开发者ID:viadeo,项目名称:axon-kafka-terminal,代码行数:24,代码来源:ClassnameDynamicClusterSelector.java

示例2: selectCluster_withTwoEventListenersOfTheSameDomain_returnTheSameInstance

import org.axonframework.eventhandling.Cluster; //导入依赖的package包/类
@Test
public void selectCluster_withTwoEventListenersOfTheSameDomain_returnTheSameInstance() throws Exception {
    // Given
    final ClassnameDynamicClusterSelector clusterSelector = initClusterSelector();

    final GroupB.EventListenerB eventListenerB = new GroupB.EventListenerB();
    final GroupB.EventListenerA eventListenerA = new GroupB.EventListenerA();

    // When
    final Cluster cluster1 = clusterSelector.selectCluster(eventListenerB);
    final Cluster cluster2 = clusterSelector.selectCluster(eventListenerA);

    // Then
    assertNotNull(cluster1);
    assertNotNull(cluster2);
    assertSame(cluster1, cluster2);
}
 
开发者ID:viadeo,项目名称:axon-kafka-terminal,代码行数:18,代码来源:ClassnameDynamicClusterSelectorUTest.java

示例3: onClusterCreated_withOneEventListener_createOneCluster

import org.axonframework.eventhandling.Cluster; //导入依赖的package包/类
@Test
public void onClusterCreated_withOneEventListener_createOneCluster() {
    // Given
    final String category = "fooBar";

    final ConsumerConnector consumerConnector = mock(ConsumerConnector.class);

    final ConsumerFactory consumerFactory = mock(ConsumerFactory.class);
    when(consumerFactory.createConnector(category)).thenReturn(consumerConnector);

    final Cluster cluster = mock(Cluster.class);
    when(cluster.getName()).thenReturn(category);
    when(cluster.getMembers()).thenReturn(Sets.<EventListener>newHashSet(mock(EventListener.class)));

    final KafkaTerminal terminal = new KafkaTerminal(consumerFactory, mock(ProducerFactory.class));

    // When
    terminal.onClusterCreated(cluster);

    // Then
    assertEquals(1, terminal.getClusterListeners().size());
}
 
开发者ID:viadeo,项目名称:axon-kafka-terminal,代码行数:23,代码来源:KafkaTerminalUTest.java

示例4: onClusterCreated_withTwoEventListeners_createOneCluster

import org.axonframework.eventhandling.Cluster; //导入依赖的package包/类
@Test
public void onClusterCreated_withTwoEventListeners_createOneCluster() {
    // Given
    final String category = "fooBar";

    final ConsumerConnector consumerConnector = mock(ConsumerConnector.class);

    final ConsumerFactory consumerFactory = mock(ConsumerFactory.class);
    when(consumerFactory.createConnector(category)).thenReturn(consumerConnector);

    final Cluster cluster = mock(Cluster.class);
    when(cluster.getName()).thenReturn(category);
    when(cluster.getMembers()).thenReturn(Sets.<EventListener>newHashSet(mock(EventListener.class), mock(EventListener.class)));

    final KafkaTerminal terminal = new KafkaTerminal(consumerFactory, mock(ProducerFactory.class));

    // When
    terminal.onClusterCreated(cluster);

    // Then
    assertEquals(1, terminal.getClusterListeners().size());
}
 
开发者ID:viadeo,项目名称:axon-kafka-terminal,代码行数:23,代码来源:KafkaTerminalUTest.java

示例5: onApplicationEvent

import org.axonframework.eventhandling.Cluster; //导入依赖的package包/类
@Override
public void onApplicationEvent(final ContextRefreshedEvent event) {
    final ConfigurableApplicationContext context
            = (ConfigurableApplicationContext) event.getSource();
    final Collection<EventProcessingMonitor> monitors
            = beansOfTypeIncludingAncestors(context.getBeanFactory(),
            EventProcessingMonitor.class).values();

    for (final Cluster cluster : beansOfTypeIncludingAncestors(
            context.getBeanFactory(), Cluster.class).values())
        monitors.forEach(cluster::subscribeEventProcessingMonitor);
}
 
开发者ID:binkley,项目名称:axon-spring-boot-starter,代码行数:13,代码来源:EventProcessingMonitorAutomation.java

示例6: KafkaClusterListener

import org.axonframework.eventhandling.Cluster; //导入依赖的package包/类
public KafkaClusterListener(
        final ConsumerFactory consumerFactory,
        final KafkaMetricHelper metricHelper,
        final TopicStrategy topicStrategy,
        final Cluster cluster,
        final int numberOfStreamListener
) {
    checkNotNull(consumerFactory);
    checkNotNull(metricHelper);
    checkNotNull(topicStrategy);
    this.cluster = checkNotNull(cluster);

    checkArgument(numberOfStreamListener > 0, "The number of stream listener must be greater or equal to 1");

    final ThreadFactory threadFactory = new ThreadFactoryBuilder().setNameFormat("event-consumer-" + cluster.getName() + "-%d").build();
    this.executor = Executors.newFixedThreadPool(numberOfStreamListener, threadFactory);

    this.streamListeners = Lists.newArrayList();

    this.consumer = consumerFactory.createConnector(cluster.getName());

    final List<KafkaStream<byte[], EventMessage>> streams = consumerFactory.createStreams(numberOfStreamListener, consumer);
    for (final KafkaStream<byte[], EventMessage> stream : streams) {
        KafkaStreamListener streamListener = new KafkaStreamListener(cluster, stream, metricHelper);
        streamListeners.add(streamListener);
        executor.submit(streamListener);
    }

    LOGGER.debug("Created cluster listener on '{}'", cluster.getName());
}
 
开发者ID:viadeo,项目名称:axon-kafka-terminal,代码行数:31,代码来源:KafkaClusterListener.java

示例7: KafkaStreamListener

import org.axonframework.eventhandling.Cluster; //导入依赖的package包/类
public KafkaStreamListener(
        final Cluster cluster,
        final KafkaStream<byte[], EventMessage> stream,
        final KafkaMetricHelper metricHelper
) {
    this.cluster = checkNotNull(cluster);
    this.stream = checkNotNull(stream);
    this.metricHelper= checkNotNull(metricHelper);
    this.terminateCallback = Optional.absent();
}
 
开发者ID:viadeo,项目名称:axon-kafka-terminal,代码行数:11,代码来源:KafkaClusterListener.java

示例8: onClusterCreated

import org.axonframework.eventhandling.Cluster; //导入依赖的package包/类
@Override
public void onClusterCreated(final Cluster cluster) {
    checkNotNull(cluster);

    final String group = cluster.getName();

    if ( ! clusterListenerByGroup.containsKey(group)) {
        clusterListenerByGroup.put(
                group,
                new KafkaClusterListener(consumerFactory, metricHelper, topicStrategy, cluster, 1)
        );
    }
}
 
开发者ID:viadeo,项目名称:axon-kafka-terminal,代码行数:14,代码来源:KafkaTerminal.java

示例9: selectCluster_withEventListenerB_returnClusterNamedAfterPackageOfListener

import org.axonframework.eventhandling.Cluster; //导入依赖的package包/类
@Test
public void selectCluster_withEventListenerB_returnClusterNamedAfterPackageOfListener() throws Exception {
    // Given
    final ClassnameDynamicClusterSelector clusterSelector = initClusterSelector();

    final GroupB.EventListenerB eventListenerB = new GroupB.EventListenerB();

    // When
    final Cluster cluster = clusterSelector.selectCluster(eventListenerB);

    // Then
    assertNotNull(cluster);
    assertEquals("groupb", cluster.getName());
}
 
开发者ID:viadeo,项目名称:axon-kafka-terminal,代码行数:15,代码来源:ClassnameDynamicClusterSelectorUTest.java

示例10: selectCluster_withEventListenerA_returnClusterNamedAfterPackageOfListener

import org.axonframework.eventhandling.Cluster; //导入依赖的package包/类
@Test
public void selectCluster_withEventListenerA_returnClusterNamedAfterPackageOfListener() throws Exception {
    // Given
    final ClassnameDynamicClusterSelector clusterSelector = initClusterSelector();

    final GroupA.EventListenerA eventListenerA = new GroupA.EventListenerA();

    // When
    final Cluster cluster = clusterSelector.selectCluster(eventListenerA);

    // Then
    assertNotNull(cluster);
    assertEquals("groupa", cluster.getName());
}
 
开发者ID:viadeo,项目名称:axon-kafka-terminal,代码行数:15,代码来源:ClassnameDynamicClusterSelectorUTest.java

示例11: createClusterSelectorFactory

import org.axonframework.eventhandling.Cluster; //导入依赖的package包/类
public static ClusterSelectorFactory createClusterSelectorFactory(final String prefix) {
    return new ClassnameDynamicClusterSelectorFactory(
            prefix,
            new ClusterFactory() {
                @Override
                public Cluster create(final String name) {
                    return new SimpleCluster(name);
                }
            }
    );
}
 
开发者ID:viadeo,项目名称:axon-kafka-terminal,代码行数:12,代码来源:KafkaTerminalITest.java

示例12: onClusterCreated

import org.axonframework.eventhandling.Cluster; //导入依赖的package包/类
@Override
public void onClusterCreated(Cluster cluster) {
    if(m_subscriber != null && m_subscribed.get() == false) {
        m_subscriber.subscribe(m_hzInstance,this);
        m_subscribed.set(true);
    }

    m_clusters.add(cluster);
}
 
开发者ID:lburgazzoli,项目名称:lb-axon,代码行数:10,代码来源:HzEventBusTerminal.java

示例13: publish

import org.axonframework.eventhandling.Cluster; //导入依赖的package包/类
@Override
public void publish(final EventMessage... events) {
    for (final Cluster cluster : clusters)
        cluster.publish(events);
}
 
开发者ID:binkley,项目名称:axon-spring-boot-starter,代码行数:6,代码来源:SimpleEventBusTerminal.java

示例14: onClusterCreated

import org.axonframework.eventhandling.Cluster; //导入依赖的package包/类
@Override
public void onClusterCreated(final Cluster cluster) {
    clusters.add(cluster);
}
 
开发者ID:binkley,项目名称:axon-spring-boot-starter,代码行数:5,代码来源:SimpleEventBusTerminal.java

示例15: simpleCluster

import org.axonframework.eventhandling.Cluster; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean
public Cluster simpleCluster(final OrderResolver orderResolver) {
    return new SimpleCluster(properties.getName(), orderResolver);
}
 
开发者ID:binkley,项目名称:axon-spring-boot-starter,代码行数:6,代码来源:AxonClusterAutoConfiguration.java


注:本文中的org.axonframework.eventhandling.Cluster类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。