All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fasterxml.clustermate.service.msg.PutResponse Maven / Gradle / Ivy

There is a newer version: 0.10.5
Show 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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy