Package com.hazelcast.spi

Examples of com.hazelcast.spi.EventService


    private void sendMigrationEvent(final MigrationInfo migrationInfo, final MigrationStatus status) {
        MemberImpl current = getMember(migrationInfo.getSource());
        MemberImpl newOwner = getMember(migrationInfo.getDestination());
        MigrationEvent event = new MigrationEvent(migrationInfo.getPartitionId(), current, newOwner, status);
        EventService eventService = nodeEngine.getEventService();
        Collection<EventRegistration> registrations = eventService.getRegistrations(SERVICE_NAME, SERVICE_NAME);
        eventService.publishEvent(SERVICE_NAME, registrations, event, event.getPartitionId());
    }
View Full Code Here


        eventService.publishEvent(SERVICE_NAME, registrations, event, event.getPartitionId());
    }

    @Override
    public String addMigrationListener(MigrationListener listener) {
        EventService eventService = nodeEngine.getEventService();
        EventRegistration registration = eventService.registerListener(SERVICE_NAME, SERVICE_NAME, listener);
        return registration.getId();
    }
View Full Code Here

        return registration.getId();
    }

    @Override
    public boolean removeMigrationListener(String registrationId) {
        EventService eventService = nodeEngine.getEventService();
        return eventService.deregisterListener(SERVICE_NAME, SERVICE_NAME, registrationId);
    }
View Full Code Here

        }
        final MapServiceContext mapServiceContext = mapService.getMapServiceContext();
        MapEventPublisher mapEventPublisher = mapServiceContext.getMapEventPublisher();
        String serviceName = mapServiceContext.serviceName();
        InMemoryFormat format = mapContainer.getMapConfig().getInMemoryFormat();
        EventService eventService = mapServiceContext.getNodeEngine().getEventService();
        if (eventService.hasEventRegistration(serviceName, name)) {
            if (format == InMemoryFormat.OBJECT && eventType != EntryEventType.REMOVED) {
                oldValue = null;
            }
            mapService.getMapServiceContext().getMapEventPublisher().
                    publishEvent(getCallerAddress(), name, eventType, dataKey, mapServiceContext.toData(oldValue), dataValue);
View Full Code Here

    @Override
    public void setListenerRegistration(final String service, final String topic, final String id) {
        removeListenerActions.add(new Runnable() {
            @Override
            public void run() {
                EventService eventService = clientEngine.getEventService();
                eventService.deregisterListener(service, topic, id);
            }
        });
    }
View Full Code Here

    public String addClientListener(ClientListener clientListener) {
        if (clientListener == null) {
            throw new NullPointerException("clientListener should not be null");
        }

        EventService eventService = nodeEngine.getEventService();
        EventRegistration registration = eventService.registerLocalListener(
                ClientEngineImpl.SERVICE_NAME, ClientEngineImpl.SERVICE_NAME, clientListener);
        return registration.getId();
    }
View Full Code Here

    public boolean removeClientListener(String registrationId) {
        if (registrationId == null) {
            throw new NullPointerException("registrationId should not be null");
        }

        EventService eventService = nodeEngine.getEventService();
        return eventService.deregisterListener(
                ClientEngineImpl.SERVICE_NAME, ClientEngineImpl.SERVICE_NAME, registrationId);
    }
View Full Code Here

    }

    @Override
    public void run() {
        final MapServiceContext mapServiceContext = mapService.getMapServiceContext();
        final EventService eventService = getNodeEngine().getEventService();
        recordStore.unlock(dataKey, ownerUuid, threadId);
        Record record = recordStore.getRecordOrNull(dataKey);
        if (record == null || version == record.getVersion()) {
            if (eventService.hasEventRegistration(MapService.SERVICE_NAME, getName())) {
                dataOldValue = record == null ? null : mapServiceContext.toData(record.getValue());
            }
            eventType = record == null ? EntryEventType.ADDED : EntryEventType.UPDATED;
            recordStore.set(dataKey, dataValue, ttl);
            shouldBackup = true;
View Full Code Here

        HazelcastInstance instance2 = Hazelcast.newHazelcastInstance();

        instance1.getLifecycleService().terminate();
        instance1 = Hazelcast.newHazelcastInstance();

        final EventService eventService1 = TestUtil.getNode(instance1).nodeEngine.getEventService();
        final EventService eventService2 = TestUtil.getNode(instance2).nodeEngine.getEventService();

        assertTrueEventually(new AssertTask() {
            @Override
            public void run() throws Exception {
                Collection<EventRegistration> regs1 = eventService1.getRegistrations(MapService.SERVICE_NAME, mapName);
                Collection<EventRegistration> regs2 = eventService2.getRegistrations(MapService.SERVICE_NAME, mapName);

                assertEquals("there should be only one registration", 1, regs1.size());
                assertEquals("there should be only one registration", 1, regs2.size());
            }
        }, 10);
View Full Code Here

        return new MapEntrySimple(key, value);
    }

    protected boolean hasRegisteredListenerForThisMap() {
        final String serviceName = mapService.getMapServiceContext().serviceName();
        final EventService eventService = getNodeEngine().getEventService();
        return eventService.hasEventRegistration(serviceName, name);
    }
View Full Code Here

TOP

Related Classes of com.hazelcast.spi.EventService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.