01: /**
02: * Copyright (C) 2006 NetMind Consulting Bt.
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 3 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */package hu.netmind.persistence.node;
18:
19: import hu.netmind.persistence.Transaction;
20: import hu.netmind.persistence.SessionInfo;
21: import java.util.List;
22:
23: /**
24: * This is the interface which provides synchronization services
25: * to nodes.
26: * @author Brautigam Robert
27: * @version Revision: $Revision$
28: */
29: public interface ServiceProvider {
30: /**
31: * Get a new serial number.
32: */
33: Long getNextSerial();
34:
35: /**
36: * Send cache update request.
37: */
38: void updateEntries(String tableName, Long serial);
39:
40: /**
41: * Lock an object.
42: * @param index The index of the node.
43: * @param threadId The id of the thread in which the lock operation was initiated.
44: * @param metas The metas to lock.
45: * @param info The session info to attach to lock.
46: * @param wait Number of milliseconds to wait, before lock considered used.
47: * @param ensureCurrent Ensure that the objects described in the metadata list are current.
48: * @return A session info if at least one of the objects if already locked.
49: */
50: SessionInfo lock(int index, long threadId, long txSerial,
51: List metas, SessionInfo info, int wait,
52: boolean ensureCurrent);
53:
54: /**
55: * Unlock objects.
56: */
57: void unlock(int index, long threadId, long txSerial, List metas);
58:
59: /**
60: * Wait for a query to execute with the given serial.
61: * This method returns, if all commits before the given serial
62: * are finished.
63: */
64: void waitForQuery(Long serial);
65:
66: /**
67: * Wait for starting a commit. The commit can start if
68: * there are no queries executed with greater serial.
69: * @return The serial the commit can run with.
70: */
71: Long startCommit(int index);
72:
73: /**
74: * Mark the end of a commit phase.
75: */
76: void endCommit(int index, Long serial);
77:
78: /**
79: * Notify object changes.
80: */
81: void notifyChange(List metas, Long endSerial, Long txSerial);
82: }
|