]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db/src/org/simantics/db/service/XSupport.java
Sync git svn branch with SVN repository r33249.
[simantics/platform.git] / bundles / org.simantics.db / src / org / simantics / db / service / XSupport.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.db.service;\r
13 \r
14 import org.simantics.db.Resource;\r
15 import org.simantics.db.Session;\r
16 import org.simantics.db.WriteOnlyGraph;\r
17 import org.simantics.db.exception.DatabaseException;\r
18 import org.simantics.db.exception.ServiceException;\r
19 import org.simantics.db.request.WriteTraits;\r
20 \r
21 /**\r
22  * @author TUOKSK\r
23  *\r
24  */\r
25 public interface XSupport {\r
26     /**\r
27      * Writes illegal data into the current cluster cluster stream.\r
28      *\r
29      * @param r is resource used to identify cluster. If null then all clusters\r
30      *        streams are corrupted.\r
31      */\r
32     void corruptCluster(Resource r)\r
33     throws DatabaseException;\r
34     /**\r
35      * Creates new cluster proxy for given clusterId.\r
36      * Depending on the cluster id this proxy is valid or invalid.\r
37      *\r
38      * @param clusterId is used to identify cluster.\r
39      * @return index of cluster proxy in cluster table.\r
40      * @throws DatabaseException\r
41      */\r
42     int corruptClusterTable(long clusterId)\r
43     throws DatabaseException;\r
44     /**\r
45      * Flush all modified data in the given cluster stream to server.\r
46      *\r
47      * @param r is resource used to identify cluster. If null then all clusters\r
48      *        streams are flushed.\r
49      */\r
50     void flushCluster(Resource r)\r
51     throws ServiceException;\r
52 \r
53     /**\r
54      * Forcibly breaks underlying connection.\r
55      */\r
56     void breakConnection()\r
57     throws DatabaseException;\r
58     /**\r
59      * Set cluster stream on or off.\r
60      *\r
61      * @param setOff true if cluster stream is turned off\r
62      * @throws DatabaseException\r
63      */\r
64     void setClusterStreamOff(boolean setOff)\r
65     throws DatabaseException;\r
66 \r
67     /**\r
68      * Clears the meta data cache.\r
69      *\r
70      * @return count of meta data entries in cache before clearing\r
71      * @throws DatabaseException\r
72      */\r
73     int clearMetadataCache()\r
74     throws DatabaseException;\r
75     /**\r
76      * Sends commit message to server but does not end transaction.\r
77      * @param wgraph Write graph to ensure that this is called inside transaction.\r
78      *\r
79      */\r
80     <T> void commitAndContinue(WriteOnlyGraph wograph, WriteTraits wtraits);\r
81 \r
82     /**\r
83      * Get cluster's immutable property.\r
84      *\r
85      * @param resource used to get cluster.\r
86      * @return true if cluster is immutable.\r
87      * @throws DatabaseException\r
88      */\r
89     boolean getImmutable(Resource resource)\r
90     throws DatabaseException;\r
91     /**\r
92      * Set cluster's immutable property.\r
93      *\r
94      * @param resource used to get cluster.\r
95      * @param immutable value to set.\r
96      * @throws DatabaseException\r
97      */\r
98     void setImmutable(Resource resource, boolean immutable)\r
99     throws DatabaseException;\r
100 \r
101     /**\r
102      * @param allowImmutableWrites <code>true</code> to allow writing to immutable cluster \r
103      * @param createAsImmutable <code>true</code> to make all created clusters immutable\r
104      */\r
105     void setServiceMode(boolean allowImmutableWrites, boolean createAsImmutable);\r
106 \r
107     /**\r
108      * If resource is acquired from DelayedWriteGraph during delayed write request then\r
109      * this method can be used to convert it to normal resource which can be use in\r
110      * write and write only requests.\r
111      *\r
112      * @param resource to convert.\r
113      * @return converted resource if it was acquired from delayed write request.\r
114      * Otherwise returns input resource.\r
115      */\r
116     Resource convertDelayedResourceToResource(Resource resource);\r
117 \r
118     /**\r
119      * Execute given command on server.\r
120      * @param command\r
121      * @return result of the command\r
122      * @throws DatabaseException\r
123      */\r
124     String execute(String command)\r
125     throws DatabaseException;\r
126     /**\r
127      * Tests cluster functionality.\r
128      * Database session is needed but no layer0.\r
129      * Enables us to test cluster implementation without layer0.\r
130      *\r
131      * @param session\r
132      */\r
133     void testCluster(Session session)\r
134     throws DatabaseException;\r
135 \r
136     /**\r
137      * Writes garbage to server page table and exits server with -1 exit code.\r
138      *\r
139      * @throws DatabaseException\r
140      */\r
141     public void corruptPageTableAndDie()\r
142     throws DatabaseException;\r
143 \r
144     /**\r
145      * Returns clusters known to server.\r
146      * @throws DatabaseException\r
147      */\r
148     public ClusterUID[] listClusters()\r
149     throws DatabaseException;\r
150 \r
151     /**\r
152      * Deletes given cluster from server.\r
153      * @param clusterUID\r
154      * @throws DatabaseException\r
155      */\r
156     public void deleteCluster(ClusterUID clusterUID)\r
157     throws DatabaseException;\r
158     public void purge() throws DatabaseException;\r
159 \r
160     public boolean rolledback();\r
161     \r
162 }\r