import com.hazelcast.nio.ObjectDataInput; import com.hazelcast.nio.ObjectDataOutput; import com.hazelcast.spi.Operation; import com.hazelcast.spi.PartitionAwareOperation; import java.io.IOException; @SuppressWarnings("unused") class IncOperation extends Operation implements PartitionAwareOperation { private String objectId; private int amount; private int returnValue; // it is important to have a no-arg constructor for deserialization public IncOperation() { } IncOperation(String objectId, int amount) { this.amount = amount; this.objectId = objectId; } @Override public void run() throws Exception { System.out.println("Executing " + objectId + ".inc() on: " + getNodeEngine().getThisAddress()); returnValue = 0; } @Override public Object getResponse() { return returnValue; } @Override protected void writeInternal(ObjectDataOutput out) throws IOException { super.writeInternal(out); out.writeUTF(objectId); out.writeInt(amount); } @Override protected void readInternal(ObjectDataInput in) throws IOException { super.readInternal(in); objectId = in.readUTF(); amount = in.readInt(); } }