com.fasterxml.clustermate.service.msg.PutResponse Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of clustermate-service Show documentation
Show all versions of clustermate-service Show documentation
Building blocks for ClusterMate-based services and servers.
The newest version!
package com.fasterxml.clustermate.service.msg;
import com.fasterxml.clustermate.api.EntryKey;
import com.fasterxml.storemate.shared.compress.Compression;
import com.fasterxml.storemate.store.Storable;
/**
* Simple value class used to return information on a successful
* PUT request
*/
public class PutResponse extends CRUDResponseBase
{
public Compression compression;
public long size;
public long storageSize;
public boolean inlined;
public PutResponse() { }
public PutResponse(K key) {
this(key, null);
}
public PutResponse(K key, String msg) {
super(key, msg);
}
protected PutResponse(K key, Storable entry, String msg) {
super(key, msg);
if (entry != null) {
compression = entry.getCompression();
size = entry.getOriginalLength();
if (size == 0L) { // mark it as "not available"
size = -1L;
}
storageSize = entry.getStorageLength();
inlined = !entry.hasExternalData();
}
}
public static PutResponse error(K key, Storable newEntry, String msg) {
return new PutResponse(key, newEntry, msg);
}
public static PutResponse error(K key, String msg) {
return new PutResponse(key, msg);
}
public static PutResponse badCompression(K key, String msg) {
return new PutResponse(key, msg);
}
public static PutResponse badArg(K key, String msg) {
return new PutResponse(key, msg);
}
/**
* Factory method for constructing a response message that indicates
* successful addition of given payload.
*/
public static PutResponse ok(K key, Storable entry) {
return new PutResponse(key, entry, null);
}
}