(this);
}
+
+ @Override
+ public String addPartitionLostListener(CachePartitionLostListener listener) {
+ checkNotNull(listener, "CachePartitionLostListener can't be null");
+ final InternalCachePartitionLostListenerAdapter listenerAdapter =
+ new InternalCachePartitionLostListenerAdapter(listener);
+
+ final EventFilter filter = new CachePartitionLostEventFilter();
+ final ICacheService service = getService();
+ final EventRegistration registration = service.getNodeEngine().getEventService().
+ registerListener(AbstractCacheService.SERVICE_NAME, name, filter, listenerAdapter);
+ return registration.getId();
+ }
+
+ @Override
+ public boolean removePartitionLostListener(String id) {
+ checkNotNull(id, "Listener id should not be null!");
+ final ICacheService service = getService();
+ return service.getNodeEngine().getEventService().
+ deregisterListener(AbstractCacheService.SERVICE_NAME,
+ name, id);
+ }
}
diff --git a/hazelcast/src/main/java/com/hazelcast/cache/impl/client/CacheAddPartitionLostListenerRequest.java b/hazelcast/src/main/java/com/hazelcast/cache/impl/client/CacheAddPartitionLostListenerRequest.java
new file mode 100644
index 000000000000..9fb0cbf1a57e
--- /dev/null
+++ b/hazelcast/src/main/java/com/hazelcast/cache/impl/client/CacheAddPartitionLostListenerRequest.java
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.hazelcast.cache.impl.client;
+
+import com.hazelcast.cache.impl.AbstractCacheService;
+import com.hazelcast.cache.impl.CachePortableHook;
+import com.hazelcast.cache.impl.CacheService;
+import com.hazelcast.cache.impl.ICacheService;
+import com.hazelcast.cache.impl.event.CachePartitionLostEvent;
+import com.hazelcast.cache.impl.event.CachePartitionLostEventFilter;
+import com.hazelcast.cache.impl.event.CachePartitionLostListener;
+import com.hazelcast.cache.impl.event.InternalCachePartitionLostListenerAdapter;
+import com.hazelcast.client.ClientEndpoint;
+import com.hazelcast.client.impl.client.CallableClientRequest;
+import com.hazelcast.client.impl.client.RetryableRequest;
+import com.hazelcast.nio.serialization.PortableReader;
+import com.hazelcast.nio.serialization.PortableWriter;
+import com.hazelcast.spi.EventFilter;
+import com.hazelcast.spi.EventRegistration;
+import com.hazelcast.spi.impl.PortableCachePartitionLostEvent;
+
+import java.io.IOException;
+import java.security.Permission;
+
+public class CacheAddPartitionLostListenerRequest extends CallableClientRequest
+ implements RetryableRequest {
+
+
+ private String name;
+
+ public CacheAddPartitionLostListenerRequest() {
+ }
+
+ public CacheAddPartitionLostListenerRequest(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public Object call() {
+ final ClientEndpoint endpoint = getEndpoint();
+
+ final CachePartitionLostListener listener = new CachePartitionLostListener() {
+ @Override
+ public void partitionLost(CachePartitionLostEvent event) {
+ if (endpoint.isAlive()) {
+ final PortableCachePartitionLostEvent portableEvent =
+ new PortableCachePartitionLostEvent(event.getPartitionId(), event.getMember().getUuid());
+ endpoint.sendEvent(null, portableEvent, getCallId());
+ }
+ }
+ };
+
+ final InternalCachePartitionLostListenerAdapter listenerAdapter =
+ new InternalCachePartitionLostListenerAdapter(listener);
+ final EventFilter filter = new CachePartitionLostEventFilter();
+ final ICacheService service = getService();
+ final EventRegistration registration = service.getNodeEngine().
+ getEventService().registerListener(AbstractCacheService.SERVICE_NAME,
+ name, filter, listenerAdapter);
+ final String registrationId = registration.getId();
+ endpoint.setListenerRegistration(CacheService.SERVICE_NAME, name, registrationId);
+
+ return registrationId;
+ }
+
+
+ @Override
+ public void write(PortableWriter writer) throws IOException {
+ writer.writeUTF("name", name);
+ }
+
+ @Override
+ public void read(PortableReader reader) throws IOException {
+ name = reader.readUTF("name");
+ }
+
+ @Override
+ public String getServiceName() {
+ return ICacheService.SERVICE_NAME;
+ }
+ @Override
+ public String getMethodName() {
+ return "addCachePartitionLostListener";
+ }
+
+ @Override
+ public int getFactoryId() {
+ return CachePortableHook.F_ID;
+ }
+
+ @Override
+ public int getClassId() {
+ return CachePortableHook.ADD_CACHE_PARTITION_LOST_LISTENER;
+ }
+
+ @Override
+ public Permission getRequiredPermission() {
+ return null;
+ }
+
+ @Override
+ public String getDistributedObjectName() {
+ return name;
+ }
+}
diff --git a/hazelcast/src/main/java/com/hazelcast/cache/impl/client/CacheRemovePartitionLostListenerRequest.java b/hazelcast/src/main/java/com/hazelcast/cache/impl/client/CacheRemovePartitionLostListenerRequest.java
new file mode 100644
index 000000000000..69c847bf735e
--- /dev/null
+++ b/hazelcast/src/main/java/com/hazelcast/cache/impl/client/CacheRemovePartitionLostListenerRequest.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.hazelcast.cache.impl.client;
+
+import com.hazelcast.cache.impl.AbstractCacheService;
+import com.hazelcast.cache.impl.CachePortableHook;
+import com.hazelcast.cache.impl.CacheService;
+import com.hazelcast.cache.impl.ICacheService;
+import com.hazelcast.client.impl.client.BaseClientRemoveListenerRequest;
+
+import java.security.Permission;
+
+public class CacheRemovePartitionLostListenerRequest extends BaseClientRemoveListenerRequest {
+
+
+ public CacheRemovePartitionLostListenerRequest() {
+ }
+
+ public CacheRemovePartitionLostListenerRequest(String name, String registrationId) {
+ super(name, registrationId);
+ }
+
+ public Object call() throws Exception {
+ final ICacheService service = getService();
+ return service.getNodeEngine().getEventService().
+ deregisterListener(AbstractCacheService.SERVICE_NAME,
+ name, registrationId);
+ }
+
+ public String getServiceName() {
+ return CacheService.SERVICE_NAME;
+ }
+
+ public int getFactoryId() {
+ return CachePortableHook.F_ID;
+ }
+
+ public int getClassId() {
+ return CachePortableHook.REMOVE_CACHE_PARTITION_LOST_LISTENER;
+ }
+
+ @Override
+ public Permission getRequiredPermission() {
+ return null;
+ }
+
+ @Override
+ public String getMethodName() {
+ return "removeCachePartitionLostListener";
+ }
+}
diff --git a/hazelcast/src/main/java/com/hazelcast/cache/impl/event/AbstractICacheEvent.java b/hazelcast/src/main/java/com/hazelcast/cache/impl/event/AbstractICacheEvent.java
new file mode 100644
index 000000000000..744639ba38ef
--- /dev/null
+++ b/hazelcast/src/main/java/com/hazelcast/cache/impl/event/AbstractICacheEvent.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.hazelcast.cache.impl.event;
+
+import com.hazelcast.cache.impl.CacheEventType;
+import com.hazelcast.core.EntryEventType;
+import com.hazelcast.core.Member;
+
+import java.util.EventObject;
+
+/**
+ * The abstract class for a JCache event {@link com.hazelcast.cache.impl.event.ICacheEvent}.
+ * @since 3.6
+ */
+public abstract class AbstractICacheEvent extends EventObject implements ICacheEvent {
+
+ protected final String name;
+
+ private final CacheEventType cacheEventType;
+
+ private final Member member;
+
+ /**
+ * Constructs a prototypical Cache Event.
+ *
+ * @param source The object on which the Event initially occurred.
+ * @param member The interface to the cluster member (node).
+ * @param eventType The event type as an enum {@link EntryEventType} integer.
+ * @throws IllegalArgumentException if source is null.
+ */
+ public AbstractICacheEvent(Object source, Member member, int eventType) {
+ super(source);
+ this.name = (String) source;
+ this.member = member;
+ this.cacheEventType = CacheEventType.getByType(eventType);
+ }
+
+
+ /**
+ * Returns the object on which the event initially occurred.
+ *
+ * @return The object on which the event initially occurred.
+ */
+ @Override
+ public Object getSource() {
+ return name;
+ }
+
+ /**
+ * Returns the member that fired this event.
+ *
+ * @return The member that fired this event.
+ */
+ @Override
+ public Member getMember() {
+ return member;
+ }
+
+ /**
+ * Returns the event type {@link EntryEventType}.
+ *
+ * @return The event type {@link EntryEventType}.
+ */
+ @Override
+ public CacheEventType getEventType() {
+ return cacheEventType;
+ }
+
+ /**
+ * Returns the name of the cache for this event.
+ *
+ * @return The name of the cache for this event.
+ */
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Returns a String representation of this event.
+ *
+ * @return A String representation of this event.
+ */
+ @Override
+ public String toString() {
+ return String.format("entryEventType=%s, member=%s, name='%s'",
+ cacheEventType, member, name);
+ }
+}
diff --git a/hazelcast/src/main/java/com/hazelcast/cache/impl/event/CachePartitionLostEvent.java b/hazelcast/src/main/java/com/hazelcast/cache/impl/event/CachePartitionLostEvent.java
new file mode 100644
index 000000000000..428879dbd352
--- /dev/null
+++ b/hazelcast/src/main/java/com/hazelcast/cache/impl/event/CachePartitionLostEvent.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.hazelcast.cache.impl.event;
+
+import com.hazelcast.core.Member;
+
+/**
+ * Used for providing information about the lost partition for a cache
+ *
+ * @see CachePartitionLostEvent
+ * @since 3.6
+ */
+public class CachePartitionLostEvent extends AbstractICacheEvent {
+
+ private static final long serialVersionUID = -7445714640964238109L;
+
+ private final int partitionId;
+
+ public CachePartitionLostEvent(Object source, Member member, int eventType, int partitionId) {
+ super(source, member, eventType);
+ this.partitionId = partitionId;
+ }
+
+ /**
+ * Returns the partition id that has been lost for the given cache
+ *
+ * @return the partition id that has been lost for the given cache
+ */
+ public int getPartitionId() {
+ return partitionId;
+ }
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName() + "{"
+ + super.toString()
+ + ", partitionId=" + partitionId
+ + '}';
+ }
+}
diff --git a/hazelcast/src/main/java/com/hazelcast/cache/impl/event/CachePartitionLostEventFilter.java b/hazelcast/src/main/java/com/hazelcast/cache/impl/event/CachePartitionLostEventFilter.java
new file mode 100644
index 000000000000..a27d07d6d2c2
--- /dev/null
+++ b/hazelcast/src/main/java/com/hazelcast/cache/impl/event/CachePartitionLostEventFilter.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.hazelcast.cache.impl.event;
+
+import com.hazelcast.nio.ObjectDataInput;
+import com.hazelcast.nio.ObjectDataOutput;
+import com.hazelcast.nio.serialization.DataSerializable;
+import com.hazelcast.spi.EventFilter;
+
+import java.io.IOException;
+
+/**
+ * Used to filter partition lost listener events
+ * @since 3.6
+ */
+public class CachePartitionLostEventFilter implements EventFilter, DataSerializable {
+
+ @Override
+ public boolean eval(Object arg) {
+ return false;
+ }
+
+ @Override
+ public void writeData(ObjectDataOutput out) throws IOException {
+ }
+
+ @Override
+ public void readData(ObjectDataInput in) throws IOException {
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return obj instanceof CachePartitionLostEventFilter;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+}
diff --git a/hazelcast/src/main/java/com/hazelcast/cache/impl/event/CachePartitionLostListener.java b/hazelcast/src/main/java/com/hazelcast/cache/impl/event/CachePartitionLostListener.java
new file mode 100644
index 000000000000..4bc13c5b1a0a
--- /dev/null
+++ b/hazelcast/src/main/java/com/hazelcast/cache/impl/event/CachePartitionLostListener.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.hazelcast.cache.impl.event;
+
+import java.util.EventListener;
+
+/**
+ * Invoked when owner and all backups of a partition is lost for a specific cache
+ * @see CachePartitionLostEvent
+ * @since 3.6
+ */
+public interface CachePartitionLostListener extends EventListener {
+
+ /**
+ * Invoked when owner and all backups of a partition is lost for a specific cache
+ *
+ * @param event the event object that contains cache name and lost partition id
+ */
+ void partitionLost(CachePartitionLostEvent event);
+
+}
diff --git a/hazelcast/src/main/java/com/hazelcast/cache/impl/event/ICacheEvent.java b/hazelcast/src/main/java/com/hazelcast/cache/impl/event/ICacheEvent.java
new file mode 100644
index 000000000000..c879e468be80
--- /dev/null
+++ b/hazelcast/src/main/java/com/hazelcast/cache/impl/event/ICacheEvent.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.hazelcast.cache.impl.event;
+
+import com.hazelcast.cache.impl.CacheEventType;
+import com.hazelcast.core.Member;
+
+/**
+ * Cache events common contract.
+ * @since 3.6
+ */
+public interface ICacheEvent {
+
+ /**
+ * Returns the member that fired this event.
+ *
+ * @return the member that fired this event.
+ */
+ Member getMember();
+
+ /**
+ * Return the event type
+ *
+ * @return event type
+ */
+ CacheEventType getEventType();
+
+ /**
+ * Returns the name of the cache for this event.
+ *
+ * @return name of the cache for this event.
+ */
+ String getName();
+
+}
diff --git a/hazelcast/src/main/java/com/hazelcast/cache/impl/event/InternalCachePartitionLostListenerAdapter.java b/hazelcast/src/main/java/com/hazelcast/cache/impl/event/InternalCachePartitionLostListenerAdapter.java
new file mode 100644
index 000000000000..e825016ba7b4
--- /dev/null
+++ b/hazelcast/src/main/java/com/hazelcast/cache/impl/event/InternalCachePartitionLostListenerAdapter.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.hazelcast.cache.impl.event;
+
+import com.hazelcast.cache.impl.CacheEventListener;
+import com.hazelcast.cache.impl.CacheEventType;
+import com.hazelcast.cache.impl.CachePartitionEventData;
+import com.hazelcast.spi.annotation.PrivateApi;
+
+@PrivateApi
+public class InternalCachePartitionLostListenerAdapter implements CacheEventListener {
+
+ private final CachePartitionLostListener partitionLostListener;
+
+ public InternalCachePartitionLostListenerAdapter(CachePartitionLostListener partitionLostListener) {
+ this.partitionLostListener = partitionLostListener;
+ }
+
+ @Override
+ public void handleEvent(Object eventObject) {
+ final CachePartitionEventData eventData = (CachePartitionEventData) eventObject;
+ final CachePartitionLostEvent event = new CachePartitionLostEvent(eventData.getName(),
+ eventData.getMember(), CacheEventType.PARTITION_LOST.getType(),
+ eventData.getPartitionId());
+ partitionLostListener.partitionLost(event);
+ }
+}
diff --git a/hazelcast/src/main/java/com/hazelcast/cache/impl/event/package-info.java b/hazelcast/src/main/java/com/hazelcast/cache/impl/event/package-info.java
new file mode 100644
index 000000000000..0ed23009e7d6
--- /dev/null
+++ b/hazelcast/src/main/java/com/hazelcast/cache/impl/event/package-info.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ *
+ * Event classes to define listenters for JCache other than EntryListener
+ * @since 3.6
+ *
+ */
+package com.hazelcast.cache.impl.event;
diff --git a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/EventMessageConst.java b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/EventMessageConst.java
index c73f8e8da6b3..ec6c564e40f5 100644
--- a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/EventMessageConst.java
+++ b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/EventMessageConst.java
@@ -44,4 +44,6 @@ public final class EventMessageConst {
//ENTERPRISE
public static final int EVENT_QUERYCACHESINGLE = 212;
public static final int EVENT_QUERYCACHEBATCH = 213;
+
+ public static final int EVENT_CACHEPARTITIONLOST = 214;
}
diff --git a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/cache/CacheAddPartitionLostListenerMessageTask.java b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/cache/CacheAddPartitionLostListenerMessageTask.java
new file mode 100644
index 000000000000..ede3c6e109c3
--- /dev/null
+++ b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/cache/CacheAddPartitionLostListenerMessageTask.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.hazelcast.client.impl.protocol.task.cache;
+
+import com.hazelcast.cache.impl.AbstractCacheService;
+import com.hazelcast.cache.impl.CacheService;
+import com.hazelcast.cache.impl.event.CachePartitionLostEvent;
+import com.hazelcast.cache.impl.event.CachePartitionLostEventFilter;
+import com.hazelcast.cache.impl.event.CachePartitionLostListener;
+import com.hazelcast.cache.impl.event.InternalCachePartitionLostListenerAdapter;
+import com.hazelcast.client.ClientEndpoint;
+import com.hazelcast.client.impl.protocol.ClientMessage;
+import com.hazelcast.client.impl.protocol.codec.CacheAddPartitionLostListenerCodec;
+import com.hazelcast.client.impl.protocol.task.AbstractCallableMessageTask;
+import com.hazelcast.instance.Node;
+import com.hazelcast.nio.Connection;
+import com.hazelcast.spi.EventFilter;
+import com.hazelcast.spi.EventRegistration;
+
+import java.security.Permission;
+
+public class CacheAddPartitionLostListenerMessageTask
+ extends AbstractCallableMessageTask {
+
+
+ public CacheAddPartitionLostListenerMessageTask(ClientMessage clientMessage, Node node, Connection connection) {
+ super(clientMessage, node, connection);
+ }
+
+ @Override
+ protected Object call() {
+ final ClientEndpoint endpoint = getEndpoint();
+
+ final 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);
+ }
+ }
+ };
+
+ final InternalCachePartitionLostListenerAdapter listenerAdapter =
+ new InternalCachePartitionLostListenerAdapter(listener);
+ final EventFilter filter = new CachePartitionLostEventFilter();
+ final CacheService service = getService(CacheService.SERVICE_NAME);
+ final EventRegistration registration = service.getNodeEngine().
+ getEventService().registerListener(AbstractCacheService.SERVICE_NAME,
+ parameters.name, filter, listenerAdapter);
+ final String registrationId = registration.getId();
+ endpoint.setListenerRegistration(CacheService.SERVICE_NAME, parameters.name, registrationId);
+ return registrationId;
+
+ }
+
+ @Override
+ protected CacheAddPartitionLostListenerCodec.RequestParameters decodeClientMessage(ClientMessage clientMessage) {
+ return CacheAddPartitionLostListenerCodec.decodeRequest(clientMessage);
+ }
+
+ @Override
+ protected ClientMessage encodeResponse(Object response) {
+ return CacheAddPartitionLostListenerCodec.encodeResponse((String) response);
+ }
+
+ @Override
+ public String getServiceName() {
+ return CacheService.SERVICE_NAME;
+ }
+
+ @Override
+ public String getMethodName() {
+ return "addCachePartitionLostListener";
+ }
+
+ @Override
+ public Object[] getParameters() {
+ return null;
+ }
+
+ @Override
+ public Permission getRequiredPermission() {
+ return null;
+ }
+
+ @Override
+ public String getDistributedObjectName() {
+ return parameters.name;
+ }
+}
diff --git a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/cache/CacheRemovePartitionLostListenerMessageTask.java b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/cache/CacheRemovePartitionLostListenerMessageTask.java
new file mode 100644
index 000000000000..188bdaaecbfc
--- /dev/null
+++ b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/cache/CacheRemovePartitionLostListenerMessageTask.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.hazelcast.client.impl.protocol.task.cache;
+
+import com.hazelcast.cache.impl.AbstractCacheService;
+import com.hazelcast.cache.impl.CacheService;
+import com.hazelcast.cache.impl.ICacheService;
+import com.hazelcast.client.impl.protocol.ClientMessage;
+import com.hazelcast.client.impl.protocol.codec.CacheRemovePartitionLostListenerCodec;
+import com.hazelcast.client.impl.protocol.task.AbstractCallableMessageTask;
+import com.hazelcast.instance.Node;
+import com.hazelcast.nio.Connection;
+
+import java.security.Permission;
+
+public class CacheRemovePartitionLostListenerMessageTask
+ extends AbstractCallableMessageTask {
+
+
+ public CacheRemovePartitionLostListenerMessageTask(ClientMessage clientMessage, Node node, Connection connection) {
+ super(clientMessage, node, connection);
+ }
+
+ @Override
+ protected Object call() {
+ ICacheService service = getService(CacheService.SERVICE_NAME);
+ return service.getNodeEngine().getEventService().deregisterListener(AbstractCacheService.SERVICE_NAME,
+ parameters.name, parameters.registrationId);
+ }
+
+ @Override
+ protected CacheRemovePartitionLostListenerCodec.RequestParameters decodeClientMessage(ClientMessage clientMessage) {
+ return CacheRemovePartitionLostListenerCodec.decodeRequest(clientMessage);
+ }
+
+ @Override
+ protected ClientMessage encodeResponse(Object response) {
+ return CacheRemovePartitionLostListenerCodec.encodeResponse((Boolean) response);
+ }
+
+ @Override
+ public String getServiceName() {
+ return CacheService.SERVICE_NAME;
+ }
+
+ @Override
+ public String getDistributedObjectName() {
+ return parameters.name;
+ }
+
+ @Override
+ public Permission getRequiredPermission() {
+ return null;
+ }
+
+ @Override
+ public String getMethodName() {
+ return "removeCachePartitionLostListener";
+ }
+
+ @Override
+ public Object[] getParameters() {
+ return new Object[]{parameters.registrationId};
+ }
+}
diff --git a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/template/CacheCodecTemplate.java b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/template/CacheCodecTemplate.java
index f87a920e84ae..7c93c1b58015 100644
--- a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/template/CacheCodecTemplate.java
+++ b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/template/CacheCodecTemplate.java
@@ -106,4 +106,11 @@ public interface CacheCodecTemplate {
@Request(id = 25, retryable = true, response = ResponseMessageConst.INTEGER)
void size(String name);
+ @Request(id = 26, retryable = true, response = ResponseMessageConst.STRING,
+ event = EventMessageConst.EVENT_CACHEPARTITIONLOST)
+ void addPartitionLostListener(String name);
+
+ @Request(id = 27, retryable = false, response = ResponseMessageConst.BOOLEAN)
+ void removePartitionLostListener(String name, String registrationId);
+
}
diff --git a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/template/EventResponseTemplate.java b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/template/EventResponseTemplate.java
index 3542a9c2e5b0..69244d36594e 100644
--- a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/template/EventResponseTemplate.java
+++ b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/template/EventResponseTemplate.java
@@ -79,5 +79,7 @@ void Entry(@Nullable Data key, @Nullable Data value, @Nullable Data oldValue, @N
@EventResponse(EventMessageConst.EVENT_QUERYCACHEBATCH)
void QueryCacheBatch(List events, String source, int partitionId);
+ @EventResponse(EventMessageConst.EVENT_CACHEPARTITIONLOST)
+ void CachePartitionLost(int partitionId, String uuid);
}
diff --git a/hazelcast/src/main/java/com/hazelcast/config/CacheConfig.java b/hazelcast/src/main/java/com/hazelcast/config/CacheConfig.java
index a9b4a6bc2053..598b7a7a9245 100644
--- a/hazelcast/src/main/java/com/hazelcast/config/CacheConfig.java
+++ b/hazelcast/src/main/java/com/hazelcast/config/CacheConfig.java
@@ -16,6 +16,9 @@
package com.hazelcast.config;
+import com.hazelcast.config.CacheSimpleConfig.ExpiryPolicyFactoryConfig.DurationConfig;
+import com.hazelcast.config.CacheSimpleConfig.ExpiryPolicyFactoryConfig.TimedExpiryPolicyFactoryConfig;
+import com.hazelcast.config.CacheSimpleConfig.ExpiryPolicyFactoryConfig.TimedExpiryPolicyFactoryConfig.ExpiryPolicyType;
import com.hazelcast.nio.ClassLoaderUtil;
import com.hazelcast.nio.ObjectDataInput;
import com.hazelcast.nio.ObjectDataOutput;
@@ -33,10 +36,8 @@
import javax.cache.expiry.ModifiedExpiryPolicy;
import javax.cache.expiry.TouchedExpiryPolicy;
import java.io.IOException;
-
-import com.hazelcast.config.CacheSimpleConfig.ExpiryPolicyFactoryConfig.TimedExpiryPolicyFactoryConfig;
-import com.hazelcast.config.CacheSimpleConfig.ExpiryPolicyFactoryConfig.DurationConfig;
-import com.hazelcast.config.CacheSimpleConfig.ExpiryPolicyFactoryConfig.TimedExpiryPolicyFactoryConfig.ExpiryPolicyType;
+import java.util.ArrayList;
+import java.util.List;
import static com.hazelcast.config.CacheSimpleConfig.DEFAULT_BACKUP_COUNT;
import static com.hazelcast.config.CacheSimpleConfig.DEFAULT_IN_MEMORY_FORMAT;
@@ -68,7 +69,7 @@ public class CacheConfig
private CacheEvictionConfig evictionConfig = new CacheEvictionConfig();
private WanReplicationRef wanReplicationRef;
-
+ private List partitionLostListenerConfigs;
private String quorumName;
public CacheConfig() {
@@ -95,6 +96,10 @@ public CacheConfig(CompleteConfiguration configuration) {
if (config.wanReplicationRef != null) {
this.wanReplicationRef = new WanReplicationRef(config.wanReplicationRef);
}
+ if (config.partitionLostListenerConfigs != null) {
+ this.partitionLostListenerConfigs = new ArrayList(
+ config.partitionLostListenerConfigs);
+ }
this.quorumName = config.quorumName;
}
}
@@ -144,6 +149,9 @@ public CacheConfig(CacheSimpleConfig simpleConfig) throws Exception {
listenerFactory, filterFactory, isOldValueRequired, synchronous);
addCacheEntryListenerConfiguration(listenerConfiguration);
}
+ for (CachePartitionLostListenerConfig listenerConfig : simpleConfig.getPartitionLostListenerConfigs()) {
+ getPartitionLostListenerConfigs().add(listenerConfig);
+ }
this.quorumName = simpleConfig.getQuorumName();
}
@@ -380,6 +388,28 @@ public CacheConfig setWanReplicationRef(WanReplicationRef wanReplicationRef) {
return this;
}
+ /**
+ * Gets the partition lost listener references added to cache config
+ *
+ * @return List of CachePartitionLostListenerConfig.
+ */
+ public List getPartitionLostListenerConfigs() {
+ if (partitionLostListenerConfigs == null) {
+ partitionLostListenerConfigs = new ArrayList();
+ }
+ return partitionLostListenerConfigs;
+ }
+
+ /**
+ * Sets the Wan target replication reference.
+ *
+ * @param partitionLostListenerConfigs CachePartitionLostListenerConfig list.
+ */
+ public CacheConfig setPartitionLostListenerConfigs(List partitionLostListenerConfigs) {
+ this.partitionLostListenerConfigs = partitionLostListenerConfigs;
+ return this;
+ }
+
/**
* Gets the data type that will be used for storing records.
*
diff --git a/hazelcast/src/main/java/com/hazelcast/config/CachePartitionLostListenerConfig.java b/hazelcast/src/main/java/com/hazelcast/config/CachePartitionLostListenerConfig.java
new file mode 100644
index 000000000000..ad60c1d41816
--- /dev/null
+++ b/hazelcast/src/main/java/com/hazelcast/config/CachePartitionLostListenerConfig.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.hazelcast.config;
+
+import com.hazelcast.cache.impl.event.CachePartitionLostListener;
+
+import java.io.Serializable;
+
+;
+
+/**
+ * Configuration for CachePartitionLostListener
+ * @see CachePartitionLostListener
+ */
+public class CachePartitionLostListenerConfig
+ extends ListenerConfig implements Serializable {
+
+ private CachePartitionLostListenerConfigReadOnly readOnly;
+
+ public CachePartitionLostListenerConfig() {
+ }
+
+ public CachePartitionLostListenerConfig(String className) {
+ super(className);
+ }
+
+ public CachePartitionLostListenerConfig(CachePartitionLostListener implementation) {
+ super(implementation);
+ }
+
+ public CachePartitionLostListenerConfig(CachePartitionLostListenerConfig config) {
+ implementation = config.getImplementation();
+ className = config.getClassName();
+ }
+
+ public CachePartitionLostListenerConfigReadOnly getAsReadOnly() {
+ if (readOnly == null) {
+ readOnly = new CachePartitionLostListenerConfigReadOnly(this);
+ }
+ return readOnly;
+ }
+
+ public CachePartitionLostListener getImplementation() {
+ return (CachePartitionLostListener) implementation;
+ }
+
+ public CachePartitionLostListenerConfig setImplementation(final CachePartitionLostListener implementation) {
+ super.setImplementation(implementation);
+ return this;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ if (!super.equals(o)) {
+ return false;
+ }
+
+ CachePartitionLostListenerConfig that = (CachePartitionLostListenerConfig) o;
+
+ if (className != null ? !className.equals(that.className) : that.className != null) {
+ return false;
+ }
+ return !(implementation != null ? !implementation.equals(that.implementation) : that.implementation != null);
+
+ }
+
+ @Override
+ public int hashCode() {
+ int result = super.hashCode();
+ result = 31 * result + (className != null ? className.hashCode() : 0);
+ result = 31 * result + (implementation != null ? implementation.hashCode() : 0);
+ return result;
+ }
+}
diff --git a/hazelcast/src/main/java/com/hazelcast/config/CachePartitionLostListenerConfigReadOnly.java b/hazelcast/src/main/java/com/hazelcast/config/CachePartitionLostListenerConfigReadOnly.java
new file mode 100644
index 000000000000..4eb7c6a5de49
--- /dev/null
+++ b/hazelcast/src/main/java/com/hazelcast/config/CachePartitionLostListenerConfigReadOnly.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.hazelcast.config;
+
+import com.hazelcast.cache.impl.event.CachePartitionLostListener;
+
+import java.util.EventListener;
+
+/**
+ * Read-Only Configuration for CachePartitionLostListener
+ * @see CachePartitionLostListener
+ */
+public class CachePartitionLostListenerConfigReadOnly
+ extends CachePartitionLostListenerConfig {
+
+ public CachePartitionLostListenerConfigReadOnly(CachePartitionLostListenerConfig config) {
+ super(config);
+ }
+
+ public CachePartitionLostListener getImplementation() {
+ return (CachePartitionLostListener) implementation;
+ }
+
+ public ListenerConfig setClassName(String className) {
+ throw new UnsupportedOperationException("this config is read-only");
+ }
+
+ public ListenerConfig setImplementation(EventListener implementation) {
+ throw new UnsupportedOperationException("this config is read-only");
+ }
+
+ public CachePartitionLostListenerConfig setImplementation(CachePartitionLostListener implementation) {
+ throw new UnsupportedOperationException("this config is read-only");
+ }
+}
diff --git a/hazelcast/src/main/java/com/hazelcast/config/CacheSimpleConfig.java b/hazelcast/src/main/java/com/hazelcast/config/CacheSimpleConfig.java
index 5857a3c0590d..cd301246349c 100644
--- a/hazelcast/src/main/java/com/hazelcast/config/CacheSimpleConfig.java
+++ b/hazelcast/src/main/java/com/hazelcast/config/CacheSimpleConfig.java
@@ -88,6 +88,8 @@ public class CacheSimpleConfig {
private String quorumName;
+ private List partitionLostListenerConfigs;
+
public CacheSimpleConfig(CacheSimpleConfig cacheSimpleConfig) {
this.name = cacheSimpleConfig.name;
this.keyType = cacheSimpleConfig.keyType;
@@ -108,6 +110,8 @@ public CacheSimpleConfig(CacheSimpleConfig cacheSimpleConfig) {
this.evictionConfig = cacheSimpleConfig.evictionConfig;
}
this.wanReplicationRef = cacheSimpleConfig.wanReplicationRef;
+ this.partitionLostListenerConfigs =
+ new ArrayList(cacheSimpleConfig.getPartitionLostListenerConfigs());
this.quorumName = cacheSimpleConfig.quorumName;
}
@@ -503,6 +507,39 @@ public CacheSimpleConfig setQuorumName(String quorumName) {
return this;
}
+ /**
+ * Gets the partition lost listener references added to cache config
+ *
+ * @return List of CachePartitionLostListenerConfig.
+ */
+ public List getPartitionLostListenerConfigs() {
+ if (partitionLostListenerConfigs == null) {
+ partitionLostListenerConfigs = new ArrayList();
+ }
+ return partitionLostListenerConfigs;
+ }
+
+ /**
+ * Sets the PartitionLostListenerConfigs
+ *
+ * @param partitionLostListenerConfigs CachePartitionLostListenerConfig list.
+ */
+ public CacheSimpleConfig setPartitionLostListenerConfigs(
+ List partitionLostListenerConfigs) {
+ this.partitionLostListenerConfigs = partitionLostListenerConfigs;
+ return this;
+ }
+
+ /**
+ * Adds the CachePartitionLostListenerConfig to partitionLostListenerConfigs
+ *
+ * @param listenerConfig CachePartitionLostListenerConfig to be added.
+ */
+ public CacheSimpleConfig addCachePartitionLostListenerConfig(CachePartitionLostListenerConfig listenerConfig) {
+ getPartitionLostListenerConfigs().add(listenerConfig);
+ return this;
+ }
+
/**
* Represents configuration for "ExpiryPolicyFactory".
*/
diff --git a/hazelcast/src/main/java/com/hazelcast/config/ConfigXmlGenerator.java b/hazelcast/src/main/java/com/hazelcast/config/ConfigXmlGenerator.java
index 62f5169b8aff..8d21479765bf 100644
--- a/hazelcast/src/main/java/com/hazelcast/config/ConfigXmlGenerator.java
+++ b/hazelcast/src/main/java/com/hazelcast/config/ConfigXmlGenerator.java
@@ -454,6 +454,9 @@ private void cacheConfigXmlGenerator(StringBuilder xml, Config config) {
wanReplicationConfigXmlGenerator(xml, c.getWanReplicationRef());
+ cachePartitionLostListenerConfigXmlGenerator(xml,
+ c.getPartitionLostListenerConfigs());
+
evictionConfigXmlGenerator(xml, c.getEvictionConfig());
if (c.getQuorumName() != null) {
@@ -464,6 +467,21 @@ private void cacheConfigXmlGenerator(StringBuilder xml, Config config) {
}
}
+ private void cachePartitionLostListenerConfigXmlGenerator(StringBuilder xml, List configs) {
+ if (!configs.isEmpty()) {
+ xml.append("");
+ for (CachePartitionLostListenerConfig c : configs) {
+ xml.append("");
+ final String clazz = c.getImplementation()
+ != null ? c.getImplementation().getClass().getName() : c.getClassName();
+ xml.append(clazz);
+ xml.append("");
+ }
+ xml.append("");
+ }
+ }
+
+
private void mapPartitionStrategyConfigXmlGenerator(StringBuilder xml, MapConfig m) {
if (m.getPartitioningStrategyConfig() != null) {
xml.append("");
diff --git a/hazelcast/src/main/java/com/hazelcast/config/XmlConfigBuilder.java b/hazelcast/src/main/java/com/hazelcast/config/XmlConfigBuilder.java
index 98187b5cc087..0c5e29fab36c 100644
--- a/hazelcast/src/main/java/com/hazelcast/config/XmlConfigBuilder.java
+++ b/hazelcast/src/main/java/com/hazelcast/config/XmlConfigBuilder.java
@@ -1033,6 +1033,8 @@ private void handleCache(final org.w3c.dom.Node node)
cacheConfig.setEvictionConfig(getEvictionConfig(n));
} else if ("quorum-ref".equals(nodeName)) {
cacheConfig.setQuorumName(value);
+ } else if ("partition-lost-listeners".equals(nodeName)) {
+ cachePartitionLostListenerHandle(n, cacheConfig);
}
}
this.config.addCacheConfig(cacheConfig);
@@ -1170,6 +1172,16 @@ private void cacheWanReplicationRefHandle(Node n, CacheSimpleConfig cacheConfig)
cacheConfig.setWanReplicationRef(wanReplicationRef);
}
+ private void cachePartitionLostListenerHandle(Node n, CacheSimpleConfig cacheConfig) {
+ for (org.w3c.dom.Node listenerNode : new IterableNodeList(n.getChildNodes())) {
+ if ("partition-lost-listener".equals(cleanNodeName(listenerNode))) {
+ String listenerClass = getTextContent(listenerNode);
+ cacheConfig.addCachePartitionLostListenerConfig(
+ new CachePartitionLostListenerConfig(listenerClass));
+ }
+ }
+ }
+
private void cacheListenerHandle(Node n, CacheSimpleConfig cacheSimpleConfig) {
for (org.w3c.dom.Node listenerNode : new IterableNodeList(n.getChildNodes())) {
if ("cache-entry-listener".equals(cleanNodeName(listenerNode))) {
diff --git a/hazelcast/src/main/java/com/hazelcast/spi/impl/PortableCachePartitionLostEvent.java b/hazelcast/src/main/java/com/hazelcast/spi/impl/PortableCachePartitionLostEvent.java
new file mode 100644
index 000000000000..44a9d9563a61
--- /dev/null
+++ b/hazelcast/src/main/java/com/hazelcast/spi/impl/PortableCachePartitionLostEvent.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.hazelcast.spi.impl;
+
+import com.hazelcast.nio.serialization.Portable;
+import com.hazelcast.nio.serialization.PortableReader;
+import com.hazelcast.nio.serialization.PortableWriter;
+
+import java.io.IOException;
+
+public class PortableCachePartitionLostEvent implements Portable {
+
+ private int partitionId;
+
+ private String uuid;
+
+ public PortableCachePartitionLostEvent() {
+ }
+
+ public PortableCachePartitionLostEvent(int partitionId, String uuid) {
+ this.partitionId = partitionId;
+ this.uuid = uuid;
+ }
+
+ public int getPartitionId() {
+ return partitionId;
+ }
+
+ public String getUuid() {
+ return uuid;
+ }
+
+ @Override
+ public int getFactoryId() {
+ return SpiPortableHook.ID;
+ }
+
+ @Override
+ public int getClassId() {
+ return SpiPortableHook.CACHE_PARTITION_LOST_EVENT;
+ }
+
+ @Override
+ public void writePortable(PortableWriter writer)
+ throws IOException {
+ writer.writeInt("p", partitionId);
+ writer.writeUTF("u", uuid);
+
+ }
+
+ @Override
+ public void readPortable(PortableReader reader)
+ throws IOException {
+ partitionId = reader.readInt("p");
+ uuid = reader.readUTF("u");
+ }
+}
diff --git a/hazelcast/src/main/java/com/hazelcast/spi/impl/SpiPortableHook.java b/hazelcast/src/main/java/com/hazelcast/spi/impl/SpiPortableHook.java
index b105af866446..4de7218ad86f 100644
--- a/hazelcast/src/main/java/com/hazelcast/spi/impl/SpiPortableHook.java
+++ b/hazelcast/src/main/java/com/hazelcast/spi/impl/SpiPortableHook.java
@@ -39,6 +39,7 @@ public final class SpiPortableHook implements PortableHook {
public static final int DISTRIBUTED_OBJECT_EVENT = 5;
public static final int MAP_PARTITION_LOST_EVENT = 6;
public static final int PARTITION_LOST_EVENT = 7;
+ public static final int CACHE_PARTITION_LOST_EVENT = 8;
@Override
public int getFactoryId() {
@@ -64,6 +65,8 @@ public Portable create(int classId) {
return new PortableMapPartitionLostEvent();
case PARTITION_LOST_EVENT:
return new PortablePartitionLostEvent();
+ case CACHE_PARTITION_LOST_EVENT:
+ return new PortableCachePartitionLostEvent();
default:
return null;
}
diff --git a/hazelcast/src/main/resources/hazelcast-config-3.6.xsd b/hazelcast/src/main/resources/hazelcast-config-3.6.xsd
index b91a8b353cb4..9a0f98f7c129 100644
--- a/hazelcast/src/main/resources/hazelcast-config-3.6.xsd
+++ b/hazelcast/src/main/resources/hazelcast-config-3.6.xsd
@@ -468,6 +468,7 @@