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

com.fasterxml.clustermate.service.sync.SyncListResponse Maven / Gradle / Ivy

There is a newer version: 0.10.5
Show newest version
package com.fasterxml.clustermate.service.sync;

import java.util.*;

import com.fasterxml.jackson.annotation.JsonInclude;

import com.fasterxml.clustermate.api.msg.ClusterStatusMessage;
import com.fasterxml.clustermate.api.msg.ExtensibleType;
import com.fasterxml.clustermate.service.store.StoredEntry;

/**
 * Simple response POJO used by sync end point; used both for failures
 * (for which {@link #message} is non-null) and successes (for which
 * {@link #entries} is non-null.
 *

* NOTE: only used for writing; on reading side we will use a "raw" * approach. */ @JsonInclude(JsonInclude.Include.NON_DEFAULT) public class SyncListResponse> extends ExtensibleType { /** * Error message, if any */ public String message; /** * Highest timestamp observed during processing; may be higher than highest * timestamp of entries returned to reflect skipped entries (or in some * cases known "empty" time ranges) */ public long lastSeenTimestamp; /** * Hash code server calculates over cluster view information. * Caller may pass it to optionally skip generation and inclusion * of unchanged cluster information. */ public long clusterHash; /** * If server returns empty result list, it may also indicate that client * may want to wait for specified amount of time before issuing a new request; * this based on its knowledge of when more data can be available at earliest. * Time is in milliseconds. */ public long clientWait; /** * Optionally included cluster view. */ public ClusterStatusMessage clusterStatus; public List entries; public SyncListResponse() { } public SyncListResponse(String error) { message = error; } public SyncListResponse(List rawEntries) { entries = new ArrayList(rawEntries.size()); for (StoredEntry e : rawEntries) { entries.add(SyncListResponseEntry.valueOf(e)); } } // NOTE: only to be used internally private SyncListResponse(boolean dummy) { entries = Collections.emptyList(); } public SyncListResponse(List rawEntries, long lastSeen, long clusterHash, ClusterStatusMessage clusterStatus) { lastSeenTimestamp = lastSeen; this.clusterStatus = clusterStatus; this.clusterHash = clusterHash; } public static > SyncListResponse emptyResponse() { return new SyncListResponse(false); } public int size() { return (entries == null) ? 0 : entries.size(); } public long lastSeen() { return lastSeenTimestamp; } public SyncListResponse setLastSeenTimestamp(long l) { lastSeenTimestamp = l; return this; } public SyncListResponse setClusterStatus(ClusterStatusMessage s) { clusterStatus = s; return this; } public SyncListResponse setClusterHash(long h) { clusterHash = h; return this; } public SyncListResponse setClientWait(long w) { clientWait = w; return this; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy