org.infinispan.iteration.impl.EntryResponseCommand Maven / Gradle / Ivy
package org.infinispan.iteration.impl;
import org.infinispan.commands.TopologyAffectedCommand;
import org.infinispan.commands.remote.BaseRpcCommand;
import org.infinispan.commons.CacheException;
import org.infinispan.container.entries.CacheEntry;
import org.infinispan.context.InvocationContext;
import org.infinispan.factories.annotations.Inject;
import org.infinispan.remoting.transport.Address;
import java.util.Collection;
import java.util.Set;
import java.util.UUID;
/**
* Command sent to respond with entry values for given segments
*
* @author wburns
* @since 7.0
*/
public class EntryResponseCommand extends BaseRpcCommand implements TopologyAffectedCommand {
public static final byte COMMAND_ID = 42;
private UUID identifier;
private Set completedSegments;
private Set inDoubtSegments;
private Collection> values;
private CacheException e;
private int topologyId = -1;
private Address origin;
private EntryRetriever entryRetrieverManager;
// Only here for CommandIdUniquenessTest
private EntryResponseCommand() {
super(null);
}
public EntryResponseCommand(String cacheName) {
super(cacheName);
}
public EntryResponseCommand(Address origin, String cacheName, UUID identifier, Set completedSegments,
Set inDoubtSegments, Collection> values, CacheException e) {
super(cacheName);
this.origin = origin;
this.identifier = identifier;
this.completedSegments = completedSegments;
this.inDoubtSegments = inDoubtSegments;
this.values = values;
this.e = e;
}
@Inject
public void init(EntryRetriever entryRetrieverManager) {
this.entryRetrieverManager = entryRetrieverManager;
}
@Override
public Object perform(InvocationContext ctx) throws Throwable {
entryRetrieverManager.receiveResponse(identifier, origin, completedSegments, inDoubtSegments, values, e);
return null;
}
@Override
public byte getCommandId() {
return COMMAND_ID;
}
@Override
public Object[] getParameters() {
return new Object[]{origin, identifier, completedSegments, inDoubtSegments, values, e, topologyId};
}
@Override
public void setParameters(int commandId, Object[] parameters) {
int i = 0;
origin = (Address) parameters[i++];
identifier = (UUID) parameters[i++];
completedSegments = (Set) parameters[i++];
inDoubtSegments = (Set) parameters[i++];
values = (Collection>)parameters[i++];
e = (CacheException)parameters[i++];
topologyId = (Integer) parameters[i++];
}
@Override
public boolean isReturnValueExpected() {
return false;
}
@Override
public int getTopologyId() {
return topologyId;
}
@Override
public void setTopologyId(int topologyId) {
this.topologyId = topologyId;
}
@Override
public String toString() {
return "EntryResponseCommand{" +
"identifier=" + identifier +
", completedSegments=" + completedSegments +
", inDoubtSegments=" + inDoubtSegments +
", values=" + values +
", topologyId=" + topologyId +
", origin=" + origin +
'}';
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy