use of com.hazelcast.client.ClientEndpoint in project hazelcast by hazelcast.
the class AbstractInvocationMessageTask method processMessage.
@Override
protected void processMessage() {
final ClientEndpoint endpoint = getEndpoint();
Operation op = prepareOperation();
op.setCallerUuid(endpoint.getUuid());
InvocationBuilder builder = getInvocationBuilder(op).setExecutionCallback(this).setResultDeserialized(false);
builder.invoke();
}
use of com.hazelcast.client.ClientEndpoint in project hazelcast by hazelcast.
the class QueueAddListenerMessageTask method call.
@Override
protected Object call() {
final ClientEndpoint endpoint = getEndpoint();
final QueueService service = getService(QueueService.SERVICE_NAME);
final Data partitionKey = serializationService.toData(parameters.name);
ItemListener listener = new ItemListener() {
@Override
public void itemAdded(ItemEvent item) {
send(item);
}
@Override
public void itemRemoved(ItemEvent item) {
send(item);
}
private void send(ItemEvent event) {
if (endpoint.isAlive()) {
if (!(event instanceof DataAwareItemEvent)) {
throw new IllegalArgumentException("Expecting: DataAwareItemEvent, Found: " + event.getClass().getSimpleName());
}
DataAwareItemEvent dataAwareItemEvent = (DataAwareItemEvent) event;
Data item = dataAwareItemEvent.getItemData();
ClientMessage clientMessage = QueueAddListenerCodec.encodeItemEvent(item, event.getMember().getUuid(), event.getEventType().getType());
sendClientMessage(partitionKey, clientMessage);
}
}
};
String registrationId = service.addItemListener(parameters.name, listener, parameters.includeValue, parameters.localOnly);
endpoint.addListenerDestroyAction(QueueService.SERVICE_NAME, parameters.name, registrationId);
return registrationId;
}
use of com.hazelcast.client.ClientEndpoint in project hazelcast by hazelcast.
the class SetAddListenerMessageTask method call.
@Override
protected Object call() {
ClientEndpoint endpoint = getEndpoint();
Data partitionKey = serializationService.toData(parameters.name);
ItemListener listener = createItemListener(endpoint, partitionKey);
EventService eventService = clientEngine.getEventService();
CollectionEventFilter filter = new CollectionEventFilter(parameters.includeValue);
EventRegistration registration;
if (parameters.localOnly) {
registration = eventService.registerLocalListener(getServiceName(), parameters.name, filter, listener);
} else {
registration = eventService.registerListener(getServiceName(), parameters.name, filter, listener);
}
String registrationId = registration.getId();
endpoint.addListenerDestroyAction(getServiceName(), parameters.name, registrationId);
return registrationId;
}
use of com.hazelcast.client.ClientEndpoint in project hazelcast by hazelcast.
the class TopicAddMessageListenerMessageTask method call.
@Override
protected Object call() throws Exception {
partitionKey = serializationService.toData(parameters.name);
TopicService service = getService(TopicService.SERVICE_NAME);
ClientEndpoint endpoint = getEndpoint();
String registrationId = service.addMessageListener(parameters.name, this, parameters.localOnly);
endpoint.addListenerDestroyAction(TopicService.SERVICE_NAME, parameters.name, registrationId);
return registrationId;
}
use of com.hazelcast.client.ClientEndpoint in project hazelcast by hazelcast.
the class AbstractMultiMapAddEntryListenerMessageTask method call.
@Override
protected Object call() throws Exception {
final ClientEndpoint endpoint = getEndpoint();
final MultiMapService service = getService(MultiMapService.SERVICE_NAME);
EntryAdapter listener = new MultiMapListener();
final String name = getDistributedObjectName();
Data key = getKey();
boolean includeValue = shouldIncludeValue();
String registrationId = service.addListener(name, listener, key, includeValue, isLocalOnly());
endpoint.addListenerDestroyAction(MultiMapService.SERVICE_NAME, name, registrationId);
return registrationId;
}
Aggregations