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


Java EventType类代码示例

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


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

示例1: setEvents

import org.apache.ignite.events.EventType; //导入依赖的package包/类
/**
 * Sets the event types to subscribe to as a comma-separated string of event constants as defined in {@link EventType}.
 * <p>
 * For example: EVT_CACHE_ENTRY_CREATED,EVT_CACHE_OBJECT_REMOVED,EVT_IGFS_DIR_CREATED.
 * 
 * @param events
 */
public void setEvents(String events) {
    this.events = new HashSet<>();
    Set<String> requestedEvents = new HashSet<>(Arrays.asList(events.toUpperCase().split(",")));
    Field[] fields = EventType.class.getDeclaredFields();
    for (Field field : fields) {
        if (!requestedEvents.contains(field.getName())) {
            continue;
        }
        try {
            this.events.add(field.getInt(null));
        } catch (Exception e) {
            throw new IllegalArgumentException("Problem while resolving event type. See stacktrace.", e);
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:IgniteEventsEndpoint.java

示例2: testExecute

import org.apache.ignite.events.EventType; //导入依赖的package包/类
@Test
public void testExecute() {
    TestIgniteComputeResources.COUNTER.set(0);

    startAdditionalGridInstance();
    startAdditionalGridInstance();

    ignite().events().enableLocal(EventType.EVT_JOB_RESULTED);
    LISTENERS.add(ignite().events().remoteListen(null, TestIgniteComputeResources.EVENT_COUNTER, EventType.EVT_JOB_RESULTED));

    // ComputeTask instance.
    String result = template.requestBodyAndHeader("ignite:compute:abc?executionType=EXECUTE", TestIgniteComputeResources.COMPUTE_TASK, IgniteConstants.IGNITE_COMPUTE_PARAMS, 10, String.class);
    assert_().that(result).isNotNull();
    assert_().that(Splitter.on(",").splitToList(result)).containsAllOf("a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9");

    // ComputeTask class.
    result = template.requestBodyAndHeader("ignite:compute:abc?executionType=EXECUTE", TestIgniteComputeResources.COMPUTE_TASK.getClass(), IgniteConstants.IGNITE_COMPUTE_PARAMS, 10, String.class);
    assert_().that(result).isNotNull();
    assert_().that(Splitter.on(",").splitToList(result)).containsAllOf("a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9");
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:IgniteComputeTest.java

示例3: getConfiguration

import org.apache.ignite.events.EventType; //导入依赖的package包/类
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    cfg.setMarshaller(new BinaryMarshaller());
    cfg.setIncludeEventTypes(EventType.EVTS_CACHE);

    if (getTestIgniteInstanceName(CLIENT_ID).equals(igniteInstanceName))
        cfg.setClientMode(true);
    else {
        CacheConfiguration ccfg = getCacheConfiguration();

        cfg.setCacheConfiguration(ccfg);
    }

    return cfg;
}
 
开发者ID:apache,项目名称:ignite,代码行数:18,代码来源:ClientReconnectAfterClusterRestartTest.java

示例4: waitForEvent

import org.apache.ignite.events.EventType; //导入依赖的package包/类
/**
 *
 * @param p Optional predicate.
 * @param types Event types to wait for.
 * @return Event future.
 */
public <T extends Event> IgniteInternalFuture<T> waitForEvent(@Nullable final IgnitePredicate<T> p,
    @Nullable int... types) {
    final GridFutureAdapter<T> fut = new GridFutureAdapter<>();

    addLocalEventListener(new GridLocalEventListener() {
        @Override public void onEvent(Event evt) {
            if (p == null || p.apply((T)evt)) {
                fut.onDone((T)evt);

                removeLocalEventListener(this);
            }
        }
    }, F.isEmpty(types) ? EventType.EVTS_ALL : types);

    return fut;
}
 
开发者ID:apache,项目名称:ignite,代码行数:23,代码来源:GridEventStorageManager.java

示例5: generateCreateEvents

import org.apache.ignite.events.EventType; //导入依赖的package包/类
/**
 * Generate events for created file or directory.
 *
 * @param createdPaths Created paths.
 * @param file Whether file was created.
 */
private void generateCreateEvents(List<IgfsPath> createdPaths, boolean file) {
    if (evts.isRecordable(EventType.EVT_IGFS_DIR_CREATED)) {
        for (int i = 0; i < createdPaths.size() - 1; i++)
            IgfsUtils.sendEvents(igfsCtx.kernalContext(), createdPaths.get(i),
                EventType.EVT_IGFS_DIR_CREATED);
    }

    IgfsPath leafPath = createdPaths.get(createdPaths.size() - 1);

    if (file) {
        IgfsUtils.sendEvents(igfsCtx.kernalContext(), leafPath, EventType.EVT_IGFS_FILE_CREATED);
        IgfsUtils.sendEvents(igfsCtx.kernalContext(), leafPath, EventType.EVT_IGFS_FILE_OPENED_WRITE);
    }
    else
        IgfsUtils.sendEvents(igfsCtx.kernalContext(), leafPath, EventType.EVT_IGFS_DIR_CREATED);
}
 
开发者ID:apache,项目名称:ignite,代码行数:23,代码来源:IgfsMetaManager.java

示例6: testReconnect

import org.apache.ignite.events.EventType; //导入依赖的package包/类
/**
 * @throws Exception If failed.
 */
public void testReconnect() throws Exception {
    Ignite srv = startGrid("server");

    IgniteEvents evts = srv.events();

    evts.enableLocal(EventType.EVTS_DISCOVERY_ALL);
    evts.localListen(new IgnitePredicate<Event>() {
        @Override public boolean apply(Event evt) {
            ClusterNode node = ((DiscoveryEvent)evt).eventNode();

            rejoinAttr = node.attribute("test");

            return true;
        }
    }, EventType.EVT_NODE_JOINED);

    Ignite client = startGrid("client");

    reconnectClientNode(log, client, srv, null);

    assertEquals("2", rejoinAttr);
}
 
开发者ID:apache,项目名称:ignite,代码行数:26,代码来源:TcpDiscoveryNodeAttributesUpdateOnReconnectTest.java

示例7: getConfiguration

import org.apache.ignite.events.EventType; //导入依赖的package包/类
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    int idx = getTestIgniteInstanceIndex(igniteInstanceName);

    if (idx == 0) {
        Map<IgnitePredicate<? extends Event>, int[]> lsnrs = new HashMap<>();

        lsnrs.put(new IgnitePredicate<Event>() {
            @Override public boolean apply(Event evt) {
                fired.countDown();

                return true;
            }
        }, new int[] { EventType.EVT_NODE_JOINED } );

        cfg.setLocalEventListeners(lsnrs);
    }

    return cfg;
}
 
开发者ID:apache,项目名称:ignite,代码行数:23,代码来源:GridLocalEventListenerSelfTest.java

示例8: addDisconnectListener

import org.apache.ignite.events.EventType; //导入依赖的package包/类
protected void addDisconnectListener(
    final CountDownLatch disconnectedLatch,
    final CountDownLatch reconnectedLatch
) {
    grid(nodeClient).events().localListen(new IgnitePredicate<Event>() {
        @Override public boolean apply(Event event) {
            switch (event.type()) {
                case EventType.EVT_CLIENT_NODE_DISCONNECTED:
                    info("Client disconnected");

                    disconnectedLatch.countDown();

                    break;
                case EventType.EVT_CLIENT_NODE_RECONNECTED:
                    info("Client reconnected");

                    reconnectedLatch.countDown();
            }

            return true;
        }
    }, EventType.EVT_CLIENT_NODE_DISCONNECTED, EventType.EVT_CLIENT_NODE_RECONNECTED);
}
 
开发者ID:apache,项目名称:ignite,代码行数:24,代码来源:IgniteAbstractStandByClientReconnectTest.java

示例9: getConfiguration

import org.apache.ignite.events.EventType; //导入依赖的package包/类
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);

    ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setForceServerMode(true);

    int[] evtTypes = cfg.getIncludeEventTypes();

    if (evtTypes == null || evtTypes.length == 0)
        cfg.setIncludeEventTypes(EventType.EVT_CACHE_OBJECT_READ);
    else {
        for (int evtType : evtTypes) {
            if (evtType == EventType.EVT_CACHE_OBJECT_READ)
                return cfg;
        }

        int[] updatedEvtTypes = Arrays.copyOf(evtTypes, evtTypes.length + 1);

        updatedEvtTypes[updatedEvtTypes.length - 1] = EventType.EVT_CACHE_OBJECT_READ;
    }

    return cfg;
}
 
开发者ID:apache,项目名称:ignite,代码行数:26,代码来源:GridCacheAbstractFullApiSelfTest.java

示例10: doTransformResourceInjection

import org.apache.ignite.events.EventType; //导入依赖的package包/类
/**
 * @param ignite Node.
 * @param cache Cache.
 * @param async Use async API.
 * @param oldAsync Use old async API.
 * @throws Exception If failed.
 */
private void doTransformResourceInjection(Ignite ignite, IgniteCache<String, Integer> cache, boolean async,
    boolean oldAsync) throws Exception {
    final Collection<ResourceType> required = Arrays.asList(ResourceType.IGNITE_INSTANCE,
        ResourceType.CACHE_NAME,
        ResourceType.LOGGER);

    final CacheEventListener lsnr = new CacheEventListener();

    IgniteEvents evts = ignite.events(ignite.cluster());

    UUID opId = evts.remoteListen(lsnr, null, EventType.EVT_CACHE_OBJECT_READ);

    try {
        checkResourceInjectionOnInvoke(cache, required, async, oldAsync);

        checkResourceInjectionOnInvokeAll(cache, required, async, oldAsync);

        checkResourceInjectionOnInvokeAllMap(cache, required, async, oldAsync);
    }
    finally {
        evts.stopRemoteListen(opId);
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:31,代码来源:GridCacheAbstractFullApiSelfTest.java

示例11: cacheEvents

import org.apache.ignite.events.EventType; //导入依赖的package包/类
/**
 * Converts comma-delimited cache events strings to Ignite internal representation.
 *
 * @param evtPropsStr Comma-delimited cache event names.
 * @return Ignite internal representation of cache events to be registered with the remote listener.
 * @throws Exception If error.
 */
private int[] cacheEvents(String evtPropsStr) throws Exception {
    String[] evtStr = evtPropsStr.split("\\s*,\\s*");

    if (evtStr.length == 0)
        return EventType.EVTS_CACHE;

    int[] evts = new int[evtStr.length];

    try {
        for (int i = 0; i < evtStr.length; i++)
            evts[i] = CacheEvt.valueOf(evtStr[i].toUpperCase()).getId();
    }
    catch (Exception e) {
        log.error("Failed to recognize the provided cache event!", e);

        throw new Exception(e);
    }
    return evts;
}
 
开发者ID:apache,项目名称:ignite,代码行数:27,代码来源:IgniteSourceTask.java

示例12: expectJoinEvents

import org.apache.ignite.events.EventType; //导入依赖的package包/类
/**
 * @param ignite     Node.
 * @param joinEvtCnt Expected events number.
 * @return Events latch.
 */
protected CountDownLatch expectJoinEvents(Ignite ignite, int joinEvtCnt) {
    final CountDownLatch latch = new CountDownLatch(joinEvtCnt);

    ignite.events().remoteListen(new IgniteBiPredicate<UUID, Event>() {
        @Override
        public boolean apply(UUID uuid, Event evt) {
            latch.countDown();
            return true;
        }
    }, null, EventType.EVT_NODE_JOINED);

    return latch;
}
 
开发者ID:aalda,项目名称:ignite-redis,代码行数:19,代码来源:TcpDiscoveryIpFinderBaseTest.java

示例13: IgniteEventsEndpoint

import org.apache.ignite.events.EventType; //导入依赖的package包/类
public IgniteEventsEndpoint(String uri, URI remainingUri, Map<String, Object> parameters, IgniteComponent igniteComponent) {
    super(uri, igniteComponent);

    // Initialize subscribed event types with ALL.
    events = new HashSet<>();
    for (Integer eventType : EventType.EVTS_ALL) {
        events.add(eventType);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:10,代码来源:IgniteEventsEndpoint.java

示例14: buildComponent

import org.apache.ignite.events.EventType; //导入依赖的package包/类
protected IgniteComponent buildComponent() {
    IgniteConfiguration config = new IgniteConfiguration();
    config.setGridName(UUID.randomUUID().toString());
    config.setIncludeEventTypes(EventType.EVT_JOB_FINISHED, EventType.EVT_JOB_RESULTED);
    config.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(LOCAL_IP_FINDER));
    
    return IgniteComponent.fromConfiguration(config);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:AbstractIgniteTest.java

示例15: testConsumeAllEvents

import org.apache.ignite.events.EventType; //导入依赖的package包/类
@Test
public void testConsumeAllEvents() throws Exception {
    context.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("ignite:events:abc").to("mock:test1");
        }
    });

    getMockEndpoint("mock:test1").expectedMinimumMessageCount(9);

    IgniteCache<String, String> cache = ignite().getOrCreateCache("abc");

    // Generate cache activity.
    cache.put("abc", "123");
    cache.get("abc");
    cache.remove("abc");
    cache.withExpiryPolicy(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.MILLISECONDS, 100)).create()).put("abc", "123");

    Thread.sleep(150);

    cache.get("abc");

    assertMockEndpointsSatisfied();

    List<Integer> eventTypes = receivedEventTypes("mock:test1");

    assert_().that(eventTypes).containsAllOf(EventType.EVT_CACHE_STARTED, EventType.EVT_CACHE_ENTRY_CREATED, EventType.EVT_CACHE_OBJECT_PUT, EventType.EVT_CACHE_OBJECT_READ,
            EventType.EVT_CACHE_OBJECT_REMOVED, EventType.EVT_CACHE_OBJECT_PUT, EventType.EVT_CACHE_OBJECT_EXPIRED, EventType.EVT_CACHE_OBJECT_READ).inOrder();

}
 
开发者ID:HydAu,项目名称:Camel,代码行数:32,代码来源:IgniteEventsTest.java


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