Search in sources :

Example 1 with ClientEndpoint

use of com.hazelcast.client.ClientEndpoint in project hazelcast by hazelcast.

the class ClientHeartbeatMonitor method run.

@Override
public void run() {
    String memberUuid = clientEngine.getThisUuid();
    for (ClientEndpoint ce : clientEndpointManager.getEndpoints()) {
        ClientEndpointImpl clientEndpoint = (ClientEndpointImpl) ce;
        monitor(memberUuid, clientEndpoint);
    }
}
Also used : StringUtil.timeToString(com.hazelcast.util.StringUtil.timeToString) ClientEndpoint(com.hazelcast.client.ClientEndpoint)

Example 2 with ClientEndpoint

use of com.hazelcast.client.ClientEndpoint in project hazelcast by hazelcast.

the class ClientReAuthOperation method run.

@Override
public void run() throws Exception {
    ClientEngineImpl engine = getService();
    String memberUuid = getCallerUuid();
    if (!engine.trySetLastAuthenticationCorrelationId(clientUuid, authCorrelationId)) {
        String message = "Server already processed a newer authentication from client with uuid " + clientUuid + ". Not applying requested ownership change to " + memberUuid;
        getLogger().info(message);
        throw new AuthenticationException(message);
    }
    Set<ClientEndpoint> endpoints = engine.getEndpointManager().getEndpoints(clientUuid);
    for (ClientEndpoint endpoint : endpoints) {
        ClientPrincipal principal = new ClientPrincipal(clientUuid, memberUuid);
        endpoint.authenticated(principal);
    }
    String previousMemberUuid = engine.addOwnershipMapping(clientUuid, memberUuid);
    clientDisconnectOperationRun = previousMemberUuid == null;
}
Also used : ClientEngineImpl(com.hazelcast.client.impl.ClientEngineImpl) AuthenticationException(com.hazelcast.client.AuthenticationException) ClientEndpoint(com.hazelcast.client.ClientEndpoint) ClientPrincipal(com.hazelcast.client.impl.client.ClientPrincipal)

Example 3 with ClientEndpoint

use of com.hazelcast.client.ClientEndpoint in project hazelcast by hazelcast.

the class ClientEndpointManagerImpl method getEndpoints.

@Override
public Set<ClientEndpoint> getEndpoints(String clientUuid) {
    checkNotNull(clientUuid, "clientUuid can't be null");
    Set<ClientEndpoint> endpointSet = new HashSet<ClientEndpoint>();
    for (ClientEndpoint endpoint : endpoints.values()) {
        if (clientUuid.equals(endpoint.getUuid())) {
            endpointSet.add(endpoint);
        }
    }
    return endpointSet;
}
Also used : ClientEndpoint(com.hazelcast.client.ClientEndpoint) HashSet(java.util.HashSet)

Example 4 with ClientEndpoint

use of com.hazelcast.client.ClientEndpoint in project hazelcast by hazelcast.

the class CacheAddNearCacheInvalidationListenerTask method call.

@Override
protected Object call() {
    ClientEndpoint endpoint = getEndpoint();
    CacheService cacheService = getService(CacheService.SERVICE_NAME);
    CacheContext cacheContext = cacheService.getOrCreateCacheContext(parameters.name);
    NearCacheInvalidationListener listener = new NearCacheInvalidationListener(endpoint, cacheContext, nodeEngine.getLocalMember().getUuid());
    String registrationId = cacheService.addInvalidationListener(parameters.name, listener, parameters.localOnly);
    endpoint.addListenerDestroyAction(CacheService.SERVICE_NAME, parameters.name, registrationId);
    return registrationId;
}
Also used : ClientEndpoint(com.hazelcast.client.ClientEndpoint) CacheContext(com.hazelcast.cache.impl.CacheContext) CacheService(com.hazelcast.cache.impl.CacheService)

Example 5 with ClientEndpoint

use of com.hazelcast.client.ClientEndpoint in project hazelcast by hazelcast.

the class CacheAddPartitionLostListenerMessageTask method call.

@Override
protected Object call() {
    final ClientEndpoint endpoint = getEndpoint();
    CachePartitionLostListener listener = new CachePartitionLostListener() {

        @Override
        public void partitionLost(CachePartitionLostEvent event) {
            if (endpoint.isAlive()) {
                ClientMessage eventMessage = CacheAddPartitionLostListenerCodec.encodeCachePartitionLostEvent(event.getPartitionId(), event.getMember().getUuid());
                sendClientMessage(null, eventMessage);
            }
        }
    };
    InternalCachePartitionLostListenerAdapter listenerAdapter = new InternalCachePartitionLostListenerAdapter(listener);
    EventFilter filter = new CachePartitionLostEventFilter();
    CacheService service = getService(CacheService.SERVICE_NAME);
    EventService eventService = service.getNodeEngine().getEventService();
    EventRegistration registration;
    if (parameters.localOnly) {
        registration = eventService.registerLocalListener(ICacheService.SERVICE_NAME, parameters.name, filter, listenerAdapter);
    } else {
        registration = eventService.registerListener(ICacheService.SERVICE_NAME, parameters.name, filter, listenerAdapter);
    }
    String registrationId = registration.getId();
    endpoint.addListenerDestroyAction(CacheService.SERVICE_NAME, parameters.name, registrationId);
    return registrationId;
}
Also used : CachePartitionLostListener(com.hazelcast.cache.impl.event.CachePartitionLostListener) EventRegistration(com.hazelcast.spi.EventRegistration) CachePartitionLostEvent(com.hazelcast.cache.impl.event.CachePartitionLostEvent) EventService(com.hazelcast.spi.EventService) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) ClientEndpoint(com.hazelcast.client.ClientEndpoint) CachePartitionLostEventFilter(com.hazelcast.cache.impl.event.CachePartitionLostEventFilter) CachePartitionLostEventFilter(com.hazelcast.cache.impl.event.CachePartitionLostEventFilter) EventFilter(com.hazelcast.spi.EventFilter) InternalCachePartitionLostListenerAdapter(com.hazelcast.cache.impl.event.InternalCachePartitionLostListenerAdapter) CacheService(com.hazelcast.cache.impl.CacheService) ICacheService(com.hazelcast.cache.impl.ICacheService)

Aggregations

ClientEndpoint (com.hazelcast.client.ClientEndpoint)21 CacheService (com.hazelcast.cache.impl.CacheService)4 Data (com.hazelcast.nio.serialization.Data)4 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)3 ItemListener (com.hazelcast.core.ItemListener)3 EventRegistration (com.hazelcast.spi.EventRegistration)3 EventService (com.hazelcast.spi.EventService)3 InternalOperationService (com.hazelcast.spi.impl.operationservice.InternalOperationService)3 CacheContext (com.hazelcast.cache.impl.CacheContext)2 ClientEngineImpl (com.hazelcast.client.impl.ClientEngineImpl)2 OperationFactoryWrapper (com.hazelcast.client.impl.operations.OperationFactoryWrapper)2 CollectionEventFilter (com.hazelcast.collection.impl.collection.CollectionEventFilter)2 MapService (com.hazelcast.map.impl.MapService)2 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)2 EventFilter (com.hazelcast.spi.EventFilter)2 InvocationBuilder (com.hazelcast.spi.InvocationBuilder)2 OperationFactory (com.hazelcast.spi.OperationFactory)2 ICacheService (com.hazelcast.cache.impl.ICacheService)1 CachePartitionLostEvent (com.hazelcast.cache.impl.event.CachePartitionLostEvent)1 CachePartitionLostEventFilter (com.hazelcast.cache.impl.event.CachePartitionLostEventFilter)1