01: /*
02: * <copyright>
03: *
04: * Copyright 2002-2004 BBNT Solutions, LLC
05: * under sponsorship of the Defense Advanced Research Projects
06: * Agency (DARPA).
07: *
08: * You can redistribute this software and/or modify it under the
09: * terms of the Cougaar Open Source License as published on the
10: * Cougaar Open Source Website (www.cougaar.org).
11: *
12: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
13: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
14: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
15: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
16: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
17: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
18: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23: *
24: * </copyright>
25: */
26:
27: package org.cougaar.core.wp.server;
28:
29: import java.util.Map;
30: import org.cougaar.core.component.Service;
31: import org.cougaar.core.mts.MessageAddress;
32:
33: /**
34: * This service sends "forward"s to replicate leases between servers.
35: * <p>
36: * This API hides the MTS and messaging details. In particular,
37: * the transport selects which WP server(s) the lookups should
38: * be sent to, aggregates results if necessary, and retries any
39: * failed deliveries.
40: * <p>
41: * The service requestor must implement the Client API.
42: */
43: public interface ForwardService extends Service {
44:
45: /**
46: * Forward entries to all our peer servers.
47: * <p>
48: * The map keys are Strings and the values are Forward objects.
49: * <p>
50: * Like the ModifyService, the "forwardAnswer" can send back a
51: * LeaseNotKnown response if the UID is not known (e.g. due to a
52: * server restart), in which case the server should send the full
53: * Record. A LeaseDenied is never sent because this is typically
54: * a race condition -- the remote server's "forward" is likely
55: * on the wire and will correct the sender's tables. Lastly, a
56: * success Lease is not necessary since a lack of acknowledgement
57: * is assumed to be an acceptance of the forwarded data.
58: * <p>
59: * Clients may see temporary inconsistencies due to propagation
60: * delays, but these should be minimal. Races between clients
61: * are resolved by deconflicting the entries based upon the
62: * optional "version" entries in each record.
63: * <p>
64: * Larger inconsistencies may occur due to network partitions or
65: * server crashes. These conflicts are eventually remedied with
66: * the server-side deconfliction code and periodic lease
67: * renewals. Additionally, as an optional optimization, a server
68: * can detect another server's crash and forward a full copy of
69: * its data to that server, by using the other "forward" method.
70: * <p>
71: * It's fine to submit a singleton map, but for efficiency a
72: * client can use this API to batch requests.
73: */
74: void forward(Map m, long ttd);
75:
76: /**
77: * Reply to a "forwardAnswer" LeaseNotKnown by sending a Forward
78: * to our peer.
79: */
80: void forward(MessageAddress target, Map m, long ttd);
81:
82: interface Client {
83: /** Receive the answer to a forward request. */
84: void forwardAnswer(MessageAddress addr, long baseTime, Map m);
85: }
86: }
|